Exemple #1
0
        private Project1Game gameaccess;                //Access to public game functions

        public Landscape(Project1Game game, int degree)
        {
            this.degree    = degree;
            this.size      = (int)Math.Pow(2, this.degree) + 1;
            this.maxheight = this.size / 2;
            this.polycount = (int)Math.Pow(this.size - 1, 2) * 2;
            this.rngesus   = new Random();
            this.coords    = new float[size, size];

            //Generate the heightmap using DiamondSquare
            Generate(0, this.size, 0, size, maxheight, size / 2);
            //Generate the terrain model
            this.terrain = TerrainModel(this.coords);
            //Place terrain model into vertex buffer
            vertices = Buffer.Vertex.New(game.GraphicsDevice, TerrainModel(this.coords));

            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                VertexColorEnabled = true,
                LightingEnabled    = true,
                View       = Matrix.LookAtLH(new Vector3(0, 0, -5), new Vector3(0, 0, 0), Vector3.UnitY),
                Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, 1000.0f),
                World      = Matrix.Identity
            };

            inputLayout     = VertexInputLayout.FromBuffer(0, vertices);
            this.gameaccess = game;
            this.game       = game;
        }
Exemple #2
0
        public ParticleSystem(GraphicsDevice device, ContentManager content)
        {
            this.device = device;

            // Create vertex buffer used to spawn new particles
            this.particleStart = Buffer.Vertex.New <ParticleVertex>(device, MAX_NEW);

            // Create vertex buffers to use for updating and drawing the particles alternatively
            var vbFlags = BufferFlags.VertexBuffer | BufferFlags.StreamOutput;

            this.particleDrawFrom = Buffer.New <ParticleVertex>(device, MAX_PARTICLES, vbFlags);
            this.particleStreamTo = Buffer.New <ParticleVertex>(device, MAX_PARTICLES, vbFlags);

            this.layout  = VertexInputLayout.FromBuffer(0, this.particleStreamTo);
            this.effect  = content.Load <Effect>("ParticleEffect");
            this.texture = content.Load <Texture2D>("Dot");

            this.viewParameter           = effect.Parameters["_view"];
            this.projParameter           = effect.Parameters["_proj"];
            this.lookAtMatrixParameter   = effect.Parameters["_lookAtMatrix"];
            this.elapsedSecondsParameter = effect.Parameters["_elapsedSeconds"];
            this.camDirParameter         = effect.Parameters["_camDir"];
            this.gravityParameter        = effect.Parameters["_gravity"];
            this.textureParameter        = effect.Parameters["_texture"];
            this.samplerParameter        = effect.Parameters["_sampler"];
            this.updatePass = effect.Techniques["UpdateTeq"].Passes[0];
            this.renderPass = effect.Techniques["RenderTeq"].Passes[0];
        }
 public override void SetGeometry(IGraphicsContext context)
 {
     context.Device.SetVertexBuffer(0, VertexBuffer);
     context.Device.SetVertexBuffer(1, InstanceData);
     context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, VertexBuffer));
     context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(1, InstanceData));
 }
Exemple #4
0
        protected override void LoadContent()
        {
            // Creates a basic effect
            basicEffect = ToDisposeContent(new BasicEffect(GraphicsDevice)
            {
                VertexColorEnabled = true,
                View       = Matrix.LookAtLH(new Vector3(0, 0, -5), new Vector3(0, 0, 0), Vector3.UnitY),
                Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f),
                World      = Matrix.Identity
            });

            // Creates vertices for the cube
            vertices = ToDisposeContent(Buffer.Vertex.New(
                                            GraphicsDevice,
                                            new[]
            {
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.Orange),         // Front
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.Orange),         // BACK
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.OrangeRed),         // Top
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.OrangeRed),         // Bottom
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.DarkOrange),         // Left
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.DarkOrange),         // Right
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.DarkOrange),
            }));
            ToDisposeContent(vertices);

            // Create an input layout from the vertices
            inputLayout = VertexInputLayout.FromBuffer(0, vertices);

            base.LoadContent();
        }
Exemple #5
0
        public Cube(LabGame game)
        {
            rand = new Random();
            Vector3 frontNormal  = new Vector3(0.0f, 0.0f, -1.0f);
            Vector3 backNormal   = new Vector3(0.0f, 0.0f, 1.0f);
            Vector3 topNormal    = new Vector3(0.0f, 1.0f, 0.0f);
            Vector3 bottomNormal = new Vector3(0.0f, -1.0f, 0.0f);
            Vector3 leftNormal   = new Vector3(-1.0f, 0.0f, 0.0f);
            Vector3 rightNormal  = new Vector3(1.0f, 0.0f, 0.0f);

            vertices = Buffer.Vertex.New(
                game.GraphicsDevice,
                new[]
            {
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, -1.0f), frontNormal, Color.Orange),     // Front
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, -1.0f), frontNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, -1.0f), frontNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, -1.0f), frontNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, -1.0f), frontNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, -1.0f), frontNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, 1.0f), backNormal, Color.Orange),     // BACK
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, 1.0f), backNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, 1.0f), backNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, 1.0f), backNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, 1.0f), backNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, 1.0f), backNormal, Color.Orange),
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, -1.0f), topNormal, Color.OrangeRed),     // Top
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, 1.0f), topNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, 1.0f), topNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, -1.0f), topNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, 1.0f), topNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, -1.0f), topNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, -1.0f), bottomNormal, Color.OrangeRed),     // Bottom
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, 1.0f), bottomNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, 1.0f), bottomNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, -1.0f), bottomNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, -1.0f), bottomNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, 1.0f), bottomNormal, Color.OrangeRed),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, -1.0f), leftNormal, Color.DarkOrange),     // Left
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, 1.0f), leftNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, 1.0f), leftNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(-1.0f, -1.0f, -1.0f), leftNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, 1.0f), leftNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(-1.0f, 1.0f, -1.0f), leftNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, -1.0f), rightNormal, Color.DarkOrange),     // Right
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, 1.0f), rightNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, 1.0f), rightNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(1.0f, -1.0f, -1.0f), rightNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, -1.0f), rightNormal, Color.DarkOrange),
                new VertexPositionNormalColor(new Vector3(1.0f, 1.0f, 1.0f), rightNormal, Color.DarkOrange),
            });

            effect = game.Content.Load <Effect>("myShader");

            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game   = game;
        }
Exemple #6
0
 public SkyBox(GameCore core)
 {
     this.core    = core;
     this.effect  = this.core.ContentManager.Load <Effect>("Effects/Sky");
     this.texture = this.core.ContentManager.Load <TextureCube>("Textures/World/skyBox");
     SetUpVertices();
     SetUpIndices();
     this.vertexInputLayout = VertexInputLayout.FromBuffer(0, this.vertexBuffer);
 }
Exemple #7
0
        public Cube(Lab4Game game)
        {
            vertices = Buffer.Vertex.New(
                game.GraphicsDevice,
                new[]
            {
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.Orange),         // Front
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.Orange),         // BACK
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.OrangeRed),         // Top
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.OrangeRed),         // Bottom
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.DarkOrange),         // Left
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.DarkOrange),         // Right
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.DarkOrange),
            });

            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                VertexColorEnabled = true,
                View       = Matrix.LookAtLH(new Vector3(0, 0, -10), new Vector3(0, 0, 0), Vector3.UnitY),
                Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f),
                World      = Matrix.Identity
            };

            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game   = game;
        }
        void LoadContent()
        {
            m_basicEffect = ToDispose(new BasicEffect(this.GraphicsDevice));

            m_basicEffect.VertexColorEnabled = true;
            m_basicEffect.LightingEnabled    = false;

            m_plane = ToDispose(GeometricPrimitive.Plane.New(this.GraphicsDevice, 2, 2, 1, true));

            m_buffer = ToDispose(Buffer <VertexPositionColor> .Vertex.New(this.GraphicsDevice, m_vertices));
            m_layout = VertexInputLayout.FromBuffer(0, m_buffer);
        }
Exemple #9
0
        public void RenderDirectionalLight(DirectionalLight light)
        {
            // set gbuffer targets as texture inputs
            this.SetAsShaderInput(gbufferEffect);

            // set light cbuffer parameters
            gbufferEffect.Parameters["dLightDirection"].SetValue(light.Direction);
            gbufferEffect.Parameters["dLightColor"].SetValue(light.Color);

            context.Device.SetVertexBuffer(lightVb);
            context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, lightVb));
            gbufferEffect.Techniques["DirectionalLight"].Passes[0].Apply();
            context.Device.Draw(PrimitiveType.TriangleList, 6);
        }
Exemple #10
0
        /// <summary>
        /// Generates the complete grass field.
        /// </summary>
        private void GenerateField(int numberOfPatchRows = 50, int numberOfRootsInPatch = 70)
        {
            this.NumberOfPatchRows    = numberOfPatchRows;
            this.NumberOfRootsInPatch = numberOfRootsInPatch;

            if (this.terrainSize > 1000)
            {
                this.NumberOfPatchRows = 160;
            }
            else if (this.terrainSize > 500)
            {
                this.NumberOfPatchRows = 190;
            }
            else
            {
                this.NumberOfPatchRows = 75;
            }

            this.NumberOfPatches = this.NumberOfPatchRows * this.NumberOfPatchRows;
            this.NumberOfRoots   = this.NumberOfPatches * this.NumberOfRootsInPatch;

            this.vertices = new VertexPositionNormalTexture[this.NumberOfRoots];

            Random rnd           = new Random();
            int    currentVertex = 0;

            Vector3 startPosition = new Vector3(0, 0, 0);
            Vector3 patchSize     = new Vector3(terrainSize / this.NumberOfPatchRows, 0, terrainSize / this.NumberOfPatchRows);

            // Generate grid of patches
            for (int x = 0; x < this.NumberOfPatchRows; x++)
            {
                for (int y = 0; y < this.NumberOfPatchRows; y++)
                {
                    Vector3 _centerPos = new Vector3(startPosition.X + patchSize.X / 2, heightData[(int)(startPosition.X + patchSize.X / 2), (int)(startPosition.Z + patchSize.Z / 2)], startPosition.Z + patchSize.Z / 2);
                    boundingDict[x * this.NumberOfPatchRows + y] = new BoundingSphere(_centerPos, BOUNDING_RADUIS);

                    currentVertex    = this.GeneratePatch(startPosition, patchSize, currentVertex, rnd);
                    startPosition.X += patchSize.X;
                }

                startPosition.X  = 0;
                startPosition.Z += patchSize.Z;
            }

            this.vertexBuffer      = Buffer.Vertex.New(this.core.GraphicsDevice, this.vertices);
            this.vertexInputLayout = VertexInputLayout.FromBuffer(0, this.vertexBuffer);

            this.InitializeWind();
        }
Exemple #11
0
        public Terrain(GameCore core)
        {
            this.core      = core;
            this.effect    = this.core.ContentManager.Load <Effect>("Effects/Terrain");
            this.texture   = this.core.ContentManager.Load <Texture2D>("Textures/Terrain/dirt");
            this.heightMap = this.core.ContentManager.Load <Texture2D>("Textures/Terrain/heightMap512");
            nIndices       = (this.heightMap.Width - 1) * (this.heightMap.Height - 1) * 6;

            LoadHeightData(this.heightMap);
            SetUpVertices();
            SetUpIndices();
            GenerateNormals();

            this.vertexInputLayout = VertexInputLayout.FromBuffer(0, this.vertexBuffer);
        }
Exemple #12
0
        public Mesh([NotNull] Buffer <T> vertexBuffer, [NotNull] Effect effect, bool disposeEffect = false)
        {
            if (vertexBuffer == null)
            {
                throw new ArgumentNullException("vertexBuffer");
            }
            if (effect == null)
            {
                throw new ArgumentNullException("effect");
            }

            VertexBuffer       = vertexBuffer;
            _vertexInputLayout = VertexInputLayout.FromBuffer(0, vertexBuffer);
            _effect            = effect;
            _disposeEffect     = disposeEffect;
        }
Exemple #13
0
        private EffectTechnique GetTechniqueFromVertexBuffer <T>(Buffer <T> vertexBuffer) where T : struct
        {
            EffectTechnique    technique    = null;
            VertexInputLayout  inputLayout  = VertexInputLayout.FromBuffer(0, vertexBuffer);
            VertexBufferLayout bufferLayout = inputLayout.BufferLayouts.First();

            bool pos = false, tex = false, col = false;
            var  semantics = bufferLayout.VertexElements.Select(ve => ve.SemanticName.ToString()).ToArray();

            if (semantics.Contains("POSITION"))
            {
                pos = true;
            }

            if (semantics.Contains("TEXCOORD"))
            {
                tex = true;
            }

            if (semantics.Contains("COLOR"))
            {
                col = true;
            }

            if (pos && tex)
            {
                technique = gbufferEffect.Techniques["PositionTexture"];
            }

            if (pos && col)
            {
                technique = gbufferEffect.Techniques["PositionColor"];
            }

            if (pos)
            {
                technique = gbufferEffect.Techniques["Position"];
            }

            if (technique == null)
            {
                throw new NotSupportedException();
            }

            return(technique);
        }
Exemple #14
0
        public Landscape2(Project2Game game)
        {
            MAX_HEIGHT = rnd.NextFloat(INIT_MIN_HEIGHT, INIT_MAX_HEIGHT);      //Randomize the height

            //initlize the world
            vpc      = InitializeGrid();
            vertices = Buffer.Vertex.New <VertexPositionNormalColor>(game.GraphicsDevice, vpc);

            effect = game.Content.Load <Effect>("LandscapeShader");

            effect.Parameters["World"].SetValue(Matrix.Identity);
            effect.Parameters["Projection"].SetValue(game.camera.Projection);
            effect.Parameters["worldInvTrp"].SetValue(Matrix.Transpose(Matrix.Invert(Matrix.Identity)));
            effect.Parameters["maxHeight"].SetValue(COLOUR_SCALE);

            inputLayout = VertexInputLayout.FromBuffer <VertexPositionNormalColor>(0, (Buffer <VertexPositionNormalColor>)vertices);
            this.game   = game;
        }
Exemple #15
0
        public void RenderGeometry <T>(PrimitiveType primitiveType, Buffer <T> vertexBuffer, int numVertices, string overrideTechnique = null) where T : struct
        {
            EffectTechnique technique = null;

            if (string.IsNullOrEmpty(overrideTechnique))
            {
                technique = GetTechniqueFromVertexBuffer(vertexBuffer);
            }
            else
            {
                technique = gbufferEffect.Techniques[overrideTechnique];
            }

            context.Device.SetVertexBuffer(vertexBuffer);
            context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vertexBuffer));
            technique.Passes[0].Apply();
            context.Device.Draw(primitiveType, numVertices);
        }
Exemple #16
0
        public Platform(ProjectGame game)
        {
            // Avoid null reference, it changes on the first update
            if (standing_platform == null)
            {
                standing_platform      = this;
                next_standing_platform = this;
            }

            // Less tiles if the difficulty is higher
            min_extra_tiles = (int)(max_extra_tiles - game.difficulty);
            type            = GameObjectType.Platform;

            //Load textures
            textureName = "Platform_Textures";
            texture     = game.Content.Load <Texture2D>(textureName);

            // Store information of the platform and create information for the next one
            platform      = next_platform;
            next_platform = create_platform(platform);

            // Create the vertices based on the platform information
            VertexPositionNormalTexture[] platform_vertices = create_vertices(platform, last_platform, next_platform);
            last_platform = platform;

            // Set the platform Z position of the intance and uptade the new Z position for the next one
            z_position_start = z_position;
            z_position      -= tile_depth;
            z_position_end   = z_position;

            // Calculates midpoint and base
            platfom_midpoint = (platform.GetLength(0) * tile_width) - tile_width / 2;
            platform_base    = Levels[0] - base_offset;

            //Load effects
            effect       = game.Content.Load <Effect>("Phong");
            lightManager = new LightManager(game);
            lightManager.SetLighting(effect);

            // Pass the vertices data
            vertices    = Buffer.Vertex.New(game.GraphicsDevice, platform_vertices);
            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game   = game;
        }
Exemple #17
0
        public void RenderGeometry <T>(PrimitiveType primitiveType, Buffer <T> vertexBuffer, Buffer <int> indexBuffer, Effect effect, int numIndices, int startIndex = 0, int baseVertex = 0, string overrideTechnique = null) where T : struct
        {
            EffectTechnique technique = null;

            if (string.IsNullOrEmpty(overrideTechnique))
            {
                technique = effect.Techniques.First();
            }
            else
            {
                technique = effect.Techniques[overrideTechnique];
            }

            Engine.GraphicsContext.Device.SetVertexBuffer(vertexBuffer);
            Engine.GraphicsContext.Device.SetIndexBuffer(indexBuffer, true);
            Engine.GraphicsContext.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vertexBuffer));
            technique.Passes[0].Apply();
            Engine.GraphicsContext.Device.DrawIndexed(primitiveType, numIndices, startIndex, baseVertex);
        }
Exemple #18
0
        public void Clear()
        {
            if (clearBlendState == null)
            {
                BlendStateDescription desc = new BlendStateDescription();
                desc.RenderTarget[0].IsBlendEnabled = false;
                desc.RenderTarget[1].IsBlendEnabled = false;
                desc.RenderTarget[2].IsBlendEnabled = false;

                clearBlendState = context.Device.BlendStates.Opaque; // SharpDX.Toolkit.Graphics.BlendState.New(context.Device, desc);
            }

            context.Device.SetVertexBuffer(vb);
            context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vb));
            context.Device.SetDepthStencilState(context.Device.DepthStencilStates.None);
            context.Device.SetBlendState(clearBlendState);
            context.Device.SetRasterizerState(context.Device.RasterizerStates.CullNone);
            gbufferEffect.Techniques["Clear"].Passes[0].Apply();
            context.Device.Draw(PrimitiveType.TriangleList, 6);
        }
Exemple #19
0
        public Landscape(LabGame game)
        {
            this.game = game;
            type      = GameObjectType.Landscape;

            List <VertexPositionNormalTexture> landscapeVertices = new List <VertexPositionNormalTexture>();

            landscapeVertices.Add(new VertexPositionNormalTexture(new Vector3(0.0f, LANDSCAPEHEIGHT, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), new Vector2(0.0f, 0.0f)));
            landscapeVertices.Add(new VertexPositionNormalTexture(new Vector3(0.0f, LANDSCAPEHEIGHT, LANDSCAPEWIDTH), new Vector3(0.0f, 1.0f, 0.0f), new Vector2(1.0f, 0.0f)));
            landscapeVertices.Add(new VertexPositionNormalTexture(new Vector3(LANDSCAPEWIDTH, LANDSCAPEHEIGHT, LANDSCAPEWIDTH), new Vector3(0.0f, 1.0f, 0.0f), new Vector2(1.0f, 1.0f)));

            landscapeVertices.Add(new VertexPositionNormalTexture(new Vector3(0.0f, LANDSCAPEHEIGHT, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), new Vector2(0.0f, 0.0f)));
            landscapeVertices.Add(new VertexPositionNormalTexture(new Vector3(LANDSCAPEWIDTH, LANDSCAPEHEIGHT, LANDSCAPEWIDTH), new Vector3(0.0f, 1.0f, 0.0f), new Vector2(1.0f, 1.0f)));
            landscapeVertices.Add(new VertexPositionNormalTexture(new Vector3(LANDSCAPEWIDTH, LANDSCAPEHEIGHT, 0.0f), new Vector3(0.0f, 1.0f, 0.0f), new Vector2(0.0f, 1.0f)));

            vertices = Buffer.Vertex.New(
                game.GraphicsDevice,
                landscapeVertices.ToArray());

            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
        }
Exemple #20
0
        /// <summary>
        /// Executes once on device creation.
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            // define vertices for single triangle
            var vertices = new[]
            {
                new VertexInputType(new Vector3(-1.0f, -1.0f, 0.0f), Color.Red),
                new VertexInputType(new Vector3(0.0f, 1.0f, 0.0f), Color.Green),
                new VertexInputType(new Vector3(1.0f, -1.0f, 0.0f), Color.Blue),
            };

            // create vertex buffer
            _vertexBuffer      = ToDisposeContent(Buffer.Vertex.New(GraphicsDevice, vertices));
            _vertexBuffer.Name = "triangle_vb";

            // create input layout
            _inputLayout = VertexInputLayout.FromBuffer(0, _vertexBuffer);

            // load effect file
            _effect      = ToDisposeContent(Content.Load <Effect>("ShaderGame1"));
            _effect.Name = "triangle_fx";
        }
Exemple #21
0
        public MeshCamera(Room room, float zoom, Vector2R?pos) : base(room, zoom, pos)
        {
            pendingVertices = new List <SpriteVertex>();
            //permVertices = new List<SpriteVertex>();
            //Perms = new HashSet<SpriteVertex>();
            pendingVertexQueue = new BlockingCollection <List <SpriteVertex> >(3);
            device             = OrbIt.Game.GraphicsDevice;
            Mesh   = Buffer.Vertex.New <SpriteVertex>(OrbIt.Game.GraphicsDevice, 16 * 1024);
            layout = VertexInputLayout.FromBuffer(0, Mesh);

            effect  = OrbIt.Game.Content.Load <Effect>("Effects/MixedShaders2");
            texture = OrbIt.Game.Content.Load <Texture2D>("Textures/spritesheet");

            mvpParam         = effect.Parameters["mvp"];
            spriteCountParam = effect.Parameters["SpriteCount"];
            textureParam     = effect.Parameters["ModelTexture"];

            textureSamplerParameter = effect.Parameters["_sampler"];
            effectPass = effect.Techniques["Render"].Passes[0];
            textureParam.SetResource(texture);

            textureSamplerParameter.SetResource(device.SamplerStates.LinearClamp);
            spriteCountParam.SetValue((float)Enum.GetValues(typeof(Textures)).Length);
        }
Exemple #22
0
        public void QueueRenderCommands(GameTime gameTime, Renderer renderer, IGraphicsContext context)
        {
            context.Device.SetVertexBuffer(vertexBuffer);
            context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vertexBuffer));
            context.Device.SetIndexBuffer(indexBuffer, true);

            context.Device.SetDepthStencilState(context.Device.DepthStencilStates.None);
            context.Device.SetBlendState(context.Device.BlendStates.Opaque);
            context.Device.SetRasterizerState(context.Device.RasterizerStates.CullNone);

            Matrix specialProj = Matrix.PerspectiveFovLH(MathUtil.PiOverFour, context.AspectRatio, 0.1f, 2f);

            skyboxEffect.Parameters["World"].SetValue(Matrix.Identity);
            skyboxEffect.Parameters["View"].SetValue(context.CurrentCamera.ViewD.ToMatrix());


            skyboxEffect.Parameters["ViewNoT"].SetValue(context.RenderContext.ViewNoTrans);
            skyboxEffect.Parameters["Proj"].SetValue(specialProj);
            skyboxEffect.Parameters["skyboxTex"].SetResource(skyboxTex);
            skyboxEffect.Parameters["skyboxSampler"].SetResource(context.Device.SamplerStates.LinearClamp);

            skyboxEffect.CurrentTechnique.Passes[0].Apply();
            context.Device.DrawIndexed(PrimitiveType.PatchList(3), indexBuffer.ElementCount);
        }
