Hello there!
I ran into some troubles while converting objects, loaded into the sObject struct, toan irrXML readable version.
First of all my code to get the data from the memblock:
dbMakeMeshFromObject(1,1);
dbMakeMemblockFromMesh(1,1);
int vertexCount = dbMemblockWord(1,8);
for(int i=1; i<node->ppMeshList[n]->dwVertexCount; i++)
{
float posx = dbMemblockWord(1,12+i*32);
float posy = dbMemblockWord(1,12+i*32+4);
float posz = dbMemblockWord(1,12+i*32+8);
float nx = dbMemblockWord(1,24+i*32);
float ny = dbMemblockWord(1,24+i*32+4);
float nz = dbMemblockWord(1,24+i*32+8);
DWORD color = dbMemblockWord(1,24+sizeof(DWORD)+i*32+8);
float uvx = dbMemblockWord(1,24+sizeof(DWORD)+12+i*32+4);
float uvy = dbMemblockWord(1,24+sizeof(DWORD)+12+i*32+8);
}
dbDeleteMesh(1);
dbDeleteMemblock(1);
I used the memblock because I couldn't figure out how the sObject stores the vertex data, there is a pointer (BYTE*) pointing to the original vertex data (pOriginalVertexData), but can't copy the memory to an array.
But maybe a better question is: am I reading the memblock the right way?
The FVF is: XYZ | NORMAL | DIFFUSE | TEX0
That's that, but how about the Indices, how do I extract it's ids corresponding with the vertices. Can I just give them id's, 0 1 2 3 4 5 6 7 ... etc?
This is the first 4 iterations of couting the data i got from the memblock:
57374 45992 6980 54103 39227 49286 0 26746 9657
26746 9657 13779 54103 39227 49286 0 21735 6607
21735 6607 23046 53446 61898 10741 2007 17086 30227
17086 30227 47462 63651 1665 47331 155c 28354 4128
28354 4128 25694 35730 31784 5973 57d6 17086 30227
The XYZ seems alright, if 100 stands for 1 (thus, devided by 100 it looks normal), same for normals?
I couted the diffuse color as:
file << hex << dwColor;
With this I am attempting to convert it to and irrXML file format.
And because this
http://www.irrlicht3d.org/download/example.irrmesh example works, I used it as a template. All goes well till the real meat, vertices & indices. It crashes upon loading without errors.
Thank you,
Leo
PS: I am wondering where the memblock get's all the data from the mesh. sObject->sObjectData->ppMeshList->sMeshDraw->pVertexData and pIndexData are all blank, I am wondering how it does it magic when it converts the normal object to an memblock (which i guess lies in the pBlock), but that's an exact copy of the sObject...
Cheers,