Original Post
Hi Im working on making a rigid terrain using the Tokamak physics SDK. I want to read in the verticies from a DirectX Mesh and load them into the Tokamak terain vertices. Ive got most of it working but heres the problem: I have defined a custom vertex format containing only the position of each vertex in my 3d model:
struct CUSTOMVERTEX
{
float x,y,z; // The untransformed position for the vertex.
};
#define TERRAIN_VERTEX (D3DFVF_XYZ)
then i wrote a method to access the mesh loaded in:
void PhysicsTerrain::BuildTerrainMesh()
{
base->D3dDevice->SetFVF(TERRAIN_VERTEX);
// The array of vertices
neV3* triVertices;
// The array of triangles
neTriangle* triData;
int i, j;
// Access the parent Mesh (already loaded)
ID3DXMesh* parentMesh = m_Mesh->getParentMesh()->m_Mesh;
// Set the number of vertices into the triMesh
triMesh.vertexCount = parentMesh->GetNumVertices();
triMesh.triangleCount = parentMesh->GetNumFaces();
CUSTOMVERTEX *pVertex = NULL;
if(FAILED(parentMesh->LockVertexBuffer(D3DLOCK_READONLY, (BYTEVOID**)&pVertex)))
{
base->messageBox(NULL,"Failed to Lock Vertex Buffer","Physics Terrain");
return;
}
triVertices = new neV3[triMesh.vertexCount];
for(i = 0; i < triMesh.vertexCount; i ++)
{
triVertices.Set(pVertex->x,pVertex->y,pVertex->z);
sprintf(base->buffer,"X %f, Y %f, Z %f \n Vertex: %d",pVertex->x,pVertex->y,pVertex->z,sizeof(pVertex));
base->messageBox(NULL,base->buffer,"Vertex Data");
pVertex ++;
}
parentMesh->UnlockVertexBuffer();
// Set the vertices into the triMesh
triMesh.vertices = triVertices;
.......... index buffer stuff (working) ......
// Tell the simulator about our mesh
base->physicsManager->PhysicsSimulator->SetTerrainMesh(&triMesh);
}
the problem is that although im specifying that it use my custom vertex format it is loading the texture coordinates and normals from each vertex. How do i read ONLY the position from the vertex?