Posted By: snake67
PhysX - 01/28/11 03:32
Hi
Nochmals in diesem Forum. Wenn bei PhysX-Modellen die Triggerung mit "pXent_settriggerflag" gesetzt ist, fallen sie durch das Level.
rojart hat die PhysX-Demo "physXtest.c" aus dem Ordner "samples" abgeändert. Bei den Kugeln wird im Gegensatz zu den Würfeln das "pXent_settriggerflag" gesetzt und (nur) sie fallen durch das Level. Hier ist der Code:
Was liegt hier wohl vor?
Nochmals in diesem Forum. Wenn bei PhysX-Modellen die Triggerung mit "pXent_settriggerflag" gesetzt ist, fallen sie durch das Level.
rojart hat die PhysX-Demo "physXtest.c" aus dem Ordner "samples" abgeändert. Bei den Kugeln wird im Gegensatz zu den Würfeln das "pXent_settriggerflag" gesetzt und (nur) sie fallen durch das Level. Hier ist der Code:
Code:
////////////////////////////////////////////////////// // PhysX stress test // (c) jcl / oP group 2010 ////////////////////////////////////////////////////// #include <default.c> #include <ackphysx.h> function EventTrigger() { reset(my,TRANSLUCENT); //to visualize the collision pX_setforcemode(NX_FORCE); pXent_addexplosion(you,my.x,500,my.max_x/2); // you is the entity that collides with the trigger object wait(4); set(my,TRANSLUCENT); vec_set(my.blue,COLOR_BLACK); } // convert entity to a PhysX actor function actor(type) { set(my,LIGHT|CAST); if (num_entities < 250) set(my,SHADOW); // set random size vec_fill(my.scale_x,0.6+random(0.4)); // activate physics pXent_settype(my,PH_RIGID,type); pXent_setelasticity(my,90); pXent_setccdskeleton(me, vector(0.2, 0.2, 0.2), 1); // set random initial speed pXent_addvelcentral(my,vector(1-random(2),1-random(2),0)); // remove entity when fallen over the edge of the ground plate while(1) { if (my.z < 0) { ent_remove(me); return; } wait(1); } } function ball() { my.material = mat_metal; vec_set(my.blue,vector(0,random(100),150+random(100))); actor(PH_SPHERE); pXent_settriggerflag(my, NX_TRIGGER_ON_ENTER , 1); my.event = EventTrigger; } function cube() { vec_set(my.blue,vector(150+random(100),random(100),0)); actor(PH_BOX); pXent_setfriction(my,0); // ice cube } function main() { shadow_stencil = 3; d3d_antialias = 4; max_entities = 3000; physX_open(); pX_setccd(1); level_load(""); // load empty level vec_set(camera.x,vector(-380,0,80)); // create ground plate ENTITY* ground = ent_create(CUBE_MDL,vector(0,0,0),NULL); vec_set(ground.scale_x,vector(20,20,1)); pXent_settype(ground,PH_STATIC,PH_BOX); pXent_setfriction(ground,10); // endlessly create entities while(1){ ent_create(SPHERE_MDL,vector(random(20),random(20),150),ball); if (random(100) > 70) ent_create(CUBE_MDL,vector(random(20),random(20),170),cube); wait(-0.05); } }
Was liegt hier wohl vor?