@@ -79,9 +79,6 @@ struct ImportFbxContext
7979
8080 // Each ImportedFbxStack has a cache of all anim layers present in that animation stack
8181 std::vector<ImportedFbxStack> animationStacks;
82-
83- // paths to files loaded on import
84- PXR_NS::VtArray<std::string> filenames;
8582};
8683
8784// Metadata on USD will be stored uniformily in the CustomLayerData dictionary.
@@ -1133,7 +1130,7 @@ importFbxMaterials(ImportFbxContext& ctx)
11331130 normalizePathFromAnyOS (fileTexture->GetRelativeFileName ());
11341131
11351132 // Add the path to the metadata even if the file is not present on disk.
1136- ctx.filenames . push_back (filePathNormalized.u8string ());
1133+ ctx.usd -> importedFileNames . insert (filePathNormalized.u8string ());
11371134
11381135 std::filesystem::path absFilePath;
11391136 if (isAbsolutePathFromAnyOS (filePathNormalized)) {
@@ -1183,7 +1180,7 @@ importFbxMaterials(ImportFbxContext& ctx)
11831180 } else {
11841181 std::ifstream file (absFileName, std::ios::binary);
11851182 if (!file.is_open ()) {
1186- TF_RUNTIME_ERROR (" Failed to open file \" %s\" " , absFileName.c_str ());
1183+ TF_WARN (" Failed to open file \" %s\" " , absFileName.c_str ());
11871184 continue ;
11881185 }
11891186 file.seekg (0 , file.end );
@@ -1401,11 +1398,14 @@ importFbxLight(ImportFbxContext& ctx, FbxNodeAttribute* attribute, int parent)
14011398 LightType usdType;
14021399 float coneAngle = 0 ;
14031400 float coneFalloff = 0 ;
1401+ float radius = 0.5 ;
14041402 switch (fbxLight->LightType .Get ()) {
14051403 case FbxLight::ePoint:
14061404 type = " sphere (from FBX point light)" ;
14071405 usdType = LightType::Sphere;
14081406
1407+ radius = DEFAULT_POINT_LIGHT_RADIUS;
1408+
14091409 break ;
14101410 case FbxLight::eDirectional:
14111411 type = " sun (from FBX directional light)" ;
@@ -1416,12 +1416,21 @@ importFbxLight(ImportFbxContext& ctx, FbxNodeAttribute* attribute, int parent)
14161416 type = " disk (from FBX spot light)" ;
14171417 usdType = LightType::Disk;
14181418
1419- // According to FBX specs, inner angle is "HotSpot". In USD, this translates to the
1420- // USDLuxShapingAPI ConeAngleAttribute
1421- coneAngle = fbxLight->InnerAngle .Get ();
1422- // According to FBX specs, outer angle is falloff. In USD, this translates to the
1423- // USDLuxShapingAPI ConeSoftnessAttribute
1424- coneFalloff = fbxLight->OuterAngle .Get ();
1419+ radius = DEFAULT_SPOT_LIGHT_RADIUS;
1420+
1421+ // FBX inner cone angle is from the center to where falloff begins, and outer cone
1422+ // angle is from the center to where falloff ends. Meanwhile, in USD, angle is from
1423+ // the center to the edge of the cone, and softness is a number from 0 to 1 indicating
1424+ // how close to the center the falloff begins.
1425+
1426+ // USD's cone angle is the entire shape of the spot light, corresponding to FBX's
1427+ // outer angle
1428+ coneAngle = fbxLight->OuterAngle .Get ();
1429+
1430+ // Get the fraction of the cone containing the falloff
1431+ if (fbxLight->OuterAngle .Get ()) {
1432+ coneFalloff = 1 - (fbxLight->InnerAngle .Get () / fbxLight->OuterAngle .Get ());
1433+ }
14251434
14261435 break ;
14271436 case FbxLight::eArea:
@@ -1478,8 +1487,10 @@ importFbxLight(ImportFbxContext& ctx, FbxNodeAttribute* attribute, int parent)
14781487
14791488 // TODO: Extract FBX light radius and replace this temporary dummy value with it. When this is
14801489 // updated, please update corresponding unit tests as well
1481- light.radius = 0.5 ;
1482- TF_WARN (" importFbxLight: ignoring FBX light radius, setting radius=0.5\n " );
1490+ light.radius = radius;
1491+ TF_WARN (" importFbxLight: ignoring FBX light radius for light of type %s, setting radius=%f\n " ,
1492+ type.c_str (),
1493+ radius);
14831494
14841495 return true ;
14851496}
@@ -2133,6 +2144,12 @@ importFbx(const ImportFbxOptions& options, Fbx& fbx, UsdData& usd)
21332144 ctx.scene = fbx.scene ;
21342145 ctx.originalColorSpace = options.originalColorSpace ;
21352146
2147+ // Include the FBX file name itself in the filenames we add to the metadata
2148+ {
2149+ std::string baseName = TfGetBaseName (fbx.filename );
2150+ usd.importedFileNames .emplace (std::move (baseName));
2151+ }
2152+
21362153 importMetadata (ctx);
21372154 importFbxSettings (ctx);
21382155
@@ -2149,10 +2166,6 @@ importFbx(const ImportFbxOptions& options, Fbx& fbx, UsdData& usd)
21492166 setSkeletonParents (ctx);
21502167 }
21512168
2152- if (!ctx.filenames .empty ()) {
2153- usd.metadata .SetValueAtPath (" filenames" , VtValue (ctx.filenames ));
2154- }
2155-
21562169 return true ;
21572170}
21582171}
0 commit comments