Size of animation and scaling

Oct 11, 2011 at 6:32 AM

Hello.  I have a question about how the "size" of an animation is found/works. I need to create collision boxes around the entire animation(and eventually around the joints) as I have a physics engine. It seems that the size of the animation is determined by the size of the images, is this correct?

I found a way to scale down the image like this:

   PlayerAnim.Draw(spriteBatch, new Vector2(Position.X, Position.Y), false, false, 0,Color.White, new Vector2(.2f,.2f),Camera2D.Singleton._transform);

But this isn't a good way to do it because the scale will vary for any given animation size. Is there a way to constrain the size of the animation programatically? Like if i wanted it to be 64x64 pixels. Otherwise, I will have to tinker with the scale so that it "fits" inside the collision box defined for that animation.

On a side note, is it possible to get the position and orientation of the bones in an animation? I need this so that i can make a bounding collision box around a given bone in an animation. And if, say, the arm rotates to attack something, The collision box would update with it, since it is set to that bones position and rotation etc. Thanks a lot.

Coordinator
Oct 11, 2011 at 4:37 PM

If you don't do any scaling, the size is going to be exactly the same as the component pieces. There's nothing built in to handle constraining the size. I create my collision boxes to fit the animations, rather than trying to make the animations fit.

There's a mechanism for getting the bone transformation out. I added it so that I could spawn particles in the correct place, but I never spent much time with it.

Check out the GetBoneTransformIndex method and the BoneTransformations property if you'd like to play around with that. You'll likely need to do a little tinkering to get it to work with your code.