Multiple Animation at the same time

Problems building or running the engine, queries about how to use features etc.
hcfen
Gnoblar
Posts: 3
Joined: Fri Jan 30, 2009 2:09 pm

Multiple Animation at the same time

Post by hcfen »

hi,

I want to play two or more animations at the same time for one entity. For Example a player that waves with his hands and walks at the same time. This would be the Animation walk and the Animation waveHands. It should be done with skeleton animations and I don´t know yet whats the best way to do it. I already managed to blend animations but this problem seems to be different.

I've found the skeletal_blend_mask_support.patch on sourceforge but its for the old version of Ogre(I use 1.6) and I hope there is another way to solve this problem!!!

Can anyone help me with this problem or give me some advice in where to look...

THX
User avatar
aguru
Goblin
Posts: 236
Joined: Tue Feb 26, 2008 5:48 pm
x 3

Re: Multiple Animation at the same time

Post by aguru »

Take a look at this lib by novaumas, it's fantastic: http://www.ogre3d.org/forums/viewtopic.php?f=11&t=45260
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 218

Re: Multiple Animation at the same time

Post by Jabberwocky »

Skeletal blend masks are officially a part of ogre as of 1.6. So you don't need to use that patch, it's already there. They are definitely what you want to use to blend animations such as waving and walking.

I don't think there's much documentation about how to use them, but the API is fairly clear so you should be able to figure it out. The relevent code is in OgreAnimationState.h. Search for "BlendMask". You can also read the original forum thread which discusses some implementation details if you want.

The only slightly tricky bit for me was that I had to change the SkeletonAnimationBlendMode from ANIMBLEND_AVERAGE to ANIMBLEND_CUMULATIVE, e.g.

Code: Select all

      pEntity->getSkeleton()->setBlendMode( ANIMBLEND_CUMULATIVE );
Image
User avatar
RedEyeCoder
Gnome
Posts: 344
Joined: Sat Jun 16, 2007 7:29 am
Location: Brisbane, Australia

Re: Multiple Animation at the same time

Post by RedEyeCoder »

I think Ogre would benefit from a demo to show off skeletal blend masking. Thoughts?
User avatar
buckED
Greenskin
Posts: 133
Joined: Fri Feb 15, 2008 9:51 pm

Re: Multiple Animation at the same time

Post by buckED »

RedEyeCoder wrote:demo to show off skeletal blend masking. Thoughts?
I think Ogre would benefit from a demo to show off skeletal blend masking. Thoughts?
True.
Many of life's failures are people who did not realize how close they were to success when they gave up.

~ Thomas Edison ~
hcfen
Gnoblar
Posts: 3
Joined: Fri Jan 30, 2009 2:09 pm

Re: Multiple Animation at the same time

Post by hcfen »

Ok it run! THX to all for the fast answer...

Another question:

Has Ogre 1.6 Inverse Kinematic??
Or must I use openTissue or havok?
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 535

Re: Multiple Animation at the same time

Post by Kojack »

No inverse kinematics, you'll need a lib to do it for you.
I think Ogre would benefit from a demo to show off skeletal blend masking. Thoughts?
I'm working on one, but I need to make a gui for it and that always puts me off.

It's pretty easy though. This code will set up the ninja ready for masked blending of Walking and Attacking at once:

Code: Select all

        g_ninjaEntity->getSkeleton()->setBlendMode(Ogre::SkeletonAnimationBlendMode::ANIMBLEND_CUMULATIVE);

        g_state1 = g_ninjaEntity->getAnimationState("Walk");
	g_state1->setEnabled(true);
	g_state1->createBlendMask(g_ninjaEntity->getSkeleton()->getNumBones(),1);

	g_state2 = g_ninjaEntity->getAnimationState("Attack1");
	g_state2->setEnabled(true);
	g_state2->createBlendMask(g_ninjaEntity->getSkeleton()->getNumBones(),1);
Now just set all the leg bones to a weight of 0 in the attack animation and 1 in the walk animation, and the opposite for all other bones. Now the ninja's leg positioning during an attack has no effect on the walk cycle.

The command to set a bone to a weight is:

Code: Select all

g_state1->setBlendMaskEntry(i,w);
where i is the bone index number and w is the float weight from 0 to 1.
hcfen
Gnoblar
Posts: 3
Joined: Fri Jan 30, 2009 2:09 pm

Re: Multiple Animation at the same time

Post by hcfen »

Yeah, thats easy!
But now its time for IK and I think that openTissue is the favourite one!
User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm
x 13

Re: Multiple Animation at the same time

Post by koirat »

It looks like a Bad behavior :).

when in mode ANIMBLEND_AVERAGE:
the average is probably calculated from main weight so even if i have got mutually exclusive mask on my two animations. Something like upper body and legs. (waving hands + walking). And this mask will be like a bit mask (0->disable bone) (1->enable bone). The legs are going to be half blended, so do hands. I think that this is undesired.
This is a block of text that can be added to posts you make. There is a 255 character limit.
darksideus
Gnoblar
Posts: 4
Joined: Mon Jul 06, 2009 10:40 am

Re: Multiple Animation at the same time

Post by darksideus »

Hey,

I had to make a generic function for blending two animations for my application.

Is there a solution if i don't know which bones are using by animations i want to play?

Is there a simple way to do that?

Thx for answering ;)
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 218

Re: Multiple Animation at the same time

Post by Jabberwocky »

darksideus wrote:Is there a solution if i don't know which bones are using by animations i want to play?
You need to look at the model inside the modeling program (3dsmax, blender, or whatever).
Then you can tell which bones are upper and lower body, and how to make your blend masks.
Image
nbeato
Gnome
Posts: 372
Joined: Thu Dec 20, 2007 1:00 am
Location: Florida
x 3

Re: Multiple Animation at the same time

Post by nbeato »

I've been wondering the same thing for a while. How do you create the blend masks in a simple way? Having a programmer open a model in max or maya is like telling a modeler to look at the cpp files. :) I guess the best solution right now is to have a modeler write down values for every animation/bone pairing and have the programmer load it somehow. That is simple, but tedious. Anyone have a good workflow for this?
Vectrex
Ogre Magi
Posts: 1266
Joined: Tue Aug 12, 2003 1:53 am
Location: Melbourne, Australia
x 1

Re: Multiple Animation at the same time

Post by Vectrex »

nbeato wrote:I've been wondering the same thing for a while. How do you create the blend masks in a simple way? Having a programmer open a model in max or maya is like telling a modeler to look at the cpp files. :) I guess the best solution right now is to have a modeler write down values for every animation/bone pairing and have the programmer load it somehow. That is simple, but tedious. Anyone have a good workflow for this?
Hopefully this lib will support it because the gui and lib is great. http://www.ogre3d.org/forums/viewtopic.php?f=11&t=45260
darksideus
Gnoblar
Posts: 4
Joined: Mon Jul 06, 2009 10:40 am

Re: Multiple Animation at the same time

Post by darksideus »

They re using max and export it with oFusion Pro.
Ok i will talk with them for setting a convention name for bone^^
it will be easier for implementing that.

I think that it should be a great thing to set an animation on a subEntity of an object to be independant of bones name.

nice project, it will help for a programmer to know bones name without modeling knowledge...
User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
x 218

Re: Multiple Animation at the same time

Post by Jabberwocky »

nbeato wrote:I guess the best solution right now is to have a modeler write down values for every animation/bone pairing
It should be simpler than that. You need one set of values per model, not per animation.

In my game, I need to blend upper body animations (shoot, reload, attack) with lower body animations (walk, run, jump). I expect this is the most common use of bone blend masks.

In this case, for each animated model, I need one list of upper body bones, and one list of lower body bones. Wherever you load game information about your characters in your project, just add two lists of bones. I use xml, so it would be something like this:

Code: Select all

   <character>
      <template>Drone Unity Troop</template>
      <mesh>DroneUnity.mesh</mesh>

       ... (a bunch more stuff here)...

      <lower_body_bone>Bone01</lower_body_bone>
      <lower_body_bone>Bone01(mirrored)</lower_body_bone>
      <lower_body_bone>Bone02</lower_body_bone>
      <lower_body_bone>Bone02(mirrored)</lower_body_bone>
      <lower_body_bone>Bone03</lower_body_bone>
      <lower_body_bone>Bone03(mirrored)</lower_body_bone>
      <lower_body_bone>Bone05</lower_body_bone>
      <lower_body_bone>Bone06</lower_body_bone>
      <lower_body_bone>Bone07</lower_body_bone>
      <lower_body_bone>Bone11</lower_body_bone>
      <lower_body_bone>Bone11(mirrored)</lower_body_bone>
      <lower_body_bone>Bone13</lower_body_bone>
      <lower_body_bone>Bone13(mirrored)</lower_body_bone>
      <lower_body_bone>Bone14</lower_body_bone>
      <lower_body_bone>Bone15</lower_body_bone>
      <lower_body_bone>Bone15(mirrored)</lower_body_bone>
      <lower_body_bone>Bone21</lower_body_bone>
      <lower_body_bone>Bone32</lower_body_bone>
      <lower_body_bone>Bone34</lower_body_bone>
      <lower_body_bone>Bone36</lower_body_bone>

      <upper_body_bone>Bone04</upper_body_bone>
      <upper_body_bone>Bone08</upper_body_bone>
      <upper_body_bone>Bone09</upper_body_bone>
      <upper_body_bone>Bone10</upper_body_bone>
      <lower_body_bone>Bone16</lower_body_bone>
      <upper_body_bone>Bone17</upper_body_bone>
      <upper_body_bone>Bone18</upper_body_bone>
      <upper_body_bone>Bone19</upper_body_bone>
      <upper_body_bone>Bone20</upper_body_bone>
      <upper_body_bone>Bone22</upper_body_bone>
      <upper_body_bone>Bone24</upper_body_bone>
      <upper_body_bone>Bone25</upper_body_bone>
      <upper_body_bone>Bone26</upper_body_bone>
      <upper_body_bone>Bone27</upper_body_bone>
      <upper_body_bone>Bone28</upper_body_bone>
      <upper_body_bone>Bone29</upper_body_bone>
      <upper_body_bone>Bone30</upper_body_bone>
      <upper_body_bone>Bone31</upper_body_bone>
   </character>
Image
darksideus
Gnoblar
Posts: 4
Joined: Mon Jul 06, 2009 10:40 am

Re: Multiple Animation at the same time

Post by darksideus »

yeah, i think that it's the simple way to get a generic function, i will add this to my osm file and parse it to get the bone list ;)

Great work and thanks all ;)