Character Animation project in OGRE - need a little advice

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
Noiprox
Halfling
Posts: 64
Joined: Mon Apr 05, 2004 6:25 am
Location: North Vancouver, Canada

Character Animation project in OGRE - need a little advice

Post by Noiprox »

I am reproducing the work in this paper with OGRE as a University project.

I would like to try to implement IK for posing. It is easy to load and animate a model with a skeleton, and I can manually construct a character out of seperate pieces with an explicit SceneNode hierarchy. If I want to do picking so that the user can select a part of the character with the mouse to drag it around, what would be the best way to determine which bone the user is trying to drag? I have looked at RaySceneQuery, but that only reports which object was hit and at what position. My guess is that I should take the world coordinates reported back by the RaySceneQuery, transform them into object space and then compute which bone is nearest to that point using point-line distance calculations. Is that right?

Another question I have is how best to set a character to an arbitrary pose. Suppose I have an algorithm which returns a vector of joint angles for the character at each frame, somewhat like the built-in keyframing system of OGRE does. How should I go about altering the bone transformations to configure the character according to the output of the algorithm? I notice there are AnimationControllers, but they seem to be for moving objects along spline paths over time and things like that. What I need is something more event-driven.

Thanks,
Dieter Buys
Image
"Death, be not proud, though some have called thee mighty and dreadful, for thou art not so." - John Donne
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

You can create instances of Animation and AnimationState on the fly for procedural or computed animations in Ogre. Look at the SceneManager and Animation/AnimationState classes in the API.

As for picking, your ray query returns everything that intersects the ray, that is not filtered out by the type mask. Go through this list and highlight the bone objects as needed as the user clicks the mouse. This is the standard default behavior in 3D packages for picking objects at different depths.
User avatar
Noiprox
Halfling
Posts: 64
Joined: Mon Apr 05, 2004 6:25 am
Location: North Vancouver, Canada

Post by Noiprox »

I will investigate the Animation and AnimationState classes more closely then, thank you.

My assumption was that, since bones are nothing but coordinate frames (i.e. transformation matrices), it would not be possible for a ray to intersect with them.
Dieter Buys
Image
"Death, be not proud, though some have called thee mighty and dreadful, for thou art not so." - John Donne
User avatar
Noiprox
Halfling
Posts: 64
Joined: Mon Apr 05, 2004 6:25 am
Location: North Vancouver, Canada

Post by Noiprox »

I have tried working with these classes and am still a little confused. Does anyone have a specific example of procedural animation in OGRE that I could look at perhaps?

I also still don't understand how RaySceneQueries work with bones. If a bone is just a transformation matrix, with no explicit geometric representation of the underlying "bone", how can a ray intersect with one? Potentially the ray could intersect with an area of the mesh bound to a particular bone that is far away from the actual bone itself, what would happen then?
Dieter Buys
Image
"Death, be not proud, though some have called thee mighty and dreadful, for thou art not so." - John Donne
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Noiprox wrote:I have tried working with these classes and am still a little confused. Does anyone have a specific example of procedural animation in OGRE that I could look at perhaps?
Not unless Will Wright is doing Spore using Ogre. ;)
I also still don't understand how RaySceneQueries work with bones. If a bone is just a transformation matrix, with no explicit geometric representation of the underlying "bone", how can a ray intersect with one? Potentially the ray could intersect with an area of the mesh bound to a particular bone that is far away from the actual bone itself, what would happen then?
You won't get a bone in a query that I know of; like you said, you can intersect with a whole object that is bound to a bone, but how you resolve the relationship between the bone and the actual part of the mesh in which you are interested is up to you.

From the article you reference, you should be dealing only with bones and using attachObjectToBone() IMO. The mesh would be incidental in this case, and used only to obtain access to the bone, which is what you actually wish to control. How you construct a skeleton at runtime is, however, again up to you.
Post Reply