Hi, I am "attempting" to learn how to use your engine. I was curious what I am doing wrong. I load a .ms3d mesh or a .md2 mesh, I used both meshs that come w/ the library, as well as a few I threw togeather. I then want to pull the indecies/verticies of the mesh I have loaded out of the mesh, to be used for some other things.
Here is my code.
IAnimatedMesh* mesh = smgr->getMesh("../../media/testing.ms3d");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
//Read the first frame of the mesh
IMesh* anothermesh = mesh->getMesh(0, 255, -1, -1);
for(u32 a=0; a<anothermesh ->getMeshBufferCount(); a++)
{
IMeshBuffer* mshbuf = anothermesh ->getMeshBuffer(a);
video::S3DVertex* VERTS = (video::S3DVertex*)mshbuf->getVertices();
int c=0;
for(c=0; c<mshbuf->getVertexCount(); c++)
{
cout << VERTS[c].Pos.X << " " << VERTS[c].Pos.Y << " " << VERTS[c].Pos.Z << " " << VERTS[c].Normal.X << " " << VERTS[c].Normal.Y << " " << VERTS[c].Normal.Z << endl;
}
u16* INDICES = mshbuf->getIndices();
for(c=0; c<mshbuf->getIndexCount(); c++)
{
cout << INDICES[c] << " ";
}
}
The problem is, the values comming out of my buffer are insane! For example, when I add one of the .md2 models that has like 320 verts total. My mesh buffer tells me I have like 2160 vertices and indices "always the same value", then when I print out my verts I have 2160 verts print to the screen and I have noticed some duplicates, which is not suppost to happen in an indexed list. As well as the fact that my indices just run from 0-2160 never skipping any.
I thought that the meshbuffers held the mesh data, or am I mistaken? Or am I loading ALL of static frames for the entire animated object? But that shouldnt be a problem w/ .ms3d because it only has one frame, and the indices should never change anyhow. Also, I was looking at your rendering code, and it bascialy passes the same values I am asking for here, and it renders just fine. Am I doing something incorrectly??
Am I doing something wrong?
-
Guest
No suggestions yet? Ok, maybe I explained things incorrectly, or asked the wrong question. Here is a second try. When I load a mesh into irrlicht, say a character, it gets loaded into a mesh made of mesh buffers. Now presumably? each mesh buffer is based on a material "so there would be 2 mesh buffers for a character that had a texture for the head, and a texture for the rest of it". So if my mesh has 50 verts/120 triangles for the head mesh, and 200 verts/310 triangles for the body mesh, I should have created 2 mesh buffers for that mesh, each with the numbers listed a moment ago respectivly. So reading the head buffer should give me 50 verts and a list of "indices" that are actualy indexed. So why when I read the buffer values like I did above, do i end up with 2,000 some points and indices, and why are there no actualy indexed indices "simply a index for each point"? Or am I entrpeting things incorrectly??
I am also running into this problem. As some of you know I have been working on a method of adding triangle strippification to Irrlicht, and I THOUGHT I had it working, but it turns out NOT. It seems that irrlicht dosnt actualy load indexed values. It is only loading the vertices then rendering each triangle one at a time USING the index BUT the index seems to be linear (thus no duplicate vertex lookups).
I placed some cout statments inside of the engine itself, to kick out how many triangles it is rendering, how many vertices it is rendering, how many indices it is rendering, and if there are ANY duplicate indices being used. Turns out there are NO duplicate indices. This is a BIG problem. Instead of an indexed array, we are basicaly rendering everthing in intermediate mode.
Niko is this an error???
I think I might be able to get the tri_stripper working with the current setup, but it would make much greater sense to simply load the mesh into memory smarter??
What say ye Niko??
Thankx all & sorry guest, I dont think you are actualy doing anything wrong....
I placed some cout statments inside of the engine itself, to kick out how many triangles it is rendering, how many vertices it is rendering, how many indices it is rendering, and if there are ANY duplicate indices being used. Turns out there are NO duplicate indices. This is a BIG problem. Instead of an indexed array, we are basicaly rendering everthing in intermediate mode.
Niko is this an error???
I think I might be able to get the tri_stripper working with the current setup, but it would make much greater sense to simply load the mesh into memory smarter??
What say ye Niko??
Thankx all & sorry guest, I dont think you are actualy doing anything wrong....