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

Joints

NDB_SetHingeLimits

syntax: NDB_SetHingeLimits hinge, min, max
hinge index of the hinge (integer)
min min rotational limit (float)
max max rotational limit (float)
returns: nothing
Comments: Sets the rotational limits for the specified hinge joint. To remove limits, set them to zero.

NDB_SetHingeMotorAccel

syntax: NDB_SetHingeMotorAccel hinge, motor_accel
hinge index of the hinge (integer)
motor_accel motor acceleration value (float)
returns: nothing
Comments: Sets the motor acceleration value for the specified hinge joint.

NDB_GetHingeMin

syntax: float = NDB_GetHingeMin( hinge )
hinge index of the hinge (integer)
returns: float minimum angle for the hinge
Comments: returns the min value set to the hinge with the NDB_HingeSetLimits function.

NDB_GetHingeMax

syntax: float = NDB_GetHingeMax( hinge )
hinge index of the hinge (integer)
returns: float maximum angle for the hinge
Comments: returns the max value set to the hinge with the NDB_HingeSetLimits function.

NDB_GetHingeMotorAccel

syntax: float = NDB_GetHingeMotorAccel( hinge )
hinge index of the hinge (integer)
returns: float motor acceleration for the hinge
Comments: returns the motor acceleration value set to the hinge with the NDB_HingeSetMotorAccel function.

NDB_SetSliderLimits

syntax: NDB_SetSliderLimits slider, min, max
slider index of the slider (integer)
min min limit (float)
max max limit (float)
returns: nothing
Comments: Sets the limits for the specified slider joint.

NDB_SetSliderMotorAccel

syntax: NDB_SetSliderMotorAccel slider, motor_accel
slider index of the slider (integer)
motor_accel motor acceleration value (float)
returns: nothing
Comments: Sets the motor acceleration value for the specified slider joint.

NDB_GetSliderMin

syntax: float = NDB_GetSliderMin( slider )
slider index of the slider (integer)
returns: float minimum distance for the slider
Comments: returns the min value set to the slider with the NDB_SliderSetLimits function.

NDB_GetSliderMax

syntax: float = NDB_GetSliderMax( slider )
slider index of the slider (integer)
returns: float maximum distance for the slider
Comments: returns the max value set to the slider with the NDB_SliderSetLimits function.

NDB_GetSliderMotorAccel

syntax: float = NDB_GetSliderMotorAccel( slider )
slider index of the slider (integer)
returns: float motor acceleration for the slider
Comments: returns the motor acceleration value set to the slider with the NDB_SliderSetMotorAccel function.

NDB_SetCorkscrewLimits

syntax: NDB_SetCorkscrewLimits corkscrew, min_angle, max_angle, min_dist, max_dist
corkscrew index of the corkscrew (integer)
min_angle max rotational angle (float)
max_angle min rotational angle (float)
min_dist max linear distance (float)
max_dist min linear distance (float)
returns: nothing
Comments: Sets the limits for a corkscrew joint. To disable limits for one of the parts, set the limits for that part to zero.
EXAMPLE 1: set a corkscrew with rotational limits of (-45,45) and linear limits of (0, 10)
NDB_SetCorkscrewLimits MyCorkscrew, -45.0, 45.0, 0.0, 10.0

EXAMPLE 2: set a corkscrew with no rotational limits, and linear limits of (-5,5)
NDB_SetCorkscrewLimits MyCorkscrew, 0.0, 0.0, -5.0, 5.0

NDB_SetCorkscrewMotors

syntax: NDB_SetCorkscrewMotors corkscrew, angle_motor, dist_motor
corkscrew index of the corkscrew (integer)
angle_motor rotational motor acceleration (float)
dist_motor linear motor acceleration (float)
returns: nothing
Comments: Sets the rotational and linear motor accelerations for a corkscrew joint. Set any of these to zero (0.0) to disable motorization for that part.

NDB_GetCorkscrewMinAngle

syntax: float = NDB_GetCorkscrewMinAngle(corkscrew)
corkscrew index of the corkscrew (integer)
returns: float min rotational angle for the corkscrew.
Comments: returns the min rotational angle value set to the corkscrew with the NDB_SetCorkscrewLimits function.

NDB_GetCorkscrewMaxAngle

syntax: float = NDB_GetCorkscrewMaxAngle(corkscrew)
corkscrew index of the corkscrew (integer)
returns: float max rotational angle for the corkscrew.
Comments: returns the max rotational angle value set to the corkscrew with the NDB_SetCorkscrewLimits function.

NDB_GetCorkscrewMinDist

syntax: float = NDB_GetCorkscrewMinDist(corkscrew)
corkscrew index of the corkscrew (integer)
returns: float min linear dist for the corkscrew.
Comments: returns the min linear distance value set to the corkscrew with the NDB_SetCorkscrewLimits function.

NDB_GetCorkscrewMaxDist

syntax: float = NDB_GetCorkscrewMaxDist(corkscrew)
corkscrew index of the corkscrew (integer)
returns: float max linear dist for the corkscrew.
Comments: returns the max linear distance value set to the corkscrew with the NDB_SetCorkscrewLimits function.

NDB_GetCorkscrewAngleMotor

syntax: float = NDB_GetCorkscrewAngleMotor(corkscrew)
corkscrew index of the corkscrew (integer)
returns: float rotational motor accel for the corkscrew.
Comments: returns the rotational motor acceleration set to the corkscrew with the NDB_SetCorkscrewMotors function.

NDB_GetCorkscrewDistMotor

syntax: float = NDB_GetCorkscrewDistMotor(corkscrew)
corkscrew index of the corkscrew (integer)
returns: float linear motor accel for the corkscrew.
Comments: returns the linear distance acceleration set to the corkscrew with the NDB_SetCorkscrewMotors function.

NDB_SetUniversalLimits

syntax: NDB_SetUniversalLimits universal, min1, max1, min2, max2
universal index of the universal (integer)
min1 max rotational angle for pin 1 (float)
max1 min rotational angle for pin 1 (float)
min2 min rotation angle for pin 2 (float)
max2 max rotation angle for pin 2 (float)
returns: nothing
Comments: Sets the limits for a universal joint. To disable limits for one of the parts, set the limits for that part to zero.

NDB_SetUniversalMotorAccel

syntax: NDB_SetUniversalMotorAccel universal, motor1, motor2
universal index of the universal (integer)
motor1 rotational motor acceleration for pin1 (float)
motor2 rotational motor acceleration for pin2 (float)
returns: nothing
Comments: Sets the rotational motor accelerations for an universal joint. Set any of these to zero (0.0) to disable motorization for that part.

NDB_GetUniversalMin1

syntax: float = NDB_GetUniversalMin1(universal)
universal index of the universal (integer)
returns: float min rotational angle for pin1 of the universal.
Comments: returns the min rotational angle value set to the univeral with the NDB_SetUniversalLimits function.

NDB_GetUniversalMax1

syntax: float = NDB_GetUniversalMax1(universal)
universal index of the universal (integer)
returns: float max rotational angle for pin1 of the universal.
Comments: returns the max rotational angle value set to the universal with the NDB_SetUniversalLimits function.

NDB_GetUniversalMin2

syntax: float = NDB_GetUniversalMin2(universal)
universal index of the universal (integer)
returns: float min rotational angle for pin2 of the universal.
Comments: returns the min rotational angle value set to the univeral with the NDB_SetUniversalLimits function.

NDB_GetUniversalMax2

syntax: float = NDB_GetUniversalMax2(universal)
universal index of the universal (integer)
returns: float max rotational angle for pin2 of the universal.
Comments: returns the max rotational angle value set to the universal with the NDB_SetUniversalLimits function.

NDB_GetUniversalMotor1

syntax: float = NDB_GetUniversalMotor1(universal)
universal index of the universal (integer)
returns: float rotational motor accel for pin1 of the universal.
Comments: returns the rotational motor acceleration set to the universal with the NDB_SetUniversalMotorAccel function.

NDB_GetUniversalMotor2

syntax: float = NDB_GetUniversalMotor2(universal)
universal index of the universal (integer)
returns: float rotational motor accel for pin2 of the universal.
Comments: returns the rotational motor acceleration set to the universal with the NDB_SetUniversalMotorAccel function.

NDB_JointExist

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

 

Common Joint Commands

NDB_NewtonJointSetCollisionState

syntax: NDB_NewtonJointSetCollisionState joint, flag
joint ID of the joint (integer)
flag 0 = collision off, 1= collision on
returns: nothing
Comments: You can choose whether or not you want the bodies that are connected by a joint to collide with each other. Setting the flag to 1 will allow collision between the parent and child, while a flag of zero (default) disregards collision between the parent and child bodies.

NDB_NewtonJointGetCollisionState

syntax: int = NDB_NewtonJointGetCollisionState( joint )
joint ID of the joint (integer)
returns: integer collision flag of the specified joint.
Comments: Returns the collision flag for the joint. This valuse can be set with the above command, NDB_NewtonJointSetCollisionState

NDB_NewtonJointSetStiffness

syntax: NDB_NewtonJointSetStiffness joint, stiff#
joint ID of the joint (integer)
stiff# stiffness coeficient between 0.0 and 1.0
returns: nothing
Comments:Constraint keep bodies together by calculating 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.

Remarks: The stiffness is set to a all around value (default is 0.9) 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.

NDB_NewtonJointGetStiffness

