function ragdoll help!!

Posted By: MDMDFSS

function ragdoll help!! - 05/11/09 16:06

Im trying to make a deathfunction (Wenn the actor/player dies he turns into a regdoll) but I don`t know how.
I begone like this: (sorry for my bad englisch)

_______________________________________________________________

void setLimit

STRING* head_mdl = "head.mdl"; // head
STRING* torso_mdl = "torso.mdl"; // upper body
STRING* abs_mdl = "abs.mdl"; // middle body
STRING* pelvis_mdl = "pelvis.mdl"; // lower body
STRING* leftarmup_mdl = "arm_up_left.mdl"; // left arm
STRING* leftarmdown_mdl = "arm_down_left.mdl";
STRING* rightarmup_mdl = "arm_up_right.mdl"; // right arm
STRING* rightarmdown_mdl = "arm_down_right.mdl";
STRING* leftlegup_mdl = "leg_up_left.mdl"; // left leg
STRING* leftlegdown_mdl = "leg_down_left.mdl";
STRING* rightlegup_mdl = "leg_up_right.mdl"; // right leg
STRING* rightlegdown_mdl = "leg_down_right.mdl";

function ragdoll1
{
???
_______________________________________________________________

How can I put everything together?

Can somebody please help me?

Posted By: Rackscha

Re: function ragdoll help!! - 05/11/09 18:47

I have finished my system today(needs some tweaking).
Its hard to explain, but i can give you some hints:
For every bone you want to be a part of the ragdoll model, you have to create a model(with similar sizes of the region its atached to). This model is a physik objekt an joined to other
Physikmodel bones, in the same order, the bones are connected on your model.

Then you have to update the rotation of a bone by reading the angle of the given constraint.

Oh i see i am going to confuse everyone with my way of explanation.

Play around with joints of physik models. Its the main part wink

GREETS
RACKSCHA
Posted By: MDMDFSS

Re: function ragdoll help!! - 05/12/09 17:08

So I must connect everithing.

Ok I try action head (the head first)

function ragdoll
{

you = ent_create(temp_string,my.x,attach_shadow)
//the pysics
phent_settype(my,PH_RIGID,PH_BOX);
phent_setgroup(my,1);
phent_setmass(my,0.5,PH_BOX);
phent_setfriction(my,88);
phent_setelasticity(my,25,10);
phent_setdamping(my,25,25);

//how can I creat the head and set the head in the right place?
//With this?:
(1,0,0),nullvector,nullvector);


Posted By: Rackscha

Re: function ragdoll help!! - 05/12/09 18:08

At first, you have to use the you pointer when calling the phent_ functions not the my pointer.
Ok how do you want to create it? One normal model, with invisible physik bones atached to it, or just a stickman like charaktere where you see every part?
Posted By: MDMDFSS

Re: function ragdoll help!! - 05/12/09 18:19

A normal model with invisible physik bones.
Posted By: Rackscha

Re: function ragdoll help!! - 05/12/09 19:55

Ok, now you have bones added to your model in med right?
Ok, use vec_for_bone to get a position of a bone and add the physik bones to it. The difficult part(which doesnt work 100% in my code) is to update the rotation of the angles in the right way. you'll have to figure it out wink
Posted By: MDMDFSS

Re: function ragdoll help!! - 05/13/09 13:43

Yes my model has bones. (now...)

//more ditail

void setLimit(VECTOR* vec1, VECTOR* vec2);

//a new vector

VECTOR temp_head;

//a define for bodyparts

#define bodyPart skill1

STRING* head_mdl = "head.mdl"; // head
STRING* torso_mdl = "torso.mdl"; // upper body
STRING* abs_mdl = "abs.mdl"; // middle body
STRING* pelvis_mdl = "pelvis.mdl"; // lower body
STRING* leftarmup_mdl = "arm_up_left.mdl"; // left arm
STRING* leftarmdown_mdl = "arm_down_left.mdl";
STRING* rightarmup_mdl = "arm_up_right.mdl"; // right arm
STRING* rightarmdown_mdl = "arm_down_right.mdl";
STRING* leftlegup_mdl = "leg_up_left.mdl"; // left leg
STRING* leftlegdown_mdl = "leg_down_left.mdl";
STRING* rightlegup_mdl = "leg_up_right.mdl"; // right leg
STRING* rightlegdown_mdl = "leg_down_right.mdl";

function ragdoll1
{
//So the vec_for_bone...:

//first the head
vec_for_vertex(temp, temp_head, 23);
temp_head = ent_create(head_mdl, temp, 0);
//I think that cold work as limit
setLimit(vector(0,1,0), vector(-40,40,0));
BodyPartInit(25, temp_head);
________________________________________________________________________________

Cold that work?
Posted By: Rackscha

Re: function ragdoll help!! - 05/13/09 16:36

It seems you are using a Ragdoll template(maybe the one from helghats? hope i wrote your name right wink )
Posted By: MDMDFSS

Re: function ragdoll help!! - 05/13/09 19:43

No im using the cranesimulation (1prise last year).
Then the crane is somthing like a ragdoll...

But is that code right or not? (rightnow i meen)
Posted By: Rackscha

Re: function ragdoll help!! - 05/13/09 21:42

I dont know what the last line EXACTLY does. But as far as i can see its ok.
Posted By: MDMDFSS

Re: function ragdoll help!! - 05/15/09 13:58

ok thanks.
But now is it hard to but everithing together.
So I looked at the cranesimulator script and saw the (I think) perfeckt way to make a ragdoll... I do the ragdoll (almost) the same as the cranesimulator, thest not with a crane but with a humen.
So everithing new you see in my script is writen um for this function.

I try it like this:
(please correct if im wrong)

________________________________________________________________________________

// set rotation limits

void setLimit(VECTOR* vec1, VECTOR* vec2) {
vec_set(tempH1, vec1); //Hinges
vec_set(tempH2, vec2);
}

//vector, to set limets

VECTOR temp_pelvis
VECTOR temp_abs;
VECTOR temp_torso;
VECTOR temp_head;
VECTOR temp_legup_l;
VECTOR temp_legup_r;
VECTOR temp_legdown_l;
VECTOR temp_legdown_r;
VECTOR temp_armup_l;
VECTOR temp_armup_r;
VECTOR temp_armdown_l;
VECTOR temp_armdown_r

//a define for bodyparts

#define bodyPart skill1

STRING* head_mdl = "head.mdl"; // head
STRING* torso_mdl = "torso.mdl"; // upper body
STRING* abs_mdl = "abs.mdl"; // middle body
STRING* pelvis_mdl = "pelvis.mdl"; // lower body
STRING* leftarmup_mdl = "arm_up_left.mdl"; // left arm
STRING* leftarmdown_mdl = "arm_down_left.mdl";
STRING* rightarmup_mdl = "arm_up_right.mdl"; // right arm
STRING* rightarmdown_mdl = "arm_down_right.mdl";
STRING* leftlegup_mdl = "leg_up_left.mdl"; // left leg
STRING* leftlegdown_mdl = "leg_down_left.mdl";
STRING* rightlegup_mdl = "leg_up_right.mdl"; // right leg
STRING* rightlegdown_mdl = "leg_down_right.mdl";

//The rotation limet dosn`t reeley work, so I try it with var`s

var rt_pelvis;
var rt_abs;
var rt_torso;
var rt_head;
var rt_legup_l;
var rt_legup_r;
var rt_legdown_l;
var rt_legdown_r;
var rt_armup_l;
var rt_armup_r;
var rt_armdown_l;
var rt_armdown_r;


//I want a center of the body, also the pelvis:


function ragdoll1
{

temp_pelvis = my;
BodyPartInit(20, temp_pelvis); //Now i mack the bodypart

rd_pelvis = phcon_add(PH_HINGE, temp_pelvis, temp_pelvis);

phcon_setparams1(rt_pelvis, temp_pelvis.x, tempH1, nullvector);

phcon_setparams2(rd_pelvis, temp2, nullvector, nullvector);

//Now I do it like in the crane simulator, thest with humenboby

// left upper leg
vec_for_vertex(temp, temp_pelvis, 23); // attach it
temp_legup_l = ent_create(leftlegup_mdl,temp, 0); // create bodypart
setLimit(vector(0,1,0), vector(-90,15,0)); // set Limet
BodyPartInit(5, temp_legup_l); // make constraint
rd_con_legup_l = phcon_add(PH_HINGE, temp_legup_l, temp_pelvis);
phcon_setparams1(rd_con_legup_l, temp_legup_l.x, tempH1, nullvector);
phcon_setparams2(rd_con_legup_l, tempH2, nullvector, nullvector);

// left lower leg

vec_for_vertex(temp, temp_legup_l, 9);
temp_legdown_l = ent_create(leftlegdown_mdl, temp, 0);
setLimit(vector(0,1,0), vector(0,120,0));
BodyPartInit(20, temp_legdown_l); // make constraint

rd_con_legdown_l = phcon_add(PH_HINGE, temp_legdown_l, temp_legup_l);
phcon_setparams1(rd_con_legdown_l, temp_legdown_l.x, tempH1,
nullvector);
phcon_setparams2(rd_con_legdown_l, tempH2, nullvector, nullvector);

// right upper leg

vec_for_vertex(temp, temp_pelvis, 22);
temp_legup_r = ent_create(rightlegup_mdl, temp, 0);
setLimit(vector(0,1,0), vector(-90,15,0));
BodyPartInit(5, temp_legup_r);
// make constraint
rt_legup_r = phcon_add(PH_HINGE, temp_legup_r, temp_pelvis);
phcon_setparams1(rt_legup_r, temp_legup_r.x, tempH1, nullvector);
phcon_setparams2(rt_legup_r, tempH2, nullvector, nullvector);

// right lower leg

vec_for_vertex(temp, temp_legup_r, 9);
temp_legdown_r = ent_create(rightlegdown_mdl, temp, 0);
setLimit(vector(0,1,0), vector(0,120,0));
BodyPartInit(20, temp_legdown_r);
// make constraint
rd_con_legdown_r = phcon_add(PH_HINGE, temp_legdown_r, temp_legup_r);
phcon_setparams1(rt_legdown_r, temp_legdown_r.x, tempH1, nullvector);
phcon_setparams2(rt_legdown_r, tempH2, nullvector, nullvector);

// abs
vec_for_vertex(temp, temp_pelvis, 21);
temp_abs = ent_create(abs_mdl, temp, 0);
setLimit(vector(0,1,0), vector(-15,15,0));
BodyPartInit(20, temp_abs);
// make constraint
rd_con_abs = phcon_add(PH_HINGE, temp_abs, temp_pelvis);
phcon_setparams1(rt_abs, temp_abs.x, tempH1, nullvector);
phcon_setparams2(rt_abs, tempH2, nullvector, nullvector);

//torso
vec_for_vertex(temp, temp_abs, 17);
temp_torso = ent_create(torso_mdl, temp, 0);
setLimit(vector(0,1,0), vector(-15,15,0));
BodyPartInit(55, temp_torso);
// make constraint
rd_con_torso = phcon_add(PH_HINGE, temp_torso, temp_abs);
phcon_setparams1(rt_torso, temp_torso.x, tempH1, nullvector);
phcon_setparams2(rt_torso, tempH2, nullvector, nullvector);

// left upper arm

vec_for_vertex(temp, temp_torso, 21);
temp_armup_l = ent_create(leftarmup_mdl, temp, 0);
setLimit(vector(1,0,0), vector(-70,80,0));
BodyPartInit(5, temp_armup_l);
// make constraint
rd_con_armup_l = phcon_add(PH_HINGE, temp_armup_l, temp_torso);
phcon_setparams1(rt_armup_l, temp_armup_l.x, tempH1,nullvector);
phcon_setparams2(rt_armup_l, tempH2, nullvector, nullvector);

// left lower arm

vec_for_vertex(temp, temp_armup_l, 9);
temp_armdown_l = ent_create(leftarmdown_mdl, temp, 0);
setLimit(vector(1,0,0), vector(270,0,0));
BodyPartInit(20, temp_armdown_l);
// make constraint
rt_armdown_l = phcon_add(PH_HINGE, temp_armdown_l, temp_armup_l);
phcon_setparams1(rt_armdown_l, temp_armdown_l.x,tempH1, nullvector);
phcon_setparams2(rd_con_armdown_l, tempHinge2, nullvector, nullvector);

// right upper arm
vec_for_vertex(temp, temp_torso, 22);
temp_armup_r = ent_create(rightarmup_mdl, temp, 0);
setLimit(vector(1,0,0), vector(-70,80,0));
BodyPartInit(5, temp_armup_r);
// make constraint
rt_armup_r = phcon_add(PH_HINGE, temp_armup_r, temp_torso);
phcon_setparams1(rt_armup_r, temp_armup_r.x, tempH1, nullvector);
phcon_setparams2(rd_con_armup_r, tempHinge2, nullvector, nullvector);

// right lower arm

vec_for_vertex(temp, temp_armup_r, 9);
temp_armdown_r = ent_create(rightarmdown_mdl, temp, 0);
setLimit(vector(1,0,0), vector(0,90,0));
BodyPartInit(20, temp_armdown_r);
// make constraint
rt_armdown_r = phcon_add(PH_HINGE, temp_armdown_r, temp_armup_r);
phcon_setparams1(rt_armdown_r, temp_armdown_r.x, tempH1, nullvector);
phcon_setparams2(rt_armdown_r, tempH2, nullvector, nullvector);

// head

vec_for_vertex(temp, temp_torso, 23);
temp_head = ent_create(head_mdl, temp, 0);
setLimit(vector(0,1,0), vector(-40,40,0));
BodyPartInit(25, temp_head);
// make constraint
rt_head = phcon_add(PH_HINGE, temp_head, temp_torso);
phcon_setparams1(rt_head, temp_head.x, tempH1, nullvector);
phcon_setparams2(rt_head, tempH2, nullvector, nullvector);

//Now I creat the actor and hide it. But how can I hide that model?
//Man I need somthing like a 3dgs school, then physics is almost the onley thing I can work with wink

you = ent_create("ragdoll.mdl", nullvector, 0); //model

//But how it`s going on?

