Inheritance: IDisposable
 public btDefaultMotionState(btTransform startTrans, btTransform centerOfMassOffset) : this(LinearMathPINVOKE.new_btDefaultMotionState__SWIG_0(btTransform.getCPtr(startTrans), btTransform.getCPtr(centerOfMassOffset)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public btDefaultMotionState(btTransform startTrans) : this(LinearMathPINVOKE.new_btDefaultMotionState__SWIG_1(btTransform.getCPtr(startTrans)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public btTransform(btTransform other) : this(LinearMathPINVOKE.new_btTransform__SWIG_5(btTransform.getCPtr(other)), true)
 {
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public void mult(btTransform t1, btTransform t2)
 {
     LinearMathPINVOKE.btTransform_mult(swigCPtr, btTransform.getCPtr(t1), btTransform.getCPtr(t2));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #5
0
 public void updateSeparatingDistance(btTransform transA, btTransform transB)
 {
     LinearMathPINVOKE.btConvexSeparatingDistanceUtil_updateSeparatingDistance(swigCPtr, btTransform.getCPtr(transA), btTransform.getCPtr(transB));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 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();
     }
 }
 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 virtual void setWorldTransform(btTransform centerOfMassWorldTrans)
 {
     LinearMathPINVOKE.btDefaultMotionState_setWorldTransform(swigCPtr, btTransform.getCPtr(centerOfMassWorldTrans));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public static void calculateDiffAxisAngle(btTransform transform0, btTransform transform1, btVector3 axis, SWIGTYPE_p_float angle)
 {
     LinearMathPINVOKE.btTransformUtil_calculateDiffAxisAngle(btTransform.getCPtr(transform0), btTransform.getCPtr(transform1), btVector3.getCPtr(axis), SWIGTYPE_p_float.getCPtr(angle));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 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 #11
0
 public virtual void getWorldTransform(btTransform worldTrans)
 {
     LinearMathPINVOKE.btMotionState_getWorldTransform(swigCPtr, btTransform.getCPtr(worldTrans));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
        public btTransform inverseTimes(btTransform t)
        {
            btTransform ret = new btTransform(LinearMathPINVOKE.btTransform_inverseTimes(swigCPtr, btTransform.getCPtr(t)), true);

            if (LinearMathPINVOKE.SWIGPendingException.Pending)
            {
                throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
 public virtual void drawTransform(btTransform transform, float orthoLen)
 {
     if (SwigDerivedClassHasMethod("drawTransform", swigMethodTypes12))
     {
         LinearMathPINVOKE.btIDebugDraw_drawTransformSwigExplicitbtIDebugDraw(swigCPtr, btTransform.getCPtr(transform), orthoLen);
     }
     else
     {
         LinearMathPINVOKE.btIDebugDraw_drawTransform(swigCPtr, btTransform.getCPtr(transform), orthoLen);
     }
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public virtual void drawBox(btVector3 bbMin, btVector3 bbMax, btTransform trans, btVector3 color)
 {
     if (SwigDerivedClassHasMethod("drawBox", swigMethodTypes18))
     {
         LinearMathPINVOKE.btIDebugDraw_drawBoxSwigExplicitbtIDebugDraw__SWIG_1(swigCPtr, btVector3.getCPtr(bbMin), btVector3.getCPtr(bbMax), btTransform.getCPtr(trans), btVector3.getCPtr(color));
     }
     else
     {
         LinearMathPINVOKE.btIDebugDraw_drawBox__SWIG_1(swigCPtr, btVector3.getCPtr(bbMin), btVector3.getCPtr(bbMax), btTransform.getCPtr(trans), btVector3.getCPtr(color));
     }
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public virtual void drawPlane(btVector3 planeNormal, float planeConst, btTransform transform, btVector3 color)
 {
     if (SwigDerivedClassHasMethod("drawPlane", swigMethodTypes22))
     {
         LinearMathPINVOKE.btIDebugDraw_drawPlaneSwigExplicitbtIDebugDraw(swigCPtr, btVector3.getCPtr(planeNormal), planeConst, btTransform.getCPtr(transform), btVector3.getCPtr(color));
     }
     else
     {
         LinearMathPINVOKE.btIDebugDraw_drawPlane(swigCPtr, btVector3.getCPtr(planeNormal), planeConst, btTransform.getCPtr(transform), btVector3.getCPtr(color));
     }
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public virtual void drawSphere(float radius, btTransform transform, btVector3 color)
 {
     if (SwigDerivedClassHasMethod("drawSphere", swigMethodTypes2))
     {
         LinearMathPINVOKE.btIDebugDraw_drawSphereSwigExplicitbtIDebugDraw__SWIG_0(swigCPtr, radius, btTransform.getCPtr(transform), btVector3.getCPtr(color));
     }
     else
     {
         LinearMathPINVOKE.btIDebugDraw_drawSphere__SWIG_0(swigCPtr, radius, btTransform.getCPtr(transform), btVector3.getCPtr(color));
     }
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
 public virtual void drawCylinder(float radius, float halfHeight, int upAxis, btTransform transform, btVector3 color)
 {
     if (SwigDerivedClassHasMethod("drawCylinder", swigMethodTypes20))
     {
         LinearMathPINVOKE.btIDebugDraw_drawCylinderSwigExplicitbtIDebugDraw(swigCPtr, radius, halfHeight, upAxis, btTransform.getCPtr(transform), btVector3.getCPtr(color));
     }
     else
     {
         LinearMathPINVOKE.btIDebugDraw_drawCylinder(swigCPtr, radius, halfHeight, upAxis, btTransform.getCPtr(transform), btVector3.getCPtr(color));
     }
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #18
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 #19
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();
 }
 public btDefaultMotionState(btTransform startTrans, btTransform centerOfMassOffset) : this(LinearMathPINVOKE.new_btDefaultMotionState__SWIG_0(btTransform.getCPtr(startTrans), btTransform.getCPtr(centerOfMassOffset)), true) {
   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 virtual void drawTransform(btTransform transform, float orthoLen) {
   if (SwigDerivedClassHasMethod("drawTransform", swigMethodTypes12)) LinearMathPINVOKE.btIDebugDraw_drawTransformSwigExplicitbtIDebugDraw(swigCPtr, btTransform.getCPtr(transform), orthoLen); else LinearMathPINVOKE.btIDebugDraw_drawTransform(swigCPtr, btTransform.getCPtr(transform), orthoLen);
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
Example #23
0
 void Update()
 {
     if( rigidBodyObj != null && myMotionState != null )
     {
         btTransform ts = new btTransform();
         myMotionState.getWorldTransform(ts);
         btVector3 vecOut = ts.getOrigin();
         btQuaternion rot = ts.getRotation();
         gameObject.transform.position = new Vector3(vecOut.getX(),vecOut.getY(),vecOut.getZ());
         gameObject.transform.rotation = new Quaternion(rot.x(),rot.y(),rot.z(),rot.w());
     }
 }
 public btTransform(btTransform other) : this(LinearMathPINVOKE.new_btTransform__SWIG_5(btTransform.getCPtr(other)), true) {
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 public virtual void drawCylinder(float radius, float halfHeight, int upAxis, btTransform transform, btVector3 color) {
   if (SwigDerivedClassHasMethod("drawCylinder", swigMethodTypes20)) LinearMathPINVOKE.btIDebugDraw_drawCylinderSwigExplicitbtIDebugDraw(swigCPtr, radius, halfHeight, upAxis, btTransform.getCPtr(transform), btVector3.getCPtr(color)); else LinearMathPINVOKE.btIDebugDraw_drawCylinder(swigCPtr, radius, halfHeight, upAxis, btTransform.getCPtr(transform), btVector3.getCPtr(color));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 public btTransform inverse() {
   btTransform ret = new btTransform(LinearMathPINVOKE.btTransform_inverse(swigCPtr), true);
   return ret;
 }
 public static btTransform getIdentity() {
   btTransform ret = new btTransform(LinearMathPINVOKE.btTransform_getIdentity(), false);
   return ret;
 }
Example #28
0
 public void initSeparatingDistance(btVector3 separatingVector, float separatingDistance, btTransform transA, btTransform transB)
 {
     LinearMathPINVOKE.btConvexSeparatingDistanceUtil_initSeparatingDistance(swigCPtr, btVector3.getCPtr(separatingVector), separatingDistance, btTransform.getCPtr(transA), btTransform.getCPtr(transB));
     if (LinearMathPINVOKE.SWIGPendingException.Pending)
     {
         throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #29
0
 public virtual void setWorldTransform(btTransform worldTrans)
 {
     LinearMathPINVOKE.btMotionState_setWorldTransform(swigCPtr, btTransform.getCPtr(worldTrans));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 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();
 }
 public static void calculateDiffAxisAngle(btTransform transform0, btTransform transform1, btVector3 axis, SWIGTYPE_p_float angle)
 {
     LinearMathPINVOKE.btTransformUtil_calculateDiffAxisAngle(btTransform.getCPtr(transform0), btTransform.getCPtr(transform1), btVector3.getCPtr(axis), SWIGTYPE_p_float.getCPtr(angle));
     if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
    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 virtual void drawSphere(float radius, btTransform transform, btVector3 color) {
   if (SwigDerivedClassHasMethod("drawSphere", swigMethodTypes2)) LinearMathPINVOKE.btIDebugDraw_drawSphereSwigExplicitbtIDebugDraw__SWIG_0(swigCPtr, radius, btTransform.getCPtr(transform), btVector3.getCPtr(color)); else LinearMathPINVOKE.btIDebugDraw_drawSphere__SWIG_0(swigCPtr, radius, btTransform.getCPtr(transform), btVector3.getCPtr(color));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 public virtual void drawPlane(btVector3 planeNormal, float planeConst, btTransform transform, btVector3 color) {
   if (SwigDerivedClassHasMethod("drawPlane", swigMethodTypes22)) LinearMathPINVOKE.btIDebugDraw_drawPlaneSwigExplicitbtIDebugDraw(swigCPtr, btVector3.getCPtr(planeNormal), planeConst, btTransform.getCPtr(transform), btVector3.getCPtr(color)); else LinearMathPINVOKE.btIDebugDraw_drawPlane(swigCPtr, btVector3.getCPtr(planeNormal), planeConst, btTransform.getCPtr(transform), btVector3.getCPtr(color));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 public btTransform inverseTimes(btTransform t) {
   btTransform ret = new btTransform(LinearMathPINVOKE.btTransform_inverseTimes(swigCPtr, btTransform.getCPtr(t)), true);
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
   return ret;
 }
        public btTransform inverse()
        {
            btTransform ret = new btTransform(LinearMathPINVOKE.btTransform_inverse(swigCPtr), true);

            return(ret);
        }
 internal static HandleRef getCPtr(btTransform obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
        public static btTransform getIdentity()
        {
            btTransform ret = new btTransform(LinearMathPINVOKE.btTransform_getIdentity(), false);

            return(ret);
        }
 public void mult(btTransform t1, btTransform t2) {
   LinearMathPINVOKE.btTransform_mult(swigCPtr, btTransform.getCPtr(t1), btTransform.getCPtr(t2));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 public virtual void drawBox(btVector3 bbMin, btVector3 bbMax, btTransform trans, btVector3 color) {
   if (SwigDerivedClassHasMethod("drawBox", swigMethodTypes18)) LinearMathPINVOKE.btIDebugDraw_drawBoxSwigExplicitbtIDebugDraw__SWIG_1(swigCPtr, btVector3.getCPtr(bbMin), btVector3.getCPtr(bbMax), btTransform.getCPtr(trans), btVector3.getCPtr(color)); else LinearMathPINVOKE.btIDebugDraw_drawBox__SWIG_1(swigCPtr, btVector3.getCPtr(bbMin), btVector3.getCPtr(bbMax), btTransform.getCPtr(trans), btVector3.getCPtr(color));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 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();
     }
 }
 public btDefaultMotionState(btTransform startTrans) : this(LinearMathPINVOKE.new_btDefaultMotionState__SWIG_1(btTransform.getCPtr(startTrans)), true) {
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }
 internal static HandleRef getCPtr(btTransform obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Example #44
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;
    }
 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();
 }
 public virtual void getWorldTransform(btTransform centerOfMassWorldTrans) {
   LinearMathPINVOKE.btDefaultMotionState_getWorldTransform(swigCPtr, btTransform.getCPtr(centerOfMassWorldTrans));
   if (LinearMathPINVOKE.SWIGPendingException.Pending) throw LinearMathPINVOKE.SWIGPendingException.Retrieve();
 }