예제 #1
0
        private void createHeightmapObjects()
        {
            HeightmapObject hmobj = new HeightmapObject();

            hmobj.scaleFactor    = 0.5f * Vector3.One;
            hmobj.position       = Vector3.Zero;
            hmobj.terrainMapName = "..\\..\\..\\..\\Content\\Textures\\US_Canyon.png";
            hmobj.textureName    = "..\\..\\..\\..\\Content\\Textures\\grass.png";
            hmobj.objectWorld    = Matrix.Identity;
            hmobj.world          = Matrix.Identity;
            heightmapObjects.Add(hmobj);
        }
예제 #2
0
        public override void InitializeEnvironment()
        {
            bool useCustomTerrain = false;

            if (useCustomTerrain)
            {
                try
                {
                    physicsManager.PhysicsSystem.Gravity = Vector3.Zero;
                    physicsManager.AddGravityController(new Vector3(0, -101, 0), 100, 10);

                    /*terrain = new Terrain(new Vector3(0, -15, 0), // position
                     *  //new Vector3(100f, .1f, 100f),  // X with, possible y range, Z depth
                     *                      new Vector3(15000f, .55f, 15000f),  // X with, possible y range, Z depth
                     *                      100, 100, graphicsDevice, moon);*/
                    planet = new Planet(new Vector3(0, -101, 0),    // Position
                                        new Vector3(100, 100, 100), // Radius
                                        0, Math.PI / 8, 2, graphicsDevice, moon);


                    objectsToAdd.Add(planet.ID, planet);
                    //objectsToAdd.Add(terrain.ID, terrain);
                }
                catch (Exception E)
                {
                    System.Diagnostics.Debug.WriteLine(E.StackTrace);
                }
            }
            else
            {
                try
                {
                    // some video cards can't handle the >16 bit index type of the terrain
                    HeightmapObject heightmapObj = new HeightmapObject(terrainModel, Vector2.Zero, new Vector3(0, 0, 0));
                    objectsToAdd.Add(heightmapObj.ID, heightmapObj);
                }
                catch (Exception E)
                {
                    // if that happens just create a ground plane
                    //planeObj = new PlaneObject(planeModel, 0.0f, new Vector3(0, -15, 0), "");
                    //newObjects.Add(planeObj.ID, planeObj);
                    System.Diagnostics.Debug.WriteLine(E.StackTrace);
                }
            }
        }
예제 #3
0
        protected override void LoadContent()
        {
            boxModel      = content.Load <Model>("content/box");
            sphereModel   = content.Load <Model>("content/sphere");
            capsuleModel  = content.Load <Model>("content/capsule");
            carModel      = content.Load <Model>("content/car");
            wheelModel    = content.Load <Model>("content/wheel");
            staticModel   = content.Load <Model>("content/staticmesh");
            planeModel    = content.Load <Model>("content/plane");
            pinModel      = content.Load <Model>("content/pin");
            compoundModel = content.Load <Model>("content/compound");
            cylinderModel = content.Load <Model>("content/cylinder");

            try
            {
                // some video card can't handle the >16 bit index type of the terrain
                terrainModel = content.Load <Model>("content/terrain");
                HeightmapObject heightmapObj = new HeightmapObject(this, terrainModel, Vector2.Zero);
                this.Components.Add(heightmapObj);
            }
            catch (Exception)
            {
                // if that happens just createa a ground plane
                PlaneObject planeObj = new PlaneObject(this, planeModel, 15.0f);
                this.Components.Add(planeObj);
            }

            TriangleMeshObject triObj = new TriangleMeshObject(this, staticModel, Matrix.Identity, Vector3.Zero);

            this.Components.Add(triObj);

            carObject = new CarObject(this, carModel, wheelModel, true, true, 30.0f, 5.0f, 4.7f, 5.0f, 0.20f, 0.4f, 0.05f, 0.45f, 0.3f, 1, 520.0f, physicSystem.Gravity.Length());
            carObject.Car.Chassis.Body.MoveTo(new Vector3(-5, -13, 5), Matrix.Identity);
            carObject.Car.EnableCar();
            carObject.Car.Chassis.Body.AllowFreezing = false;
            this.Components.Add(carObject);

            camera.Position = Vector3.Down * 12 + Vector3.Backward * 30.0f;

            CreateScene6();

            base.LoadContent();
        }
예제 #4
0
파일: JiggleGame.cs 프로젝트: jdarc/jiglibx
        protected override void LoadContent()
        {
            boxModel      = content.Load <Model>("Content/box");
            sphereModel   = content.Load <Model>("Content/sphere");
            capsuleModel  = content.Load <Model>("Content/capsule");
            carModel      = content.Load <Model>("Content/car");
            wheelModel    = content.Load <Model>("Content/wheel");
            staticModel   = content.Load <Model>("Content/StaticMesh");
            planeModel    = content.Load <Model>("Content/plane");
            pinModel      = content.Load <Model>("Content/pin");
            compoundModel = content.Load <Model>("Content/compound");
            cylinderModel = content.Load <Model>("Content/cylinder");

            try
            {
                terrainModel = content.Load <Model>("content/terrain");
                var heightmapObj = new HeightmapObject(this, terrainModel, Vector2.Zero);
                Components.Add(heightmapObj);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                var planeObj = new PlaneObject(this, planeModel, 15.0f);
                Components.Add(planeObj);
            }

            var triObj = new TriangleMeshObject(this, staticModel, Matrix.Identity, Vector3.Zero);

            Components.Add(triObj);

            carObject = new CarObject(this, carModel, wheelModel, true, true, 30.0f, 5.0f, 4.7f, 5.0f, 0.20f, 0.4f, 0.05f, 0.45f, 0.3f, 1, 520.0f, physicSystem.Gravity.Length());
            carObject.Car.Chassis.Body.MoveTo(new Vector3(-5, -13, 5), Matrix.Identity);
            carObject.Car.EnableCar();
            carObject.Car.Chassis.Body.AllowFreezing = false;
            Components.Add(carObject);

            camera.Position = Vector3.Down * 12 + Vector3.Backward * 30.0f;

            CreateScene6();

            base.LoadContent();
        }
예제 #5
0
        /// <summary>
        /// Should do scene and object initialization
        /// </summary>
        public virtual void InitializeEnvironment()
        {
            bool useCustomTerrain = false;

            if (useCustomTerrain)
            {
                try
                {
                    terrain = new Terrain(new Vector3(0, -15, 0),            // position
                                                                             //new Vector3(100f, .1f, 100f),  // X with, possible y range, Z depth
                                          new Vector3(15000f, .55f, 15000f), // X with, possible y range, Z depth
                                          100, 100, graphicsDevice, moon);

                    objectsToAdd.Add(terrain.ID, terrain);
                }
                catch (Exception E)
                {
                    System.Diagnostics.Debug.WriteLine(E.StackTrace);
                }
            }
            else
            {
                try
                {
                    // some video cards can't handle the >16 bit index type of the terrain
                    HeightmapObject heightmapObj = new HeightmapObject(terrainModel, Vector2.Zero, new Vector3(0, 0, 0));
                    objectsToAdd.Add(heightmapObj.ID, heightmapObj);
                }
                catch (Exception E)
                {
                    // if that happens just create a ground plane
                    planeObj = new PlaneObject(planeModel, 0.0f, new Vector3(0, -15, 0), 0);
                    objectsToAdd.Add(planeObj.ID, planeObj);
                    System.Diagnostics.Debug.WriteLine(E.StackTrace);
                }
            }
        }