|
|
|
@ -68,7 +68,8 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM
|
|
|
|
|
baseBuild = new CMeshBase::CMeshBaseBuild();
|
|
|
|
|
|
|
|
|
|
// Get a pointer on the object's node
|
|
|
|
|
Object *obj = node.EvalWorldState(tvTime).obj;
|
|
|
|
|
ObjectState os = node.EvalWorldState(tvTime);
|
|
|
|
|
Object *obj = os.obj;
|
|
|
|
|
|
|
|
|
|
// Check if there is an object
|
|
|
|
|
if (obj)
|
|
|
|
@ -79,6 +80,8 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM
|
|
|
|
|
{
|
|
|
|
|
// Get a triobject from the node
|
|
|
|
|
TriObject *tri = (TriObject*)obj->ConvertToType(tvTime, Class_ID(TRIOBJ_CLASS_ID, 0));
|
|
|
|
|
if (tri)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Note that the TriObject should only be deleted
|
|
|
|
|
// if the pointer to it is not equal to the object
|
|
|
|
@ -107,7 +110,9 @@ CMesh::CMeshBuild* CExportNel::createMeshBuild(INode& node, TimeValue tvTime, CM
|
|
|
|
|
|
|
|
|
|
// Delete the triObject if we should...
|
|
|
|
|
if (deleteIt)
|
|
|
|
|
tri->DeleteMe();
|
|
|
|
|
tri->MaybeAutoDelete();
|
|
|
|
|
tri = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -126,7 +131,7 @@ static void copyMultiLodMeshBaseLod0Infos(CMeshBase::CMeshBaseBuild &dst, const
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
// Export a mesh
|
|
|
|
|
IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt *nodeMap, bool buildLods)
|
|
|
|
|
NLMISC::CSmartPtr<NL3D::IShape> CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt *nodeMap, bool buildLods)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// Is this a multi lod object ?
|
|
|
|
@ -134,14 +139,15 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|
|
|
|
|
|
|
|
|
// Here, we must check what kind of node we can build with this mesh.
|
|
|
|
|
// For the time, just Triobj is supported.
|
|
|
|
|
IShape *retShape=NULL;
|
|
|
|
|
CSmartPtr<IShape> retShape = NULL;
|
|
|
|
|
|
|
|
|
|
// If skinning, disable skin modifier
|
|
|
|
|
if (nodeMap)
|
|
|
|
|
enableSkinModifier (node, false);
|
|
|
|
|
|
|
|
|
|
// Get a pointer on the object's node
|
|
|
|
|
Object *obj = node.EvalWorldState(time).obj;
|
|
|
|
|
ObjectState os = node.EvalWorldState(time);
|
|
|
|
|
Object *obj = os.obj;
|
|
|
|
|
|
|
|
|
|
// Check if there is an object
|
|
|
|
|
if (obj)
|
|
|
|
@ -184,6 +190,8 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|
|
|
|
// Get a triobject from the node
|
|
|
|
|
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
|
|
|
|
|
|
|
|
|
if (tri)
|
|
|
|
|
{
|
|
|
|
|
// Note that the TriObject should only be deleted
|
|
|
|
|
// if the pointer to it is not equal to the object
|
|
|
|
|
// pointer that called ConvertToType()
|
|
|
|
@ -198,7 +206,7 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Mesh base ?
|
|
|
|
|
CMeshBase *meshBase;
|
|
|
|
|
CSmartPtr<CMeshBase> meshBase = NULL;
|
|
|
|
|
|
|
|
|
|
// Get the node matrix
|
|
|
|
|
Matrix3 nodeMatrixMax;
|
|
|
|
@ -310,6 +318,7 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|
|
|
|
|
|
|
|
|
// Make a CMeshMultiLod mesh object
|
|
|
|
|
CMeshMultiLod *multiMesh = new CMeshMultiLod;
|
|
|
|
|
++multiMesh->crefs; // hack
|
|
|
|
|
|
|
|
|
|
// Build it
|
|
|
|
|
multiMesh->build(multiLodBuild);
|
|
|
|
@ -441,7 +450,9 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|
|
|
|
|
|
|
|
|
// Delete the triObject if we should...
|
|
|
|
|
if (deleteIt)
|
|
|
|
|
tri->DeleteMe();
|
|
|
|
|
tri->MaybeAutoDelete();
|
|
|
|
|
tri = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -450,7 +461,7 @@ IShape* CExportNel::buildShape (INode& node, TimeValue time, const TInodePtrInt
|
|
|
|
|
enableSkinModifier (node, true);
|
|
|
|
|
|
|
|
|
|
// Set the dist max for this shape
|
|
|
|
|
if (retShape && !multiLodObject && buildLods)
|
|
|
|
|
if (retShape.getPtr() && !multiLodObject && buildLods)
|
|
|
|
|
{
|
|
|
|
|
// Get the dist max for this node
|
|
|
|
|
float distmax = getScriptAppData (&node, NEL3D_APPDATA_LOD_DIST_MAX, NEL3D_APPDATA_LOD_DIST_MAX_DEFAULT);
|
|
|
|
@ -1173,6 +1184,7 @@ void CExportNel::getBSMeshBuild (std::vector<CMesh::CMeshBuild*> &bsList, INode
|
|
|
|
|
CMeshBase::CMeshBaseBuild *dummyMBB = NULL;
|
|
|
|
|
std::auto_ptr<CMesh::CMeshBuild> baseMB(createMeshBuild (node, time, dummyMBB, finalSpace));
|
|
|
|
|
delete dummyMBB;
|
|
|
|
|
dummyMBB = NULL;
|
|
|
|
|
if (baseMB.get() == NULL) return;
|
|
|
|
|
|
|
|
|
|
j = 0;
|
|
|
|
@ -1184,7 +1196,7 @@ void CExportNel::getBSMeshBuild (std::vector<CMesh::CMeshBuild*> &bsList, INode
|
|
|
|
|
++j;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bsList.resize (j);
|
|
|
|
|
bsList.resize(j, NULL);
|
|
|
|
|
|
|
|
|
|
j = 0;
|
|
|
|
|
for (i = 0; i < 100; ++i)
|
|
|
|
@ -1198,6 +1210,7 @@ void CExportNel::getBSMeshBuild (std::vector<CMesh::CMeshBuild*> &bsList, INode
|
|
|
|
|
// get the meshbuild of the morhp target
|
|
|
|
|
bsList[j] = createMeshBuild (*pNode, time, pMBB, finalSpace, true);
|
|
|
|
|
delete pMBB;
|
|
|
|
|
pMBB = NULL;
|
|
|
|
|
// copy src normals from src mesh for vertices that are on interfaces
|
|
|
|
|
CMesh::CMeshBuild *mb = bsList[j];
|
|
|
|
|
if (mb)
|
|
|
|
@ -1281,7 +1294,8 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|
|
|
|
enableSkinModifier (node, false);
|
|
|
|
|
|
|
|
|
|
// Get a pointer on the object's node
|
|
|
|
|
Object *obj = node.EvalWorldState(time).obj;
|
|
|
|
|
ObjectState os = node.EvalWorldState(time);
|
|
|
|
|
Object *obj = os.obj;
|
|
|
|
|
|
|
|
|
|
// Check if there is an object
|
|
|
|
|
if (obj)
|
|
|
|
@ -1292,12 +1306,12 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|
|
|
|
// Get a triobject from the node
|
|
|
|
|
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
|
|
|
|
|
|
|
|
|
if (tri)
|
|
|
|
|
{
|
|
|
|
|
// Note that the TriObject should only be deleted
|
|
|
|
|
// if the pointer to it is not equal to the object
|
|
|
|
|
// pointer that called ConvertToType()
|
|
|
|
|
bool deleteIt=false;
|
|
|
|
|
if (obj != tri)
|
|
|
|
|
deleteIt = true;
|
|
|
|
|
bool deleteIt = (obj != tri);
|
|
|
|
|
|
|
|
|
|
// Coarse mesh ?
|
|
|
|
|
bool coarseMesh=(getScriptAppData (&node, NEL3D_APPDATA_LOD_COARSE_MESH, 0)!=0) && (!_View);
|
|
|
|
@ -1364,8 +1378,13 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|
|
|
|
// Return this pointer
|
|
|
|
|
meshGeom=meshMRMGeom;
|
|
|
|
|
|
|
|
|
|
#ifdef NL_DONT_FIND_MAX_CRASH
|
|
|
|
|
for (uint32 bsListIt = 0; bsListIt < bsList.size(); ++bsListIt)
|
|
|
|
|
{
|
|
|
|
|
delete bsList[bsListIt];
|
|
|
|
|
bsList[bsListIt] = NULL;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -1388,7 +1407,9 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|
|
|
|
|
|
|
|
|
// Delete the triObject if we should...
|
|
|
|
|
if (deleteIt)
|
|
|
|
|
tri->DeleteMe();
|
|
|
|
|
tri->MaybeAutoDelete();
|
|
|
|
|
tri = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1397,7 +1418,7 @@ IMeshGeom *CExportNel::buildMeshGeom (INode& node, TimeValue time, const TInodeP
|
|
|
|
|
enableSkinModifier (node, true);
|
|
|
|
|
|
|
|
|
|
if (InfoLog)
|
|
|
|
|
InfoLog->display("buidlMeshGeom : %d ms\n", timeGetTime()-t);
|
|
|
|
|
InfoLog->display("buildMeshGeom : %d ms\n", timeGetTime()-t);
|
|
|
|
|
if (InfoLog)
|
|
|
|
|
InfoLog->display("End of %s \n", node.GetName());
|
|
|
|
|
|
|
|
|
@ -1657,10 +1678,15 @@ NL3D::IShape *CExportNel::buildWaterShape(INode& node, TimeValue time)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get a pointer on the object's node
|
|
|
|
|
Object *obj = node.EvalWorldState(time).obj;
|
|
|
|
|
ObjectState os = node.EvalWorldState(time);
|
|
|
|
|
Object *obj = os.obj;
|
|
|
|
|
|
|
|
|
|
if (!obj) return NULL;
|
|
|
|
|
|
|
|
|
|
// Get a triobject from the node
|
|
|
|
|
TriObject *tri = (TriObject *) obj->ConvertToType(0, Class_ID(TRIOBJ_CLASS_ID, 0));
|
|
|
|
|
TriObject *tri = (TriObject *) obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
|
|
|
|
|
|
|
|
|
if (!tri) return NULL;
|
|
|
|
|
|
|
|
|
|
// Note that the TriObject should only be deleted
|
|
|
|
|
// if the pointer to it is not equal to the object
|
|
|
|
@ -2033,7 +2059,8 @@ NL3D::IShape *CExportNel::buildWaterShape(INode& node, TimeValue time)
|
|
|
|
|
|
|
|
|
|
// Delete the triObject if we should...
|
|
|
|
|
if (deleteIt)
|
|
|
|
|
tri->DeleteMe();
|
|
|
|
|
tri->MaybeAutoDelete();
|
|
|
|
|
tri = NULL;
|
|
|
|
|
nlinfo("WaterShape : build succesful");
|
|
|
|
|
return ws;
|
|
|
|
|
}
|
|
|
|
@ -2047,11 +2074,13 @@ NL3D::IShape *CExportNel::buildWaterShape(INode& node, TimeValue time)
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
bool CExportNel::buildMeshAABBox(INode &node, NLMISC::CAABBox &dest, TimeValue time)
|
|
|
|
|
{
|
|
|
|
|
Object *obj = node.EvalWorldState(time).obj;
|
|
|
|
|
ObjectState os = node.EvalWorldState(time);
|
|
|
|
|
Object *obj = os.obj;
|
|
|
|
|
if (!obj) return false;
|
|
|
|
|
if (!obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0))) return false;
|
|
|
|
|
// Get a triobject from the node
|
|
|
|
|
TriObject *tri = (TriObject*)obj->ConvertToType(time, Class_ID(TRIOBJ_CLASS_ID, 0));
|
|
|
|
|
if (!tri) return false;
|
|
|
|
|
// Note that the TriObject should only be deleted
|
|
|
|
|
// if the pointer to it is not equal to the object
|
|
|
|
|
// pointer that called ConvertToType()
|
|
|
|
@ -2073,10 +2102,11 @@ bool CExportNel::buildMeshAABBox(INode &node, NLMISC::CAABBox &dest, TimeValue t
|
|
|
|
|
//
|
|
|
|
|
if (deleteIt)
|
|
|
|
|
{
|
|
|
|
|
#ifndef NL_DEBUG
|
|
|
|
|
tri->DeleteMe();
|
|
|
|
|
#ifdef NL_DONT_FIND_MAX_CRASH
|
|
|
|
|
tri->MaybeAutoDelete();
|
|
|
|
|
#endif // NL_DEBUG
|
|
|
|
|
}
|
|
|
|
|
tri = NULL;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|