on animating a dwarf

Feb 23, 2012 at 9:26 PM
Edited Feb 23, 2012 at 11:50 PM

Hi,

As a test I downloaded this model and plugged it into the "skin and bones" example.

http://www.3d-resources.com/download-model/56.html

I have code that looks like below. If I use static textured I see two versions, a solid one that doesn't move and an animated one with just some markers:

http://s14.postimage.org/u6ygo0x2p/dwarf.png

If I use GeneratedSkinnedTextured I don't see the solid dwarf at all, just the markers.

Why is actor optional in the Load() method? Is the way I'm setting the material correct?

Thanks,

Michael

 m_pActor = new SkinnedActor();
 GeometryPtr pGeometry = GeometryLoaderDX11::loadMS3DFileWithAnimation( std::wstring( L"dwarf1.ms3d" ), m_pActor);
 MaterialPtr pMaterial = MaterialGeneratorDX11::GenerateStaticTextured(*RendererDX11::Get());
//MaterialPtr pMaterial = MaterialGeneratorDX11::GenerateSkinnedTextured(*RendererDX11::Get());
m_pActor->GetBody()->SetMaterial( pMaterial );


ResourcePtr ColorTexture = RendererDX11::Get()->LoadTexture( L"dwarf.jpg" );
ShaderResourceParameterWriterDX11* pTextureParameter = new ShaderResourceParameterWriterDX11();
pTextureParameter->SetRenderParameterRef(
	(RenderParameterDX11*)m_pRenderer11->m_pParamMgr->GetShaderResourceParameterRef( std::wstring( L"ColorTexture" ) ) );
pTextureParameter->SetValue( ColorTexture );
m_pActor->GetBody()->Parameters.AddRenderParameter( pTextureParameter );


m_pActor->SetBindPose();
m_pActor->SetSkinningMatrices( *m_pRenderer11 );
m_pActor->PlayAllAnimations();


Coordinator
Feb 27, 2012 at 12:13 PM

Hello,

Sorry for the delayed response (I'm moving back to the U.S. at the moment and have been offline...).  I think what you are seeing is an issue with how that loading function interprets the animation data from the MS3D file.  While writing the book, I ran into the issue that it was working for some models and not for others, and I just haven't had time to revisit the topic yet.  Instead, I programmatically create the skeletons and animation data.  So unfortunately that means that there is no support for loading MS3D files with animation right now.  It may be worth investigating AssImp in the future to simplify the loading process and to support lots of different formats.

If anyone has expertise in the MS3D file format and/or AssImp, especially for animations, this would be a great place for a contribution!  Please let me know if you have implemented something like this or not, and if so, then take a look at the code and see if there is something I am missing or doing improperly.

I don't have access to the code at the moment, but I think the actor was made optional to allow an existing actor to be passed in, but to allow one to be created if it wasn't passed in.  However, I will need to take a look at the code to see exactly what is going on there...

Thanks for the post!

- Jason

Feb 27, 2012 at 1:00 PM

Thanks Jason. I thought  it was an issue in my code since there is no similar example. So if the importer were working what I have is correct (and it should be SkinnedTextured, right)?

Michael

Coordinator
Feb 27, 2012 at 1:09 PM

IIRC, that particular method puts its own material in the proper place within the actor - take a look into the method and follow the actor reference to see where the material is being set (sorry, I can't check out the code at the moment...).