Newton SDK DBPro Wrapper v1.53

By Walaber
All Coding between 1.31-1.32B by Kjelle
Updated to 1.53 by Tiresius

Main Index of Commands

Rigid Body Interface

NDB_BodySetGravity

syntax: NDB_BodySetGravity body, flag
body index of the rigid body (integer)
flag gravity flag (1=gravity on, 0=gravity off)
returns: nothing

Comments: Sets whether or not to apply the standard gravitational force to the body every call of NDB_NewtonUpdate.  a value of 1 = apply gravity, 0 = no gravity.

NDB_BodyGetGravity

syntax: int = NDB_BodyGetGravity( body )
body index of the rigid body (integer)
(vector 1) the gravitational force
returns: gravity flag for the body (int)
Comments: Returns the current gravity setting for the rigid body.  see NDB_BodySetGravity for more details.

NDB_BodySetSphere

syntax: NDB_BodySetSphere body, flag
body index of the rigid body (integer)
flag sphere flag (1=is a sphere, 0=not a sphere)
returns: nothing

Comments: Sets whether or not a body will use a modified collision callback setup by NDB_NewtonMaterialSetSphereCollisionCallback. Please see the notes in that function for more details.

NDB_BodyGetSphere

syntax: int = NDB_BodyGetSphere( body )
body index of the rigid body (integer)
returns: sphere flag for the body (int)
Comments: Returns the current sphere flag setting for the rigid body. See NDB_BodySetGravity for more details.

NDB_BodySetBuoyancy

syntax: NDB_BodySetBuoyancy body, flag
body index to the rigid body (integer)
flag buoyancy flag (0=off 1=on 2=per body)
returns: nothing
Comments: sets whether to apply the bouyancy force to the rigid body. A flag of "1" sets buoyancy on, "0" turns it off. And 2 uses the settings used in the call to NDB_BodySetLiquid

NDB_BodyGetBuoyancy

syntax: int = NDB_BodyGetBuoyancy( body )
body index to the rigid body (integer)
returns: integer flag for the body bouyancy.
Comments: none.

NDB_BodySetBuoyancyPlane

syntax: NDB_BodySetBuoyancyPlane body
body index to the rigid body (integer)
(vector 1) temp vector used for passing values.
returns: nothing
Comments: Sets the buoyancy plane to the contents of temp vector 1. The buoyancy plane is defined as a normal vector (3 floats) and a distance (float). If you have a normal and a point on the plane, you can calculate the distance value like so:

normal vector (nx, ny, nz)
point in plane (x,y,z)

general equation: nx*x+ny*y+ nz*z+d=0

solve for d:
d = (nx*x + ny*y + nz*z) * -1

plug in this equation to solve for d. then fill temp vector 1 like so: NDB_SetVector nx#, ny#, nz#, d#

This is the proper format for the buoyancy plane equation. Check the demo programs for an example of buoyancy.

NDB_BodyGetBuoyancyPlane

syntax: NDB_BodyGetBuoyancyPlane body
body index to the rigid body (integer)
returns: nothing
Comments: fills temp vector 1 with the current buoyancy plane data for the specified body.

NDB_BodySetLiquid

syntax: NDB_BodySetLiquid body, f_density, l_visc, a_visc
body ID of the rigid body (integer)
  f_density fluid density (float)
  l_visc linear viscosity (float)
  a_visc angular viscosity (float)
  (vector 1) vector data used to describe acceleration due to gravity
returns: nothing
Comments: Sets the custom liquid values (for buoyancy forces) for the rigid body, describing the density and viscosity of the liquid.  make sure to fill temp vector 1 with the gravitational vector for the liquid as well. You need to use NDB_BodySetBuoyancy with a flag of '2' in order for these values to take effect.

NDB_BodyGetLiquid

syntax: NDB_BodyGetLiquid body
  body ID of the rigid body (integer)
  (vector 1)

temp vector used to return values

  (vector 2) temp vector used to return values
returns: nothing

Comments: returns the custom liquid settings for the rigid body.  like so:

temp vector 1
x = fluid density
y = linear viscosity
z = angular viscosity

temp vector 2 = gravity vector

NDB_BodyAddForceLocal

syntax: NDB_BodyAddForceLocal body [,NoScale]
  body ID of the rigid body (integer)
  NoScale If NoScale set to 1, do not scale force to mass *optional
  (vector 1)

temp vector used to pass values

  (vector 2) temp vector used to pass values
returns: nothing

Comments: this command adds a force to a body, based on the local coordinate system of that body.  this is extremely useful for adding forces regardless of the body's orientation.  for example you can apply a thrust force for a spaceship, that always pushes 'forward', regardless of the object orientation.

When using this command, you must set temp vector 1 to the local position of the force, and temp vector 2 with a vector representing the force.

you can call this command multiple times to apply several different forces, resulting in a net force on the body.  The default force on a body is reset to zero with each call to NDB_NewtonUpdate.  Note that this command works independantly to the StandardGravity, which can be applied to the body with the NDB_BodySetGravity command.

NOTE: In 1.53 this command received a flag to not scale the force to the mass of the object. Default behavior is scaling the mass (which is really adding to the acceleration of the object) in order to maintain backwards compatibility.

Example:
apply a force of 10.0 along the local z-axis of the body, with an offset of 5 units in the y direction:
NDB_SetVector 1, 0.0, 5.0, 0.0
NDB_SetVector 2, 0.0, 0.0, 10.0
NDB_BodyAddForceLocal body1

NDB_BodyAddForceGlobal

syntax: NDB_BodyAddForceGlobal body [,NoScale]
  body ID of the rigid body (integer)
  NoScale If NoScale set to 1, do not scale force to mass *optional
  (vector 1)

temp vector used to pass values

  (vector 2) temp vector used to pass values
returns: nothing

Comments: this command adds a force to a body, based on the global coordinate system.  this is extremely useful for adding forces based on a specific global position..

When using this command, you must set temp vector 1 to the local position of the force, and temp vector 2 with a vector representing the force.

you can call this command multiple times to apply several different forces, resulting in a net force on the body.  The default force on a body is reset to zero with each call to NDB_NewtonUpdate.  Note that this command works independantly to the StandardGravity, which can be applied to the body with the NDB_BodySetGravity command.

NOTE: In 1.53 this command received a flag to not scale the force to the mass of the object. Default behavior is scaling the mass (which is really adding to the acceleration of the object) in order to maintain backwards compatibility.

Example:
apply a force of 10.0 along the global y-axis of the body, at global position (3,5,0):
NDB_SetVector 1, 3.0, 5.0, 0.0
NDB_SetVector 2, 0.0, 10.0, 0.0
NDB_BodyAddForceGlobal body1

NDB_BodySetForceLocal

syntax: NDB_BodySetForceLocal body [,NoScale]
  body ID of the rigid body (integer)
  NoScale If NoScale set to 1, do not scale force to mass *optional
  (vector 1)

temp vector used to pass values

  (vector 2) temp vector used to pass values
returns: nothing

Comments: this command sets the net force to a body directly, based on the local coordinate system of that body.

When using this command, you must set temp vector 1 to the local position of the force, and temp vector 2 with a vector representing the force.

This command is similar to NDB_BodyAddForceLocal, but it overwrites any previous forces applied to the body, and sets the net force directly.  you can use this command for resetting object forces, or just applying a single force to the body. syntax is same as NDB_BodyAddForceLocal.

NOTE: In 1.53 this command received a flag to not scale the force to the mass of the object. Default behavior is scaling the mass (which is really setting the acceleration of the object) in order to maintain backwards compatibility.

NDB_BodySetForceGlobal

syntax: NDB_BodyAddForceGlobal body [,NoScale]
  body ID of the rigid body (integer)
  NoScale If NoScale set to 1, do not scale force to mass *optional
  (vector 1)

temp vector used to pass values

  (vector 2) temp vector used to pass values
returns: nothing

Comments: this command sets the net force to a body directly, based on the global coordinate system.

When using this command, you must set temp vector 1 to the global position of the force, and temp vector 2 with a vector representing the force.

This command is similar to NDB_BodyAddForceGlobal, but it overwrites any previous forces applied to the body, and sets the net force directly.  you can use this command for resetting object forces, or just applying a single force to the body. syntax is same as NDB_BodyAddForceGlobal.

NOTE: In 1.53 this command received a flag to not scale the force to the mass of the object. Default behavior is scaling the mass (which is really setting the acceleration of the object) in order to maintain backwards compatibility.

NDB_BodyAddTorque

syntax: NDB_BodyAddTorque body
  body ID of the rigid body (integer)
  (vector 1)

temp vector used to pass values

returns: nothing

Comments: this command adds a torque (rotational) force to a body. In most cases, the above commands should be used, as they generate the proper torque forces for you, based on the position of the force relative to the center of mass of the body. However there may be certain cases where the user wants to add ONLY a Torque force, of an arbitrary value to a body, and so this command has been maintained.

NDB_BodySetTorque

syntax: NDB_BodySetTorque body
  body ID of the rigid body (integer)
  (vector 1)

temp vector used to pass values

returns: nothing

Comments: this command sets the torque (rotational) force to a body. In most cases, the above commands should be used, as they generate the proper torque forces for you, based on the position of the force relative to the center of mass of the body. However there may be certain cases where the user wants to set a specific Torque force to a body, and so this command has been maintained.

NDB_BodyGetRotation

syntax: NDB_BodyGetRotation body
body index of the rigid body (integer)
(vector 1) temp vector used to return values
returns: nothing
Comments: Fills temp vector 1 with the global rotation for this body.  Similar to the object angle commands in DBPro, but for a rigid body.  Note that the angles returned here can be confusing because they are converted from matrix data.  For a more detailed picture of the body rotation, try using the NDB_NewtonBodyGetMatrix command.

NDB_BodyGetPosition

syntax: NDB_BodyGetPosition body
body index of the rigid body (integer)
(vector 1) temp vector used to return values
returns: nothing
Comments: Fills temp vector 1 with the global position for this body.  Similar to the object position commands in DBPro, but for a rigid body.  Note these values can also be gathered from the NDB_NewtonBodyGetMatrix command.

NDB_BodySetDBProData

syntax: NDB_BodySetDBProData body, db_num
body index to rigid body (int)
db_num dbpro object (int)
returns: nothing

Comments: This command assigns a DBPro object (3D model) to a rigid body. Newton can automatically position/rotate the object for you, as a visual representation of the rigid body.

Also, calling the NDB_NewtonBodySetDestructorCallback command will automatically delete the DBPro object when the rigid body is destroyed.

NDB_GetBody

syntax: int = NDB_GetBody( db_num )
db_num dbpro object number (int)
returns: index to the rigid body (int)
Comments: If you have assigned a rigid body to a dbpro object, this command will return the index to the rigid body, based on the dbpro object number passed.

NDB_GetDBPro

syntax: int = NDB_GetDBPro( body )
body index to the rigid body (int)
returns: index to the dbpro object (int)
Comments: If you have assigned a rigid body to a dbpro object, this command will return the dbpro object number assigned to the rigid body passed.

NDB_BodyExist

syntax: int = NDB_BodyExist( body )
body index to the rigid body (int)
returns: int (0-1)
Comments: returns a one "1" if the body exists, zero "0" if it doesn't.

 

Rigid Body Interface Commands

NDB_NewtonCreateBody

syntax: int = NDB_NewtonCreateBody( col )
col index to the collision data that describes this rigid body.
returns: index to the rigid body
Comments: This is a very important command. All rigid bodies in Newton are made with this command. The basic process is to make collision data (with the above commands), and then make a rigid body based on that collision data. The process is the same for primitives, collision arrays, and mesh collision. The returned value is an index to the rigid body, and is used in all subsequent commands affecting the body. Note that the wrapper no longer automatically assigns a DBPro object to each body, you must do this manually now with the NDB_BodySetDBProData command.
Body = NDB_NewtonCreateBody( col ) make a body from collision data "col".

NDB_NewtonDestroyBody

syntax: NDB_NewtonDestroyBody body
body index to the rigid body.
returns: nothing
Comments: Destroys a rigid body from the system. If you have called NDB_NewtonBodySetDestructorCallback, the DBPro object associated with the rigid body will also be deleted.

NDB_NewtonBodySetDestructorCallback

syntax: NDB_NewtonBodySetDestructorCallback body
body index to the rigid body.
returns: nothing
Comments: Newton allows you to automatically destroy the visual representation of an body when the body is removed from the world. Setting this call for a body will tell Newton to destory the DBPro object associated with it when the body is destroyed. See related command NDB_NewtonSetBodyLeaveWorldEvent.

NDB_NewtonBodySetMassMatrix

syntax: NDB_NewtonBodySetMassMatrix body, Mass, [ Ixx, Iyy, Izz ]
body index to the rigid body.
Mass mass of the body (float)
Ixx moment of inertia of the X principal axis of inertia of the body. *optional
Iyy moment of inertia of the Y principal axis of inertia of the body. *optional
Izz moment of inertia of the Z principal axis of inertia of the body. *optional
returns: nothing
Comments: Sets the mass and rotational inertia for the body. If no Ixx/Iyy/Izz values are supplied, the contents of temp vector 1 are used. This is convenient, because the NDB_CalculateMIxxx commands fill that vector with the relevant values.
From the newton documentation: Newton algorithms have no restriction on the values for the mass values, but due to floating point dynamic range (24 bit presision) 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 behaviour.
NBD_NewtonBodySetMassMatrix Ball, 10.0, 1.0, 1.0, 1.0 - sets object "ball" to have a mass of 10, Ixx=1, Iyy=1, Izz=1.

NDB_NewtonBodyGetMassMatrix

syntax: float = NDB_NewtonBodyGetMassMatrix( body )
body index to the rigid body.
returns: Mass of the body, and fills temp vector 1 with Ixx, Iyy, Izz
Comments:Retrieve the Mass Matrix, set using NDB_NewtonBodySetMassMatrix. the function returns the mass of the body as a float, and fills temp vector 1 with the Ixx, Iyy, Izz data.
Mass# = NDB_NewtonBodyGetMassMatrix( Ball )
Ixx# = NDB_GetVector_X()
Ixx# = NDB_GetVector_Y()
Ixx# = NDB_GetVector_Z()

NDB_NewtonBodyGetInvMass

syntax: float = NDB_NewtonBodyGetInvMass( body )
body index to the rigid body.
returns: Inverse Mass of the body, and fills temp vector 1 with InvIxx, InvIyy, InvIzz
Comments:Retrieve the Inverse Mass Matrix, set using NDB_NewtonBodySetMassMatrix. the function returns the inverse mass of the body as a float, and fills temp vector 1 with the InvIxx, InvIyy, InvIzz data.
InvMass# = NDB_NewtonBodyGetInvMass( Ball )
InvIxx# = NDB_GetVector_X()
InvIxx# = NDB_GetVector_Y()
InvIxx# = NDB_GetVector_Z()

NDB_NewtonBodySetMatrix

syntax: NDB_NewtonBodySetMatrix body
body index to the rigid body.
(matrix) matrix holding the position and rotation of the body in global space.
returns: nothing
Comments: This is a very important command. It allows you to set the position and rotation of a body in Global space. In DBPro terms. this is the "position object" and "rotate object" commands, all rolled into one. You must set the temp matrix inside the wrapper before calling this function. use NDB_BuildMatrix to do this.
EXAMPLE 1: an object "floor" with no rotation, at point (-10, 10, 0)
NDB_BuildMatrix 0.0, 0.0, 0.0, -10.0, 10.0, 0.0
NDB_NewtonBodySetMatrix Floor


EXAMPLE 2: an object "missile" with rotation (20.0, 45.0, 0.0) at point (100, 100, 10)
NDB_BuildMatrix 20.0, 45.0, 0.0, 100.0, 100.0, 10.0
NDB_NewtonBodySetMatrix missile


See the demo projects for many examples of how to use these commands.

NDB_NewtonBodySetMatrixRecursive

syntax: NDB_NewtonBodySetMatrixRecursive body
body index to the rigid body.
(matrix) matrix holding the position and rotation of the body in global space.
returns: nothing

Comments: This command is just like the above command, but it will also automatically move any other bodies connected to this body (via joints). you can use it to move complex body/joint combinations in one command. be sure to setup a temp matrix with NDB_BuildMatrix before you call the command.

Remark

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.

Remark

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).

Remark

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.

NDB_NewtonBodyGetMatrix

syntax: NDB_NewtonBodyGetMatrix body
body index to the rigid body.
returns: nothing
Comments: Fills the internal temp matrix with the translation/rotation matrix for the body. You can access the data in the matrix with the following commands: NDB_GetMatrix, NDB_GetVector_X, NDB_GetVector_Y, NDB_GetVector_Z
EXAMPLE 1: - find the position of a rigid body "Missile" with this command.
NDB_NewtonBodyGetMatrix "Missile"
NDB_GetMatrix
posx# = NDB_GetVector_X(4)
posy# = NDB_GetVector_Y(4)
posz# = NDB_GetVector_Z(4)


*note- since Newton can automatically update object positions for you, in most cases you should be able to use the built-in dbpro commands "object position x/y/z()", or "object rotation x/y/z()".

NDB_NewtonBodySetCollision

syntax: NDB_NewtonBodySetCollision body, col
body index to the rigid body.
col index to the collision data that describes this rigid body.
returns: nothing
Comments: When you first make a body with the NDB_NewtonCreateBody command, you specify collision data (col) to describe the body. Newton allows you to change the collision data for a body at runtime as well, using this command. This can be used to create transforming characters, scaling objects, etc.

NDB_NewtonBodyCoriolisForcesMode

syntax: NewtonBodyCoriolisForcesMode body, Coriolismode
body index to the rigid body.
Coriolismode Mode of Coriolisforces. Force mode zero indicate not gyroscopic force calculation. 
returns: nothing

Comments: Gyroscopic forces internal forces generated as a result of an asymmetric tensor. They are a pure mathematical consequence that the physics have to comply in order to agree with the math. As Gyroscopic forces are not real forces but the result of net unbalance of the changing inertia tensor or a rigid body when its angular velocity is measured on a reference frame different than the body’s own. Gyroscopic forces are extremely non linear by nature, therefore a first order implicit integrator will have a extremely hard time at dealing with this kind of forces, however because the fact that they are not real forces they do not make much difference in the outcome of the integration. Fortunately due to the fact that the magnitude of gyroscopic forces is proportional to the unbalance of the inertia tensor, it is possible to disregard the effect of this forces by assuming their inertial tensor is symmetric for the purpose of this calculation. For most cases an ordinary person is not capable to distinguish the motion of a body subject to gyroscopic forces and one that is not, especially when the motion is constrained. Because of this fact gyroscopic force are turned off by default in Newton, however there are cases when the desire effect is precisely to simulate these forces like a spinning top, or the design of a space navigational system, etc. The most important feature of gyroscopic forces is that they make the rigid body to process.

V1.31

NDB_NewtonBodyGetCollision

syntax: int = NDB_NewtonBodyGetCollision( body )
body index to the rigid body.
returns: index to the collision data used for this object.
Comments: Use this command to find what collision data is currently being used by a body.

NDB_NewtonBodySetMaterialGroupID

syntax: NDB_NewtonBodySetMaterialGroupID body, group_id
body index to the rigid body.
group_id ID number for the material to assign to ths body.
returns: nothing
Comments: Sets the material for a body. The material must have already been created with the NDB_NewtonMaterialCreateGroupID command.
BallMat = NDB_NewtonMaterialCreateGroupID
(make body here)
NDB_NewtonBodySetMaterialGroupID Body, BallMat - sets the material of "Body" to "BallMat".

NDB_NewtonBodyGetMaterialGroupID

syntax: int = NDB_NewtonBodyGetMaterialGroupID( body )
body index to the rigid body.
returns: integer ID of the material being used by the rigid body.
Comments: none

NDB_NewtonBodySetAutoFreeze

syntax: NDB_NewtonBodySetAutoFreeze body, flag
body index to the rigid body.
flag 0 = off, 1 = on
returns: nothing
Comments: Newton automatically removes bodies that have reached a state of equilibrium from the active body list. In essence, bodies that are in a state of rest, are "forgotten" by the engine until some force puts them back into motion. However for some objects, like characters, AI-driven objects, this can cause problems. Setting the flag to "0" for a body will keep it permanently in the active list. It is not recommended to do this for many objects, as performance will be severly affected. Bodies default to an AutoFreeze "on".

NDB_NewtonBodyGetAutoFreeze

syntax: int = NDB_NewtonBodyGetAutoFreeze( body )
body index to the rigid body.
returns: integer flag of AutoFreeze status for the rigid body.
Comments: none

NDB_NewtonBodySetFreezeTreshold

syntax: NDB_NewtonBodySetFreezeTreshold(body,frames)
body

index to the rigid body.

Frames Number of frames the body and angular velocity will not exceed freezeSpeedMag and freezeOmegaMag.
(vector 1) temp vector used to pass values.
returns: nothing
Comments: Newton ignores objects that have come to a complete state of rest. Unfortunately, due to the innacuracy of floating point numbers, you must accept a very-small number as being equivalent to zero. This function sets the threshold for the body. There are 4 thresholds.This function uses the contents of temo vector 1 for the values. They are:
AccelMag - acceleration threshold. (vector value X)
AlphaMag - angular acceleration threshold. (vector value Y)
SpeedMag - velocity threshold. (vector value Z)
OmegaMag - angular velocity threshold. (vector value W)

From the Newton documentation: Ideally, a body should be deactivated when it reaches a state of stable equilibrium. However, because of floating point inaccuracy, discreet time step simulation and other factors it is virtually impossible for a body to reach that state in a real-time simulation. Therefore, in the Newton World, a body is considered to be in stable equilibrium when its net acceleration, and velocity fall below some threshold for one frame. The Newton Engine does not use time slices for the activation/deactivation of bodies.

The default and minimum values for the thresholds is 0.01. These values are tuned for single objects colliding under the influence of gravity. It is possible that for complex configuration of bodies like multiples pendulums, ragdolls, etc. these values may need to be increased. This is because joints have the property that they add a small amount of energy to the system in order to reduce the separation error. This may cause the bodies reach a state of unstable equilibrium. That is, when a body oscillates between two different positions because the energy added to the body is equal to to the energy dissipated by the integrator. This is a situation that is hard to predict, and the best solution is to tweak these values for specific cases.

NDB_NewtonBodyGetFreezeTreshold

syntax: NDB_NewtonBodyGetFreezeTreshold body
body index to the rigid body.
returns: nothing
Comments: Fills temp vector 1 with the FreezeThreshold data for the rigid body. for an explanation of the data, see the command above, NDB_NewtonBodySetFreezeTreshold

NDB_NewtonBodySetVelocity

syntax: NDB_NewtonBodySetVelocity body
body index to the rigid body.
(vector 1) temp vector used to pass values.
returns: nothing
Comments: You can physically set the linear velocity of any body with this command. Set temp vector 1 with the velocity vector before calling this command.
Setting velocity of body "Car" to x=100, y=0, z=0
NDB_SetVector 100.0, 0.0, 0.0
NDB_NewtonBodySetVelocity Car

NDB_NewtonBodyGetVelocity

syntax: NDB_NewtonBodyGetVelocity body
body index to the rigid body.
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the velocity of the specified rigid body. Use the NDB_GetVector_X , Y, and Z commands to get the components of the vector.
EXAMPLE: Increase X velocity of body "Wheel" by 5.0
NDB_NewtonBodyGetVelocity Wheel
x# = NDB_GetVector_X() : y# = NDB_GetVector_Y() : z# = NDB_GetVector_Z()
inc x#, 5.0
NDB_SetVector x#, y#, z#
NDB_NewtonBodySetVelocity Wheel

NDB_NewtonBodySetOmega

syntax: NDB_NewtonBodySetOmega body
body index to the rigid body.
(vector 1) temp vector used to pass values.
returns: nothing
Comments: You can physically set the angular (rotational) velocity of any body with this command. Set temp vector 1 with the angular velocity vector before calling this command.

NDB_NewtonBodyGetOmega

syntax: NDB_NewtonBodyGetOmega body
body index to the rigid body.
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the angular velocity of the specified rigid body. Use the NDB_GetVector_X , Y, and Z commands to get the components of the vector.

NDB_NewtonBodySetLinearDamping

syntax: NDB_NewtonBodySetLinearDamping body, lin_damp
body index to the rigid body.
lin_damp linear damping value for the body (float)
returns: nothing
Comments: From the Newton documentation: The dampening viscous friction force is added to the extenal 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 preventz the integrator from adding very large velocities to a body.

the default value of linearDamp is 0.1.

NDB_NewtonBodyGetLinearDamping

syntax: float = NDB_NewtonBodyGetLinearDamping( body )
body index to the rigid body.
returns: float value which is the linear damping for the body.
Comments: none.

NDB_NewtonBodySetAngularDamping

syntax: NDB_NewtonBodySetAngularDamping body
body index to the rigid body.
(vector 1) temp vector used to pass values.
returns: nothing
Comments: This function requires you set the temp vector 1 with the X, Y, and Z angular damping values before calling.

From the newton documentation: 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 recomended 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.

The default value of linearDamp is 0.1.

NDB_NewtonBodyGetAngularDamping

syntax: NDB_NewtonBodyGetAngularDamping body
body index to the rigid body.
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills the temp vector 1 with the angular damping for the body.

 

NDB_NewtonAddBodyImpulse

syntax: NDB_NewtonAddBodyImpulse body
body index to the rigid body.
(vector 1) temp vector used to pass values.
(vector 2) temp vector used to pass values.
returns: nothing
Comments: This function applies an impulse the the specified rigid body. Before calling this command, fill temp vector 1 with the change in velocity to the body. Then fill temp vector 2 with the location of the impulse in global space.
EXAMPLE: apply an increase in velocity of (+1, -1, -1) to body "Man" at point (30, 20, 10)
NDB_SetVector 1, 1.0, -1.0, -1.0
NDB_SetVector 2, 30.0, 20.0, 10.0
NDB_NewtonAddBodyImpulse Man

NDB_NewtonBodySetCentreOfMass

syntax: NDB_NewtonBodySetCentreOfMass body
body index to the rigid body (integer)
(vector 1) temp vector used for passing values.
returns: nothing
Comments:
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.
Care must be taken when offsetting the center of mass of a body. The application must make sure that the external torques resulting from forces applied at at point relative to the center of mass are calculated appropriately.

NDB_NewtonBodyGetCentreOfMass

syntax: NDB_NewtonBodyGetCentreOfMass body
body index to the rigid body (integer)
(vector 1) temp vector used for returning values.
returns: nothing
Comments:
Fills the temp vector 1 with the center of mass for the body.

NDB_NewtonBodySetContinuousCollisionMode

syntax: NDB_NewtonBodySetContinuousCollisionMode body, state
body index to the rigid body (integer)
state continuous collision state (0=off 1=on)
returns: nothing
Comments: Please see NDB_NewtonMaterialSetContinuousCollisionMode for details on how to use the Continuous Collision functions.

NDB_NewtonBodyGetContinuousCollisionMode

syntax: int = NDB_NewtonBodyGetContinuousCollisionMode( body )
body index to the rigid body (integer)
returns: integer state for the body continuous collision.
Comments: Please see NDB_NewtonMaterialSetContinuousCollisionMode for details on how to use the Continuous Collision functions.