Jump to content

Start playing animation


photo

Recommended Posts

I have imported FBX with animations using Editor. During runtime at some action I'm creating from it NodeReference in code:

Unigine::NodeReferencePtr fbxReference = Unigine::NodeReference::create( "man_animated.fbx" );

I know that this object have 3 animations with 2 skinned meshes. In Editor to start playing animations I must select all skinned meshes of this object and hit Play under Mesh skinned section. But how can I achive same result from code at runtime?

 

EDIT:
Ok, so basically I created this code and it seems to work, but is this proper way of doing this task?

Unigine::NodeReferencePtr fbxReference = Unigine::NodeReference::create( "man_animated.fbx" );
//...some transformation manipulations
StartAnimationRecursive( fbxReference->getReference( ) );

...

void StartAnimationRecursive( Unigine::NodePtr node )
{
	Unigine::ObjectMeshSkinnedPtr meshSkinned = Unigine::ObjectMeshSkinned::cast( node );
	if ( meshSkinned )
	{
		meshSkinned->setAnimName( meshSkinned->getAnimationName( 1 ), 1 ); //TODO here goes the animation number to play, 0 seems to be "rest" pose (?)
		meshSkinned->setLoop( 1 );
		meshSkinned->play( );
	}

	for ( int i = 0; i < node->getNumChildren( ); ++i )
		StartAnimationRecursive( node->getChild( i ) );
}

 

Edited by arzezniczak
Link to comment

Hello,

17 hours ago, arzezniczak said:

Ok, so basically I created this code and it seems to work, but is this proper way of doing this task?

Yep that code is fine.

17 hours ago, arzezniczak said:

0 seems to be "rest" pose (?)

Yes, by default fbx stores an empty animation and real animation sequence.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...