public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, int shapeTypeA,
			int shapeTypeB, float marginA, float marginB, VoronoiSimplexSolver simplexSolver,
			ConvexPenetrationDepthSolver penetrationDepthSolver)
			: base(btGjkPairDetector_new2(objectA._native, objectB._native, shapeTypeA,
                shapeTypeB, marginA, marginB, simplexSolver._native, (penetrationDepthSolver != null) ? penetrationDepthSolver._native : IntPtr.Zero))
		{
		}
        protected override void OnInitializePhysics()
        {
            CollisionConf = new DefaultCollisionConfiguration();
            Dispatcher = new CollisionDispatcher(CollisionConf);

            Broadphase = new DbvtBroadphase();

            World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, null, CollisionConf);
            World.Gravity = new Vector3(0, -10, 0);

            // ground
            CollisionShape groundShape = new BoxShape(50, 1, 50);
            CollisionShapes.Add(groundShape);
            CollisionObject ground = LocalCreateRigidBody(0, Matrix.Identity, groundShape);
            ground.UserObject = "Ground";

            // Objects
            //colShape = new BoxShape(1);
            Vector3[] points0 = {
                new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1)
            };
            Vector3[] points1 = {
                new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 1), new Vector3(0,0,-1), new Vector3(-1,-1,0)
            };
            colShape0 = new ConvexHullShape(points0);
            colShape1 = new ConvexHullShape(points1);
            CollisionShapes.Add(colShape0);
            CollisionShapes.Add(colShape1);

            body2 = LocalCreateRigidBody(0, body2Position, colShape1);

            rotBody = LocalCreateRigidBody(0, rotBodyPosition, colShape0);
            rotBody.CollisionFlags |= CollisionFlags.KinematicObject;
            rotBody.ActivationState = ActivationState.DisableDeactivation;
        }
 public KinematicCharacterController(PairCachingGhostObject ghostObject, ConvexShape convexShape, float stepHeight, int upAxis = 1)
 {
     m_upAxis = upAxis;
     m_addedMargin = 0.02f;
     m_walkDirection = Vector3.Zero;
     m_useGhostObjectSweepTest = true;
     m_ghostObject = ghostObject;
     m_stepHeight = stepHeight;
     m_turnAngle = 0f;
     m_convexShape = convexShape;
     m_useWalkDirection = true;	// use walk direction by default, legacy behavior
     m_velocityTimeInterval = 0.0f;
     m_verticalVelocity = 0.0f;
     m_verticalOffset = 0.0f;
     Gravity = 9.8f * 3; // 3G acceleration.
     m_fallSpeed = 55.0f; // Terminal velocity of a sky diver in m/s.
     m_jumpSpeed = 10.0f; // ?
     m_wasOnGround = false;
     m_wasJumping = false;
     m_interpolateUp = true;
     MaxSlope = MathUtil.DegToRadians(45.0f);
     m_currentStepOffset = 0;
     full_drop = false;
     bounce_fix = false;
 }
		public bool CalcPenDepth(VoronoiSimplexSolver simplexSolver, ConvexShape convexA,
			ConvexShape convexB, Matrix transA, Matrix transB, out Vector3 v, out Vector3 pa,
			out Vector3 pb, IDebugDraw debugDraw)
		{
			return btConvexPenetrationDepthSolver_calcPenDepth(_native, simplexSolver._native,
				convexA._native, convexB._native, ref transA, ref transB, out v, out pa,
				out pb, DebugDraw.GetUnmanaged(debugDraw));
		}
		public unsafe static void ConvexSweepTest(this GhostObject obj, ConvexShape castShape, ref OpenTK.Matrix4 convexFromWorld, ref OpenTK.Matrix4 convexToWorld, ConvexResultCallback resultCallback, float allowedCcdPenetration)
		{
			fixed (OpenTK.Matrix4* convexFromWorldPtr = &convexFromWorld)
			{
				fixed (OpenTK.Matrix4* convexToWorldPtr = &convexToWorld)
				{
					obj.ConvexSweepTest(castShape, ref *(BulletSharp.Math.Matrix*)convexFromWorldPtr, ref *(BulletSharp.Math.Matrix*)convexToWorldPtr, resultCallback, allowedCcdPenetration);
				}
			}
		}
        public TriangleConvexcastCallback(ConvexShape convexShape, ref Matrix convexShapeFrom, ref Matrix convexShapeTo, ref Matrix triangleToWorld, float triangleCollisionMargin)
        {
            ConvexShape = convexShape;
            ConvexShapeFrom = convexShapeFrom;
            ConvexShapeTo = convexShapeTo;
            TriangleToWorld = triangleToWorld;
            TriangleCollisionMargin = triangleCollisionMargin;

            AllowedPenetration = 0.0f;
            HitFraction = 1.0f;
        }
