locked
3dmax file in directx RRS feed

  • Question

  • hi all ,

     

    i have model in 3dmax and this model include materials (pictures is 2d) and i'm convert this file to .x  , and i trying to load this model (load mesh) in visual c# using direct x and i'm failing

    i don't know where is the problem

    how can i load or import this model with this materials in the visual c# using direct x program???

    please i hope to help me because this program is my final project in my university , and i don't have time

    i'm very searching  about it but nothing

    please i need code to help me

    quickly please anyone help me

     

    see you later ...

     

     

    Saturday, April 28, 2007 6:11 PM

All replies

  • 1st.
    Download Panda DirectX 3DSMax Exporter
    for 9th Max :

    http://www.andytather.co.uk/Panda/Files/3dsmax9/PandaDirectXMaxExporter4.9.63.0.zip

    for 8th Max :
    http://www.andytather.co.uk/Panda/Files/3dsmax8/PandaDirectXMaxExporter4.8.63.0.zip

    Then export your model to project's Bin directory and copy there your textures (i know some formats are not supported so convert them firstly to .tga, .bmp, .jpg., .png (before exporting model, remap textures)).



    2nd.
    Mesh loading method

    public static Mesh LoadMesh(Device device, string file, ref Material[] meshMaterials, ref Texture[] meshTextures)
    {
    ExtendedMaterial[] mtrl;

    // Load our mesh
    Mesh tempMesh = Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl);

    // If we have any materials, store them
    if ((mtrl != null) && (mtrl.Length > 0))
    {
    meshMaterials = new Material[mtrl.Length];
    meshTextures = new Texture[mtrl.Length];

    // Store each material and texture
    for (int i = 0; i < mtrl.Length; i++)
    {
    meshMaterials[ i ] = mtrl[ i ].Material3D;
    if ((mtrl[ i ].TextureFilename != null) && (mtrl[ i ].TextureFilename != string.Empty))
    {
    // We have a texture, try to load it
    meshTextures [ i ] = TextureLoader.FromFile(device, @"..\..\" + mtrl[ i ].TextureFilename);
    }
    }
    }

    return tempMesh;
    }

    This is stolen from "managed DirectX 9 : Games & Graphics Programming" by T. Miller

    You'll need

    private Mesh objMesh = null;
    private Material[] objMaterials = null;
    private Texture[] objTextures = null;

    then call
    LoadMesh(dxDevice, "myobject.x", ref objMaterials, ref objTextures);

    3rd
    Render model

    for (int i = 0; i < objMaterials.Length; i++)
    {
    device.Material = objMaterials[ i ];
    device.SetTexture(0, objTextures[ i ]);
    objMesh.DrawSubset( i );
    }

    Place this into OnPaint()

    P.S. you must place
    using Microsoft.DirectX;
    using Microsoft.DirectX.Direct3D;
    using Direct3D = Microsoft.DirectX.Direct3D;
    in the very beginning of the main class to import all the needed libs
    Sunday, April 29, 2007 8:58 AM
  • what's the mean of this ????

     

    http://www.andytather.co.uk/Panda/Files/3dsmax9/PandaDirectXMaxExporter4.9.63.0.zip

     

    when i can download it and how i can open it because i'm trying and i'm fail

     

    i'm writing the code try to applied it on c#.net using direct x and i go step by step without having the goal

     

    the materials dose't appearent , picture is bitmap (.bmp)

     

    how can i solving this problem????

     

    plz help me  




    Forum: Game Technologies: DirectX 101
    Posted: : Sunday, April 29, 2007 8:58 AM
    Post Subject: : Re: 3dmax file in directx
     Punkoff wrote:
    1st.
    Download Panda DirectX 3DSMax Exporter
    for 9th Max :

    http://www.andytather.co.uk/Panda/Files/3dsmax9/PandaDirectXMaxExporter4.9.63.0.zip

    for 8th Max :
    http://www.andytather.co.uk/Panda/Files/3dsmax8/PandaDirectXMaxExporter4.8.63.0.zip

    Then export your model to project's Bin directory and copy there your textures (i know some formats are not supported so convert them firstly to .tga, .bmp, .jpg., .png (before exporting model, remap textures)).



    2nd.
    Mesh loading method

    public static Mesh LoadMesh(Device device, string file, ref Material[] meshMaterials, ref Texture[] meshTextures)
    {
    ExtendedMaterial[] mtrl;

    // Load our mesh
    Mesh tempMesh = Mesh.FromFile(file, MeshFlags.Managed, device, out mtrl);

    // If we have any materials, store them
    if ((mtrl != null) && (mtrl.Length > 0))
    {
    meshMaterials = new Material[mtrl.Length];
    meshTextures = new Texture[mtrl.Length];

    // Store each material and texture
    for (int i = 0; i < mtrl.Length; i++)
    {
    meshMaterials[ i ] = mtrl[ i ].Material3D;
    if ((mtrl[ i ].TextureFilename != null) && (mtrl[ i ].TextureFilename != string.Empty))
    {
    // We have a texture, try to load it
    meshTextures [ i ] = TextureLoader.FromFile(device, @"..\..\" + mtrl[ i ].TextureFilename);
    }
    }
    }

    return tempMesh;
    }

    This is stolen from "managed DirectX 9 : Games & Graphics Programming" by T. Miller

    You'll need

    private Mesh objMesh = null;
    private Material[] objMaterials = null;
    private Texture[] objTextures = null;

    then call
    LoadMesh(dxDevice, "myobject.x", ref objMaterials, ref objTextures);

    3rd
    Render model

    for (int i = 0; i < objMaterials.Length; i++)
    {
    device.Material = objMaterials[ i ];
    device.SetTexture(0, objTextures[ i ]);
    objMesh.DrawSubset( i );
    }

    Place this into OnPaint()

    P.S. you must place
    using Microsoft.DirectX;
    using Microsoft.DirectX.Direct3D;
    using Direct3D = Microsoft.DirectX.Direct3D;
    in the very beginning of the main class to import all the needed libs
    Tuesday, May 15, 2007 6:10 AM