meshes and .x files

Started by
-1 comments, last by StuartSlater 21 years, 9 months ago
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.MatD3D; g_pMeshMaterials.Ambient = g_pMeshMaterials.Diffuse; D3DXCreateTextureFromFile(DXTigerPage.D3DDevice,d3dxMaterials.pTextureFilename,&g_pMeshTextures); } pD3DXMtrlBuffer->Release(); 2) for(DWORD i=0; i<g_dwNumMaterials;i++) { DXTigerPage.D3DDevice->SetMaterial(&g_pMeshMaterials); DXTigerPage.D3DDevice->SetTexture(0,g_pMeshTextures); g_pMesh->DrawSubset(i); } Stuart </i>

This topic is closed to new replies.

Advertisement