示例#1
0
        public override void Draw(Camera camera)
        {
            if (Alive)
            {
                // Draw the ship
                Matrix rotation = Matrix.CreateRotationZ(Rotation);
                Matrix translation = Matrix.CreateTranslation(Position);

                if (LineBatch == null || PointBatch == null)
                {
                    LineBatch = Scene.LineBatch;
                    PointBatch = Scene.PointBatch;
                }
                else
                {
                    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();
                }
            }
        }
示例#2
0
 public virtual void Draw(Camera camera)
 {
     lock (Children)
     {
         foreach (GameObject gameObject in Children)
         {
             gameObject.Draw(camera);
         }
     }
 }
示例#3
0
        public override void Draw(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();
        }
示例#4
0
        public override void Draw(Camera camera)
        {
            if (LineBatch == null || PointBatch == null)
            {
                LineBatch = Scene.LineBatch;
                PointBatch = Scene.PointBatch;
            }

            LineBatch.Begin(Matrix.Identity, camera);
            LineBatch.Draw(Position, Position - Velocity / Velocity.Length() * length, width, color);
            LineBatch.End();

            PointBatch.Begin(Matrix.Identity, camera);
            PointBatch.Draw(Position, radius, lightColor);
            PointBatch.End();
        }
示例#5
0
        // 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;
        }