Jump to content

Is there a way to know if an imported model comes with animation?


hit2501
 Share

Recommended Posts

Its me again :P

I can play animation of an imported model with:

new BABYLON.PlayAnimationAction(BABYLON.ActionManager.NothingTrigger, MESH_NAME, 0, FINAL_FRAME, 0),

 But this only works if I know the number of frames to put it as "FINAL_FRAME", now, I need to know if an imported model contains an animation (1) or not (0) and if it contains animation to know how many frames it haves.

Is this possible?

How can I make it?

Gracias.

Link to comment
Share on other sites

Someone can probably confirm this but as I understand it, you can check the imported mesh's animations array property. If it's null or length==0, you don't have an animation.

Something like:

if( MESH_NAME.animations && MESH_NAME.animations.length > 0 )
// you've got an animation

 

Link to comment
Share on other sites

Though it seems a little insane to be checking this at run time, it would work.  Better to just check the export log file.

Coming from Blender, there can be more than one blender action exported for a mesh.  They will all be in the animations property.  Blender also exports BABYLON.AnimationRanges.  These hold the start-stop frames of each Blender action.  That solves you needing to know which frames anything is in.

You just start the range by name: mesh.beginAnimation("Action", true);

Note: When more than one object in the .blend has actions, you must give names to the actions in the format 'objectname-action' so the exporter can figure out which action goes to which object.  Blender actions are not owned by a specific mesh in their API.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...