Пример #1
0
        public void DrawElipse(
            HSBColor idColor, Vector3 position, float radiusW, float radiusH)
        {
            // TODO: Batch/cache.
            var rgba = idColor.ToColor();
            var temp = (VertexPositionColorTexture[])unitSquare.Clone();

            for (int i = 0; i < temp.Length; i++)
            {
                temp[i].Color = rgba;
            }

            Matrix world =
                Matrix.CreateScale(radiusW * 2, radiusH * 2, 1) *
                Matrix.CreateTranslation(position);

            this.worldMatrix.SetValue(world);
            this.shapesEffect.CurrentTechnique = this.circleTechnique;
            foreach (EffectPass pass in this.shapesEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                this.device.DrawUserPrimitives(
                    PrimitiveType.TriangleList, temp, 0, 2);
            }
        }
Пример #2
0
        public void DrawSquare(
            HSBColor idColor,
            Matrix world,
            Vector3 pt0,
            Vector3 pt1,
            Vector3 pt2,
            Vector3 pt3)
        {
            var rgba = idColor.ToColor();
            var temp = (VertexPositionColorTexture[])unitSquare.Clone();

            temp[0].Position = pt0;
            temp[0].Color    = rgba;
            temp[1].Position = pt1;
            temp[1].Color    = rgba;
            temp[2].Position = pt2;
            temp[2].Color    = rgba;

            temp[3].Position = pt0;
            temp[3].Color    = rgba;
            temp[4].Position = pt2;
            temp[4].Color    = rgba;
            temp[5].Position = pt3;
            temp[5].Color    = rgba;

            this.worldMatrix.SetValue(world);
            this.shapesEffect.CurrentTechnique = this.squareTechnique;
            foreach (EffectPass pass in this.shapesEffect.CurrentTechnique.Passes)
            {
                pass.Apply();
                this.device.DrawUserPrimitives(
                    PrimitiveType.TriangleList, temp, 0, 2);
            }
        }
Пример #3
0
        protected override void Draw(GameTime gameTime)
        {
            var background = new HSBColor(0.55f, 0.1f, 1f, 1);

            GraphicsDevice.Clear(background.ToColor());
            GraphicsDevice.RasterizerState = RasterizerState.CullNone;
            GraphicsDevice.BlendState      = BlendState.AlphaBlend;

            Matrix view = Matrix.CreateLookAt(
                new Vector3(0, 0, -10),
                new Vector3(0, 0, 0),
                Vector3.UnitY
                ) * Matrix.CreateScale(0.75f) *
                          Matrix.CreateTranslation(0, 0, 0);
            Matrix projection = Matrix.CreateOrthographic(
                GraphicsDevice.Viewport.Width,
                GraphicsDevice.Viewport.Height,
                0.0f,
                100.0f
                );

            this.drawingContext.View       = view;
            this.drawingContext.Projection = projection;

            foreach (var node in nodes)
            {
                node.Draw(this.drawingContext);
            }
        }