public void Draw(PointBatch pointBatch, Camera camera)
        {
            // Draw the starfield
            pointBatch.Begin(Matrix.Identity, camera);

            for (int s = 0; s < starCount; s++)
            {
                pointBatch.Draw(points[s], starRadius, new Color(brightnesses[s], brightnesses[s], brightnesses[s]));
            }

            pointBatch.End();
        }
        public void Draw(Ship ship, LineBatch lineBatch, PointBatch pointBatch, Camera camera)
        {
            // Draw the ship
            Matrix rotation = Matrix.CreateRotationZ(ship.Movement.Rotation);
            Matrix translation = Matrix.CreateTranslation(new Vector3(ship.Movement.Position.X, ship.Movement.Position.Y, 0.0f));

            lineBatch.Begin(rotation * translation, camera);

            for (int v = 0; v < vertices.Count; v++)
            {
                lineBatch.Draw(vertices[v], vertices[(v + 1) % vertices.Count], lineWidth, color);
            }

            lineBatch.End();

            pointBatch.Begin(translation, camera);
            pointBatch.Draw(Vector3.Zero, lightRadius, lightColor);
            pointBatch.End();
        }
 /// <summary>
 /// Initializes the world view
 /// </summary>
 /// <param name="graphicsDevice"></param>
 public void Initialize(GraphicsDevice graphicsDevice)
 {
     this.graphicsDevice = graphicsDevice;
     camera = new Camera(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);
     PresentationParameters parameters = graphicsDevice.PresentationParameters;
     renderTarget = new RenderTarget2D(graphicsDevice, parameters.BackBufferWidth, parameters.BackBufferHeight, false, parameters.BackBufferFormat, parameters.DepthStencilFormat, parameters.MultiSampleCount, RenderTargetUsage.DiscardContents);
 }
        // Prepares lines to be drawn
        public void Begin(Matrix world, Camera camera)
        {
            if (hasBegun)
                throw new InvalidOperationException("End must be called before Begin can be called again.");

            effect.World = world;
            effect.View = camera.View;
            effect.Projection = camera.Projection;

            // Begin the effect
            effect.CurrentTechnique.Passes[0].Apply();

            // It's now ok to call Draw and Flush
            hasBegun = true;
        }
Пример #5
0
        public void Draw(LineBatch lineBatch, Camera camera)
        {
            lineBatch.Begin(Matrix.Identity, camera);

            for (int i = 0; i < startPoints.Count; i++)
            {
                lineBatch.Draw(startPoints[i], endPoints[i], widths[i], colors[i]);
            }

            lineBatch.Draw(new Vector3(bounds.Min.X, bounds.Min.Y, bounds.Min.Z), new Vector3(bounds.Max.X, bounds.Min.Y, bounds.Max.Z), 5.0f, Color.White);
            lineBatch.Draw(new Vector3(bounds.Min.X, bounds.Max.Y, bounds.Min.Z), new Vector3(bounds.Max.X, bounds.Max.Y, bounds.Max.Z), 5.0f, Color.White);
            lineBatch.Draw(new Vector3(bounds.Min.X, bounds.Min.Y, bounds.Min.Z), new Vector3(bounds.Min.X, bounds.Max.Y, bounds.Max.Z), 5.0f, Color.White);
            lineBatch.Draw(new Vector3(bounds.Max.X, bounds.Min.Y, bounds.Min.Z), new Vector3(bounds.Max.X, bounds.Max.Y, bounds.Max.Z), 5.0f, Color.White);

            lineBatch.End();
        }