Loading CMO exception

Nov 12, 2013 at 10:52 PM
I am using the sample project (in visual studio 2012) and I am trying to load a .cmo file that I created from a .fbx. But I get an exception when creating the .cmo (Unhandled exception at at 0x74EFC41F in SimpleSampleTK.exe: Microsoft C++ exception: std::exception at memory location). I have to continue 6 times and then I see the 3d model (in black).

Values on throw:
&ThisException 0x0035cb80 {ExceptionCode=3765269347 ExceptionFlags=1 ExceptionRecord=0x00000000 {ExceptionCode=??? ...} ...} EHExceptionRecord *

&ThisException.params 0x0035cb94 {magicNumber=429065504 pExceptionObject=0x0035cbcc pThrowInfo=0x0108d1c0 {SimpleSampleTK.exe!__{SimpleSampleTK.exe!__TI1?AVexception@std@@} {...} } EHExceptionRecord::EHParameters *

ThisException {ExceptionCode=3765269347 ExceptionFlags=1 ExceptionRecord=0x00000000 {ExceptionCode=??? ExceptionFlags=...} ...} EHExceptionRecord

ThisException.NumberParameters 3 unsigned long

Stack:
KernelBase.dll!74efc41f()   Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]    
msvcr110d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 152    C++
SimpleSampleTK.exe!MyEffectFactory::CreateTexture(const wchar_t * name, ID3D11DeviceContext * deviceContext, ID3D11ShaderResourceView * * textureView) Line 51  C++
SimpleSampleTK.exe!DirectX::EffectFactory::Impl::CreateEffect(DirectX::IEffectFactory * factory, const DirectX::IEffectFactory::EffectInfo & info, ID3D11DeviceContext * deviceContext) Line 178    C++
SimpleSampleTK.exe!DirectX::EffectFactory::CreateEffect(const DirectX::IEffectFactory::EffectInfo & info, ID3D11DeviceContext * deviceContext) Line 289 C++
SimpleSampleTK.exe!DirectX::Model::CreateFromCMO(ID3D11Device * d3dDevice, const unsigned char * meshData, unsigned int dataSize, DirectX::IEffectFactory & fxFactory, bool ccw, bool pmalpha) Line 777 C++
SimpleSampleTK.exe!DirectX::Model::CreateFromCMO(ID3D11Device * d3dDevice, const wchar_t * szFileName, DirectX::IEffectFactory & fxFactory, bool ccw, bool pmalpha) Line 829    C++
SimpleSampleTK.exe!OnD3D11CreateDevice(ID3D11Device * pd3dDevice, const DXGI_SURFACE_DESC * pBackBufferSurfaceDesc, void * pUserContext) Line 291   C++
SimpleSampleTK.exe!DXUTCreate3DEnvironment11(ID3D11Device * pd3d11DeviceFromApp) Line 2563  C++
SimpleSampleTK.exe!DXUTChangeDevice(DXUTDeviceSettings * pNewDeviceSettings, ID3D11Device * pd3d11DeviceFromApp, bool bClipWindowToSingleAdapter) Line 1853 C++
SimpleSampleTK.exe!DXUTCreateDevice(D3D_FEATURE_LEVEL reqFL, bool bWindowed, int nSuggestedWidth, int nSuggestedHeight) Line 1654   C++
SimpleSampleTK.exe!wWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, wchar_t * lpCmdLine, int nCmdShow) Line 153   C++
SimpleSampleTK.exe!__tmainCRTStartup() Line 528 C
SimpleSampleTK.exe!wWinMainCRTStartup() Line 377    C
kernel32.dll!76e1336a() Unknown
ntdll.dll!77349f72()    Unknown
ntdll.dll!77349f45()    Unknown

I really don't know if I am forgetting something. Hope someone can help me out!

Thanks in advance
Coordinator
Nov 13, 2013 at 12:24 AM
Edited Nov 13, 2013 at 12:24 AM
Enable C++ "Break on Exceptions". You'll likely see that you are missing a .CSO, .DGSL.CSO, or .DDS file that is required by your model. It's either missing from your package, is located in a different directory, or got renamed by the VS content pipeline.
Nov 13, 2013 at 9:20 PM
Thanks for the quick reply, but I can't fix it.

Maybe you can tell me what I am doing wrong.

What I am doing:
  1. Create a simple box in autodesk 3ds max
  2. Export the scene to a fbx in the sample (http://code.msdn.microsoft.com/DirectXTK-Simple-Win32-23db418a) project folder
  3. Include it into visual studio (In visual studio I added the meshcontent pipeline in the build customizations)
  4. I set the output folder to the project folder, now it creates a cmo when I build (this works)
  5. I added the line g_Model = Model::CreateFromSDKMESH( g_pd3dDevice, L"tiny.sdkmesh", *g_FXFactory, true ); to g_Model = Model::CreateFromCMO( g_pd3dDevice, L"Cube.cmo", *g_FXFactory, true );
There is no texture file, because the model exported one and I don't set my own hlsl or dgsl effect file (I assume it uses a default)

I hope you can help me
Coordinator
Nov 14, 2013 at 1:10 AM
Edited Nov 14, 2013 at 7:37 AM
Again, Break on Exceptions in the debugger and determine exactly what file is missing that results in the exception being thrown...

The fact that SimpleSampleTK.exe!MyEffectFactory::CreateTexture is in your callstack means it's missing a texture file that was referenced by a loaded model. Remember that the texture data is NOT in the .CMO file... just a filename to a texture file that is expected to be available at loadtime as a .DDS file.

Note I filed 1053 to improve the library with some key debugging messages around this area.
Marked as answer by walbourn on 1/23/2014 at 11:25 PM