C Senthil Kumar

In my game, using .X file format for objects in the world (players, health pack etc...) is okay. Right now, my game doesn't have a detailed world.

When it does have a detailed world, can I use the .X format for the entire world One .X file for a huge level or part of the level If I use it, Can I get the individual triangle vertices from the mesh




Re: Game Technologies: Graphics Using .X files for world model

BLANC Guillaume

Using one or more .x files for the level is up to your choice. The two solutions will work.
You can get vertices from a mesh using ID3DXBaseMesh interface and LockVertexBuffer function. You'll have to use the vertex declaration obtained with ID3DXBaseMesh::GetDeclaration or GetFVF functions to understand the vertex buffer layout.
Triangle indexes can also be fetched using the ID3DXBaseMesh::LockIndexBuffer function.





Re: Game Technologies: Graphics Using .X files for world model

C Senthil Kumar

Hey, thanks for stopping by...

Using the LockVertexBuffer, I can get the data. But I am confused with the FVF.

When I call the GetFVF(ID3DXMesh), it returns a DWORD. How can I figure out which combination of FVF flags are present. It can be any combination right






Re: Game Technologies: Graphics Using .X files for world model

BLANC Guillaume

No it can't be any combination. The FVF DWORD you get back from the GetFVF function stores a bit field. It's exactly the same usage as when you're specifying by yourself a FVF toDirectX to render a vertex buffer. Using usual bit manipulation syntax you can extract the information you need:

DWORD dwValue = GetFVF(...);
if(dwValue & D3DFVF_XYZ)
{
// FVF uses positions, do whatever you want with positions
}
if(dwValue & D3DFVF_NORMAL)
{
// FVF uses normals, do whatever you want with normals
}
...

Anyway, if you can, I would recommend to use the vertex declaration (ID3DXBaseMesh::GetDeclaration) rather than the FVF. It's a more powerful vertex buffer layout descriptor.

Both FVF and declarations are well documented in DirectX SDK. If you've got problems to extract informations from the mesh, try the opposite in order to understand how things are working : render a VB using your own FVF or declaration. Then, you'll easily decode mesh's vertex buffers.






Re: Game Technologies: Graphics Using .X files for world model

C Senthil Kumar

Thanks for the code . Now I understand how I am supposed to get information about the FVF.