mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 09:04:38 +00:00
Merge pull request #1606 from marauder2k9-torque/AssimpImportFixes
Some checks failed
Linux Build / ${{matrix.config.name}} (map[build_type:Release cc:gcc cxx:g++ generator:Ninja name:Ubuntu Latest GCC]) (push) Has been cancelled
MacOSX Build / ${{matrix.config.name}} (map[build_type:Release cc:clang cxx:clang++ generator:Ninja name:MacOSX Latest Clang]) (push) Has been cancelled
Windows Build / ${{matrix.config.name}} (map[build_type:Release cc:cl cxx:cl environment_script:C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat generator:Visual Studio 17 2022 name:Windows Latest MSVC]) (push) Has been cancelled
Some checks failed
Linux Build / ${{matrix.config.name}} (map[build_type:Release cc:gcc cxx:g++ generator:Ninja name:Ubuntu Latest GCC]) (push) Has been cancelled
MacOSX Build / ${{matrix.config.name}} (map[build_type:Release cc:clang cxx:clang++ generator:Ninja name:MacOSX Latest Clang]) (push) Has been cancelled
Windows Build / ${{matrix.config.name}} (map[build_type:Release cc:cl cxx:cl environment_script:C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat generator:Visual Studio 17 2022 name:Windows Latest MSVC]) (push) Has been cancelled
Assimp Import Axis
This commit is contained in:
commit
9f29bee45f
4 changed files with 67 additions and 3 deletions
2
.github/workflows/build-macos-clang.yml
vendored
2
.github/workflows/build-macos-clang.yml
vendored
|
|
@ -20,7 +20,7 @@ jobs:
|
||||||
build-linux:
|
build-linux:
|
||||||
if: github.repository == 'TorqueGameEngines/Torque3D'
|
if: github.repository == 'TorqueGameEngines/Torque3D'
|
||||||
name: ${{matrix.config.name}}
|
name: ${{matrix.config.name}}
|
||||||
runs-on: macos-13
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,11 @@ MatrixF AssimpAppNode::getTransform(F32 time)
|
||||||
// no parent (ie. root level) => scale by global shape <unit>
|
// no parent (ie. root level) => scale by global shape <unit>
|
||||||
mLastTransform.identity();
|
mLastTransform.identity();
|
||||||
mLastTransform.scale(ColladaUtils::getOptions().unit * ColladaUtils::getOptions().formatScaleFactor);
|
mLastTransform.scale(ColladaUtils::getOptions().unit * ColladaUtils::getOptions().formatScaleFactor);
|
||||||
ColladaUtils::convertTransform(mLastTransform);
|
if (!isBounds())
|
||||||
|
{
|
||||||
|
MatrixF axisFix = ColladaUtils::getOptions().axisCorrectionMat;
|
||||||
|
mLastTransform.mulL(axisFix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this node is animated in the active sequence, fetch the animated transform
|
// If this node is animated in the active sequence, fetch the animated transform
|
||||||
|
|
|
||||||
|
|
@ -380,7 +380,66 @@ void AssimpShapeLoader::getRootAxisTransform()
|
||||||
meta->Get("CoordAxis", coordAxis);
|
meta->Get("CoordAxis", coordAxis);
|
||||||
meta->Get("CoordAxisSign", coordSign);
|
meta->Get("CoordAxisSign", coordSign);
|
||||||
|
|
||||||
ColladaUtils::getOptions().upAxis = (domUpAxisType)upAxis;
|
switch (upAxis)
|
||||||
|
{
|
||||||
|
case 0: ColladaUtils::getOptions().upAxis = UPAXISTYPE_X_UP; break;
|
||||||
|
case 1: ColladaUtils::getOptions().upAxis = UPAXISTYPE_Y_UP; break;
|
||||||
|
case 2: ColladaUtils::getOptions().upAxis = UPAXISTYPE_Z_UP; break;
|
||||||
|
default: ColladaUtils::getOptions().upAxis = UPAXISTYPE_Y_UP; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MatrixF rot(true);
|
||||||
|
|
||||||
|
// ===== Y-UP SOURCE =====
|
||||||
|
if (upAxis == 1)
|
||||||
|
{
|
||||||
|
if (frontAxis == 2)
|
||||||
|
{
|
||||||
|
// Y-up, Z-forward → Z-up, Y-forward
|
||||||
|
// Rotate 180° Y, then 90° X
|
||||||
|
rot(0, 0) = -1.0f;
|
||||||
|
rot(1, 1) = 0.0f; rot(2, 1) = 1.0f;
|
||||||
|
rot(1, 2) = 1.0f; rot(2, 2) = 0.0f;
|
||||||
|
}
|
||||||
|
else if (frontAxis == 0)
|
||||||
|
{
|
||||||
|
// Y-up, X-forward → Z-up, Y-forward
|
||||||
|
// Rotate -90° around Z then 90° around X
|
||||||
|
rot(0, 0) = 0.0f; rot(0, 1) = -1.0f;
|
||||||
|
rot(1, 0) = 1.0f; rot(1, 1) = 0.0f;
|
||||||
|
rot(2, 2) = 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== Z-UP SOURCE =====
|
||||||
|
if (upAxis == 2)
|
||||||
|
{
|
||||||
|
if (frontAxis == 1)
|
||||||
|
{
|
||||||
|
// Already Z-up, Y-forward → no change
|
||||||
|
}
|
||||||
|
else if (frontAxis == 0)
|
||||||
|
{
|
||||||
|
// Z-up, X-forward → rotate -90° around Z
|
||||||
|
rot(0, 0) = 0.0f; rot(0, 1) = -1.0f;
|
||||||
|
rot(1, 0) = 1.0f; rot(1, 1) = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== X-UP SOURCE =====
|
||||||
|
if (upAxis == 0)
|
||||||
|
{
|
||||||
|
if (frontAxis == 2)
|
||||||
|
{
|
||||||
|
// X-up, Z-forward → Z-up, Y-forward
|
||||||
|
// Rotate -90° around Y then -90° around Z
|
||||||
|
rot(0, 0) = 0.0f; rot(0, 1) = 0.0f; rot(0, 2) = -1.0f;
|
||||||
|
rot(1, 0) = 1.0f; rot(1, 1) = 0.0f; rot(1, 2) = 0.0f;
|
||||||
|
rot(2, 0) = 0.0f; rot(2, 1) = -1.0f; rot(2, 2) = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColladaUtils::getOptions().axisCorrectionMat = rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssimpShapeLoader::processAnimations()
|
void AssimpShapeLoader::processAnimations()
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@ namespace ColladaUtils
|
||||||
eAnimTimingType animTiming; // How to import timing data as frames, seconds or milliseconds
|
eAnimTimingType animTiming; // How to import timing data as frames, seconds or milliseconds
|
||||||
S32 animFPS; // FPS value to use if timing is set in frames and the animations does not have an fps set
|
S32 animFPS; // FPS value to use if timing is set in frames and the animations does not have an fps set
|
||||||
F32 formatScaleFactor; // Scale factor applied to convert the shape format default unit to meters
|
F32 formatScaleFactor; // Scale factor applied to convert the shape format default unit to meters
|
||||||
|
MatrixF axisCorrectionMat;
|
||||||
|
|
||||||
ImportOptions()
|
ImportOptions()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue