/// <summary> /// Draw the lines from the "camera"'s persepective. /// </summary> /// <param name="camera">The camera to use when drawing.</param> public void DrawColorLines(Camera camera) { this.basicEffects.World = camera.World; this.basicEffects.View = camera.View; this.basicEffects.Projection = camera.Projection; this.basicEffects.TextureEnabled = false; this.basicEffects.VertexColorEnabled = true; foreach (EffectPass pass in this.basicEffects.CurrentTechnique.Passes) { pass.Apply(); this.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, this.whiteLinesVertexPositionColor, 0, 36); // Draw the 1st inner line this.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, this.whiteLinesVertexPositionColor, 37, 36); // Draw the 2nd inner line this.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, this.whiteLinesVertexPositionColor, 37 * 2, 36); // Draw the outerline this.GraphicsDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineStrip, this.whiteLinesVertexPositionColor, 37 * 3, 36); // Draw the 2nd outerline } }
/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { // Create a new SpriteBatch, which can be used to draw 2D textures. this.spriteBatch = new SpriteBatch(Game.GraphicsDevice); this.houghInfo = this.imageAnalysis.GetHoughInfo(); this.arial = Game.Content.Load<SpriteFont>("Arial"); // Load the font // Camera needed for the analysis picture int xposition = this.screenHeight * 50 / 100; int yposition = this.screenWidth * 50 / 100; this.camera = new Camera(Game, new Vector3(yposition, xposition, -590), new Vector3(yposition, xposition, 0), -Vector3.UnitY, true); // Unit x for updirection this.Game.Components.Add(this.camera); this.vertexIndex = new int[this.screenHeight * this.screenWidth * 2]; this.LoadVertexArray(); // Loads the vertexs needed to draw the analysis triangles this.vertexArray2 = new VertexPositionColor[65535]; // The vertex array for the analysis triangles , the largest this could be is 65535 = 16 bit for (int i = 0; i < 65535; i++) { this.vertexArray2[i] = new VertexPositionColor(Vector3.UnitX, Color.Blue); } base.Initialize(); }
/// <summary> /// Draw the grass or ground from "camera"'s perspective /// </summary> /// <param name="camera">The camera to use when drawing.</param> public void DrawGrass(Camera camera) { this.basicEffects.World = camera.World; this.basicEffects.View = camera.View; this.basicEffects.Projection = camera.Projection; this.basicEffects.VertexColorEnabled = false; this.basicEffects.Texture = this.largeGrass; this.basicEffects.TextureEnabled = true; // Because the ground is a texture object. foreach (EffectPass pass in this.basicEffects.CurrentTechnique.Passes) { pass.Apply(); GraphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleStrip, this.grassAndGroundVertexPositionColor, 0, 2); } }