MeshBuffer help
Posted: Wed Sep 05, 2007 4:32 pm
Hi guys, i think i need some help from you. I would like to get alle Vertices and Indices out of a Mesh because i need them for building a physics object:
The Problem is that I cannot access all the Vertices I get from getVertexCount(). My Programm always crashes when I run through more than 7 loops. That means there seem to be not more than 7 Vertices included in my mesh although getVertexCount() says there are more than 900!
Furthermore I don't understand why my Mesh has 23 different MeshBuffers. So does my Mesh have 23 Materials and for every Material 1 MeshBuffer?
Code: Select all
ISceneNode* node = smgr->addMeshSceneNode( mesh1, 0, -1, vector3df(0,-5,15), vector3df(0,0,0), vector3df(0.01f,0.01f,0.01f) );
node->setMaterialFlag(video::EMF_LIGHTING, false);
node->setMaterialTexture( 0, driver->getTexture("media/house/fw12b.jpg") );
IMeshBuffer *buffer = mesh1->getMeshBuffer(0);
int nv = buffer->getVertexCount ();
int ni = buffer->getIndexCount ();
float *pVerts = new float[3*nv];
int *pInds = new int[ni];
if(buffer->getVertexType() == video::EVT_2TCOORDS)
{
irr::video::S3DVertex2TCoords* pv1 = (irr::video::S3DVertex2TCoords*) buffer->getVertices();
irr::u16* pi = (irr::u16*)buffer->getIndices();
int loop;
for (loop=0;i<nv;loop++) {
pVerts[loop*3+0]=0.01*pv1[loop].Pos.X + 0;
pVerts[loop*3+1]=0.01*pv1[loop].Pos.Y - 5;
pVerts[loop*3+2]=0.01*pv1[loop].Pos.Z + 15;
}
for (loop=0;loop<ni;loop++) {
pInds[loop]=pi[loop];
}
}
Furthermore I don't understand why my Mesh has 23 different MeshBuffers. So does my Mesh have 23 Materials and for every Material 1 MeshBuffer?