Inheritance: btQuadWord
Example #1
0
 public btMatrix3x3(btQuaternion q) : this(LinearMathPINVOKE.new_btMatrix3x3__SWIG_1(btQuaternion.getCPtr(q)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public btQuaternion(btQuaternion rhs) : this(LinearMathPINVOKE.new_btQuaternion__SWIG_1(btQuaternion.getCPtr(rhs)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public btTransform(btQuaternion q) : this(LinearMathPINVOKE.new_btTransform__SWIG_2(btQuaternion.getCPtr(q)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public static void calculateDiffAxisAngleQuaternion(btQuaternion orn0, btQuaternion orn1a, btVector3 axis, SWIGTYPE_p_float angle)
 {
     LinearMathPINVOKE.btTransformUtil_calculateDiffAxisAngleQuaternion(btQuaternion.getCPtr(orn0), btQuaternion.getCPtr(orn1a), btVector3.getCPtr(axis), SWIGTYPE_p_float.getCPtr(angle));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public void setRotation(btQuaternion q)
 {
     LinearMathPINVOKE.btTransform_setRotation(swigCPtr, btQuaternion.getCPtr(q));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
        public float dot(btQuaternion q)
        {
            float ret = LinearMathPINVOKE.btQuaternion_dot(swigCPtr, btQuaternion.getCPtr(q));

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public btQuaternion slerp(btQuaternion q, float t)
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_slerp(swigCPtr, btQuaternion.getCPtr(q), t), true);

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public btQuaternion nearest(btQuaternion qd)
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_nearest(swigCPtr, btQuaternion.getCPtr(qd)), true);

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static btQuaternion inverse(btQuaternion q)
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.inverse(btQuaternion.getCPtr(q)), true);

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static btVector3 quatRotate(btQuaternion rotation, btVector3 v)
        {
            btVector3 ret = new btVector3(LinearMathPINVOKE.quatRotate(btQuaternion.getCPtr(rotation), btVector3.getCPtr(v)), true);

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static btQuaternion shortestArcQuatNormalize2(btVector3 v0, btVector3 v1)
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.shortestArcQuatNormalize2(btVector3.getCPtr(v0), btVector3.getCPtr(v1)), true);

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static float btAngle(btQuaternion q1, btQuaternion q2)
        {
            float ret = LinearMathPINVOKE.btAngle__SWIG_0(btQuaternion.getCPtr(q1), btQuaternion.getCPtr(q2));

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static btQuaternion slerp(btQuaternion q1, btQuaternion q2, float t)
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.slerp(btQuaternion.getCPtr(q1), btQuaternion.getCPtr(q2), t), true);

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
        public static float length(btQuaternion q)
        {
            float ret = LinearMathPINVOKE.length(btQuaternion.getCPtr(q));

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #15
0
 public btMatrix3x3(btQuaternion q)
     : this(LinearMathPINVOKE.new_btMatrix3x3__SWIG_1(btQuaternion.getCPtr(q)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #16
0
    public bool OnBulletCreate()
    {
        if( ConstraintType == ConstraintTypes.Point2Point )
        {
            if( RigidBodyA != null && RigidBodyB == null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                point2pointConstraint = new btPoint2PointConstraint(rA,vecA.GetSwigPtr());
                constraintPtr = point2pointConstraint.GetSwigPtr();
                return true;
            }
            else if( RigidBodyA != null && RigidBodyB != null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                btVector3 vecB = new btVector3(PivotInB.x,PivotInB.y,PivotInB.z);
                btRigidBody rB = RigidBodyB.GetRigidBody();
                if( rB == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                point2pointConstraint = new btPoint2PointConstraint(rA,rB,vecA.GetSwigPtr(),vecB.GetSwigPtr());
                constraintPtr = point2pointConstraint.GetSwigPtr();
                return true;
            }

            return false;
        }
        else if( ConstraintType == ConstraintTypes.Hinge )
        {
            if( RigidBodyA != null && RigidBodyB == null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btVector3 axisA = new btVector3(AxisInA.x,AxisInA.y,AxisInA.z);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                hingeConstraint = new btHingeConstraint(rA,vecA.GetSwigPtr(),axisA.GetSwigPtr(),useReferenceFrameAHinge);
                constraintPtr = hingeConstraint.GetSwigPtr();
                return true;
            }
            else if( RigidBodyA != null && RigidBodyB != null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btVector3 axisA = new btVector3(AxisInA.x,AxisInA.y,AxisInA.z);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                btVector3 vecB = new btVector3(PivotInB.x,PivotInB.y,PivotInB.z);
                btVector3 axisB = new btVector3(AxisInB.x,AxisInB.y,AxisInB.z);
                btRigidBody rB = RigidBodyB.GetRigidBody();
                if( rB == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                hingeConstraint = new btHingeConstraint(rA,rB,vecA.GetSwigPtr(),vecB.GetSwigPtr(),axisA.GetSwigPtr(),axisB.GetSwigPtr(),useReferenceFrameAHinge);
                constraintPtr = hingeConstraint.GetSwigPtr();
                return true;
            }

            return false;
        }
        else if( ConstraintType == ConstraintTypes.Slider )
        {
            if( RigidBodyA != null && RigidBodyB == null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btQuaternion rot = new btQuaternion(RotationA.x,RotationA.y,RotationA.z);
                btTransform transA = new btTransform();
                transA.setIdentity();
                transA.setOrigin(vecA);
                transA.setRotation(rot);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                sliderConstraint = new btSliderConstraint(rA,transA.GetSwigPtr(),useLinearReferenceFrameASlider);
                constraintPtr = sliderConstraint.GetSwigPtr();
                return true;
            }
            else if( RigidBodyA != null && RigidBodyB != null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btQuaternion rotA = new btQuaternion(RotationA.x,RotationA.y,RotationA.z);
                btTransform transA = new btTransform();
                transA.setIdentity();
                transA.setOrigin(vecA);
                transA.setRotation(rotA);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                btVector3 vecB = new btVector3(PivotInB.x,PivotInB.y,PivotInB.z);
                btQuaternion rotB = new btQuaternion(RotationB.x,RotationB.y,RotationB.z);
                btTransform transB = new btTransform();
                transB.setIdentity();
                transB.setOrigin(vecB);
                transB.setRotation(rotB);
                btRigidBody rB = RigidBodyB.GetRigidBody();
                if( rB == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                sliderConstraint = new btSliderConstraint(rA,rB,transA.GetSwigPtr(),transB.GetSwigPtr(), useLinearReferenceFrameASlider);
                constraintPtr = sliderConstraint.GetSwigPtr();
                return true;
            }

            return false;
        }
        else if( ConstraintType == ConstraintTypes.ConeTwist )
        {
            if( RigidBodyA != null && RigidBodyB == null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btQuaternion rot = new btQuaternion(RotationA.x,RotationA.y,RotationA.z);
                btTransform transA = new btTransform();
                transA.setIdentity();
                transA.setOrigin(vecA);
                transA.setRotation(rot);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                coneTwistConstraint = new btConeTwistConstraint(rA,transA.GetSwigPtr());
                constraintPtr = coneTwistConstraint.GetSwigPtr();
                return true;
            }
            else if( RigidBodyA != null && RigidBodyB != null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btQuaternion rotA = new btQuaternion(RotationA.x,RotationA.y,RotationA.z);
                btTransform transA = new btTransform();
                transA.setIdentity();
                transA.setOrigin(vecA);
                transA.setRotation(rotA);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                btVector3 vecB = new btVector3(PivotInB.x,PivotInB.y,PivotInB.z);
                btQuaternion rotB = new btQuaternion(RotationB.x,RotationB.y,RotationB.z);
                btTransform transB = new btTransform();
                transB.setIdentity();
                transB.setOrigin(vecB);
                transB.setRotation(rotB);
                btRigidBody rB = RigidBodyB.GetRigidBody();
                if( rB == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                coneTwistConstraint = new btConeTwistConstraint(rA,rB,transA.GetSwigPtr(),transB.GetSwigPtr());
                constraintPtr = coneTwistConstraint.GetSwigPtr();
                return true;
            }

            return false;
        }
        else if( ConstraintType == ConstraintTypes.Gear )
        {
            if( RigidBodyA != null && RigidBodyB != null )
            {
                btVector3 axisA = new btVector3(AxisInA.x,AxisInA.y,AxisInA.z);
                btVector3 axisB = new btVector3(AxisInB.x,AxisInB.y,AxisInB.z);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                btRigidBody rB = RigidBodyB.GetRigidBody();
                if( rB == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                gearConstraint = new btGearConstraint(rA,rB,axisA.GetSwigPtr(),axisB.GetSwigPtr(),GearConstraintRatio);
                constraintPtr = gearConstraint.GetSwigPtr();
                return true;
            }
            return false;
        }
        else if( ConstraintType == ConstraintTypes.Generic6Dof )
        {
            if( RigidBodyA != null && RigidBodyB != null )
            {
                btVector3 vecA = new btVector3(PivotInA.x,PivotInA.y,PivotInA.z);
                btQuaternion rotA = new btQuaternion(RotationA.x,RotationA.y,RotationA.z);
                btTransform transA = new btTransform();
                transA.setIdentity();
                transA.setOrigin(vecA);
                transA.setRotation(rotA);
                btRigidBody rA = RigidBodyA.GetRigidBody();
                if( rA == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                btVector3 vecB = new btVector3(PivotInB.x,PivotInB.y,PivotInB.z);
                btQuaternion rotB = new btQuaternion(RotationB.x,RotationB.y,RotationB.z);
                btTransform transB = new btTransform();
                transB.setIdentity();
                transB.setOrigin(vecB);
                transB.setRotation(rotB);
                btRigidBody rB = RigidBodyB.GetRigidBody();
                if( rB == null )
                {
                    Debug.LogError("Can't Create Constraint for null RigidBody!");
                    return false;
                }
                generic6Dof = new btGeneric6DofConstraint(rA,rB,transA.GetSwigPtr(),transB.GetSwigPtr(),useLinearReferenceFrameASlider);
                if( UseLinearLimit )
                {
                    btVector3 lowerVec = new btVector3(LinearLowerLimit.x,LinearLowerLimit.y,LinearLowerLimit.z);
                    btVector3 uppderVec = new btVector3(LinearUpperLimit.x,LinearUpperLimit.y,LinearUpperLimit.z);
                    generic6Dof.setLinearLowerLimit(lowerVec.GetSwigPtr());
                    generic6Dof.setLinearUpperLimit(uppderVec.GetSwigPtr());
                }
                if( UseAngularLimit )
                {
                    btVector3 lowerVec = new btVector3(AngularLowerLimit.x,AngularLowerLimit.y,AngularLowerLimit.z);
                    btVector3 uppderVec = new btVector3(AngularUpperLimit.x,AngularUpperLimit.y,AngularUpperLimit.z);
                    generic6Dof.setAngularLowerLimit(lowerVec.GetSwigPtr());
                    generic6Dof.setAngularUpperLimit(uppderVec.GetSwigPtr());
                }

                constraintPtr = generic6Dof.GetSwigPtr();
                return true;
            }

            return false;
        }

        return false;
    }
Example #17
0
 public btQuaternion normalized()
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_normalized(swigCPtr), true);
     return ret;
 }
Example #18
0
 internal static HandleRef getCPtr(btQuaternion obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
 public void setRotation(btQuaternion q) {
   LinearMathPINVOKE.btTransform_setRotation(swigCPtr, btQuaternion.getCPtr(q));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #20
0
 public static btQuaternion shortestArcQuatNormalize2(btVector3 v0, btVector3 v1)
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.shortestArcQuatNormalize2(btVector3.getCPtr(v0), btVector3.getCPtr(v1)), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #21
0
 public static btQuaternion getIdentity()
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_getIdentity(), false);
     return ret;
 }
Example #22
0
 public static float dot(btQuaternion q1, btQuaternion q2)
 {
     float ret = LinearMathPINVOKE.dot(btQuaternion.getCPtr(q1), btQuaternion.getCPtr(q2));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 internal static HandleRef getCPtr(btQuaternion obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
 public static void calculateVelocityQuaternion(btVector3 pos0, btVector3 pos1, btQuaternion orn0, btQuaternion orn1, float timeStep, btVector3 linVel, btVector3 angVel)
 {
     LinearMathPINVOKE.btTransformUtil_calculateVelocityQuaternion(btVector3.getCPtr(pos0), btVector3.getCPtr(pos1), btQuaternion.getCPtr(orn0), btQuaternion.getCPtr(orn1), timeStep, btVector3.getCPtr(linVel), btVector3.getCPtr(angVel));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #25
0
 public btQuaternion farthest(btQuaternion qd)
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_farthest(swigCPtr, btQuaternion.getCPtr(qd)), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #26
0
 public float dot(btQuaternion q)
 {
     float ret = LinearMathPINVOKE.btQuaternion_dot(swigCPtr, btQuaternion.getCPtr(q));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public static void calculateDiffAxisAngleQuaternion(btQuaternion orn0, btQuaternion orn1a, btVector3 axis, SWIGTYPE_p_float angle)
 {
     LinearMathPINVOKE.btTransformUtil_calculateDiffAxisAngleQuaternion(btQuaternion.getCPtr(orn0), btQuaternion.getCPtr(orn1a), btVector3.getCPtr(axis), SWIGTYPE_p_float.getCPtr(angle));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #28
0
 public static float length(btQuaternion q)
 {
     float ret = LinearMathPINVOKE.length(btQuaternion.getCPtr(q));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public static void calculateVelocityQuaternion(btVector3 pos0, btVector3 pos1, btQuaternion orn0, btQuaternion orn1, float timeStep, btVector3 linVel, btVector3 angVel)
 {
     LinearMathPINVOKE.btTransformUtil_calculateVelocityQuaternion(btVector3.getCPtr(pos0), btVector3.getCPtr(pos1), btQuaternion.getCPtr(orn0), btQuaternion.getCPtr(orn1), timeStep, btVector3.getCPtr(linVel), btVector3.getCPtr(angVel));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #30
0
 public btQuaternion(btQuaternion rhs)
     : this(LinearMathPINVOKE.new_btQuaternion__SWIG_1(btQuaternion.getCPtr(rhs)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #31
0
 public static btQuaternion inverse(btQuaternion q)
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.inverse(btQuaternion.getCPtr(q)), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
        public btQuaternion inverse()
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_inverse(swigCPtr), true);

            return(ret);
        }
Example #33
0
 public static btVector3 quatRotate(btQuaternion rotation, btVector3 v)
 {
     btVector3 ret = new btVector3(LinearMathPINVOKE.quatRotate(btQuaternion.getCPtr(rotation), btVector3.getCPtr(v)), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public btQuaternion getRotation() {
   btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btTransform_getRotation(swigCPtr), true);
   return ret;
 }
Example #35
0
 public static btQuaternion slerp(btQuaternion q1, btQuaternion q2, float t)
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.slerp(btQuaternion.getCPtr(q1), btQuaternion.getCPtr(q2), t), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
        public static btQuaternion getIdentity()
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_getIdentity(), false);

            return(ret);
        }
 public btTransform(btQuaternion q) : this(LinearMathPINVOKE.new_btTransform__SWIG_2(btQuaternion.getCPtr(q)), true) {
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #38
0
 public btQuaternion slerp(btQuaternion q, float t)
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_slerp(swigCPtr, btQuaternion.getCPtr(q), t), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
        public btQuaternion getRotation()
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btTransform_getRotation(swigCPtr), true);

            return(ret);
        }
    public bool OnBulletCreate()
    {
        if( collisionShapePtr != null ) // can't be created multi-times
            return true;

        if( ShapeType == CollisionShapeType.BoxShape)
        {
            btVector3 vec = new btVector3(BoxShapeVec.x*transform.localScale.x,BoxShapeVec.y*transform.localScale.y,BoxShapeVec.z*transform.localScale.z);
            boxShape = new btBoxShape(vec.GetSwigPtr());
            collisionShapePtr = boxShape.GetSwigPtr();
        }
        else if( ShapeType == CollisionShapeType.SphereShape)
        {
            float maxFactor = Mathf.Max(transform.localScale.x,transform.localScale.y);
            maxFactor = Mathf.Max(transform.localScale.z,maxFactor);
            sphereShape = new btSphereShape(SphereShapeRadius*maxFactor);
            collisionShapePtr = sphereShape.GetSwigPtr();
        }
        else if( ShapeType == CollisionShapeType.CapsuleShape)
        {
            float maxFactor = Mathf.Max(transform.localScale.x,transform.localScale.z);

            capsuleShape = new btCapsuleShape(CapsuleRadius*maxFactor,CapsuleHeight*transform.localScale.y);
            collisionShapePtr = capsuleShape.GetSwigPtr();
        }
        else if( ShapeType == CollisionShapeType.CylinderShape)
        {
            float maxFactor = Mathf.Max(transform.localScale.x,transform.localScale.z);
            btVector3 vec = new btVector3(CylinderRadius*maxFactor,CylinderHeight*transform.localScale.y,CylinderRadius*maxFactor);
            cylinderShape = new btCylinderShape(vec.GetSwigPtr());
            collisionShapePtr = cylinderShape.GetSwigPtr();
        }
        else if( ShapeType == CollisionShapeType.ConeShape)
        {
            float maxFactor = Mathf.Max(transform.localScale.x,transform.localScale.z);
            coneShape = new btConeShape(ConeRadius*maxFactor,ConeHeight*transform.localScale.y);
            collisionShapePtr = coneShape.GetSwigPtr();
        }
        else if( ShapeType == CollisionShapeType.ConvexHull )
        {
            if(CheckUnityMesh() == false)
                return false;

            List<float> vertexposList = new List<float>();

            for(int index=0;index<meshFilter.mesh.vertexCount;index++)
            {
                Vector3 vec = meshFilter.mesh.vertices[index];
                vertexposList.Add(vec.x);
                vertexposList.Add(vec.y);
                vertexposList.Add(vec.z);
            }

            convexHull = new btConvexHullShape(vertexposList.ToArray(),meshFilter.mesh.vertexCount,3*sizeof(float));
            convexPolyhedral = convexHull.GetPolihedralConvexShape();
            //convexPolyhedral.initializePolyhedralFeatures();
            collisionShapePtr = convexHull.GetSwigPtr();

        }
        else if( ShapeType == CollisionShapeType.CompoundShape )
        {
            // use all its children's collision shapes to create itself...
            if( CollisionShapeArray == null || CollisionShapeArray.Length == 0 )
            {
                Debug.Log("There is no child collision shapes to use CompoundShape!");
                return false;
            }

            compoundShape = new btCompoundShape();

            for( int i=0;i<CollisionShapeArray.Length;i++)
            {
                if( CollisionShapeArray[i] == null )
                    continue;

                if( CollisionShapeArray[i].gameObject == gameObject )
                    continue;

                bool result = CollisionShapeArray[i].OnBulletCreate();
                if( result == false )
                {
                    Debug.Log(" Bullet Collision Create Error!");
                    return false;
                }

                Transform t = CollisionShapeArray[i].transform;
                Matrix4x4 objMatrix = Matrix4x4.TRS(t.localPosition,t.localRotation,t.localScale);

                btVector3 pos = new btVector3(t.localPosition.x,t.localPosition.y,t.localPosition.z);
                btQuaternion rot = new btQuaternion(t.localRotation.x,t.localRotation.y,t.localRotation.z,t.localRotation.w);

                btTransform trans = new btTransform(rot,pos);

                compoundShape.addChildShape(trans.GetSwigPtr(),CollisionShapeArray[i].GetCollisionShapePtr());
            }

            collisionShapePtr = compoundShape.GetSwigPtr();

        }
        else if( ShapeType == CollisionShapeType.BvhTriangleMeshShape )
        {
            if(CheckUnityMesh() == false)
                return false;
            List<float> verList = new List<float>();
            for(int index=0;index<meshFilter.mesh.vertexCount;index++)
            {
                Vector3 vec = meshFilter.mesh.vertices[index];
                //vec = transform.TransformPoint(vec);
                verList.Add(vec.x);
                verList.Add(vec.y);
                verList.Add(vec.z);
            }

            meshVertexArray = verList.ToArray();

            List<int> indexList = new List<int>();
            // Unity3D counter clock-wise to Bullet's clock wise.
            for( int i=0;i< meshFilter.mesh.triangles.Length;i+=3)
            {
                indexList.Add(meshFilter.mesh.triangles[i]);
                indexList.Add(meshFilter.mesh.triangles[i+2]);
                indexList.Add(meshFilter.mesh.triangles[i+1]);
            }

            meshIndexArray = indexList.ToArray();

            triangleArray = new btTriangleIndexVertexArray(indexList.Count/3,meshIndexArray,3*sizeof(int),
                                                                                      meshFilter.mesh.vertexCount,meshVertexArray,3*sizeof(float));
            bvhTriangleMeshShape = new btBvhTriangleMeshShape(triangleArray.GetSwigPtr(),true);
            collisionShapePtr = bvhTriangleMeshShape.GetSwigPtr();
        }
        else if( ShapeType == CollisionShapeType.StaticPlaneShape)
        {
            btVector3 vec = new btVector3(StaticPlaneNormal.x,StaticPlaneNormal.y,StaticPlaneNormal.z);
            staticPlaneShape = new btStaticPlaneShape(vec.GetSwigPtr(),StaticPlaneConstant);
            collisionShapePtr = staticPlaneShape.GetSwigPtr();
        }

        return true;
    }
        public btQuaternion normalized()
        {
            btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_normalized(swigCPtr), true);

            return(ret);
        }
Example #42
0
 public btQuaternion inverse()
 {
     btQuaternion ret = new btQuaternion(LinearMathPINVOKE.btQuaternion_inverse(swigCPtr), true);
     return ret;
 }