to render it seems close to opengl except I have to create a vertex buffer for each texture group of polygons instead of creating a model
here's the code :
Code:
// build the vertex buffers corresponding to each mesh
ppVBs = new LPDIRECT3DVERTEXBUFFER9 * [meshes.GetSize()];
for ( i=0; i<meshes.GetSize(); i++ )
{
Data36* mesh = meshes.GetAt(i);
// precalculate the scale of the mesh
float scale = (float)(1<<mesh->Scale);
// builds the vertex buffers
ppVBs[i] = new LPDIRECT3DVERTEXBUFFER9 [ mesh->PolygonTexCount ];
int polygoncount = 0;
for ( j=0; j<mesh->PolygonTexCount; j++ )
{
int nbvertex = mesh->PolygonTexEntries[j][0] * 3;
if( FAILED ( pd3dDevice->CreateVertexBuffer(
nbvertex * sizeof ( MODELVERTEX ),
D3DUSAGE_WRITEONLY, D3DFVF_MODELVERTEX,
D3DPOOL_DEFAULT, &ppVBs[i][j] , NULL ) ) )
return E_FAIL;
MODELVERTEX * pVertex;
ppVBs[i][j]->Lock( 0, 0, ( void * * ) & pVertex , 0 );
for ( k=0; k<mesh->PolygonTexEntries[j][0]; k++ )
{
for ( int numvertex=1; numvertex<=3; numvertex++ )
{
int vertexindex = mesh->PolygonEntries[polygoncount][numvertex];
// get the unajusted vertices
float x = mesh->CenterX + mesh->VertexEntries[vertexindex][0]/scale;
float y = mesh->CenterY + mesh->VertexEntries[vertexindex][1]/scale;
float z = mesh->CenterZ + mesh->VertexEntries[vertexindex][2]/scale;
// get the index of the piece that contains this vertex
int pieceindex = GetPieceIndex( mesh, vertexindex );
// rotate the unajusted vertices
RotateX( pieces[pieceindex].XAng, x, y, z );
RotateY( pieces[pieceindex].YAng, x, y, z );
RotateZ( pieces[pieceindex].ZAng, x, y, z );
// add the position of the piece
pVertex->x = x + pieces[pieceindex].XOfs;
pVertex->y = y + pieces[pieceindex].YOfs;
pVertex->z = z + pieces[pieceindex].ZOfs;
pVertex->nx = mesh->VertexNormalEntries[vertexindex][0]/127.0f;
pVertex->ny = mesh->VertexNormalEntries[vertexindex][0]/127.0f;
pVertex->nz = mesh->VertexNormalEntries[vertexindex][0]/127.0f;
pVertex->color = 0xffffffff;
pVertex->u1 = mesh->TextureCoordEntries_w[vertexindex][0]/256.0f;
pVertex->v1 = mesh->TextureCoordEntries_w[vertexindex][1]/256.0f;
pVertex ++;
}
polygoncount++;
}
ppVBs[i][j]->Unlock();
}
}
I followed exactly what you have done in dzoneconverter =)