Skip to content

Commit

Permalink
Fix USD up axis (#1110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meakk authored Dec 21, 2023
1 parent bf9227b commit e5dee4f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ if(F3D_PLUGIN_BUILD_OCCT)
endif()

if(F3D_PLUGIN_BUILD_USD)
f3d_test(NAME TestUSD DATA suzanne.usd ARGS --load-plugins=usd --up=+Z DEFAULT_LIGHTS)
f3d_test(NAME TestUSD DATA suzanne.usd ARGS --load-plugins=usd DEFAULT_LIGHTS)
f3d_test(NAME TestUSDAPrimitives DATA primitives.usda ARGS --load-plugins=usd DEFAULT_LIGHTS)
f3d_test(NAME TestUSDAPrimitivesZAxis DATA primitivesZ.usda ARGS --load-plugins=usd DEFAULT_LIGHTS)
f3d_test(NAME TestUSDAInstancing DATA instancing.usda ARGS --load-plugins=usd DEFAULT_LIGHTS)
Expand Down
19 changes: 17 additions & 2 deletions plugins/usd/module/vtkF3DUSDImporter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class vtkF3DUSDImporter::vtkInternals
pxr::UsdGeomXform xform = pxr::UsdGeomXform(prim);

auto mat = this->GetLocalTransform(xform, timeCode);
vtkMatrix4x4::Multiply4x4(currentMatrix, mat, mat);

this->ImportNode(renderer, prim.GetPrototype(), path.AppendChild(prim.GetName()), mat);
}
Expand Down Expand Up @@ -539,8 +540,22 @@ class vtkF3DUSDImporter::vtkInternals
pxr::UsdSkelBakeSkinning(this->Stage->Traverse());
this->Stage->Save();

vtkNew<vtkMatrix4x4> identity;
this->ImportNode(renderer, this->Stage->GetPseudoRoot(), pxr::SdfPath("/"), identity);
vtkNew<vtkMatrix4x4> rootTransform;

pxr::TfToken up = pxr::UsdGeomGetStageUpAxis(this->Stage);

if (up == pxr::UsdGeomTokens->z)
{
vtkWarningWithObjectMacro(
renderer, << "This USD file up axis is +Z, internally rotate it to align with +Y axis");
rootTransform->Zero();
rootTransform->SetElement(0, 0, 1.0);
rootTransform->SetElement(1, 2, 1.0);
rootTransform->SetElement(2, 1, -1.0);
rootTransform->SetElement(3, 3, 1.0);
}

this->ImportNode(renderer, this->Stage->GetPseudoRoot(), pxr::SdfPath("/"), rootTransform);
}

vtkSmartPointer<vtkImageData> CombineORMImage(
Expand Down
4 changes: 2 additions & 2 deletions testing/baselines/TestDefaultConfigFileUSD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions testing/baselines/TestThumbnailConfigFileUSD.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e5dee4f

Please sign in to comment.