public void setCollisionShape(btCollisionShape collisionShape)
        {
            if (m_disposed)
            {
                throw new ObjectDisposedException(ToString());
            }

            BulletAPI_BtCollisionObject_setCollisionShape(m_handle, collisionShape.Handle);
        }
Esempio n. 2
0
 public btRigidBody(float mass, btMotionState motionState, btCollisionShape collisionShape, btVector3 localInertia)
 {
     m_constructionInfo = new btRigidBodyConstructionInfo();
     m_constructionInfo.m_collisionShape      = collisionShape;
     m_constructionInfo.m_localInertia        = localInertia;
     m_constructionInfo.m_motionState         = motionState;
     m_constructionInfo.m_startWorldTransform = btTransform.getIdentity();
     m_constructionInfo.SetGenericDefaultValues();
     m_constructionInfo.m_mass = mass;
     m_constructionInfo.commit();
     m_handle = BulletAPI_CreateBtRigidBody(m_constructionInfo.Handle);
 }
Esempio n. 3
0
 public btRigidBody(float mass, btMotionState motionState, btCollisionShape collisionShape, btVector3 localInertia)
 {
     
     m_constructionInfo = new btRigidBodyConstructionInfo();
     m_constructionInfo.m_collisionShape = collisionShape;
     m_constructionInfo.m_localInertia = localInertia;
     m_constructionInfo.m_motionState = motionState;
     m_constructionInfo.m_startWorldTransform = btTransform.getIdentity();
     m_constructionInfo.SetGenericDefaultValues();
     m_constructionInfo.m_mass = mass;
     m_constructionInfo.commit();
     m_handle = BulletAPI_CreateBtRigidBody(m_constructionInfo.Handle);
  }
        internal void Dispose()
        {
            m_parent_scene.RemoveAvatarFromList(this);
            if (Body != null)
            {
                if (Body.isInWorld())
                {
                    m_parent_scene.removeFromWorld(this, Body);
                    m_parent_scene.RemoveCollisionObject(Body);
                }
                Body.Dispose(); 
                Body = null;
            }

            if (m_aMotor != null)
            {
                if (m_aMotor.Handle != IntPtr.Zero)
                    m_parent_scene.getBulletWorld().removeConstraint(m_aMotor);

                m_aMotor.Dispose(); m_aMotor = null;
            }
            if (ClosestCastResult != null)
            {
                ClosestCastResult.Dispose(); ClosestCastResult = null;
            }
            if (Shell != null)
            {
                Shell.Dispose(); Shell = null;
            }
            tempQuat1.Dispose();
            tempTrans1.Dispose();
            tempVector1.Dispose();
            tempVector2.Dispose();
            tempVector3.Dispose();
            tempVector4.Dispose();
            tempVector5RayCast.Dispose();
            tempVector6RayCast.Dispose();

        }
        /// <summary>
        /// This creates the Avatar's physical Surrogate at the position supplied
        /// </summary>
        /// <param name="npositionX"></param>
        /// <param name="npositionY"></param>
        /// <param name="npositionZ"></param>

        // WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access
        // to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only 
        // place that is safe to call this routine AvatarGeomAndBodyCreation.
        private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ)
        {
            
            if (CAPSULE_LENGTH <= 0)
            {
                m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
                CAPSULE_LENGTH = 0.01f;

            }

            if (CAPSULE_RADIUS <= 0)
            {
                m_log.Warn("[PHYSICS]: The capsule size you specified in opensim.ini is invalid!  Setting it to the smallest possible size!");
                CAPSULE_RADIUS = 0.01f;

            }

            Shell = new btCapsuleShape(CAPSULE_RADIUS, CAPSULE_LENGTH);

            if (m_bodyPosition == null)
                m_bodyPosition = new btVector3(npositionX, npositionY, npositionZ);

            m_bodyPosition.setValue(npositionX, npositionY, npositionZ);

            if (m_bodyOrientation == null)
                m_bodyOrientation = new btQuaternion(m_CapsuleOrientationAxis, (Utils.DEG_TO_RAD * 90));

            if (m_bodyTransform == null)
                m_bodyTransform = new btTransform(m_bodyOrientation, m_bodyPosition);
            else
            {
                m_bodyTransform.Dispose();
                m_bodyTransform = new btTransform(m_bodyOrientation, m_bodyPosition);
            }

            if (m_bodyMotionState == null)
                m_bodyMotionState = new btDefaultMotionState(m_bodyTransform);
            else
                m_bodyMotionState.setWorldTransform(m_bodyTransform);

            m_mass = Mass;

            Body = new btRigidBody(m_mass, m_bodyMotionState, Shell);
            // this is used for self identification. User localID instead of body handle
            Body.setUserPointer(new IntPtr((int)m_localID));
            
            if (ClosestCastResult != null)
                ClosestCastResult.Dispose();
            ClosestCastResult = new ClosestNotMeRayResultCallback(Body);

            m_parent_scene.AddRigidBody(Body);
            Body.setActivationState(4);
            if (m_aMotor != null)
            {
                if (m_aMotor.Handle != IntPtr.Zero)
                {
                    m_parent_scene.getBulletWorld().removeConstraint(m_aMotor);
                    m_aMotor.Dispose();
                }
                m_aMotor = null;
            }

            m_aMotor = new btGeneric6DofConstraint(Body, m_parent_scene.TerrainBody,
                                                                         m_parent_scene.TransZero,
                                                                         m_parent_scene.TransZero, false);
            m_aMotor.setAngularLowerLimit(m_parent_scene.VectorZero);
            m_aMotor.setAngularUpperLimit(m_parent_scene.VectorZero);
            
           
        }
Esempio n. 6
0
        private void SetCollisionShape(btCollisionShape shape)
        {
            /*
            if (shape == null)
                m_log.Debug("[PHYSICS]:SetShape!Null");
            else
                m_log.Debug("[PHYSICS]:SetShape!");
            
            if (Body != null)
            {
                DisposeOfBody();
            }

            if (prim_geom != null)
            {
                prim_geom.Dispose();
                prim_geom = null;
            }
             */
            prim_geom = shape;

            //Body.set
        }
Esempio n. 7
0
        public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, Vector3 pos, Vector3 size,
                       Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical)
        {
            tempPosition1 = new btVector3(0, 0, 0);
            tempPosition2 = new btVector3(0, 0, 0);
            tempPosition3 = new btVector3(0, 0, 0);
            tempSize1 = new btVector3(0, 0, 0);
            tempSize2 = new btVector3(0, 0, 0);
            tempLinearVelocity1 = new btVector3(0, 0, 0);
            tempLinearVelocity2 = new btVector3(0, 0, 0);
            tempAngularVelocity1 = new btVector3(0, 0, 0);
            tempAngularVelocity2 = new btVector3(0, 0, 0);
            tempInertia1 = new btVector3(0, 0, 0);
            tempInertia2 = new btVector3(0, 0, 0);
            tempOrientation1 = new btQuaternion(0, 0, 0, 1);
            tempOrientation2 = new btQuaternion(0, 0, 0, 1);
            _parent_scene = parent_scene;
            tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero);
            tempTransform2 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero); ;
            tempTransform3 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero); ;
            tempTransform4 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero); ;

            tempMotionState1 = new btDefaultMotionState(_parent_scene.TransZero);
            tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero);
            tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero);


            AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize);
            int regionsize = (int)Constants.RegionSize;

            if (regionsize == 256)
                regionsize = 512;

            AxisLockLinearHigh = new btVector3((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionSize);

            _target_velocity = Vector3.Zero;
            _velocity = Vector3.Zero;
            _position = pos;
            m_taintposition = pos;
            PID_D = parent_scene.bodyPIDD;
            PID_G = parent_scene.bodyPIDG;
            m_density = parent_scene.geomDefaultDensity;
            // m_tensor = parent_scene.bodyMotorJointMaxforceTensor;
            // body_autodisable_frames = parent_scene.bodyFramesAutoDisable;

            prim_geom = null;
            Body = null;

            if (size.X <= 0) size.X = 0.01f;
            if (size.Y <= 0) size.Y = 0.01f;
            if (size.Z <= 0) size.Z = 0.01f;

            _size = size;
            m_taintsize = _size;
            _acceleration = Vector3.Zero;
            m_rotationalVelocity = Vector3.Zero;
            _orientation = rotation;
            m_taintrot = _orientation;
            _mesh = mesh;
            _pbs = pbs;

            _parent_scene = parent_scene;

            if (pos.Z < 0)
                m_isphysical = false;
            else
            {
                m_isphysical = pisPhysical;
                // If we're physical, we need to be in the master space for now.
                // linksets *should* be in a space together..  but are not currently
            }
            m_primName = primName;
            m_taintadd = true;
            _parent_scene.AddPhysicsActorTaint(this);

        }
        internal void Dispose()
        {
            if (Body.isInWorld())
                m_parent_scene.removeFromWorld(Body);

            if (m_aMotor.Handle != IntPtr.Zero)
                m_parent_scene.getBulletWorld().removeConstraint(m_aMotor);

            m_aMotor.Dispose(); m_aMotor = null;
            ClosestCastResult.Dispose(); ClosestCastResult = null;
            Body.Dispose(); Body = null;
            Shell.Dispose(); Shell = null;
            tempQuat1.Dispose();
            tempTrans1.Dispose();
            tempVector1.Dispose();
            tempVector2.Dispose();
            tempVector3.Dispose();
            tempVector4.Dispose();
            tempVector5RayCast.Dispose();
            tempVector6RayCast.Dispose();

        }
Esempio n. 9
0
        public void setCollisionShape(btCollisionShape collisionShape)
        {
            if (m_disposed)
                throw new ObjectDisposedException(ToString());

            BulletAPI_BtCollisionObject_setCollisionShape(m_handle, collisionShape.Handle);
        }
Esempio n. 10
0
        private void SetCollisionShape(btCollisionShape shape)
        {
            /*if (shape == null)
                m_log.Debug("[PHYSICS]:SetShape!Null");
            
            if (Body != null)
            {
                DisposeOfBody();
            }

            if (prim_geom != null)
            {
                prim_geom.Dispose();
                prim_geom = null;
            }*/
            if (shape != null)
            {
                prim_geom = shape;
                //CreateGeom(IntPtr.Zero, null);
            }
            else
                prim_geom = shape;

            //Body.set
        }