Search code examples
c++winapivisual-studio-2015directx-11direct3d

How do I build an SdkMesh with Textures and MeshConvert.exe?


I need to build an sdkmesh file similar to Tiny.sdkmesh that comes with DirectX SDK.

I have the mesh file base.obj

And I have the texture in textures/base.jpg

I'm running meshconvert.exe with the following command line

meshconvert.exe base.obj -n -op -tb

It generates a base.sdkmesh but it has no texture file

I tried saving the jpeg texture as a dds file using paint.net

When I render my model, it comes out all black. But when I render the tiny.sdkmesh model, it comes out textured.

Can someone help explain this undocumented tool and procedure?

Thanks,


Solution

  • The latest version of meshconvert is part of the DirectXMesh, so unless you specifically need legacy .X file support (which you don't since you are using Wavefront OBJ) you should use that one instead of the legacy DirectX SDK.

    The default behavior of meshconvert is to take the texture file names from your Wavefront OBJ's mtl file and embed them as .dds versions of the same file (so texture.jpg is stored as texture.dds). You can generate the dds using the texconv tool in the DirectXTex project. You can also tell the latest meshconvert to leave the filenames alone using the -nodds switch.

    You can also create SDKMESH files from Autodesk FBX files using the DirectX SDK Samples Content Exporter. This exporter will 'cook' the textures as part of the export process as well.

    If you have a sdkmesh and you are trying to figure out what texture references it has in it, try using the sdkmeshdump console utility to see what's in it.

    Disclaimer: SDKMESH is really only intended as a learning format used in DirectX samples. You can use it in your project, but you will most likely want to develop your own runtime container format if your engine/project becomes sophisticated. It mostly has the value of existing, so YMMV.

    See DirectXMesh wiki and the DirectX SDK Content Exporter wiki

    If you are using DXUT, you should use the latest version from GitHub. sdkmesh is also supported by the DirectX Tool Kit for DX11 and DX12