|
@@ -1,5 +1,11 @@
|
|
|
Namespace mojo3d
|
|
|
|
|
|
+Private
|
|
|
+
|
|
|
+'Global nullBody:btRigidBody=New btRigidBody( 0,Null,Null,Null )
|
|
|
+
|
|
|
+Public
|
|
|
+
|
|
|
Class Joint Extends Component
|
|
|
|
|
|
Const ERP:=0 'error reduction parameter - http://bulletphysics.org/mediawiki-1.5.8/index.php/Definitions
|
|
@@ -148,6 +154,8 @@ Class HingeJoint Extends Joint
|
|
|
Super.New( entity )
|
|
|
|
|
|
Axis=New Vec3f( 0,1,0 )
|
|
|
+ MinAngle=180
|
|
|
+ MaxAngle=-180
|
|
|
|
|
|
AddInstance()
|
|
|
End
|
|
@@ -159,6 +167,8 @@ Class HingeJoint Extends Joint
|
|
|
ConnectedBody=joint.ConnectedBody
|
|
|
Pivot=joint.Pivot
|
|
|
Axis=joint.Axis
|
|
|
+ MinAngle=joint.MinAngle
|
|
|
+ MaxAngle=joint.MaxAngle
|
|
|
|
|
|
AddInstance( joint )
|
|
|
End
|
|
@@ -193,20 +203,51 @@ Class HingeJoint Extends Joint
|
|
|
_axis1=axis
|
|
|
End
|
|
|
|
|
|
+ Property MinAngle:Float()
|
|
|
+
|
|
|
+ Return _minAngle
|
|
|
+
|
|
|
+ Setter( angle:Float )
|
|
|
+
|
|
|
+ _minAngle=angle
|
|
|
+
|
|
|
+ SetLimits()
|
|
|
+ End
|
|
|
+
|
|
|
+ Property MaxAngle:Float()
|
|
|
+
|
|
|
+ Return _maxAngle
|
|
|
+
|
|
|
+ Setter( angle:Float )
|
|
|
+
|
|
|
+ _maxAngle=angle
|
|
|
+
|
|
|
+ SetLimits()
|
|
|
+ End
|
|
|
+
|
|
|
Protected
|
|
|
|
|
|
Field _connected:RigidBody
|
|
|
Field _pivot1:Vec3f
|
|
|
Field _axis1:Vec3f
|
|
|
+ Field _minAngle:Float
|
|
|
+ Field _maxAngle:Float
|
|
|
+
|
|
|
+ Method SetLimits()
|
|
|
+
|
|
|
+ If Not _btconstraint Return
|
|
|
+
|
|
|
+ Cast<btHingeConstraint>(_btconstraint).setLimit( _minAngle*Pi/180,_maxAngle*Pi/180 )
|
|
|
+ End
|
|
|
|
|
|
Method OnCreate() Override
|
|
|
|
|
|
Local btBody1:=Entity.GetComponent<RigidBody>().btBody
|
|
|
- Assert( btBody1,"BallSocketJoint: No rigid body" ) 'todo: fail nicely
|
|
|
+ Assert( btBody1,"HingeJoint: No rigid body" ) 'todo: fail nicely
|
|
|
|
|
|
If _connected
|
|
|
Local btBody2:=_connected.btBody
|
|
|
- Assert( btBody2,"BallSocketJoint: No rigid body" ) 'todo: fail nicely
|
|
|
+ Assert( btBody2,"HingeJoint: No rigid body" ) 'todo: fail nicely
|
|
|
Local tform:=_connected.Entity.InverseMatrix * Entity.Matrix
|
|
|
Local pivot2:=tform * _pivot1
|
|
|
Local axis2:=tform.m * _axis1
|
|
@@ -214,6 +255,8 @@ Class HingeJoint Extends Joint
|
|
|
Else
|
|
|
_btconstraint=New btHingeConstraint( btBody1,_pivot1,_axis1 )
|
|
|
End
|
|
|
+
|
|
|
+ SetLimits()
|
|
|
End
|
|
|
|
|
|
End
|