2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
A8 Ragdoll conversion from A7 - case study
#336821
08/06/10 14:10
08/06/10 14:10
|
Joined: Jul 2000
Posts: 27,986 Frankfurt
jcl
OP
Chief Engineer
|
OP
Chief Engineer
Joined: Jul 2000
Posts: 27,986
Frankfurt
|
We were asked to help fixing the A8 version of the A7 Ragdoll demo by Helghast. As this is a good example of the problems you can encounter when converting an A7 ODE project to A8 PhysX, I'm posting here our experiences as case study. 1. Continous collision detection For speed reasons, PhysX does not use CCD by default. This causes very small objects, such as the tiny bones of the demo, to fall through the floor. So you need to activate CCD when tiny things move fast and collide with something.
// A7 physics initialization
fps_max = 60;
fps_min = 30;
ph_iterations = 20; // set itterating physics to smooth out.
ph_setgravity(vector(0, 0, -668)); // set gravity
ph_setcorrections(9000, 0); // set physics corrections
ph_setcollisions(1000, 20);
// A8 physics initialization for CCD
physX_open();
pX_setgravity(vector(0, 0, -9.81)); // set gravity
pX_setccd(1);
2. Initialize physics objects Begin with the default settings. They will suffice in most cases. Adjust them later if necessary. The mass is calculated automatically in A8.
// A7 physics object initialization
set(entityMe, PASSABLE);
phent_settype(entityMe, PH_RIGID, PH_BOX);
phent_setmass(entityMe, mass, PH_BOX);
phent_setfriction(entityMe, 15);
phent_setdamping(entityMe, 35, 35);
phent_setelasticity(entityMe, 35, 30); // bounciness
reset(entityMe, PASSABLE);
// A8 physics object initialization with CCD
pXent_settype(entityMe, PH_RIGID, PH_BOX);
pXent_setccdskeleton(entityMe, nullvector, 1);
3. Initialize joints In A8, joints are addressed through the entity pointer, not through a hinge handle, and have more parameters (for instance restitution, and break limits). When you don't need a break limit, pass NULL for the vector parameter. Passing nullvector would set the break limits to 0. And don't join an object with itself! This will cause a crash, just as in real life.
// A7 hinge initialization
var tempHinge;
// make constraint
tempHinge = phcon_add(PH_HINGE, constr_1, constr_2); // attach to bodypart
phcon_setparams1(tempHinge, constr_1.x, RD_Hinge1, nullvector); // set hinge limits
phcon_setparams2(tempHinge, RD_Hinge2, nullvector, nullvector);
// A8 hinge initialization
// make constraint
pXcon_add(PH_HINGE, constr_1, constr_2, 0); // attach to bodypart
pXcon_setparams1(constr_1, constr_1.x, RD_Hinge1, NULL); // set hinge limits
pXcon_setparams2(constr_1, RD_Hinge2, NULL, NULL); // same
4. Reading object positions Don't disable or enable objects for reading their positions in A8. First, it is not necessary. Second, you can't displace objects that are attached to joints, so disabling an object requires removing its joints first. You don't want to do that for a ragdoll.
// A7
pXent_enable(limb, 0);
vec_for_bone(limb.x, actor, boneBlend); // place at right position
ang_for_bone(limb.pan, actor, boneBlend); // rotate by right angle
pXent_enable(limb, 1);
// A8
vec_for_bone(limb.x, actor, boneBlend); // place at right position
ang_for_bone(limb.pan, actor, boneBlend); // rotate by right angle
|
|
|
Re: A8 Ragdoll conversion from A7 - case study
[Re: jcl]
#336836
08/06/10 14:54
08/06/10 14:54
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
Yes, 6DJOINT has the advantage that you can add spring elements, simulating the resistance of muscles and tendons. But you need to read the nVidia documentation for learning all possibilities of 6D joints. It's a lot of pages and didn't fit into our manual. That's no problem, im used to reading alot of documentation, I will go ahead and take a look at this, and possibly convert it at a later point. For now I think the Demo would be a bigger use to the community. Another question, how does the speed of a collision type of PH_BOX vs PH_CAPSULE hold up against each other? I feel humanoid ragdolls would benefit from using capsules rather then using boxes, am I right in this case?
|
|
|
Re: A8 Ragdoll conversion from A7 - case study
[Re: Helghast]
#336871
08/06/10 18:12
08/06/10 18:12
|
Joined: Oct 2007
Posts: 5,210 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
|
there are some really good pieces of small tips on that post, i suggest this to be either sticky or go in to the a7->a8 part of manual/aum.
Last edited by Quadraxas; 08/06/10 18:12.
3333333333
|
|
|
Re: A8 Ragdoll conversion from A7 - case study
[Re: jcl]
#337810
08/13/10 15:38
08/13/10 15:38
|
Joined: Mar 2007
Posts: 197
yorisimo
Member
|
Member
Joined: Mar 2007
Posts: 197
|
How do we make a motorized hinge joint in A8? (In A7 we could just use phcon_setmotor, but a similar function does not exist in A8) I would be OK using the more complicated 6D joint if that is the solution. Are joint motors/springs/dampers implemented yet in A8: in the manual under pXcon_set6djoint it says that JointDrive[6] is unused.
I am having trouble finding the PhysX SDK Manual. Does anyone have a copy they can send me? It seems NVIDIA is delayed in giving developers access to the PhysX SDK. I don't necessarily want the source code, just the manual.
How are swing1Motion, swing2Motion and twistMotion defined (about local/global x, y, an z axes?)
EDIT: testing it out... looks like swing1Motion is pan (z), swing2Motion is tilt (-y) and twistMotion is roll (x) relative to bodies starting orientations. I think the documentation would be a lot more clear if it used the standard Gamestudio descriptions pan/tilt/roll than the non descriptive swing1/swing2/twist
What I don't understand is why the 6D Joint needs a Rotation Axis parameter defined by pX_setparams1 (Parameter 2), since the axes are defined using pXcon_set6djoint. I also don't understand why Parameter 4 sets both swing1 and swing2 limit in the x and y parameters, whereas Parameter 5 sets the lower and upper limit of twist in the x and y parameters. How do you set the lower and upper limits independently for swing1/swing2? For Parameter 6, shouldn't you be able to set the x,y,and z linear limits independently?
Also, will pXcon_getposition support the 6D Joint as well? There would be up to 6 values (x,y,z,pan,tilt,roll) that it would need to return
Thanks
Last edited by yorisimo; 08/13/10 19:16.
|
|
|
Re: A8 Ragdoll conversion from A7 - case study
[Re: yorisimo]
#343020
10/03/10 08:36
10/03/10 08:36
|
Joined: Feb 2010
Posts: 886
Random
User
|
User
Joined: Feb 2010
Posts: 886
|
So, did somebody made it???
|
|
|
Re: A8 Ragdoll conversion from A7 - case study
[Re: HeelX]
#344541
10/18/10 09:34
10/18/10 09:34
|
Joined: Jan 2004
Posts: 3,023 The Netherlands
Helghast
Expert
|
Expert
Joined: Jan 2004
Posts: 3,023
The Netherlands
|
I'm also interested in this... Helgast? Anyone?? Due to deadlines at work, and freelance contracts which have my priority, I have been unable as of yet to convert this properly. I cant tell yet either when exactly I will have it done... as the coming 6 weeks I'm gonna be crunching at the project at work. regards,
|
|
|
|