Exemple #23
0
        public void PreProcess()
        {
            order = 2;

            GraphicsDevice device = Engine.GraphicsContext.Device;

            device.SetRasterizerState(device.RasterizerStates.CullNone);
            device.SetBlendState(device.BlendStates.Default);
            device.SetDepthStencilState(device.DepthStencilStates.None);

            // compute transmittance texture T (line 1 in algorithm 4.1)
            device.SetRenderTargets(transmittanceT);
            device.SetViewport(new ViewportF(0, 0, TRANSMITTANCE_W, TRANSMITTANCE_H));
            device.DrawQuad(transmittance);

            // compute irradiance texture deltaE (line 2 in algorithm 4.1)
            device.SetRenderTargets(deltaET);
            device.SetViewport(new ViewportF(0, 0, SKY_W, SKY_H));
            irradiance1.Parameters["transTex"].SetResource(transmittanceT);
            device.DrawQuad(irradiance1);

            //// compute single scattering texture deltaS (line 3 in algorithm 4.1)
            //// Rayleigh and Mie separated in deltaSR + deltaSM
            device.SetRenderTargets(deltaSRT, deltaSMT);
            device.SetViewport(new ViewportF(0, 0, RES_MU_S * RES_NU, RES_MU));
            device.SetVertexBuffer(vb);
            device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vb));
            inscatter1.Parameters["_transTex"].SetResource(transmittanceT);
            inscatter1.Parameters["_transSamp"].SetResource(device.SamplerStates.LinearClamp);
            for (int layer = 0; layer < RES_R; layer++)
            {
                setLayer(inscatter1, layer);
                inscatter1.CurrentTechnique.Passes[0].Apply();
                device.Draw(PrimitiveType.TriangleList, 6);
            }

            // copy deltaE into irradiance texture E (line 4 in algorithm 4.1)
            // really this just clears irradianceT
            device.SetRenderTargets(irradianceT);
            device.SetViewport(new ViewportF(0, 0, SKY_W, SKY_H));
            copyIrradiance.Parameters["k"].SetValue(0f);
            copyIrradiance.Parameters["deltaE"].SetResource(deltaET);
            device.DrawQuad(copyIrradiance);

            for (; order < 3; order++)
            {
                // copy deltaS into inscatter texture S (line 5 in algorithm 4.1)
                device.SetRenderTargets(inscatterT);
                device.SetViewport(new ViewportF(0, 0, RES_MU_S * RES_NU, RES_MU));
                device.SetVertexBuffer(vb);
                device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vb));
                copyInscatter1.Parameters["deltaSR"].SetResource(deltaSRT);
                copyInscatter1.Parameters["deltaSM"].SetResource(deltaSMT);
                for (int layer = 0; layer < RES_R; layer++)
                {
                    setLayer(copyInscatter1, layer);
                    copyInscatter1.CurrentTechnique.Passes[0].Apply();
                    device.Draw(PrimitiveType.TriangleList, 6);
                }

                // compute deltaJ (line 7 in algorithm 4.1)
                device.SetRenderTargets(deltaJT);
                device.SetViewport(new ViewportF(0, 0, RES_MU_S * RES_NU, RES_MU));
                device.SetVertexBuffer(vb);
                device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vb));
                inscatterS.Parameters["first"].SetValue(order == 2 ? 1.0f : 0.0f);
                inscatterS.Parameters["trans"].SetResource(transmittanceT);
                inscatterS.Parameters["deltaE"].SetResource(deltaET);
                inscatterS.Parameters["deltaSR"].SetResource(deltaSRT);
                inscatterS.Parameters["deltaSM"].SetResource(deltaSMT);
                for (int layer = 0; layer < RES_R; layer++)
                {
                    setLayer(inscatterS, layer);
                    inscatterS.CurrentTechnique.Passes[0].Apply();
                    device.Draw(PrimitiveType.TriangleList, 6);
                }

                // compute deltaE (line 8 in algorithm 4.1)
                device.SetRenderTargets(deltaET);
                device.SetViewport(new ViewportF(0, 0, SKY_W, SKY_H));
                irradianceN.Parameters["first"].SetValue(order == 2 ? 1.0f : 0.0f);
                irradianceN.Parameters["deltaSR"].SetResource(deltaSRT);
                irradianceN.Parameters["deltaSM"].SetResource(deltaSMT);
                device.DrawQuad(irradianceN);

                // compute deltaS (line 9 in algorithm 4.1)
                device.SetRenderTargets(deltaSRT);
                device.SetViewport(new ViewportF(0, 0, RES_MU_S * RES_NU, RES_MU));
                device.SetVertexBuffer(vb);
                device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vb));
                inscatterN.Parameters["trans"].SetResource(transmittanceT);
                inscatterN.Parameters["deltaJ"].SetResource(deltaJT);
                for (int layer = 0; layer < RES_R; layer++)
                {
                    setLayer(inscatterN, layer);
                    inscatterN.CurrentTechnique.Passes[0].Apply();
                    device.Draw(PrimitiveType.TriangleList, 6);
                }

                device.SetBlendState(BlendState.New(device,
                                                    SharpDX.Direct3D11.BlendOption.One,
                                                    SharpDX.Direct3D11.BlendOption.One,
                                                    SharpDX.Direct3D11.BlendOperation.Add,
                                                    SharpDX.Direct3D11.BlendOption.One,
                                                    SharpDX.Direct3D11.BlendOption.One,
                                                    SharpDX.Direct3D11.BlendOperation.Add));

                // add deltaE into irradiance texture E (line 10 in algorithm 4.1)
                device.SetRenderTargets(irradianceT);
                device.SetViewport(new ViewportF(0, 0, SKY_W, SKY_H));
                copyIrradiance.Parameters["k"].SetValue(1.0f);
                copyIrradiance.Parameters["deltaE"].SetResource(deltaET);
                device.DrawQuad(copyIrradiance);

                // add deltaS into inscatter texture S (line 11 in algorithm 4.1)
                device.SetRenderTargets(inscatterT);
                device.SetViewport(new ViewportF(0, 0, RES_MU_S * RES_NU, RES_MU));
                device.SetVertexBuffer(vb);
                device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, vb));
                copyInscatterN.Parameters["deltaS"].SetResource(deltaSRT);
                for (int layer = 0; layer < RES_R; layer++)
                {
                    setLayer(copyInscatterN, layer);
                    copyInscatterN.CurrentTechnique.Passes[0].Apply();
                    device.Draw(PrimitiveType.TriangleList, 6);
                }

                device.SetBlendState(device.BlendStates.Opaque);
            } // end multiple scattering loop

            LightQuadVertex[] lightVerts = new LightQuadVertex[6]
            {
                new LightQuadVertex(-1, -1, 0, 0, 1, 3),
                new LightQuadVertex(-1, 1, 0, 0, 0, 2),
                new LightQuadVertex(1, 1, 0, 1, 0, 1),

                new LightQuadVertex(1, 1, 0, 1, 0, 1),
                new LightQuadVertex(1, -1, 0, 1, 1, 0),
                new LightQuadVertex(-1, -1, 0, 0, 1, 3)
            };

            atmosVb = SharpDX.Toolkit.Graphics.Buffer.New <LightQuadVertex>(device, lightVerts, BufferFlags.VertexBuffer);
        }
Exemple #24
0
        public Sun(Game game, Landscape landscape)
        {
            this.landscape = landscape;
            this.terrain   = landscape.Terrain;
            float sunsize = terrain.max / 4;

            numberUpdates          = 80f;
            frontBottomLeftNormal  = new Vector3(-0.333f, -0.333f, -0.333f);
            frontTopLeftNormal     = new Vector3(-0.333f, 0.333f, -0.333f);
            frontTopRightNormal    = new Vector3(0.333f, 0.333f, -0.333f);
            frontBottomRightNormal = new Vector3(0.333f, -0.333f, -0.333f);
            backBottomLeftNormal   = new Vector3(-0.333f, -0.333f, 0.333f);
            backBottomRightNormal  = new Vector3(0.333f, -0.333f, 0.333f);
            backTopLeftNormal      = new Vector3(-0.333f, 0.333f, 0.333f);
            backTopRightNormal     = new Vector3(0.333f, 0.333f, 0.333f);

            float sunX, sunY, sunZ, sunOffset;

            sunX             = terrain.size; sunY = terrain.maxHeight + 10f; sunZ = terrain.size / 2; sunOffset = 40f;
            frontBottomLeft  = new Vector3(sunX - sunOffset, sunY - sunOffset, sunZ - sunOffset);
            frontTopLeft     = new Vector3(sunX - sunOffset, sunY + sunOffset, sunZ - sunOffset);
            frontTopRight    = new Vector3(sunX + sunOffset, sunY + sunOffset, sunZ - sunOffset);
            frontBottomRight = new Vector3(sunX + sunOffset, sunY - sunOffset, sunZ - sunOffset);
            backBottomLeft   = new Vector3(sunX - sunOffset, sunY - sunOffset, sunZ + sunOffset);
            backBottomRight  = new Vector3(sunX + sunOffset, sunY - sunOffset, sunZ + sunOffset);
            backTopLeft      = new Vector3(sunX - sunOffset, sunY + sunOffset, sunZ + sunOffset);
            backTopRight     = new Vector3(sunX + sunOffset, sunY + sunOffset, sunZ + sunOffset);



            vertices = Buffer.Vertex.New(
                game.GraphicsDevice,
                new[]
            {
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, Color.Yellow),     // Front
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, Color.Yellow),
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, Color.Yellow),     // BACK
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, Color.Yellow),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, Color.Yellow),     // Top
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, Color.Yellow),     // Bottom
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, Color.Yellow),
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, Color.Yellow),
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, Color.Yellow),     // Left
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, Color.Yellow),     // Right
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, Color.Yellow),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, Color.Yellow),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, Color.Yellow),
            });


            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                VertexColorEnabled = true,
                View       = Matrix.LookAtLH(landscape.currentPosition, landscape.currentTarget, landscape.currentUp),
                Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, -10.0f, (float)terrain.size * 2),
                World      = Matrix.Identity,
            };



            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
            this.game   = game;
        }
