NewtonJoint

From oWiki

Jump to: navigation, search

Contents


Attributes

id

string  ( r )
The Joint's unique identifier.

type

int  ( r )
The type of joint. Possible values are:

JOINT_UP=0,
JOINT_UNIVERSAL=1,
JOINT_HINGE=2,
JOINT_SLIDER=3,
JOINT_BALLSOCKET=4,
JOINT_CORKSCREW=5,
JOINT_CUSTOM=6.

parent

molecule  ( r )
Specifies parent rigid body of this joint.

child

molecule  ( r )
Specifies child rigid body of this joint.


Methods

setUpVector( v )

v: Vector3

Set the up vector for a JOINT_UP joints.

getUpVector()

Return: Vector3

Get the up vector of a JOINT_UP joint.

setLimits( pin, maxCone, maxTwist )

pin: Vector3
maxCone: float
maxTwist: float

Set limits on the joint's rotation. pin is the joint's direction in global space. maxCone is the max angle for "swing" (in degrees). maxTwist is the max angle for "twist" (in degrees).

setCallback( s )

s: script molecule

Set the callback script molecule for these four types of joints, JOINT_UNIVERSAL, JOINT_SLIDER, JOINT_HINGE, and JOINT_CORKSCREW.

setCallbackAccel( a, p )

This function is only valid when used inside a custom callback script molecule.
a: float
p: null, 0, or 1

Sets acceleration around the joint pin. p indicate which pin this function applies to for a two-pin joint, default is 0.

setCallbackFrictionMin( a, p )

This function is only valid when used inside a custom callback script molecule.
a: float
p: null, 0, or 1

Sets minimum joint friction. p indicate which pin this function applies to for a two-pin joint, default is 0.

setCallbackFrictionMax( a, p )

This function is only valid when used inside a custom callback script molecule.
a: float, p: null, 0, or 1

Sets maximum joint friction. p indicate which pin this function applies to for a two-pin joint, default is 0.

setStiffness( a )

a: float in range [0,1]

Set joint stiffness. Joint stiffness adjusts how much "play" the joint can have. high stiffness = very small play, but more likely to become unstable.

getStiffness()

Get joint stiffness.

setCollisionState( a )

a: 0 or 1

Sets the collision state. The collision state determines whether collision should be calculated between the parent and child bodies of the joint. 1 = collision on, 0 = collision off. By default, it is off.

getCollisionState()

Returns collision state, 1 is on and 0 is off.

getJointAngle( a )

a: null, 0, or 1
Return: int in degree or Vector3 in degrees

Retrieve the angle around the pin. a indicates which pin for a two-pin joint, default is 0. Note, for JOINT_BALLSOCKET, this returns a Vector3 of angles in degrees.

getJointOmega( a )

a: null, 0, or 1
Return: float or Vector3

Retrieve the current joint omega (angular momentum). a indicates which pin for a two-pin joint, default is 0. Note, for JOINT_BALLSOCKET, this returns a Vector3.

getJointForce( a )

a: null, 0, or 1
Return: float or Vector3

Retrieve the current joint force. a indicates which pin for a two-pin joint, default is 0. Note, for JOINT_BALLSOCKET, this returns a Vector3 of angles in degrees.

This can be used to find the "stress" on the joint. you can do special effects like break the joint if the force exceeds some value, etc.

getJointPosition()

Return: float

Returns the current child rigid body's position along the pin. Only applicable to JOINT_SLIDER and JOINT_CORKSCREW.

getJointVelocity()

Return: float

Returns the current child rigid body's velocity along the pin. Only applicable to JOINT_SLIDER and JOINT_CORKSCREW.

calculateStopAlpha( g, a )

g: int
a: null, 0, or 1
Return: float

Calculate the acceleration necessary to stop the joint at the specified angle on pin. a indicates which pin for a two-pin joint, default is 0. Only applicable to JOINT_UNIVERSAL, JOINT_HINGE, and JOINT_CORKSCREW.

calculateStopAccel( g )

g: float
Return: float

Calculate the acceleration neccesary to stop the joint at the specified distance. Only applicable to JOINT_SLIDER.

Comments

NewtonJoint object can be created by calling camera molecule's createJoint function.

Personal tools