Exemplo n.º 1
0
        public void Draw(Camera camera)
        {
            if (!visible) return;
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect e in mesh.Effects)
                {
                    e.EnableDefaultLighting();

                    e.World = GetWorld(mesh);
                    e.View = camera.ViewMatrix;
                    e.Projection = camera.ProjectionMatrix;
                }
                mesh.Draw();
            }
        }
Exemplo n.º 2
0
        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;

            PresentationParameters pp = device.PresentationParameters;
            renderTarget = new RenderTarget2D(device, 600, 600, true, device.DisplayMode.Format, DepthFormat.Depth24);

            spriteBatch = new SpriteBatch(device);
            effect = new BasicEffect(device);
            //effect.VertexColorEnabled = true;
            effect.LightingEnabled = true;
            effect.DirectionalLight0.Enabled = true;
            effect.DirectionalLight0.DiffuseColor = Color.White.ToVector3();
            effect.DirectionalLight0.Direction = new Vector3(0, -1, 0);
            effect.AmbientLightColor = new Vector3(0.3f);
            camera = new Camera(new Vector3(0, 15, 20), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            SetupGrid(new Vector3(-5, 0, -5), new Vector3(5, 0, 5), 10);
        }