////////////////////////////////////////////////////// // PhysX stress test // (c) jcl / oP group 2010 ////////////////////////////////////////////////////// #include <default.c> #include <ackphysX3.h> // 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 pX3ent_settype(my,PH_RIGID,type); pX3ent_setmaterial(my, vector(60, 40, 90), NULL); //pX3ent_setelasticity(my,90); // set random initial speed pX3ent_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); } function cube() { vec_set(my.blue,vector(150+random(100),random(100),0)); actor(PH_BOX); pX3ent_setfriction(my,0); // ice cube } function main() { shadow_stencil = 1; d3d_antialias = 4; max_entities = 3000; physX3_open(); level_load(""); // load empty level vec_set(camera.x,vector(-180,0,30)); // create ground plate ENTITY* ground = ent_create(CUBE_MDL,vector(0,0,0),NULL); vec_set(ground.scale_x,vector(20,20,1)); pX3ent_settype(ground,PH_STATIC,PH_BOX); pX3ent_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); } }
#include <acknex.h> #include <default.c> #include <ackphysX3.h> // Variables // Headers void test_physX3(); // Acknex PhysX3 Character Controller test void main() { test_physX3(); } // Scenequery test void test_physX3() { video_window(NULL, NULL, 0, "PhysX3 CCT Test"); fps_max = 60; // Shadow Stencil shadow_stencil = 4; d3d_antialias = 1; // Create level level_load(NULL); // Position camera vec_set(camera->x, vector(-252, 0, 130)); camera->tilt = -20; // Create ground ENTITY *ground = ent_create("CUBE.MDL", nullvector, NULL); vec_set(ground->scale_x, vector(20, 20, 1)); c_setminmax(ground); // Create entities ENTITY *block1 = ent_create("CUBE.MDL", vector(50, 0, 50), NULL); vec_set(block1->scale_x, vector(2, 2, 2)); set(block1, SHADOW | LIGHT); ENTITY *block2 = ent_create("CUBE.MDL", vector(50, 50, 50), NULL); vec_set(block2->scale_x, vector(2, 2, 2)); set(block2, SHADOW | LIGHT); ENTITY *block3 = ent_create("CUBE.MDL", vector(-50, -50, 60), NULL); vec_set(block3->scale_x, vector(2, 2, 2)); set(block3, SHADOW | LIGHT); // Create sphere ENTITY *sphere = ent_create("SPHERE.MDL", vector(0, -50, 50), NULL); vec_set(sphere->scale_x, vector(5, 5, 5)); c_setminmax(sphere); set(sphere, SHADOW | TRANSLUCENT); sphere->alpha = 5; // Create capsule ENTITY *capsule = ent_create("CUBE.MDL", vector(50, 50, 50), NULL); vec_set(capsule->scale_x, vector(5, 5, 5)); c_setminmax(capsule); set(capsule, SHADOW | TRANSLUCENT); capsule->alpha = 5; // Set gravity pX3_setgravity(vector(0, 0, -9.81)); // Open physX physX3_open(); // Create actors pX3ent_settype(ground, PH_STATIC, PH_BOX); pX3ent_settype(block1, PH_RIGID, PH_CAPSULE); pX3ent_settype(block2, PH_STATIC, PH_BOX); pX3ent_settype(block3, PH_RIGID, PH_BOX); // Spherecheck test var scaResult = pX3_spherecheckany(sphere->x, sphere->max_x, 0, 0, NULL); if (scaResult) { //printf ("%d", (int)scaResult); set(you, TRANSLUCENT); } // Capsulecheck test VECTOR start, end; vec_set(start, capsule->x); vec_sub(start, vector(0, 0, capsule->max_z)); vec_set(end, capsule->x); vec_add(end, vector(0, 0, capsule->max_z)); var ccaResult = pX3_capsulecheckany(start, end, capsule->max_x, 0, 0, NULL); if (ccaResult) { //printf ("%d", (int)ccaResult); set(you, TRANSLUCENT); } #define nbContacts 5 CONTACT scmContacts[nbContacts]; CONTACT ccmContacts[nbContacts]; // SphereCheckMultiple test var scmResult = pX3_spherecheckmultiple(sphere->x, sphere->max_x, 0, 0, scmContacts, nbContacts); if (scmResult) { //printf("%d", (int)scmResult); var i = 0; for (i = 0; i < scmResult; i++) { set(scmContacts[i].entity, TRANSLUCENT); } } // CapsuleCheckMultiple test var ccmResult = pX3_capsulecheckmultiple(start, end, capsule->max_x, 0, 0, ccmContacts, nbContacts); if (ccmResult) { //printf("%d", (int)ccmResult); var i = 0; for (i = 0; i < ccmResult; i++) { set(ccmContacts[i].entity, TRANSLUCENT); } } // App main loop while(1) { // Sphere check multiple var i = 0; for (i = 0; i < scmResult; i++) { draw_point3d(scmContacts[i].x, vector(255, 255, 0), 100, 4); } // capsule check multiple var i = 0; for (i = 0; i < ccmResult; i++) { draw_point3d(ccmContacts[i].x, vector(255, 0, 255), 100, 4); } wait(1); } }
Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy
oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de