예제 #1
0
        public void InitializeWorld()
        {
            mGameObjects = new List <NetGameObject>();
            //mWorldMap = new WorldMap();

#if _USE_BEPU_PHYSICS
            space = new BEPUphysics.Space();
            space.ForceUpdater.Gravity = new BEPUutilities.Vector3(0, -9.81f, 0);
#elif _USE_BULLET_SHARP
            Broadphase = new BulletSharp.AxisSweep3(new BulletSharp.Math.Vector3(-1000, -1000, -1000), new BulletSharp.Math.Vector3(1000, 1000, 1000));

            var conf       = new BulletSharp.DefaultCollisionConfiguration();
            var dispatcher = new BulletSharp.CollisionDispatcher(conf);
            world         = new BulletSharp.MultiBodyDynamicsWorld(dispatcher, Broadphase, new BulletSharp.MultiBodyConstraintSolver(), conf);
            world.Gravity = new BulletSharp.Math.Vector3(0, -9.81f, 0);

            var box = new BulletSharp.BoxShape(50f, 1f, 50f);
            //box.Margin = 0f;
            floor = new BulletSharp.RigidBody(new BulletSharp.RigidBodyConstructionInfo(0f, new BulletSharp.DefaultMotionState(), box, new BulletSharp.Math.Vector3(0, -2f, 0)));
            floor.CollisionFlags = BulletSharp.CollisionFlags.KinematicObject;


            BulletSharp.Math.Matrix worldTrans = new BulletSharp.Math.Matrix();
            worldTrans.M41       = 0f;
            worldTrans.M42       = -2f;
            worldTrans.M43       = 0;
            floor.WorldTransform = worldTrans;
            //floor.Friction = 0.5f;


            world.AddRigidBody(floor, BulletSharp.CollisionFilterGroups.DefaultFilter, //BulletSharp.CollisionFilterGroups.Everything);
                               (BulletSharp.CollisionFilterGroups.DefaultFilter
                                | BulletSharp.CollisionFilterGroups.StaticFilter
                                | BulletSharp.CollisionFilterGroups.KinematicFilter
                                | BulletSharp.CollisionFilterGroups.DebrisFilter
                                | BulletSharp.CollisionFilterGroups.SensorTrigger
                                | BulletSharp.CollisionFilterGroups.CharacterFilter
                               )
                               );
#elif _USE_BEPU_PHYSICS_V2
            characters = new BepuPhysics.CharacterControllers(BufferPool);
            Simulation = Simulation.Create(BufferPool, new BepuPhysics.CharacterNarrowphaseCallbacks(characters), new DemoPoseIntegratorCallbacks(new System.Numerics.Vector3(0, -10, 0)));

            Simulation.Statics.Add(new StaticDescription(new System.Numerics.Vector3(0, 0, 0), new CollidableDescription(Simulation.Shapes.Add(new Box(50, 1, 50)), 0.1f)));
#endif
        }
예제 #2
0
        private void LoadPhysics()
        {
            var defaultCollisionConfiguration = new BulletSharp.DefaultCollisionConfiguration();
            var collisionDispatcher = new BulletSharp.CollisionDispatcher();
            var worldAabbMin = new Vector3(-1000, -1000, -1000);
            var worldAabbMax = new Vector3(1000, 1000, 1000);
            var broadphase = new BulletSharp.AxisSweep3(worldAabbMin, worldAabbMax);
            this.collisionWorld = new BulletSharp.CollisionWorld(collisionDispatcher, broadphase, defaultCollisionConfiguration);
            this.collisionWorld.DebugDrawer = new BulletDebugDrawer(this.viewscreenProgram);

            foreach (var collisionObject in mousePole.ContactObjects)
            {
                collisionWorld.AddCollisionObject(collisionObject);
            }
        }