one stop for all game coders..
| Spring constraint |
|
|
| Written by CR Team | |||||||||||||||||||||
| Saturday, 18 April 2009 00:00 | |||||||||||||||||||||
|
What is a spring ? A spring constraint in Director is a constraint similar to an Angular joint , the only difference being that , in a spring constraint the constraint between 2 rigidbodies can be interchanged dynamically. As in , during program execution one can change the constraint between rbA<->rbB to say rbA<->rbC . Apart from this and the change in method to create a spring , no significant difference was found. Please refer Angular Joint for the diagram.
Syntax and usage: createSpring()
ConstraintDesc - Required. Reference to the constraint descriptor object. forceExertionMode - Takes the following symbol values. #kDuringCompression - Restoring force will be applied only when the actual length is less than the rest length between objectA and objectB. #kDuringExpansion - Restoring force will be applied only when the actual length is more than the rest length between objectA and objectB. #kBoth - Restoring force will be applied in both the above cases. restLength - Required. Float value that specifies the rest length of the spring. The distance that need to be maintained between 2 rigid bodies. Example code :
Other helper functions/methods available in spring are: getSpring() - Return the spring handler specified by the descriptor name.
getSprings() - This returns a list of all the springs in the physics world.
deleteSpring() - This deletes the specified string using the name of the spring.
|
|||||||||||||||||||||