Jump to content
  • Advertisement
Sign in to follow this  
Talisker

.x file trouble

This topic is 4846 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

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Loading from x files is reasy with D3DXLoadMeshHierarchyFromFile.
But as far as materials go, there are two representations in the system.
D3DXMATERIAL which is the old fixed function pipeline material system which hopefully everyone is moving away from, and D3DXEffectInstances which tell you what FX file to load and how to set it's parameters.

Using either material system is not automatic though...
for D3DXMATERIALS you have to set up the device state with the values it contains before rendering.

For EffectInstances you have to load the FX file to get an ID3DXEffect interface, then set its parameter and follow the orchastration conventions of that FX file. The most widely used one is "use the first valid technique, execute the passes in order while use some Draw* command to submit the geometry between each pass"

Also depending on what version of the Maya exporter you are using, older versions were never designed to provide you D3DXMATERIAL data. Instead it was designed to the the DirectX Material which is included in the same plugin. This material type managed those D3DXEffectInstances I was talking about.
The August version of the exporter includes support for D3DXMATERIALs though if you really must use that system.




Share this post


Link to post
Share on other sites
If you are planning you use Maya 6.0 you can expect to be having alot of ".x file troubles". Me and my friend have been pulling our hair out trying to find a WORKING exporter for maya 6.0 -> .x but nothing has ever worked for us.

http://www.gamedev.net/community/forums/topic.asp?topic_id=337909

I cry about this situation more in that thread.....


We have abandoned .X files... but have not decided on an alternative yet : /

Share this post


Link to post
Share on other sites
We use Maya 6.5 for content creation here at work and dump to .X files. For exporting we use Okino Polytrans and haven't had many issues at all, and nothing we couldn't work through.

There is the animation timing issue (the DX controller wants to see 4800 keys whereas Polytrans was dumping 3600 for 30fps).. that was easily fixed.

You have to watch what you are doing with complex animations, I mean everything is possible but just like in anything you have to make sure assets are built and animated properly.

There is an issue when dumping you see actual verts in the file (lets say 2000) but when you load up in the Hierarchy loading call you get around 3000 or so verts. This is due to redundancy and is mostly corrected with the newer Microsoft exporters but you can also do the weld/optimize and remap skin info.

I mean X isn't the greatest format ever made, but we used it here at work because we didn't have the time to build a format, exporter, tools, and animation system for the project we are currently working on. It does everything we want, right now skeletal FK animation, we built morph target support, etc with a very optimized math library and functionality.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!