________________________________________________________________________________

Please you can tell me that thats right, then I can`t feel my finger anymore smile

But after conecting bodyparts and seting Limets, what should I do then?
Then this script should be a death funktion, and I can`t belive that after seting limets (and bodyparts) that it`s already finish.

But that would be cool wink


Posted By: Rackscha

Re: function ragdoll help!! - 05/15/09 15:52

ok looks fine, before you create your visible actor model: test your ragdoll bones. Just create the scelet as you have written it above and see how it falls to the ground and how arms/legs behave. if this is ok create your visible actor model.

If you want to hide the physik bones, then do the folowing: when creating the model of a physikbone, assign an action to it which makes it invisible(set(my,INVISIBLE);)

Or you simply use the pointer you receive from the ent_create function and use this pointer DIRECTLY after the creation of the physik bone model, with set(pointer,flag);

And if you have done this, the next step is to set the rotation of your actors model's bones to the rotation of the attached physikbone wink

Greets
Rackscha
Posted By: MDMDFSS

Re: function ragdoll help!! - 05/15/09 16:10

Thats a problem I must wait for my new computer.
My computer is to bad for lite-c. averytime I try to start somthing it shows:

"Can`t open video device. Try -W3D command line option"

But in max 2weeks I have my new computer smile

Or how can I give you my ragdoll?
Posted By: XD1v0

