Archived

This topic is now archived and is closed to further replies.

MindCode

lib3ds

Recommended Posts

MindCode    122
I'm using lib3ds to extract the triangle geometry from a 3ds file. For some reason it's crashing.
void Extract3dsNode(Lib3dsFile* p3ds, Lib3dsNode* pNode) {
	for(Lib3dsNode* i = pNode->childs; i != NULL; i = i->next) {
		Extract3dsNode(p3ds, i);
	}

	if(pNode->type == LIB3DS_OBJECT_NODE) {

		if(!strcmp(pNode->name, "$$$DUMMY")) {
			throw "Lib3ds: Invalid mesh name.";
		}

		Lib3dsMesh* pMesh;

		pMesh = lib3ds_file_mesh_by_name(p3ds, pNode->name);

		if(!pMesh) {
			throw "Lib3ds: Mesh name does not exist.";
		}

		for(int _i = 0; _i < pMesh->faces; ++_i) {

			Lib3dsFace* pFace;
			CTriangle Triangle;

			pFace = &pMesh->faceL[_i];

			for(int j = 0; j < 3; j++) {

				Triangle.m_vVector[j].x = pMesh->pointL[ pFace->points[j] ].pos[0];
				Triangle.m_vVector[j].y = pMesh->pointL[ pFace->points[j] ].pos[1];
				Triangle.m_vVector[j].z = pMesh->pointL[ pFace->points[j] ].pos[2];
			}

			Triangle.Gen(Vector3dv);
			m_vTriangles.push_back(Triangle);

		}
	}
}
 
From what I can tell, it crashes on the innermost loop, when it gets the vertex information. [edited by - MindCode on January 28, 2003 7:19:45 PM]

Share this post


Link to post
Share on other sites