# 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

## RagDoll Commands

### NDB_NewtonCreateRagDoll
syntax: int = NDB_NewtonCreateRagDoll()
| no values passed to this function |
returns: integer index to the ragdoll.
Comments: This command creates an empty ragdoll container, and returns an integer index to the ragdoll.

### NDB_NewtonDestroyRagDoll
syntax: NDB_NewtonDestroyRagDoll ragdoll
| ragdoll | ID of the ragdoll (integer)
returns: nothing
Comments: This command destroys the ragdoll from the Newton world. Note there is no "DestroyCallback" for ragdolls yet, so you must manually delete the visual objects used to represent the ragdoll onscreen yourself.

### NDB_NewtonRagDollBegin
syntax: NDB_NewtonRagDollBegin ragdoll
| ragdoll | ID of the ragdoll (integer)
returns: nothing
Comments: This command tells Newton you want to begin adding / defining the bones that will make up the ragdoll. You must call this command before you can add bones to a ragdoll.

### NDB_NewtonRagDollEnd
syntax: NDB_NewtonRagDollEnd ragdoll
| ragdoll | ID of the ragdoll (integer)
returns: nothing
Comments: This command tells Newton you are finished adding / defining the bones that make up a ragdoll. This should be called after all settings for the ragdoll are complete.

### NDB_NewtonRagDollAddBone
syntax: int = NDB_NewtonRagDolladdBone( ragdoll, p_bone, col, mass )
| ragdoll | ID of the ragdoll (integer)
| p_bone | ID of the parent bone (integer)
| col | ID of the bone collision geometry. (integer)
| mass | mass of the bone (float)
| (matrix) | temp matrix used for passing values
| (vector 1) | temp vector used for passing values
returns: integer index of the newly created bone.
Comments: This command adds a bone to the specified ragdoll. Note that the internal temp matrix is used for the position and rotation of the bone (in local space based on the parent bone), and temp vector 1 is used to describe the size of the bone. See the ragdoll tutorial for examples of this command in use. This command must be called in-between a NDB_NewtonRagDollBegin / NDB_NewtonRagDollEnd pair.

### NDB_NewtonRagDollBoneSetLimits
syntax: NDB_NewtonRagDollBoneSetLimits ragbone, min_cone, max_cone, max_twist
| ragbone | ID of the ragdoll bone (integer)
| min_cone | minimum cone rotation (float)
| max_cone | maximum cone rotation (float)
| max_twist | maximum twist rotation (float)
| (vector 1) | temp vector used for passing values
returns: nothing
Comments: This command sets the rotational limits for a particular bone. Before calling this command you must set temp vector 1 to a unit-vector describing the direction of the pin in global space. This command must be called in-between a NDB_NewtonRagDollBegin / NDB_NewtonRagDollEnd pair.

### NDB_RagDollSetGravity
syntax: NDB_RagDollSetGravity ragdoll,flag
| ragdoll | ID of the ragdoll bone (integer)
| flag |
| flag | gravity flag (1=gravity on, 0=gravity off)
returns: nothing
Comments: sets the custom gravitational force for the specified ragdoll to the contents of temp vector 1.

### NDB_RagDollGetGravity
syntax: NDB_RagDollGetGravity ragdoll
| ragdoll | ID of the ragdoll bone (integer)
| (vector 1) | temp vector used to return values.
returns: nothing
Comments: fills temp vector 1 with the custom gravity set for the specified ragdoll.

### NDB_RagDollBoneSetDBProData
syntax: NDB_RagDollBoneSetDBProData bone, db_num, limb_num
| bone | ID of the ragdoll bone (integer)
| db_num | ID of the dbpro object (integer)
| limb_num | ID of the dbpro object limb (integer)
returns: nothing
Comments: This command assigns a dbpro object (or limb thereof) to a ragdoll bone. If the limb is set to "0" (zero), the object's position will also be updated based on the position of the bone. Use this for the root bone, or ragdolls made up of seperate objects. A limb number greater than zero will rotate the limb of the object to the local rotation matrix of the bone. Don't forget to set an offset (NDB_RagDollBoneSetOffset) for the bone, or your ragdoll might not rotate correctly!

### NDB_RagDollBoneSetOffset
syntax: NDB_RagDollBoneSetOffset bone
| bone | ID of the ragdoll bone (integer)
| (matrix) | temp matrix used to pass values.
returns: nothing
Comments: sets the "zero position" for the ragdoll bone rotation. DBPro considers a model's default pose (frame 0 in the object's animation) to be the "zero" point for limb rotation. The newton wrapper needs to know the rotation that defines the "zero" point, so that it can rotate the limbs properly. Usually, you can use the same matrix used when creating the bones. However if you are trying to create a ragdoll in a different pose than the default pose, the matrix used to create the bones will be different from this matrix. Generally this matrix should stay the same for a single model, regardless of what pose you create the ragdoll in. For more information please check the ragdoll tutorial, and the ragdoll examples.
EXAMPLE: biuld a matrix, and set the bone offset NDB_BuildMatrix 78.0, -50.0, 35.0, 2.0, 0.0, 0.0 NDB_RagDollBoneSetOffset LArmbone

### NDB_RagDollBoneGetBody
syntax: int = NDB_RagDollBoneGetBody( bone )
| bone | ID of the ragdoll bone (integer)
returns: integer index to the rigid body for the bone
Comments: This command returns the index of the rigid body for the supplied bone. All ragdoll bones are actually rigid bodies, and using this command you can do things you might do to other rigid bodies, such as attach external joints to them, add impulses to them, assign materials, etc.

### NDB_RagDollExist
syntax: int = NDB_RagDollExist( ragdoll )
| ragdoll | ID of the ragdoll (integer)
returns: 1 if ragdoll exists, 0 if it doesn't

### NDB_RagDollBoneExist
syntax: int = NDB_RagDollBoneExist( bone )
| bone | ID of the ragdoll bone (integer)
returns: 1 if ragdoll bone exists, 0 if it doesn't