Re: function ragdoll help!! - 05/19/09 10:50

If you want I can do examples for ragdoll code, on contest winter 2008 I do program "Physics Constrains Editor" , i did this program for easy creating entities and set physic properties to entity in editor window and set physics constrains between two entities, any entity user could attach to entity bone, when user could save this entities and physics properties to *.ent file.
But how see what A7 user could not use PCE, sure if i shall do good tutorial maybie then other understand how it works, but its hard for my english.
So i have only one way out, i can create easy examples for how create ragdoll, do you want this?
Posted By: sebbi91

Re: function ragdoll help!! - 05/19/09 16:32

@XD1v0
You written the "Physics Constrains Editor" ?
Nice Job!!
Awesome! ^^

It's very nice but I cant use the .Ent files!
Could you explain how you set the Position of a Bone to a Ph-Objekt like in "ph_scene5.ent"

Sorry but I cant understand that script!
But I want to learn how bones and the Physik engeine works!

btw sorry for my english, i am a german user! ^^
Posted By: XD1v0

Re: function ragdoll help!! - 05/20/09 10:08

Ok I try make some example, maybe video tutorial
Posted By: sebbi91

Re: function ragdoll help!! - 05/20/09 18:35

ok that would be very nice!

^^

Its just a tip but it will be very,very nice if you could add a "Save as Lite-C" or "Save as C-Script" function.
Because I cant get any informations from the .ent file!

It would be very usefull to understand how your ragdoll code works and easier to use the Ragdoll code!



Lg BasTi
Posted By: MDMDFSS

Re: function ragdoll help!! - 05/21/09 11:31

Das ist nicht so schlimm
Ich speche auch gut Deutsch.
Posted By: Helghast

Re: function ragdoll help!! - 05/25/09 09:38

If darkinferno gives me permission, i created a whole new system in A7 lite-c to create ragdolls. Just wait a couple of days, i'll upload it then smile

(It looks like you used a part of my code anyway for this, am i right? the setLimit and bodyPartInit stuff (plus defined model names are exactly like mine)).

regards,
Posted By: MDMDFSS

Re: function ragdoll help!! - 06/08/09 11:09

wow...
Posted By: Helghast

Re: function ragdoll help!! - 06/10/09 07:37

Originally Posted By: MDMDFSS
wow...


It was uploaded, it's in Projects forum.
Hope it works fine for you smile

regards,
© 2024 lite-C Forums