Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Enhanced Animations - How do I rotate a limb/bone?

Author
Message
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 10th Jun 2010 13:45
After studying the example code given with EnAn I think I understand how OAC's and animation files work, but I still can't figure out how to use EnAn to do something as simple as rotate all limbs/bones to (0,0,0). My current code is:



The idea was to create a blank animation file (from "Obj.X" limb structure) then create a single keyframe for each limb, that could be modified to rotate each limb manually - only it doesn't work. The object loads in the first frame of any animation the .X file holds, rather than appearing in the default pose.

I also don't understand the difference between "keys" and "time" - in DBC the animation just played through the keys in order. in EnAn, I'm not sure if the keys are just numerical identifiers whose actual value doesn't matter, while "time" refers to a place on a timeline and holds the keys in order. Any ideas?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 10th Jun 2010 14:43 Edited at: 10th Jun 2010 14:44
@Robert The Robot

You can animate manually any bones of your model.Download this example and see how it works.

Cheers.



I'm not a grumpy grandpa
Ron Erickson
Moderator
23
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 10th Jun 2010 17:58 Edited at: 10th Jun 2010 18:00
Robert,
I haven't tested your code but I may be able to answer some of your questions.

Quote: "The object loads in the first frame of any animation the .X file holds, rather than appearing in the default pose."

This is because, typically, when you export your model, the first frame is actually stored as part of the bone structure. So, the first frame of animation becomes the default pose. If you want to use the default pose, then make the first frame of your animation actually be the default pose. Let the second frame start your animation. It is a pain in the butt.

Quote: "I also don't understand the difference between "keys" and "time" - in DBC the animation just played through the keys in order. in EnAn, I'm not sure if the keys are just numerical identifiers whose actual value doesn't matter, while "time" refers to a place on a timeline and holds the keys in order. Any ideas?"

This is a simple concept, but kind of hard to explain. lol
DBpro actually works the same way. You just don't see the keys because you have no ability to modify the animation.
Let's say you have an animation that is 100 frames long. You will not necessarily have 100 "keys" for each limb of your model. You may have a Key at frame 0, then another at frame 10, then another at frame 25, then another at frame 60, then another at frame 65. then another at frame 85, and finally a last one at frame 100. When your animation plays, it goes frame by frame. When the animation is at frame 0, it is exactly at the first key. The animation pose is exactly what the first key tells it to be. Now, the next key isn't until frame 10. Once the animation reaches frame 10, it becomes exactly as the second key tells it to be. But, when the frame is between the two keys, it blends them (interpolates) to find a new rotation between. For example, if you were at frame 5, (the first key is at frame 0 and the second key is at frame 10), you would be half way between the two keys. The animation pose would then be half way between where the first key and second key tell the pose to be.
The reason for this is animation data takes up a lot of space! If you can completely describe a 100 frame animation in 5 or 6 keys, you significantly reduce the amount of data that you have to store and load. It becomes much more efficient.

I hope this helps!

Ron


a.k.a WOLF!
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 11th Jun 2010 16:47 Edited at: 11th Jun 2010 16:48
@chafari
Thanks for the example code - I hadn't realised that DBPro treats bones and limbs in the same way.

@Ron Erickson
Quote: "This is because, typically, when you export your model, the first frame is actually stored as part of the bone structure."

Ah, so is there any way I can clear this? Or have I just been lucky in my choice of test models?

I experiemnted with the DarkMatter alien mutant, and by default it loads in the DBP pose shown in the attached JPG. Running this code in DBC and DBP:



There are two outcomes. DBC rotates the limbs back to what I call the "default pose" (see JPG), but DBP seems to think that the rotations applied to generate the first frame of animation is the "default pose" and treats that as rotations of (0,0,0). Is there any way around that, or is this just normal?



I also wanted to ask about the keys and timeline values again - I don't think I asked the right question last time. EnAn_AnimInsertKey returns a value, which I assume is the keyframes "number" (the "Key" parameter in EnAn_AnimModifyKeyRot, for example) but you can also set the time at which this keyframe occurs using EnAn_AnimModifyKeyTime. I don't quite understand this difference - DBC allows you to set keys such as 3, 6, 25, with the gap between them determining how long it takes to move from one key to the next. In EnAn, would I be correct in thinking that the "key" value is just an identifier number, while the "time" value determines how long it takes to transition from one frame to the next?

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Ron Erickson
Moderator
23
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 11th Jun 2010 21:08 Edited at: 11th Jun 2010 21:09
Quote: "There are two outcomes. DBC rotates the limbs back to what I call the "default pose" (see JPG), but DBP seems to think that the rotations applied to generate the first frame of animation is the "default pose" and treats that as rotations of (0,0,0). Is there any way around that, or is this just normal?"


Will any animation play at all in DBC on that model? I think the reason is that DBC doesn't support bone animation. So, the vertices are not going where the bones tell them to go. In DBpro, the mesh is deformed by where the bones are. Like I said, I think the only real way around this is to actually modify your model in your animation package and add a new initial frame of animation that is set at the default pose. Then, let the next frame be the start of all your animation.

Quote: "I also wanted to ask about the keys and timeline values again - I don't think I asked the right question last time. EnAn_AnimInsertKey returns a value, which I assume is the keyframes "number" (the "Key" parameter in EnAn_AnimModifyKeyRot, for example) but you can also set the time at which this keyframe occurs using EnAn_AnimModifyKeyTime. I don't quite understand this difference - DBC allows you to set keys such as 3, 6, 25, with the gap between them determining how long it takes to move from one key to the next. In EnAn, would I be correct in thinking that the "key" value is just an identifier number, while the "time" value determines how long it takes to transition from one frame to the next?"

When you insert a key, you give it a "Time" parameter. The time parameter is not an amount of frames until the next key. It is a true marker of the frame that the key takes place on. As you add a new key, EnAn will look through your animation data and find which two existing keys the new key belongs between. For instance, say you have an animation with the following keys/times.
Key: - Time:
1 - 0
2 - 5
3 - 10
4 - 20
5 - 25
6 - 40
This animation is 40 frames long with key frames taking place on frames 0, 5, 10, 20, 25 and 40. If you insert a new key with a time of 15, the new key would become key 4. The existing keys 4, 5, and 6 would become keys 5, 6, and 7. The total animation length has not changed. It is still 40 frames long.


Ron


a.k.a WOLF!
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 12th Jun 2010 13:13 Edited at: 12th Jun 2010 13:14
The model will play in DBC - it's limb-based (I should have made that clearer).

Quote: "Like I said, I think the only real way around this is to actually modify your model in your animation package and add a new initial frame of animation that is set at the default pose."

Actually, I'm trying to write my own animation package! That's why I'm trying to figure out how to create a default pose based on the data DBPro gives me. I'm really intrigued by the way that DBC lets the limb animation data simply modify the default rotation, scale and position, yet DBPro makes the default become the first frame of animation. I'm just wondering if there is any way of making the DBPro pose turn back into the DBC pose?

Thanks for the explanaion of EnAn's keyframes and time parameters - that bit makes perfect sense to me now!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."

Login to post a reply

Server time is: 2026-07-25 16:21:22
Your offset time is: 2026-07-25 16:21:22