Skeletal animation + ragdoll

nasirus1983

11-02-2009 10:26:49

Hi,

I'm give up and I realy need help. I have problem with my skeletal animation.
I've made character model in 3ds max, next I've prepared skeleton for it and animated it.
I also exported my animation to ogre mesh format. Next what I wanted to do is make an actor for each bone and connect them.
So I've taken boneiterator ane iterated through bones. But I don't have got a green idea what next.
My idea for that, was that I make actors for bones and make character controler - actors are static.
Next thing I thing should be some contact hit report. I'm making project on university. In this project my character shold walking and collide with terrain for begin.
So please help me. I can't imagine how to implement this. Beacause I'm 'by example learner', maybe some body have something similar and can share with me.
If not, maybe you can give some example, maybe explanation. I've been searching on the formu but can't find nothing working and connected with it.

betajaen

11-02-2009 11:12:12

Sounds much like how a ragdoll would work except in reverse; rather than the physics moving the Ogre bones, it would be the other way around. I suggest you make them kinematic than static (otherwise PhysX will fall apart). As for the collision parts; that will be tricky, you could do some ray-casting to find out the height of the ground and move the bone actors accordantly but personally I would just use a capsule instead. It's easier and think many games that do ragdolls cheat and do it that way.

There have been a few posts with code demonstrating ragdolls with NxOgre, I'm sure the search can find them all.

nasirus1983

11-02-2009 12:42:34

Thnx for reply.
Could you explain me what do you mean: "move the bone actors accordantly but personally I would just use a capsule instead" ? I thought that kinematic actor will follow bones when they animating ?

betajaen

11-02-2009 14:45:43

Yes; but you want it so the animation code will also move the kinematic actors but at the same time the kinematic actors need to collide with the floor properly and adjust the bones back. It's very difficult to do, I've seen it with the Euphoria engine (see GTA IV) but outside that no.

The easiest way is to use a capsule over the kinematic actors for basic collision with the floor and walls, but ignore that when you want say collision with bullets.

nasirus1983

11-02-2009 15:31:28

I don't want bullet collisions. In my project I only have to implement skeletal animation with collision for walls, floot, stairs etc.
But still I can not imagine how to implement kinematic actor or ragdoll (isn't it the same ?).
So best for me would be some example. Currently I've found on the forum some examples for ragdoll, but still don't know how to connect it with collisions.

betajaen

11-02-2009 18:41:52

You'll have to use the capsule for walking/wall collisions. If your not using the bones for collisions, there is no need to even simulate the moving ragdoll, just create it and use it the moment the player dies.

nasirus1983

11-02-2009 18:56:47

Ok, I understan part with creating ragdoll only. But my problem is, what happen next. Skeletal animation will move bones, right ?
So how to make, that actors will follow that moving bones ?

betajaen

11-02-2009 19:44:37

I told you; it's the opposite function of a ragdoll; Skeleton move bones and you move the kinematic actors to match the bone positions and orientations, but why on earth are you doing it that way if your not using it for collision? Seems a whole lot for nothing.

nasirus1983

11-02-2009 20:41:49

I'm not doing this yet. I'm trying to get help how to do this :)
I have skeletal animation and I want (or rather I have to) my character for example going on stair or something like this.
So for stairs, one capsule is not enought. This walking must be precise, so I thought that must be actors/bodies for feets.
This realistic and precision is not my idea but my promoter.

And about question for moving kinematic actors when skeleton moves - question is very prosaic: in every frame I must update position and orientation of kinematic actors with values form bones ?

betajaen

11-02-2009 21:16:06

Yes, but you want both; Skeleton animation to move the kinematic actors, but meanwhile those kinematic actors must collide with the environment, and feed that back into the skeleton.

There is no example on how to do this, it's never been done in NxOgre. The closest your going to get is a ragdoll, from that your on your own.

nasirus1983

11-02-2009 21:30:10

Ok. So maybe give me some adivce, how I should do that most simply.
Mesh with skeletal animation, collisions with floor, wall, stairs. Goint on to stairs and that's it.
I just try to get infor, how is most simply. It's first time I developing that kind of appliaction.

nasirus1983

12-02-2009 19:14:32

Maybe I ask in different way.
I have skeletal animation. I iterate throught bones and for each bone I create actor (position and what else ? orientation ?).
Next my animation is being played. So bones are moving and their positions are changing. And here is my question. How and where I must deliver information about changed bones positions to actors, that they can change their positions too.
It should be done somewhere in FrameListener ?

Please explain me this once for all.

nasirus1983

13-02-2009 08:53:17

come on ... I thought that only I don't know this :) - I'm feel better now :wink:
anyway I'll appreciate if somebody answer on my last question

betajaen

13-02-2009 09:28:14

At this point your being annoying and rude. If you don't know how to do these things in your head, then your not going to be able to do it in code.

nasirus1983

13-02-2009 09:48:49

At this point your being annoying and rude. If you don't know how to do these things in your head, then your not going to be able to do it in code.
Is this really so difficult to answer for my simple question ? I want only to know how it should be done. I don't want code, examples. Just answer, where and how, information about position and orientation from moved bones should be delivered to kinematic actors (each for one bone) ? Is this so much ????

betajaen

13-02-2009 10:32:41

At this point your being annoying and rude. If you don't know how to do these things in your head, then your not going to be able to do it in code.
Is this really so difficult to answer for my simple question ? I want only to know how it should be done. I don't want code, examples. Just answer, where and how, information about position and orientation from moved bones should be delivered to kinematic actors (each for one bone) ? Is this so much ????


But it ISN'T a simple question, it's a really hard one. You don't see any examples or pieces of code related to it, because the implementation is really difficult to do. Just look at the ragdoll code, you'll have to work from there.

nasirus1983

13-02-2009 10:42:21

Ok. Let say I've got ragdoll class and making ragdoll, where each actor is kinematic.
So tell me if this what I write next is good idea or not.
I have ragdoll (with kinematic actors). My animation is being played. Bones are change positions.
In framelistener for example in frameRenderingQueued(const FrameEvent& evt) I should iterate through bones (as I do when creating ragdoll)
and get position of each bone and set it to each actor ?
Something like this

Ogre::Skeleton::BoneIterator it = si->getBoneIterator();

while(it.hasMoreElements())
{
Bone* b = it.getNext();
//for name of each bone, get actor by name and get new position from bone and set to actor ??
it.moveNext();
}

betajaen

13-02-2009 11:17:25

Yes, or a faster way would to attach the Actor to the Ogre::Any of the bone (presuming it has one).