Removed LWOImporter::AddChildren and LWOImporter::GenerateNodeGraph

pull/3/head
Gellule Xg 2011-12-06 20:14:01 -10:00
parent 32cabd8bbc
commit 058be9323d
1 changed files with 0 additions and 92 deletions

View File

@ -528,98 +528,6 @@ void LWOImporter::ComputeNormals(aiMesh* mesh, const std::vector<unsigned int>&
}
}
// ------------------------------------------------------------------------------------------------
void LWOImporter::AddChildren(aiNode* node, uint16_t parent, std::vector<aiNode*>& apcNodes)
{
for (std::vector<aiNode*>::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) {
if (*it) {
LWO::Layer* layer = (LWO::Layer*)(*it)->mParent;
if (layer->mParent == parent && layer->mIndex != parent)
++node->mNumChildren;
}
}
if (node->mNumChildren) {
unsigned int p = 0;
node->mChildren = new aiNode* [ node->mNumChildren ];
for (std::vector<aiNode*>::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) {
if (*it) {
LWO::Layer* layer = (LWO::Layer*)(*it)->mParent;
if (layer->mParent == parent && layer->mIndex != parent) {
aiNode* nd = node->mChildren[p++] = *it;
nd->mParent = node;
// fixme: ignore pivot points for the moment
//nd->mTransformation.a4 = layer->mPivot.x;
//nd->mTransformation.b4 = layer->mPivot.y;
//nd->mTransformation.c4 = layer->mPivot.z;
// recursively add more children
(*it) = NULL;
AddChildren(nd,layer->mIndex,apcNodes);
}
}
}
}
}
// ------------------------------------------------------------------------------------------------
void LWOImporter::GenerateNodeGraph(std::vector<aiNode*>& apcNodes)
{
// now generate the final nodegraph - generate a root node and attach children
aiNode* root = pScene->mRootNode = new aiNode();
root->mName.Set("<LWORoot>");
AddChildren(root,0,apcNodes);
// check whether we added all layers with meshes assigned to the output graph.
// if not, add them to the root node
unsigned int extra = 0;
for (std::vector<aiNode*>::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) {
if ((*it) && (*it)->mNumMeshes)
++extra;
}
if (extra) {
const unsigned int newSize = extra + pScene->mRootNode->mNumChildren;
aiNode** const apcNewNodes = new aiNode*[newSize];
if((extra = root->mNumChildren))
::memcpy(apcNewNodes,root->mChildren,extra*sizeof(void*));
aiNode** cc = apcNewNodes+extra;
for (std::vector<aiNode*>::iterator it = apcNodes.begin(); it != apcNodes.end(); ++it) {
if ((*it) && (*it)->mNumMeshes) {
aiNode* nd = *cc++ = *it;
nd->mParent = pScene->mRootNode;
// recursively add more children
(*it) = NULL;
AddChildren(nd,((LWO::Layer*)nd->mParent)->mIndex,apcNodes);
}
}
delete[] root->mChildren;
root->mChildren = apcNewNodes;
root->mNumChildren = newSize;
}
if (!pScene->mRootNode->mNumChildren)
throw DeadlyImportError("LWO: Unable to build a valid node graph");
// Remove a single root node with no meshes assigned to it ...
if (1 == pScene->mRootNode->mNumChildren) {
aiNode* pc = pScene->mRootNode->mChildren[0];
pc->mParent = pScene->mRootNode->mChildren[0] = NULL;
delete pScene->mRootNode;
pScene->mRootNode = pc;
}
// convert the whole stuff to RH with CCW winding
MakeLeftHandedProcess maker;
maker.Execute(pScene);
FlipWindingOrderProcess flipper;
flipper.Execute(pScene);
}
// ------------------------------------------------------------------------------------------------
void LWOImporter::ResolveTags()
{