scripted v. engine - ragdolls?

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
fps
Posts: 504
Joined: Mon Sep 26, 2005 9:54 pm
Location: in a magical land devoid of hope, happiness, and sanity.

scripted v. engine - ragdolls?

Post by fps »

I am trying to use ragdolls in my game for gibed pawns. I am setting up a ragdoll to look like a body that has been blasted and burned into a charcol skeleton.

I was just wondering if scripted or engine based ragdolls would work better. I believe that engine based ragdolls would run faster but i might be completly wrong about that. If i use scripted ragdolls I could have many more features such as detaching joints on an active ragdoll. the only problem with that is that i would need to write a ragdoll script that worked. basicly all I need the ragdolls to do is trigger, spawn, and fall to the ground. if a limb of the ragdoll is hit by a force over a certain amount then the appening joint is detached. I think i can only do this with a scripted ragdoll, right.
What do you guys think?

Is there a script for a ragdoll somewere that i can start with?

Thanks,
fps
Nout
Posts: 136
Joined: Tue Jul 05, 2005 5:14 pm

Post by Nout »

Frederico is making a ragdoll script I think is very similar to what you describe.

I've added some new bone features to RF075 + physics, but it's unreleased material. I'm also adding an ActorDoll, which sounds like the entity version of what you discribed.

So today, no, it's not existing (read: not yet working)
Yes, scripting offers you much more possibilities but it is a bit slower
Yes, in the future we believe that both a script and an entity will be available to make a triggerable Actor-ragdoll with physics

When is the release? Well, the progress is very very slow...
It will take sure some weeks and more likely some months to close on this.
User avatar
federico
RF Dev Team
Posts: 443
Joined: Tue Jul 05, 2005 3:14 pm
Contact:

Post by federico »

Nout is totally right but something more can be said.
Mainly to have a "skinned" ragdoll we must first have a "composed" ragdoll. Just to be sure, I call "composed ragdoll" a composition of Physics bodies jointed together using Tokamak joints. In this way there are different actors that "compose" the ragdoll. A "skinned ragdoll" is the common ragdoll that you can see in today's games: the bones of the actor follow directly the physics so the actor is only one skinned character articulated by the physics.
Using a physics engine external to Genesis we have to fake a bit to getthe result. The process is this:
1) A composed ragdoll is spawned over a actor pawn. Every bodypart will keep the position/orientation of the bone structure of the actor. For example: the LeftUpArm bodypart of the ragdoll is positioned in the position/orientation of the "BIP01 L UPPERARM" of a virgil actor. Every bodypart of the ragdoll mirrors the bone structure of the pawn.
This is mandatory both for composed or skinned ragdoll. Then the path parts in two directions:
2a) The actor pawn is made invisible while the composed ragdoll is keep visible. In this way the ragoll and the pawn actor must be similar. So you should take some time to "break" in milkshape your pawn actor in several pieces, having care to keep the correct orientation of the bodyparts in respect to the axis origin. You will see an example of this.
2b) To fake a "skinned" ragdoll we simply force the actor bones of the pawn to match the orientation/position of the composed ragdoll while it falls, bounces etc... Naturally the composed ragdoll has to be kept invisible and the pawn actor visible instead. In this way the composed ragdoll doesn't need to have the same aspect of the actor pawn: it can have any form, the only thing important is to keep the proportion between the "master" ragdoll and the "slave" pawnactor. The latter is a problem but we have yet some idea to solve it.

So, where are the issue? At the beginning. First, to accomplish 1), we have to get the correct orientation/position of the pawnactor bones. The genesis functions to get this values doesn't work good (geActor_GetEulerAngles nor CCD->ModelManager(GetEulerAngles)). Only Nout can fix this, he's sure to fix it. I tried to solve it using the geXForm3d_SetFromLeftUpIn command but the result wasn't good. This is the main obstacle.
In addiction, the only way we have to accomplish 2b) is to use commands that set the RELATIVE position of a actor bone. This could create some trouble 'cause we look for an ABSOLUTE rotation of the bodyarts. Anyway...

You can grab an intermediate relase of my ragdoll demo here:
http://realitychess.altervista.org/physics/
The commands are partly changed now, so watch the demos but please don't use that exe's and headers for developping. Instead get ragdoll1.p to create your ragdoll script.
Mainly the Init Order is this:

Code: Select all