Beispiel #7
0
 public KinematicCharacterController(PairCachingGhostObject ghostObject, ConvexShape convexShape, float stepHeight, int upAxis = 1)
 {
     m_addedMargin             = 0.02f;
     m_walkDirection           = Vector3.Zero;
     m_useGhostObjectSweepTest = true;
     m_ghostObject             = ghostObject;
     m_stepHeight           = stepHeight;
     m_convexShape          = convexShape;
     m_useWalkDirection     = true; // use walk direction by default, legacy behavior
     m_velocityTimeInterval = 0.0f;
     m_verticalVelocity     = 0.0f;
     m_verticalOffset       = 0.0f;
     Gravity             = 9.8f * 3; // 3G acceleration.
     m_fallSpeed         = 55.0f;    // Terminal velocity of a sky diver in m/s.
     m_jumpSpeed         = 10.0f;    // ?
     m_wasOnGround       = false;
     m_wasJumping        = false;
     m_interpolateUp     = true;
     MaxSlope            = MathUtil.DegToRadians(45.0f);
     m_currentStepOffset = 0;
     full_drop           = false;
     bounce_fix          = false;
     _callback           = new KinematicClosestNotMeConvexResultCallback(m_ghostObject, -Vector3.UnitY, 0.7071f);
 }
Beispiel #8
0
 public void ConvexSweepTest(ConvexShape castShape, Matrix convexFromWorld, Matrix convexToWorld, ConvexResultCallback resultCallback)
 {
     btGhostObject_convexSweepTest(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native);
 }
Beispiel #9
0
 public void ConvexSweepTest(ConvexShape castShape, Matrix convexFromWorld,
                             Matrix convexToWorld, ConvexResultCallback resultCallback, double allowedCcdPenetration = 0)
 {
     btGhostObject_convexSweepTest(Native, castShape.Native, ref convexFromWorld,
                                   ref convexToWorld, resultCallback.Native, allowedCcdPenetration);
 }
 public ContinuousConvexCollision(ConvexShape shapeA, StaticPlaneShape plane)
     : base(btContinuousConvexCollision_new2(shapeA._native, plane._native))
 {
 }
 public ContinuousConvexCollision(ConvexShape shapeA, StaticPlaneShape plane)
     : base(btContinuousConvexCollision_new2(shapeA.Native, plane.Native))
 {
 }
Beispiel #12
0
 public void SetMinkowskiA(ConvexShape minkA)
 {
     btGjkPairDetector_setMinkowskiA(_native, minkA._native);
 }
Beispiel #13
0
 public GjkConvexCast(ConvexShape convexA, ConvexShape convexB, VoronoiSimplexSolver simplexSolver)
     : base(btGjkConvexCast_new(convexA._native, convexB._native, simplexSolver._native))
 {
 }
		public Convex2DShape(ConvexShape convexChildShape)
			: base(btConvex2dShape_new(convexChildShape._native))
		{
            _childShape = convexChildShape;
		}
 public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, int shapeTypeA, int shapeTypeB, float marginA, float marginB, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver)
     : base(btGjkPairDetector_new2(objectA._native, objectB._native, shapeTypeA, shapeTypeB, marginA, marginB, simplexSolver._native, (penetrationDepthSolver != null) ? penetrationDepthSolver._native : IntPtr.Zero))
 {
 }
		public void SetMinkowskiA(ConvexShape minkA)
		{
			btGjkPairDetector_setMinkowskiA(_native, minkA._native);
		}
 public ShapeHull(ConvexShape shape)
 {
     _native = btShapeHull_new(shape._native);
     _shape = shape;
 }
		public GjkConvexCast(ConvexShape convexA, ConvexShape convexB, VoronoiSimplexSolver simplexSolver)
			: base(btGjkConvexCast_new(convexA._native, convexB._native, simplexSolver._native))
		{
		}
Beispiel #19
0
 public ShapeHull(ConvexShape shape)
 {
     _native = btShapeHull_new(shape._native);
     //_shape = shape;
 }
Beispiel #20
0
        public GjkConvexCast(ConvexShape convexA, ConvexShape convexB, VoronoiSimplexSolver simplexSolver)
        {
            IntPtr native = btGjkConvexCast_new(convexA.Native, convexB.Native, simplexSolver.Native);

            InitializeUserOwned(native);
        }
        public ContinuousConvexCollision(ConvexShape shapeA, StaticPlaneShape plane)
        {
            IntPtr native = btContinuousConvexCollision_new2(shapeA.Native, plane.Native);

            InitializeUserOwned(native);
        }
 public unsafe static OpenTK.Vector3 LocalGetSupportVertexWithoutMarginNonVirtual(this ConvexShape obj, ref OpenTK.Vector3 vec)
 {
     fixed(OpenTK.Vector3 *vecPtr = &vec)
     {
         return(obj.LocalGetSupportVertexWithoutMarginNonVirtual(ref *(BulletSharp.Math.Vector3 *)vecPtr).ToOpenTK());
     }
 }
		public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver)
            : base(btGjkPairDetector_new(objectA._native, objectB._native, simplexSolver._native, (penetrationDepthSolver != null) ? penetrationDepthSolver._native : IntPtr.Zero))
		{
		}
Beispiel #24
0
 public ShapeHull(ConvexShape shape)
 {
     Native = btShapeHull_new(shape.Native);
     _shape = shape;
 }
		public void SetMinkowskiB(ConvexShape minkB)
		{
			btGjkPairDetector_setMinkowskiB(_native, minkB._native);
		}
 public MinkowskiSumShape(ConvexShape shapeA, ConvexShape shapeB)
     : base(btMinkowskiSumShape_new(shapeA.Native, shapeB.Native))
 {
     ShapeA = shapeA;
     ShapeB = shapeB;
 }
 public UniformScalingShape(ConvexShape convexChildShape, float uniformScalingFactor)
     : base(btUniformScalingShape_new(convexChildShape._native, uniformScalingFactor))
 {
     _convexChildShape = convexChildShape;
 }
 public void ConvexSweepTestRef(ConvexShape castShape, ref Matrix convexFromWorld, ref Matrix convexToWorld, ConvexResultCallback resultCallback)
 {
     btGhostObject_convexSweepTest(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native);
 }
		public UniformScalingShape(ConvexShape convexChildShape, float uniformScalingFactor)
			: base(btUniformScalingShape_new(convexChildShape._native, uniformScalingFactor))
		{
            _convexChildShape = convexChildShape;
		}
 public void ConvexSweepTestRef(ConvexShape castShape, ref Matrix convexFromWorld, ref Matrix convexToWorld, ConvexResultCallback resultCallback, float allowedCcdPenetration)
 {
     btGhostObject_convexSweepTest2(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native, allowedCcdPenetration);
 }
Beispiel #31
0
 public GjkPairDetector(ConvexShape objectA, ConvexShape objectB, VoronoiSimplexSolver simplexSolver,
                        ConvexPenetrationDepthSolver penetrationDepthSolver)
     : base(btGjkPairDetector_new(objectA._native, objectB._native, simplexSolver._native,
                                  (penetrationDepthSolver != null) ? penetrationDepthSolver._native : IntPtr.Zero))
 {
 }
		public void ConvexSweepTest(ConvexShape castShape, Matrix from, Matrix to,
			ConvexResultCallback resultCallback)
		{
			btCollisionWorld_convexSweepTest(_native, castShape._native, ref from,
				ref to, resultCallback._native);
		}
Beispiel #33
0
 public void SetMinkowskiB(ConvexShape minkB)
 {
     btGjkPairDetector_setMinkowskiB(_native, minkB._native);
 }
		public void ConvexSweepTest(ConvexShape castShape, Matrix from, Matrix to,
			ConvexResultCallback resultCallback, float allowedCcdPenetration)
		{
			btCollisionWorld_convexSweepTest2(_native, castShape._native, ref from,
				ref to, resultCallback._native, allowedCcdPenetration);
		}
 public ContinuousConvexCollision(ConvexShape shapeA, ConvexShape shapeB, VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver)
     : base(btContinuousConvexCollision_new(shapeA._native, shapeB._native, simplexSolver._native, penetrationDepthSolver._native))
 {
 }
		public static void ObjectQuerySingle(ConvexShape castShape, Matrix rayFromTrans,
			Matrix rayToTrans, CollisionObject collisionObject, CollisionShape collisionShape,
			Matrix colObjWorldTransform, ConvexResultCallback resultCallback, float allowedPenetration)
		{
			btCollisionWorld_objectQuerySingle(castShape._native, ref rayFromTrans,
				ref rayToTrans, collisionObject._native, collisionShape._native, ref colObjWorldTransform,
				resultCallback._native, allowedPenetration);
		}
 public ContinuousConvexCollision(ConvexShape shapeA, ConvexShape shapeB,
                                  VoronoiSimplexSolver simplexSolver, ConvexPenetrationDepthSolver penetrationDepthSolver)
     : base(btContinuousConvexCollision_new(shapeA.Native, shapeB.Native,
                                            simplexSolver.Native, penetrationDepthSolver.Native))
 {
 }
		public static void ObjectQuerySingleInternal(ConvexShape castShape, Matrix convexFromTrans,
			Matrix convexToTrans, CollisionObjectWrapper colObjWrap, ConvexResultCallback resultCallback,
			float allowedPenetration)
		{
			btCollisionWorld_objectQuerySingleInternal(castShape._native, ref convexFromTrans,
				ref convexToTrans, colObjWrap._native, resultCallback._native, allowedPenetration);
		}
		public MinkowskiSumShape(ConvexShape shapeA, ConvexShape shapeB)
			: base(btMinkowskiSumShape_new(shapeA._native, shapeB._native))
		{
			_shapeA = shapeA;
			_shapeB = shapeB;
		}
 public UniformScalingShape(ConvexShape convexChildShape, double uniformScalingFactor)
     : base(btUniformScalingShape_new(convexChildShape.Native, uniformScalingFactor))
 {
     ChildShape = convexChildShape;
 }
Beispiel #41
0
 public void ConvexSweepTest(ConvexShape castShape, Matrix convexFromWorld, Matrix convexToWorld, ConvexResultCallback resultCallback, float allowedCcdPenetration)
 {
     btGhostObject_convexSweepTest2(_native, castShape._native, ref convexFromWorld, ref convexToWorld, resultCallback._native, allowedCcdPenetration);
 }
 public Convex2DShape(ConvexShape convexChildShape)
     : base(btConvex2dShape_new(convexChildShape.Native))
 {
     ChildShape = convexChildShape;
 }
Beispiel #43
0
 public bool CalcPenDepth(VoronoiSimplexSolver simplexSolver, ConvexShape convexA, ConvexShape convexB, Matrix transA, Matrix transB, out Vector3 v, out Vector3 pa, out Vector3 pb, IDebugDraw debugDraw)
 {
     return(btConvexPenetrationDepthSolver_calcPenDepth(_native, simplexSolver._native, convexA._native, convexB._native, ref transA, ref transB, out v, out pa, out pb, DebugDraw.GetUnmanaged(debugDraw)));
 }
		public unsafe static void ConvexSweepTest(this CollisionWorld obj, ConvexShape castShape, ref OpenTK.Matrix4 from, ref OpenTK.Matrix4 to, ConvexResultCallback resultCallback)
		{
			fixed (OpenTK.Matrix4* fromPtr = &from)
			{
				fixed (OpenTK.Matrix4* toPtr = &to)
				{
					obj.ConvexSweepTest(castShape, ref *(BulletSharp.Math.Matrix*)fromPtr, ref *(BulletSharp.Math.Matrix*)toPtr, resultCallback);
				}
			}
		}