Newton Dynamics Engine Documentation Release 3

Oliver Nagy

Sep 18, 2016

Contents

1 Installation 3 1.1 Linux...... 3 1.2 Other Systems...... 4 1.3 Questions/Problems...... 4

2 Tutorials 5 2.1 Compiling And Linking A Trivial Program That Uses Newton...... 5 2.2 Basic Rigid Bodies And Forces...... 6 2.3 Attach Custom Data To A Newton Body...... 8 2.4 Ball Bouncing Off Surface...... 9

3 API Documentation 13 3.1 Misc...... 13 3.2 World...... 13 3.3 GroupID...... 24 3.4 MaterialSetup...... 24 3.5 ContactBehaviour...... 28 3.6 CshapesConvexSimple...... 32 3.7 CshapesConvexComplex...... 40 3.8 CollisionLibraryGeneric...... 46 3.9 TransUtil...... 52 3.10 RigidBodyInterface...... 53 3.11 ConstraintBall...... 68 3.12 JointHinge...... 70 3.13 JointSlider...... 70 3.14 JointCorkscrew...... 72 3.15 JointUniversal...... 74 3.16 JointUpVector...... 76 3.17 JointUser...... 77 3.18 JointCommon...... 80 3.19 SpecialEffectMesh...... 83 3.20 Unclassified...... 88 3.21 Doxygen...... 88

4 Indices and tables 89

i ii Newton Dynamics Engine Documentation, Release 3

The Newton Dynamics engine is a physics engine to simulate life-like physics. More information about its used are available on its homepage. The is available on Github. Contents:

Contents 1 Newton Dynamics Engine Documentation, Release 3

2 Contents CHAPTER 1

Installation

You can build Newton with- or without graphical demos. For the core library (ie no graphical demos) you only need a ++ compiler, CMake, a Git client, and the TinyXML library. The sections below outline the process for the both options.

1.1 Linux

This section assumes Ubuntu 16.04, but the procedure is similar for other Linux flavours. To prove it, here are the Dockerfiles for some of them: • Ubuntu 14.04 • Ubuntu 16.04 • Fedora 22 • Fedora 23

1.1.1 Core Library Only apt-get install build-essential git libtinyxml-dev git clone https://github.com/MADEAPPS/newton-dynamics.git cd newton-dynamics mkdir build&& cd build cmake -DNEWTON_DEMOS_SANDBOX=OFF ..&& make

1.1.2 Library + Demos apt-get install build-essential cmake git libtinyxml-dev apt-get install libwxgtk3.0-dev libfreetype6-dev libopenal-dev libglew-dev git clone https://github.com/MADEAPPS/newton-dynamics.git cd newton-dynamics mkdir build&& cd build cmake -DNEWTON_DEMOS_SANDBOX=ON ..&& make

The demos are all contained in a single executable. To start it from the build directory type:

3 Newton Dynamics Engine Documentation, Release 3

../applications/demosSandbox/demosSandbox

1.2 Other Systems

If you know how to compile and install Newton on any other system please submit a pull request.

1.3 Questions/Problems

• Newton does not compile under latest Fedora 24

4 Chapter 1. Installation CHAPTER 2

Tutorials

This “Starter Kit” is for people who have never used Newton before. The examples are self contained and strive to be as short as possible to demonstrate the feature. Consequently, the examples lack all bells and whistles, including error checks, automated Makefiles, or 3D graphics... you have been warned :)

Note: The tutorials were developed on Kubuntu 16.04, but should run on all platforms supported by Newton.

2.1 Compiling And Linking A Trivial Program That Uses Newton

Purpose: show how to compile a Newton simulation. The simulation creates a Newton world, steps it sixty times, and then destroys the world again. Literally nothing will happen since the world is empty. Here is the code:

1 #include

2 #include "Newton.h"

3

4 5 int main( int argc, const char * argv[]) 6 {

7 // Print the library version.

8 printf("Hello, this is Newton version %\n", NewtonWorldGetVersion());

9

10 // Create the Newton world. 11 NewtonWorld* const world= NewtonCreate(); 12

13 // Step the (empty) world 60 times in increments of 1/60 second.

14 const float timestep= 1.0f/ 60;

15 for(int i=0; i<60; i++){

16 NewtonUpdate(world, timestep);

17 }

18

19 // Clean up.

20 NewtonDestroyAllBodies(world);

21 NewtonDestroy(world);

22

23 return 0;

24 }

5 Newton Dynamics Engine Documentation, Release 3

2.1.1 Linux

If you installed the Newton library into your system the you can compile, link, and run the program with these commands:

1 $ g++ tut0.cpp -o tut0 -lNewton -lpthread

2 $ ./tut0

If you did _not_ install the library and want to use the version from your source and build directory, then you need a longer command:

1 $ g++ tut0.cpp -o tut0 -I ../../coreLibrary_300/source/newton/ -L ../../build/lib/ -

˓→lNewton -lpthread -Wl,"-rpath=../../build/lib/"

2 $ ./tut0

This may look intimidating but is straightforward. The -I ../../coreLibrary_300/source/newton/ flag tells the compiler where to find Newton.h. Similarly, -L ../../build/lib/ tells the linker where to look for additional libraries. The next flag (-lNewton) tells the linker to link our program against the libNewton.so library we built in Installation. Newton uses threads, thus we linke it to -lpthread. Finally, the purpose of -Wl,"-rpath=../../build/lib/" is to bake the location of the Newton library into the executable, or other- wise the runtime linker will probably not find it.

2.1.2 Other

Please submit pull request for instructions.

2.2 Basic Rigid Bodies And Forces

Purpose: create a spherical body, apply a force, and track its motion over time. We are now adding two more functions. The first, addSphereToSimulation creates a sphere in the Newton world and parameterises it (mass, inertia). It also installs the second new function cb_applyForce as a callback. Newton will trigger that callback whenever it moves the body. It will not trigger it if the body is already at rest. Inside the callback we query the state matrix and print the current position. Furthermore, we apply a force along the y axis, which makes the body accelerate in that direction. Since that force is 1N, and the simulation runs for one second, the body must move exactly 0.5 Meters. Here is the code:

1 #include

2 #include "Newton.h"

3

4 5 void cb_applyForce(const NewtonBody* const body, dFloat timestep, int threadIndex) 6 {

7 // Apply a force to the object.

8 dFloat force[3]={0, 1.0,0};

9 NewtonBodySetForce(body, force);

10

11 // Query the state (4x4 matrix) and extract the body's position.

12 float state[16];

13 NewtonBodyGetMatrix(body, state);

14 printf("Time %.3fs: x=%.3f y=%.3f z=%.2f\n",

15 timestep, state[12], state[13], state[14]);

6 Chapter 2. Tutorials Newton Dynamics Engine Documentation, Release 3

16 }

17

18 19 void addSphereToSimulation(NewtonWorld *world) { 20 // fixme: what is this?

21 float foo[16]={

22 1.0f, 0.0f, 0.0f, 0.0f,

23 0.0f, 1.0f, 0.0f, 0.0f,

24 0.0f, 0.0f, 1.0f, 0.0f,

25 0.0f, 0.0f, 0.0f, 1.0f

26 };

27

28 // Create the sphere. Is this radius or diameter? 29 NewtonCollision* const collision= NewtonCreateSphere(world,1,0, NULL); 30

31 // fixme: what is this for? 32 NewtonBody* const body= NewtonCreateDynamicBody(world, collision, foo); 33

34 // fixme: has no doc string. Is this mass, I_xx, I_yy, and I_zz?

35 NewtonBodySetMassMatrix(body, 1.0f,1,1,1);

36

37 // Install callback. Newton will call it whenever the object moves.

38 NewtonBodySetForceAndTorqueCallback(body, cb_applyForce);

39 }

40

41 42 int main( int argc, const char * argv[]) 43 {

44 // Create the Newton world. 45 NewtonWorld* const world= NewtonCreate(); 46

47 // Add the sphere.

48 addSphereToSimulation(world);

49

50 // Step the (empty) world 60 times in increments of 1/60 second.

51 const float timestep= 1.0f/ 60;

52 for(int i=0; i<60; i++){

53 NewtonUpdate(world, timestep);

54 }

55

56 // Clean up.

57 NewtonDestroyAllBodies(world);

58 NewtonDestroy(world);

59

60 return 0;

61 }

2.2.1 Linux

To compile, link, and run the program type:

1 $ g++ tut1.cpp -o tut1 -I ../../coreLibrary_300/source/newton/ -L ../../build/lib/ -

˓→lNewton -lpthread -Wl,"-rpath=../../build/lib/"

2 $ ./tut1

2.2. Basic Rigid Bodies And Forces 7 Newton Dynamics Engine Documentation, Release 3

2.2.2 Other

Please submit pull request for instructions.

2.2.3 Questions/Problems

• What is the third parameter to NewtonCreateDynamicBody? • What is shapeID?

2.3 Attach Custom Data To A Newton Body

Newton provides NewtonBodySetUserData and NewtonBodySetUserData to set and retrieve custom user data, respectively. Their usage is straightforward as the next example illustrates. Here is the code:

1 #include

2 #include "Newton.h"

3

4

5 // Define a custom data structure to store a body ID.

6 struct UserData {

7 int bodyID=0;

8 };

9

10 11 void cb_applyForce(const NewtonBody* const body, dFloat timestep, int threadIndex) 12 {

13 // Request the custom data, print the ID, and increment it. 14 UserData *mydata= (UserData *)NewtonBodyGetUserData(body); 15 printf("BodyID: %d\n", mydata->bodyID++);

16 }

17

18 19 void addSphereToSimulation(NewtonWorld *world) { 20 // fixme: what is this?

21 float foo[16]={

22 1.0f, 0.0f, 0.0f, 0.0f,

23 0.0f, 1.0f, 0.0f, 0.0f,

24 0.0f, 0.0f, 1.0f, 0.0f,

25 0.0f, 0.0f, 0.0f, 1.0f

26 };

27

28 // Create the sphere. Is this radius or diameter? 29 NewtonCollision* const collision= NewtonCreateSphere(world,1,0, NULL); 30

31 // fixme: what is this for? 32 NewtonBody* const body= NewtonCreateDynamicBody(world, collision, foo); 33

34 // fixme: has no doc string. Is this mass, I_xx, I_yy, and I_zz?

35 NewtonBodySetMassMatrix(body, 1.0f,1,1,1);

36

37 // Install callback. Newton will call it whenever the object moves.

38 NewtonBodySetForceAndTorqueCallback(body, cb_applyForce);

39

8 Chapter 2. Tutorials Newton Dynamics Engine Documentation, Release 3

40 // Attach our custom data structure to the body. 41 UserData *myData= new UserData; 42 myData->bodyID=5; 43 NewtonBodySetUserData(body, (void *)myData); 44 }

45

46 47 int main( int argc, const char * argv[]) 48 {

49 // Create the Newton world. 50 NewtonWorld* const world= NewtonCreate(); 51

52 // Add the sphere.

53 addSphereToSimulation(world);

54

55 // Step the (empty) world 60 times in increments of 1/60 second.

56 const float timestep= 1.0f/ 60;

57 for(int i=0; i<5; i++){

58 NewtonUpdate(world, timestep);

59 }

60

61 // Clean up.

62 NewtonDestroyAllBodies(world);

63 NewtonDestroy(world);

64

65 return 0;

66 }

2.3.1 Linux

To compile, link, and run the program type:

1 $ g++ tut_userdata.cpp -o tut_userdata -I ../../coreLibrary_300/source/newton/ -L ../.

˓→./build/lib/ -lNewton -lpthread -Wl,"-rpath=../../build/lib/"

2 $ ./tut_userdata

2.3.2 Other

Please submit pull request for instructions.

2.3.3 Questions/Problems

2.4 Ball Bouncing Off Surface

Purpose: specify the initial position of bodies and let them collide. This simulation creates a sphere 2m above (in y-direction) of a 0.1m thin plane at the origin. The plane is a static body because we do not set its mass (equivalent to setting it to zero in Newton). The ball accelerates downwards (negative y-direction) due to the force we apply in the callback. Here is the code:

2.4. Ball Bouncing Off Surface 9 Newton Dynamics Engine Documentation, Release 3

1 #include

2 #include "Newton.h"

3

4

5 // Define a custom data structure to store a body ID.

6 struct UserData {

7 int bodyID=0;

8 };

9

10 11 void cb_applyForce(const NewtonBody* const body, dFloat timestep, int threadIndex) 12 {

13 // Fetch user data and body position. 14 UserData *mydata= (UserData *)NewtonBodyGetUserData(body); 15 dFloat pos[4];

16 NewtonBodyGetPosition(body, pos);

17

18 // Apply force.

19 dFloat force[3]={0,-1.0,0};

20 NewtonBodySetForce(body, force);

21

22 // Print info to terminal.

23 printf("BodyID=%d, Sleep=%d, %.2f, %.2f, %.2f\n",

24 mydata->bodyID, NewtonBodyGetSleepState(body), pos[0], pos[1], pos[2]);

25 }

26

27 28 void addBodies(NewtonWorld *world) { 29 // Neutral transform matrix.

30 float tm[16]={

31 1.0f, 0.0f, 0.0f, 0.0f,

32 0.0f, 1.0f, 0.0f, 0.0f,

33 0.0f, 0.0f, 1.0f, 0.0f,

34 0.0f, 0.0f, 0.0f, 1.0f

35 };

36

37 // Collision shapes: sphere (our ball), and large box (our ground plane). 38 NewtonCollision* const cs_sphere= NewtonCreateSphere(world,1,0, NULL); 39 NewtonCollision* const cs_ground= NewtonCreateBox(world, 100, 0.1, 100,0, NULL); 40

41 // Create the bodies and assign them the collision shapes. Note that

42 // we need to modify initial transform for the ball to place it a y=2.0 43 NewtonBody* const ground= NewtonCreateDynamicBody(world, cs_ground, tm); 44 tm[13]= 2.0; 45 NewtonBody* const sphere= NewtonCreateDynamicBody(world, cs_sphere, tm); 46

47 // Assign non-zero mass to sphere to make it dynamic.

48 NewtonBodySetMassMatrix(sphere, 1.0f,1,1,1);

49

50 // Install the callbacks to track the body positions.

51 NewtonBodySetForceAndTorqueCallback(sphere, cb_applyForce);

52 NewtonBodySetForceAndTorqueCallback(ground, cb_applyForce);

53

54 // Attach our custom data structure to the bodies. 55 UserData *myData= new UserData[2]; 56 myData[0].bodyID=0;

57 myData[1].bodyID=1; 58 NewtonBodySetUserData(sphere, (void *)&myData[0]);

10 Chapter 2. Tutorials Newton Dynamics Engine Documentation, Release 3

59 NewtonBodySetUserData(ground, (void *)&myData[1]); 60 }

61

62 63 int main( int argc, const char * argv[]) 64 {

65 // Create the Newton world. 66 NewtonWorld* const world= NewtonCreate(); 67

68 // Add the bodies.

69 addBodies(world);

70

71 // Step the simulation.

72 const float timestep= 1.0f/ 60;

73 for(int i=0; i<300; i++){

74 NewtonUpdate(world, timestep);

75 }

76

77 // Clean up.

78 NewtonDestroyAllBodies(world);

79 NewtonDestroy(world);

80

81 return 0;

82 }

2.4.1 Linux

To compile, link, and run the program type:

1 $ g++ tut_bouncing_ball.cpp -o tut_bouncing_ball -I ../../coreLibrary_300/source/

˓→newton/ -L ../../build/lib/ -lNewton -lpthread -Wl,"-rpath=../../build/lib/"

2 $ ./tut_bouncing_ball

2.4.2 Other Platform

Please submit pull request for instructions.

2.4.3 Result

The left figure graphs the y position of the ball and ground. As expected, the ball drops, bounces off the ground, and eventually comes to rest. Note that the rest position is 1.1m because the ball radius is 1m and the thickness of the ground is 0.1m. The right figure shows the sleeping attribute for each body as returned by NewtonBodyGetSleepState. Newton puts the static body immediately to rest because it is, well, static. The ball, on the other hand, stays active until it has come to rest on the surface.

2.4. Ball Bouncing Off Surface 11 Newton Dynamics Engine Documentation, Release 3

2.4.4 Questions/Problems

12 Chapter 2. Tutorials CHAPTER 3

API Documentation

API functions by group.

3.1 Misc

int NewtonGetMemoryUsed() Return the exact amount of memory use by the engine and any given time time. this function is useful for application to determine if the memory use by the engine is balanced at all time. Return memory use by the engine. See also: NewtonCreate void NewtonSetMemorySystem(NewtonAllocMemory mallocFnt, NewtonFreeMemory mfreeFnt) void *NewtonAlloc(int sizeInBytes) void NewtonFree(void *const ptr)

3.2 World

NewtonWorld *NewtonCreate() Create an instance of the Newton world. this function must be called before any of the other API functions. Return pointer to an instance of the Newton world. See also: NewtonDestroy, NewtonDestroyAllBodies void NewtonDestroy(const NewtonWorld *const newtonWorld) Destroy an instance of the Newton world. This function will destroy the entire Newton world. Return . Parameters • *newtonWorld : pointer to the Newton world. See also: NewtonCreate, NewtonDestroyAllBodies int NewtonGetBroadphaseAlgorithm(const NewtonWorld *const newtonWorld) void NewtonSelectBroadphaseAlgorithm(const NewtonWorld *const newtonWorld, int algorithm- Type) dFloat NewtonGetContactMergeTolerance(const NewtonWorld *const newtonWorld)

13 Newton Dynamics Engine Documentation, Release 3 void NewtonSetContactMergeTolerance(const NewtonWorld *const newtonWorld, dFloat toler- ance) void NewtonInvalidateCache(const NewtonWorld *const newtonWorld) Reset all internal states of the engine. When an application wants to reset the state of all the objects in the world to a predefined initial condition, just setting the initial position and velocity is not sufficient to reproduce equal runs since the engine maintain there are internal states that in order to take advantage of frame to frame coherence. In this cases this function will reset all of the internal states. Parameters • *newtonWorld : is the pointer to the Newton world. This function must be call outside of a Newton Update. this function should only be used for special case of synchronization, using it as part of the simulation loop will severally affect the engine performance.See also: NewtonUpdate void NewtonSetJointSerializationCallbacks(const NewtonWorld *const newtonWorld, NewtonOnJointSerializationCallback serialize- Joint, NewtonOnJointDeserializationCallback deserializeJoint) void NewtonGetJointSerializationCallbacks(const NewtonWorld *const newtonWorld, NewtonOnJointSerializationCallback *const seri- alizeJoint, NewtonOnJointDeserializationCallback *const deserializeJoint) void NewtonSerializeToFile(const NewtonWorld *const newtonWorld, const char *const file- name, NewtonOnBodySerializationCallback bodyCallback, void *const bodyUserData) void NewtonDeserializeFromFile(const NewtonWorld *const newtonWorld, const char *const file- name, NewtonOnBodyDeserializationCallback bodyCallback, void *const bodyUserData) int NewtonGetCurrentDevice(const NewtonWorld *const newtonWorld) int NewtonEnumerateDevices(const NewtonWorld *const newtonWorld) void NewtonSetCurrentDevice(const NewtonWorld *const newtonWorld, int deviceIndex) void NewtonGetDeviceString(const NewtonWorld *const newtonWorld, int deviceIndex, char *const vendorString, int maxSize) void NewtonWorldCriticalSectionLock(const NewtonWorld *const newtonWorld, int threadIndex) this function block all other threads from executing the same subsequent code simultaneously. this function should use to present racing conditions when when a call back ins executed form a mutithreaded loop. In general most call back are thread safe when they do not write to object outside the scope of the call back. this means for example that the application can modify values of object pointed by the arguments and or call that function that are allowed to be call for such callback. There are cases, however, when the application need to collect data for the client logic, example of such case are collecting information to display debug information, of collecting data for feedback. In these situations it is possible the the same critical code could be execute at the same time but several thread causing unpredictable side effect. so it is necessary to block all of the thread from executing any pieces of critical code. Parameters • *newtonWorld : is the pointer to the Newton world. • threadIndex : thread index from whe thsi function is called, zero if call form outsize a newton update

14 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

Not calling function NewtonWorldCriticalSectionUnlock will result on the engine going into an infinite loop.it is important that the critical section wrapped by functions NewtonWorldCriticalSectionLock and NewtonWorld- CriticalSectionUnlock* be keep small if the application is using the multi threaded functionality of the engine no doing so will lead to serialization of the parallel treads since only one thread can run the a critical section at a time. See also: NewtonWorldCriticalSectionUnlock Return . int NewtonAtomicSwap(int *const ptr, int value) int NewtonAtomicAdd(int *const ptr, int value) void NewtonYield() void NewtonWorldCriticalSectionUnlock(const NewtonWorld *const newtonWorld) this function block all other threads from executing the same subsequent code simultaneously. this function should use to present racing conditions when when a call back ins executed form a mutithreaded loop. In general most call back are thread safe when they do not write to object outside the scope of the call back. this means for example that the application can modify values of object pointed by the arguments and or call that function that are allowed to be call for such callback. There are cases, however, when the application need to collect data for the client logic, example of such case are collecting information to display debug information, of collecting data for feedback. In these situations it is possible the the same critical code could be execute at the same time but several thread causing unpredictable side effect. so it is necessary to block all of the thread from executing any pieces of critical code. Parameters • *newtonWorld : is the pointer to the Newton world. it is important that the critical section wrapped by functions NewtonWorldCriticalSectionLock and Newton- WorldCriticalSectionUnlock* be keep small if the application is using the multi threaded functionality of the engine no doing so will lead to serialization of the parallel treads since only one thread can run the a critical section at a time. See also: NewtonWorldCriticalSectionLock Return . void NewtonSetThreadsCount(const NewtonWorld *const newtonWorld, int threads) Set the maximum number of thread the engine is allowed to use by the application. The maximum number of threaded is set on initialization to the maximum number of CPU in the system. Return Parameters • *newtonWorld : is the pointer to the Newton world • threads : max number of threaded allowed The engine will only allow a maximum number of thread equal are lower to the maximum number of cores visible in the system. if threads is set to a value larger that then number of logical CPUs in the system, the threads will be clamped to the number of logical CPUs.the function is only only have effect on the multi core version of the engine.See also: NewtonGetThreadsCount int NewtonGetThreadsCount(const NewtonWorld *const newtonWorld) Get the total number of thread running in the engine. The maximum number of threaded is set on initialization to the maximum number of CPU in the system. Return threads Parameters • *newtonWorld : is the pointer to the Newton world

3.2. World 15 Newton Dynamics Engine Documentation, Release 3

the function will always return 1 on the none multi core version of the library..See also: NewtonSetThread- sCount, NewtonSetMultiThreadSolverOnSingleIsland int NewtonGetMaxThreadsCount(const NewtonWorld *const newtonWorld) Get the maximu number of thread abialble. The maximum number of threaded is set on initialization to the maximum number of CPU in the system. Return threads Parameters • *newtonWorld : is the pointer to the Newton world the function will always return 1 on the none multi core version of the library..See also: NewtonSetThread- sCount, NewtonSetMultiThreadSolverOnSingleIsland void NewtonSetMultiThreadSolverOnSingleIsland(const NewtonWorld *const newtonWorld, int mode) Enable or disable solver to resolve constraint forces in multi threaded mode when large island configurations. Mode is disabled by default. When running in multi threaded mode it is not always faster to calculate constraint forces in parallel. there reasons for this are: 1 - there is a significant software cost for setting threads both in memory and instructions overhead. 2 - different systems have different cost for running separate threads in a share memory environment 3 - numerical algorithms have decreased converge rate when implemented in parallel, typical lost of converge can be as high as half of the of the sequential version, for this reason the parallel version require higher number of interaction to achieve similar convergence. Return Parameters • *newtonWorld : is the pointer to the Newton world • mode : solver mode 1 enable parallel mode 0 disable parallel mode, default It is recommended this option is enabled on system with more than two cores, since the performance gain in a dual core system are marginally better. at the very list the application must test the option to verify the performance gains.disabling or enabling this option have not impact on the execution of the any of the other subsystems of the engine.See also: NewtonGetThreadsCount, NewtonSetThreadsCount void NewtonDispachThreadJob(const NewtonWorld *const newtonWorld, NewtonJobTask task, void *const usedData) void NewtonSyncThreadJobs(const NewtonWorld *const newtonWorld) int NewtonGetMultiThreadSolverOnSingleIsland(const NewtonWorld *const newtonWorld) void NewtonSetSolverModel(const NewtonWorld *const newtonWorld, int model) Set the solver precision mode. This function allows the application to configure the Newton solver to work in three different modes. Return Parameters • *newtonWorld : is the pointer to the Newton world • model : model of operation 0 = exact, 1 = adaptive, n = linear. The default is adaptive. 0: Is the exact mode. This is good for application where precision is more important than speed, ex: realistic simulation.1 (default): Is the adaptive mode, the solver is not as exact but the simulation will still maintain a high degree of accuracy. This mode is good for applications were a good degree of stability is important but not as important as speed.n: Linear mode. The solver will not try to reduce the joints relative acceleration errors to below some limit, instead it will perform up to n passes over the joint configuration each time reducing the ac- celeration error, but it will terminate when the number of passes is exhausted regardless of the error magnitude.

16 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

In general this is the fastest mode and is is good for applications where speed is the only important factor, ex: video games.the adaptive friction model combined with the linear model make for the fastest possible configu- ration of the Newton solver. This setup is best for games. If you need the best realistic behavior, we recommend the use of the exact solver and exact friction model which are the defaults.See also: NewtonSetFrictionModel void NewtonSetSolverConvergenceQuality(const NewtonWorld *const newtonWorld, int lowOrHigh) lowOrHigh = 0 the solver is controlled by high acceleration limit lowOrHigh different than zero the solver controlled by low acceleration limit void NewtonSetFrictionModel(const NewtonWorld *const newtonWorld, int model) Set coulomb model of friction. This function allows the application to chose between and exact or an adaptive coulomb friction model Return . Parameters • *newtonWorld : is the pointer to the Newton world • model : friction model; 0 = exact coulomb, 1 = adaptive coulomb, The default is exact. 0: Is the exact model. Friction forces are calculated in each frame. This model is good for applications where precision is more important than speed, ex: realistic simulation.1: Is the adaptive model. Here values from previous frames are used to determine the maximum friction values of the current frame. This is about 10% faster than the exact model however it may introduce strange friction behaviors. For example a bouncing object tumbling down a ramp will act as a friction less object because the contacts do not have continuity. In general each time a new contact is generated the friction value is zero, only if the contact persist a non zero friction values is used. The second effect is that if a normal force is very strong, and if the contact is suddenly destroyed, a very strong friction force will be generated at the contact point making the object react in a non-familiar way.the adaptive friction model combined with the linear model make for the fastest possible configuration of the Newton solver. This setup is best for games. If you need the best realistic behavior, we recommend the use of the exact solver and exact friction model which are the defaults.See also: NewtonSetSolverModel void NewtonUpdate(const NewtonWorld *const newtonWorld, dFloat timestep) Advance the simulation by an amount of time. This function will advance the simulation by the amount of time specified by timestep. The Newton Engine does not perform sub-steps, and does not need tuning parameters. It is the responsibility of the application to ensure that timestep is small enough to guarantee physics stability. Return Parameters • *newtonWorld : is the pointer to the Newton world • timestep : time step in seconds See also: NewtonInvalidateCache Return function call NewtonCollisionUpdate at the lower level to get the colliding contacts. fixme: is this true? there is no such function. void NewtonUpdateAsync(const NewtonWorld *const newtonWorld, dFloat timestep) void NewtonWaitForUpdateToFinish(const NewtonWorld *const newtonWorld) void NewtonSetMinimumFrameRate(const NewtonWorld *const newtonWorld, dFloat frameRate) Set the minimum frame rate at which the simulation can run. the default minimum frame rate of the simulation is 60 frame per second. When the simulation falls below the specified minimum frame, Newton will perform sub steps in order to meet the desired minimum FPS. Return Parameters

3.2. World 17 Newton Dynamics Engine Documentation, Release 3

• *newtonWorld : is the pointer to the Newton world • frameRate : minimum frame rate of the simulation in frame per second. This value is clamped between 60fps and 1000fps void NewtonDestroyAllBodies(const NewtonWorld *const newtonWorld) Remove all bodies and joints from the newton world. This function will destroy all bodies and all joints in the Newton world, but it will retain group IDs. Use this function for when you want to clear the world but preserve all the group IDs and material pairs. Return Parameters • *newtonWorld : is a pointer to the Newton world See also: NewtonMaterialDestroyAllGroupID void NewtonSetIslandUpdateEvent(const NewtonWorld *const newtonWorld, NewtonIslandUpdate islandUpdate) Set a function callback to be call on each island update. The application can set a function callback to be called just after the array of all bodies making an island of articulated and colliding bodies are collected for resolution. This function will be called just before the array is accepted for solution and integration. The function callback may return one to validate the array or zero to skip the resolution of this array of bodies on this frame only. This functionality can be used by the application to implement in game physics LOD. For example the application can determine the AABB of the island and check against the view frustum, if the entire island AABB is invisible then the application can suspend simulation even if they are not in equilibrium. another functionality is the implementation of visual debuggers, and also the implementation of auto frozen bodies under arbitrary condition set by the logic of the application. Return . Parameters • *newtonWorld : is the pointer to the Newton world • islandUpdate : application defined callback The application should not modify the position, velocity, or it create or destroy any body or joint during this function call. Doing so will result in unpredictable malfunctions.See also: NewtonIslandGetBody NewtonBody *NewtonWorldGetFirstBody(const NewtonWorld *const newtonWorld) get th first body in the body in the world body list. The application can call this function to iterate thought every body in the world. Return Parameters • *newtonWorld : is the pointer to the Newton world. The application call this function for debugging purpose See also: NewtonWorldGetNextBody, NewtonWorld- ForEachBodyInAABBDo, NewtonWorldForEachJointDo NewtonBody *NewtonWorldGetNextBody(const NewtonWorld *const newtonWorld, const NewtonBody *const curBody) get the fixt body in the general body. The application can call this function to iterate thought every body in the world. Return Parameters • *newtonWorld : is the pointer to the Newton world.

18 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• curBody : fixme The application call this function for debugging purpose See also: NewtonWorldGetFirstBody, NewtonWorld- ForEachBodyInAABBDo, NewtonWorldForEachJointDo void NewtonWorldForEachJointDo(const NewtonWorld *const newtonWorld, NewtonJointIterator callback, void *const userData) Iterate thought every joint in the world calling the function callback. The application can call this function to iterate thought every joint in the world. the application should provide the function NewtonJointIterator callback to be called by Newton for every joint in the world Return Parameters • *newtonWorld : is the pointer to the Newton world. • callback : application define callback • *userData : pointer to the user defined user data value. this function affect severally the performance of Newton. The application should call this function only for de- bugging or for serialization purposes.See also: NewtonWorldForEachBodyInAABBDo, NewtonWorldGetFirst- Body void NewtonWorldForEachBodyInAABBDo(const NewtonWorld *const newtonWorld, const dFloat *const p0, const dFloat *const p1, NewtonBodyIterator callback, void *const userData) Iterate thought every body in the world that intersect the AABB calling the function callback. The application can call this function to iterate thought every body in the world. the application should provide the function NewtonBodyIterator callback to be called by Newton for every body in the world Return Parameters • *newtonWorld : is the pointer to the Newton world. • *p0 : - pointer to an array of at least three floats to hold minimum value for the AABB. • *p1 : - pointer to an array of at least three floats to hold maximum value for the AABB. • callback : application defined callback • *userData : pointer to the user defined user data value. For relatively small AABB volumes this function is much more inefficients that NewtonWorldGetFirstBody, however in case where the AABB contain must of the objects in the scene, the overhead of scanning the internal Broad face collision plus the AABB test make this function more expensive.See also: NewtonWorldGetFirst- Body int NewtonWorldGetVersion() Return the current library version number. Return decimal three digit value x.xx the first digit: is mayor version number (interface changes among other things) the second digit: is mayor patch number (new features, and bug fixes) third digit: is minor bug fixed patch. int NewtonWorldFloatSize() Return the current sizeof of float value in bytes. Return of float value in bytes

3.2. World 19 Newton Dynamics Engine Documentation, Release 3

void NewtonWorldSetUserData(const NewtonWorld *const newtonWorld, void *const userData) Store a user defined data value with the world. The application can store a user defined value with the Newton world. The user data is useful for application developing object oriented classes based on the Newton API. Return . Parameters • *newtonWorld : is the pointer to the newton world. • *userData : pointer to the user defined user data value. See also: NewtonWorldGetUserData void *NewtonWorldGetUserData(const NewtonWorld *const newtonWorld) Retrieve a user previously stored user define value with the world. The application can store a user defined value with the Newton world. The user data is useful for application developing object oriented classes based on the Newton API. Return data value. Parameters • *newtonWorld : is the pointer to the Newton world. See also: NewtonWorldSetDestructorCallback, NewtonWorldGetUserData void NewtonWorldSetDestructorCallback(const NewtonWorld *const newtonWorld, Newton- WorldDestructorCallback destructor) set a function pointer as destructor call back. The application can store a user defined destructor call back function to be called at the time the world is to be destroyed Parameters • *newtonWorld : is the pointer to the Newton world. • destructor : function poiter callback See also: NewtonWorldGetUserData NewtonWorldDestructorCallback NewtonWorldGetDestructorCallback(const NewtonWorld *const newtonWorld) Return the function call back Pointer. The application can store a user defined destructor call back function to be called at the time the world is to be destroyed Parameters • *newtonWorld : is the pointer to the Newton world. See also: NewtonWorldGetUserData, NewtonWorldSetDestructorCallback void NewtonWorldSetCollisionConstructorDestructorCallback(const NewtonWorld *const newtonWorld, NewtonCollisionCopy- ConstructionCallback constructor, NewtonCol- lisionDestructorCallback destructor) void *NewtonWorldGetListenerUserData(const NewtonWorld *const newtonWorld, void *const lis- tener)

20 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

NewtonWorldListenerBodyDestroyCallback NewtonWorldListenerGetBodyDestroyCallback(const New- ton- World *const new- ton- World, void *const lis- tener) void NewtonWorldListenerSetBodyDestroyCallback(const NewtonWorld *const newtonWorld, void *const listener, NewtonWorldLis- tenerBodyDestroyCallback bodyDestroy- Callback) void *NewtonWorldAddPreListener(const NewtonWorld *const newtonWorld, const char *const nameId, void *const listenerUserData, NewtonWorldUpdateLis- tenerCallback update, NewtonWorldDestroyListenerCallback de- stroy) void *NewtonWorldGetPreListener(const NewtonWorld *const newtonWorld, const char *const nameId) void *NewtonWorldAddPostListener(const NewtonWorld *const newtonWorld, const char *const nameId, void *const listenerUserData, NewtonWorldUp- dateListenerCallback update, NewtonWorldDestroyListener- Callback destroy) void *NewtonWorldGetPostListener(const NewtonWorld *const newtonWorld, const char *const nameId) int NewtonWorldGetBodyCount(const NewtonWorld *const newtonWorld) return the total number of rigid bodies in the world. Return of rigid bodies in this world. Parameters • *newtonWorld : is the pointer to the Newton world int NewtonWorldGetConstraintCount(const NewtonWorld *const newtonWorld) return the total number of constraints in the world. this function will return the total number of joint including contacts Parameters • *newtonWorld : is the pointer to the Newton world

Return of rigid bodies in this world. void NewtonWorldRayCast(const NewtonWorld *const newtonWorld, const dFloat *const p0, const dFloat *const p1, NewtonWorldRayFilterCallback filter, void *const user- Data, NewtonWorldRayPrefilterCallback prefilter, int threadIndex) Shoot a ray from p0 to p1 and call the application callback with each ray intersection. The ray cast function will call the application with each body intersecting the line segment. By writing the callback filter function in different ways the application can implement different flavors of ray casting. For example an all body ray cast can be easily implemented by having the filter function always returning 1.0, and copying each rigid body into an array of pointers; a closest hit ray cast can be implemented by saving the body with the smaller intersection

3.2. World 21 Newton Dynamics Engine Documentation, Release 3

parameter and returning the parameter t; and a report the first body hit can be implemented by having the filter function returning zero after the first call and saving the pointer to the rigid body. Return Parameters • *newtonWorld : is the pointer to the world. • *p0 : - pointer to an array of at least three floats containing the beginning of the ray in global space. • *p1 : - pointer to an array of at least three floats containing the end of the ray in global space. • filter : user define function to be called for each body hit during the ray scan. • *userData : user data to be passed to the filter callback. • prefilter : user define function to be called for each body before intersection. • threadIndex : thread index from whe thsi function is called, zero if call form outsize a newton update The most common use for the ray cast function is the closest body hit, In this case it is important, for performance reasons, that the filter function returns the intersection parameter. If the filter function returns a value of zero the ray cast will terminate immediately.if prefilter is not NULL, Newton will call the application right before executing the intersections between the ray and the primitive. if the function returns zero the Newton will not ray cast the primitive. passing a NULL pointer will ray cast the. The application can use this implement faster or smarter filters when implementing complex logic, otherwise for normal all ray cast this parameter could be NULL.The ray cast function is provided as an utility function, this means that even thought the function is very high performance by function standards, it can not by batched and therefore it can not be an incremental function. For example the cost of calling 1000 ray cast is 1000 times the cost of calling one ray cast. This is much different than the collision system where the cost of calculating collision for 1000 pairs in much, much less that the 1000 times the cost of one pair. Therefore this function must be used with care, as excessive use of it can degrade performance.See also: NewtonWorldConvexCast int NewtonWorldConvexCast(const NewtonWorld *const newtonWorld, const dFloat *const matrix, const dFloat *const target, const NewtonCollision *const shape, dFloat *const param, void *const userData, NewtonWorldRayPrefilterCallback prefilter, NewtonWorldConvexCastReturnInfo *const info, int maxCon- tactsCount, int threadIndex) cast a simple convex shape along the ray that goes for the matrix position to the destination and get the firsts contacts of collision. passing and value of NULL in info an dzero in maxContactsCount will turn thos function into a spcial Ray cast where the function will only calculate the hitParam at the momenet of contacts. tshi si one of the most effiecnet way to use thsio function. Return number of contact at the intesection point (a value equal o lower than maxContactsCount. variable hitParam will be set the uintesation parameter an the momen of impact. Parameters • *newtonWorld : is the pointer to the world. • *matrix : pointer to an array of at least three floats containing the beginning and orienetaion of the shape in global space. • *target : pointer to an array of at least three floats containing the end of the ray in global space. • shape : collision shap[e use to cat the ray. • param : pointe to a variable the will contart the time to closet aproah to the collision. • *userData : user data to be passed to the prefilter callback. • prefilter : user define function to be called for each body before intersection.

22 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• *info : pointer to an array of contacts at the point of intesections. • maxContactsCount : maximun number of contacts to be conclaculated, the variable sould be initialized to the capaciaty of info • threadIndex : thread index from whe thsi function is called, zero if call form outsize a newton update these function is similar to NewtonWorldRayCast but instead of casting a point it cast a simple convex shape along a ray for maoprix.m_poit to target position. the shape is global orientation and position is set to matrix and then is swept along the segment to target and it will stop at the very first intersession contact.for case where the application need to cast solid short to medium rays, it is better to use this function instead of casting and array of parallel rays segments. examples of these are: implementation of ray cast cars with cylindrical tires, foot placement of character controllers, kinematic motion of objects, user controlled continuous collision, etc. this function may not be as efficient as sampling ray for long segment, for these cases try using parallel ray cast.The most common use for the ray cast function is the closest body hit, In this case it is important, for performance reasons, that the filter function returns the intersection parameter. If the filter function returns a value of zero the ray cast will terminate immediately.if prefilter is not NULL, Newton will call the application right before executing the intersections between the ray and the primitive. if the function returns zero the Newton will not ray cast the primitive. The application can use this callback to implement faster or smarter filters when implementing complex logic, otherwise for normal all ray cast this parameter could be NULL.See also: NewtonWorldRayCast int NewtonWorldCollide(const NewtonWorld *const newtonWorld, const dFloat *const matrix, const NewtonCollision *const shape, void *const userData, NewtonWorldRayPre- filterCallback prefilter, NewtonWorldConvexCastReturnInfo *const info, int maxContactsCount, int threadIndex) NewtonBody *NewtonIslandGetBody(const void *const island, int bodyIndex) Get the body indexed by bodyIndex form and island. This function can only be called from an island update callback. Return at location bodtIndex. Parameters • *island : is the pointer to current island • bodyIndex : index to the body in current island The application can set a function callback to be called just after the array of all bodies making an island of connected bodies are collected. This function will be called just before the array is accepted for solution and integration. The function callback may return one to validate the array of zero to freeze it. This functionality can be used by the application to implement in game physics LOD. For example the application can determine the AABB of the island and check against the view frustum, if the entire island AABB is invisible then the application can suspend simulation even if they are not in equilibrium. another functionality is the implementa- tion of visual debuggers, and also the implementation of auto frozen bodies under arbitrary condition set by the logic of the application.The application should not modify any parameter of the origin body when the callback is called, nor it should create or destroy any body or joint. Do so will result in unpredictable malfunction.See also: NewtonSetIslandUpdateEvent void NewtonIslandGetBodyAABB(const void *const island, int bodyIndex, dFloat *const p0, dFloat *const p1) Return the AABB of the body on this island This function can only be called from an island update callback. Parameters • island : is the pointer to current island • bodyIndex : index to the body in current island • p0 : - fixme

3.2. World 23 Newton Dynamics Engine Documentation, Release 3

• p1 : - fixme The application can set a function callback to be called just after the array of all bodies making an island of connected bodies are collected. This function will be called just before the array is accepted for solution and integration. The function callback may return one to validate the array of zero to freeze it. This functionality can be used by the application to implement in game physics LOD. For example the application can determine the AABB of the island and check against the view frustum, if the entire island AABB is invisible then the application can suspend simulation even if they are not in equilibrium. another functionality is the implementa- tion of visual debuggers, and also the implementation of auto frozen bodies under arbitrary condition set by the logic of the application.The application should not modify any parameter of the origin body when the callback is called, nor it should create or destroy any body or joint. Do so will result in unpredictable malfunction.See also: NewtonSetIslandUpdateEvent

3.3 GroupID int NewtonMaterialGetDefaultGroupID(const NewtonWorld *const newtonWorld) Get the value of the default MaterialGroupID. Group IDs can be interpreted as the nodes of a dense graph. The edges of the graph are the physics materials. When the Newton world is created, the default Group ID is created by the engine. When bodies are created the application assigns a group ID to the body. Return ID number for the default Group ID. Parameters • *newtonWorld : is the pointer to the Newton world int NewtonMaterialCreateGroupID(const NewtonWorld *const newtonWorld) Create a new MaterialGroupID. Group IDs can be interpreted as the nodes of a dense graph. The edges of the graph are the physics materials. When the Newton world is created, the default Group ID is created by the engine. When bodies are created the application assigns a group ID to the body. Return ID of a new GroupID. Parameters • *newtonWorld : is the pointer to the Newton world Note: The only way to destroy a Group ID after its creation is by destroying all the bodies and calling the function NewtonMaterialDestroyAllGroupID.See also: NewtonMaterialDestroyAllGroupID void NewtonMaterialDestroyAllGroupID(const NewtonWorld *const newtonWorld) Remove all groups ID from the Newton world. This function removes all groups ID from the Newton world. This function must be called after there are no more rigid bodies in the word. Return . Parameters • *newtonWorld : is the pointer to the Newton world See also: NewtonDestroyAllBodies

3.4 MaterialSetup

void NewtonMaterialSetDefaultCollidable(const NewtonWorld *const newtonWorld, int id0, int id1, int state) Set the material interaction between two physics materials to be collidable or non-collidable by default.

24 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

Return . Parameters • *newtonWorld : is the pointer to the Newton world • id0 : - group id0 • id1 : - group id1 • state : state for this material: 1 = collidable; 0 = non collidable void NewtonMaterialSetSurfaceThickness(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat thickness) Set an imaginary thickness between the collision geometry of two colliding bodies whose physics properties are defined by this material pair when two bodies collide the engine resolve contact inter penetration by applying a small restoring velocity at each contact point. By default this restoring velocity will stop when the two contacts are at zero inter penetration distance. However by setting a non zero thickness the restoring velocity will continue separating the contacts until the distance between the two point of the collision geometry is equal to the surface thickness. Return . Parameters • *newtonWorld : is the pointer to the Newton world • id0 : - group id0 • id1 : - group id1 • thickness : material thickness a value form 0.0 to 0.125; the default surface value is 0.0 Surfaces thickness can improve the behaviors of rolling objects on flat surfaces.Surface thickness does not alter the performance of contact calculation. void NewtonMaterialSetDefaultFriction(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat staticFriction, dFloat kineticFriction) Set the default coefficients of friction for the material interaction between two physics materials . staticFriction* and kineticFriction must be positive values. kineticFriction must be lower than staticFriction. It is recommended that staticFriction and kineticFriction be set to a value lower or equal to 1.0, however because some synthetic materials can have higher than one coefficient of friction Newton allows for the coefficient of friction to be as high as 2.0. Return . Parameters • *newtonWorld : is the pointer to the Newton world • id0 : - group id0 • id1 : - group id1 • staticFriction : static friction coefficients • kineticFriction : dynamic coefficient of friction void NewtonMaterialSetDefaultElasticity(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat elasticCoef ) Set the default coefficients of restitution (elasticity) for the material interaction between two physics materials . elasticCoef* must be a positive value. It is recommended that elasticCoef be set to a value lower or equal to 1.0 Return . Parameters

3.4. MaterialSetup 25 Newton Dynamics Engine Documentation, Release 3

• *newtonWorld : is the pointer to the Newton world • id0 : - group id0 • id1 : - group id1 • elasticCoef : static friction coefficients void NewtonMaterialSetDefaultSoftness(const NewtonWorld *const newtonWorld, int id0, int id1, dFloat softnessCoef ) Set the default softness coefficients for the material interaction between two physics materials . softnessCoef* must be a positive value. It is recommended that softnessCoef be set to value lower or equal to 1.0 A low value for softnessCoef will make the material soft. A typical value for softnessCoef is 0.15 Return . Parameters • *newtonWorld : is the pointer to the Newton world • id0 : - group id0 • id1 : - group id1 • softnessCoef : softness coefficient void NewtonMaterialSetCallbackUserData(const NewtonWorld *const newtonWorld, int id0, int id1, void *const userData) void NewtonMaterialSetCollisionCallback(const NewtonWorld *const newtonWorld, int id0, int id1, NewtonOnAABBOverlap aabbOverlap, New- tonContactsProcess processCallback) Set userData and the functions event handlers for the material interaction between two physics materials . When the AABB extend of the collision geometry of two bodies overlap, Newton collision system retrieves the material interaction that defines the behavior between the pair of bodies. The material interaction is collected from a database of materials, indexed by the material gruopID assigned to the bodies. If the material is tagged as non collidable, then no action is taken and the simulation continues. If the material is tagged as collidable, and a aabbOverlap was set for this material, then the aabbOverlap function is called. If the function aabbOverlap returns 0, no further action is taken for this material (this can be use to ignore the interaction under certain conditions). If the function aabbOverlap returns 1, Newton proceeds to calculate the array of contacts for the pair of colliding bodies. If the function processCallback was set, the application receives a callback for every contact found between the two colliding bodies. Here the application can perform fine grain control over the behavior of the collision system. For example, rejecting the contact, making the contact frictionless, applying special effects to the surface etc. After all contacts are processed and if the function endCallback was set, Newton calls endCallback. Here the application can collect information gathered during the contact-processing phase and provide some feedback to the player. A typical use for the material callback is to play sound effects. The application passes the address of structure in the userData along with three event function callbacks. When the function aabbOverlap is called by Newton, the application resets a variable say maximumImpactSpeed. Then for every call to the function processCallback, the application compares the impact speed for this contact with the value of maximumImpactSpeed*, if the value is larger, then the application stores the new value along with the position, and any other quantity desired. When the application receives the call to endCallback the application plays a 3d sound based in the position and strength of the contact. Return . Parameters • *newtonWorld : is the pointer to the Newton world. • id0 : - group id0. • id1 : - group id1.

26 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• *aabbOverlap : address of the event function called when the AABB of tow bodyes overlap. This parameter can be NULL. • *processCallback : address of the event function called for every contact resulting from contact calculation. This parameter can be NULL. void NewtonMaterialSetContactGenerationCallback(const NewtonWorld *const newtonWorld, int id0, int id1, NewtonOnContactGener- ation contactGeneration) void NewtonMaterialSetCompoundCollisionCallback(const NewtonWorld *const newton- World, int id0, int id1, NewtonOn- CompoundSubCollisionAABBOverlap compoundAabbOverlap) Set userData and the functions event handlers for the material interaction between two physics materials . When the AABB extend of the collision geometry of two bodies overlap, Newton collision system retrieves the material interaction that defines the behavior between the pair of bodies. The material interaction is collected from a database of materials, indexed by the material gruopID assigned to the bodies. If the material is tagged as non collidable, then no action is taken and the simulation continues. If the material is tagged as collidable, and a aabbOverlap was set for this material, then the aabbOverlap function is called. If the function aabbOverlap returns 0, no further action is taken for this material (this can be use to ignore the interaction under certain conditions). If the function aabbOverlap returns 1, Newton proceeds to calculate the array of contacts for the pair of colliding bodies. If the function processCallback was set, the application receives a callback for every contact found between the two colliding bodies. Here the application can perform fine grain control over the behavior of the collision system. For example, rejecting the contact, making the contact frictionless, applying special effects to the surface etc. After all contacts are processed and if the function endCallback was set, Newton calls endCallback. Here the application can collect information gathered during the contact-processing phase and provide some feedback to the player. A typical use for the material callback is to play sound effects. The application passes the address of structure in the userData along with three event function callbacks. When the function aabbOverlap is called by Newton, the application resets a variable say maximumImpactSpeed. Then for every call to the function processCallback, the application compares the impact speed for this contact with the value of maximumImpactSpeed*, if the value is larger, then the application stores the new value along with the position, and any other quantity desired. When the application receives the call to endCallback the application plays a 3d sound based in the position and strength of the contact. Return . Parameters • *newtonWorld : is the pointer to the Newton world. • id0 : - group id0. • id1 : - group id1. • *compoundAabbOverlap : fixme (can this be NULL?) void *NewtonMaterialGetUserData(const NewtonWorld *const newtonWorld, int id0, int id1) Get userData associated with this material. Return . Parameters • *newtonWorld : is the pointer to the Newton world. • id0 : - group id0. • id1 : - group id1. NewtonMaterial *NewtonWorldGetFirstMaterial(const NewtonWorld *const newtonWorld) Get the first Material pair from the material array. See also: NewtonWorldGetNextMaterial

3.4. MaterialSetup 27 Newton Dynamics Engine Documentation, Release 3

Return first material. Parameters • *newtonWorld : is the pointer to the Newton world. NewtonMaterial *NewtonWorldGetNextMaterial(const NewtonWorld *const newtonWorld, const NewtonMaterial *const material) Get the next Material pair from the material array. See also: NewtonWorldGetFirstMaterial Return material in material array or NULL if material is the last material in the list. Parameters • *newtonWorld : is the pointer to the Newton world. • *material : corrent material

3.5 ContactBehaviour

void *NewtonMaterialGetMaterialPairUserData(const NewtonMaterial *const materialHandle) Get the userData set by the application when it created this material pair. This function can only be called from a material callback event handler. Return user data. Parameters • materialHandle : pointer to a material pair See also: NewtonMaterialSetCollisionCallback unsigned NewtonMaterialGetContactFaceAttribute(const NewtonMaterial *const materialHan- dle) Return the face attribute assigned to this face when for a user defined collision or a Newton collision tree. This function can only be called from a material callback event handler. Return attribute for collision trees. Zero if the contact was generated by two convex collisions. Parameters • materialHandle : pointer to a material pair this function can be used by the application to retrieve the face id of a polygon for a collision tree.See also: NewtonMaterialSetCollisionCallback dFloat NewtonMaterialGetContactNormalSpeed(const NewtonMaterial *const materialHandle) Calculate the speed of this contact along the normal vector of the contact. This function can only be called from a material callback event handler. Return speed. A positive value means the contact is repulsive. Parameters • materialHandle : pointer to a material pair See also: NewtonMaterialSetCollisionCallback dFloat NewtonMaterialGetContactTangentSpeed(const NewtonMaterial *const materialHandle, int index) Calculate the speed of this contact along the tangent vector of the contact. This function can only be called from a material callback event handler. Return tangent speed.

28 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

Parameters • materialHandle : pointer to a material pair. • index : index to the tangent vector. This value can be 0 for primary tangent direction or 1 for the secondary tangent direction. See also: NewtonMaterialSetCollisionCallback dFloat NewtonMaterialGetContactMaxNormalImpact(const NewtonMaterial *const materialHan- dle) dFloat NewtonMaterialGetContactMaxTangentImpact(const NewtonMaterial *const material- Handle, int index) void NewtonMaterialGetContactPositionAndNormal(const NewtonMaterial *const material- Handle, const NewtonBody *const body, dFloat *const positPtr, dFloat *const nor- malPtr) Get the contact position and normal in global space. This function can only be called from a material callback event handle. Return . Parameters • materialHandle : pointer to a material pair. • *body : pointer to body • *positPtr : pointer to an array of at least three floats to hold the contact position. • *normalPtr : pointer to an array of at least three floats to hold the contact normal. See also: NewtonMaterialSetCollisionCallback void NewtonMaterialGetContactForce(const NewtonMaterial *const materialHandle, const New- tonBody *const body, dFloat *const forcePtr) Get the contact force vector in global space. The contact force value is only valid when calculating resting contacts. This means if two bodies collide with non zero relative velocity, the reaction force will be an impulse, which is not a reaction force, this will return zero vector. this function will only return meaningful values when the colliding bodies are at rest. Return . Parameters • materialHandle : pointer to a material pair. • *body : pointer to body • *forcePtr : pointer to an array of at least three floats to hold the force vector in global space. This function can only be called from a material callback event handler.See also: NewtonMaterialSetCollision- Callback void NewtonMaterialGetContactTangentDirections(const NewtonMaterial *const material- Handle, const NewtonBody *const body, dFloat *const dir0, dFloat *const dir1) Get the contact tangent vector to the contact point. This function can only be called from a material callback event handler. Return . Parameters • materialHandle : pointer to a material pair.

3.5. ContactBehaviour 29 Newton Dynamics Engine Documentation, Release 3

• *body : pointer to body • *dir0 : - pointer to an array of at least three floats to hold the contact primary tangent vector. • *dir1 : - pointer to an array of at least three floats to hold the contact secondary tangent vector. See also: NewtonMaterialSetCollisionCallback dFloat NewtonMaterialGetContactPenetration(const NewtonMaterial *const materialHandle) NewtonCollision *NewtonMaterialGetBodyCollidingShape(const NewtonMaterial *const materi- alHandle, const NewtonBody *const body) void NewtonMaterialSetContactSoftness(const NewtonMaterial *const materialHandle, dFloat softness) Override the default softness value for the contact. This function can only be called from a material callback event handler. Return . Parameters • materialHandle : pointer to a material pair. • softness : softness value, must be positive. See also: NewtonMaterialSetCollisionCallback, NewtonMaterialSetDefaultSoftness void NewtonMaterialSetContactElasticity(const NewtonMaterial *const materialHandle, dFloat restitution) Override the default elasticity (coefficient of restitution) value for the contact. This function can only be called from a material callback event handler. Return . Parameters • materialHandle : pointer to a material pair. • restitution : elasticity value, must be positive. See also: NewtonMaterialSetCollisionCallback, NewtonMaterialSetDefaultElasticity void NewtonMaterialSetContactFrictionState(const NewtonMaterial *const materialHandle, int state, int index) Enable or disable friction calculation for this contact. This function can only be called from a material callback event handler. Return . Parameters • materialHandle : pointer to a material pair. • state* : new state. 0 makes the contact frictionless along the index tangent vector. • index : index to the tangent vector. 0 for primary tangent vector or 1 for the secondary tangent vector. See also: NewtonMaterialSetCollisionCallback void NewtonMaterialSetContactFrictionCoef(const NewtonMaterial *const materialHandle, dFloat staticFrictionCoef, dFloat kineticFriction- Coef, int index) Override the default value of the kinetic and static coefficient of friction for this contact. This function can only be called from a material callback event handler.

30 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

Return . Parameters • materialHandle : pointer to a material pair. • staticFrictionCoef : static friction coefficient. Must be positive. • kineticFrictionCoef : static friction coefficient. Must be positive. • index : index to the tangent vector. 0 for primary tangent vector or 1 for the secondary tangent vector. It is recommended that coef be set to a value lower or equal to 1.0, however because some synthetic materials can have hight than one coefficient of friction Newton allows for the coefficient of friction to be as high as 2.0.the value staticFrictionCoef and kineticFrictionCoef will be clamped between 0.01f and 2.0. If the application wants to set a kinetic friction higher than the current static friction it must increase the static friction first.See also: NewtonMaterialSetCollisionCallback, NewtonMaterialSetDefaultFriction void NewtonMaterialSetContactNormalAcceleration(const NewtonMaterial *const material- Handle, dFloat accel) Force the contact point to have a non-zero acceleration aligned this the contact normal. This function can only be called from a material callback event handler. Return . Parameters • materialHandle : pointer to a material pair. • accel : desired contact acceleration, Must be a positive value This function can be used for spacial effects like implementing jump, of explosive contact in a call back.See also: NewtonMaterialSetCollisionCallback void NewtonMaterialSetContactTangentAcceleration(const NewtonMaterial *const material- Handle, dFloat accel, int index) Force the contact point to have a non-zero acceleration along the surface plane. This function can only be called from a material callback event handler. Return . Parameters • materialHandle : pointer to a material pair. • accel : desired contact acceleration. • index : index to the tangent vector. 0 for primary tangent vector or 1 for the secondary tangent vector. See also: NewtonMaterialSetCollisionCallback, NewtonMaterialContactRotateTangentDirections void NewtonMaterialSetContactTangentFriction(const NewtonMaterial *const materialHan- dle, dFloat friction, int index) void NewtonMaterialSetContactNormalDirection(const NewtonMaterial *const materialHan- dle, const dFloat *const direction) Set the new direction of the for this contact point. This function can only be called from a material callback event handler. This function changes the basis of the contact point to one where the contact normal is aligned to the new direction vector and the tangent direction are recalculated to be perpendicular to the new contact normal. Return . Parameters

3.5. ContactBehaviour 31 Newton Dynamics Engine Documentation, Release 3

• materialHandle : pointer to a material pair. • *direction : pointer to an array of at least three floats holding the direction vector. In 99.9% of the cases the collision system can calculates a very good contact normal. however this algorithm that calculate the contact normal use as criteria the normal direction that will resolve the inter penetration with the least amount on motion. There are situations however when this solution is not the best. Take for example a rolling ball over a tessellated floor, when the ball is over a flat polygon, the contact normal is always perpendicular to the floor and pass by the origin of the sphere, however when the sphere is going across two adjacent polygons, the contact normal is now perpendicular to the polygons edge and this does not guarantee they it will pass bay the origin of the sphere, but we know that the best normal is always the one passing by the origin of the sphere.See also: NewtonMaterialSetCollisionCallback, NewtonMaterialContactRotateTangentDirections void NewtonMaterialSetContactPosition(const NewtonMaterial *const materialHandle, const dFloat *const position) void NewtonMaterialContactRotateTangentDirections(const NewtonMaterial *const materi- alHandle, const dFloat *const align- Vector) Rotate the tangent direction of the contacts until the primary direction is aligned with the alignVector. This function can only be called from a material callback event handler. This function rotates the tangent vectors of the contact point until the primary tangent vector and the align vector are perpendicular (ex. when the dot product between the primary tangent vector and the alignVector is 1.0). This function can be used in conjunction with NewtonMaterialSetContactTangentAcceleration in order to create special effects. For example, conveyor belts, cheap low LOD vehicles, slippery surfaces, etc. Return . Parameters • *materialHandle : pointer to a material pair. • *alignVector : pointer to an array of at least three floats holding the aligning vector. See also: NewtonMaterialSetCollisionCallback, NewtonMaterialSetContactNormalDirection

3.6 CshapesConvexSimple

NewtonCollision *NewtonCreateNull(const NewtonWorld *const newtonWorld) Create a transparent collision primitive. Some times the application needs to create helper rigid bodies that will never collide with other bodies, for example the neck of a rag doll, or an internal part of an articulated structure. This can be done by using the material system but it too much work and it will increase unnecessarily the material count, and therefore the project complexity. The Null collision is a collision object that satisfy all this conditions without having to change the engine philosophy. Return to the collision object. Parameters • *newtonWorld : is the pointer to the Newton world. NewtonCollision *NewtonCreateBox(const NewtonWorld *const newtonWorld, dFloat dx, dFloat dy, dFloat dz, int shapeID, const dFloat *const offsetMatrix) Create a box primitive for collision. Return to the box Parameters • *newtonWorld : is the pointer to the Newton world.

32 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• dx : box side one x dimension. • dy : box side one y dimension. • dz : box side one z dimension. • shapeID : fixme • *offsetMatrix : pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. NewtonCollision *NewtonCreateSphere(const NewtonWorld *const newtonWorld, dFloat radius, int shapeID, const dFloat *const offsetMatrix) Create a generalized ellipsoid primitive.. Sphere collision are generalized ellipsoids, the application can create many different kind of objects by just playing with dimensions of the radius. for example to make a sphere set all tree radius to the same value, to make a ellipse of revolution just set two of the tree radius to the same value. Return to the generalized sphere. Parameters • *newtonWorld : is the pointer to the Newton world. • radius : sphere radius • shapeID : fixme • *offsetMatrix : pointer to an array of 16 floats containing the offset matrix of the sphere relative to the body. If this parameter is NULL then the sphere is centered at the origin of the body. General ellipsoids are very good hull geometries to represent the outer shell of avatars in a game. NewtonCollision *NewtonCreateCone(const NewtonWorld *const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat *const offsetMatrix) Create a cone primitive for collision. Return to the box Parameters • *newtonWorld : is the pointer to the Newton world. • radius : cone radius at the base. • height : cone height along the x local axis from base to tip. • shapeID : fixme • *offsetMatrix : pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. NewtonCollision *NewtonCreateCapsule(const NewtonWorld *const newtonWorld, dFloat radio0, dFloat radio1, dFloat height, int shapeID, const dFloat *const offsetMatrix) Create a capsule primitive for collision. the capsule height must equal of larger than the sum of the cap radius. If this is not the case the height will be clamped the 2 * radius. Return to the box Parameters • *newtonWorld : is the pointer to the Newton world. • radio0 : - fixme • radio1 : - fixme • height : capsule height along the x local axis from tip to tip.

3.6. CshapesConvexSimple 33 Newton Dynamics Engine Documentation, Release 3

• shapeID : fixme • *offsetMatrix : pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. NewtonCollision *NewtonCreateCylinder(const NewtonWorld *const newtonWorld, dFloat radio0, dFloat radio1, dFloat height, int shapeID, const dFloat *const offsetMatrix) Create a cylinder primitive for collision. Return to the box Parameters • *newtonWorld : is the pointer to the Newton world. • radio0 : - fixme • radio1 : - fixme • height : cylinder height along the x local axis. • shapeID : fixme • *offsetMatrix : pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. NewtonCollision *NewtonCreateChamferCylinder(const NewtonWorld *const newtonWorld, dFloat radius, dFloat height, int shapeID, const dFloat *const offsetMatrix) Create a ChamferCylinder primitive for collision. Return to the box Parameters • *newtonWorld : is the pointer to the Newton world. • radius : ChamferCylinder radius at the base. • height : ChamferCylinder height along the x local axis. • shapeID : fixme • *offsetMatrix : pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. NewtonCollision *NewtonCreateConvexHull(const NewtonWorld *const newtonWorld, int count, const dFloat *const vertexCloud, int strideInBytes, dgFloat32 tolerance, int shapeID, const dFloat *const offsetMatrix) Create a ConvexHull primitive from collision from a cloud of points. Convex hulls are the solution to collision primitive that can not be easily represented by an implicit solid. The implicit solid primitives (spheres, cubes, cylinders, capsules, cones, etc.), have constant time complexity for contact calculation and are also extremely efficient on memory usage, therefore the application get perfect smooth behavior. However for cases where the shape is too difficult or a polygonal representation is desired, convex hulls come closest to the to the model shape. For example it is a mistake to model a 10000 point sphere as a convex hull when the perfect sphere is available, but it is better to represent a pyramid by a convex hull than with a sphere or a box. Return to the collision mesh, NULL if the function fail to generate convex shape Parameters • *newtonWorld : is the pointer to the Newton world. • count : number of consecutive point to follow must be at least 4.

34 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• *vertexCloud : pointer to and array of point. • strideInBytes : vertex size in bytes, must be at least 12. • tolerance : tolerance value for the hull generation. • shapeID : fixme • *offsetMatrix : pointer to an array of 16 floats containing the offset matrix of the box relative to the body. If this parameter is NULL, then the primitive is centered at the origin of the body. There is not upper limit as to how many vertex the application can pass to make a hull shape, however for performance and memory usage concern it is the application responsibility to keep the max vertex at the possible minimum. The minimum number of vertex should be equal or larger than 4 and it is the application responsibility that the points are part of a solid geometry. Unpredictable results will occur if all points happen to be collinear or coplanar.The performance of collision with convex hull proxies is sensitive to the vertex count of the hull. Since a the convex hull of a visual geometry is already an approximation of the mesh, for visual purpose there is not significant difference between the appeal of a exact hull and one close to the exact hull but with but with a smaller vertex count. It just happens that sometime complex meshes lead to generation of convex hulls with lots of small detail that play not roll of the quality of the simulation but that have a significant impact on the performance because of a large vertex count. For this reason the application have the option to set a tolerance parameter. tolerance* is use to post process the final geometry in the following faction, a point on the surface of the hull can be remove if the distance of all of the surrounding vertex immediately adjacent to the average plane equation formed the faces adjacent to that point, is smaller than the tolerance. A value of zero in tolerance will generate an exact hull and a value langer that zero will generate a loosely fitting hull and it willbe faster to generate. NewtonCollision *NewtonCreateConvexHullFromMesh(const NewtonWorld *const newtonWorld, const NewtonMesh *const mesh, dFloat tol- erance, int shapeID) Create a ConvexHull primitive from a special effect mesh. Because the in general this function is used for runtime special effect like debris and or solid particles it is recommended that the source mesh complexity is kept small. Return to the collision mesh, NULL if the function fail to generate convex shape Parameters • *newtonWorld : is the pointer to the Newton world. • *mesh : special effect mesh • tolerance : tolerance value for the hull generation. • shapeID : fixme See also: NewtonCreateConvexHull, NewtonMeshCreate NewtonCollision *NewtonCreateCompoundCollision(const NewtonWorld *const newtonWorld, int shapeID) Create a container to hold an array of convex collision primitives. Compound collision primitives can only be made of convex collision primitives and they can not contain compound collision. Therefore they are treated as convex primitives. Return to the compound collision. Parameters • *newtonWorld : is the pointer to the Newton world. • shapeID : fixme Compound collision primitives are treated as instance collision objects that can not shared by multiples rigid bodies.

3.6. CshapesConvexSimple 35 Newton Dynamics Engine Documentation, Release 3 void *NewtonCompoundCollisionAddSubCollision(NewtonCollision *const compoundCollision, const NewtonCollision *const convexColli- sion) void NewtonCompoundCollisionRemoveSubCollision(NewtonCollision *const compoundColli- sion, const void *const collisionNode) void NewtonCompoundCollisionRemoveSubCollisionByIndex(NewtonCollision *const com- poundCollision, int nodeIndex) void NewtonCompoundCollisionSetSubCollisionMatrix(NewtonCollision *const compound- Collision, const void *const colli- sionNode, const dFloat *const ma- trix) void NewtonCompoundCollisionBeginAddRemove(NewtonCollision *const compoundCollision) void NewtonCompoundCollisionEndAddRemove(NewtonCollision *const compoundCollision) void *NewtonCompoundCollisionGetFirstNode(NewtonCollision *const compoundCollision) void *NewtonCompoundCollisionGetNextNode(NewtonCollision *const compoundCollision, const void *const node) void *NewtonCompoundCollisionGetNodeByIndex(NewtonCollision *const compoundCollision, int index) int NewtonCompoundCollisionGetNodeIndex(NewtonCollision *const compoundCollision, const void *const node) NewtonCollision *NewtonCompoundCollisionGetCollisionFromNode(NewtonCollision *const compoundCollision, const void *const node) NewtonCollision *NewtonCreateCompoundCollisionFromMesh(const NewtonWorld *const new- tonWorld, const NewtonMesh *const convexAproximation, dFloat hullTolerance, int shapeID, int subShapeID) Create a compound collision from a concave mesh by an approximate convex partition The algorithm will separated the the original mesh into a series of sub meshes until either the worse concave point is smaller than the specified min concavity or the max number convex shapes is reached. Return to the compound collision. Parameters • *newtonWorld : is the pointer to the Newton world. • *convexAproximation : fixme • hullTolerance : fixme • shapeID : fixme • subShapeID : fixme is is recommended that convex approximation are made by person with a graphics toll by physically overlaying collision primitives over the concave mesh. but for quit test of maybe for simple meshes and algorithm ap- proximations can be used.is is recommended that for best performance this function is used in an off line toll and serialize the output.Compound collision primitives are treated as instanced collision objects that cannot be shared by multiples rigid bodies.

36 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

NewtonCollision *NewtonCreateFracturedCompoundCollision(const NewtonWorld *const newtonWorld, const Newton- Mesh *const solidMesh, int shapeID, int fracturePhysicsMa- terialID, int pointcloudCount, const dFloat *const vertex- Cloud, int strideInBytes, int materialID, const dFloat *const textureMatrix, NewtonFrac- tureCompoundCollisionRe- constructMainMeshCallBack regenerateMainMeshCallback, NewtonFractureCompoundCol- lisionOnEmitCompoundFrac- tured emitFracturedCompound, NewtonFractureCompoundCol- lisionOnEmitChunk emitFrac- furedChunk) NewtonCollision *NewtonFracturedCompoundPlaneClip(const NewtonCollision *const fractured- Compound, const dFloat *const plane) void NewtonFracturedCompoundSetCallbacks(const NewtonCollision *const fracturedCompound, NewtonFractureCompoundCollisionReconstruct- MainMeshCallBack regenerateMainMeshCallback, NewtonFractureCompoundCollisionOnEmit- CompoundFractured emitFracturedCompound, NewtonFractureCompoundCollisionOnEmitChunk emitFracfuredChunk) int NewtonFracturedCompoundNeighborNodeList(const NewtonCollision *const fracturedCom- pound, void *const collisionNode, void **const nodesArray, int maxCount) int NewtonFracturedCompoundIsNodeFreeToDetach(const NewtonCollision *const fractured- Compound, void *const collisionNode) NewtonFracturedCompoundMeshPart *NewtonFracturedCompoundGetFirstSubMesh(const New- tonCollision *const fractured- Compound) NewtonFracturedCompoundMeshPart *NewtonFracturedCompoundGetNextSubMesh(const New- tonCollision *const fractured- Compound, NewtonFrac- turedCom- poundMesh- Part *const subMesh) NewtonFracturedCompoundMeshPart *NewtonFracturedCompoundGetMainMesh(const NewtonCol- lision *const frac- turedCompound)

3.6. CshapesConvexSimple 37 Newton Dynamics Engine Documentation, Release 3

int NewtonFracturedCompoundCollisionGetVertexCount(const NewtonCollision *const fracturedCompound, const New- tonFracturedCompoundMeshPart *const meshOwner) const dFloat *NewtonFracturedCompoundCollisionGetVertexPositions(const Newton- Collision *const fracturedCom- pound, const NewtonFractured- CompoundMesh- Part *const meshOwner) const dFloat *NewtonFracturedCompoundCollisionGetVertexNormals(const NewtonCollision *const fractured- Compound, const NewtonFracturedCom- poundMeshPart *const meshOwner) const dFloat *NewtonFracturedCompoundCollisionGetVertexUVs(const NewtonCollision *const fracturedCompound, const NewtonFractured- CompoundMeshPart *const meshOwner) int NewtonFracturedCompoundMeshPartGetIndexStream(const NewtonCollision *const frac- turedCompound, const NewtonFrac- turedCompoundMeshPart *const meshOwner, const void *const segment, int *const index) void *NewtonFracturedCompoundMeshPartGetFirstSegment(const NewtonFracturedCom- poundMeshPart *const break- ableComponentMesh) void *NewtonFracturedCompoundMeshPartGetNextSegment(const void *const breakableCom- ponentSegment) int NewtonFracturedCompoundMeshPartGetMaterial(const void *const segment) int NewtonFracturedCompoundMeshPartGetIndexCount(const void *const segment) int NewtonCollisionGetMode(const NewtonCollision *const convexCollision) void NewtonCollisionSetMode(const NewtonCollision *const convexCollision, int mode) int NewtonConvexHullGetVertexData(const NewtonCollision *const convexHullCollision, dFloat **const vertexData, int *strideInBytes) int NewtonConvexHullGetFaceIndices(const NewtonCollision *const convexHullCollision, int face, int *const faceIndices) Return the number of vertices of face and copy each index into array faceIndices. this function will return zero on all shapes other than a convex full collision shape. Return face count of face. Parameters • convexHullCollision : is the pointer to a convex collision hull primitive. • face : fixme

38 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• faceIndices : fixme To get the number of faces of a convex hull shape see function NewtonCollisionGetInfoSee also: NewtonColli- sionGetInfo, NewtonCreateConvexHull dFloat NewtonConvexCollisionCalculateVolume(const NewtonCollision *const convexCollision) calculate the total volume defined by a convex collision geometry. The total volume calculated by the function is only an approximation of the ideal volume. This is not an error, it is a fact resulting from the polygonal representation of convex solids. Return geometry volume. This function will return zero if the body collision geometry is no convex. Parameters • *convexCollision : pointer to the collision. This function can be used to assist the application in calibrating features like fluid density weigh factor when calibrating buoyancy forces for more realistic result. void NewtonConvexCollisionCalculateInertialMatrix(const NewtonCollision *convexColli- sion, dFloat *const inertia, dFloat *const origin) Calculate the three principal axis and the the values of the inertia matrix of a convex collision objects. This function calculate a general inertial matrix for arbitrary convex collision including compound collisions. Parameters • convexCollision : is the pointer to a convex collision primitive. • *inertia : pointer to and array of a least 3 floats to hold the values of the principal inertia. • *origin : pointer to and array of a least 3 floats to hold the values of the center of mass for the principal inertia. See also: NewtonBodySetMassMatrix, NewtonBodyGetMass, NewtonBodySetCentreOfMass, NewtonBodyGet- CentreOfMass void NewtonConvexCollisionCalculateBuoyancyAcceleration(const NewtonCollision *const convexCollision, const dFloat *const ma- trix, const dFloat *const shapeOrigin, const dFloat *const gravityVector, const dFloat *const fluidPlane, dFloat fluidDensity, dFloat fluidViscosity, dFloat *const accel, dFloat *const alpha) Add buoyancy force and torque for bodies immersed in a fluid. This function is only effective when called from NewtonApplyForceAndTorque callback Return . Parameters • convexCollision : fixme • matrix : fixme • shapeOrigin : fixme • *gravityVector : pointer to an array of floats containing the gravity vector. • fluidPlane : fixme • fluidDensity : fluid density.

3.6. CshapesConvexSimple 39 Newton Dynamics Engine Documentation, Release 3

• fluidViscosity : fluid linear viscosity (resistance to linear translation). • accel : fixme • alpha : fixme This function adds buoyancy force and torque to a body when it is immersed in a fluid. The force is calculated according to Archimedes Buoyancy Principle. When the parameter buoyancyPlane is set to NULL, the body is considered to completely immersed in the fluid. This can be used to simulate boats and lighter than air vehicles etc..If buoyancyPlane return 0 buoyancy calculation for this collision primitive is ignored, this could be used to filter buoyancy calculation of compound collision geometry with different IDs.See also: NewtonConvexColli- sionCalculateVolume const void *NewtonCollisionDataPointer(const NewtonCollision *const convexCollision)

3.7 CshapesConvexComplex

NewtonCollision *NewtonCreateUserMeshCollision(const NewtonWorld *const newtonWorld, const dFloat *const minBox, const dFloat *const maxBox, void *const userData, New- tonUserMeshCollisionCollideCallback collide- Callback, NewtonUserMeshCollisionRayHit- Callback rayHitCallback, NewtonUserMesh- CollisionDestroyCallback destroyCallback, NewtonUserMeshCollisionGetCollisionInfo getInfoCallback, NewtonUserMeshCollision- AABBTest getAABBOverlapTestCallback, NewtonUserMeshCollisionGetFacesInAABB facesInAABBCallback, NewtonOnUserColli- sionSerializationCallback serializeCallback, int shapeID) Create a complex collision geometry to be controlled by the application. UserMeshCollision* provides the ap- plication with a method of overloading the built-in collision system for background objects. UserMeshCollision can be used for implementing collisions with height maps, collisions with BSP, and any other collision structure the application supports and wishes to preserve. However, UserMeshCollision can not take advantage of the ef- ficient and sophisticated algorithms and data structures of the built-in TreeCollision. We suggest you experiment with both methods and use the method best suited to your situation. Return to the user collision. Parameters • *newtonWorld : is the pointer to the Newton world. • *minBox : pointer to an array of at least three floats to hold minimum value for the box relative to the collision. • *maxBox : pointer to an array of at least three floats to hold maximum value for the box relative to the collision. • *userData : pointer to user data to be used as context for event callback. • collideCallback : pointer to an event function for providing Newton with the polygon inside a given box region. • rayHitCallback : pointer to an event function for providing Newton with ray intersection infor- mation.

40 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• destroyCallback : pointer to an event function for destroying any data allocated for use by the application. • getInfoCallback : fixme • getAABBOverlapTestCallback : fixme • facesInAABBCallback : fixme • serializeCallback : fixme • shapeID : fixme When a UserMeshCollision is assigned to a body, the mass of the body is ignored in all dynamics calculations. This make the body behave as a static body. int NewtonUserMeshCollisionContinuousOverlapTest(const NewtonUserMeshCollisionCollid- eDesc *const collideDescData, const void *const rayHandle, const dFloat *const minAabb, const dFloat *const maxAabb) NewtonCollision *NewtonCreateTreeCollision(const NewtonWorld *const newtonWorld, int shapeID) Create an empty complex collision geometry tree. TreeCollision* is the preferred method within Newton for collision with polygonal meshes of arbitrary complexity. The mesh must be made of flat non-intersecting poly- gons, but they do not explicitly need to be triangles. TreeCollision* can be serialized by the application to/from an arbitrary storage device. Return to the collision tree. Parameters • *newtonWorld : is the pointer to the Newton world. • shapeID : fixme When a TreeCollision is assigned to a body the mass of the body is ignored in all dynamics calculations. This makes the body behave as a static body.See also: NewtonTreeCollisionBeginBuild, NewtonTreeCollision- AddFace, NewtonTreeCollisionEndBuild, NewtonStaticCollisionSetDebugCallback, NewtonTreeCollisionGet- FaceAttribute, NewtonTreeCollisionSetFaceAttribute NewtonCollision *NewtonCreateTreeCollisionFromMesh(const NewtonWorld *const newton- World, const NewtonMesh *const mesh, int shapeID) void NewtonStaticCollisionSetDebugCallback(const NewtonCollision *const staticCollision, NewtonTreeCollisionCallback userCallback) set a function call back to be call during the face query of a collision tree. because debug display display report all the faces of a collision primitive, it could get slow on very large static collision. this function can be used for debugging purpose to just report only faces intersection the collision AABB of the collision shape colliding with the polyginal mesh collision. Parameters • *staticCollision : is the pointer to the static collision (a CollisionTree of a HeightFieldColli- sion) • *userCallback : pointer to an event function to call before Newton evaluates the polygons col- liding with a body. This parameter can be NULL. this function is not recommended to use for production code only for debug purpose.See also: NewtonTreeCol- lisionGetFaceAttribute, NewtonTreeCollisionSetFaceAttribute

3.7. CshapesConvexComplex 41 Newton Dynamics Engine Documentation, Release 3

void NewtonTreeCollisionSetUserRayCastCallback(const NewtonCollision *const treeCol- lision, NewtonCollisionTreeRayCastCall- back rayHitCallback) set a function call back to be called during the face query of a collision tree. In general a ray cast on a collision tree will stops at the first intersections with the closest face in the tree that was hit by the ray. In some cases the application may be interested in the intesation with faces other than the fiorst hit. In this cases the application can set this alternate callback and the ray scanner will notify the application of each face hit by the ray scan. Parameters • *treeCollision : is the pointer to the collision tree. • rayHitCallback : pointer to an event function for providing Newton with ray intersection infor- mation. since this function faces the ray scanner to visit all of the potential faces intersected by the ray, setting the function call back make the ray casting on collision tree less efficient than the default behavior. So it is this functionality is only recommended for cases were the application is using especial effects like transparencies, or other effectscalling this function with rayHitCallback = NULL will rest the collision tree to it default raycast mode, which is return with the closest hit.when rayHitCallback is not null then the callback is dalled with the follwing arguments const NewtonCollisio* collision - pointer to the collision tree interseption - inetstion param- eters of the ray normal - unnormalized face mormal in the space fo eth parent of the collision. faceId - id of this face in the collision tree.See also: NewtonTreeCollisionGetFaceAttribute, NewtonTreeCollisionSetFaceAttribute void NewtonHeightFieldSetUserRayCastCallback(const NewtonCollision *const heightField, NewtonHeightFieldRayCastCallback rayHit- Callback) void NewtonHeightFieldSetHorizontalDisplacement(const NewtonCollision *const height- Field, const unsigned short *const hori- zontalMap, dFloat scale) void NewtonTreeCollisionBeginBuild(const NewtonCollision *const treeCollision) Prepare a TreeCollision to begin to accept the polygons that comprise the collision mesh. See also: Newton- TreeCollisionAddFace, NewtonTreeCollisionEndBuild Return . Parameters • *treeCollision : is the pointer to the collision tree. void NewtonTreeCollisionAddFace(const NewtonCollision *const treeCollision, int vertexCount, const dFloat *const vertexPtr, int strideInBytes, int faceAttribute) Add an individual polygon to a TreeCollision. After the call to NewtonTreeCollisionBeginBuild the TreeColli- sion is ready to accept polygons. The application should iterate through the application’s mesh, adding the mesh polygons to the TreeCollision one at a time. The polygons must be flat and non-self intersecting. Return . Parameters • *treeCollision : is the pointer to the collision tree. • vertexCount : number of vertex in vertexPtr • *vertexPtr : pointer to an array of vertex. The vertex should consist of at least 3 floats each. • strideInBytes : size of each vertex in bytes. This value should be 12 or larger. • faceAttribute : id that identifies the polygon. The application can use this value to customize the behavior of the collision geometry. See also: NewtonTreeCollisionAddFace, NewtonTreeCollisionEndBuild

42 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

void NewtonTreeCollisionEndBuild(const NewtonCollision *const treeCollision, int optimize) Finalize the construction of the polygonal mesh. After the application has finished adding polygons to the TreeCollision, it must call this function to finalize the construction of the collision mesh. If concave polygons are added to the TreeCollision, the application must call this function with the parameter optimize set to 1. With the optimize parameter set to 1, Newton will optimize the collision mesh by removing non essential edges from adjacent flat polygons. Newton will not change the topology of the mesh but significantly reduces the number of polygons in the mesh. The reduction factor of the number of polygons in the mesh depends upon the irregularity of the mesh topology. A reduction factor of 1.5 to 2.0 is common. Calling this function with the parameter optimize set to zero, will leave the mesh geometry unaltered. Return . Parameters • *treeCollision : is the pointer to the collision tree. • optimize : flag that indicates to Newton whether it should optimize this mesh. Set to 1 to optimize the mesh, otherwise 0. See also: NewtonTreeCollisionAddFace, NewtonTreeCollisionEndBuild int NewtonTreeCollisionGetFaceAttribute(const NewtonCollision *const treeCollision, const int *const faceIndexArray, int indexCount) Get the user defined collision attributes stored with each face of the collision mesh. This function is used to obtain the user data stored in faces of the collision geometry. The application can use this user data to achieve per polygon material behavior in large static collision meshes. Return id of the face. Parameters • treeCollision : fixme • *faceIndexArray : pointer to the face index list passed to the function *NewtonTreeCollision- Callback userCallback • indexCount : fixme See also: NewtonTreeCollisionSetFaceAttribute, NewtonCreateTreeCollision void NewtonTreeCollisionSetFaceAttribute(const NewtonCollision *const treeCollision, const int *const faceIndexArray, int indexCount, int at- tribute) Change the user defined collision attribute stored with faces of the collision mesh. This function is used to obtain the user data stored in faces of the collision geometry. The application can use this user data to achieve per polygon material behavior in large static collision meshes. By changing the value of this user data the application can achieve modifiable surface behavior with the collision geometry. For example, in a driving game, the surface of a polygon that represents the street can changed from pavement to oily or wet after some collision event occurs. Return id of the face. Parameters • *treeCollision : fixme • *faceIndexArray : pointer to the face index list passed to the NewtonTreeCollisionCallback function • indexCount : fixme • attribute : value of the user defined attribute to be stored with the face. See also: NewtonTreeCollisionGetFaceAttribute, NewtonCreateTreeCollision

3.7. CshapesConvexComplex 43 Newton Dynamics Engine Documentation, Release 3

void NewtonTreeCollisionForEachFace(const NewtonCollision *const treeCollision, Newton- TreeCollisionFaceCallback forEachFaceCallback, void *const context) int NewtonTreeCollisionGetVertexListTriangleListInAABB(const NewtonCollision *const treeCollision, const dFloat *const p0, const dFloat *const p1, const dFloat **const vertexArray, int *const vertexCount, int *const vertexStrideInBytes, const int *const indexList, int maxIn- dexCount, const int *const faceAttribute) collect the vertex list index list mesh intersecting the AABB in collision mesh. indexList should be a list 3 * maxIndexCount the number of elements. Return number of triangles in indexList. Parameters • *treeCollision : fixme • *p0 : - pointer to an array of at least three floats representing the ray origin in the local space of the geometry. • *p1 : - pointer to an array of at least three floats representing the ray end in the local space of the geometry. • **vertexArray : pointer to a the vertex array of vertex. • *vertexCount : pointer int to return the number of vertex in vertexArray. • *vertexStrideInBytes : pointer to int to return the size of each vertex in vertexArray. • *indexList : pointer to array on integers containing the triangles intersection the aabb. • maxIndexCount : maximum number of indices the function will copy to indexList. • *faceAttribute : pointer to array on integers top contain the face containing the . faceAttributet should be a list maxIndexCount the number of elements.this function could be used by the ap- plication for many purposes. for example it can be used to draw the collision geometry intersecting a collision primitive instead of drawing the entire collision tree in debug mode. Another use for this function is to to efficient draw projective texture shadows. NewtonCollision *NewtonCreateHeightFieldCollision(const NewtonWorld *const newtonWorld, int width, int height, int gridsDiago- nals, dgInt32 elevationdatType, const void *const elevationMap, const char *const attributeMap, dFloat verticalScale, dFloat horizontalScale, int shapeID) Create a height field collision geometry. NewtonCollision* NewtonCreateHeightFieldCollision(const Newton- World* const newtonWorld, int width, int height, int cellsDiagonals, const dFloat* const elevationMap, const char* const atributeMap, dFloat horizontalScale, int shapeID) Return to the collision. Parameters • *newtonWorld : is the pointer to the Newton world. • width : fixme

44 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• height : fixme • gridsDiagonals : fixme • elevationdatType : fixme • elevationMap : fixme • attributeMap : fixme • verticalScale : fixme • horizontalScale : fixme • shapeID : fixme NewtonCollision *NewtonCreateSceneCollision(const NewtonWorld *const newtonWorld, int shapeID) Create a height field collision geometry. Return to the collision. Parameters • *newtonWorld : is the pointer to the Newton world. • shapeID : fixme void NewtonSceneCollisionBeginAddRemove(NewtonCollision *const sceneCollision) void NewtonSceneCollisionEndAddRemove(NewtonCollision *const sceneCollision) void NewtonSceneCollisionSetSubCollisionMatrix(NewtonCollision *const sceneCollision, const void *const collisionNode, const dFloat *const matrix) void *NewtonSceneCollisionAddSubCollision(NewtonCollision *const sceneCollision, const NewtonCollision *const collision) void NewtonSceneCollisionRemoveSubCollision(NewtonCollision *const sceneCollision, const void *const collisionNode) void NewtonSceneCollisionRemoveSubCollisionByIndex(NewtonCollision *const sceneColli- sion, int nodeIndex) void *NewtonSceneCollisionGetNodeByIndex(NewtonCollision *const sceneCollision, int index) int NewtonSceneCollisionGetNodeIndex(NewtonCollision *const sceneCollision, const void *const collisionNode) NewtonCollision *NewtonSceneCollisionGetCollisionFromNode(NewtonCollision *const sceneCollision, const void *const node) void *NewtonSceneCollisionGetFirstNode(NewtonCollision *const sceneCollision) void *NewtonSceneCollisionGetNextNode(NewtonCollision *const sceneCollision, const void *const node) dFloat NewtonCollisionGetSkinThickness(const NewtonCollision *const collision)

3.7. CshapesConvexComplex 45 Newton Dynamics Engine Documentation, Release 3

3.8 CollisionLibraryGeneric

int NewtonCollisionPointDistance(const NewtonWorld *const newtonWorld, const dFloat *const point, const NewtonCollision *const collision, const dFloat *const matrix, dFloat *const contact, dFloat *const normal, int threadIndex) Calculate the closest point between a point and convex collision primitive. This function can be used as a low-level building block for a stand-alone collision system. Applications that have already there own physics system, and only want and quick and fast collision solution, can use Newton advanced collision engine as the low level collision detection part. To do this the application only needs to initialize Newton, create the collision primitives at application discretion, and just call this function when the objects are in close proximity. Applications using Newton as a collision system only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. Also the application should implement their own trivial aabb test, before calling this function . Return if the two bodies are disjoint and the closest point could be found, zero if the point is inside the convex primitive. Parameters • *newtonWorld : is the pointer to the Newton world. • *point : pointer to and array of a least 3 floats representing the origin. • *collision : pointer to collision primitive. • *matrix : pointer to an array of 16 floats containing the offset matrix of collision primitiveA. • *contact : pointer to and array of a least 3 floats to contain the closest point to collisioA. • *normal : pointer to and array of a least 3 floats to contain the separating vector normal. • threadIndex : -Thread index form where the call is made from, zeor otherwize the current implementation of this function do work on collision trees, or user define collision.See also: Newton- CollisionCollideContinue, NewtonCollisionClosestPoint, NewtonCollisionCollide, NewtonCollisionRayCast, NewtonCollisionCalculateAABB int NewtonCollisionClosestPoint(const NewtonWorld *const newtonWorld, const NewtonCollision *const collisionA, const dFloat *const matrixA, const Newton- Collision *const collisionB, const dFloat *const matrixB, dFloat *const contactA, dFloat *const contactB, dFloat *const nor- malAB, int threadIndex) Calculate the closest points between two disjoint convex collision primitive. This function can be used as a low-level building block for a stand-alone collision system. Applications that have already there own physics system, and only want and quick and fast collision solution, can use Newton advanced collision engine as the low level collision detection part. To do this the application only needs to initialize Newton, create the collision primitives at application discretion, and just call this function when the objects are in close proximity. Applications using Newton as a collision system only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. Also the application should implement their own trivial aabb test, before calling this function . Return if the tow bodies are disjoint and he closest point could be found, zero if the two collision primitives are intersecting. Parameters • *newtonWorld : is the pointer to the Newton world. • *collisionA : pointer to collision primitive A. • *matrixA : pointer to an array of 16 floats containing the offset matrix of collision primitiveA.

46 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• *collisionB : pointer to collision primitive B. • *matrixB : pointer to an array of 16 floats containing the offset matrix of collision primitiveB. • *contactA : pointer to and array of a least 3 floats to contain the closest point to collisionA. • *contactB : pointer to and array of a least 3 floats to contain the closest point to collisionB. • *normalAB : pointer to and array of a least 3 floats to contain the separating vector normal. • threadIndex : -Thread index form where the call is made from, zeor otherwize the current implementation of this function does not work on collision trees, or user define collision.See also: NewtonCollisionCollideContinue, NewtonCollisionPointDistance, NewtonCollisionCollide, NewtonCollision- RayCast, NewtonCollisionCalculateAABB int NewtonCollisionIntersectionTest(const NewtonWorld *const newtonWorld, const Newton- Collision *const collisionA, const dFloat *const matrixA, const NewtonCollision *const collisionB, const dFloat *const matrixB, int threadIndex) int NewtonCollisionCollide(const NewtonWorld *const newtonWorld, int maxSize, const NewtonCol- lision *const collisionA, const dFloat *const matrixA, const NewtonCol- lision *const collisionB, const dFloat *const matrixB, dFloat *const con- tacts, dFloat *const normals, dFloat *const penetration, dLong *const attributeA, dLong *const attributeB, int threadIndex) Calculate contact points between two collision primitive. This function can be used as a low-level building block for a stand-alone collision system. Applications that have already there own physics system, and only want and quick and fast collision solution, can use Newton advanced collision engine as the low level collision detection part. To do this the application only needs to initialize Newton, create the collision primitives at application discretion, and just call this function when the objects are in close proximity. Applications using Newton as a collision system only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. Also the application should implement their own trivial aabb test, before calling this function . Return number of contact points. Parameters • *newtonWorld : is the pointer to the Newton world. • maxSize : size of maximum number of elements in contacts, normals, and penetration. • *collisionA : pointer to collision primitive A. • *matrixA : pointer to an array of 16 floats containing the offset matrix of collision primitiveA. • *collisionB : pointer to collision primitive B. • *matrixB : pointer to an array of 16 floats containing the offset matrix of collision primitiveB. • *contacts : pointer to and array of a least 3 times maxSize floats to contain the collision contact points. • *normals : pointer to and array of a least 3 times maxSize floats to contain the collision contact normals. • *penetration : pointer to and array of a least maxSize floats to contain the collision penetration at each contact. • attributeA : fixme • attributeB : fixme • threadIndex : Thread index form where the call is made from, zeor otherwize

3.8. CollisionLibraryGeneric 47 Newton Dynamics Engine Documentation, Release 3

See also: NewtonCollisionCollideContinue, NewtonCollisionClosestPoint, NewtonCollisionPointDistance, NewtonCollisionRayCast, NewtonCollisionCalculateAABB int NewtonCollisionCollideContinue(const NewtonWorld *const newtonWorld, int maxSize, dFloat timestep, const NewtonCollision *const collisionA, const dFloat *const matrixA, const dFloat *const velocA, const dFloat *const omegaA, const NewtonCollision *const colli- sionB, const dFloat *const matrixB, const dFloat *const ve- locB, const dFloat *const omegaB, dFloat *const timeOfIm- pact, dFloat *const contacts, dFloat *const normals, dFloat *const penetration, dLong *const attributeA, dLong *const attributeB, int threadIndex) Calculate time of impact of impact and contact points between two collision primitive. by passing zero as maxSize not contact will be calculated and the function will just determine the time of impact is any. Return number of contact points. Parameters • *newtonWorld : is the pointer to the Newton world. • maxSize : size of maximum number of elements in contacts, normals, and penetration. • timestep : maximum time interval considered for the continuous collision calculation. • *collisionA : pointer to collision primitive A. • *matrixA : pointer to an array of 16 floats containing the offset matrix of collision primitiveA. • *velocA : pointer to and array of a least 3 times maxSize floats containing the linear velocity of collision primitiveA. • *omegaA : pointer to and array of a least 3 times maxSize floats containing the angular velocity of collision primitiveA. • *collisionB : pointer to collision primitive B. • *matrixB : pointer to an array of 16 floats containing the offset matrix of collision primitiveB. • *velocB : pointer to and array of a least 3 times maxSize floats containing the linear velocity of collision primitiveB. • *omegaB : pointer to and array of a least 3 times maxSize floats containing the angular velocity of collision primitiveB. • *timeOfImpact : pointer to least 1 float variable to contain the time of the intersection. • *contacts : pointer to and array of a least 3 times maxSize floats to contain the collision contact points. • *normals : pointer to and array of a least 3 times maxSize floats to contain the collision contact normals. • *penetration : pointer to and array of a least maxSize floats to contain the collision penetration at each contact. • attributeA : fixme • attributeB : fixme • threadIndex : -Thread index form where the call is made from, zeor otherwize if the body are inter penetrating the time of impact will be zero.if the bodies do not collide time of impact will be set to timestepThis function can be used as a low-level building block for a stand-alone collision sys- tem. Applications that have already there own physics system, and only want and quick and fast collision

48 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

solution, can use Newton advanced collision engine as the low level collision detection part. To do this the application only needs to initialize Newton, create the collision primitives at application discretion, and just call this function when the objects are in close proximity. Applications using Newton as a collision system only, are responsible for implementing their own broad phase collision determination, based on any high level tree structure. Also the application should implement their own trivial aabb test, before calling this function .See also: NewtonCollisionCollide, NewtonCollisionClosestPoint, NewtonCollisionPointDistance, NewtonCollision- RayCast, NewtonCollisionCalculateAABB void NewtonCollisionSupportVertex(const NewtonCollision *const collisionPtr, const dFloat *const dir, dFloat *const vertex) Calculate the most extreme point of a convex collision shape along the given direction. the search direction must be in the space of the collision shape. Return . Parameters • *collisionPtr : pointer to the collision object. • *dir : pointer to an array of at least three floats representing the search direction. • *vertex : pointer to an array of at least three floats to hold the collision most extreme vertex along the search direction. See also: NewtonCollisionRayCast, NewtonCollisionClosestPoint, NewtonCollisionPointDistance dFloat NewtonCollisionRayCast(const NewtonCollision *const collisionPtr, const dFloat *const p0, const dFloat *const p1, dFloat *const normal, dLong *const at- tribute) Ray cast specific collision object. This function is intended for applications using newton collision system separate from the dynamics system, also for applications implementing any king of special purpose logic like sensing distance to another object. Return parametric value of the intersection, between 0.0 and 1.0, an value larger than 1.0 if the ray miss. Parameters • *collisionPtr : pointer to the collision object. • *p0 : - pointer to an array of at least three floats representing the ray origin in the local space of the geometry. • *p1 : - pointer to an array of at least three floats representing the ray end in the local space of the geometry. • *normal : pointer to an array of at least three floats to hold the normal at the intersection point. • *attribute : pointer to an array of at least one floats to hold the ID of the face hit by the ray. the ray most be local to the collisions geometry, for example and application ray casting the collision geometry of of a rigid body, must first take the points p0, and p1 to the local space of the rigid body by multiplying the points by the inverse of he rigid body transformation matrix.See also: NewtonCollisionClosestPoint, NewtonCollision- SupportVertex, NewtonCollisionPointDistance, NewtonCollisionCollide, NewtonCollisionCalculateAABB void NewtonCollisionCalculateAABB(const NewtonCollision *const collisionPtr, const dFloat *const offsetMatrix, dFloat *const p0, dFloat *const p1) Calculate an axis-aligned bounding box for this collision, the box is calculated relative to offsetMatrix. See also: NewtonCollisionClosestPoint, NewtonCollisionPointDistance, NewtonCollisionCollide, NewtonCollision- RayCast Return . Parameters • *collisionPtr : pointer to the collision object.

3.8. CollisionLibraryGeneric 49 Newton Dynamics Engine Documentation, Release 3

• *offsetMatrix : pointer to an array of 16 floats containing the offset matrix used as the coordinate system and center of the AABB. • *p0 : - pointer to an array of at least three floats to hold minimum value for the AABB. • *p1 : - pointer to an array of at least three floats to hold maximum value for the AABB. void NewtonCollisionForEachPolygonDo(const NewtonCollision *const collisionPtr, const dFloat *const matrixPtr, NewtonCollisionIterator callback, void *const userDataPtr) Iterate thought polygon of the collision geometry of a body calling the function callback. This function used to be a member of the rigid body, but to making it a member of the collision object provides better low lever display capabilities. The application can still call this function to show the collision of a rigid body by getting the collision and the transformation matrix from the rigid, and then calling this functions. Return Parameters • *collisionPtr : is the pointer to the collision objects. • *matrixPtr : is the pointer to the collision objects. • callback : application define callback • *userDataPtr : pointer to the user defined user data value. This function can be called by the application in order to show the collision geometry. The application should provide a pointer to the function NewtonCollisionIterator, Newton will convert the collision geometry into a polygonal mesh, and will call callback for every polygon of the meshthis function affect severely the perfor- mance of Newton. The application should call this function only for debugging purposeThis function will ignore user define collision mesh See also: NewtonWorldGetFirstBody, NewtonWorldForEachBodyInAABBDo int NewtonCollisionGetType(const NewtonCollision *const collision) int NewtonCollisionIsConvexShape(const NewtonCollision *const collision) int NewtonCollisionIsStaticShape(const NewtonCollision *const collision) void NewtonCollisionSetUserID(const NewtonCollision *const collision, unsigned id) Store a user defined value with a convex collision primitive. the application can store an id with any collision primitive. This id can be used to identify what type of collision primitive generated a contact. Return Parameters • collision : is the pointer to a collision primitive. • id : value to store with the collision primitive. See also: NewtonCollisionGetUserID, NewtonCreateBox, NewtonCreateSphere unsigned NewtonCollisionGetUserID(const NewtonCollision *const collision) Return a user define value with a convex collision primitive. the application can store an id with any collision primitive. This id can be used to identify what type of collision primitive generated a contact. Return id Parameters • collision : is the pointer to a convex collision primitive. See also: NewtonCreateBox, NewtonCreateSphere void NewtonCollisionSetUserData(const NewtonCollision *const collision, void *const userData)

50 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3 void *NewtonCollisionGetUserData(const NewtonCollision *const collision) void NewtonCollisionSetUserData1(const NewtonCollision *const collision, void *const userData) void *NewtonCollisionGetUserData1(const NewtonCollision *const collision) void *NewtonCollisionGetSubCollisionHandle(const NewtonCollision *const collision) NewtonCollision *NewtonCollisionGetParentInstance(const NewtonCollision *const collision) void NewtonCollisionSetMatrix(const NewtonCollision *collision, const dFloat *const matrix) void NewtonCollisionGetMatrix(const NewtonCollision *const collision, dFloat *const matrix) void NewtonCollisionSetScale(const NewtonCollision *const collision, dFloat scaleX, dFloat scaleY, dFloat scaleZ) void NewtonCollisionGetScale(const NewtonCollision *const collision, dFloat *const scaleX, dFloat *const scaleY, dFloat *const scaleZ) void NewtonDestroyCollision(const NewtonCollision *const collisionPtr) Release a reference from this collision object returning control to Newton. to get the correct reference count of a collision primitive the application can call function NewtonCollisionGetInfo Return . Parameters • *collisionPtr : pointer to the collision object NewtonCollision *NewtonCollisionCreateInstance(const NewtonCollision *const collision) void NewtonCollisionSerialize(const NewtonWorld *const newtonWorld, const NewtonCollision *const collision, NewtonSerializeCallback serializeFunction, void *const serializeHandle) Serialize a general collision shape. Small and medium collision shapes like TreeCollision (under 50000 poly- gons) small convex hulls or compude collision can be constructed at application startup without significant processing overhead. Return . Parameters • *newtonWorld : is the pointer to the Newton world. • *collision : is the pointer to the collision tree shape. • serializeFunction : pointer to the event function that will do the serialization. • *serializeHandle : - user data that will be passed to the NewtonSerialize callback. See also: NewtonCollisionGetInfo NewtonCollision *NewtonCreateCollisionFromSerialization(const NewtonWorld *const newtonWorld, NewtonDeserial- izeCallback deserializeFunction, void *const serializeHandle) Create a collision shape via a serialization function. this function is useful to to load collision primitive for and archive file. In the case of complex shapes like convex hull and compound collision the it save a significant amount of construction time. Return . Parameters • *newtonWorld : is the pointer to the Newton world. • deserializeFunction : pointer to the event function that will do the deserialization.

3.8. CollisionLibraryGeneric 51 Newton Dynamics Engine Documentation, Release 3

• *serializeHandle : user data that will be passed to the NewtonSerialize callback. if this function is called to load a serialized tree collision, the tree collision will be loaded, but the function pointer callback will be set to NULL. for this operation see function NewtonCreateTreeCollisionFromSerializationSee also: NewtonCollisionSerialize, NewtonCollisionGetInfo void NewtonCollisionGetInfo(const NewtonCollision *const collision, NewtonCollisionInfoRecord *const collisionInfo) Get creation parameters for this collision objects. This function can be used by the application for writing file format and for serialization. Parameters • collision : is the pointer to a convex collision primitive. • *collisionInfo : pointer to a collision information record. See also: NewtonCollisionGetInfo, NewtonCollisionSerialize

3.9 TransUtil void NewtonGetEulerAngle(const dFloat *const matrix, dFloat *const angles0, dFloat *const angles1) Get the three Euler angles from a 4x4 rotation matrix arranged in row-major order. The motivation for this function is that many graphics engines still use Euler angles to represent the orientation of graphics entities. The angles are expressed in radians and represent: angle[0]* - rotation about first matrix row angle[1]* - rotation about second matrix row angle[2]* - rotation about third matrix row Return . Parameters • matrix : pointer to the 4x4 rotation matrix. • angles0 : - fixme • angles1 : - pointer to an array of at least three floats to hold the Euler angles. See also: NewtonSetEulerAngle void NewtonSetEulerAngle(const dFloat *const angles, dFloat *const matrix) Build a rotation matrix from the Euler angles in radians. The motivation for this function is that many graphics engines still use Euler angles to represent the orientation of graphics entities. The angles are expressed in radians and represent: angle[0]* - rotation about first matrix row angle[1]* - rotation about second matrix row angle[2]* - rotation about third matrix row Return . Parameters • matrix : pointer to the 4x4 rotation matrix. • angles : pointer to an array of at least three floats to hold the Euler angles. See also: NewtonGetEulerAngle dFloat NewtonCalculateSpringDamperAcceleration(dFloat dt, dFloat ks, dFloat x, dFloat kd, dFloat s) Calculates the acceleration to satisfy the specified the spring damper system. return: the spring acceleration. Parameters • dt : integration time step. • ks : spring stiffness, it must be a positive value.

52 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• x : spring position. • kd : desired spring damper, it must be a positive value. • s : spring velocity. the acceleration calculated by this function represent the mass, spring system of the form a = -ks * x - kd * v.

3.10 RigidBodyInterface

NewtonBody *NewtonCreateDynamicBody(const NewtonWorld *const newtonWorld, const Newton- Collision *const collisionPtr, const dFloat *const matrix- Ptr) Create a rigid body. This function creates a Newton rigid body and assigns a collisionPtr as the collision geometry representing the rigid body. This function increments the reference count of the collision geometry. All event functions are set to NULL and the material gruopID of the body is set to the default GroupID. Return to the rigid body. Parameters • *newtonWorld : is the pointer to the Newton world. • *collisionPtr : pointer to the collision object. • *matrixPtr : fixme See also: NewtonDestroyBody NewtonBody *NewtonCreateKinematicBody(const NewtonWorld *const newtonWorld, const Newton- Collision *const collisionPtr, const dFloat *const ma- trixPtr) NewtonBody *NewtonCreateDeformableBody(const NewtonWorld *const newtonWorld, const New- tonCollision *const deformableMesh, const dFloat *const matrixPtr) void NewtonDestroyBody(const NewtonBody *const bodyPtr) Destroy a rigid body. If this function is called from inside a simulation step the destruction of the body will be delayed until end of the time step. This function will decrease the reference count of the collision geometry by one. If the reference count reaches zero, then the collision geometry will be destroyed. This function will destroy all joints associated with this body. Return . Parameters • *bodyPtr : pointer to the body to be destroyed. See also: NewtonCreateDynamicBody int NewtonBodyGetSimulationState(const NewtonBody *const bodyPtr) Gets the current simulation state of the specified body. See also: NewtonBodySetSimulationState Return current simulation state 0: disabled 1: active. Parameters • *bodyPtr : pointer to the body to be inspected. void NewtonBodySetSimulationState(const NewtonBody *const bodyPtr, const int state) Sets the current simulation state of the specified body. See also: NewtonBodyGetSimulationState Return .

3.10. RigidBodyInterface 53 Newton Dynamics Engine Documentation, Release 3

Parameters • *bodyPtr : pointer to the body to be changed. • state : the new simulation state 0: disabled 1: active int NewtonBodyGetCollidable(const NewtonBody *const bodyPtr) void NewtonBodySetCollidable(const NewtonBody *const bodyPtr, int collidable) int NewtonBodyGetType(const NewtonBody *const bodyPtr) int NewtonBodyGetID(const NewtonBody *const bodyPtr) void NewtonBodySetUserData(const NewtonBody *const bodyPtr, void *const userDataPtr) Store a user defined data value with the body. The application can store a user defined value with the Body. This value can be the pointer to a structure containing some application data for special effect. if the application allocate some resource to store the user data, the application can register a joint destructor to get rid of the allocated resource when the body is destroyed Return . Parameters • *bodyPtr : pointer to the body. • *userDataPtr : pointer to the user defined user data value. See also: NewtonBodyGetUserData, NewtonBodySetDestructorCallback void *NewtonBodyGetUserData(const NewtonBody *const bodyPtr) Retrieve a user defined data value stored with the body. The application can store a user defined value with a rigid body. This value can be the pointer to a structure which is the graphical representation of the rigid body. Return user defined data. Parameters • *bodyPtr : pointer to the body. See also: NewtonBodySetUserData NewtonWorld *NewtonBodyGetWorld(const NewtonBody *const bodyPtr) Retrieve get the pointer to the world from the body. The application can use this function to determine what world own this body. If the application have to get the world from a joint, it can do so by getting one of the bodies attached to the joint and getting the world from that body. Return world that own this body. Parameters • *bodyPtr : pointer to the body. void NewtonBodySetTransformCallback(const NewtonBody *const bodyPtr, NewtonSetTransform callback) Assign a transformation event function to the body. The function NewtonSetTransform callback is called by the Newton engine every time a visual object that represents the rigid body has changed. The application can obtain the pointer user data value that points to the visual object. The Newton engine does not call the NewtonSetTransform callback function for bodies that are inactive or have reached a state of stable equilibrium. Return . Parameters • *bodyPtr : pointer to the body.

54 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• callback : pointer to a function callback in used to update the transformation matrix of the visual object that represents the rigid body. The matrix should be organized in row-major order (this is the way directX and OpenGL stores matrices).See also: NewtonBodyGetUserData, NewtonBodyGetUserData NewtonSetTransform NewtonBodyGetTransformCallback(const NewtonBody *const bodyPtr) Assign a transformation event function to the body. The function NewtonSetTransform callback is called by the Newton engine every time a visual object that represents the rigid body has changed. The application can obtain the pointer user data value that points to the visual object. The Newton engine does not call the NewtonSetTransform callback function for bodies that are inactive or have reached a state of stable equilibrium. Return . Parameters • *bodyPtr : pointer to the body. The matrix should be organized in row-major order (this is the way directX and OpenGL stores matrices).See also: NewtonBodyGetUserData, NewtonBodyGetUserData void NewtonBodySetForceAndTorqueCallback(const NewtonBody *const bodyPtr, NewtonApply- ForceAndTorque callback) Assign an event function for applying external force and torque to a rigid body. Before the NewtonApplyForce- AndTorque callback is called for a body, Newton first clears the net force and net torque for the body. Return . Parameters • *bodyPtr : pointer to the body. • callback : pointer to a function callback used to apply force and torque to a rigid body. The function NewtonApplyForceAndTorque callback is called by the Newton Engine every time an active body is going to be simulated. The Newton Engine does not call the NewtonApplyForceAndTorque callback function for bodies that are inactive or have reached a state of stable equilibrium.See also: NewtonBodyGetUserData, NewtonBodyGetUserData, NewtonBodyGetForceAndTorqueCallback NewtonApplyForceAndTorque NewtonBodyGetForceAndTorqueCallback(const NewtonBody *const bodyPtr) Return the pointer to the current force and torque call back function. This function can be used to concatenate different force calculation components making more modular the design of function components dedicated to apply special effect. For example a body may have a basic force a force that only apply the effect of gravity, but that application can place a region in where there can be a fluid volume, or another gravity field. we this function the application can read the correct function and save into a local variable, and set a new one. this new function will firs call the save function pointer and upon return apply the correct effect. this similar to the concept of virtual methods on objected oriented languages. Return to the force call back. Parameters • *bodyPtr : pointer to the body. The function NewtonApplyForceAndTorque callback is called by the Newton Engine every time an active body is going to be simulated. The Newton Engine does not call the NewtonApplyForceAndTorque callback function for bodies that are inactive or have reached a state of stable equilibrium.See also: NewtonBodyGetUserData, NewtonBodyGetUserData, NewtonBodySetForceAndTorqueCallback void NewtonBodySetDestructorCallback(const NewtonBody *const bodyPtr, NewtonBodyDestruc- tor callback) Assign an event function to be called when this body is about to be destroyed. This function NewtonBodyDe-

3.10. RigidBodyInterface 55 Newton Dynamics Engine Documentation, Release 3

structor callback acts like a destruction function in CPP. This function is called when the body and all data joints associated with the body are about to be destroyed. The application could use this function to destroy or release any resource associated with this body. The application should not make reference to this body after this function returns. Return . Parameters • *bodyPtr : pointer to the body to be destroyed. • callback : pointer to a function callback. The destruction of a body will destroy all joints associated with the body.See also: NewtonBodyGetUserData, NewtonBodyGetUserData NewtonBodyDestructor NewtonBodyGetDestructorCallback(const NewtonBody *const bodyPtr) void NewtonBodySetFullMassMatrix(const NewtonBody *const bodyPtr, dFloat mass, const dFloat *const inertiaMatrix) Set the mass matrix of a rigid body. Newton algorithms have no restriction on the values for the mass, but due to floating point dynamic range (24 bit precision) it is best if the ratio between the heaviest and the lightest body in the scene is limited to 200. There are no special utility functions in Newton to calculate the moment of inertia of common primitives. The application should specify the inertial values, keeping in mind that realistic inertia values are necessary for realistic physics behavior. Return . Parameters • *bodyPtr : pointer to the body. • mass : mass value. • inertiaMatrix : fixme See also: NewtonConvexCollisionCalculateInertialMatrix, NewtonBodyGetMass, NewtonBodyGetInvMass void NewtonBodySetMassMatrix(const NewtonBody *const bodyPtr, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz) void NewtonBodySetMassProperties(const NewtonBody *const bodyPtr, dFloat mass, const Newton- Collision *const collisionPtr) void NewtonBodyGetMass(const NewtonBody *const bodyPtr, dFloat *const mass, dFloat *const Ixx, dFloat *const Iyy, dFloat *const Izz) Get the mass matrix of a rigid body. See also: NewtonBodySetMassMatrix, NewtonBodyGetInvMass Return . Parameters • *bodyPtr : pointer to the body. • *mass : pointer to a variable that will hold the mass value of the body. • *Ixx : pointer to a variable that will hold the moment of inertia of the first principal axis of inertia of the body. • *Iyy : pointer to a variable that will hold the moment of inertia of the first principal axis of inertia of the body. • *Izz : pointer to a variable that will hold the moment of inertia of the first principal axis of inertia of the body.

56 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

void NewtonBodyGetInvMass(const NewtonBody *const bodyPtr, dFloat *const invMass, dFloat *const invIxx, dFloat *const invIyy, dFloat *const invIzz) Get the inverse mass matrix of a rigid body. See also: NewtonBodySetMassMatrix, NewtonBodyGetMass Return . Parameters • *bodyPtr : pointer to the body. • *invMass : pointer to a variable that will hold the mass inverse value of the body. • *invIxx : pointer to a variable that will hold the moment of inertia inverse of the first principal axis of inertia of the body. • *invIyy : pointer to a variable that will hold the moment of inertia inverse of the first principal axis of inertia of the body. • *invIzz : pointer to a variable that will hold the moment of inertia inverse of the first principal axis of inertia of the body. void NewtonBodyGetInertiaMatrix(const NewtonBody *const bodyPtr, dFloat *const inertiaMatrix) void NewtonBodyGetInvInertiaMatrix(const NewtonBody *const bodyPtr, dFloat *const invInertia- Matrix) void NewtonBodySetMatrix(const NewtonBody *const bodyPtr, const dFloat *const matrixPtr) Set the transformation matrix of a rigid body. The matrix should be arranged in row-major order. If you are using OpenGL matrices (column-major) you will need to transpose you matrices into a local array, before passing them to Newton. Return . Parameters • *bodyPtr : pointer to the body. • *matrixPtr : pointer to an array of 16 floats containing the global matrix of the rigid body. That application should make sure the transformation matrix has not scale, otherwise unpredictable result will occur.See also: NewtonBodyGetMatrix void NewtonBodySetMatrixNoSleep(const NewtonBody *const bodyPtr, const dFloat *const matrix- Ptr) void NewtonBodySetMatrixRecursive(const NewtonBody *const bodyPtr, const dFloat *const ma- trixPtr) Apply hierarchical transformation to a body. This function applies the transformation matrix to the body and also applies the appropriate transformation matrix to set of articulated bodies. If the body is in contact with another body the other body is not transformed. Return . Parameters • *bodyPtr : pointer to the body. • *matrixPtr : pointer to an array of 16 floats containing the global matrix of the rigid body. this function should not be used to transform set of articulated bodies that are connected to a static body. doing so will result in unpredictables results. Think for example moving a chain attached to a ceiling from one place to another, to do that in real life a person first need to disconnect the chain (destroy the joint), move the chain (apply the transformation to the entire chain), the reconnect it in the new position (recreate the joint again).this function will set to zero the linear and angular velocity of all bodies that are part of the set of articulated body array.The matrix should be arranged in row-major order (this is the way direct x stores matrices). If you

3.10. RigidBodyInterface 57 Newton Dynamics Engine Documentation, Release 3

are using OpenGL matrices (column-major) you will need to transpose you matrices into a local array, before passing them to Newton.See also: NewtonBodySetMatrix void NewtonBodyGetMatrix(const NewtonBody *const bodyPtr, dFloat *const matrixPtr) Get the transformation matrix of a rigid body. The matrix should be arranged in row-major order (this is the way direct x stores matrices). If you are using OpenGL matrices (column-major) you will need to transpose you matrices into a local array, before passing them to Newton. Return . Parameters • *bodyPtr : pointer to the body. • *matrixPtr : pointer to an array of 16 floats that will hold the global matrix of the rigid body. See also: NewtonBodySetMatrix, NewtonBodyGetRotation void NewtonBodyGetPosition(const NewtonBody *const bodyPtr, dFloat *const posPtr) void NewtonBodyGetRotation(const NewtonBody *const bodyPtr, dFloat *const rotPtr) Get the rotation part of the transformation matrix of a body, in form of a unit quaternion. The rotation matrix is written set in the form of a unit quaternion in the format Rot (q0, q1, q1, q3) Return . Parameters • *bodyPtr : pointer to the body. • *rotPtr : pointer to an array of 4 floats that will hold the global rotation of the rigid body. The rotation quaternion is the same as what the application would get by using at function to extract a quater- nion form a matrix. however since the rigid body already contained the rotation in it, it is more efficient to just call this function avoiding expensive conversion.this function could be very useful for the implementation of pseudo frame rate independent simulation. by running the simulation at a fix rate and using linear inter- polation between the last two simulation frames. to determine the exact fraction of the render step.See also: NewtonBodySetMatrix, NewtonBodyGetMatrix void NewtonBodySetForce(const NewtonBody *const bodyPtr, const dFloat *const vectorPtr) Set the net force applied to a rigid body. This function is only effective when called from NewtonApplyForce- AndTorque callback Return . Parameters • *bodyPtr : pointer to the body. • *vectorPtr : pointer to an array of 3 floats containing the net force to be applied to the body. See also: NewtonBodyAddForce, NewtonBodyGetForce, NewtonBodyGetForceAcc void NewtonBodyAddForce(const NewtonBody *const bodyPtr, const dFloat *const vectorPtr) Add the net force applied to a rigid body. This function is only effective when called from NewtonApplyForce- AndTorque callback Return . Parameters • *bodyPtr : pointer to the body to be destroyed. • *vectorPtr : pointer to an array of 3 floats containing the net force to be applied to the body. See also: NewtonBodySetForce, NewtonBodyGetForce, NewtonBodyGetForceAcc

58 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

void NewtonBodyGetForceAcc(const NewtonBody *const bodyPtr, dFloat *const vectorPtr) Get the force applied on the last call to apply force and torque callback. this function can be useful to modify force from joint callback Parameters • *bodyPtr : pointer to the body. • *vectorPtr : pointer to an array of 3 floats to hold the net force of the body. See also: NewtonBodyAddForce, NewtonBodyGetForce, NewtonBodyGetForce Return . void NewtonBodyGetForce(const NewtonBody *const bodyPtr, dFloat *const vectorPtr) Get the net force applied to a rigid body after the last NewtonUpdate. See also: NewtonBodyAddForce, Newton- BodyGetForce, NewtonBodyGetForceAcc Return . Parameters • *bodyPtr : pointer to the body. • *vectorPtr : pointer to an array of 3 floats to hold the net force of the body. void NewtonBodyCalculateInverseDynamicsForce(const NewtonBody *const bodyPtr, dFloat timestep, const dFloat *const desiredVeloc, dFloat *const forceOut) Calculate the next force that net to be applied to the body to archive the desired velocity in the current time step. this function can be useful when creating object for game play. Parameters • *bodyPtr : pointer to the body. • timestep : time step that the force will be applyed. • *desiredVeloc : pointer to an array of 3 floats containing the desired velocity. • *forceOut : pointer to an array of 3 floats to hold the calculated net force. this treat the body as a point mass and is uses the solver to calculates the net force that need to be applied to the body such that is reach the desired velocity in the net time step. In general the force should be calculated by the expression f = M * (dsiredVeloc - bodyVeloc) / timestep however due to algorithmic optimization and limitations if such equation is used then the solver will generate a different desired velocity. See also: NewtonBodySetForce, NewtonBodyAddForce, NewtonBodyGetForce, NewtonBodyGetForceAcc Return . void NewtonBodySetTorque(const NewtonBody *const bodyPtr, const dFloat *const vectorPtr) Set the net torque applied to a rigid body. This function is only effective when called from NewtonApplyForce- AndTorque callback Return . Parameters • *bodyPtr : pointer to the body. • *vectorPtr : pointer to an array of 3 floats containing the net torque to be applied to the body. See also: NewtonBodyAddTorque, NewtonBodyGetTorque, NewtonBodyGetTorqueAcc void NewtonBodyAddTorque(const NewtonBody *const bodyPtr, const dFloat *const vectorPtr) Add the net torque applied to a rigid body. This function is only effective when called from NewtonApplyForce- AndTorque callback

3.10. RigidBodyInterface 59 Newton Dynamics Engine Documentation, Release 3

Return . Parameters • *bodyPtr : pointer to the body. • *vectorPtr : pointer to an array of 3 floats containing the net torque to be applied to the body. See also: NewtonBodySetTorque, NewtonBodyGetTorque, NewtonBodyGetTorqueAcc void NewtonBodyGetTorque(const NewtonBody *const bodyPtr, dFloat *const vectorPtr) Get the net torque applied to a rigid body after the last NewtonUpdate. See also: NewtonBodyAddTorque, NewtonBodyGetTorque, NewtonBodyGetTorqueAcc Return . Parameters • *bodyPtr : pointer to the body. • *vectorPtr : pointer to an array of 3 floats to hold the net torque of the body. void NewtonBodyGetTorqueAcc(const NewtonBody *const bodyPtr, dFloat *const vectorPtr) Get the torque applied on the last call to apply force and torque callback. this function can be useful to modify torque form joint callback Parameters • *bodyPtr : pointer to the body. • *vectorPtr : pointer to an array of 3 floats to hold the net force of the body. See also: NewtonBodyAddTorque, NewtonBodyGetTorque, NewtonBodyGetTorque Return . void NewtonBodySetCentreOfMass(const NewtonBody *const bodyPtr, const dFloat *const comPtr) Set the relative position of the center of mass of a rigid body. This function can be used to set the relative offset of the center of mass of a rigid body. when a rigid body is created the center of mass is set the the point c(0, 0, 0), and normally this is the best setting for a rigid body. However the are situations in which and object does not have symmetry or simple some kind of special effect is desired, and this origin need to be changed. Return . Parameters • *bodyPtr : pointer to the body. • *comPtr : pointer to an array of 3 floats containing the relative offset of the center of mass of the body. Care must be taken when offsetting the center of mass of a body. The application must make sure that the exter- nal torques resulting from forces applied at at point relative to the center of mass are calculated appropriately. this could be done Transform and Torque callback function as the follow pseudo code fragment shows:Matrix matrix; Vector center;NewtonGatMetrix(body, matrix) NewtonGetCentreOfMass(body, center);for global space torque. Vector localForce (fx, fy, fz); Vector localPosition (x, y, z); Vector localTroque (crossproduct ((localPo- sition - center). localForce); Vector globalTroque (matrix.RotateVector (localTroque));for global space torque. Vector globalCentre (matrix.TranformVector (center)); Vector globalPosition (x, y, z); Vector globalForce (fx, fy, fz); Vector globalTroque (crossproduct ((globalPosition - globalCentre). globalForce);See also: NewtonCon- vexCollisionCalculateInertialMatrix, NewtonBodyGetCentreOfMass void NewtonBodyGetCentreOfMass(const NewtonBody *const bodyPtr, dFloat *const comPtr) Get the relative position of the center of mass of a rigid body. This function can be used to set the relative offset of the center of mass of a rigid body. when a rigid body is created the center of mass is set the the point c(0, 0,

60 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

0), and normally this is the best setting for a rigid body. However the are situations in which and object does not have symmetry or simple some kind of special effect is desired, and this origin need to be changed. Return . Parameters • *bodyPtr : pointer to the body. • *comPtr : pointer to an array of 3 floats to hold the relative offset of the center of mass of the body. This function can be used in conjunction with NewtonConvexCollisionCalculateInertialMatrixSee also: New- tonConvexCollisionCalculateInertialMatrix, NewtonBodySetCentreOfMass NewtonJoint *NewtonBodyGetFirstJoint(const NewtonBody *const bodyPtr) Return a pointer to the first joint attached to this rigid body. this function will only return the pointer to user defined joints, older build in constraints will be skipped by this function. Return if at least one is attached to the body, NULL if not joint is attached Parameters • *bodyPtr : pointer to the body. this function can be used to implement recursive walk of complex articulated arrangement of rodid bodies.See also: NewtonBodyGetNextJoint NewtonJoint *NewtonBodyGetNextJoint(const NewtonBody *const bodyPtr, const NewtonJoint *const jointPtr) Return a pointer to the next joint attached to this body. this function will only return the pointer to User defined joint, older build in constraints will be skipped by this function. Return is at least one joint is attached to the body, NULL if not joint is attached Parameters • *bodyPtr : pointer to the body. • *jointPtr : pointer to current joint. this function can be used to implement recursive walk of complex articulated arrangement of rodid bodies.See also: NewtonBodyGetFirstJoint NewtonJoint *NewtonBodyGetFirstContactJoint(const NewtonBody *const bodyPtr) Return a pointer to the first contact joint attached to this rigid body. See also: NewtonBodyGetNextContactJoint, NewtonContactJointGetFirstContact, NewtonContactJointGetNextContact, NewtonContactJointRemoveCon- tact Return if the body is colliding with anther body, NULL otherwise Parameters • *bodyPtr : pointer to the body. NewtonJoint *NewtonBodyGetNextContactJoint(const NewtonBody *const bodyPtr, const Newton- Joint *const contactPtr) Return a pointer to the next contact joint attached to this rigid body. See also: NewtonBodyGetFirst- ContactJoint, NewtonContactJointGetFirstContact, NewtonContactJointGetNextContact, NewtonContactJoin- tRemoveContact Return if the body is colliding with anther body, NULL otherwise Parameters • *bodyPtr : pointer to the body. • *contactPtr : pointer to corrent contact joint.

3.10. RigidBodyInterface 61 Newton Dynamics Engine Documentation, Release 3

NewtonSkeletonContainer *NewtonBodyGetSkeleton(const NewtonBody *const bodyPtr) int NewtonJointIsActive(const NewtonJoint *const jointPtr) int NewtonContactJointGetContactCount(const NewtonJoint *const contactJoint) Return to number of contact in this contact joint. See also: NewtonContactJointGetFirstContact, NewtonCon- tactJointGetNextContact, NewtonContactJointRemoveContact Return of contacts. Parameters • *contactJoint : pointer to corrent contact joint. void *NewtonContactJointGetFirstContact(const NewtonJoint *const contactJoint) Return to pointer to the first contact from the contact array of the contact joint. See also: NewtonContactJoint- GetNextContact, NewtonContactGetMaterial, NewtonContactJointRemoveContact Return pointer to the first contact from the contact array, NULL if no contacts exist Parameters • *contactJoint : pointer to a contact joint. void *NewtonContactJointGetNextContact(const NewtonJoint *const contactJoint, void *const contact) Return a pointer to the next contact from the contact array of the contact joint. See also: NewtonContactJoint- GetFirstContact, NewtonContactGetMaterial, NewtonContactJointRemoveContact Return pointer to the next contact in the contact array, NULL if no contacts exist. Parameters • *contactJoint : pointer to a contact joint. • *contact : pointer to current contact. void NewtonContactJointRemoveContact(const NewtonJoint *const contactJoint, void *const con- tact) Return to the next contact from the contact array of the contact joint. See also: NewtonBodyGetFirst- ContactJoint, NewtonBodyGetNextContactJoint, NewtonContactJointGetFirstContact, NewtonContactJoint- GetNextContact Return contact contact array of the joint contact exist, NULL otherwise Parameters • *contactJoint : pointer to corrent contact joint. • *contact : pointer to current contact. dFloat NewtonContactJointGetClosestDistance(const NewtonJoint *const contactJoint) NewtonMaterial *NewtonContactGetMaterial(const void *const contact) Return to the next contact from the contact array of the contact joint. See also: NewtonContactJointGetFirst- Contact, NewtonContactJointGetNextContact Return contact contact array of the joint contact exist, NULL otherwise Parameters • *contact : pointer to current contact. NewtonCollision *NewtonContactGetCollision0(const void *const contact) NewtonCollision *NewtonContactGetCollision1(const void *const contact) void *NewtonContactGetCollisionID0(const void *const contact)

62 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

void *NewtonContactGetCollisionID1(const void *const contact) void NewtonBodySetCollision(const NewtonBody *const bodyPtr, const NewtonCollision *const col- lisionPtr) Assign a collision primitive to the body. This function replaces a collision geometry of a body with the new collision geometry. This function increments the reference count of the collision geometry and decrements the reference count of the old collision geometry. If the reference count of the old collision geometry reaches zero, the old collision geometry is destroyed. This function can be used to swap the collision geometry of bodies at runtime. Return . Parameters • *bodyPtr : pointer to the body. • *collisionPtr : pointer to the new collision geometry. See also: NewtonCreateDynamicBody, NewtonBodyGetCollision void NewtonBodySetCollisionScale(const NewtonBody *const bodyPtr, dFloat scaleX, dFloat sca- leY, dFloat scaleZ) NewtonCollision *NewtonBodyGetCollision(const NewtonBody *const bodyPtr) Get the collision primitive of a body. This function does not increment the reference count of the collision geometry. Return to body collision geometry. Parameters • *bodyPtr : pointer to the body. See also: NewtonCreateDynamicBody, NewtonBodySetCollision void NewtonBodySetMaterialGroupID(const NewtonBody *const bodyPtr, int id) Assign a material group id to the body. When the application creates a body, the default material group, default- GroupId, is applied by default. Return . Parameters • *bodyPtr : pointer to the body. • id : id of a previously created material group. See also: NewtonBodyGetMaterialGroupID, NewtonMaterialCreateGroupID, NewtonMaterialGetDefault- GroupID int NewtonBodyGetMaterialGroupID(const NewtonBody *const bodyPtr) Get the material group id of the body. See also: NewtonBodySetMaterialGroupID Return . Parameters • *bodyPtr : pointer to the body. void NewtonBodySetContinuousCollisionMode(const NewtonBody *const bodyPtr, unsigned state) Set the continuous collision state mode for this rigid body. continuous collision flag is off by default in when bodies are created. continuous collision mode enable allow the engine to predict colliding contact on rigid bodies Moving at high speed of subject to strong forces. Return .

3.10. RigidBodyInterface 63 Newton Dynamics Engine Documentation, Release 3

Parameters • *bodyPtr : pointer to the body. • state : collision state. 1 indicates this body may tunnel through other objects while moving at high speed. 0 ignore high speed collision checks. continuous collision mode does not prevent rigid bodies from inter penetration instead it prevent bodies from passing trough each others by extrapolating contact points when the bodies normal contact calculation determine the bodies are not colliding.for performance reason the bodies angular velocities is only use on the broad face of the collision, but not on the contact calculation.continuous collision does not perform back tracking to determine time of contact, instead it extrapolate contact by incrementally extruding the collision geometries of the two colliding bodies along the linear velocity of the bodies during the time step, if during the extrusion colliding contact are found, a collision is declared and the normal contact resolution is called.for continuous collision to be active the continuous collision mode must on the material pair of the colliding bodies as well as on at least one of the two colliding bodies.Because there is penalty of about 40% to 80% depending of the shape complexity of the collision geometry, this feature is set off by default. It is the job of the application to determine what bodies need this feature on. Good guidelines are: very small objects, and bodies that move a height speed.See also: NewtonBodyGetContinuousCollisionMode, NewtonBodySetContinuousCollisionMode int NewtonBodyGetContinuousCollisionMode(const NewtonBody *const bodyPtr) Get the continuous collision state mode for this rigid body. Because there is there is penalty of about 3 to 5 depending of the shape complexity of the collision geometry, this feature is set off by default. It is the job of the application to determine what bodies need this feature on. Good guidelines are: very small objects, and bodies that move a height speed. Return . Parameters • *bodyPtr : pointer to the body. this feature is currently disabled:See also: NewtonBodySetContinuousCollisionMode, NewtonBodySetContinu- ousCollisionMode void NewtonBodySetJointRecursiveCollision(const NewtonBody *const bodyPtr, unsigned state) Set the collision state flag of this body when the body is connected to another body by a hierarchy of joints. sometimes when making complicated arrangements of linked bodies it is possible the collision geometry of these bodies is in the way of the joints work space. This could be a problem for the normal operation of the joints. When this situation happens the application can determine which bodies are the problem and disable collision for those bodies while they are linked by joints. For the collision to be disable for a pair of body, both bodies must have the collision disabled. If the joints connecting the bodies are destroyed these bodies become collidable automatically. This feature can also be achieved by making special material for the whole configuration of jointed bodies, however it is a lot easier just to set collision disable for jointed bodies. Return . Parameters • *bodyPtr : pointer to the body. • state : collision state. 1 indicates this body will collide with any linked body. 0 disable collision with body connected to this one by joints. See also: NewtonBodySetMaterialGroupID int NewtonBodyGetJointRecursiveCollision(const NewtonBody *const bodyPtr) Get the collision state flag when the body is joint. See also: NewtonBodySetMaterialGroupID Return the collision state flag for this body. Parameters

64 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• *bodyPtr : pointer to the body. dFloat NewtonBodyGetMaxRotationPerStep(const NewtonBody *const bodyPtr) void NewtonBodySetMaxRotationPerStep(const NewtonBody *const bodyPtr, dFloat angleInRadi- ans) int NewtonBodyGetFreezeState(const NewtonBody *const bodyPtr) get the freeze state of this body When a body is created it is automatically placed in the active simulation list. As an optimization for large scenes, you may use this function to put background bodies in an inactive equilibrium state. Return 1 id the bode is frozen, 0 if bode is unfrozen. Parameters • *bodyPtr : is the pointer to the body to be frozen This function tells Newton that this body does not currently need to be simulated. However, if the body is part of a larger configuration it may be affected indirectly by the reaction forces of objects that it is connected to.See also: NewtonBodySetAutoSleep, NewtonBodyGetAutoSleep void NewtonBodySetFreezeState(const NewtonBody *const bodyPtr, int state) This function tells Newton to simulate or suspend simulation of this body and all other bodies in contact with it This function to no activate the body, is just lock or unlock the body for physics simulation. Return Parameters • *bodyPtr : is the pointer to the body to be activated • state : 1 teels newton to freeze the bode and allconceted bodiesm, 0 to unfreze it See also: NewtonBodyGetFreezeState, NewtonBodySetAutoSleep, NewtonBodyGetAutoSleep void NewtonBodySetAutoSleep(const NewtonBody *const bodyPtr, int state) Set the auto-activation mode for this body. Bodies are created with auto-activation on by default. Return . Parameters • *bodyPtr : is the pointer to the body. • state : active mode: 1 = auto-activation on (controlled by Newton). 0 = auto-activation off and body is active all the time. Auto activation enabled is the default state for the majority of bodies in a large scene. However, for player control, ai control or some other special circumstance, the application may want to control the acti- vation/deactivation of the body. In that case, the application may call NewtonBodySetAutoSleep (body, 0) fol- lowed by NewtonBodySetFreezeState(body), this will make the body active forever.See also: NewtonBodyGet- FreezeState, NewtonBodySetFreezeState, NewtonBodyGetAutoSleep int NewtonBodyGetAutoSleep(const NewtonBody *const bodyPtr) Get the auto-activation state of the body. See also: NewtonBodySetAutoSleep, NewtonBodyGetSleepState Return activation state: 1 = auto-activation on. 0 = auto-activation off. Parameters • *bodyPtr : is the pointer to the body. int NewtonBodyGetSleepState(const NewtonBody *const bodyPtr) Return the sleep mode of a rigid body. See also: NewtonBodySetAutoSleep Return state: 1 = active. 0 = sleeping.

3.10. RigidBodyInterface 65 Newton Dynamics Engine Documentation, Release 3

Parameters • *bodyPtr : is the pointer to the body. void NewtonBodySetSleepState(const NewtonBody *const bodyPtr, int state) void NewtonBodyGetAABB(const NewtonBody *const bodyPtr, dFloat *const p0, dFloat *const p1) Get the world axis aligned bounding box (AABB) of the body. Parameters • *bodyPtr : is the pointer to the body. • *p0 : - pointer to an array of at least three floats to hold minimum value for the AABB. • *p1 : - pointer to an array of at least three floats to hold maximum value for the AABB. void NewtonBodySetVelocity(const NewtonBody *const bodyPtr, const dFloat *const velocity) Set the global linear velocity of the body. See also: NewtonBodyGetVelocity Parameters • *bodyPtr : is the pointer to the body. • *velocity : pointer to an array of at least three floats containing the velocity vector. void NewtonBodySetVelocityNoSleep(const NewtonBody *const bodyPtr, const dFloat *const ve- locity) void NewtonBodyGetVelocity(const NewtonBody *const bodyPtr, dFloat *const velocity) Get the global linear velocity of the body. See also: NewtonBodySetVelocity Parameters • *bodyPtr : is the pointer to the body. • *velocity : pointer to an array of at least three floats to hold the velocity vector. void NewtonBodySetOmega(const NewtonBody *const bodyPtr, const dFloat *const omega) Set the global angular velocity of the body. See also: NewtonBodyGetOmega Parameters • *bodyPtr : is the pointer to the body. • *omega : pointer to an array of at least three floats containing the angular velocity vector. void NewtonBodySetOmegaNoSleep(const NewtonBody *const bodyPtr, const dFloat *const omega) void NewtonBodyGetOmega(const NewtonBody *const bodyPtr, dFloat *const omega) Get the global angular velocity of the body. See also: NewtonBodySetOmega Parameters • *bodyPtr : is the pointer to the body • *omega : pointer to an array of at least three floats to hold the angular velocity vector. void NewtonBodySetLinearDamping(const NewtonBody *const bodyPtr, dFloat linearDamp) Apply the linear viscous damping coefficient to the body. the default value of linearDamp is clamped to a value between 0.0 and 1.0; the default value is 0.1, There is a non zero implicit attenuation value of 0.0001 assume by the integrator. Parameters • *bodyPtr : is the pointer to the body. • linearDamp : linear damping coefficient.

66 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

The dampening viscous friction force is added to the external force applied to the body every frame before going to the solver-integrator. This force is proportional to the square of the magnitude of the velocity to the body in the opposite direction of the velocity of the body. An application can set linearDamp to zero when the application takes control of the external forces and torque applied to the body, should the application desire to have absolute control of the forces over that body. However, it is recommended that the linearDamp coefficient is set to a non-zero value for the majority of background bodies. This saves the application from having to control these forces and also prevents the integrator from adding very large velocities to a body.See also: NewtonBodyGetLinearDamping dFloat NewtonBodyGetLinearDamping(const NewtonBody *const bodyPtr) Get the linear viscous damping of the body. See also: NewtonBodySetLinearDamping Return linear damping coefficient. Parameters • *bodyPtr : is the pointer to the body. void NewtonBodySetAngularDamping(const NewtonBody *const bodyPtr, const dFloat *angular- Damp) Apply the angular viscous damping coefficient to the body. the default value of angularDamp is clamped to a value between 0.0 and 1.0; the default value is 0.1, There is a non zero implicit attenuation value of 0.0001 assumed by the integrator. Parameters • *bodyPtr : is the pointer to the body. • *angularDamp : pointer to an array of at least three floats containing the angular damping coeffi- cients for the principal axis of the body. The dampening viscous friction torque is added to the external torque applied to the body every frame before going to the solver-integrator. This torque is proportional to the square of the magnitude of the angular velocity to the body in the opposite direction of the angular velocity of the body. An application can set angularDamp to zero when the to take control of the external forces and torque applied to the body, should the application desire to have absolute control of the forces over that body. However, it is recommended that the linearDamp coefficient be set to a non-zero value for the majority of background bodies. This saves the application from needing to control these forces and also prevents the integrator from adding very large velocities to a body.See also: NewtonBodyGetAngularDamping void NewtonBodyGetAngularDamping(const NewtonBody *const bodyPtr, dFloat *angularDamp) Get the linear viscous damping of the body. See also: NewtonBodySetAngularDamping Parameters • *bodyPtr : is the pointer to the body. • *angularDamp : pointer to an array of at least three floats to hold the angular damping coefficient for the principal axis of the body. void NewtonBodyGetPointVelocity(const NewtonBody *const bodyPtr, const dFloat *const point, dFloat *const velocOut) void NewtonBodyAddImpulse(const NewtonBody *const bodyPtr, const dFloat *const pointDeltaVeloc, const dFloat *const pointPosit) Add an impulse to a specific point on a body. This function will activate the body. Return . Parameters • *bodyPtr : is the pointer to the body.

3.10. RigidBodyInterface 67 Newton Dynamics Engine Documentation, Release 3

• pointDeltaVeloc : pointer to an array of at least three floats containing the desired change in velocity to point pointPosit. • pointPosit : - pointer to an array of at least three floats containing the center of the impulse in global space. pointPosit* and pointDeltaVeloc must be specified in global space.pointDeltaVeloc* represent a change in ve- locity. For example, a value of pointDeltaVeloc of (1, 0, 0) changes the velocity of bodyPtr in such a way that the velocity of point pointDeltaVeloc will increase by (1, 0, 0)Because pointDeltaVeloc represents a change in velocity, this function must be used with care. Repeated calls to this function will result in an increase of the velocity of the body and may cause to integrator to lose stability. void NewtonBodyApplyImpulseArray(const NewtonBody *const bodyPtr, int impulseCount, int strideInByte, const dFloat *const impulseArray, const dFloat *const pointArray) Add an train of impulses to a specific point on a body. This function will activate the body. Return . Parameters • *bodyPtr : is the pointer to the body. • impulseCount : - number of impulses and distances in the array distance • strideInByte : - sized in bytes of vector impulse and • impulseArray : pointer to an array containing the desired impulse to apply ate psoition pointarray. • pointArray : pointer to an array of at least three floats containing the center of the impulse in global space. pointPosit* and pointDeltaVeloc must be specified in global space.this function apply at general impulse to a body a oppose to a desired change on velocity this mean that the body mass, and Inertia will determine the gain on velocity. void NewtonBodyApplyImpulsePair(const NewtonBody *const bodyPtr, dFloat *const linearImpulse, dFloat *const angularImpulse) void NewtonBodyIntegrateVelocity(const NewtonBody *const bodyPtr, dFloat timestep)

3.11 ConstraintBall

NewtonJoint *NewtonConstraintCreateBall(const NewtonWorld *const newtonWorld, const dFloat *pivotPoint, const NewtonBody *const childBody, const NewtonBody *const parentBody) Create a ball an socket joint. This function creates a ball and socket and add it to the world. By default joint disables collision with the linked bodies. Return to the ball and socket joint. Parameters • *newtonWorld : is the pointer to the Newton world. • *pivotPoint : is origin of ball and socket in global space. • *childBody : is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. • *parentBody : is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body.

68 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3 void NewtonBallSetConeLimits(const NewtonJoint *const ball, const dFloat *pin, dFloat maxConeAn- gle, dFloat maxTwistAngle) Set the ball and socket cone and twist limits. limits are disabled at creation time. A value of zero for max- ConeAngle disable the cone limit, a value of zero for maxTwistAngle disable the twist limit all non-zero value for maxConeAngle are clamped between 5 degree and 175 degrees Parameters • *ball : is the pointer to a ball and socket joint. • *pin : pointer to a unit vector defining the cone axis in global space. • maxConeAngle : max angle in radians the attached body is allow to swing relative to the pin axis, a value of zero will disable this limits. • maxTwistAngle : max angle in radians the attached body is allow to twist relative to the pin axis, a value of zero will disable this limits. See also: NewtonConstraintCreateBall void NewtonBallSetUserCallback(const NewtonJoint *const ball, NewtonBallCallback callback) Set an update call back to be called when either of the two bodies linked by the joint is active. if the application wants to have some feedback from the joint simulation, the application can register a function update callback to be called every time any of the bodies linked by this joint is active. This is useful to provide special effects like particles, sound or even to simulate breakable moving parts. Return . Parameters • *ball : pointer to the joint. • callback : pointer to the joint function call back. See also: NewtonJointSetUserData void NewtonBallGetJointAngle(const NewtonJoint *const ball, dFloat *angle) Get the relative joint angle between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play a bell sound when the joint angle passes some max value. Return . Parameters • *ball : pointer to the joint. • *angle : pointer to an array of a least three floats to hold the joint relative Euler angles. See also: NewtonBallSetUserCallback void NewtonBallGetJointOmega(const NewtonJoint *const ball, dFloat *omega) Get the relative joint angular velocity between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play the creaky noise of a hanging lamp. Return . Parameters • *ball : pointer to the joint. • *omega : pointer to an array of a least three floats to hold the joint relative angular velocity. See also: NewtonBallSetUserCallback

3.11. ConstraintBall 69 Newton Dynamics Engine Documentation, Release 3

void NewtonBallGetJointForce(const NewtonJoint *const ball, dFloat *const force) Get the total force asserted over the joint pivot point, to maintain the constraint. this function can be used during a function update call back to provide the application with some special effect. for example the application can destroy the joint if the force exceeds some predefined value. Return . Parameters • *ball : pointer to the joint. • *force : pointer to an array of a least three floats to hold the force value of the joint. See also: NewtonBallSetUserCallback

3.12 JointHinge

3.13 JointSlider

NewtonJoint *NewtonConstraintCreateSlider(const NewtonWorld *const newtonWorld, const dFloat *pivotPoint, const dFloat *pinDir, const NewtonBody *const childBody, const NewtonBody *const parentBody) Create a slider joint. This function creates a slider and add it to the world. By default joint disables collision with the linked bodies. Return to the slider joint. Parameters • *newtonWorld : is the pointer to the Newton world. • *pivotPoint : is origin of the slider in global space. • *pinDir : is the line of action of the slider in global space. • *childBody : is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. • *parentBody : is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. void NewtonSliderSetUserCallback(const NewtonJoint *const slider, NewtonSliderCallback call- back) Set an update call back to be called when either of the two body linked by the joint is active. if the application wants to have some feedback from the joint simulation, the application can register a function update callback to be call every time any of the bodies linked by this joint is active. This is useful to provide special effects like particles, sound or even to simulate breakable moving parts. Return . Parameters • *slider : pointer to the joint. • callback : pointer to the joint function call back. See also: NewtonJointGetUserData, NewtonJointSetUserData

70 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3 dFloat NewtonSliderGetJointPosit(const NewtonJoint *Slider) Get the relative joint angle between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play a bell sound when the joint angle passes some max value. Return joint angle relative to the hinge pin. Parameters • *Slider : pointer to the joint. See also: NewtonSliderSetUserCallback dFloat NewtonSliderGetJointVeloc(const NewtonJoint *Slider) Get the relative joint angular velocity between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play the creaky noise of a hanging lamp. Return joint angular velocity relative to the pin axis. Parameters • *Slider : pointer to the joint. See also: NewtonSliderSetUserCallback dFloat NewtonSliderCalculateStopAccel(const NewtonJoint *const slider, const NewtonHingeS- liderUpdateDesc *const desc, dFloat distance) Calculate the angular acceleration needed to stop the slider at the desired angle. fixme: inconsistent variable capitalisation; some functions use “slider”, others “Slider”. Parameters • *slider : pointer to the joint. • *desc : is the pointer to the Slider or slide structure. • distance : desired stop distance relative to the pivot point this function can only be called from a NewtonSliderCallback and it can be used by the application to implement slider limits. Return relative linear acceleration needed to stop the slider. See also: NewtonSliderSetUserCallback void NewtonSliderGetJointForce(const NewtonJoint *const slider, dFloat *const force) Get the total force asserted over the joint pivot point, to maintain the constraint. this function can be used during a function update call back to provide the application with some special effect. for example the application can destroy the joint if the force exceeds some predefined value. Return . Parameters • *slider : pointer to the joint. • *force : pointer to an array of a least three floats to hold the force value of the joint. See also: NewtonSliderSetUserCallback

3.13. JointSlider 71 Newton Dynamics Engine Documentation, Release 3

3.14 JointCorkscrew

NewtonJoint *NewtonConstraintCreateCorkscrew(const NewtonWorld *const newtonWorld, const dFloat *pivotPoint, const dFloat *pinDir, const NewtonBody *const childBody, const Newton- Body *const parentBody) Create a corkscrew joint. This function creates a corkscrew and add it to the world. By default joint disables collision with the linked bodies. Return to the corkscrew joint. Parameters • *newtonWorld : is the pointer to the Newton world. • *pivotPoint : is origin of the corkscrew in global space. • *pinDir : is the line of action of the corkscrew in global space. • *childBody : is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. • *parentBody : is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. void NewtonCorkscrewSetUserCallback(const NewtonJoint *const corkscrew, NewtonCorkscrew- Callback callback) Set an update call back to be called when either of the two body linked by the joint is active. if the application wants to have some feedback from the joint simulation, the application can register a function update callback to be call every time any of the bodies linked by this joint is active. This is useful to provide special effects like particles, sound or even to simulate breakable moving parts. Return . Parameters • *corkscrew : pointer to the joint. • callback : pointer to the joint function call back. the function NewtonCorkscrewCallback callback should return a bit field code. if the application does not want to set the joint acceleration the return code is zero if the application only wants to change the joint linear acceleration the return code is 1 if the application only wants to change the joint angular acceleration the return code is 2 if the application only wants to change the joint angular and linear acceleration the return code is 3See also: NewtonJointGetUserData, NewtonJointSetUserData dFloat NewtonCorkscrewGetJointPosit(const NewtonJoint *const corkscrew) Get the relative joint angle between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play a bell sound when the joint angle passes some max value. Return joint angle relative to the hinge pin. Parameters • *corkscrew : pointer to the joint. See also: NewtonCorkscrewSetUserCallback dFloat NewtonCorkscrewGetJointVeloc(const NewtonJoint *const corkscrew) Get the relative joint angular velocity between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play the creaky noise of a hanging lamp.

72 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

Return joint angular velocity relative to the pin axis. Parameters • *corkscrew : pointer to the joint. See also: NewtonCorkscrewSetUserCallback dFloat NewtonCorkscrewGetJointAngle(const NewtonJoint *const corkscrew) Get the relative joint angle between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play a bell sound when the joint angle passes some max value. Return joint angle relative to the corkscrew pin. Parameters • *corkscrew : pointer to the joint. See also: NewtonCorkscrewSetUserCallback dFloat NewtonCorkscrewGetJointOmega(const NewtonJoint *const corkscrew) Get the relative joint angular velocity between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play the creaky noise of a hanging lamp. Return joint angular velocity relative to the pin axis. Parameters • *corkscrew : pointer to the joint. See also: NewtonCorkscrewSetUserCallback dFloat NewtonCorkscrewCalculateStopAlpha(const NewtonJoint *const corkscrew, const Newton- HingeSliderUpdateDesc *const desc, dFloat angle) Calculate the angular acceleration needed to stop the corkscrew at the desired angle. this function can only be called from a NewtonCorkscrewCallback and it can be used by the application to implement corkscrew limits. Return relative angular acceleration needed to stop the corkscrew. Parameters • *corkscrew : pointer to the joint. • *desc : is the pointer to the Corkscrew or slide structure. • angle : is the desired corkscrew stop angle See also: NewtonCorkscrewSetUserCallback dFloat NewtonCorkscrewCalculateStopAccel(const NewtonJoint *const corkscrew, const New- tonHingeSliderUpdateDesc *const desc, dFloat dis- tance) Calculate the angular acceleration needed to stop the corkscrew at the desired angle. this function can only be called from a NewtonCorkscrewCallback and it can be used by the application to implement corkscrew limits. Return relative linear acceleration needed to stop the corkscrew. Parameters • *corkscrew : pointer to the joint. • *desc : is the pointer to the Corkscrew or slide structure. • distance : desired stop distance relative to the pivot point See also: NewtonCorkscrewSetUserCallback

3.14. JointCorkscrew 73 Newton Dynamics Engine Documentation, Release 3

void NewtonCorkscrewGetJointForce(const NewtonJoint *const corkscrew, dFloat *const force) Get the total force asserted over the joint pivot point, to maintain the constraint. this function can be used during a function update call back to provide the application with some special effect. for example the application can destroy the joint if the force exceeds some predefined value. Return . Parameters • *corkscrew : pointer to the joint. • *force : pointer to an array of a least three floats to hold the force value of the joint. See also: NewtonCorkscrewSetUserCallback

3.15 JointUniversal

NewtonJoint *NewtonConstraintCreateUniversal(const NewtonWorld *const newtonWorld, const dFloat *pivotPoint, const dFloat *pinDir0, const dFloat *pinDir1, const NewtonBody *const childBody, const NewtonBody *const parent- Body) Create a universal joint. This function creates a universal joint and add it to the world. By default joint disables collision with the linked bodies. Return to the universal joint. Parameters • *newtonWorld : is the pointer to the Newton world. • *pivotPoint : is origin of the universal joint in global space. • *pinDir0 : - first axis of rotation fixed on childBody body and perpendicular to pinDir1. • *pinDir1 : - second axis of rotation fixed on parentBody body and perpendicular to pinDir0. • *childBody : is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. • *parentBody : is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body. a universal joint is a constraint that restricts twp rigid bodies to be connected to a point fixed on both bodies, while and allowing one body to spin around a fix axis in is own frame, and the other body to spin around another axis fixes on it own frame. Both axis must be mutually perpendicular. void NewtonUniversalSetUserCallback(const NewtonJoint *const universal, NewtonUniversalCall- back callback) Set an update call back to be called when either of the two body linked by the joint is active. if the application wants to have some feedback from the joint simulation, the application can register a function update callback to be called every time any of the bodies linked by this joint is active. This is useful to provide special effects like particles, sound or even to simulate breakable moving parts. Return . Parameters • *universal : pointer to the joint. • callback : pointer to the joint function call back.

74 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

the function NewtonUniversalCallback callback should return a bit field code. if the application does not want to set the joint acceleration the return code is zero if the application only wants to change the joint linear acceleration the return code is 1 if the application only wants to change the joint angular acceleration the return code is 2 if the application only wants to change the joint angular and linear acceleration the return code is 3See also: NewtonJointGetUserData, NewtonJointSetUserData dFloat NewtonUniversalGetJointAngle0(const NewtonJoint *const universal) Get the relative joint angle between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play a bell sound when the joint angle passes some max value. Return joint angle relative to the universal pin0. Parameters • *universal : pointer to the joint. See also: NewtonUniversalSetUserCallback dFloat NewtonUniversalGetJointAngle1(const NewtonJoint *const universal) Get the relative joint angle between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play a bell sound when the joint angle passes some max value. Return joint angle relative to the universal pin1. Parameters • *universal : pointer to the joint. See also: NewtonUniversalSetUserCallback dFloat NewtonUniversalGetJointOmega0(const NewtonJoint *const universal) Get the relative joint angular velocity between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play the creaky noise of a hanging lamp. Return joint angular velocity relative to the pin0 axis. Parameters • *universal : pointer to the joint. See also: NewtonUniversalSetUserCallback dFloat NewtonUniversalGetJointOmega1(const NewtonJoint *const universal) Get the relative joint angular velocity between the two bodies. this function can be used during a function update call back to provide the application with some special effect. for example the application can play the creaky noise of a hanging lamp. Return joint angular velocity relative to the pin1 axis. Parameters • *universal : pointer to the joint. See also: NewtonUniversalSetUserCallback dFloat NewtonUniversalCalculateStopAlpha0(const NewtonJoint *const universal, const Newton- HingeSliderUpdateDesc *const desc, dFloat angle) Calculate the angular acceleration needed to stop the universal at the desired angle. this function can only be called from a NewtonUniversalCallback and it can be used by the application to implement universal limits. Return relative angular acceleration needed to stop the universal. Parameters

3.15. JointUniversal 75 Newton Dynamics Engine Documentation, Release 3

• *universal : pointer to the joint. • *desc : is the pointer to the Universal or slide structure. • angle : is the desired universal stop angle rotation around pin0 See also: NewtonUniversalSetUserCallback dFloat NewtonUniversalCalculateStopAlpha1(const NewtonJoint *const universal, const Newton- HingeSliderUpdateDesc *const desc, dFloat angle) Calculate the angular acceleration needed to stop the universal at the desired angle. this function can only be called from a NewtonUniversalCallback and it can be used by the application to implement universal limits. Return relative angular acceleration needed to stop the universal. Parameters • *universal : pointer to the joint. • *desc : is the pointer to and the Universal or slide structure. • angle : is the desired universal stop angle rotation around pin1 See also: NewtonUniversalSetUserCallback void NewtonUniversalGetJointForce(const NewtonJoint *const universal, dFloat *const force) Get the total force asserted over the joint pivot point, to maintain the constraint. this function can be used during a function update call back to provide the application with some special effect. for example the application can destroy the joint if the force exceeds some predefined value. Return . Parameters • *universal : pointer to the joint. • *force : pointer to an array of a least three floats to hold the force value of the joint. See also: NewtonUniversalSetUserCallback

3.16 JointUpVector

NewtonJoint *NewtonConstraintCreateUpVector(const NewtonWorld *const newtonWorld, const dFloat *pinDir, const NewtonBody *const body) Create a UpVector joint. This function creates an up vector joint. An up vector joint is a constraint that allows a body to translate freely in 3d space, but it only allows the body to rotate around the pin direction vector. This could be use by the application to control a character with physics and collision. Return to the up vector joint. Parameters • *newtonWorld : is the pointer to the Newton world. • *pinDir : is the aligning vector. • *body : is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. Since the UpVector joint is a unary constraint, there is not need to have user callback or user data assigned to it. The application can simple hold to the joint handle and update the pin on the force callback function of the rigid body owning the joint.

76 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3 void NewtonUpVectorGetPin(const NewtonJoint *const upVector, dFloat *pin) Get the up vector pin of this joint in global space. the application ca call this function to read the up vector, this is useful to animate the up vector. if the application is going to animated the up vector, it must do so by applying only small rotation, too large rotation can cause vibration of the joint. Return . Parameters • *upVector : pointer to the joint. • *pin : pointer to an array of a least three floats to hold the up vector direction in global space. See also: NewtonUpVectorSetPin void NewtonUpVectorSetPin(const NewtonJoint *const upVector, const dFloat *pin) Set the up vector pin of this joint in global space. the application ca call this function to change the joint up vector, this is useful to animate the up vector. if the application is going to animated the up vector, it must do so by applying only small rotation, too large rotation can cause vibration of the joint. Return . Parameters • *upVector : pointer to the joint. • *pin : pointer to an array of a least three floats containing the up vector direction in global space. See also: NewtonUpVectorGetPin

3.17 JointUser

NewtonJoint *NewtonConstraintCreateUserJoint(const NewtonWorld *const newtonWorld, int maxDOF, NewtonUserBilateralCallback submit- Constraints, NewtonUserBilateralGetInfoCall- back getInfo, const NewtonBody *const child- Body, const NewtonBody *const parentBody) Create a user define bilateral joint. Bilateral joint are constraints that can have up to 6 degree of freedoms, 3 linear and 3 angular. By restricting the motion along any number of these degree of freedom a very large number of useful joint between two rigid bodies can be accomplished. Some of the degree of freedoms restriction makes no sense, and also some combinations are so rare that only make sense to a very specific application, the Newton engine implements the more commons combinations like, hinges, ball and socket, etc. However if and application is in the situation that any of the provided joints can achieve the desired effect, then the application can design it own joint. Parameters • *newtonWorld : is the pointer to the Newton world. • maxDOF : is the maximum number of degree of freedom controlled by this joint. • submitConstraints : pointer to the joint constraint definition function call back. • getInfo : pointer to callback for collecting joint information. • *childBody : is the pointer to the attached rigid body, this body can not be NULL or it can not have an infinity (zero) mass. • *parentBody : is the pointer to the parent rigid body, this body can be NULL or any kind of rigid body.

3.17. JointUser 77 Newton Dynamics Engine Documentation, Release 3

User defined joint is a very advance feature that should be look at, only for very especial situations. The designer must be a person with a very good understanding of constrained dynamics, and it may be the case that many trial have to be made before a good result can be accomplished.function submitConstraints is called before the solver state to get the jacobian derivatives and the righ hand acceleration for the definition of the constraint.maxDOF is and upper bound as to how many degrees of freedoms the joint can control, usually this value can be 6 for bilat- eral joints, but it can be higher for special joints like vehicles where by the used of friction clamping the number of rows can be higher. In general the application should determine maxDof correctly, passing an unnecessary excessive value will lead to performance decreased.See also: NewtonUserJointSetFeedbackCollectorCallback void NewtonUserJointAddLinearRow(const NewtonJoint *const joint, const dFloat *const pivot0, const dFloat *const pivot1, const dFloat *const dir) Add a linear restricted degree of freedom. A linear constraint row calculates the Jacobian derivatives and relative acceleration required to enforce the constraint condition at the attachment point and the pin direction considered fixed to both bodies. Parameters • *joint : pointer to the joint. • *pivot0 : - pointer of a vector in global space fixed on body zero. • *pivot1 : - pointer of a vector in global space fixed on body one. • *dir : pointer of a unit vector in global space along which the relative position, velocity and accel- eration between the bodies will be driven to zero. The acceleration is calculated such that the relative linear motion between the two points is zero, the application can afterward override this value to create motors.after this function is call and internal DOF index will point to the current row entry in the constraint matrix.This function call only be called from inside a NewtonUserBilat- eralCallback callback.See also: NewtonUserJointAddAngularRow, void NewtonUserJointAddAngularRow(const NewtonJoint *const joint, dFloat relativeAngleError, const dFloat *const pin) Add an angular restricted degree of freedom. An angular constraint row calculates the Jacobian derivatives and relative acceleration required to enforce the constraint condition at pin direction considered fixed to both bodies. Parameters • *joint : pointer to the joint. • relativeAngleError : relative angle error between both bodies around pin axis. • *pin : pointer of a unit vector in global space along which the relative position, velocity and accel- eration between the bodies will be driven to zero. The acceleration is calculated such that the relative angular motion between the two points is zero, The appli- cation can afterward override this value to create motors.After this function is called and internal DOF index will point to the current row entry in the constraint matrix.This function call only be called from inside a New- tonUserBilateralCallback callback.This function is of not practical to enforce hard constraints, but it is very useful for making angular motors.See also: NewtonUserJointAddLinearRow void NewtonUserJointAddGeneralRow(const NewtonJoint *const joint, const dFloat *const jaco- bian0, const dFloat *const jacobian1) set the general linear and angular Jacobian for the desired degree of freedom In general this function must be used for very special effects and in combination with other joints. it is expected that the user have a knowledge of Constrained dynamics to make a good used of this function. Must typical application of this function are the creation of synchronization or control joints like gears, pulleys, worm gear and some other mechanical control. Parameters • *joint : pointer to the joint. • *jacobian0 : - pointer of a set of six values defining the linear and angular Jacobian for body0.

78 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

• *jacobian1 : - pointer of a set of six values defining the linear and angular Jacobian for body1. this function set the relative acceleration for this degree of freedom to zero. It is the application responsibility to set the relative acceleration after a call to this functionSee also: NewtonUserJointAddLinearRow, NewtonUser- JointAddAngularRow int NewtonUserJoinRowsCount(const NewtonJoint *const joint) void NewtonUserJointGetGeneralRow(const NewtonJoint *const joint, int index, dFloat *const jaco- bian0, dFloat *const jacobian1) void NewtonUserJointSetRowMaximumFriction(const NewtonJoint *const joint, dFloat friction) Set the maximum friction value the solver is allow to apply to the joint row. This function will override the default friction values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. friction value is context sensitive, if for linear constraint friction is a Max friction force, for angular constraint friction is a max friction is a Max friction torque. Parameters • *joint : pointer to the joint. • friction : maximum friction value for this row. It must be a positive value between 0.0 and INFINITY. See also: NewtonUserJointSetRowMinimumFriction, NewtonUserJointAddLinearRow, NewtonUserJointAd- dAngularRow void NewtonUserJointSetRowMinimumFriction(const NewtonJoint *const joint, dFloat friction) Set the minimum friction value the solver is allow to apply to the joint row. This function will override the default friction values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. friction value is context sensitive, if for linear constraint friction is a Min friction force, for angular constraint friction is a friction is a Min friction torque. Parameters • *joint : pointer to the joint. • friction : friction value for this row. It must be a negative value between 0.0 and -INFINITY. See also: NewtonUserJointSetRowMaximumFriction, NewtonUserJointAddLinearRow, NewtonUserJointAd- dAngularRow void NewtonUserJointSetRowAcceleration(const NewtonJoint *const joint, dFloat acceleration) Set the value for the desired acceleration for the current constraint row. This function will override the default acceleration values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngularRow. friction value is context sensitive, if for linear constraint acceleration is a linear acceleration, for angular con- straint acceleration is an angular acceleration. Parameters • *joint : pointer to the joint. • acceleration : desired acceleration value for this row. See also: NewtonUserJointAddLinearRow, NewtonUserJointAddAngularRow dFloat NewtonUserCalculateRowZeroAccelaration(const NewtonJoint *const joint) void NewtonUserJointSetRowSpringDamperAcceleration(const NewtonJoint *const joint, dFloat spring, dFloat damper) Calculates the row acceleration to satisfy the specified the spring damper system. This function will override the default acceleration values set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAddAngular- Row. friction value is context sensitive, if for linear constraint acceleration is a linear acceleration, for angular constraint acceleration is an angular acceleration.

3.17. JointUser 79 Newton Dynamics Engine Documentation, Release 3

Parameters • *joint : pointer to the joint. • spring : desired spring stiffness, it must be a positive value. • damper : desired damper coefficient, it must be a positive value. the acceleration calculated by this function represent the mass, spring system of the form a = -ks * x - kd * v.for this function to take place the joint stiffness must be set to a values lower than 1.0See also: NewtonUser- JointSetRowAcceleration, NewtonUserJointSetRowStiffness void NewtonUserJointSetRowStiffness(const NewtonJoint *const joint, dFloat stiffness) Set the maximum percentage of the constraint force that will be applied to the constraint row. This function will override the default stiffness value set after a call to NewtonUserJointAddLinearRow or NewtonUserJointAd- dAngularRow. the row stiffness is the percentage of the constraint force that will be applied to the rigid bodies. Ideally the value should be 1.0 (100% stiff) but dues to numerical integration error this could be the joint a little unstable, and lower values are preferred. Parameters • *joint : pointer to the joint. • stiffness : row stiffness, it must be a values between 0.0 and 1.0, the default is 0.9. See also: NewtonUserJointAddLinearRow, NewtonUserJointAddAngularRow, NewtonUserJointSetRowSpring- DamperAcceleration dFloat NewtonUserJointGetRowForce(const NewtonJoint *const joint, int row) Return the magnitude previews force or torque value calculated by the solver for this constraint row. This function can be call for any of the previews row for this particular joint, The application must keep track of the meaning of the row. Parameters • *joint : pointer to the joint. • row : index to the constraint row. This function can be used to produce special effects like breakable or malleable joints, fro example a hinge can turn into ball and socket after the force in some of the row exceed certain high value. void NewtonUserJointSetFeedbackCollectorCallback(const NewtonJoint *const joint, New- tonUserBilateralCallback getFeedback) Set a constrain callback to collect the force calculated by the solver to enforce this constraint See also: New- tonUserJointGetRowForce Parameters • *joint : pointer to the joint. • getFeedback : pointer to the joint constraint definition function call back.

3.18 JointCommon

void NewtonJointSetUserData(const NewtonJoint *const joint, void *const userData) Store a user defined data value with the joint. The application can store a user defined value with the Joint. This value can be the pointer to a structure containing some application data for special effect. if the application allocate some resource to store the user data, the application can register a joint destructor to get rid of the allocated resource when the Joint is destroyed Return .

80 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

Parameters • *joint : pointer to the joint. • *userData : pointer to the user defined user data value. See also: NewtonJointSetDestructor void *NewtonJointGetUserData(const NewtonJoint *const joint) Retrieve a user defined data value stored with the joint. The application can store a user defined value with a joint. This value can be the pointer to a structure to store some game play data for special effect. Return user defined data. Parameters • *joint : pointer to the joint. See also: NewtonJointSetUserData void NewtonJointGetInfo(const NewtonJoint *const joint, NewtonJointRecord *const jointInfo) Get creation parameters for this joint. This function can be used by the application for writing file format and for serialization. Parameters • joint : is the pointer to a convex collision primitive. • *jointInfo : pointer to a collision information record. See also: ::// See also: NewtonBody *NewtonJointGetBody0(const NewtonJoint *const joint) Get the first body connected by this joint. See also: ::// See also: Parameters • *joint : is the pointer to a convex collision primitive. NewtonBody *NewtonJointGetBody1(const NewtonJoint *const joint) Get the second body connected by this joint. See also: ::// See also: Parameters • *joint : is the pointer to a convex collision primitive. void NewtonJointSetCollisionState(const NewtonJoint *const joint, int state) Enable or disable collision between the two bodies linked by this joint. The default state is collision disable when the joint is created. usually when two bodies are linked by a joint, the application wants collision between this two bodies to be disabled. This is the default behavior of joints when they are created, however when this behavior is not desired the application can change it by setting collision on. If the application decides to enable collision between jointed bodies, the application should make sure the collision geometry do not collide in the work space of the joint. Return . Parameters • *joint : pointer to the joint. • state : collision state, zero mean disable collision, non zero enable collision between linked bodies. if the joint is destroyed the collision state of the two bodies linked by this joint is determined by the material pair assigned to each body.See also: NewtonJointGetCollisionState, NewtonBodySetJointRecursiveCollision

3.18. JointCommon 81 Newton Dynamics Engine Documentation, Release 3

int NewtonJointGetCollisionState(const NewtonJoint *const joint) Get the collision state of the two bodies linked by the joint. usually when two bodies are linked by a joint, the application wants collision between this two bodies to be disabled. This is the default behavior of joints when they are created, however when this behavior is not desired the application can change it by setting collision on. If the application decides to enable collision between jointed bodies, the application should make sure the collision geometry do not collide in the work space of the joint. Return collision state. Parameters • *joint : pointer to the joint. See also: NewtonJointSetCollisionState void NewtonJointSetStiffness(const NewtonJoint *const joint, dFloat stiffness) Set the strength coefficient to be applied to the joint reaction forces. Constraint keep bodies together by calcu- lating the exact force necessary to cancel the relative acceleration between one or more common points fixed in the two bodies. The problem is that when the bodies drift apart due to numerical integration inaccuracies, the reaction force work to pull eliminated the error but at the expense of adding extra energy to the system, does violating the rule that constraint forces must be work less. This is a inevitable situation and the only think we can do is to minimize the effect of the extra energy by dampening the force by some amount. In essence the stiffness coefficient tell Newton calculate the precise reaction force by only apply a fraction of it to the joint point. And value of 1.0 will apply the exact force, and a value of zero will apply only 10 percent. Return . Parameters • *joint : pointer to the joint. • stiffness : stiffness coefficient, a value between 0, and 1.0, the default value for most joint is 0.9 The stiffness is set to a all around value that work well for most situation, however the application can play with these parameter to make finals adjustment. A high value will make the joint stronger but more prompt to vibration of instability; a low value will make the joint more stable but weaker.See also: NewtonJointGetStiffness dFloat NewtonJointGetStiffness(const NewtonJoint *const joint) Get the strength coefficient bing applied to the joint reaction forces. Constraint keep bodies together by calcu- lating the exact force necessary to cancel the relative acceleration between one or more common points fixed in the two bodies. The problem is that when the bodies drift apart due to numerical integration inaccuracies, the reaction force work to pull eliminated the error but at the expense of adding extra energy to the system, does violating the rule that constraint forces must be work less. This is a inevitable situation and the only think we can do is to minimize the effect of the extra energy by dampening the force by some amount. In essence the stiffness coefficient tell Newton calculate the precise reaction force by only apply a fraction of it to the joint point. And value of 1.0 will apply the exact force, and a value of zero will apply only 10 percent. Return coefficient. Parameters • *joint : pointer to the joint. The stiffness is set to a all around value that work well for most situation, however the application can play with these parameter to make finals adjustment. A high value will make the joint stronger but more prompt to vibration of instability; a low value will make the joint more stable but weaker.See also: NewtonJointSetStiffness void NewtonJointSetDestructor(const NewtonJoint *const joint, NewtonConstraintDestructor de- structor) Register a destructor callback to be called when the joint is about to be destroyed. If application stores any resource with the joint, or the application wants to be notified when the joint is about to be destroyed. The application can register a destructor call back with the joint.

82 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

Return . Parameters • *joint : pointer to the joint. • destructor : pointer to the joint destructor callback. See also: NewtonJointSetUserData void NewtonDestroyJoint(const NewtonWorld *const newtonWorld, const NewtonJoint *const joint) destroy a joint. The application can call this function when it wants to destroy a joint. This function can be used by the application to simulate breakable joints Return Parameters • *newtonWorld : is the pointer to the body. • *joint : pointer to joint to be destroyed See also: NewtonConstraintCreateSlider

3.19 SpecialEffectMesh

NewtonMesh *NewtonMeshCreate(const NewtonWorld *const newtonWorld) NewtonMesh *NewtonMeshCreateFromMesh(const NewtonMesh *const mesh) NewtonMesh *NewtonMeshCreateFromCollision(const NewtonCollision *const collision) NewtonMesh *NewtonMeshCreateConvexHull(const NewtonWorld *const newtonWorld, int count, const dFloat *const vertexCloud, int strideInBytes, dFloat tolerance) NewtonMesh *NewtonMeshCreateDelaunayTetrahedralization(const NewtonWorld *const newtonWorld, int pointCount, const dFloat *const vertex- Cloud, int strideInBytes, int materialID, const dFloat *const textureMatrix) NewtonMesh *NewtonMeshCreateVoronoiConvexDecomposition(const NewtonWorld *const newtonWorld, int pointCount, const dFloat *const vertex- Cloud, int strideInBytes, int materialID, const dFloat *const textureMatrix) NewtonMesh *NewtonMeshCreateFromSerialization(const NewtonWorld *const newtonWorld, NewtonDeserializeCallback deserialize- Function, void *const serializeHandle) void NewtonMeshDestroy(const NewtonMesh *const mesh) void NewtonMeshSerialize(const NewtonMesh *const mesh, NewtonSerializeCallback serializeFunc- tion, void *const serializeHandle) void NewtonMeshSaveOFF(const NewtonMesh *const mesh, const char *const filename) NewtonMesh *NewtonMeshLoadOFF(const NewtonWorld *const newtonWorld, const char *const file- name)

3.19. SpecialEffectMesh 83 Newton Dynamics Engine Documentation, Release 3

void NewtonMeshApplyTransform(const NewtonMesh *const mesh, const dFloat *const matrix) void NewtonMeshCalculateOOBB(const NewtonMesh *const mesh, dFloat *const matrix, dFloat *const x, dFloat *const y, dFloat *const z) void NewtonMeshCalculateVertexNormals(const NewtonMesh *const mesh, dFloat angleInRadi- ans) void NewtonMeshApplyAngleBasedMapping(const NewtonMesh *const mesh, int material, Newton- ReportProgress reportPrograssCallback, void *const re- portPrgressUserData) void NewtonMeshApplySphericalMapping(const NewtonMesh *const mesh, int material) void NewtonMeshApplyBoxMapping(const NewtonMesh *const mesh, int front, int side, int top) void NewtonMeshApplyCylindricalMapping(const NewtonMesh *const mesh, int cylinderMaterial, int capMaterial) void NewtonMeshTriangulate(const NewtonMesh *const mesh) void NewtonMeshPolygonize(const NewtonMesh *const mesh) int NewtonMeshIsOpenMesh(const NewtonMesh *const mesh) void NewtonMeshFixTJoints(const NewtonMesh *const mesh) void NewtonMeshClip(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix, NewtonMesh **const topMesh, NewtonMesh **const bot- tomMesh) NewtonMesh *NewtonMeshSimplify(const NewtonMesh *const mesh, int maxVertexCount, Newton- ReportProgress progressReportCallback, void *const reportPrgres- sUserData) NewtonMesh *NewtonMeshApproximateConvexDecomposition(const NewtonMesh *const mesh, dFloat maxConcavity, dFloat backFaceDistanceFactor, int maxCount, int maxVertexPerHull, NewtonReportProgress progress- ReportCallback, void *const reportProgressUserData) NewtonMesh *NewtonMeshUnion(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix) NewtonMesh *NewtonMeshDifference(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix) NewtonMesh *NewtonMeshIntersection(const NewtonMesh *const mesh, const NewtonMesh *const clipper, const dFloat *const clipperMatrix) NewtonMesh *NewtonMeshConvexMeshIntersection(const NewtonMesh *const mesh, const New- tonMesh *const convexMesh) void NewtonRemoveUnusedVertices(const NewtonMesh *const mesh, int *const vertexRemapTable) void NewtonMeshBeginFace(const NewtonMesh *const mesh) void NewtonMeshAddFace(const NewtonMesh *const mesh, int vertexCount, const dFloat *const vertex, int strideInBytes, int materialIndex) void NewtonMeshEndFace(const NewtonMesh *const mesh)

84 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3 void NewtonMeshBuildFromVertexListIndexList(const NewtonMesh *const mesh, int face- Count, const int *const faceIndexCount, const int *const faceMaterialIndex, const dFloat *const vertex, int vertexStrideInBytes, const int *const vertexIndex, const dFloat *const nor- mal, int normalStrideInBytes, const int *const normalIndex, const dFloat *const uv0, int uv0StrideInBytes, const int *const uv0Index, const dFloat *const uv1, int uv1StrideInBytes, const int *const uv1Index) int NewtonMeshGetVertexCount(const NewtonMesh *const mesh) int NewtonMeshGetVertexStrideInByte(const NewtonMesh *const mesh) dFloat64 *NewtonMeshGetVertexArray(const NewtonMesh *const mesh) int NewtonMeshGetPointCount(const NewtonMesh *const mesh) int NewtonMeshGetPointStrideInByte(const NewtonMesh *const mesh) dFloat64 *NewtonMeshGetPointArray(const NewtonMesh *const mesh) dFloat64 *NewtonMeshGetNormalArray(const NewtonMesh *const mesh) dFloat64 *NewtonMeshGetUV0Array(const NewtonMesh *const mesh) dFloat64 *NewtonMeshGetUV1Array(const NewtonMesh *const mesh) void NewtonMeshGetVertexStreams(const NewtonMesh *const mesh, dgInt32 vetexStrideInByte, dFloat *const vertex, dgInt32 normalStrideInByte, dFloat *const normal, dgInt32 uvStrideInByte0, dFloat *const uv0, dgInt32 uvStrideInByte1, dFloat *const uv1) void NewtonMeshGetIndirectVertexStreams(const NewtonMesh *const mesh, int vetexStrideIn- Byte, dFloat *const vertex, int *const vertexIndices, int *const vertexCount, int normalStrideInByte, dFloat *const normal, int *const normalIndices, int *const normalCount, int uvStrideInByte0, dFloat *const uv0, int *const uvIndices0, int *const uvCount0, int uvStrideInByte1, dFloat *const uv1, int *const uvIndices1, int *const uvCount1) void *NewtonMeshBeginHandle(const NewtonMesh *const mesh) void NewtonMeshEndHandle(const NewtonMesh *const mesh, void *const handle) int NewtonMeshFirstMaterial(const NewtonMesh *const mesh, void *const handle) int NewtonMeshNextMaterial(const NewtonMesh *const mesh, void *const handle, int materialId) int NewtonMeshMaterialGetMaterial(const NewtonMesh *const mesh, void *const handle, int ma- terialId) int NewtonMeshMaterialGetIndexCount(const NewtonMesh *const mesh, void *const handle, int materialId) void NewtonMeshMaterialGetIndexStream(const NewtonMesh *const mesh, void *const handle, int materialId, int *const index) void NewtonMeshMaterialGetIndexStreamShort(const NewtonMesh *const mesh, void *const handle, int materialId, short int *const index) NewtonMesh *NewtonMeshCreateFirstSingleSegment(const NewtonMesh *const mesh)

3.19. SpecialEffectMesh 85 Newton Dynamics Engine Documentation, Release 3

NewtonMesh *NewtonMeshCreateNextSingleSegment(const NewtonMesh *const mesh, const NewtonMesh *const segment) NewtonMesh *NewtonMeshCreateFirstLayer(const NewtonMesh *const mesh) NewtonMesh *NewtonMeshCreateNextLayer(const NewtonMesh *const mesh, const NewtonMesh *const segment) int NewtonMeshGetTotalFaceCount(const NewtonMesh *const mesh) int NewtonMeshGetTotalIndexCount(const NewtonMesh *const mesh) void NewtonMeshGetFaces(const NewtonMesh *const mesh, int *const faceIndexCount, int *const face- Material, void **const faceIndices) void *NewtonMeshGetFirstVertex(const NewtonMesh *const mesh) void *NewtonMeshGetNextVertex(const NewtonMesh *const mesh, const void *const vertex) int NewtonMeshGetVertexIndex(const NewtonMesh *const mesh, const void *const vertex) void *NewtonMeshGetFirstPoint(const NewtonMesh *const mesh) void *NewtonMeshGetNextPoint(const NewtonMesh *const mesh, const void *const point) int NewtonMeshGetPointIndex(const NewtonMesh *const mesh, const void *const point) int NewtonMeshGetVertexIndexFromPoint(const NewtonMesh *const mesh, const void *const point) void *NewtonMeshGetFirstEdge(const NewtonMesh *const mesh) void *NewtonMeshGetNextEdge(const NewtonMesh *const mesh, const void *const edge) void NewtonMeshGetEdgeIndices(const NewtonMesh *const mesh, const void *const edge, int *const v0, int *const v1) void *NewtonMeshGetFirstFace(const NewtonMesh *const mesh) void *NewtonMeshGetNextFace(const NewtonMesh *const mesh, const void *const face) int NewtonMeshIsFaceOpen(const NewtonMesh *const mesh, const void *const face) int NewtonMeshGetFaceIndexCount(const NewtonMesh *const mesh, const void *const face) int NewtonMeshGetFaceMaterial(const NewtonMesh *const mesh, const void *const face) void NewtonMeshSetFaceMaterial(const NewtonMesh *const mesh, const void *const face, int matId) void NewtonMeshGetFaceIndices(const NewtonMesh *const mesh, const void *const face, int *const indices) void NewtonMeshGetFacePointIndices(const NewtonMesh *const mesh, const void *const face, int *const indices) void NewtonMeshCalculateFaceNormal(const NewtonMesh *const mesh, const void *const face, dFloat64 *const normal) NewtonCollision *NewtonCreateClothPatch(const NewtonWorld *const newtonWorld, NewtonMesh *const mesh, int shapeID, NewtonClothPatchMaterial *const structuralMaterial, NewtonClothPatchMaterial *const bendMaterial) NewtonCollision *NewtonCreateDeformableMesh(const NewtonWorld *const newtonWorld, Newton- Mesh *const mesh, int shapeID) void NewtonDeformableMeshCreateClusters(NewtonCollision *const deformableMesh, int clun- sterCount, dFloat overlapingWidth)

86 Chapter 3. API Documentation Newton Dynamics Engine Documentation, Release 3

void NewtonDeformableMeshSetDebugCallback(NewtonCollision *const deformableMesh, New- tonCollisionIterator callback) int NewtonDeformableMeshGetParticleCount(const NewtonCollision *const deformableMesh) void NewtonDeformableMeshGetParticlePosition(NewtonCollision *const deformableMesh, int particleIndex, dFloat *const posit) void NewtonDeformableMeshBeginConfiguration(const NewtonCollision *const de- formableMesh) void NewtonDeformableMeshEndConfiguration(const NewtonCollision *const deformableMesh) void NewtonDeformableMeshUnconstraintParticle(NewtonCollision *const deformableMesh, int partivleIndex) void NewtonDeformableMeshConstraintParticle(NewtonCollision *const deformableMesh, int particleIndex, const dFloat *const posit, const NewtonBody *const body) void NewtonDeformableMeshSetSkinThickness(NewtonCollision *const deformableMesh, dFloat skinThickness) void NewtonDeformableMeshSetPlasticity(NewtonCollision *const deformableMesh, dFloat plas- ticity) void NewtonDeformableMeshSetStiffness(NewtonCollision *const deformableMesh, dFloat stiff- ness) int NewtonDeformableMeshGetVertexCount(const NewtonCollision *const deformableMesh) void NewtonDeformableMeshUpdateRenderNormals(const NewtonCollision *const de- formableMesh) void NewtonDeformableMeshGetVertexStreams(const NewtonCollision *const deformableMesh, int vertexStrideInByte, dFloat *const vertex, int normalStrideInByte, dFloat *const normal, int uvStrideInByte0, dFloat *const uv0) NewtonDeformableMeshSegment *NewtonDeformableMeshGetFirstSegment(const Newton- Collision *const deformableMesh) NewtonDeformableMeshSegment *NewtonDeformableMeshGetNextSegment(const Newton- Collision *const deformableMesh, const NewtonDe- formableMeshSeg- ment *const segment) int NewtonDeformableMeshSegmentGetMaterialID(const NewtonCollision *const de- formableMesh, const NewtonDe- formableMeshSegment *const segment) int NewtonDeformableMeshSegmentGetIndexCount(const NewtonCollision *const de- formableMesh, const NewtonDe- formableMeshSegment *const segment) const int *NewtonDeformableMeshSegmentGetIndexList(const NewtonCollision *const de- formableMesh, const NewtonDe- formableMeshSegment *const seg- ment)

3.19. SpecialEffectMesh 87 Newton Dynamics Engine Documentation, Release 3

3.20 Unclassified

NewtonSkeletonContainer *NewtonSkeletonContainerCreate(NewtonWorld *const worldPtr, New- tonBody *const rootBone, New- tonSkeletontDestructor destructor) void NewtonSkeletonContainerDelete(NewtonSkeletonContainer *const skeletonPtr) void *NewtonSkeletonContainerGetRoot(const NewtonSkeletonContainer *const skeletonPtr) void *NewtonSkeletonContainerGetParent(const NewtonSkeletonContainer *const skeletonPtr, void *const node) void *NewtonSkeletonContainerFirstChild(const NewtonSkeletonContainer *const skeletonPtr, void *const parentNode) void *NewtonSkeletonContainerNextSibling(const NewtonSkeletonContainer *const skeletonPtr, void *const siblingNode) NewtonBody *NewtonSkeletonContainerGetBodyFromNode(const NewtonSkeletonContainer *const skeletonPtr, void *const node) NewtonJoint *NewtonSkeletonContainerGetParentJointFromNode(const NewtonSkele- tonContainer *const skeletonPtr, void *const node) void NewtonSkeletonContainerAttachJointArray(NewtonSkeletonContainer *const skeleton, int jointCount, NewtonJoint **const jointArray) void *NewtonSkeletonContainerAttachBone(NewtonSkeletonContainer *const skeleton, Newton- Body *const childBone, NewtonBody *const parent- Bone) void NewtonSkeletonContainernDetachBone(NewtonSkeletonContainer *const skeleton, void *const bone) void NewtonSkeletonContainerFinalize(NewtonSkeletonContainer *const skeleton) void *NewtonCollisionAggregateCreate(NewtonWorld *const worldPtr) void NewtonCollisionAggregateDestroy(void *const aggregatePtr) void NewtonCollisionAggregateAddBody(void *const aggregatePtr, const NewtonBody *const body) void NewtonCollisionAggregateRemoveBody(void *const aggregatePtr, const NewtonBody *const body) int NewtonCollisionAggregateGetSelfCollision(void *const aggregatePtr) void NewtonCollisionAggregateSetSelfCollision(void *const aggregatePtr, int state)

3.21 Doxygen

It is also possible to produce the API documentation via Doxygen:

cd doc doxygen Doxyfile firefox /index.html

88 Chapter 3. API Documentation CHAPTER 4

Indices and tables

• genindex • modindex • search

89 Newton Dynamics Engine Documentation, Release 3

90 Chapter 4. Indices and tables Index

N NewtonBodyGetMaterialGroupID (C++ function), 63 NewtonAlloc (C++ function), 13 NewtonBodyGetMatrix (C++ function), 58 NewtonAtomicAdd (C++ function), 15 NewtonBodyGetMaxRotationPerStep (C++ function), 65 NewtonAtomicSwap (C++ function), 15 NewtonBodyGetNextContactJoint (C++ function), 61 NewtonBallGetJointAngle (C++ function), 69 NewtonBodyGetNextJoint (C++ function), 61 NewtonBallGetJointForce (C++ function), 69 NewtonBodyGetOmega (C++ function), 66 NewtonBallGetJointOmega (C++ function), 69 NewtonBodyGetPointVelocity (C++ function), 67 NewtonBallSetConeLimits (C++ function), 68 NewtonBodyGetPosition (C++ function), 58 NewtonBallSetUserCallback (C++ function), 69 NewtonBodyGetRotation (C++ function), 58 NewtonBodyAddForce (C++ function), 58 NewtonBodyGetSimulationState (C++ function), 53 NewtonBodyAddImpulse (C++ function), 67 NewtonBodyGetSkeleton (C++ function), 61 NewtonBodyAddTorque (C++ function), 59 NewtonBodyGetSleepState (C++ function), 65 NewtonBodyApplyImpulseArray (C++ function), 68 NewtonBodyGetTorque (C++ function), 60 NewtonBodyApplyImpulsePair (C++ function), 68 NewtonBodyGetTorqueAcc (C++ function), 60 NewtonBodyCalculateInverseDynamicsForce (C++ func- NewtonBodyGetTransformCallback (C++ function), 55 tion), 59 NewtonBodyGetType (C++ function), 54 NewtonBodyGetAABB (C++ function), 66 NewtonBodyGetUserData (C++ function), 54 NewtonBodyGetAngularDamping (C++ function), 67 NewtonBodyGetVelocity (C++ function), 66 NewtonBodyGetAutoSleep (C++ function), 65 NewtonBodyGetWorld (C++ function), 54 NewtonBodyGetCentreOfMass (C++ function), 60 NewtonBodyIntegrateVelocity (C++ function), 68 NewtonBodyGetCollidable (C++ function), 54 NewtonBodySetAngularDamping (C++ function), 67 NewtonBodyGetCollision (C++ function), 63 NewtonBodySetAutoSleep (C++ function), 65 NewtonBodyGetContinuousCollisionMode (C++ func- NewtonBodySetCentreOfMass (C++ function), 60 tion), 64 NewtonBodySetCollidable (C++ function), 54 NewtonBodyGetDestructorCallback (C++ function), 56 NewtonBodySetCollision (C++ function), 63 NewtonBodyGetFirstContactJoint (C++ function), 61 NewtonBodySetCollisionScale (C++ function), 63 NewtonBodyGetFirstJoint (C++ function), 61 NewtonBodySetContinuousCollisionMode (C++ func- NewtonBodyGetForce (C++ function), 59 tion), 63 NewtonBodyGetForceAcc (C++ function), 58 NewtonBodySetDestructorCallback (C++ function), 55 NewtonBodyGetForceAndTorqueCallback (C++ func- NewtonBodySetForce (C++ function), 58 tion), 55 NewtonBodySetForceAndTorqueCallback (C++ func- NewtonBodyGetFreezeState (C++ function), 65 tion), 55 NewtonBodyGetID (C++ function), 54 NewtonBodySetFreezeState (C++ function), 65 NewtonBodyGetInertiaMatrix (C++ function), 57 NewtonBodySetFullMassMatrix (C++ function), 56 NewtonBodyGetInvInertiaMatrix (C++ function), 57 NewtonBodySetJointRecursiveCollision (C++ function), NewtonBodyGetInvMass (C++ function), 56 64 NewtonBodyGetJointRecursiveCollision (C++ function), NewtonBodySetLinearDamping (C++ function), 66 64 NewtonBodySetMassMatrix (C++ function), 56 NewtonBodyGetLinearDamping (C++ function), 67 NewtonBodySetMassProperties (C++ function), 56 NewtonBodyGetMass (C++ function), 56 NewtonBodySetMaterialGroupID (C++ function), 63 NewtonBodySetMatrix (C++ function), 57

91 Newton Dynamics Engine Documentation, Release 3

NewtonBodySetMatrixNoSleep (C++ function), 57 NewtonCollisionSupportVertex (C++ function), 49 NewtonBodySetMatrixRecursive (C++ function), 57 NewtonCompoundCollisionAddSubCollision (C++ func- NewtonBodySetMaxRotationPerStep (C++ function), 65 tion), 35 NewtonBodySetOmega (C++ function), 66 NewtonCompoundCollisionBeginAddRemove (C++ NewtonBodySetOmegaNoSleep (C++ function), 66 function), 36 NewtonBodySetSimulationState (C++ function), 53 NewtonCompoundCollisionEndAddRemove (C++ func- NewtonBodySetSleepState (C++ function), 66 tion), 36 NewtonBodySetTorque (C++ function), 59 NewtonCompoundCollisionGetCollisionFromNode NewtonBodySetTransformCallback (C++ function), 54 (C++ function), 36 NewtonBodySetUserData (C++ function), 54 NewtonCompoundCollisionGetFirstNode (C++ func- NewtonBodySetVelocity (C++ function), 66 tion), 36 NewtonBodySetVelocityNoSleep (C++ function), 66 NewtonCompoundCollisionGetNextNode (C++ func- NewtonCalculateSpringDamperAcceleration (C++ func- tion), 36 tion), 52 NewtonCompoundCollisionGetNodeByIndex (C++ func- NewtonCollisionAggregateAddBody (C++ function), 88 tion), 36 NewtonCollisionAggregateCreate (C++ function), 88 NewtonCompoundCollisionGetNodeIndex (C++ func- NewtonCollisionAggregateDestroy (C++ function), 88 tion), 36 NewtonCollisionAggregateGetSelfCollision (C++ func- NewtonCompoundCollisionRemoveSubCollision (C++ tion), 88 function), 36 NewtonCollisionAggregateRemoveBody (C++ function), NewtonCompoundCollisionRemoveSubCollisionByIndex 88 (C++ function), 36 NewtonCollisionAggregateSetSelfCollision (C++ func- NewtonCompoundCollisionSetSubCollisionMatrix (C++ tion), 88 function), 36 NewtonCollisionCalculateAABB (C++ function), 49 NewtonConstraintCreateBall (C++ function), 68 NewtonCollisionClosestPoint (C++ function), 46 NewtonConstraintCreateCorkscrew (C++ function), 72 NewtonCollisionCollide (C++ function), 47 NewtonConstraintCreateSlider (C++ function), 70 NewtonCollisionCollideContinue (C++ function), 48 NewtonConstraintCreateUniversal (C++ function), 74 NewtonCollisionCreateInstance (C++ function), 51 NewtonConstraintCreateUpVector (C++ function), 76 NewtonCollisionDataPointer (C++ function), 40 NewtonConstraintCreateUserJoint (C++ function), 77 NewtonCollisionForEachPolygonDo (C++ function), 50 NewtonContactGetCollision0 (C++ function), 62 NewtonCollisionGetInfo (C++ function), 52 NewtonContactGetCollision1 (C++ function), 62 NewtonCollisionGetMatrix (C++ function), 51 NewtonContactGetCollisionID0 (C++ function), 62 NewtonCollisionGetMode (C++ function), 38 NewtonContactGetCollisionID1 (C++ function), 62 NewtonCollisionGetParentInstance (C++ function), 51 NewtonContactGetMaterial (C++ function), 62 NewtonCollisionGetScale (C++ function), 51 NewtonContactJointGetClosestDistance (C++ function), NewtonCollisionGetSkinThickness (C++ function), 45 62 NewtonCollisionGetSubCollisionHandle (C++ function), NewtonContactJointGetContactCount (C++ function), 62 51 NewtonContactJointGetFirstContact (C++ function), 62 NewtonCollisionGetType (C++ function), 50 NewtonContactJointGetNextContact (C++ function), 62 NewtonCollisionGetUserData (C++ function), 50 NewtonContactJointRemoveContact (C++ function), 62 NewtonCollisionGetUserData1 (C++ function), 51 NewtonConvexCollisionCalculateBuoyancyAcceleration NewtonCollisionGetUserID (C++ function), 50 (C++ function), 39 NewtonCollisionIntersectionTest (C++ function), 47 NewtonConvexCollisionCalculateInertialMatrix (C++ NewtonCollisionIsConvexShape (C++ function), 50 function), 39 NewtonCollisionIsStaticShape (C++ function), 50 NewtonConvexCollisionCalculateVolume (C++ func- NewtonCollisionPointDistance (C++ function), 46 tion), 39 NewtonCollisionRayCast (C++ function), 49 NewtonConvexHullGetFaceIndices (C++ function), 38 NewtonCollisionSerialize (C++ function), 51 NewtonConvexHullGetVertexData (C++ function), 38 NewtonCollisionSetMatrix (C++ function), 51 NewtonCorkscrewCalculateStopAccel (C++ function), NewtonCollisionSetMode (C++ function), 38 73 NewtonCollisionSetScale (C++ function), 51 NewtonCorkscrewCalculateStopAlpha (C++ function), NewtonCollisionSetUserData (C++ function), 50 73 NewtonCollisionSetUserData1 (C++ function), 51 NewtonCorkscrewGetJointAngle (C++ function), 73 NewtonCollisionSetUserID (C++ function), 50 NewtonCorkscrewGetJointForce (C++ function), 73

92 Index Newton Dynamics Engine Documentation, Release 3

NewtonCorkscrewGetJointOmega (C++ function), 73 NewtonDeformableMeshSegmentGetIndexList (C++ NewtonCorkscrewGetJointPosit (C++ function), 72 function), 87 NewtonCorkscrewGetJointVeloc (C++ function), 72 NewtonDeformableMeshSegmentGetMaterialID (C++ NewtonCorkscrewSetUserCallback (C++ function), 72 function), 87 NewtonCreate (C++ function), 13 NewtonDeformableMeshSetDebugCallback (C++ func- NewtonCreateBox (C++ function), 32 tion), 86 NewtonCreateCapsule (C++ function), 33 NewtonDeformableMeshSetPlasticity (C++ function), 87 NewtonCreateChamferCylinder (C++ function), 34 NewtonDeformableMeshSetSkinThickness (C++ func- NewtonCreateClothPatch (C++ function), 86 tion), 87 NewtonCreateCollisionFromSerialization (C++ func- NewtonDeformableMeshSetStiffness (C++ function), 87 tion), 51 NewtonDeformableMeshUnconstraintParticle (C++ func- NewtonCreateCompoundCollision (C++ function), 35 tion), 87 NewtonCreateCompoundCollisionFromMesh (C++ func- NewtonDeformableMeshUpdateRenderNormals (C++ tion), 36 function), 87 NewtonCreateCone (C++ function), 33 NewtonDeserializeFromFile (C++ function), 14 NewtonCreateConvexHull (C++ function), 34 NewtonDestroy (C++ function), 13 NewtonCreateConvexHullFromMesh (C++ function), 35 NewtonDestroyAllBodies (C++ function), 18 NewtonCreateCylinder (C++ function), 34 NewtonDestroyBody (C++ function), 53 NewtonCreateDeformableBody (C++ function), 53 NewtonDestroyCollision (C++ function), 51 NewtonCreateDeformableMesh (C++ function), 86 NewtonDestroyJoint (C++ function), 83 NewtonCreateDynamicBody (C++ function), 53 NewtonDispachThreadJob (C++ function), 16 NewtonCreateFracturedCompoundCollision (C++ func- NewtonEnumerateDevices (C++ function), 14 tion), 36 NewtonFracturedCompoundCollisionGetVertexCount NewtonCreateHeightFieldCollision (C++ function), 44 (C++ function), 37 NewtonCreateKinematicBody (C++ function), 53 NewtonFracturedCompoundCollisionGetVertexNormals NewtonCreateNull (C++ function), 32 (C++ function), 38 NewtonCreateSceneCollision (C++ function), 45 NewtonFracturedCompoundCollisionGetVertexPositions NewtonCreateSphere (C++ function), 33 (C++ function), 38 NewtonCreateTreeCollision (C++ function), 41 NewtonFracturedCompoundCollisionGetVertexUVs NewtonCreateTreeCollisionFromMesh (C++ function), (C++ function), 38 41 NewtonFracturedCompoundGetFirstSubMesh (C++ NewtonCreateUserMeshCollision (C++ function), 40 function), 37 NewtonDeformableMeshBeginConfiguration (C++ func- NewtonFracturedCompoundGetMainMesh (C++ func- tion), 87 tion), 37 NewtonDeformableMeshConstraintParticle (C++ func- NewtonFracturedCompoundGetNextSubMesh (C++ tion), 87 function), 37 NewtonDeformableMeshCreateClusters (C++ function), NewtonFracturedCompoundIsNodeFreeToDetach (C++ 86 function), 37 NewtonDeformableMeshEndConfiguration (C++ func- NewtonFracturedCompoundMeshPartGetFirstSegment tion), 87 (C++ function), 38 NewtonDeformableMeshGetFirstSegment (C++ func- NewtonFracturedCompoundMeshPartGetIndexCount tion), 87 (C++ function), 38 NewtonDeformableMeshGetNextSegment (C++ func- NewtonFracturedCompoundMeshPartGetIndexStream tion), 87 (C++ function), 38 NewtonDeformableMeshGetParticleCount (C++ func- NewtonFracturedCompoundMeshPartGetMaterial (C++ tion), 87 function), 38 NewtonDeformableMeshGetParticlePosition (C++ func- NewtonFracturedCompoundMeshPartGetNextSegment tion), 87 (C++ function), 38 NewtonDeformableMeshGetVertexCount (C++ func- NewtonFracturedCompoundNeighborNodeList (C++ tion), 87 function), 37 NewtonDeformableMeshGetVertexStreams (C++ func- NewtonFracturedCompoundPlaneClip (C++ function), tion), 87 37 NewtonDeformableMeshSegmentGetIndexCount (C++ NewtonFracturedCompoundSetCallbacks (C++ func- function), 87 tion), 37

Index 93 Newton Dynamics Engine Documentation, Release 3

NewtonFree (C++ function), 13 NewtonMaterialGetDefaultGroupID (C++ function), 24 NewtonGetBroadphaseAlgorithm (C++ function), 13 NewtonMaterialGetMaterialPairUserData (C++ func- NewtonGetContactMergeTolerance (C++ function), 13 tion), 28 NewtonGetCurrentDevice (C++ function), 14 NewtonMaterialGetUserData (C++ function), 27 NewtonGetDeviceString (C++ function), 14 NewtonMaterialSetCallbackUserData (C++ function), 26 NewtonGetEulerAngle (C++ function), 52 NewtonMaterialSetCollisionCallback (C++ function), 26 NewtonGetJointSerializationCallbacks (C++ function), NewtonMaterialSetCompoundCollisionCallback (C++ 14 function), 27 NewtonGetMaxThreadsCount (C++ function), 16 NewtonMaterialSetContactElasticity (C++ function), 30 NewtonGetMemoryUsed (C++ function), 13 NewtonMaterialSetContactFrictionCoef (C++ function), NewtonGetMultiThreadSolverOnSingleIsland (C++ 30 function), 16 NewtonMaterialSetContactFrictionState (C++ function), NewtonGetThreadsCount (C++ function), 15 30 NewtonHeightFieldSetHorizontalDisplacement (C++ NewtonMaterialSetContactGenerationCallback (C++ function), 42 function), 27 NewtonHeightFieldSetUserRayCastCallback (C++ func- NewtonMaterialSetContactNormalAcceleration (C++ tion), 42 function), 31 NewtonInvalidateCache (C++ function), 14 NewtonMaterialSetContactNormalDirection (C++ func- NewtonIslandGetBody (C++ function), 23 tion), 31 NewtonIslandGetBodyAABB (C++ function), 23 NewtonMaterialSetContactPosition (C++ function), 32 NewtonJointGetBody0 (C++ function), 81 NewtonMaterialSetContactSoftness (C++ function), 30 NewtonJointGetBody1 (C++ function), 81 NewtonMaterialSetContactTangentAcceleration (C++ NewtonJointGetCollisionState (C++ function), 81 function), 31 NewtonJointGetInfo (C++ function), 81 NewtonMaterialSetContactTangentFriction (C++ func- NewtonJointGetStiffness (C++ function), 82 tion), 31 NewtonJointGetUserData (C++ function), 81 NewtonMaterialSetDefaultCollidable (C++ function), 24 NewtonJointIsActive (C++ function), 62 NewtonMaterialSetDefaultElasticity (C++ function), 25 NewtonJointSetCollisionState (C++ function), 81 NewtonMaterialSetDefaultFriction (C++ function), 25 NewtonJointSetDestructor (C++ function), 82 NewtonMaterialSetDefaultSoftness (C++ function), 26 NewtonJointSetStiffness (C++ function), 82 NewtonMaterialSetSurfaceThickness (C++ function), 25 NewtonJointSetUserData (C++ function), 80 NewtonMeshAddFace (C++ function), 84 NewtonMaterialContactRotateTangentDirections (C++ NewtonMeshApplyAngleBasedMapping (C++ function), function), 32 84 NewtonMaterialCreateGroupID (C++ function), 24 NewtonMeshApplyBoxMapping (C++ function), 84 NewtonMaterialDestroyAllGroupID (C++ function), 24 NewtonMeshApplyCylindricalMapping (C++ function), NewtonMaterialGetBodyCollidingShape (C++ function), 84 30 NewtonMeshApplySphericalMapping (C++ function), 84 NewtonMaterialGetContactFaceAttribute (C++ function), NewtonMeshApplyTransform (C++ function), 83 28 NewtonMeshApproximateConvexDecomposition (C++ NewtonMaterialGetContactForce (C++ function), 29 function), 84 NewtonMaterialGetContactMaxNormalImpact (C++ NewtonMeshBeginFace (C++ function), 84 function), 29 NewtonMeshBeginHandle (C++ function), 85 NewtonMaterialGetContactMaxTangentImpact (C++ NewtonMeshBuildFromVertexListIndexList (C++ func- function), 29 tion), 84 NewtonMaterialGetContactNormalSpeed (C++ func- NewtonMeshCalculateFaceNormal (C++ function), 86 tion), 28 NewtonMeshCalculateOOBB (C++ function), 84 NewtonMaterialGetContactPenetration (C++ function), NewtonMeshCalculateVertexNormals (C++ function), 84 30 NewtonMeshClip (C++ function), 84 NewtonMaterialGetContactPositionAndNormal (C++ NewtonMeshConvexMeshIntersection (C++ function), 84 function), 29 NewtonMeshCreate (C++ function), 83 NewtonMaterialGetContactTangentDirections (C++ NewtonMeshCreateConvexHull (C++ function), 83 function), 29 NewtonMeshCreateDelaunayTetrahedralization (C++ NewtonMaterialGetContactTangentSpeed (C++ func- function), 83 tion), 28 NewtonMeshCreateFirstLayer (C++ function), 86

94 Index Newton Dynamics Engine Documentation, Release 3

NewtonMeshCreateFirstSingleSegment (C++ function), NewtonMeshMaterialGetIndexStreamShort (C++ func- 85 tion), 85 NewtonMeshCreateFromCollision (C++ function), 83 NewtonMeshMaterialGetMaterial (C++ function), 85 NewtonMeshCreateFromMesh (C++ function), 83 NewtonMeshNextMaterial (C++ function), 85 NewtonMeshCreateFromSerialization (C++ function), 83 NewtonMeshPolygonize (C++ function), 84 NewtonMeshCreateNextLayer (C++ function), 86 NewtonMeshSaveOFF (C++ function), 83 NewtonMeshCreateNextSingleSegment (C++ function), NewtonMeshSerialize (C++ function), 83 85 NewtonMeshSetFaceMaterial (C++ function), 86 NewtonMeshCreateVoronoiConvexDecomposition (C++ NewtonMeshSimplify (C++ function), 84 function), 83 NewtonMeshTriangulate (C++ function), 84 NewtonMeshDestroy (C++ function), 83 NewtonMeshUnion (C++ function), 84 NewtonMeshDifference (C++ function), 84 NewtonRemoveUnusedVertices (C++ function), 84 NewtonMeshEndFace (C++ function), 84 NewtonSceneCollisionAddSubCollision (C++ function), NewtonMeshEndHandle (C++ function), 85 45 NewtonMeshFirstMaterial (C++ function), 85 NewtonSceneCollisionBeginAddRemove (C++ func- NewtonMeshFixTJoints (C++ function), 84 tion), 45 NewtonMeshGetEdgeIndices (C++ function), 86 NewtonSceneCollisionEndAddRemove (C++ function), NewtonMeshGetFaceIndexCount (C++ function), 86 45 NewtonMeshGetFaceIndices (C++ function), 86 NewtonSceneCollisionGetCollisionFromNode (C++ NewtonMeshGetFaceMaterial (C++ function), 86 function), 45 NewtonMeshGetFacePointIndices (C++ function), 86 NewtonSceneCollisionGetFirstNode (C++ function), 45 NewtonMeshGetFaces (C++ function), 86 NewtonSceneCollisionGetNextNode (C++ function), 45 NewtonMeshGetFirstEdge (C++ function), 86 NewtonSceneCollisionGetNodeByIndex (C++ function), NewtonMeshGetFirstFace (C++ function), 86 45 NewtonMeshGetFirstPoint (C++ function), 86 NewtonSceneCollisionGetNodeIndex (C++ function), 45 NewtonMeshGetFirstVertex (C++ function), 86 NewtonSceneCollisionRemoveSubCollision (C++ func- NewtonMeshGetIndirectVertexStreams (C++ function), tion), 45 85 NewtonSceneCollisionRemoveSubCollisionByIndex NewtonMeshGetNextEdge (C++ function), 86 (C++ function), 45 NewtonMeshGetNextFace (C++ function), 86 NewtonSceneCollisionSetSubCollisionMatrix (C++ NewtonMeshGetNextPoint (C++ function), 86 function), 45 NewtonMeshGetNextVertex (C++ function), 86 NewtonSelectBroadphaseAlgorithm (C++ function), 13 NewtonMeshGetNormalArray (C++ function), 85 NewtonSerializeToFile (C++ function), 14 NewtonMeshGetPointArray (C++ function), 85 NewtonSetContactMergeTolerance (C++ function), 13 NewtonMeshGetPointCount (C++ function), 85 NewtonSetCurrentDevice (C++ function), 14 NewtonMeshGetPointIndex (C++ function), 86 NewtonSetEulerAngle (C++ function), 52 NewtonMeshGetPointStrideInByte (C++ function), 85 NewtonSetFrictionModel (C++ function), 17 NewtonMeshGetTotalFaceCount (C++ function), 86 NewtonSetIslandUpdateEvent (C++ function), 18 NewtonMeshGetTotalIndexCount (C++ function), 86 NewtonSetJointSerializationCallbacks (C++ function), NewtonMeshGetUV0Array (C++ function), 85 14 NewtonMeshGetUV1Array (C++ function), 85 NewtonSetMemorySystem (C++ function), 13 NewtonMeshGetVertexArray (C++ function), 85 NewtonSetMinimumFrameRate (C++ function), 17 NewtonMeshGetVertexCount (C++ function), 85 NewtonSetMultiThreadSolverOnSingleIsland (C++ func- NewtonMeshGetVertexIndex (C++ function), 86 tion), 16 NewtonMeshGetVertexIndexFromPoint (C++ function), NewtonSetSolverConvergenceQuality (C++ function), 17 86 NewtonSetSolverModel (C++ function), 16 NewtonMeshGetVertexStreams (C++ function), 85 NewtonSetThreadsCount (C++ function), 15 NewtonMeshGetVertexStrideInByte (C++ function), 85 NewtonSkeletonContainerAttachBone (C++ function), 88 NewtonMeshIntersection (C++ function), 84 NewtonSkeletonContainerAttachJointArray (C++ func- NewtonMeshIsFaceOpen (C++ function), 86 tion), 88 NewtonMeshIsOpenMesh (C++ function), 84 NewtonSkeletonContainerCreate (C++ function), 88 NewtonMeshLoadOFF (C++ function), 83 NewtonSkeletonContainerDelete (C++ function), 88 NewtonMeshMaterialGetIndexCount (C++ function), 85 NewtonSkeletonContainerFinalize (C++ function), 88 NewtonMeshMaterialGetIndexStream (C++ function), 85 NewtonSkeletonContainerFirstChild (C++ function), 88

Index 95 Newton Dynamics Engine Documentation, Release 3

NewtonSkeletonContainerGetBodyFromNode (C++ NewtonUserJointSetRowMaximumFriction (C++ func- function), 88 tion), 79 NewtonSkeletonContainerGetParent (C++ function), 88 NewtonUserJointSetRowMinimumFriction (C++ func- NewtonSkeletonContainerGetParentJointFromNode tion), 79 (C++ function), 88 NewtonUserJointSetRowSpringDamperAcceleration NewtonSkeletonContainerGetRoot (C++ function), 88 (C++ function), 79 NewtonSkeletonContainernDetachBone (C++ function), NewtonUserJointSetRowStiffness (C++ function), 80 88 NewtonUserMeshCollisionContinuousOverlapTest (C++ NewtonSkeletonContainerNextSibling (C++ function), function), 41 88 NewtonWaitForUpdateToFinish (C++ function), 17 NewtonSliderCalculateStopAccel (C++ function), 71 NewtonWorldAddPostListener (C++ function), 21 NewtonSliderGetJointForce (C++ function), 71 NewtonWorldAddPreListener (C++ function), 21 NewtonSliderGetJointPosit (C++ function), 70 NewtonWorldCollide (C++ function), 23 NewtonSliderGetJointVeloc (C++ function), 71 NewtonWorldConvexCast (C++ function), 22 NewtonSliderSetUserCallback (C++ function), 70 NewtonWorldCriticalSectionLock (C++ function), 14 NewtonStaticCollisionSetDebugCallback (C++ func- NewtonWorldCriticalSectionUnlock (C++ function), 15 tion), 41 NewtonWorldFloatSize (C++ function), 19 NewtonSyncThreadJobs (C++ function), 16 NewtonWorldForEachBodyInAABBDo (C++ function), NewtonTreeCollisionAddFace (C++ function), 42 19 NewtonTreeCollisionBeginBuild (C++ function), 42 NewtonWorldForEachJointDo (C++ function), 19 NewtonTreeCollisionEndBuild (C++ function), 42 NewtonWorldGetBodyCount (C++ function), 21 NewtonTreeCollisionForEachFace (C++ function), 43 NewtonWorldGetConstraintCount (C++ function), 21 NewtonTreeCollisionGetFaceAttribute (C++ function), NewtonWorldGetDestructorCallback (C++ function), 20 43 NewtonWorldGetFirstBody (C++ function), 18 NewtonTreeCollisionGetVertexListTriangleListInAABB NewtonWorldGetFirstMaterial (C++ function), 27 (C++ function), 44 NewtonWorldGetListenerUserData (C++ function), 20 NewtonTreeCollisionSetFaceAttribute (C++ function), 43 NewtonWorldGetNextBody (C++ function), 18 NewtonTreeCollisionSetUserRayCastCallback (C++ NewtonWorldGetNextMaterial (C++ function), 28 function), 41 NewtonWorldGetPostListener (C++ function), 21 NewtonUniversalCalculateStopAlpha0 (C++ function), NewtonWorldGetPreListener (C++ function), 21 75 NewtonWorldGetUserData (C++ function), 20 NewtonUniversalCalculateStopAlpha1 (C++ function), NewtonWorldGetVersion (C++ function), 19 76 NewtonWorldListenerGetBodyDestroyCallback (C++ NewtonUniversalGetJointAngle0 (C++ function), 75 function), 20 NewtonUniversalGetJointAngle1 (C++ function), 75 NewtonWorldListenerSetBodyDestroyCallback (C++ NewtonUniversalGetJointForce (C++ function), 76 function), 21 NewtonUniversalGetJointOmega0 (C++ function), 75 NewtonWorldRayCast (C++ function), 21 NewtonUniversalGetJointOmega1 (C++ function), 75 NewtonWorldSetCollisionConstructorDestructorCallback NewtonUniversalSetUserCallback (C++ function), 74 (C++ function), 20 NewtonUpdate (C++ function), 17 NewtonWorldSetDestructorCallback (C++ function), 20 NewtonUpdateAsync (C++ function), 17 NewtonWorldSetUserData (C++ function), 19 NewtonUpVectorGetPin (C++ function), 76 NewtonYield (C++ function), 15 NewtonUpVectorSetPin (C++ function), 77 NewtonUserCalculateRowZeroAccelaration (C++ func- tion), 79 NewtonUserJoinRowsCount (C++ function), 79 NewtonUserJointAddAngularRow (C++ function), 78 NewtonUserJointAddGeneralRow (C++ function), 78 NewtonUserJointAddLinearRow (C++ function), 78 NewtonUserJointGetGeneralRow (C++ function), 79 NewtonUserJointGetRowForce (C++ function), 80 NewtonUserJointSetFeedbackCollectorCallback (C++ function), 80 NewtonUserJointSetRowAcceleration (C++ function), 79

96 Index