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. The source code of the PhysX implementation is available as Open Source, so with some C++ knowledge you can implement any additional physics functions.
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.
physX_ | Global functions that open or close the physics simulator. |
pX_ | Global functions that change the behavior of the simulated world |
pXent_ | Physics entity functions that operate on a single entity at a time |
pXcon_ | Constraint functions that limit the movement of physics entities. |
#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); } }
When your game uses PhysX commands, the recent PhysX System Software by nVidia must be installed on the target system. You are also required to include the PhysX logo in press releases and on your splash or credit screens. The standard splash screen already contains the PhysX logo. You can find the detailed deployment requirements in the PhysX EULA.
When you publish a PhysX application, the DLLs ackphysX.dll, PhysXCore.dll, PhysXDevice.dll, PhysXLoader.dll, PhysXCooking.dll, NxCharacter.dll and cudart32_30_9.dll are automatically bound to the project and copied to the .CD folder. For version A8.20 or below, you also need to make sure that the end user has installed the PhysX System Software on her PC. Either provide a link for your users to download it from the nVidia Download Page (http://www.nvidia.com/object/physx_system_software.html). Or - preferably - include it in your installation program, or let your application install it through the exec_wait command. You can silently install the software with the command line option /quiet. Examples for automatic installation:
// installing PhysX from the application folder function main() { if (!physX_open()) { printf("Install PhysX System Software"); exec_wait("PhysX_9.10.0224_SystemSoftware.exe","/quiet"); // insert the recent filename here printf("PhysX System Software installed!\nPlease restart your PC now!"); sys_exit(NULL); } ... // installing PhysX from the nVidia Website function main() { if (!physX_open()) { printf("Install PhysX System Software from the web"); exec("http://www.nvidia.com/object/physx_system_software.html",NULL); printf("After installing, please restart your PC!"); sys_exit(NULL); } ...Installation of the PhysX System Software is not necessary anymore from version A8.30 or above, which uses PhysX version 2.8.4.