mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +00:00
Update assimpShapeLoader.cpp
non destructive fixes for assimp loader -this creates an ambient sequence if 1 does not exist. -adds a bounds node if 1 does not exist.
This commit is contained in:
parent
600a6b8ebc
commit
37dd58dca4
1 changed files with 50 additions and 5 deletions
|
|
@ -229,6 +229,18 @@ void AssimpShapeLoader::enumerateScene()
|
||||||
if (!processNode(node))
|
if (!processNode(node))
|
||||||
delete node;
|
delete node;
|
||||||
|
|
||||||
|
// add bounds node.
|
||||||
|
if (!boundsNode)
|
||||||
|
{
|
||||||
|
aiNode* req[1];
|
||||||
|
req[0] = new aiNode("bounds");
|
||||||
|
mScene->mRootNode->addChildren(1, req);
|
||||||
|
|
||||||
|
AssimpAppNode* appBounds = new AssimpAppNode(mScene, req[0]);
|
||||||
|
if (!processNode(appBounds))
|
||||||
|
delete appBounds;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for animations and process those.
|
// Check for animations and process those.
|
||||||
processAnimations();
|
processAnimations();
|
||||||
}
|
}
|
||||||
|
|
@ -243,13 +255,42 @@ void AssimpShapeLoader::enumerateScene()
|
||||||
|
|
||||||
void AssimpShapeLoader::processAnimations()
|
void AssimpShapeLoader::processAnimations()
|
||||||
{
|
{
|
||||||
|
bool ambient = false;
|
||||||
for(U32 n = 0; n < mScene->mNumAnimations; ++n)
|
for(U32 n = 0; n < mScene->mNumAnimations; ++n)
|
||||||
{
|
{
|
||||||
Con::printf("[ASSIMP] Animation Found: %s", mScene->mAnimations[n]->mName.C_Str());
|
Con::printf("[ASSIMP] Animation Found: %s", mScene->mAnimations[n]->mName.C_Str());
|
||||||
|
|
||||||
|
if (mScene->mAnimations[n]->mName.C_Str() == "ambient")
|
||||||
|
ambient = true;
|
||||||
|
|
||||||
AssimpAppSequence* newAssimpSeq = new AssimpAppSequence(mScene->mAnimations[n]);
|
AssimpAppSequence* newAssimpSeq = new AssimpAppSequence(mScene->mAnimations[n]);
|
||||||
appSequences.push_back(newAssimpSeq);
|
appSequences.push_back(newAssimpSeq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dont have ambient, lets just add everything to an ambient sequence.
|
||||||
|
// we should probably just do this as default.
|
||||||
|
if (!ambient)
|
||||||
|
{
|
||||||
|
aiAnimation* ambientSeq = new aiAnimation();
|
||||||
|
ambientSeq->mName = "ambient";
|
||||||
|
|
||||||
|
Vector<aiNodeAnim*> ambientChannels;
|
||||||
|
|
||||||
|
for (U32 i = 0; i < mScene->mNumAnimations; ++i)
|
||||||
|
{
|
||||||
|
aiAnimation* anim = mScene->mAnimations[i];
|
||||||
|
for (U32 j = 0; j < anim->mNumChannels; j++)
|
||||||
|
{
|
||||||
|
ambientChannels.push_back(anim->mChannels[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ambientSeq->mChannels = ambientChannels.address();
|
||||||
|
|
||||||
|
AssimpAppSequence* defaultAssimpSeq = new AssimpAppSequence(ambientSeq);
|
||||||
|
appSequences.push_back(defaultAssimpSeq);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssimpShapeLoader::computeBounds(Box3F& bounds)
|
void AssimpShapeLoader::computeBounds(Box3F& bounds)
|
||||||
|
|
@ -369,12 +410,16 @@ bool AssimpShapeLoader::fillGuiTreeView(const char* sourceShapePath, GuiTreeView
|
||||||
tree->insertItem(matItem, String::ToString("%s", name.c_str()), String::ToString("%s", texName.c_str()));
|
tree->insertItem(matItem, String::ToString("%s", name.c_str()), String::ToString("%s", texName.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (U32 i = 0; i < shapeScene->mNumAnimations; i++)
|
if (shapeScene->mNumAnimations == 0)
|
||||||
{
|
{
|
||||||
String sequenceName = shapeScene->mAnimations[i]->mName.C_Str();
|
tree->insertItem(animItem, "ambient", "animation", "", 0, 0);
|
||||||
if (sequenceName.isEmpty())
|
}
|
||||||
sequenceName = "ambient";
|
else
|
||||||
tree->insertItem(animItem, sequenceName.c_str());
|
{
|
||||||
|
for (U32 i = 0; i < shapeScene->mNumAnimations; i++)
|
||||||
|
{
|
||||||
|
tree->insertItem(animItem, shapeScene->mAnimations[i]->mName.C_Str(), "animation", "", 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
U32 numNodes = 0;
|
U32 numNodes = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue