Archived

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

StuartSlater

meshes and .x files

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