Horde3D

Next-Generation Graphics Engine
It is currently 29.04.2024, 06:22

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: 25.05.2010, 17:36 
Offline

Joined: 25.05.2010, 17:18
Posts: 2
I am working on an internship in which we are developing a Tutor Model. We have two animations we would like to happen at the same time. The first animation, the tutor raises her hand to shoulder height, palm facing away from the tutor. The second animation is counting on her fingers. It can be 1-5 so essentially there are 5 animations.

I am currently just trying one of the counting animations. The problem is the counting animation is almost twice as fast as the hand raising animation. So when they are mixed, they work independently of each other and are completely out of sync. Is there anyway to get the two animations to sync up without manually picking and guessing on possible times in the setModelAnimParams function.

Heres the code of the two animations:
Code:
h3d.setupModelAnimStage(_tutor, 0, tutorCOF2, 0, string.Empty, true); //Hold two fingers up for the count of two.  Additive is true
h3d.setupModelAnimStage(_tutor, 1, tutorRH, 0, string.Empty, false); //Raise Hand

h3d.setModelAnimParams(_tutor, 0, _animTime * 14.5f, _weight);
h3d.setModelAnimParams(_tutor, 1, _animTime * 24.0f, 1.0f - _weight);


I'm still fairly new to Horde3D and any help or suggestions would be great. If you need any other information let me know. Thanks


EDIT: Or if there is a way to get the number of frames in an animation using a function.


Top
 Profile  
Reply with quote  
PostPosted: 26.05.2010, 07:54 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
darkmage530 wrote:
EDIT: Or if there is a way to get the number of frames in an animation using a function.

You can use
Code:
int frames = h3dGetResParamI(resourceID, H3DAnimRes::EntityElem, 0, H3DAnimRes::EntFrameCountI);

to query the number of frames in an animation resource.

You also may want to check the animation component of the GameEngine. It contains some code for running animations with Horde3D. Horde3D itself does not contain timing for animations, so it's up to you or the asset creator to sync the animations.


Top
 Profile  
Reply with quote  
PostPosted: 26.05.2010, 09:14 
Offline

Joined: 24.03.2010, 10:17
Posts: 55
Hi.

In your code you set up one of the animations as being additive, and then you want to do a crossfade of both animations. I guess this will not work correctly.
In the current SVN (version 243) additive animations cannot be weighted, so once the play the get full intensity.
In our code-base I added a simple fix - which does not account for multiple weighted animations on the same layer and does not normalize their weights - and yes, should be optimized, but we tend to add non-invasive fixes to allow constant re-syncing to horde's svn:
In egAnimation.cpp around lines 474:
Code:
            if( curStage.additive )
            {
               // Additive animations are only applied if there is some other animation before
               if( nodeUpdated )
               {
                  // Add the difference to the first frame of the animation
                  const float w = curStage.weight; // use the current stage's weight directly, not normalized
                  Frame &firstFrame = animEnt->frames[0];
                  Quaternion dstRotQuat = nodeRotQuat * (firstFrame.rotQuat.inverted()*rotQuat);
                  nodeRotQuat = nodeRotQuat.nlerp(dstRotQuat, w);
                  nodeTransVec += (transVec-firstFrame.transVec)*w;
                  Vec3f wScale = firstFrame.scaleVec.lerp(scaleVec, w);
                  nodeScaleVec.x *= 1 / firstFrame.scaleVec.x * wScale.x;
                  nodeScaleVec.y *= 1 / firstFrame.scaleVec.y * wScale.y;
                  nodeScaleVec.z *= 1 / firstFrame.scaleVec.z * wScale.z;
               }
            }

We also added the possibility to query the animation length in seconds besides the number of frames (this applies adding some code to the Collada converter).

I'm not sure if you really need additive animations in the scenario you described - as you seem to crossfade the animations.
As soon as the weight of your non-additive animation on layer 1 reaches 0, the additive animation will no longer be applied, because they always need a non-additive animation playing at the same time - basically sth. to which they can add to.

You might want to have a look at Unity3D's animation description which covers Additive and Blend animations, normalized frame time and synchronization of different animations http://unity3d.com/support/documentation/Manual/Character-Animation.html#AnimBlend


Top
 Profile  
Reply with quote  
PostPosted: 26.05.2010, 17:18 
Offline

Joined: 25.05.2010, 17:18
Posts: 2
So our project is in C# instead of C++ but we've converted the code to C# but we are getting absurd numbers such as -2147483648 for
Code:
int frames = h3d.getResParamI(tutorCOF2, (int)h3d.H3DAnimRes.EntFrameCountI);
in C# getResParamI(int res, int param)

The odd thing is regardless of what I put the resource as, it always returns the same large negative number. I even made an
Code:
int boo = 5
and used that as the resource which still returned the large number. So I figure something is wrong with the resource I'm entering or maybe the int param isn't getting the right information either. I'm not sure.

And AlexL I haven't gotten around to giving your code a try yet. Will work on that shortly

Thanks for the responses.


Top
 Profile  
Reply with quote  
PostPosted: 26.05.2010, 20:53 
Offline

Joined: 26.05.2010, 20:46
Posts: 3
Location: Memphis
Hi, I am working on the same project as darkmage and would like to update the status of our issue. The below code (in c++) works perfectly and returns the correct amount of frames for an animation that we already know the frame count for:
Code:
int frames = h3dGetResParamI(guruAnim3Res, H3DAnimRes::EntityElem, 0, H3DAnimRes::EntFrameCountI);


However, the below code (using the exact same function, but in c#) does not work and returns the value "-2147483648":
Code:
int frames = h3d.getResParamI(guruAnim3Res, (int)h3d.H3DAnimRes.EntFrameCountI);


Is it possible that this is an issue with the c# wrapper for the program? Thank you for your help!


Top
 Profile  
Reply with quote  
PostPosted: 27.05.2010, 00:15 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
nickav21 wrote:
However, the below code (using the exact same function, but in c#) does not work and returns the value "-2147483648":

Obviously, there is a difference in the number of arguments ;)
It is better to use the code and bindings from the SF svn. It is a lot more stable than the beta4 release.


Top
 Profile  
Reply with quote  
PostPosted: 27.05.2010, 16:00 
Offline

Joined: 26.05.2010, 20:46
Posts: 3
Location: Memphis
Ah, I was afraid of that. The project we are working for is already using Beta4 and will probably be very reluctant to use a newer version. Thanks anyways!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group