///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
///////////////////////////////
ENTITY* Kopf;
ENTITY* OberarmR;
ENTITY* UnterarmR;
ENTITY* HandR;
ENTITY* OberarmL;
ENTITY* UnterarmL;
ENTITY* HandL;
ENTITY* Bein1R;
ENTITY* Bein2R;
ENTITY* FussR;
ENTITY* Bein1L;
ENTITY* Bein2L;
ENTITY* FussL;
ENTITY* Body1;
ENTITY* Body2;
ENTITY* Body3;
ENTITY* Hals;
ENTITY* Haare;
ENTITY* Skelett;
ENTITY* Plane;
VECTOR* swingLimit = {x=60;y=0;z=0;}
VECTOR* twistLimit = {x=-30;y=0;z=0;}
VECTOR* linearLimit = {x=0;y=0;z=0;}
var elasticity = 0;
var linear = 0;
var angular = 0;
var friction = 0;
function main()
{
vec_set(screen_size,vector(1200,900,0));
ENTITY* to;
var Motion[6];
var Motion2[6];
video_window(NULL,NULL,0,"PhysX Grundsteuerung");
physX_open();
pX_setsteprate(512, 8, NX_TIMESTEP_FIXED);
pX_setccd (1);
level_load("");
Motion[0] = NX_D6JOINT_MOTION_LOCKED;
Motion[1] = NX_D6JOINT_MOTION_LOCKED;
Motion[2] = NX_D6JOINT_MOTION_LOCKED;
Motion[3] = NX_D6JOINT_MOTION_LIMITED;
Motion[4] = NX_D6JOINT_MOTION_LIMITED;
Motion[5] = NX_D6JOINT_MOTION_LIMITED;
Plane = ent_create(NULL, nullvector,NULL);
Kopf = ent_create("Kopf.mdl",nullvector,NULL);
OberarmR = ent_create("ArmR1.mdl",nullvector,NULL);
UnterarmR = ent_create("ArmR2.mdl",nullvector,NULL);
HandR = ent_create("HandR.mdl",nullvector,NULL);
OberarmL = ent_create("ArmL1.mdl",nullvector,NULL);
UnterarmL = ent_create("ArmL2.mdl",nullvector,NULL);
HandL = ent_create("HandL.mdl",nullvector,NULL);
Bein1R = ent_create("BeinR1.mdl",nullvector,NULL);
Bein2R = ent_create("BeinR2.mdl",nullvector,NULL);
FussR = ent_create("FusR.mdl",nullvector,NULL);
Bein1L = ent_create("BeinL1.mdl",nullvector,NULL);
Bein2L = ent_create("BeinL2.mdl",nullvector,NULL);
FussL = ent_create("FusL.mdl",nullvector,NULL);
Body1 = ent_create("Body1.mdl",nullvector,NULL);
Body2 = ent_create("Body2.mdl",nullvector,NULL);
Body3 = ent_create("Body3.mdl",nullvector,NULL);
Hals = ent_create("Hals.mdl",nullvector,NULL);
Haare = ent_create("Haare.mdl",nullvector,NULL);
Skelett = ent_create("Skelett.mdl",vector(0,0,500),NULL);
to = ent_create(NULL,nullvector,NULL);
ent_animate(Skelett,"Angle",0,NULL);
vec_for_bone(Body1.x,Skelett,"Main");
vec_for_bone(Body2.x,Skelett,"Body");
vec_for_bone(to.x,Skelett,"Body1");
vec_add(to.x,Body2.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Body2.x,to.x);
vec_for_bone(Body3.x,Skelett,"Body1");
vec_for_bone(to.x,Skelett,"Body2");
vec_add(to.x,Body3.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Body3.x,to.x);
vec_for_bone(Hals.x,Skelett,"Body2");
vec_for_bone(to.x,Skelett,"Head");
vec_add(to.x,Hals.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Hals.x,to.x);
vec_for_bone(Kopf.x,Skelett,"Head");
vec_for_bone(to.x,Skelett,"Head1");
vec_add(to.x,Kopf.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Kopf.x,to.x);
vec_for_bone(OberarmR.x,Skelett,"ArmR");
vec_for_bone(to.x,Skelett,"ArmR1");
vec_add(to.x,OberarmR.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(OberarmR.x,to.x);
OberarmR.tilt = 90;
vec_for_bone(UnterarmR.x,Skelett,"ArmR1");
vec_for_bone(to.x,Skelett,"HandR");
vec_add(to.x,UnterarmR.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(UnterarmR.x,to.x);
UnterarmR.tilt = 90;
vec_for_bone(HandR.x,Skelett,"HandR");
vec_for_bone(to.x,Skelett,"HandR1");
vec_add(to.x,HandR.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(HandR.x,to.x);
HandR.tilt = 90;
vec_for_bone(OberarmL.x,Skelett,"ArmL");
vec_for_bone(to.x,Skelett,"ArmL1");
vec_add(to.x,OberarmL.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(OberarmL.x,to.x);
OberarmL.tilt = -90;
vec_for_bone(UnterarmL.x,Skelett,"ArmL1");
vec_for_bone(to.x,Skelett,"HandL");
vec_add(to.x,UnterarmL.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(UnterarmL.x,to.x);
UnterarmL.tilt = -90;
vec_for_bone(HandL.x,Skelett,"HandL");
vec_for_bone(to.x,Skelett,"HandL1");
vec_add(to.x,HandL.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(HandL.x,to.x);
HandL.tilt = -90;
vec_for_bone(Bein1R.x,Skelett,"LegR");
vec_for_bone(to.x,Skelett,"LegR1");
vec_add(to.x,Bein1R.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Bein1R.x,to.x);
vec_for_bone(Bein2R.x,Skelett,"LegR1");
vec_for_bone(to.x,Skelett,"FootR");
vec_add(to.x,Bein2R.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Bein2R.x,to.x);
vec_for_bone(FussR.x,Skelett,"FootR");
vec_for_bone(to.x,Skelett,"FootR1");
vec_add(to.x,FussR.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(FussR.x,to.x);
FussR.roll = -90;
vec_for_bone(Bein1L.x,Skelett,"LegL");
vec_for_bone(to.x,Skelett,"LegL1");
vec_add(to.x,Bein1L.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Bein1L.x,to.x);
vec_for_bone(Bein2L.x,Skelett,"LegL1");
vec_for_bone(to.x,Skelett,"FootL");
vec_add(to.x,Bein2L.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(Bein2L.x,to.x);
vec_for_bone(FussL.x,Skelett,"FootL");
vec_for_bone(to.x,Skelett,"FootL1");
vec_add(to.x,FussL.x);
vec_mul(to.x,vector(0.5,0.5,0.5));
vec_set(FussL.x,to.x);
FussL.roll = -90;
pXent_settype(Plane, PH_STATIC, PH_PLANE);
pXent_settype(Kopf, PH_RIGID, PH_SPHERE);
pXent_settype(OberarmR, PH_RIGID, PH_CAPSULE);
pXent_settype(UnterarmR, PH_RIGID, PH_CAPSULE);
pXent_settype(HandR, PH_RIGID, PH_CAPSULE);
pXent_settype(OberarmL, PH_RIGID, PH_CAPSULE);
pXent_settype(UnterarmL, PH_RIGID, PH_CAPSULE);
pXent_settype(HandL, PH_RIGID, PH_CAPSULE);
pXent_settype(Bein1R, PH_RIGID, PH_CAPSULE);
pXent_settype(Bein2R, PH_RIGID, PH_CAPSULE);
pXent_settype(FussR, PH_RIGID, PH_CAPSULE);
pXent_settype(Bein1L, PH_RIGID, PH_CAPSULE);
pXent_settype(Bein2L, PH_RIGID, PH_CAPSULE);
pXent_settype(FussL, PH_RIGID, PH_CAPSULE);
pXent_settype(Body1, PH_RIGID, PH_CAPSULE);
pXent_settype(Body2, PH_RIGID, PH_CAPSULE);
pXent_settype(Body3, PH_RIGID, PH_CONVEX);
pXent_settype(Hals, PH_RIGID, PH_CAPSULE);
pXent_setcollisionflag( Body1, Body2, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Body1,Body2,0);
vec_for_bone(to.x,Skelett,"Body");
pXcon_setparams1(Body1, to.x,NULL,NULL);
pXcon_setparams2(Body1,vector(30,10,0),NULL,NULL);
pXcon_set6djoint(Body1,Motion,NULL);
pXent_setcollisionflag( Body2, Body3, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Body2,Body3,0);
vec_for_bone(to.x,Skelett,"Body1");
pXcon_setparams1(Body2, to.x,NULL,NULL);
pXcon_setparams2(Body2,vector(30,20,0),NULL,NULL);
pXcon_set6djoint(Body2,Motion,NULL);
pXent_setcollisionflag( Hals, Body3, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Hals,Body3,0);
vec_for_bone(to.x,Skelett,"Body2");
pXcon_setparams1(Hals, to.x,NULL,NULL);
pXcon_setparams2(Hals,vector(30,20,0),NULL,NULL);
pXcon_set6djoint(Hals,Motion,NULL);
pXent_setcollisionflag(Kopf, Hals, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Kopf,Hals,0);
vec_for_bone(to.x,Skelett,"Head");
pXcon_setparams1(Kopf, to.x,NULL,NULL);
pXcon_setparams2(Kopf,vector(30,20,0),NULL,NULL);
pXcon_set6djoint(Kopf,Motion,NULL);
pXent_setcollisionflag(OberarmR,Body3, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,OberarmR,Body3,0);
vec_for_bone(to.x,Skelett,"ArmR");
pXcon_setparams1(OberarmR, to.x,vector(0,0,1),NULL);
pXcon_setparams2(OberarmR,vector(120,120,0),vector(0, 0, 70),NULL);
pXcon_set6djoint(OberarmR,Motion2,NULL);
pXent_setcollisionflag(OberarmL,Body3, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,OberarmL,Body3,0);
vec_for_bone(to.x,Skelett,"ArmL");
pXcon_setparams1(OberarmL, to.x,vector(0,0,1),NULL);
pXcon_setparams2(OberarmL,vector(120,120,0),vector(0, 0, 70),NULL);
pXcon_set6djoint(OberarmL,Motion2,NULL);
pXent_setcollisionflag(UnterarmR, OberarmR, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT, UnterarmR, OberarmR, 0);
vec_for_bone(to.x, Skelett, "ArmR1");
pXcon_setparams1(UnterarmR, to.x, vector(0,0,1), NULL);
pXcon_setparams2(UnterarmR, NULL, vector(0,135,0), NULL);
pXcon_set6djoint(UnterarmR, Motion, NULL);
pXent_setcollisionflag(UnterarmL, OberarmL, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT, UnterarmL, OberarmL, 0);
vec_for_bone(to.x, Skelett, "ArmL1");
pXcon_setparams1(UnterarmL, to.x, vector(0,0,-1), NULL);
pXcon_setparams2(UnterarmL, NULL, vector(0,135,0), NULL);
pXcon_set6djoint(UnterarmL, Motion, NULL);
pXent_setcollisionflag(HandR,UnterarmR, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,HandR,UnterarmR,0);
vec_for_bone(to.x,Skelett,"HandR");
pXcon_setparams1(HandR, to.x,NULL,NULL);
pXcon_setparams2(HandR, vector(135,135,0), NULL, NULL);
pXcon_set6djoint(HandR,Motion,NULL);
pXent_setcollisionflag(HandL,UnterarmL, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,HandL,UnterarmL,0);
vec_for_bone(to.x,Skelett,"HandL");
pXcon_setparams1(HandL, to.x,NULL,NULL);
pXcon_setparams2(HandL, vector(135,135,0), NULL, NULL);
pXcon_set6djoint(HandL,Motion,NULL);
pXent_setcollisionflag(Bein1R,Body1, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Bein1R,Body1,0);
vec_for_bone(to.x,Skelett,"LegR");
pXcon_setparams1(Bein1R, to.x,NULL,NULL);
pXcon_setparams2(Bein1R, vector(50,135,0), NULL, NULL);
pXcon_set6djoint(Bein1R,Motion,NULL);
pXent_setcollisionflag(Bein1L,Body1, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Bein1L,Body1,0);
vec_for_bone(to.x,Skelett,"LegL");
pXcon_setparams1(Bein1L, to.x,NULL,NULL);
pXcon_setparams2(Bein1L, vector(50,135,0), NULL, NULL);
pXcon_set6djoint(Bein1L,Motion,NULL);
pXent_setcollisionflag(Bein2R,Bein1R, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Bein2R,Bein1R,0);
vec_for_bone(to.x,Skelett,"LegR1");
pXcon_setparams1(Bein2R, to.x,vector(1,0,0),NULL);
pXcon_setparams2(Bein2R, NULL, vector(0,135,0), NULL);
pXcon_set6djoint(Bein2R,Motion,NULL);
pXent_setcollisionflag(Bein2L,Bein1L, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,Bein2L,Bein1L,0);
vec_for_bone(to.x,Skelett,"LegL1");
pXcon_setparams1(Bein2L, to.x,vector(1,0,0),NULL);
pXcon_setparams2(Bein2L, NULL, vector(0,135,0), NULL);
pXcon_set6djoint(Bein2L,Motion,NULL);
pXent_setcollisionflag(FussR,Bein2R, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,FussR,Bein2R,0);
vec_for_bone(to.x,Skelett,"FootR");
pXcon_setparams1(FussR, to.x,vector(1,0,0),NULL);
pXcon_setparams2(FussR, vector(10,0,0), vector(0,30,0), NULL);
pXcon_set6djoint(FussR,Motion,NULL);
pXent_setcollisionflag(FussL,Bein2L, NX_IGNORE_PAIR);
pXcon_add(PH_6DJOINT,FussL,Bein2L,0);
vec_for_bone(to.x,Skelett,"FootL");
pXcon_setparams1(FussL, to.x,vector(1,0,0),NULL);
pXcon_setparams2(FussL, vector(10,0,0), vector(0,30,0), NULL);
pXcon_set6djoint(FussL,Motion,NULL);
vec_set(camera.x,vector(1000,0,0));
vec_set(camera.pan,vector(180,15,0));
pXent_setelasticity(Plane, elasticity);
pXent_setelasticity(Kopf, elasticity);
pXent_setelasticity(Hals, elasticity);
pXent_setelasticity(Body1, elasticity);
pXent_setelasticity(Body2, elasticity);
pXent_setelasticity(Body3, elasticity);
pXent_setelasticity(OberarmR, elasticity);
pXent_setelasticity(UnterarmR, elasticity);
pXent_setelasticity(HandR, elasticity);
pXent_setelasticity(Bein1R, elasticity);
pXent_setelasticity(Bein2R, elasticity);
pXent_setelasticity(FussR, elasticity);
pXent_setelasticity(OberarmL, elasticity);
pXent_setelasticity(UnterarmL, elasticity);
pXent_setelasticity(HandL, elasticity);
pXent_setelasticity(Bein1L, elasticity);
pXent_setelasticity(Bein2L, elasticity);
pXent_setelasticity(FussL, elasticity);
while(1)
{
pX_pick();
vec_set(Haare.x, Kopf.x);
vec_set(Haare.pan, Kopf.pan);
wait(1);
}
}