Example #1
0
        /// <summary>
        /// Directly render a given primitive shape, with an optional effect parameter.<br />
        /// Calls the RenderPrimitives method, using the parameters of the given primitive shape to determine vertices, indeces, and type of primitives to draw.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="effect"></param>
        public static void DrawPrimitiveShape(IPrimitiveShape primitiveShape, Effect effect = null)
        {
            ApplyPrimitiveShader(effect);
            primitiveShape.PrimitiveStructure(out VertexPositionColorTexture[] vertices, out short[] indeces);

            RenderPrimitives(vertices, indeces, primitiveShape.GetPrimitiveType);
        }
Example #2
0
        public void AdditiveCall(SpriteBatch spriteBatch)
        {
            float  blurLength      = 100 * projectile.scale;
            float  blurWidth       = 5 * projectile.scale;
            float  flickerStrength = (((float)Math.Sin(Main.GlobalTime * 10) % 1) * 0.1f) + 1f;
            Effect blurEffect      = mod.GetEffect("Effects/BlurLine");

            IPrimitiveShape[] blurLines = new IPrimitiveShape[]
            {
                //Horizontal
                new SquarePrimitive()
                {
                    Position = projectile.Center - Main.screenPosition,
                    Height   = blurWidth * flickerStrength,
                    Length   = blurLength * flickerStrength,
                    Rotation = 0,
                    Color    = Color.White * flickerStrength * projectile.Opacity
                },

                //Vertical, lower length
                new SquarePrimitive()
                {
                    Position = projectile.Center - Main.screenPosition,
                    Height   = blurWidth * flickerStrength,
                    Length   = blurLength * flickerStrength * 0.5f,
                    Rotation = MathHelper.PiOver2,
                    Color    = Color.White * flickerStrength * projectile.Opacity
                },
            };

            PrimitiveRenderer.DrawPrimitiveShapeBatched(blurLines, blurEffect);
        }
Example #3
0
 public RayHit(IRay ray, IShape masterShape, IPrimitiveShape intersectShape, IVector normal, IVector intersection, float time, bool incoming)
 {
     this.Ray            = ray;
     this.MasterShape    = masterShape;
     this.IntersectShape = intersectShape;
     this.Normal         = normal.Normalize();
     this.Intersection   = intersection;
     this.Time           = time;
     this.InComing       = incoming;
 }
Example #4
0
        public override void Draw(Effect effect, BasicEffect effect2, GraphicsDevice device)
        {
            if (Dead || _points.Count <= 1)
            {
                return;
            }

            //set the parameters for the shader
            Effect flametrailEffect = SpiritMod.Instance.GetEffect("Effects/FlameTrail");

            flametrailEffect.Parameters["uTexture"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_3"));
            flametrailEffect.Parameters["uTexture2"].SetValue(SpiritMod.Instance.GetTexture("Textures/Trails/Trail_4"));
            flametrailEffect.Parameters["Progress"].SetValue(Main.GlobalTime * -1f);
            flametrailEffect.Parameters["xMod"].SetValue(1.5f);
            flametrailEffect.Parameters["StartColor"].SetValue(_startColor.ToVector4());
            flametrailEffect.Parameters["MidColor"].SetValue(_midColor.ToVector4());
            flametrailEffect.Parameters["EndColor"].SetValue(_endColor.ToVector4());


            float getWidthMod(float progress = 0) => ((float)Math.Sin((Main.GlobalTime - progress) * MathHelper.TwoPi * 1.5f) * 0.33f + 1.33f) / (float)Math.Pow(1 - progress, 0.1f);

            IPrimitiveShape[] shapesToDraw = new IPrimitiveShape[]
            {
                new CirclePrimitive
                {
                    Color      = Color.White * _deathProgress,
                    Radius     = _width * _deathProgress * getWidthMod(),
                    Position   = _points[0] - Main.screenPosition,
                    MaxRadians = MathHelper.TwoPi
                },
                new PrimitiveStrip
                {
                    Color         = Color.White * _deathProgress,
                    Width         = _width * _deathProgress,
                    PositionArray = _points.ToArray(),
                    TaperingType  = StripTaperType.TaperEnd,
                    WidthDelegate = delegate(float progress) { return(getWidthMod(progress)); }
                }
            };

            PrimitiveRenderer.DrawPrimitiveShapeBatched(shapesToDraw, flametrailEffect);
        }
Example #5
0
        public void AdditiveCall(SpriteBatch sB)
        {
            float  blurLength      = 180 * projectile.scale;
            float  blurWidth       = 8 * projectile.scale;
            float  flickerStrength = (((float)Math.Sin(Main.GlobalTime * 12) % 1) * 0.1f) + 1f;
            Effect blurEffect      = mod.GetEffect("Effects/BlurLine");

            IPrimitiveShape[] blurLines = new IPrimitiveShape[]
            {
                //Horizontal
                new SquarePrimitive()
                {
                    Position = projectile.Center - Main.screenPosition,
                    Height   = blurWidth * flickerStrength,
                    Length   = blurLength * flickerStrength,
                    Rotation = 0,
                    Color    = Color.White * flickerStrength * projectile.Opacity
                },

                //Vertical, lower length
                new SquarePrimitive()
                {
                    Position = projectile.Center - Main.screenPosition,
                    Height   = blurWidth * flickerStrength,
                    Length   = blurLength * flickerStrength * 0.75f,
                    Rotation = MathHelper.PiOver2,
                    Color    = Color.White * flickerStrength * projectile.Opacity
                },
            };

            PrimitiveRenderer.DrawPrimitiveShapeBatched(blurLines, blurEffect);

            Texture2D bloom = mod.GetTexture("Effects/Masks/CircleGradient");

            sB.Draw(bloom, projectile.Center - Main.screenPosition, null, Color.White * projectile.Opacity, 0, bloom.Size() / 2, 0.25f * projectile.scale, SpriteEffects.None, 0);
        }