About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
Animation replace
Author Message
JonathonA Offline
Member

Post: #1
Animation replace
Evening everyone, I have been looking at the animation codes and trying to replace parts of the character model animations instead of replacing the entire animation when calling cskel.animate(..., ..., ..., true). As an example, take a look at the simple code here:

Code:
cskel.animate(L"Data/Anim/walk.anim", ..., ..., ...);
cskel.animate(L"Data/Anim/aim.anim", ..., ..., true); // Should only replace upper body animation, not whole body animation; how do we do this in Esenthel?

The "aim.anim" affects the lower body and I don't want that to happen, I just want it to affect the upper body, without having to change the .anim resource (unless I have to).

So the second animation completely replaces the first. What I would like to do is replace only part of the first animation with the second animation. In other words, tell the second animation to replace the upper body animation only, not the whole body animation.

So I can create a combination of animations like "walk and aim".

Is this is at all possible in Esenthel? I have been looking through the various animation methods and tried a few bits of code but haven't managed it so far. I am still getting to grips with every aspect of the engine so apologies if it takes me a few topics of posts to try and understand it smile

Look forward to hearing from everyone smile

EDIT: This is theory but would something like this work? I haven't managed to get it to work yet.

cskel.animate("Data/Anim/walk.anim", ..., ..., ...); // initial animation

SkelAnim* aimAnim = cskel.findSkelAnim("Data/Anim/aim.anim"); // get aim animation data

// Step 1: Pull out keyframe data for the upper body only
// Step 2: For each bone in upper body: forceMatrix(boneIndex, keyframeMatrixForThisBone, true);
// Step 3: build final transform matrix using updateMatrix(MatrixIdentity);
// Step 4: updateVelocities();

EDIT I did try the above but got nowhere with it, don't think I am going in the right direction.
(This post was last modified: 04-20-2012 08:55 PM by JonathonA.)
04-19-2012 09:19 PM
Visit this user's website Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #2
RE: Animation bone target
If that won't work, I'll try disabling (if its possible) the keyframes for the set of bones I do not wish to apply any animation to.

Trying out some codes now, if anyone has any thoughts they would be very much appreciated.
04-20-2012 08:29 PM
Visit this user's website Find all posts by this user Quote this message in a reply
EthanC Offline
Member

Post: #3
RE: Animation replace
Anyone?
04-21-2012 07:49 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Animation replace
Quote:The "aim.anim" affects the lower body and I don't want that to happen, I just want it to affect the upper body, without having to change the .anim resource (unless I have to).
you can just use replace parameter to true, blend parameter to 1.0
and make the "aim.anim" contain animation orientation keyframes for all upper bones, and no keyframes for all other bones.
04-22-2012 07:59 AM
Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #5
RE: Animation replace
Cheers for the response Esenthel. Yes I noticed that is what you did with the Esenthel RPG using the swing animations which do not affect the lower bones in any way.

So there is no way of discarding keyframes for other bones (that are not upper bones) in codes, so it has to be done in the Editor (can it be done in the Editor?) ?
(This post was last modified: 04-24-2012 03:27 PM by JonathonA.)
04-22-2012 12:27 PM
Visit this user's website Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #6
RE: Animation replace
Sorry for double-posting, and I am not saying this in a rude way, but I just want to check that my last post make sense?
(This post was last modified: 04-23-2012 02:25 PM by JonathonA.)
04-23-2012 02:24 PM
Visit this user's website Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #7
RE: Animation replace
Okay so after taking a look at the swing.anim and modifying our own "aim" animations using the Editor here is what happens...

Animation prior to keyframe deletion : lower body is offset (not pointing to the front), but since we can't replace animations for specified body parts I am going to have to delete keyframes for lower bones.
   

So in the above picture I have deleted keyframes across all modes for all leg bones but they are still oriented wrong. I used this animation in-game and the picture below shows what happens (I am actually walking directly ahead the way my arms are facing but the legs are pointing the wrong way so animation looks completely wrong).
   

Animation after keyframe deletion for Bip01 bone : deleting the keyframe animations across all modes for the "Bip01" bone causes this to happen, and the lower body is pointing in the right direction now.
   

But as you can see, upper body is not pointing in the right direction so I have to rotate one of the upper spine bones to achieve this:
   

Rotating one of the upper spine bones works, but I can't seem to rotate the lower spine bones so as you can see the models chest is completely out of line with the stomach/abdomen area of the body. The character has a slight "bobbing" motion also (as a result of deleting keyframes from some of the lower bones I believe) when I play the modified animation and set it to replace any previous animations.

The above sort of works but it is really awkward.

Couple of questions about modifying existing animations...

1. What modes should I be deleting keyframes from? I just deleted keyframes from every mode but the target orientation keyframes are the cause of the leg orientation so should I just delete from that mode?

2. Are empty orientation keyframes required?

3. Do I need to reset keyframes?

To be honest the work I had to do was tedious (awkward) so is there no way around it in codes?
(This post was last modified: 04-25-2012 11:57 PM by JonathonA.)
04-25-2012 11:47 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: Animation replace
(04-22-2012 12:27 PM)JonathonA Wrote:  So there is no way of discarding keyframes for other bones (that are not upper bones) in codes, so it has to be done in the Editor (can it be done in the Editor?) ?
yes you can discard keyframes in code for a CSkelBone after animating, CSkelBone::orn.zero(), rot.zero()
but I don't recommend this, just blend the aiming animation with replace value to true
04-26-2012 06:14 AM
Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #9
RE: Animation replace
(04-26-2012 06:14 AM)Esenthel Wrote:  
(04-22-2012 12:27 PM)JonathonA Wrote:  So there is no way of discarding keyframes for other bones (that are not upper bones) in codes, so it has to be done in the Editor (can it be done in the Editor?) ?
yes you can discard keyframes in code for a CSkelBone after animating, CSkelBone::orn.zero(), rot.zero()
but I don't recommend this, just blend the aiming animation with replace value to true

I tried the blend/replace in my very first post unless you are talking about something else?

Code:
cskel.animate(L"Data/Anim/walk.anim", ..., ..., ...);
cskel.animate(L"Data/Anim/aim.anim", ..., ..., true); // just replace walk.anim

The unmodified "aim.anim" replaced every keyframe in the "walk.anim" so the model moved but no walking animation was played only "aim.anim" (see the first picture in my post above to see what the frames in aim.anim look like).

That first picture shows the upper body orientation that I need when blending between walk and aim or run and aim or any other combination. As I said before, the upper body orientation and animations are all I care about in aim.anim.
04-26-2012 07:36 AM
Visit this user's website Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #10
RE: Animation replace
Hello everyone; I am trying to traverse (loop through) the skeleton bones in order; So if I start at the shoulder, I want to traverse (loop through) through the bicep, forearm then hand and so on.

I notice in the Editor that when you hover over a bone it identifies the children of it so I assumed I could traverse through the skeleton bones in codes but I cannot find any methods to do this. In fact, I can't find any methods that allow me to identify the children/parents of a bone.

Any suggestions?
05-21-2012 06:14 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
RE: Animation replace
isn't there a SkelBone::parent? index to bone in skeleton
05-23-2012 08:23 PM
Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #12
RE: Animation replace
Okay, so that is the only way to identify relationships or connections between SkelBones is that right?

So does that mean, as an example, I get a reference to the LeftShoulder SkelBone, loop through all SkelBones and check if the SkelBone::parent points to the LeftShoulder.

And I take it that is the only way of identifying relationships?

I was just surprised it wasn't in some form of traversable structure that maintained the relationships (similar to a Tree). Might be worth thinking about that for the future?
05-27-2012 09:31 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #13
RE: Animation replace
it uses less memory if it's just an array with Byte index to parent, so I'm not gonna change that
05-28-2012 10:51 AM
Find all posts by this user Quote this message in a reply
JonathonA Offline
Member

Post: #14
RE: Animation replace
Well thanks for answering that. Is it really that big a memory footprint to use a hierarchical tree? Just curious.
05-29-2012 04:33 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply