Difference between revisions of "R3d.BallAndSocketJoint"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 8: Line 8:
  
 
In order to create a ball and socket joint, you first need to create an instance of the BallAndSocketJointInfo class with the necessary information. You need to provide the pointers to the two rigid bodies and also the coordinates of the anchor point (in world-space). At the joint creation, the world-space anchor point will be converted into the local-space of the two rigid bodies and then, the joint will make sure that the two local-space anchor points match in world-space. Therefore, the two bodies need to be in a correct position at the joint creation.
 
In order to create a ball and socket joint, you first need to create an instance of the BallAndSocketJointInfo class with the necessary information. You need to provide the pointers to the two rigid bodies and also the coordinates of the anchor point (in world-space). At the joint creation, the world-space anchor point will be converted into the local-space of the two rigid bodies and then, the joint will make sure that the two local-space anchor points match in world-space. Therefore, the two bodies need to be in a correct position at the joint creation.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
r3d.BallAndSocketJoint
 
r3d.BallAndSocketJoint
 
</source>
 
</source>
Line 17: Line 17:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
</source>
 
</source>
  
 
{{R3d.Joint}}
 
{{R3d.Joint}}

Revision as of 15:30, 13 July 2023

Available since: Gideros 2019.10
Class: R3d.Joint

Description

The BallAndSocketJoint class describes a ball and socket joint between two bodies.

In a ball and socket joint, the two bodies cannot translate with respect to each other. However, they can rotate freely around a common anchor point. This joint has three degrees of freedom and can be used to simulate a chain of bodies for instance.

In order to create a ball and socket joint, you first need to create an instance of the BallAndSocketJointInfo class with the necessary information. You need to provide the pointers to the two rigid bodies and also the coordinates of the anchor point (in world-space). At the joint creation, the world-space anchor point will be converted into the local-space of the two rigid bodies and then, the joint will make sure that the two local-space anchor points match in world-space. Therefore, the two bodies need to be in a correct position at the joint creation. <syntaxhighlight lang="lua"> r3d.BallAndSocketJoint </source>

Now, it is time to create the actual joint in the dynamics world using the Dynamics World::createJoint() method.

Note that this method will also return a pointer to the BallAndSocketJoint object that has been created internally. You will then be able to use that pointer to change properties of the joint and also to destroy it at the end.

Example

<syntaxhighlight lang="lua"> </source>