Jump to content

Skeleton animation ranges and total frames


royibernthal
 Share

Recommended Posts

1) Is there a way to create animation ranges via blender? e.g. define there that between 50-100 is a "win" animation, instead of defining it in bjs as follows:

skeleton.createAnimationRange("win", 50, 100);

Maybe by exporting markers?

https://www.blender.org/manual/animation/markers.html

 

2) Is there a way to get the total frames of a skeleton in bjs?

Link to comment
Share on other sites

Hiya Royi... umm... #1  -  if you look here:  https://github.com/BabylonJS/Babylon.js/blob/master/src/Animations/babylon.animation.js

...and search the document for _ranges, you'll see that animation ranges are definitely active.  Have you searched the forum?  There might be more talk.  But yes, I think SOMETHING would need to be set in Blender... so that the ranges/markers are exported.  I don't have much info on that.... sorry.

#2 - You can drill into the animation objects on each bone, and get the _keys.length.  Take a look at this PG.  In line 72, I am using this method to report the # of keys for our friend...  Four Bone Rabbit.  :)  But notice that Animation objects have a toString() method, as well.  I use that in line 71, and it delivers quite a bit of good info, too.

Now, you are well on your way to making your own "Bone Animations Report", yes?  It might be worth noting that this animation has 141 keys... but it is 100 frames.  The # of keys and the # of frames... need not match.

THIS playground was used to test "ping-pong" animation, where the animation runs standard, forward, for 141 keys, and then I reverse the order of the keys, and begin an animation again, which makes the animation run backwards.  Then the keys are reversed again, and off we go again.  Because of the ping-pong, this animation is quite smooth.

We do not have a "ping pong" animation cycle mode, so I wanted to see what it took to make one.  Thx to Deltakosh for helping me get it working properly.  The post that started it... is here

It might be interesting to notice that the mesh boundingBox does not bend WITH the rabbit mesh, nor do the bone-lines bend in the debug layer skeleton viewer.  This... is normal, I hear.  It is because bones are not really mesh.  They are matrix transformations. :o

What would you think of an "Animations Report" built-into the BJS Debug System?  I bet that would be handy for your needs, huh?  "The BJS Skeleton Report"... published live... from the boneyard.  :)  Sounds like a great weekend project and PR contribution, eh?  ;)

Link to comment
Share on other sites

Hey, sorry for the late reply, busy week.

Thanks, I'll use that way to access the keys.

I searched the forum, I didn't see anything about exporting ranges from blender.

Actually an "Animations Report" wouldn't be handy at all for my needs :)

However I don't mind contributing to the skeleton tutorial like I mentioned in the PM, just give me some guidance regarding the format and publishing.

Link to comment
Share on other sites

Thanks

There are indeed tons of topics discussing different issues, but I couldn't find any tutorial explaining from start to end how to do it, not that I could find anyway.

 

If I understand correctly from the link you attached - Blender Exporter automatically exports animations actions into animation ranges in bjs.

It might be more of a blender question, but how do I create different actions for different frame groups?

All my keyframes and animations are grouped under a single action automatically, possibly since they're all animating the same properties of the same bones.

I'd like to manually group different keyframes under different actions. How do I do that?

e.g. manually set frames 1-10 to "firstAction", and frames 11-20 to "secondAction".

 

btw, should I start animating in blender from frame 0 or 1?

Link to comment
Share on other sites

I went over all of it solution by solution. I didn't really find anything that works/relevant or actually explains how to create separate actions, people just say it like it's obvious how to do it.

One thing that I didn't try and may work is creating a new scene per animation, but it seems like an overkill that I'd like to avoid, it's more of an answer to the specific question in the link.

 

With that said, I encountered this topic:

https://www.blender.org/forum/viewtopic.php?t=25849

 

So I now know how to add a new action:

Quote

in dope sheet editor, change mode to action editor and add a new action

but I've yet to successfully set the start-end frames of each action.

 

Pressing N in the NLA editor as suggested in here doesn't bring up the settings of the selected strip (doesn't do anything actually), the reply is from 2012 so it's probably outdated, that or I'm missing something.

https://blenderartists.org/forum/showthread.php?241204-Start-and-End-frame-for-Animations

Link to comment
Share on other sites

@Deltakosh: well you picked a good day to ping me - "Thanksgiving Day" in Canada. So a holiday :lol:

@royibernthal: You have two basic ways to export your animations :

1.) Just a single animation containing all the actions that a rig will have the option to carry out - see image 1. Exported like this code in the .babylon file:

"ranges":[{"name":"allActions","from":0,"to":132}]}]

Although it has a range name, there is only one animation in the range.

2.) Multiple animations that will be exported with individual name ranges - see image 2. Code will look like this in the .babylon file:

"ranges":[{"name":"idleAction","from":0,"to":41},{"name":"runAction","from":50,"to":81},{"name":"walkAction","from":90,"to":121}]}]

Typically when I work with animations, I have open a window with the "Dope Sheet" visible(green A) and set to "Action Editor" (green B). If the rig/mesh you are using it has an animation, then this window should look like image 1. If it has multiple animations then clicking on the action selector (green C) will bring up a list of all the animations attached to the rig (image 2).

If the rig/mesh has no attached animations - the space where the animation name is will look like a button with a "+" and the word "New". Click it to start to add an animation. (Tip: if you do not see a number beside the action name box (or a 0 beside and action name) - click the "F" button - you can lose animations when you save and later reload your Blender file)

Don't waste your time with the NLA editor. I know that if you switch between animations when you have multiple animations the "End" box in Blender does not change but the Exporter automatically uses the the last frame of the animation as the end frame.

And I always load the exported .babylon file into a text editor and  search for the word "range" to get all the exact details for start and end for each animation .

cheers, gryff :)

 

r_animations1.png

r_animations2.png

Link to comment
Share on other sites

@gryff Thanks for the detailed explanation :)

I failed to understand though - how do I define the animation range of each action inside blender? (putting bjs aside for a moment)

e.g. On the timeline you see "idleAction" from frames 1-30, and then you see "runAction" from frames 50-80, and you can tell that different frames have different actions.

I can create a new action but I can't set its frame ranges (regardless of bjs).

It's very possible that you already answered this question and I simply didn't understand.

Link to comment
Share on other sites

2 hours ago, royibernthal said:

I can create a new action but I can't set its frame ranges (regardless of bjs).

@royibernthal : the frame ranges are defined by the Blender Exporter using the multiple animations start and end keyframes as in this example:

"ranges":[{"name":"firstAction","from":0,"to":46},{"name":"secondAction","from":60,"to":91},{"name":"thirdAction","from":100,"to":161}]}]

I created 3 different actions called "firstAction", secondAction" and "thirdAction" and in that order. All of them started at frame 1 - and had different end values. The exporter combines them and leaves some empty space between the different actions for example between firstAction and secondAction

{"frame":45,"values":[1,-0.0001,-0.0037,0,-0.0002,0.9983, 0.0576,0,0.0037,0.0576,0.9983,0,0,0.1108,0,1]},
{"frame":46,"values":[1,0,0,0,0,0.9983,-0.0576,0,0,0.0576,0.9983,0,0,0.1108,0,1]},
{"frame":61,"values":[1,0,0,0,0,0.9983,-0.0576,0,0,0.0576,0.9983,0,0,0.1108,0,1]},
{"frame":62,"values":[1,0,0,0,0,0.9985,-0.0555,0,0,0.0555,0.9985,0,0,0.1108,0,1]},

See the gap? It saves with the file size. within the "ranges". The actions appear to be used/combined in the "ranges"  in the order that they appear in the list (alphabetical) . See image 2 above idle, run, walk in the list and the same sequence in the code I posted.

It begs the question as to what you mean by "set its frame range" ?

cheers, gryff :)

 

 

 

Link to comment
Share on other sites

@gryff Putting Blender Exporter and bjs aside -

Let's say I create a walking animation from frame 1-10.

I then create a running animation from frame 11-20.

Both animations automatically belong to a single action that's generated automatically by blender. In other words, this action consists of both animations (frames 1-20).

I create a new animation action manually.

Now I have the first action consisting of both animations (frames 1-20), and the second action is empty.

I'd like the first action to consist of frames 1-10, and the second action to consist of frames 11-20. How do I do that?

 

With that said, I might be looking at it all wrong - if what I'm asking doesn't make any sense - do you perhaps have a video that demonstrates creating more than one animation action in a blender file from start to end?