Exemple #25
0
        protected override void OnDraw()
        {
            // To make sure things are in a defined state for legacy rendering...
            ((TombLib.Rendering.DirectX11.Dx11RenderingSwapChain)SwapChain).BindForce();
            ((TombLib.Rendering.DirectX11.Dx11RenderingDevice)Device).ResetState();

            _device.SetDepthStencilState(_device.DepthStencilStates.Default);
            _device.SetRasterizerState(_device.RasterizerStates.CullBack);
            _device.SetBlendState(_device.BlendStates.Opaque);

            Matrix4x4 viewProjection = Camera.GetViewProjectionMatrix(ClientSize.Width, ClientSize.Height);

            /*if (Level != null && Room != null)
             * {
             *  Effect roomsEffect = _deviceManager.Effects["Room"];
             *
             *  roomsEffect.Parameters["TextureEnabled"].SetValue(true);
             *  roomsEffect.Parameters["DrawSectorOutlinesAndUseEditorUV"].SetValue(false);
             *  roomsEffect.Parameters["Highlight"].SetValue(false);
             *  roomsEffect.Parameters["Dim"].SetValue(false);
             *  roomsEffect.Parameters["Color"].SetValue(new Vector4(1.0f, 1.0f, 1.0f, 1.0f));
             *  roomsEffect.Parameters["Texture"].SetResource(_textureAtlas);
             *  roomsEffect.Parameters["TextureSampler"].SetResource(_device.SamplerStates.AnisotropicWrap);
             *  roomsEffect.Parameters["UseVertexColors"].SetValue(true);
             *  roomsEffect.Parameters["TextureAtlasRemappingSize"].SetValue(_textureAtlasRemappingSize);
             *  roomsEffect.Parameters["TextureCoordinateFactor"].SetValue(_textureAtlas == null ? new Vector2(0) : new Vector2(1.0f / _textureAtlas.Width, 1.0f / _textureAtlas.Height));
             *
             *  _device.SetVertexBuffer(0, Room.VertexBuffer);
             *  _device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, Room.VertexBuffer));
             *
             *  var world = Matrix4x4.CreateTranslation(new Vector3(-RoomPosition.X, 0, -RoomPosition.Z));
             *
             *  roomsEffect.Parameters["ModelViewProjection"].SetValue((world * viewProjection).ToSharpDX());
             *
             *  roomsEffect.Techniques[0].Passes[0].Apply();
             *  _device.Draw(PrimitiveType.TriangleList, Room.VertexBuffer.ElementCount);
             *
             * }*/

            Effect solidEffect = _deviceManager.___LegacyEffects["Solid"];

            if (_model != null)
            {
                var skin   = (_skinModel != null ? _skinModel : _model);
                var effect = _deviceManager.___LegacyEffects["Model"];

                effect.Parameters["Texture"].SetResource(_wadRenderer.Texture);
                effect.Parameters["TextureSampler"].SetResource(_device.SamplerStates.Default);

                // Build animation transforms
                var matrices = new List <Matrix4x4>();
                if (_editor.ValidAnimationAndFrames)
                {
                    for (var b = 0; b < _model.Meshes.Count; b++)
                    {
                        matrices.Add(_model.AnimationTransforms[b]);
                    }
                }
                else
                {
                    foreach (var bone in _model.Bones)
                    {
                        matrices.Add(bone.GlobalTransform);
                    }
                }

                for (int i = 0; i < skin.Meshes.Count; i++)
                {
                    var mesh = skin.Meshes[i];
                    if (mesh.Vertices.Count == 0)
                    {
                        continue;
                    }

                    _device.SetVertexBuffer(0, mesh.VertexBuffer);
                    _device.SetIndexBuffer(mesh.IndexBuffer, true);
                    _device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, mesh.VertexBuffer));

                    if (SelectedMesh == _model.Meshes[i] && _editor.ValidAnimationAndFrames)
                    {
                        effect.Parameters["Color"].SetValue(new Vector4(1.0f, 0.0f, 0.0f, 1.0f));
                    }
                    else
                    {
                        effect.Parameters["Color"].SetValue(Vector4.One);
                    }

                    effect.Parameters["ModelViewProjection"].SetValue((matrices[i] * viewProjection).ToSharpDX());

                    effect.Techniques[0].Passes[0].Apply();

                    foreach (var submesh in mesh.Submeshes)
                    {
                        _device.Draw(PrimitiveType.TriangleList, submesh.Value.NumIndices, submesh.Value.BaseIndex);
                    }

                    //foreach (var submesh in mesh.Submeshes)
                    //   _device.DrawIndexed(PrimitiveType.TriangleList, submesh.Value.NumIndices, submesh.Value.MeshBaseIndex);
                }

                if (_editor.ValidAnimationAndFrames)
                {
                    _device.SetRasterizerState(_rasterizerWireframe);

                    // Draw selection box
                    if (SelectedMesh != null)
                    {
                        if (_vertexBufferVisibility != null)
                        {
                            _vertexBufferVisibility.Dispose();
                        }
                        int meshIndex = _model.Meshes.IndexOf(SelectedMesh);
                        _vertexBufferVisibility = GetVertexBufferFromBoundingBox(Skin.Meshes[meshIndex].BoundingBox);

                        _device.SetVertexBuffer(_vertexBufferVisibility);
                        _device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, _vertexBufferVisibility));
                        _device.SetIndexBuffer(null, false);

                        solidEffect.Parameters["ModelViewProjection"].SetValue((_model.AnimationTransforms[meshIndex] * viewProjection).ToSharpDX());
                        solidEffect.Parameters["Color"].SetValue(new Vector4(0.0f, 1.0f, 0.0f, 1.0f));
                        solidEffect.CurrentTechnique.Passes[0].Apply();

                        _device.Draw(PrimitiveType.LineList, _vertexBufferVisibility.ElementCount);
                    }

                    // Draw collision box
                    if (Configuration.AnimationEditor_ShowCollisionBox)
                    {
                        if (_vertexBufferVisibility != null)
                        {
                            _vertexBufferVisibility.Dispose();
                        }
                        _vertexBufferVisibility = GetVertexBufferFromBoundingBox(_editor.CurrentKeyFrame.BoundingBox);

                        _device.SetVertexBuffer(_vertexBufferVisibility);
                        _device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, _vertexBufferVisibility));
                        _device.SetIndexBuffer(null, false);

                        solidEffect.Parameters["ModelViewProjection"].SetValue((viewProjection).ToSharpDX());
                        solidEffect.Parameters["Color"].SetValue(new Vector4(0.0f, 0.0f, 1.0f, 1.0f));
                        solidEffect.CurrentTechnique.Passes[0].Apply();

                        _device.Draw(PrimitiveType.LineList, _vertexBufferVisibility.ElementCount);
                    }
                }
            }

            if (Configuration.AnimationEditor_ShowGrid)
            {
                // Draw the grid
                _device.SetVertexBuffer(0, _plane.VertexBuffer);
                _device.SetVertexInputLayout(VertexInputLayout.FromBuffer(0, _plane.VertexBuffer));
                _device.SetIndexBuffer(_plane.IndexBuffer, true);
                _device.SetRasterizerState(_rasterizerWireframe);

                var shift = Matrix4x4.CreateTranslation(new Vector3(-GridPosition.X, GridPosition.Y, -GridPosition.Z));
                solidEffect.Parameters["ModelViewProjection"].SetValue((shift * viewProjection).ToSharpDX());
                solidEffect.Parameters["Color"].SetValue(Vector4.One);
                solidEffect.Techniques[0].Passes[0].Apply();

                _device.Draw(PrimitiveType.LineList, _plane.VertexBuffer.ElementCount);
            }

            if (Configuration.AnimationEditor_ShowGizmo &&
                SelectedMesh != null && _editor.ValidAnimationAndFrames)
            {
                // Draw the gizmo
                SwapChain.ClearDepth();
                _gizmo.Draw(viewProjection);
            }

            if (_editor.CurrentAnim != null &&
                Configuration.RenderingItem_ShowDebugInfo)
            {
                ((TombLib.Rendering.DirectX11.Dx11RenderingDevice)Device).ResetState(); // To make sure SharpDx.Toolkit didn't change settings.
                string debugMessage = "Frame: " + (_editor.CurrentFrameIndex + 1) + "/" + _editor.CurrentAnim.DirectXAnimation.KeyFrames.Count;
                if (SelectedMesh != null)
                {
                    debugMessage += "\nMesh: " + SelectedMesh.Name;
                    debugMessage += "\nBone: " + _model.Bones[_model.Meshes.IndexOf(SelectedMesh)].Name;
                    debugMessage += "\nRotation: " + _editor.CurrentKeyFrame.Rotations[Model.Meshes.IndexOf(SelectedMesh)];
                }
                SwapChain.RenderText(new Text
                {
                    Font      = _fontDefault,
                    PixelPos  = new Vector2(10, 25),
                    Alignment = new Vector2(0, 0),
                    String    = debugMessage
                });
            }
        }
