Skip to content
Snippets Groups Projects
Commit 244fb632 authored by Gundalf's avatar Gundalf
Browse files

Fixed groups

parent a6425611
No related branches found
No related tags found
No related merge requests found
...@@ -242,8 +242,10 @@ bool Exporter::makeCollisionHierarchy(NiNodeRef &parent, INode *node, TimeValue ...@@ -242,8 +242,10 @@ bool Exporter::makeCollisionHierarchy(NiNodeRef &parent, INode *node, TimeValue
Exporter::Result Exporter::exportCollision(NiNodeRef &parent, INode *node) Exporter::Result Exporter::exportCollision(NiNodeRef &parent, INode *node)
{ {
// marked as collision? // marked as collision?
bool coll = npIsCollision(node);
NiNodeRef newParent; NiNodeRef newParent;
if (npIsCollision(node)) if (coll)
{ {
/* NiNodeRef n = DynamicCast<NiNode>(CreateBlock("NiNode")); /* NiNodeRef n = DynamicCast<NiNode>(CreateBlock("NiNode"));
parent->AddChild(DynamicCast<NiAVObject>(n)); parent->AddChild(DynamicCast<NiAVObject>(n));
...@@ -279,7 +281,7 @@ Exporter::Result Exporter::exportCollision(NiNodeRef &parent, INode *node) ...@@ -279,7 +281,7 @@ Exporter::Result Exporter::exportCollision(NiNodeRef &parent, INode *node)
newParent->SetCollisionObject(DynamicCast<NiCollisionObject>(co)); newParent->SetCollisionObject(DynamicCast<NiCollisionObject>(co));
} else } else
if (node->IsGroupHead()) if (isCollisionGroup(node))
{ {
newParent = makeNode(parent, node); newParent = makeNode(parent, node);
} else } else
......
...@@ -88,6 +88,10 @@ private: ...@@ -88,6 +88,10 @@ private:
BitmapTex *getTexture(Mtl *mtl); BitmapTex *getTexture(Mtl *mtl);
void getTextureMatrix(Matrix3 &mat, Mtl *mtl); void getTextureMatrix(Matrix3 &mat, Mtl *mtl);
NiNodeRef makeNode(NiNodeRef &parent, INode *maxNode, bool local=true); NiNodeRef makeNode(NiNodeRef &parent, INode *maxNode, bool local=true);
// returns true if the node contains collision objects
bool isCollisionGroup(INode *maxNode, bool root=true);
// returns true if the node contains meshes
bool isMeshGroup(INode *maxNode, bool root=true);
/* tristrips */ /* tristrips */
void strippify(TriStrips &strips, vector<Vector3> &verts, vector<Vector3> &norms, const Triangles &tris); void strippify(TriStrips &strips, vector<Vector3> &verts, vector<Vector3> &norms, const Triangles &tris);
......
...@@ -43,28 +43,14 @@ void FPUtility::GetAlphaVal(void) ...@@ -43,28 +43,14 @@ void FPUtility::GetAlphaVal(void)
Exporter::Result Exporter::exportMeshes(NiNodeRef &parent, INode *node) Exporter::Result Exporter::exportMeshes(NiNodeRef &parent, INode *node)
{ {
bool coll = npIsCollision(node); bool coll = npIsCollision(node);
if ((coll && !mExportCollision) || if (coll || (node->IsHidden() && !mExportHidden && !coll) || (mSelectedOnly && !node->Selected()))
(node->IsHidden() && !mExportHidden && !coll) ||
(mSelectedOnly && !node->Selected()))
return Skip; return Skip;
NiNodeRef newParent; NiNodeRef newParent;
TimeValue t = 0; TimeValue t = 0;
ObjectState os = node->EvalWorldState(t); ObjectState os = node->EvalWorldState(t);
if (!coll && os.obj && os.obj->SuperClassID()==GEOMOBJECT_CLASS_ID) if (os.obj && os.obj->SuperClassID()==GEOMOBJECT_CLASS_ID)
{ {
/* newParent = DynamicCast<NiNode>(CreateBlock("NiNode"));
parent->AddChild(DynamicCast<NiAVObject>(newParent));
Matrix33 rot;
Vector3 trans;
nodeTransform(rot, trans, node, t);
newParent->SetLocalRotation(rot);
newParent->SetLocalTranslation(trans);
string name = (char*)node->GetName();
newParent->SetName(name);
*/
newParent = makeNode(parent, node); newParent = makeNode(parent, node);
Result result; Result result;
...@@ -73,20 +59,10 @@ Exporter::Result Exporter::exportMeshes(NiNodeRef &parent, INode *node) ...@@ -73,20 +59,10 @@ Exporter::Result Exporter::exportMeshes(NiNodeRef &parent, INode *node)
return result; return result;
} else } else
if (node->IsGroupHead()) if (isMeshGroup(node))
{ {
newParent = makeNode(parent, node); newParent = makeNode(parent, node);
/* newParent = DynamicCast<NiNode>(CreateBlock("NiNode"));
Matrix33 rot;
Vector3 trans;
nodeTransform(rot, trans, node, t);
newParent->SetLocalRotation(rot);
newParent->SetLocalTranslation(trans);
string name = (char*)node->GetName();
newParent->SetName(name);
parent->AddChild(DynamicCast<NiAVObject>(newParent));
*/
} else } else
newParent = parent; newParent = parent;
......
...@@ -105,3 +105,50 @@ NiNodeRef Exporter::makeNode(NiNodeRef &parent, INode *maxNode, bool local) ...@@ -105,3 +105,50 @@ NiNodeRef Exporter::makeNode(NiNodeRef &parent, INode *maxNode, bool local)
parent->AddChild(DynamicCast<NiAVObject>(node)); parent->AddChild(DynamicCast<NiAVObject>(node));
return node; return node;
} }
bool Exporter::isCollisionGroup(INode *maxNode, bool root)
{
if (root)
{
if (!maxNode->IsGroupHead())
return false;
} else
{
if (npIsCollision(maxNode))
return true;
}
for (int i=0; i<maxNode->NumberOfChildren(); i++)
{
if (isCollisionGroup(maxNode->GetChildNode(i), false))
return true;
}
return false;
}
bool Exporter::isMeshGroup(INode *maxNode, bool root)
{
if (root)
{
if (!maxNode->IsGroupHead())
return false;
} else
{
if (!npIsCollision(maxNode))
{
TimeValue t = 0;
ObjectState os = maxNode->EvalWorldState(t);
if (os.obj->SuperClassID() == GEOMOBJECT_CLASS_ID)
return true;
}
}
for (int i=0; i<maxNode->NumberOfChildren(); i++)
{
if (isMeshGroup(maxNode->GetChildNode(i), false))
return true;
}
return false;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment