Example #1
0
        private void AddTreeBranch(VertexPositionColor p1, int branches, double maxRadius, int maxLines)
        {
            double radius = fRandom.NextDouble() * maxRadius;

            if (radius > 4.0f && fLines.Lines < maxLines)
            {
                double maxInnerRadius = radius / 1.8f;
                for (int i = 0; i < branches; i++)
                {
                    VertexPositionColor p2 = GetRandomPoint(p1, radius);
                    p2.Color.A += 32;
                    fLines.AddLine(p1, p2);
                    AddTreeBranch(p2, branches, maxInnerRadius, maxLines);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Loads any component specific content
        /// </summary>
        protected override void LoadContent()
        {
            fSpriteBatch = new SpriteBatch(Game.GraphicsDevice);

            InitializeTransform();
            InitializeEffect();

            fModel1 = this.Game.Content.Load <Model>("MyFirstModel/grid");
            fModel2 = this.Game.Content.Load <Model>("MyFirstModel/dude");

            fLines = new PrimitiveLine(Game.GraphicsDevice);
            fLines.AddLine(
                new VertexPositionColor(new Vector3(0, 0, 0), Color.Red),
                new VertexPositionColor(new Vector3(1000, 0, 0), Color.Yellow));
            fLines.AddLine(
                new VertexPositionColor(new Vector3(0, 0, 0), Color.Green),
                new VertexPositionColor(new Vector3(0, 1000, 0), Color.LightGreen));
            fLines.AddLine(
                new VertexPositionColor(new Vector3(0, 0, 0), Color.Blue),
                new VertexPositionColor(new Vector3(0, 0, 1000), Color.Cyan));
            fLines.AddLine(
                new VertexPositionColor(new Vector3(0, 0, 0), Color.DarkRed),
                new VertexPositionColor(new Vector3(-1000, 0, 0), Color.DarkRed));
            fLines.AddLine(
                new VertexPositionColor(new Vector3(0, 0, 0), Color.DarkGreen),
                new VertexPositionColor(new Vector3(0, -1000, 0), Color.DarkGreen));
            fLines.AddLine(
                new VertexPositionColor(new Vector3(0, 0, 0), Color.DarkBlue),
                new VertexPositionColor(new Vector3(0, 0, -1000), Color.DarkBlue));
            for (int r = 0; r < 360; r += 10)
            {
                float angle = MathHelper.ToRadians(r);
                fLines.AddCircle(0, 35, 0, 40, 50, Color.Red, 0, 0);
                fLines.AddCircle(0, 35, 0, 40, 50, Color.Tomato, angle, 0);
                fLines.AddCircle(0, 35, 0, 40, 50, Color.Orange, 0, angle);
            }
            fStateBlend      = BlendState.Opaque;
            fStateDepth      = DepthStencilState.Default;
            fStateNoDepth    = DepthStencilState.None;
            fStateRasterizer = new RasterizerState()
            {
                FillMode = FillMode.Solid, CullMode = CullMode.None
            };
            fStateSampler = new SamplerState()
            {
                AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap
            };

            base.LoadContent();
        }