Exemple #26
0
 public virtual void SetGeometry(IGraphicsContext context)
 {
     context.Device.SetVertexInputLayout(VertexInputLayout.FromBuffer <T>(0, VertexBuffer));
     context.Device.SetVertexBuffer(0, VertexBuffer);
 }
Exemple #27
0
 public SharedData(GraphicsDevice device)
 {
     VertexBuffer      = ToDispose(Buffer.Vertex.New(device, QuadsVertices));
     VertexInputLayout = VertexInputLayout.FromBuffer(0, VertexBuffer);
 }
Exemple #28
0
        public Landscape(Project1Game game)
        {
            this.game = game;
            // Create the height map and vertex norms
            heightMap   = createRandomMap();
            vertexNorms = calcNorms();

            // Set the array to hold all the vertices
            VertexPositionNormalColor[] pointList = new VertexPositionNormalColor[6 * (LENGTH - 1) * (LENGTH - 1) + 6];
            int counter = 0;

            for (int x = 0; x < LENGTH - 1; x++)
            {
                for (int y = 1; y < LENGTH; y++)
                {
                    // Taking a point (x,y) from the height map it draws the square with the corners (x,y) (x+1,y) (x+1,y+1) and (x+1,y)
                    Vector3 pointA = new Vector3(x, heightMap[x, y - 1], y - 1);
                    pointList[counter] = new VertexPositionNormalColor(pointA, vertexNorms[x, y - 1], chooseColor(heightMap[x, y - 1]));
                    counter++;
                    Vector3 pointB = new Vector3(x, heightMap[x, y], y);
                    pointList[counter] = new VertexPositionNormalColor(pointB, vertexNorms[x, y], chooseColor(heightMap[x, y]));
                    counter++;
                    Vector3 pointC = new Vector3(x + 1, heightMap[x + 1, y], y);
                    pointList[counter] = new VertexPositionNormalColor(pointC, vertexNorms[x + 1, y], chooseColor(heightMap[x + 1, y]));
                    counter++;
                    Vector3 pointD = new Vector3(x, heightMap[x, y - 1], y - 1);
                    pointList[counter] = new VertexPositionNormalColor(pointD, vertexNorms[x, y - 1], chooseColor(heightMap[x, y - 1]));
                    counter++;
                    Vector3 pointE = new Vector3(x + 1, heightMap[x + 1, y], y);
                    pointList[counter] = new VertexPositionNormalColor(pointE, vertexNorms[x + 1, y], chooseColor(heightMap[x + 1, y]));
                    counter++;
                    Vector3 pointF = new Vector3(x + 1, heightMap[x + 1, y - 1], y - 1);
                    pointList[counter] = new VertexPositionNormalColor(pointF, vertexNorms[x + 1, y - 1], chooseColor(heightMap[x + 1, y - 1]));
                    counter++;
                }
            }

            // Adds a plane of water which we will make sea level eg. y=0
            Color   water   = new Color(new Vector3(0, 0, 50), TRANSPARENCY);
            Vector3 wpointA = new Vector3(-0.1f, -0.1f, -0.1f);

            pointList[counter] = new VertexPositionNormalColor(wpointA, Vector3.Down, water);
            counter++;
            Vector3 wpointB = new Vector3(-0.1f, -0.1f, LENGTH - 0.9f);

            pointList[counter] = new VertexPositionNormalColor(wpointB, Vector3.Down, water);
            counter++;
            Vector3 wpointC = new Vector3(LENGTH - 0.9f, -0.1f, LENGTH - 0.9f);

            pointList[counter] = new VertexPositionNormalColor(wpointC, Vector3.Down, water);
            counter++;
            Vector3 wpointD = new Vector3(-0.1f, -0.1f, -0.1f);

            pointList[counter] = new VertexPositionNormalColor(wpointD, Vector3.Down, water);
            counter++;
            Vector3 wpointE = new Vector3(LENGTH - 0.9f, -0.1f, LENGTH - 0.9f);

            pointList[counter] = new VertexPositionNormalColor(wpointE, Vector3.Down, water);
            counter++;
            Vector3 wpointF = new Vector3(LENGTH - 0.9f, -0.1f, -0.1f);

            pointList[counter] = new VertexPositionNormalColor(wpointF, Vector3.Down, water);
            counter++;

            // Add the vertices to the landscape
            vertices = Buffer.Vertex.New(game.GraphicsDevice, pointList);

            // Set the lighting of the landscape
            basicEffect = new BasicEffect(game.GraphicsDevice)
            {
                View               = game.camera.View,
                Projection         = game.camera.Projection,
                VertexColorEnabled = true,
                World              = Matrix.Identity,
                LightingEnabled    = true,
                AmbientLightColor  = new Vector3(0.1f, 0.1f, 0.1f),
            };
            basicEffect.DirectionalLight0.Enabled       = true;
            basicEffect.DirectionalLight0.Direction     = Vector3.Right;
            basicEffect.DirectionalLight0.DiffuseColor  = new Vector3(0.1f, 0.1f, 0.1f);
            basicEffect.DirectionalLight0.SpecularColor = new Vector3(1.0f, 1.0f, 1.0f);

            inputLayout = VertexInputLayout.FromBuffer(0, vertices);
        }
Exemple #29
0
        public Portal(LabGame game)
        {
            this.game    = game;
            type         = GameObjectType.Portal;
            this.pos     = new Vector3(r.Next(0, (int)game.landscape.getWidth()), 10, r.Next(0, (int)game.landscape.getWidth()));
            this.cubeCol = randomColor();

            float   size             = 2;
            Vector3 frontBottomLeft  = new Vector3(-size, -size, -size);
            Vector3 frontTopLeft     = new Vector3(-size, size, -size);
            Vector3 frontTopRight    = new Vector3(size, size, -size);
            Vector3 frontBottomRight = new Vector3(size, -size, -size);
            Vector3 backBottomLeft   = new Vector3(-size, -size, size);
            Vector3 backBottomRight  = new Vector3(size, -size, size);
            Vector3 backTopLeft      = new Vector3(-size, size, size);
            Vector3 backTopRight     = new Vector3(size, size, size);

            Vector3 frontNormal  = new Vector3(0.0f, 0.0f, -1.0f);
            Vector3 backNormal   = new Vector3(0.0f, 0.0f, 1.0f);
            Vector3 topNormal    = new Vector3(0.0f, 1.0f, 0.0f);
            Vector3 bottomNormal = new Vector3(0.0f, -1.0f, 0.0f);
            Vector3 leftNormal   = new Vector3(-1.0f, 0.0f, 0.0f);
            Vector3 rightNormal  = new Vector3(1.0f, 0.0f, 0.0f);

            Vector3 frontBottomLeftNormal  = new Vector3(-0.333f, -0.333f, -0.333f);
            Vector3 frontTopLeftNormal     = new Vector3(-0.333f, 0.333f, -0.333f);
            Vector3 frontTopRightNormal    = new Vector3(0.333f, 0.333f, -0.333f);
            Vector3 frontBottomRightNormal = new Vector3(0.333f, -0.333f, -0.333f);
            Vector3 backBottomLeftNormal   = new Vector3(-0.333f, -0.333f, 0.333f);
            Vector3 backBottomRightNormal  = new Vector3(0.333f, -0.333f, 0.333f);
            Vector3 backTopLeftNormal      = new Vector3(-0.333f, 0.333f, 0.333f);
            Vector3 backTopRightNormal     = new Vector3(0.333f, 0.333f, 0.333f);

            Color portalColor = Color.White;

            vertices = Buffer.Vertex.New(
                game.GraphicsDevice,
                new[]
            {
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, portalColor),     // Front
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, portalColor),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, portalColor),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, portalColor),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, portalColor),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, portalColor),
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, portalColor),     // BACK
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, portalColor),
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, portalColor),
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, portalColor),
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, portalColor),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, portalColor),
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, portalColor),     // Top
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, portalColor),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, portalColor),
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, portalColor),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, portalColor),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, portalColor),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, portalColor),     // Bottom
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, portalColor),
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, portalColor),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, portalColor),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, portalColor),
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, portalColor),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, portalColor),     // Left
                new VertexPositionNormalColor(backBottomLeft, backBottomLeftNormal, portalColor),
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, portalColor),
                new VertexPositionNormalColor(frontBottomLeft, frontBottomLeftNormal, portalColor),
                new VertexPositionNormalColor(backTopLeft, backTopLeftNormal, portalColor),
                new VertexPositionNormalColor(frontTopLeft, frontTopLeftNormal, portalColor),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, portalColor),     // Right
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, portalColor),
                new VertexPositionNormalColor(backBottomRight, backBottomRightNormal, portalColor),
                new VertexPositionNormalColor(frontBottomRight, frontBottomRightNormal, portalColor),
                new VertexPositionNormalColor(frontTopRight, frontTopRightNormal, portalColor),
                new VertexPositionNormalColor(backTopRight, backTopRightNormal, portalColor),
            });

            //basicEffect = new BasicEffect(game.GraphicsDevice)
            //{
            //    VertexColorEnabled = true,
            //    View = Matrix.LookAtLH(game.camera.cameraPos, game.camera.cameraTarget, Vector3.UnitY),
            //    Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f, (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, 1000.0f),
            //    World = Matrix.Identity

            //};

            inputLayout = VertexInputLayout.FromBuffer(0, vertices);

            hitSoundEffect = new SoundEffect(@"Content\eat.wav", false);
        }
        protected override void LoadContent()
        {
            _basicEffect = ToDisposeContent(new BasicEffect(GraphicsDevice)
            {
                VertexColorEnabled = true,
                View       = Matrix.LookAtRH(new Vector3(0, 0, 5), new Vector3(0, 0, 0), Vector3.UnitY),
                Projection = Matrix.PerspectiveFovRH(MathUtil.PiOverFour, (float)GraphicsDevice.BackBuffer.Width / GraphicsDevice.BackBuffer.Height, 0.1f, 100.0f),
                World      = Matrix.Identity
            });

            _vertices = ToDisposeContent(SharpDX.Toolkit.Graphics.Buffer.Vertex.New(
                                             GraphicsDevice,
                                             new[]
            {
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.Orange),         // Back
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.Orange),

                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.Orange),         // Front
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.Orange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.Orange),

                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.OrangeRed),         // Top
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.OrangeRed),

                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.OrangeRed),         // Bottom
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.OrangeRed),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.OrangeRed),

                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.DarkOrange),         // Left
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, -1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(-1.0f, 1.0f, 1.0f), Color.DarkOrange),

                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.DarkOrange),         // Right
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, -1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, -1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, 1.0f), Color.DarkOrange),
                new VertexPositionColor(new Vector3(1.0f, 1.0f, -1.0f), Color.DarkOrange),
            }));
            ToDisposeContent(_vertices);

            _font        = Content.Load <SpriteFont>("Font");
            _spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice));

            _inputLayout = VertexInputLayout.FromBuffer(0, _vertices);

            SetScaling(1f);

            base.LoadContent();
        }