Init[ () //Is excecuted only once.
{
Console(true);
PosX = 0;
PosY = 390;
PosZ = 240;
DefineMaterial(1, 0.3, 2);

Body[0] = CreateRigidBody("Corps",  "box_centered.act",1,1.8,0.5, 255, PosX, PosY, PosZ, 0,0,0, 0,0,0 , true, 100, "Box 0", 1, Mass);
Dx = GetBodyBBox(Body[0],0);
Dy = GetBodyBBox(Body[0],1);
Dz = GetBodyBBox(Body[0],2);




//Head
Body[1] = CreateRigidBody("Head",  "+y.act", 0.7,0.8,0.7, 255, PosX, PosY+(Dy/2)+2, PosZ, 0,0,0, 0,Dx/2,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateBallJoint(Body[0], Body[1], PosX, PosY+(Dy/2)+2, PosZ, 0,0,0, -20, 20, 40, 40, 3,4);

//Left Arm
Body[2] = CreateRigidBody("LUpArm",  "+x.act", 0.8,0.5,0.5, 255, PosX+(Dx/2), PosY+(Dy/2), PosZ, 0,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateBallJoint(Body[0], Body[2], PosX+(Dx/2), PosY+(Dy/2), PosZ, 90,0,0, 0, 80, 70, 80, 3,4);

Body[6] = CreateRigidBody("LDownArm",  "+x.act", 1,0.5,0.5, 255, PosX+(Dx/2)+(Dx*0.8)+1, PosY+(Dy/2), PosZ, 0,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateHingeJoint(Body[2], Body[6], PosX+(Dx/2)+(Dx*0.8)+1, PosY+(Dy/2), PosZ, 0,0,0, -130, 10, -130, 10, Dy/2, -1, 0,0);

//Right Arm
Body[3] = CreateRigidBody("RUpArm",  "-x.act", 0.8,0.5,0.5, 255, PosX-(Dx/2), PosY+(Dy/2), PosZ, 90,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateBallJoint(Body[0], Body[3], PosX-(Dx/2), PosY+(Dy/2), PosZ, 90,180,0, 0,80, 70, 80,3,4);

Body[7] = CreateRigidBody("RDownArm",  "-x.act", 1,0.5,0.5, 255, PosX-(Dx/2)-(Dx*0.8)-1, PosY+(Dy/2), PosZ, 0,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateHingeJoint(Body[3], Body[7], PosX-(Dx/2)-(Dx*0.8)-1, PosY+(Dy/2), PosZ, 0,0,0, -10, 130, -10, 130, Dy/2, -1, 0,0);


//Left Leg
Body[4] = CreateRigidBody("RUpLeg",  "-y.act", 0.5,1.3,0.5, 255, PosX+(Dx/3), PosY-(Dy/2), PosZ, 0,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateBallJoint(Body[0], Body[4], PosX+(Dx/3), PosY-(Dy/2), PosZ, 90,0,0,  -30,20, 80, 90, 3, 4);

Body[8] = CreateRigidBody("RDownLeg",  "-y.act", 0.5,1.4,0.5, 255, PosX+(Dx/3), PosY-(Dy/2)-(Dx*1.3)-1, PosZ, 0,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateHingeJoint(Body[4], Body[8], PosX+(Dx/3), PosY-(Dy/2)-(Dx*1.3)-1, PosZ, 0,0,90, -130, 0, -130, 0, Dy/2, -1, 0,0);


//Right Leg
Body[5] = CreateRigidBody("RUpLeg",  "-y.act", 0.5,1.3,0.5, 255, PosX-(Dx/3), PosY-(Dy/2), PosZ, 0,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateBallJoint(Body[0], Body[5], PosX-(Dx/3), PosY-(Dy/2), PosZ, 0,0,0,  -20,30, 80, 90, 3, 4);

Body[9] = CreateRigidBody("RDownLeg",  "-y.act", 0.5,1.4,0.5, 255, PosX-(Dx/3), PosY-(Dy/2)-(Dx*1.3)-1, PosZ, 0,0,0, 0,0,0 , SHADOW, 100, "Box 0", 1, Mass);
CreateHingeJoint(Body[5], Body[9], PosX-(Dx/3), PosY-(Dy/2)-(Dx*1.3)-1, PosZ, 0,0,90, -130, 0, -130, 0, Dy/2, -1, 0,0);

User avatar
fps
Posts: 504
Joined: Mon Sep 26, 2005 9:54 pm
Location: in a magical land devoid of hope, happiness, and sanity.

Post by fps »

Thanks for the in-depth responce. :)
I will try the physics script but i might want to wait untill you are done working on it to actually put them in my game for pawn deaths. (I have 29 death animations to use for now).
As for getting the ragdolls to work, would you be able to use a system of actor skeletons with physics with a fake actor body attached to the skeleton the way that we match the motions for the 3rd person weapons?
I am not entirely sure how this works in the first place but I do now that all you would need is a matching skeleton. if all of the charectors in the game had the same skeleton you could use the same physics skeleton for every pawn. If not then all you would need is a seperate physics skeleton setup for the actors that didn't match the origional.

That way you could have it defined like this:

physics skeleton: PS1
list of bones and arrangement (I have no idea how you would do this?).
mass:
gravity:
physics script to use:
other entries for physics stuff that I don't understand:

Ragdolls.
ragdoll name: corpse 1
ragdoll skeleton entry: PS1
acror file to snap to skeleton: DeadJoe.act
enviroment sound file: enviroment.ini
ect:

Pawn script.s
Dead joe
bla bla bla.
die 1.
animation. diegutshot. hideactor.
Create ragdoll (corpse1, pose postdeathanimation1)

enviroment.ini
Ragdoll land ground sound: thump.wav
Ragdoll land water sound: splash.wav
ragdoll shot sound: hitbody.wav
ragdoll gibbed sound: splat.wav

I dont know if this is helpful at all. you are probably working on a better way right now or i could just be repeting things that are old news to you.

Thank you for your help, good luck with your work.
Fps
Post Reply