XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

D3DXMATERIAL gets garbled texture name from X file when texture not in material

Last post 08-29-2008 4:35 AM by Roonda. 3 replies.
  • 08-28-2008 6:54 AM

    D3DXMATERIAL gets garbled texture name from X file when texture not in material

    I'm trying to support X files with and without textures. Here's an example of the material section of an X file that has been exported by Pandasoft 3ds Max exporter:

      Material {
       0.650980;0.898039;0.898039;1.000000;;
       0.000000;
       0.650980;0.898039;0.898039;;
       0.000000;0.000000;0.000000;;
      }

     

    I then use D3DXLoadMeshFromX, pretty much like all the samples I've checked:

     

     
    if( !FAILED(D3DXLoadMeshFromX( 
                    meshFileName.c_str(), D3DXMESH_MANAGED, m_pDevice, NULL,  
                    &pMaterialBuffer, NULL, &numMaterials,  
                    &pMesh ) ) ) 
        // Apply textures and materials from the mesh 
        D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pMaterialBuffer->GetBufferPointer(); 
        // ETC ETC 

     

    But for some reason, d3dxMaterials[0]->pTextureFileName != NULL. All the samples I have seen check for NULL at this point before loading a texture, but since my texture file name seems to point to random garbage, I can't do this. Anybody seen this before or have any ideas?

  • 08-28-2008 11:15 AM In reply to

    Re: D3DXMATERIAL gets garbled texture name from X file when texture not in material

    In the documentation about D3DXLoadMeshFromXof it says that the texture name is assigned a default value. I thought that happened when supplied with an effect instance buffer, but that might not be the case.

    If you look at sdkmesh.h in DXUT, CDXUTXFileMesh first checks if the texture file name isn’t null and then it validates the texture with D3DXGetImageInfoFromFile, if this fails it just continues.

    You can use  a similar approach, try loading the texture and if that fails just continue or set a default white texture.

  • 08-29-2008 12:49 AM In reply to

    Re: D3DXMATERIAL gets garbled texture name from X file when texture not in material

    I just tried this by taking tiger.x from the SDK and removing the texture filename node from the .x file.  I then loaded it with D3DXLoadMeshFromX and checked the materials array that was returned.  A single material was returned and the texture filename pointer was NULL in that material.  So I can't reproduce what you're seeing.  I'm using the March 2008 SDK for this test.
  • 08-29-2008 4:35 AM In reply to

    Re: D3DXMATERIAL gets garbled texture name from X file when texture not in material

    Thanks for the help guys. It seems that something strange was going on... I did a rebuild all and now I can't reproduce it either! Sorry to waste your time.

     

    Bad Habit:
    try loading the texture and if that fails just continue

     

    That is what I was doing but I wanted to be able to provide a meaningful message to the user about the name of the texture not being found, but only if it wasn't NULL. Thanks again!.

Page 1 of 1 (4 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG