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

Group ID Interface Commands

NDB_NewtonMaterialGetDefaultGroupID

syntax: int = NDB_NewtonMaterialGetDefaultGroupID()
no variables passed to this function
returns: integer index of the default material group ID.
Comments: When rigid bodies are created, they are automatically assigned the "default" material, which defines things like friction, etc. This function returns the ID to the default material, so you can set interaction between the default material and other custom materials.

NDB_NewtonMaterialCreateGroupID

syntax: int = NDB_NewtonMaterialCreateGroupID()
no variables passed to this function
returns: integer index of the newly created material group
Comments: To setup how objects interact, you first make materials. This command makes a new material, and gives you an index number to refer to it by. Then you can use the Material Setup Interface Commands to set how 2 materials should interact.

NDB_NewtonMaterialDestroyAllGroupID

syntax: NDB_NewtonMaterialDestroyAllGroupID
no variables passed to this function
returns: nothing
Comments: Deletes all materials. All rigid bodies must be deleted before this command is called.



Material Setup Interface Commands

NDB_NewtonMaterialSetDefaultCollidable

syntax: NDB_NewtonMaterialSetDefaultCollidable mat1, mat2, state
mat1 index of first material (integer)
mat2 index of second material (integer)
state state for this pair. 1 = collidable, 0 non-collidable
returns: nothing
Comments: Use this command to set collision for a pair of materials.
NDB_NewtonMaterialSetDefaultCollidable Metal, Char, 0 sets materials "Metal" and "Char" to NOT collide with each other by default.
NDB_NewtonMaterialSetDefaultCollidable Plastic, Wood, 1 sets materials "plastic" and "wood" to collide by default.

NDB_NewtonMaterialSetDefaultFriction

syntax: NDB_NewtonMaterialSetDefaultFriction mat1, mat2, static, kinetic
mat1 index of first material (integer)
mat2 index of second material (integer)
static coeficient of static friction (float)
kinetic coefiction of kinetic friction (float)
returns: nothing
Comments:Sets the friction values for a pair of materials. Both values should be positive, and are recommended to be between 0 and 1.0
NDB_NewtonMaterialSetDefaultFriction Char, Ice, 0.5, 0.15 sets friction between materials "char" and "ice" (static friction is pretty strong, but once you start sliding, there if little friction)
NDB_NewtonMaterialSetDefaultFriction Rubber, Street, 0.95, 0.88 sets friction between materials "Rubber" and "Street" very high for good traction.

NDB_NewtonMaterialSetDefaultElasticity

syntax: NDB_NewtonMaterialSetDefaultElasticity mat1, mat2, elasticity
mat1 index of first material (integer)
mat2 index of second material (integer)
elasticity coeficient of elasticity (float)
returns: nothing
Comments: Sets the elasticity between a pair of materials.

NDB_NewtonMaterialSetDefaultSoftness

syntax: NDB_NewtonMaterialSetDefaultSoftness mat1, mat2, softness
mat1 index of first material (integer)
mat2 index of second material (integer)
softness coeficient of softness (float)
returns: nothing
Comments: Sets the softness between a pair of materials.

NDB_NewtonMaterialSetContinuousCollisionMode

syntax: NDB_NewtonMaterialSetContinuousCollisionMode mat1, mat2, state
mat1 index of first material (integer)
mat2 index of second material (integer)
state state for this pair. 1 = Continuous, 0 = Not Continuous
returns: nothing
Comments: Use this command to set continuous collision for a pair of materials.

Remarks
Continuous collision mode enabled allows the engine to predict colliding contact on rigid bodies Moving at high speed of subject to strong forces.

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.

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 continue collision mode must on the material pair of the colliding bodies as well as on at least one of the two colliding bodies.

For performance reason the bodies angular velocities is only use on the broad face of the collision, but not on the contact calculation. 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 at a high speed.

NDB_NewtonMaterialSetCollisionCallback

syntax: NDB_NewtonMaterialSetCollisionCallback mat1, mat2
mat1 index of first material (integer)
mat2 index of second material (integer)
returns: nothing
Comments: This is another important command. Setting this callback tells the wrapper to record all collisions that happen between bodies of these materials. You can use the NDB_GetCollisionData commands to check for / get information about the collisions.

NDB_NewtonMaterialSetSphereCollisionCallback

syntax: NDB_NewtonMaterialSetSphereCollisionCallback mat1, mat2
mat1 index of first material (integer)
mat2 index of second material (integer)
returns: nothing
Comments: This function utilizes a custom collision callback that is tailored for sphere collisions. Not necessary unless extreme accuracy is needed between a sphere and polygonal edges in a model (i.e. tiled floor). The use of NDB_BodySetSphere is needed on one of the bodies in question for this to take effect.
Remarks: (From the 1.53 Newton SDK doc). 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 interpenetration 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 texelated 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.