action pivot()
{
VECTOR finalvector;
VECTOR tempvector;
var i = 0 ;
var j = 0 ;
phent_settype (me, PH_RIGID, PH_SPHERE); //physics..
phent_setmass (me, 3, PH_SPHERE);
phent_setfriction (me, 80);
phent_setdamping (me, 40, 40);
phent_setelasticity (me, 100, 50);
//adjusting the position for the new entity
vec_set (tempvector , vector(0,0,100));
vec_set (finalvector, tempvector);
vec_add (finalvector, my.x);
ent_create ("triang.mdl", finalvector, pontosmoveis); //first (top) triangle created
//adjusting position again
vec_rotate(tempvector, vector(0,180,0));
vec_set (finalvector, tempvector);
vec_add (finalvector, my.x);
ent_create ("triang.mdl", finalvector, pontosmoveis); //bottom triangle created
//the following loop creates all the triangles left
while (i<5)
{
i+=1;
vec_rotate(tempvector, vector(0,30,0));
vec_set (finalvector, tempvector);
vec_add (finalvector, vector(my.x, my.y, my.z));
while (j<8)
{
j +=1;
ent_create("triang.mdl", finalvector , pontosmoveis);
vec_rotate(tempvector,vector(45 ,0 ,0));
vec_set (finalvector, tempvector);
vec_add (finalvector, vector(my.x, my.y, my.z));
}
j=0;
}
}
function pontosmoveis(indice)
{
VECTOR range;
vec_set(range, vector(-10,10,0));
phent_settype (me, PH_RIGID, PH_SPHERE);
phent_setmass (me, 1, PH_SPHERE);
phent_setfriction (me, 80);
phent_setdamping (me, 40, 40);
phent_setelasticity (me, 50, 20);
pivotobj = phcon_add(PH_SLIDER, me, you); //pivotobj is a previously defined pointer
phcon_setparams2(pivotobj, range, nullvector, nullvector);
while(1)
{
if(key_z)
{
vec_set(strength, vector(1000,10000,0));
}
if(key_x)
{
vec_set(strength, vector(-1000,10000,0));
}
if(!key_z && !key_x)
{
vec_set(strength, vector(0,0,0));
}
phcon_setmotor(pivotobj, strength, nullvector, nullvector);
phcon_setmotor(pivotobj, strength, nullvector, nullvector);
wait(1);
}
}