public btHingeConstraint( btRigidBody rbA, ref btTransform rbAFrame, bool useReferenceFrameA = false ) : base( btObjectTypes.HINGE_CONSTRAINT_TYPE, rbA ) { Init(); m_rbAFrame = ( rbAFrame ); m_rbBFrame = ( rbAFrame ); #if _BT_USE_CENTER_LIMIT_ m_limit = new btAngularLimit(); #endif //m_useSolveConstraintObsolete = ( false/*HINGE_USE_OBSOLETE_SOLVER*/ ); //m_useOffsetForConstraintFrame = ( true/*HINGE_USE_FRAME_OFFSET*/ ); m_useReferenceFrameA = ( useReferenceFrameA ); ///not providing rigidbody B means implicitly using worldspace for body B m_rbA.m_worldTransform.Apply( ref m_rbAFrame.m_origin, out m_rbBFrame.m_origin ); //m_rbBFrame.getOrigin() = m_rbA.getCenterOfMassTransform()( m_rbAFrame.getOrigin() ); m_referenceSign = m_useReferenceFrameA ? (double)( -1 ) : (double)( 1 ); }
public btHingeConstraint( btRigidBody rbA, btRigidBody rbB, ref btTransform rbAFrame, ref btTransform rbBFrame, bool useReferenceFrameA = false ) : base( btObjectTypes.HINGE_CONSTRAINT_TYPE, rbA, rbB ) { Init(); m_rbAFrame = ( rbAFrame ); m_rbBFrame = ( rbBFrame ); #if _BT_USE_CENTER_LIMIT_ m_limit = new btAngularLimit(); #endif m_useReferenceFrameA = ( useReferenceFrameA ); m_referenceSign = m_useReferenceFrameA ? (double)( -1 ) : (double)( 1 ); }
public btHingeConstraint( btRigidBody rbA, btRigidBody rbB, ref btVector3 pivotInA, ref btVector3 pivotInB, ref btVector3 axisInA, ref btVector3 axisInB, bool useReferenceFrameA = false ) : base( btObjectTypes.HINGE_CONSTRAINT_TYPE, rbA, rbB ) { Init(); #if _BT_USE_CENTER_LIMIT_ m_limit = new btAngularLimit(); #endif m_useReferenceFrameA = ( useReferenceFrameA ); m_rbAFrame.m_origin = pivotInA; // since no frame is given, assume this to be zero angle and just pick rb transform axis btVector3 rbAxisA1; rbA.m_worldTransform.m_basis.getColumn( 0, out rbAxisA1 ); btVector3 rbAxisA2; double projection = axisInA.dot( rbAxisA1 ); if( projection >= 1.0f - btScalar.SIMD_EPSILON ) { btVector3 tmp; rbA.m_worldTransform.m_basis.getColumn( 2, out tmp ); tmp.Invert( out rbAxisA1 ); rbA.m_worldTransform.m_basis.getColumn( 1, out rbAxisA2 ); } else if( projection <= -1.0f + btScalar.SIMD_EPSILON ) { rbA.m_worldTransform.m_basis.getColumn( 2, out rbAxisA1 ); rbA.m_worldTransform.m_basis.getColumn( 1, out rbAxisA2 ); } else { axisInA.cross( ref rbAxisA1, out rbAxisA2 ); rbAxisA2.cross( ref axisInA, out rbAxisA1 ); } btMatrix3x3.setValue( out m_rbAFrame.m_basis, rbAxisA1.x, rbAxisA2.x, axisInA.x, rbAxisA1.y, rbAxisA2.y, axisInA.y, rbAxisA1.z, rbAxisA2.z, axisInA.z ); btQuaternion rotationArc; btQuaternion.shortestArcQuat( ref axisInA, ref axisInB, out rotationArc ); btVector3 rbAxisB1; btQuaternion.quatRotate( ref rotationArc, ref rbAxisA1, out rbAxisB1 ); btVector3 rbAxisB2; axisInB.cross( ref rbAxisB1, out rbAxisB2 ); m_rbBFrame.m_origin = pivotInB; m_rbBFrame.m_basis.setValue( ref rbAxisB1, ref rbAxisB2, ref axisInB ); btMatrix3x3.setValue( out m_rbBFrame.m_basis, ref rbAxisB1, ref rbAxisB2, ref axisInB ); m_referenceSign = m_useReferenceFrameA ? (double)( -1 ) : (double)( 1 ); }
public btHingeConstraint( btRigidBody rbA, ref btVector3 pivotInA, ref btVector3 axisInA, bool useReferenceFrameA = false ) : base( btObjectTypes.HINGE_CONSTRAINT_TYPE, rbA ) { Init(); #if _BT_USE_CENTER_LIMIT_ m_limit = new btAngularLimit(); #endif m_useReferenceFrameA = ( useReferenceFrameA ); // since no frame is given; assume this to be zero angle and just pick rb transform axis // fixed axis in worldspace btVector3 rbAxisA1, rbAxisA2; btVector3.btPlaneSpace1( ref axisInA, out rbAxisA1, out rbAxisA2 ); m_rbAFrame.m_origin = pivotInA; m_rbAFrame.m_basis.setValue( rbAxisA1.x, rbAxisA2.x, axisInA.x, rbAxisA1.y, rbAxisA2.y, axisInA.y, rbAxisA1.z, rbAxisA2.z, axisInA.z ); btVector3 axisInB; rbA.m_worldTransform.m_basis.Apply( ref axisInA, out axisInB ); btQuaternion rotationArc; btQuaternion.shortestArcQuat( ref axisInA, ref axisInB, out rotationArc ); btVector3 rbAxisB1; btQuaternion.quatRotate( ref rotationArc, ref rbAxisA1, out rbAxisB1 ); btVector3 rbAxisB2; axisInB.cross( ref rbAxisB1, out rbAxisB2 ); //btVector3 tmp; rbA.m_worldTransform.Apply( ref pivotInA, out m_rbBFrame.m_origin ); //m_rbBFrame.m_origin = rbA.getCenterOfMassTransform()( pivotInA ); m_rbBFrame.m_basis.setValue( rbAxisB1.x, rbAxisB2.x, axisInB.x, rbAxisB1.y, rbAxisB2.y, axisInB.y, rbAxisB1.z, rbAxisB2.z, axisInB.z ); m_referenceSign = m_useReferenceFrameA ? (double)( -1 ) : (double)( 1 ); }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(btAngularLimit obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }