예제 #1
0
        protected override void Initialize()
        {
            // Initialise the camera
            cam = new Camera(MathHelper.ToRadians(45.0f),
                (float)graphics.GraphicsDevice.Viewport.Width /
                (float)graphics.GraphicsDevice.Viewport.Height,
                1.0f, 10000.0f, Vector3.Zero, Vector3.Up);
            cam.position = new Vector3(0.0f, 0.0f, 0.0f);

            // Initialise the roman
            roman = new Roman("Models/Characters/roman", Content);

            base.Initialize();
        }
예제 #2
0
        protected override void LoadContent()
        {
            // Load the terrain object
            terrain = new Terrain("Models/Terrain/terrain", Content);

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // used to set up camera
            cam = new Camera(MathHelper.ToRadians(45.0f), // field of view
                (float)graphics.GraphicsDevice.Viewport.Width /
                (float)graphics.GraphicsDevice.Viewport.Height, // aspect ratio
                1.0f, 10000.0f, Vector3.Zero, Vector3.Up);
            cam.position = new Vector3(0.0f, 30.0f, 160.0f); // sets up cameras position

            // roman position
            roman.position = new Vector3(cam.position.X - 5.0f, cam.position.Y - 10.0f,
                cam.position.Z - 5.0f);

            // Add objects to the game objects list
            gameObjects.Add(cam);
            gameObjects.Add(terrain);
            gameObjects.Add(roman);
        }
예제 #3
0
        // Draw method
        public virtual void draw(Camera cam)
        {
            if (model != null)
            {
                foreach(ModelMesh mesh in model.Meshes)
                {
                    foreach (BasicEffect effect in mesh.Effects)
                    {
                        effect.EnableDefaultLighting();
                        effect.PreferPerPixelLighting = true;

                        effect.World = worldMatrix;
                        effect.Projection = cam.projMat;
                        effect.View = cam.viewMat;
                    }
                    mesh.Draw();
                }
            }
        }