#include <default.c>
#include <ackphysx.h>
function main()
{
physX_open();
level_load(""); // load an empty level
vec_set(camera.x,vector(-100,0,30));
pXent_settype(NULL,PH_STATIC,PH_PLANE); // create a static plane at groundlevel zero
ENTITY* box4 = ent_create(SPHERE_MDL,vector(0,0,100),NULL);
ENTITY* box5 = ent_create(CUBE_MDL,vector(0,0,60),NULL);
pXent_settype(box4,PH_RIGID,PH_SPHERE );
pXent_settype(box5,PH_RIGID,PH_BOX );
// upper joint
pXcon_add(PH_6DJOINT,box4,NULL,0); // when you use NULL you attach the entity (box4) to the world
// lower joint
pXcon_add(PH_6DJOINT,box5,box4,0);
VECTOR* globalAxis = vector(0,0,-1); // using the z axis
pXcon_setparams1(box4,NULL,globalAxis,NULL);
pXcon_setparams1(box5,NULL,globalAxis,NULL);
VECTOR* swingLimit = vector(30,70,0);
VECTOR* twistLimit = vector(-90,45,0);
VECTOR* linearLimit = vector(10,0,0);
pXcon_setparams2(box4,swingLimit,twistLimit,linearLimit);
pXcon_setparams2(box5,swingLimit,twistLimit,linearLimit);
var Motion[6];
Motion[0] = NX_D6JOINT_MOTION_FREE; // This frees box4 from the world (NULL)
Motion[1] = NX_D6JOINT_MOTION_FREE;
Motion[2] = NX_D6JOINT_MOTION_FREE;
Motion[3] = NX_D6JOINT_MOTION_LIMITED; //this limits the angles
Motion[4] = NX_D6JOINT_MOTION_LIMITED;
Motion[5] = NX_D6JOINT_MOTION_LIMITED;
pXcon_set6djoint(box4,Motion,NULL);
Motion[0] = NX_D6JOINT_MOTION_LOCKED; //this locks box5 on box4
Motion[1] = NX_D6JOINT_MOTION_LOCKED;
Motion[2] = NX_D6JOINT_MOTION_LOCKED;
pXcon_set6djoint(box5,Motion,NULL);
while(1){
pX_pick(); // pick and move the ball (!) with the cursor
wait(1);
}
}