Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


meshes and .x files

This topic is 5941 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im currently working on a game that was a 2d based game but is rapidly evolving into a 3d game but I am having trouble reading in a texture and displaying it properly. I think that im right to presume that it requires 2 stages, 1) Read in and set up texture. 2) in the render stage display the texture but I am having trouble doing this properly The .x file im trying to read doesnt have a texture I can see associated with it as a BMP and mesh viewer shows it in colour. Heres my code for 1) and 2) anyone see where im going wrong. 1) D3DXLoadMeshFromX("m_tree2.x",D3DXMESH_SYSTEMMEM,DXTigerPage.D3DDevice,NULL,&pD3DXMtrlBuffer,&g_dwNumMaterials,&g_pMesh); D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer(); g_pMeshMaterials = new D3DMATERIAL8[g_dwNumMaterials]; g_pMeshTextures = new LPDIRECT3DTEXTURE8[g_dwNumMaterials]; for (DWORD i=0; i=d3dxMaterials[i].MatD3D; g_pMeshMaterials[i].Ambient = g_pMeshMaterials[i].Diffuse; D3DXCreateTextureFromFile(DXTigerPage.D3DDevice,d3dxMaterials[i].pTextureFilename,&g_pMeshTextures[i]); } pD3DXMtrlBuffer->Release(); 2) for(DWORD i=0; iSetMaterial(&g_pMeshMaterials[i]); DXTigerPage.D3DDevice->SetTexture(0,g_pMeshTextures[i]); g_pMesh->DrawSubset(i); } Stuart

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!