ENTITY* p_pole;
ENTITY*p_flag_ent;
void p_open()
{
// pXent_settype(p_pole,0,0);
pXent_settype(p_flag_ent,0,0);
// pXent_settype(NULL,0,0);
wait(5);
ent_remove(p_pole);
ent_remove(p_flag_ent);
wait(5);
//physX_open();
level_load(NULL);
vec_set(sun_angle.pan,vector(300,60,5000));
vec_set(camera.x,vector(-1200,100,500));
vec_set(camera.pan,vector(0,-10,0));
//////////////////////////////
// Cloth #1
//////////////////////////////
// generate flag pole
ENTITY *pole = ent_create(CUBE_MDL,vector(0,400,40*8),NULL);
p_pole=pole;
vec_set(pole.scale_x,vector(0.5,.5,40));
vec_set(pole.pan,vector(0,0,0));
vec_set(pole.blue,COLOR_WHITE);
set(pole,SHADOW|CAST);
pXent_settype(pole,PH_STATIC,PH_BOX);
// generate flag
ENTITY *cloth = ent_create("clothflag.mdl",NULL,NULL);
p_flag_ent=cloth;
vec_set(cloth.pan,vector(0,0,0));
cloth.material = mtl_twosided_alpha;
cloth.ambient = 50;
set(cloth,SHADOW|CAST);
set(cloth.material,PASS_SOLID); // required for shadow
//ent_clone(cloth); // Prevents, that all clothes move the same way
// attach flag to pole
c_setminmax(pole);
c_setminmax(cloth);
vec_set(cloth.x,vector(
pole.x,
pole.y+(cloth.max_y-cloth.min_y)/2,
pole.z+pole.max_z-(cloth.max_z-cloth.min_z)/2));
// setup flag cloth
var cloth_options[40];
memcpy(cloth_options,CLOTH_DEFAULT,40*sizeof(var));
vec_set(cloth_options[25],vector(-1,-1,0)); // external acceleration
vec_set(cloth_options[28],vector(0,30,0)); // random wind acceleration
cloth_options[9] = 4; // Tear Factor
cloth_options[37] |= NX_CLF_GRAVITY|NX_CLF_BENDING|NX_CLF_COLLISION_TWOWAY|NX_CLF_SELFCOLLISION|NX_CLF_TEARABLE;
pXent_cloth(cloth,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options);
}
function main(){
fps_max = 60;
physX_open();
level_load("");
vec_set(sky_color,COLOR_BLUE);
vec_set(sun_angle.pan,vector(300,60,5000));
vec_set(camera.x,vector(-1200,100,500));
vec_set(camera.pan,vector(0,-10,0));
wait(1);
//on_d = destroy_physic;
on_o = p_open;
// on_c = create_flag;
// var num_bodies = pX_stats(1);
//////////////////////////////
// Cloth #1
//////////////////////////////
// generate flag pole
ENTITY *pole = ent_create(CUBE_MDL,vector(0,400,40*8),NULL);
p_pole=pole;
vec_set(pole.scale_x,vector(0.5,.5,40));
vec_set(pole.pan,vector(0,0,0));
vec_set(pole.blue,COLOR_WHITE);
set(pole,SHADOW|CAST);
pXent_settype(pole,PH_STATIC,PH_BOX);
// generate flag
ENTITY *cloth = ent_create("clothflag.mdl",NULL,NULL);
p_flag_ent=cloth;
vec_set(cloth.pan,vector(0,0,0));
cloth.material = mtl_twosided_alpha;
cloth.ambient = 50;
set(cloth,SHADOW|CAST);
set(cloth.material,PASS_SOLID); // required for shadow
//ent_clone(cloth); // Prevents, that all clothes move the same way
// attach flag to pole
c_setminmax(pole);
c_setminmax(cloth);
vec_set(cloth.x,vector(
pole.x,
pole.y+(cloth.max_y-cloth.min_y)/2,
pole.z+pole.max_z-(cloth.max_z-cloth.min_z)/2));
// setup flag cloth
var cloth_options[40];
memcpy(cloth_options,CLOTH_DEFAULT,40*sizeof(var));
vec_set(cloth_options[25],vector(-1,-1,0)); // external acceleration
vec_set(cloth_options[28],vector(0,30,0)); // random wind acceleration
cloth_options[9] = 4; // Tear Factor
cloth_options[37] |= NX_CLF_GRAVITY|NX_CLF_BENDING|NX_CLF_COLLISION_TWOWAY|NX_CLF_SELFCOLLISION|NX_CLF_TEARABLE;
pXent_cloth(cloth,pole,NX_CLOTH_ATTACHMENT_TWOWAY,0,0,cloth_options);
}