Inheritance: IDisposable
 public void CalculateLocalInertia(float mass,btVector3 intertiaVec)
 {
     if( ShapeType == CollisionShapeType.BoxShape && boxShape != null)
     {
          boxShape.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
     else if( ShapeType == CollisionShapeType.SphereShape && sphereShape != null)
     {
         sphereShape.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
     else if( ShapeType == CollisionShapeType.CapsuleShape && capsuleShape != null)
     {
         capsuleShape.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
     else if( ShapeType == CollisionShapeType.CylinderShape && cylinderShape != null)
     {
         cylinderShape.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
     else if( ShapeType == CollisionShapeType.ConeShape && coneShape != null)
     {
         coneShape.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
     else if( ShapeType == CollisionShapeType.ConvexHull && convexPolyhedral != null )
     {
         convexPolyhedral.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
     else if( ShapeType == CollisionShapeType.CompoundShape && compoundShape != null )
     {
         compoundShape.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
     else if( ShapeType == CollisionShapeType.StaticPlaneShape && staticPlaneShape != null)
     {
         staticPlaneShape.calculateLocalInertia(mass,intertiaVec.GetSwigPtr());
     }
 }
Example #2
0
    public bool OnBulletCreate()
    {
        if( rigidBodyObj != null ) // have created!
        {
            return true;
        }

        if( CollisionShapeObject == null )   // if user not give a collision, search it on itself first!
            CollisionShapeObject = GetComponent<BCollisionShape>();

        if( CollisionShapeObject == null )
        {
            Debug.LogError("Bullet RigidBody need a collision shape!");
            return false;
        }

        bool cResult = CollisionShapeObject.OnBulletCreate();

        if( cResult == false )
        {
            Debug.LogError("Collision Shape Create Error!");
            return false;
        }

        btTransform trans = new btTransform();
        trans.setIdentity();
        btVector3 pos = new btVector3(transform.position.x,transform.position.y,transform.position.z);
        trans.setOrigin(pos);
        trans.setRotation(new btQuaternion(transform.rotation.x,transform.rotation.y,transform.rotation.z,transform.rotation.w));

        //rigidbody is dynamic if and only if mass is non zero, otherwise static
        bool isDynamic = (Mass != 0.0f);

        btVector3 localInertia = new btVector3(0,0,0);
        if (isDynamic)
        {
             CollisionShapeObject.CalculateLocalInertia(Mass,localInertia);
        }

        //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
        myMotionState = new btDefaultMotionState(trans);
        rbInfo = new btRigidBodyConstructionInfo(Mass,myMotionState.GetSwigPtr(),CollisionShapeObject.GetCollisionShapePtr(),localInertia.GetSwigPtr());
        rigidBodyObj = new btRigidBody(rbInfo);
        collisionObject = btCollisionObject.GetObjectFromSwigPtr(rigidBodyObj.GetCollisionObject());
        collisionObject.setFriction(Friction);
        return true;
    }
Example #3
0
 public static bool TestTriangleAgainstAabb2(btVector3 vertices, btVector3 aabbMin, btVector3 aabbMax)
 {
     bool ret = LinearMathPINVOKE.TestTriangleAgainstAabb2(btVector3.getCPtr(vertices), btVector3.getCPtr(aabbMin), btVector3.getCPtr(aabbMax));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #4
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 #5
0
 public static btVector3 lerp(btVector3 v1, btVector3 v2, float t)
 {
     btVector3 ret = new btVector3(LinearMathPINVOKE.lerp(btVector3.getCPtr(v1), btVector3.getCPtr(v2), t), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #6
0
 public static void btUnSwapVector3Endian(btVector3 vector)
 {
     LinearMathPINVOKE.btUnSwapVector3Endian(btVector3.getCPtr(vector));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #7
0
 public static void btTransformAabb(btVector3 localAabbMin, btVector3 localAabbMax, float margin, btTransform trans, btVector3 aabbMinOut, btVector3 aabbMaxOut)
 {
     LinearMathPINVOKE.btTransformAabb__SWIG_1(btVector3.getCPtr(localAabbMin), btVector3.getCPtr(localAabbMax), margin, btTransform.getCPtr(trans), btVector3.getCPtr(aabbMinOut), btVector3.getCPtr(aabbMaxOut));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #8
0
 public static void btSwapVector3Endian(btVector3 sourceVec, btVector3 destVec)
 {
     LinearMathPINVOKE.btSwapVector3Endian(btVector3.getCPtr(sourceVec), btVector3.getCPtr(destVec));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 public void setOrigin(btVector3 origin) {
   LinearMathPINVOKE.btTransform_setOrigin(swigCPtr, btVector3.getCPtr(origin));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #10
0
        public btVector3 getRow(int i)
        {
            btVector3 ret = new btVector3(LinearMathPINVOKE.btMatrix3x3_getRow(swigCPtr, i), false);

            return(ret);
        }
Example #11
0
        public btVector3 getColumn(int i)
        {
            btVector3 ret = new btVector3(LinearMathPINVOKE.btMatrix3x3_getColumn(swigCPtr, i), true);

            return(ret);
        }
        public btVector3 getAxis()
        {
            btVector3 ret = new btVector3(LinearMathPINVOKE.btQuaternion_getAxis(swigCPtr), true);

            return(ret);
        }
 public void getSkewSymmetricMatrix(btVector3 v0, btVector3 v1, btVector3 v2)
 {
     LinearMathPINVOKE.btVector3_getSkewSymmetricMatrix(swigCPtr, btVector3.getCPtr(v0), btVector3.getCPtr(v1), btVector3.getCPtr(v2));
 }
 internal static HandleRef getCPtr(btVector3 obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
        public btVector3 absolute()
        {
            btVector3 ret = new btVector3(LinearMathPINVOKE.btVector3_absolute(swigCPtr), true);

            return(ret);
        }
Example #16
0
 public static btVector3 btAabbSupport(btVector3 halfExtents, btVector3 supportDir)
 {
     btVector3 ret = new btVector3(LinearMathPINVOKE.btAabbSupport(btVector3.getCPtr(halfExtents), btVector3.getCPtr(supportDir)), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public btTransform(btMatrix3x3 b, btVector3 c) : this(LinearMathPINVOKE.new_btTransform__SWIG_3(btMatrix3x3.getCPtr(b), btVector3.getCPtr(c)), 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 btVector3 normalized()
        {
            btVector3 ret = new btVector3(LinearMathPINVOKE.btVector3_normalized(swigCPtr), true);

            return(ret);
        }
 public static void calculateVelocity(btTransform transform0, btTransform transform1, float timeStep, btVector3 linVel, btVector3 angVel)
 {
     LinearMathPINVOKE.btTransformUtil_calculateVelocity(btTransform.getCPtr(transform0), btTransform.getCPtr(transform1), timeStep, btVector3.getCPtr(linVel), btVector3.getCPtr(angVel));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #21
0
 public static void btTransformAabb(btVector3 halfExtents, float margin, btTransform t, btVector3 aabbMinOut, btVector3 aabbMaxOut)
 {
     LinearMathPINVOKE.btTransformAabb__SWIG_0(btVector3.getCPtr(halfExtents), margin, btTransform.getCPtr(t), btVector3.getCPtr(aabbMinOut), btVector3.getCPtr(aabbMaxOut));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 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 #23
0
 public static float btTriple(btVector3 v1, btVector3 v2, btVector3 v3)
 {
     float ret = LinearMathPINVOKE.btTriple(btVector3.getCPtr(v1), btVector3.getCPtr(v2), btVector3.getCPtr(v3));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public static void integrateTransform(btTransform curTrans, btVector3 linvel, btVector3 angvel, float timeStep, btTransform predictedTransform)
 {
     LinearMathPINVOKE.btTransformUtil_integrateTransform(btTransform.getCPtr(curTrans), btVector3.getCPtr(linvel), btVector3.getCPtr(angvel), timeStep, btTransform.getCPtr(predictedTransform));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #25
0
 public static void GrahamScanConvexHull2D(SWIGTYPE_p_btAlignedObjectArrayT_GrahamVector3_t originalPoints, SWIGTYPE_p_btAlignedObjectArrayT_GrahamVector3_t hull, btVector3 normalAxis)
 {
     LinearMathPINVOKE.GrahamScanConvexHull2D(SWIGTYPE_p_btAlignedObjectArrayT_GrahamVector3_t.getCPtr(originalPoints), SWIGTYPE_p_btAlignedObjectArrayT_GrahamVector3_t.getCPtr(hull), btVector3.getCPtr(normalAxis));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 public static bool isInside(SWIGTYPE_p_btAlignedObjectArrayT_btVector3_t vertices, btVector3 planeNormal, float margin)
 {
     bool ret = LinearMathPINVOKE.btGeometryUtil_isInside(SWIGTYPE_p_btAlignedObjectArrayT_btVector3_t.getCPtr(vertices), btVector3.getCPtr(planeNormal), margin);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #27
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 static bool isPointInsidePlanes(SWIGTYPE_p_btAlignedObjectArrayT_btVector3_t planeEquations, btVector3 point, float margin)
 {
     bool ret = LinearMathPINVOKE.btGeometryUtil_isPointInsidePlanes(SWIGTYPE_p_btAlignedObjectArrayT_btVector3_t.getCPtr(planeEquations), btVector3.getCPtr(point), margin);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #29
0
 public static bool TestPointAgainstAabb2(btVector3 aabbMin1, btVector3 aabbMax1, btVector3 point)
 {
     bool ret = LinearMathPINVOKE.TestPointAgainstAabb2(btVector3.getCPtr(aabbMin1), btVector3.getCPtr(aabbMax1), btVector3.getCPtr(point));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #30
0
 public static btVector3 btCross(btVector3 v1, btVector3 v2)
 {
     btVector3 ret = new btVector3(LinearMathPINVOKE.btCross(btVector3.getCPtr(v1), btVector3.getCPtr(v2)), true);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Example #31
0
 public static void AabbExpand(btVector3 aabbMin, btVector3 aabbMax, btVector3 expansionMin, btVector3 expansionMax)
 {
     LinearMathPINVOKE.AabbExpand(btVector3.getCPtr(aabbMin), btVector3.getCPtr(aabbMax), btVector3.getCPtr(expansionMin), btVector3.getCPtr(expansionMax));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #32
0
 public static int btOutcode(btVector3 p, btVector3 halfExtent)
 {
     int ret = LinearMathPINVOKE.btOutcode(btVector3.getCPtr(p), btVector3.getCPtr(halfExtent));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public btTransform(btQuaternion q, btVector3 c) : this(LinearMathPINVOKE.new_btTransform__SWIG_1(btQuaternion.getCPtr(q), btVector3.getCPtr(c)), true) {
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #34
0
 public static bool btRayAabb(btVector3 rayFrom, btVector3 rayTo, btVector3 aabbMin, btVector3 aabbMax, SWIGTYPE_p_float param, btVector3 normal)
 {
     bool ret = LinearMathPINVOKE.btRayAabb(btVector3.getCPtr(rayFrom), btVector3.getCPtr(rayTo), btVector3.getCPtr(aabbMin), btVector3.getCPtr(aabbMax), SWIGTYPE_p_float.getCPtr(param), btVector3.getCPtr(normal));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public btVector3 getOrigin() {
   btVector3 ret = new btVector3(LinearMathPINVOKE.btTransform_getOrigin__SWIG_0(swigCPtr), false);
   return ret;
 }
Example #36
0
 public static bool btRayAabb2(btVector3 rayFrom, btVector3 rayInvDirection, SWIGTYPE_p_unsigned_int raySign, btVector3 bounds, SWIGTYPE_p_float tmin, float lambda_min, float lambda_max)
 {
     bool ret = LinearMathPINVOKE.btRayAabb2(btVector3.getCPtr(rayFrom), btVector3.getCPtr(rayInvDirection), SWIGTYPE_p_unsigned_int.getCPtr(raySign), btVector3.getCPtr(bounds), SWIGTYPE_p_float.getCPtr(tmin), lambda_min, lambda_max);
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
 public btVector3 invXform(btVector3 inVec) {
   btVector3 ret = new btVector3(LinearMathPINVOKE.btTransform_invXform(swigCPtr, btVector3.getCPtr(inVec)), true);
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
        public btVector3 safeNormalize()
        {
            btVector3 ret = new btVector3(LinearMathPINVOKE.btVector3_safeNormalize(swigCPtr), false);

            return(ret);
        }