ConeJoint
Joins two physics bodies like a shoulder: they swing within a cone.
ConeJoint ( entity1,entity2,x#,y#,z#,axis_x#,axis_y#,axis_z#[,swing#][,twist#] )
Parameters
- entity1
- the entity to join (it must have a body: see EntityPhysics)
- entity2
- the entity to join it to, or 0 to join it to the world
- x#, y#, z#
- the point they are joined at, in world space
- axis_x#, axis_y#, axis_z#
- the direction the first entity points from the joint, in world space
- swing# (optional)
- how far it can swing away from that direction, in degrees. Defaults to 45.
- twist# (optional)
- how far it can twist about that direction, in degrees. Defaults to 20.
Description
Joins two physics bodies like a shoulder or hip: the first can swing within a cone and twist a little, but no further. Returns the joint's handle.
Cone joints make ragdolls, tails, hanging signs and anything that should swing without flopping all the way round. JointLimits changes the swing and twist later.
Example
; Physics joints example (an ArcBasic extension); A door on a hinge, a chain of pins, a weight on a spring and a glued pair.; Space gives everything a shove. C lets the door hit its frame, D shows shapesGraphics3D 640,480SetBuffer BackBuffer()camera=CreateCamera()PositionEntity camera,0,5,-15TurnEntity camera,12,0,0light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,70,90,70EntityPhysics ground,1; a door: a hinge on its left edge, joined to the world (entity2 = 0)frame=CreateCube()ScaleEntity frame,.1,1.5,.1PositionEntity frame,-7,1.5,0EntityPhysics frame,1door=CreateCube()ScaleEntity door,1,1.4,.08PositionEntity door,-5.9,1.5,0EntityColor door,160,110,60EntityPhysics door,2,3hinge=HingeJoint(door,0,-6.9,1.5,0,0,1,0); a chain: each link pinned to the one above, the first to the worldDim link(6)For i=0 To 6 link(i)=CreateSphere(8) ScaleEntity link(i),.2,.2,.2 PositionEntity link(i),-1+i*.42,7,0 EntityPhysics link(i),2,.3 If i=0 PinJoint link(0),0,-1.2,7,0 Else PinJoint link(i),link(i-1),-1+i*.42-.21,7,0 EndIfNext; a weight on a spring that can only move up and downweight=CreateCube()ScaleEntity weight,.5,.5,.5PositionEntity weight,4,4,0EntityColor weight,90,160,255EntityPhysics weight,2,2spring=SpringJoint(weight,0,0,1,0,60,1); two crates glued into onea=CreateCube() : ScaleEntity a,.5,.5,.5 : PositionEntity a,7,3,0 : EntityPhysics a,2b=CreateCube() : ScaleEntity b,.5,.5,.5 : PositionEntity b,7.5,3.9,0 : EntityPhysics b,2EntityColor b,255,200,80FixedJoint b,acollide=Falsedebug=FalseWhile Not KeyHit(1) If KeyHit(57) ApplyImpulse door,0,0,4,1,0,0 ApplyImpulse link(6),3,0,0 ApplyImpulse weight,0,-6,0 ApplyImpulse a,0,6,0,.5,0,0 EndIf If KeyHit(46) Then collide=Not collide : JointCollide hinge,collide If KeyHit(32) Then debug=Not debug : PhysicsDebug debug UpdateWorld RenderWorld Text 0,0,"Space: shove C: door collides with its frame D: shapes" Text 0,15,"Door angle: "+Int(JointPosition(hinge))+" spring stretch: "+JointPosition(spring) FlipWendEnd
