Thread: .x file loading

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    68

    .x file loading

    I am writing a .x file parser and there is really no documentation on the file layout. I used the directx file viewer with the direct x SDK, to load this dwarf.x and it displays the model correctly. But in the .x file I don't understand a part; maybe someone can look at the problematic part in the file and point out what is going on.
    open the file and goto where Dwarf_2_LOD0Mtl_maceSub5 is used as a material on the mesh, not the material declaration at the top of the file.

    Now, notice in in that specific MeshMaterialList, there are 6 materials listed, and if you scroll up, you will see the index 4 used for that mesh. My problem is, why the hell are there 6 materials listed there and only one is used? index 4? Where do I use the other 6 at? Can this be explained in short over these boards? If you check the rest of the file, you will see that is the only place where those other 5 materials are used anywhere.

    Here are the textures used in the model:
    SWORD03_color.DDS
    BODY02_color.DDS
    LEG02_color.DDS
    SHOULDER02_color.DDS
    HEAD02_color.DDS
    SHIELD02_color.DDS
    MACE02_color.DDS
    HEAD03_color.DDS
    BODY03_color.DDS
    LEG03_color.DDS

    *Edit*
    the .x file link works now
    Last edited by smasherprog; 05-27-2010 at 08:33 AM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Your link to dwarf.x seems to be down. Could it be that those materials have been added to the model but not actually used...as in they are there in the material library so to speak but never used on the actual model?

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Just use D3DXLoadMeshFromX. That way if the X file format changes you won't have to maintain your code and can rely on Microsoft's library. The less you have to maintain the better. The only time I would write my own loader is for proprietary formats and/or for much faster X file loading.

    When loading the file you should get 6 D3DXMATERIAL structures. Since I cannot see the file in question I can only guess as to what is going on.

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    68
    Ok, I had a w transposed with the a :P It works now.

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    68

    bump

    bumpage. Still looking for an answer. And in response to using direct x's library. The reason I am writing this is so that I can control what vertex streams are created without having to let direct x make it's own, then I would have to copy them out to separate streams that can be bound at different times. Also, creating a direct x 9 reference device to load the file. There is just alot of extra fluff. I am really held up on this one specific point that doesn't make any sense and there's no damned documentation.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You can still grab the final vertex buffers from the meshes and then discard the meshes later when you don't need them.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To find the memory leaks without using any tools
    By asadullah in forum C Programming
    Replies: 2
    Last Post: 05-12-2008, 07:54 AM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM