Exemplo n.º 1
0
        public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager content)
        {
            base.LoadContent(content);

            BlockData.Initialize(Device, content);

            cam = new FirstPersonCamera(0.5f, 10);
            cam.Pos = new Vector3(3, 3, 13);


            map = new Map(Device);

            partition = new MapPartition(map);
            engine = new PhysicsEngine3D(partition);

            MeshBuilder mb = new MeshBuilder(Device);
            sphere = mb.CreateSphere(0.1f, 10, 10);
            marker = new MeshNode(sphere);

            placeType = 1;

            primBatch = new PrimitiveBatch(Device);


        }
Exemplo n.º 2
0
        private void initializePhysicsEngine()
        {
            engine = new PhysicsEngine3D(partition);
            engine.Gravity = new Vector3(0, -0.1f, 0);
            engine.AddRigidBody(player.Body); //physics body of player

            //floor and walls
            engine.AddRigidBody(new PlaneBody(Vector3.Up, new Vector3(0, 1f, 0)));
            engine.AddRigidBody(new PlaneBody(new Vector3(1f, 0, 0), new Vector3(1f, 0, 0)));
            engine.AddRigidBody(new PlaneBody(new Vector3(-1f, 0, 0), new Vector3(map.Width - 1, 0, 0)));
            engine.AddRigidBody(new PlaneBody(new Vector3(0, 0, 1f), new Vector3(0, 0, 1f)));
            engine.AddRigidBody(new PlaneBody(new Vector3(0, 0, -1f), new Vector3(0, 0, map.Depth - 1)));
        }
Exemplo n.º 3
0
        private void setupEngine()
        {
            engine = new PhysicsEngine3D(new GridPartition3D(Vector3.Zero, new Vector3(10, 10, 10), 3, 3, 3));

            float boxSize = 10;

            engine.AddRigidBody(new PlaneBody(Vector3.Up, Vector3.Zero));
            engine.AddRigidBody(new PlaneBody(Vector3.Right, Vector3.Zero));
            engine.AddRigidBody(new PlaneBody(new Vector3(0, 0, 1), Vector3.Zero));

            engine.AddRigidBody(new PlaneBody(-Vector3.Up, new Vector3(0, boxSize, 0)));
            engine.AddRigidBody(new PlaneBody(-Vector3.Right, new Vector3(boxSize, 0, 0)));
            engine.AddRigidBody(new PlaneBody(new Vector3(0, 0, -1), new Vector3(0, 0, boxSize)));

            int bodyCount = 5;
            for (int i = 0; i < bodyCount; i++)
            {
                engine.AddRigidBody(new SphereBody(new Vector3((i*2) + 1, 6, 2), new Vector3(i + 1f, 0, 0), 1f, radius));
            }

            for (int i = 0; i < bodyCount; i++)
            {
                engine.AddRigidBody(new SphereBody(new Vector3((i * 2) + 1, 8, 2.4f), new Vector3(i - 1f, 0, 0), 1f, radius));
            }
        }