syntax: float = NDB_NewtonJointGetStiffness( joint )
joint ID of the joint (integer)
returns: float value of stiffness coeficient
See NDB_NewtonJointSetStiffness for details.


Ball/Socket Joint Commands

NDB_NewtonConstraintCreateBall

syntax: int = NDB_NewtonConstraintCreateBall( db_child, db_parent )
child index of the child body.
parent index of the parent body.
(vector 1) temp vector used to pass values.
returns: integer ID of the ball joint created.
Comments: This creates a ball/socket joint in the world. Before calling this command you must fill temp vector 1 with the position of the joint in global space. Joints have heirarchy, so if the parent object moves, the child is dragged with it. To make an joint with no parent (the joint is "glued" in space, use zero "0" for parent.
See the demo programs for examples of joints in action.

NDB_NewtonBallSetConeLimits

syntax: NDB_NewtonBallSetConeLimits joint, cone_lim, twist_lim
joint ID of the joint (integer)
cone_lim max swing angle (from the joint pin axis) in degrees (float)
twist_lim max twist angle in degrees (float)/td>
(vector 1) temp vector used to pass values.
returns: nothing
Comments: Sets the limits for the ball/socket joint. Before calling this function you must set temp vector 1 with a normalized vector of the direction of the joint.
EXAMPLE: - set joint "BallJoint" pointing straight down, cone_lim = 75deg, twist_lim = 5deg
NDB_SetVector 0.0, -1.0, 0.0
NDB_NewtonBallSetConeLimits BallJoint, 75.0, 5.0

NDB_NewtonBallGetJointAngle

syntax: NDB_NewtonBallGetJointAngle joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the current angle of the joint, based on the pin angle. This can be used for special effects, like a bell sound when the angle is greater than a certain value.

NDB_NewtonBallGetJointOmega

syntax: NDB_NewtonBallGetJointOmega joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the angular (rotational) velocity of the joint.

NDB_NewtonBallGetJointForce

syntax: NDB_NewtonBallGetJointForce joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the total force asserted over the joint. This can be used to create special effects like breakable joints, etc.



Hinge Joint Commands

NDB_NewtonConstraintCreateHinge

syntax: int = NDB_NewtonConstraintCreateHinge( child, parent )
child index of the child body.
parent index of the parent body.
(vector 1) temp vector used to pass values.
(vector 2) temp vector used to pass values.
returns: integer ID of the hinge joint created.
Comments: This creates a hinge joint in the world. Before calling this command you must fill temp vector 1 with the position of the joint in global space. You must also fill temp vector 2 with the direction of the pin. Joints have heirarchy, so if the parent object moves, the child is dragged with it. To make an joint with no parent (the joint is "glued" in space, use zero "0" for parent.
See the demo programs for examples of joints in action. Demo05 is an example of hinge joints.

NDB_NewtonHingeGetJointAngle

syntax: float = NDB_NewtonHingeGetJointAngle( joint )
joint ID of the joint (integer)
returns: float angle around the hinge pin

NDB_NewtonHingeGetJointOmega

syntax: float = NDB_NewtonHingeGetJointOmega( joint )
joint ID of the joint (integer)
returns: angular velocity around the pin axis.

NDB_NewtonHingeGetJointForce

syntax: NDB_NewtonHingeGetJointForce joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the total force asserted over the joint. This can be used to create special effects like breakable joints, etc.



Slider Joint Commands

NDB_NewtonConstraintCreateSlider

syntax: int = NDB_NewtonConstraintCreateSlider( _child, parent )
child index of the child body.
parent index of the parent body.
(vector 1) temp vector used to pass values.
(vector 2) temp vector used to pass values.
returns: integer ID of the slider joint created.
Comments: This creates a slider joint in the world. Before calling this command you must fill temp vector 1 with the position of the joint in global space. You must also fill temp vector 2 with the direction of the pin. Joints have heirarchy, so if the parent object moves, the child is dragged with it. To make an joint with no parent (the joint is "glued" in space, use zero "0" for parent.
See the demo programs for examples of joints in action.

NDB_NewtonSliderGetJointPosit

syntax: float = NDB_NewtonSliderGetJointPosit( joint )
joint ID of the joint (integer)
returns: float distance along the slider pin

NDB_NewtonSliderGetJointVeloc

syntax: float = NDB_NewtonSliderGetJointVeloc( joint )
joint ID of the joint (integer)
returns: velocity along the pin axis.

NDB_NewtonSliderGetJointForce

syntax: NDB_NewtonSliderGetJointForce joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the total force asserted over the joint. This can be used to create special effects like breakable joints, etc.



Corkscrew Joint Commands

NDB_NewtonConstraintCreateCorkscrew

syntax: int = NDB_NewtonConstraintCreateCorkscrew( child, parent )
child index of the child body.
parent index of the parent body.
(vector 1) temp vector used to pass values.
(vector 2) temp vector used to pass values.
returns: integer ID of the corkscrew joint created.
Comments: This creates a corkscrew joint in the world. A Corkscrew joint is a combination of a slider and a hinge into one joint. basically the child object can slide along the pin axis (Slider), and rotate around the pin axis (Hinge). Before calling this command you must fill temp vector 1 with the position of the joint in global space. You must also fill temp vector 2 with the direction of the pin. Joints have heirarchy, so if the parent object moves, the child is dragged with it. To make an joint with no parent (the joint is "glued" in space, use zero "0" for parent.
See the demo programs for examples of joints in action.

NDB_NewtonCorkscrewGetJointPosit

syntax: float = NDB_NewtonCorkscrewGetJointPosit( joint )
joint ID of the joint (integer)
returns: float distance along the corkscrew pin

NDB_NewtonCorkscrewGetJointVeloc

syntax: float = NDB_NewtonCorkscrewGetJointVeloc( joint )
joint ID of the joint (integer)
returns: velocity along the corkscrew pin.

NDB_NewtonCorkscrewGetJointAngle

syntax: float = NDB_NewtonCorkscrewGetJointAngle( joint )
joint ID of the joint (integer)
returns: float angle around the corkscrew pin

NDB_NewtonCorkscrewGetJointOmega

syntax: float = NDB_NewtonCorkscrewGetJointOmega( joint )
joint ID of the joint (integer)
returns: angular velocity around the pin axis.

NDB_NewtonCorkscrewGetJointForce

syntax: NDB_NewtonCorkscrewGetJointForce joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the total force asserted over the joint. This can be used to create special effects like breakable joints, etc.



Universal Joint Commands

NDB_NewtonConstraintCreateUniversal

syntax: int = NDB_NewtonConstraintCreateUniversal( child, parent )
child index of the child body.
parent index of the parent body.
(vector 1) temp vector used to pass values.
(vector 2) temp vector used to pass values.
(vector 3) temp vector used to pass values.
returns: integer ID of the universal joint created.
Comments: This creates a universal joint in the world. A universal joint is 2 hinges put together into one. A simple example of a universal joint is a car tire. It can rotate around the axle, and also steer.
Before calling this command you must fill temp vector 1 with the position of the joint in global space. You must also fill temp vector 2 and temp vector 3 with the direction of the 2 pins. Joints have heirarchy, so if the parent object moves, the child is dragged with it. To make an joint with no parent (the joint is "glued" in space, use zero "0" for parent.
See the demo programs for examples of joints in action.

NDB_NewtonUnivsersalGetJointAngle0

syntax: float = NDB_NewtonUnivsersalGetJointAngle0( joint )
joint ID of the joint (integer)
returns: float angle around pin1 of the universal

NDB_NewtonUnivsersalGetJointAngle1

syntax: float = NDB_NewtonUnivsersalGetJointAngle1( joint )
joint ID of the joint (integer)
returns: float angle around pin2 of the universal

NDB_NewtonUniversalGetJointOmega0

syntax: float = NDB_NewtonUniversalGetJointOmega0( joint )
joint ID of the joint (integer)
returns: rotational velocity around pin1 of the universal

NDB_NewtonUniversalGetJointOmega1

syntax: float = NDB_NewtonUniversalGetJointOmega1( joint )
joint ID of the joint (integer)
returns: rotational velocity around pin2 of the universal

NDB_NewtonUniversalGetJointForce

syntax: NDB_NewtonUniversalGetJointForce joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: Fills temp vector 1 with the total force asserted over the joint. This can be used to create special effects like breakable joints, etc.



UpVector Joint Commands

NDB_NewtonConstraintCreateUpVector

syntax: int = NDB_NewtonConstraintCreateUpVector( body )
body index of the body.
(vector 1) temp vector used to pass values.
returns: integer ID of the upvector joint created.
Comments: This creates a upvector joint in the world. An upvector joint is a special joint that will always keep a body aligned along its pin. This joint is useful for bodies representing characters, etc. Before calling this function you must fill temp vector 1 with the pin direction for the upvector.
See the demo programs for examples of joints in action.

NDB_NewtonUpVectorGetPin

syntax: NDB_NewtonUpVectorGetPin joint
joint ID of the joint (integer)
(vector 1) temp vector used to return values.
returns: nothing
Comments: This command fills temp vector 1 with the pin direction of the specified upvector joint.

NDB_NewtonUpVectorSetPin

syntax: NDB_NewtonUpVectorSetPin joint
joint ID of the joint (integer)
(vector 1) temp vector used to pass values.
returns: nothing
Comments: This command sets the pin direction of the specified upvector joint to the contents of temp vector 1. This command can be used to animate an upvector body by slightly changing the pin direction each loop.