Advertisement Jump to content
  • Advertisement

Talisker

Member
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Talisker

  • Rank
    Newbie
  1. Talisker

    .x file trouble

    Thnx! was just about to look into .fx files. Never used it before.
  2. I'm building a little game from scratch and I've decided to use .x files for my objects... so I need an .x file parser. I'm going to use maya 6.0 to model the objects in my game, and I have installed and exported a simple cube... just to check if things are working. First question... if the cube has a shader or a texture.. isn't it supposed to show up in the directX viewer? becaus mine is all gray. Allso.. the texture file name is not in the .x file. Does anyone have any experience exporting .x files from Maya? I think I've got everything set up ok, but nothing is rendering!? Loading the file and looping through to get the materials: //Load the mesh from the file HRESULT hr=D3DXLoadMeshFromX( cFileName, D3DXMESH_SYSTEMMEM, gD3dDevice, NULL, &m_matBuffer, NULL, &m_numMat, &m_mesh); D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)m_matBuffer->GetBufferPointer(); m_meshMaterials = new D3DMATERIAL9[m_numMat]; m_meshTextures = new LPDIRECT3DTEXTURE9[m_numMat]; for(DWORD i = 0; i < m_numMat; i++) { //copy the material m_meshMaterials = d3dxMaterials.MatD3D; m_meshMaterials.Ambient = m_meshMaterials.Diffuse; //Create the texture if it exists m_meshTextures = NULL; if(d3dxMaterials.pTextureFilename) { D3DXCreateTextureFromFile(gD3dDevice, d3dxMaterials.pTextureFilename, &m_meshTextures); } } m_matBuffer->Release(); hr comes to 0 and the file seems to be loaded into memory. m_numMat becomes 2 etc. And then to render it: D3DXMatrixIdentity(&m_mWorldMatrix); D3DXMatrixTranslation(&m_mWorldMatrix, 0.0f, 0.0f, 0.0f); gD3dDevice->SetTransform(D3DTS_WORLD, &m_mWorldMatrix); for (DWORD i=0; i<m_numMat; i++) { // Set the material and texture for this subset gD3dDevice->SetMaterial(&m_meshMaterials); gD3dDevice->SetTexture(0,m_meshTextures); // Draw the mesh subset m_mesh->DrawSubset( i ); } Tali
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!