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...
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.
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);