b3dCreatePointConstraint

Creates point constraint (joint) connecting two physics bodies at specified attachment points (returns constraintHandle). Takes bodyHandle1 (first body physics handle), bodyHandle2 (second body physics handle), point1X/Y/Z (attachment point on body1 in local coordinates), point2X/Y/Z (attachment point on body2 in local coordinates). Returns constraintHandle (constraint handle for subsequent operations, 0 on failure).

3D Graphics

Parameters & Returns

Parameters

bodyHandle1 Int
bodyHandle2 Int
point1X Double
point1Y Double
point1Z Double
point2X Double
point2Y Double
point2Z Double

Returns

Int

Quick Summary

Creates point constraint (joint) connecting two physics bodies at specified attachment points (returns constraintHandle). Takes bodyHandle1 (first body physics handle), bodyHandle2 (second body physics handle), point1X/Y/Z (attachment point on body1 in local coordinates), point2X/Y/Z (attachment point on body2 in local coordinates). Returns constraintHandle (constraint handle for subsequent operations, 0 on failure).

Technical Exegesis...

Creates point constraint (joint) connecting two physics bodies at specified attachment points. Takes bodyHandle1 (first body physics handle from b3dCreatePhysicsBody), bodyHandle2 (second body physics handle), point1X/Y/Z (attachment point on body1 in local coordinates relative to body center), point2X/Y/Z (attachment point on body2 in local coordinates relative to body center). Returns constraintHandle (constraint handle for use with b3dDestroyConstraint, 0 on failure).

Example

Example.bam
; Create static anchor box at top
Local anchor:Int = b3dCreateCube(1, 0, 0)
b3dPositionEntity(anchor, 0, 10, 0)
Local anchorBody:Int = b3dCreatePhysicsBody(anchor, -1, 1.0, 0, 0, 0)
b3dSetPhysicsBodyType(anchorBody, 0)  ; Make static

; Create dynamic weight box at bottom
Local weight:Int = b3dCreateCube(1, 0, 0)
b3dPositionEntity(weight, 0, 1, 0)
Local weightBody:Int = b3dCreatePhysicsBody(weight, -1, 1.0, 0, 0, 0)

; Connect bottom of anchor (0,-1,0) to top of weight (0,1,0)
Local constraint:Int = b3dCreatePointConstraint(anchorBody, weightBody, 0, -1, 0, 0, 1, 0)

; Apply impulse to make it swing
b3dApplyPhysicsImpulse(weightBody, 20, 0, 0)