Link to comment
Share on other sites

2 hours ago, royibernthal said:

Let's say I create a walking animation from frame 1-10.

I then create a running animation from frame 11-20.

Both animations automatically belong to a single action that's generated automatically by blender. In other words, this action consists of both animations (frames 1-20).

@royibernthal:  So, you are trying to split a single animation into separate individual animations. Why did you do it that way in the first place? Why not just create an action for walk and then a new action for run?

I had a strange feeling that is what you were trying to do.

However,  such a single action can be split into new actions that just contain only walk or run etc.

For what I am about to say, See the seven sections (labelled 1-7) in the attached image below.

Step 1 : Open your Blender file with the rig/mesh & one long animation (called here : "allActions")  Open the Dopesheet window and chose "Action Editor" (1 below). Click the "F" button to bring up a number (2 usually) along side the action name so you don't lose the animation if you save your .blend file until you have finished.

Step 2 : Click the "+" button to create a new animation (see 2 below). This new action is not as you put it , "empty" but rather is a copy of the current "allActions" labelled "allActions.001" (This happens for at least Blender 2.71->2.76).

Step 3 : Now deselect all the key frames (the A key), and using the "Box Select" (B key), select all the keys to be deleted (3 below)

Step 4 : Hit the X key to delete all the selected key frames (4 below). Hi-light the name of the action and change it to something like "10walk" then click the "F" button so it will be saved.

Now we will get at the rest of the animations with the steps above plus one additionbal step:

Step 5 : Change the animation in the selection box to the original "allActions" animation and click the "+" button again. We get the "allActions.001" again.(5 below) This time select a different set of key frames to be deleted (using the A key  and B keys as above)

Step 6 : Now delete those keys with the X key (6 below). 

Step 7 :Then select the remaining key frames (A key), then hit the G key and drag those key frames down to frame 1. (7 below). This is the additional step. Rename the animation (perhaps "20Run") and hit the "F" button to make sure it is saved.

Repeat steps 5 - 7 for and other parts of your multi-part single animation

Save this file in case you have made a mistake.

Now one last time bring up the  "allActions" in the action selection box and then Shift + the "X" button. You will get a warning about this "allActions" will not be saved. Now Save the file with a different name and then re-open it You should have your actions in separate pieces named appropriately for export as "ranges"  to a babylon file.

cheers, gryff :)

Edit: changed the image to two separate images as the forum software resized the single original image so that it became unreadable. The number sequence is still the same.

 

 

r_animations2a1.png

r_animations2a2.png

Link to comment
Share on other sites

@gryff Thanks again for the very detailed explanation :) I played around a little with what you said, and I think I more or less got the hang of creating / modifying actions. Ranges are exported to bjs like a charm as well.

Some small followup questions - 

1) How do I completely delete an action?

2) Is it possible to start animating from frame 0? (if it even makes sense)

If so, which is more common, 0 or 1?

3) Do I need a camera and a light in my .blend file if I'm only interested in creating a 3d model for bjs? (they are automatically generated for each new .blend file)

Do they even show on bjs if I load a mesh via the assets manager rather than via SceneLoader.Load?

Link to comment
Share on other sites

@royibernthal

4 hours ago, royibernthal said:

1) How do I completely delete an action?

I explained this in my previous post. Bring the action you want to delete in to the "Action Name', then Shift + "X" button. It will give you a warning about that action will not be saved. Now save the file under a different name (just in case you change your mind). Then reload that new file - the action you deleted will be gone.

4 hours ago, royibernthal said:

2) Is it possible to start animating from frame 0? (if it even makes sense)

You can start your animations at frame zero but all the skilled animators that I have learnt from start at frame 1. And you will notice that by default the Timeline in Blender starts at frame1. Several years ago when I worked with Unity 3D, starting at frame 0 caused issues as Unity would import it at frame -1. So I always start at frame 1.

4 hours ago, royibernthal said:

3) Do I need a camera and a light in my .blend file if I'm only interested in creating a 3d model for bjs?

No. I normally always have a camera and light but I put them in their own separate layer. I set the Exporter to "Export Selected Layers Only". When that is set I can then chose to export or not the camera and light just by which layers I chose to export.

cheers, gryff :)

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...