Пример #1
0
        public override void Draw(GraphicsDevice device)
        {
            var gd = GameFacade.GraphicsDevice;

            gd.VertexDeclaration    = new VertexDeclaration(gd, TerrainVertex.VertexElements);
            effect.CurrentTechnique = effect.Techniques["TerrainSplat"];

            effect.Parameters["xWorld"].SetValue(World);
            effect.Parameters["xView"].SetValue(View);
            effect.Parameters["xProjection"].SetValue(Projection);

            effect.Parameters["xEnableLighting"].SetValue(true);
            effect.Parameters["xAmbient"].SetValue(0.8f);
            effect.Parameters["xLightDirection"].SetValue(lightDirection);
            effect.CommitChanges();

            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                Geom.Draw(gd);
                pass.End();
            }
            effect.End();
        }
Пример #2
0
        public override void Draw(GraphicsDevice device, ThreeDScene scene)
        {
            var camera = new Camera(new Vector3(0, -14.1759f, 10f), new Vector3(0, 0, 0), Vector3.Up);

            var gd = GameFacade.GraphicsDevice;

            gd.VertexDeclaration    = new VertexDeclaration(gd, TerrainVertex.VertexElements);
            effect.CurrentTechnique = effect.Techniques["TerrainSplat"];

            if (zoomedIn)
            {
                effect.Parameters["xTextureBlend"].SetValue(TextureBlend);
                effect.Parameters["xTextureTerrain"].SetValue(TextureTerrain);
            }
            else
            {
                effect.Parameters["xTextureGrass"].SetValue(TextureGrass);
                effect.Parameters["xTextureSnow"].SetValue(TextureSnow);
                effect.Parameters["xTextureSand"].SetValue(TextureSand);
                effect.Parameters["xTextureRock"].SetValue(TextureRock);
                effect.Parameters["xTextureWater"].SetValue(TextureWater);
            }
            //;
            //var worldMatrix = Matrix.Identity * Matrix.CreateTranslation(transX, 0, transY) * Matrix.CreateScale(zoom) * Matrix.CreateRotationX(MathHelper.ToRadians(degs));

            effect.Parameters["xWorld"].SetValue(World);
            effect.Parameters["xView"].SetValue(scene.Camera.View);
            effect.Parameters["xProjection"].SetValue(GameFacade.Scenes.ProjectionMatrix);

            effect.Parameters["xEnableLighting"].SetValue(true);
            effect.Parameters["xAmbient"].SetValue(0.8f);
            effect.Parameters["xLightDirection"].SetValue(lightDirection);
            effect.CommitChanges();


            //GraphicsDevice.BlendState = BlendState.Opaque;


            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();
                Geom.Draw(gd);
                pass.End();
            }
            effect.End();
        }