Gamestudio/A8 Physics

Gamestudio/A8 contains a physics subsystem based on the PhysX™ Engine by nVIDIA, which allows for realistic motion of models. The basic functions support rigid bodies and joints. With additional plugins, deformable bodies, liquids, cloth and many other effects can be supported.

Because this type of simulation is CPU resp. GPU intensive, the physics subsystem is disabled by default. When you wish to use it, include the ackphysx.h header, and call physX_open(). Afterwards you can load a level and register dynamic physics objects for the simulation. This delegates exclusive motion control of those objects to the engine; they can not be moved anymore by changing their position. When you no longer need a physics entity, unregister it or disable the physics system.

Functions Overview

There are 4 function categories dealing with the control of physics objects:
physX_ Global functions that open or close the physics simulator.
pX_ Global functions that change the behavior of the physics simulator or the simulated world
pXent_ Physical entity functions which operate on a single entity at a time
pXcon_ Constraint functions, which limit the movement of physical entities

Include Physics in your Game

The basic steps in setting up a physics entity are:

Example

#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* ball = ent_create(SPHERE_MDL,vector(0,0,100),NULL); pXent_settype (ball,PH_RIGID,PH_SPHERE ); // create a ball pXent_setelasticity(ball,50); pXent_addvelcentral(ball,vector(0,-10,0)); // make it jump and roll sidewards while(1){ pX_pick(); // pick and move the ball with the cursor wait(1); } }

Credits

NVIDIA PhysX, Copyright © 2009 NVIDIA Corporation. All rights reserved. AGEIA PhysX,
Copyright © 2002-2008 AGEIA Technologies, Inc. All rights reserved. NovodeX Physics SDK,
Copyright © 2001-2006 NovodeX. All rights reserved. http://www.NVIDIA.com.
PhysX plugin implementation and documentation by Chris Kahler (Chris3D).

See also:

physX_run, physX_open, physX_load, pXent_settype, pX_setunit, pXent_setmaterial, pXent_movechar, pXcon_setmotor, pXcon_add6djoint, pXcon_add...