Esempio n. 1
0
        public Tuple <Location, Vector4, Vector2> GetDetails()
        {
            if (lTT != TheClient.GlobalTickTimeLocal)
            {
                TTL -= (float)TheClient.gDelta;
                lTT  = TheClient.GlobalTickTimeLocal;
            }
            if (TTL <= 0)
            {
                return(null);
            }
            if (AltAlpha != null)
            {
                Alpha = AltAlpha(this);
                if (Alpha <= 0.01)
                {
                    return(null);
                }
            }
            else if (Fades)
            {
                Alpha -= (float)TheClient.gDelta / O_TTL;
                if (Alpha <= 0.01)
                {
                    TTL = 0;
                    return(null);
                }
            }
            float rel = TTL / O_TTL;

            if (rel >= 1 || rel <= 0)
            {
                return(null);
            }
            Location start = Start(this) + WindOffset;

            if (WindMod != 0)
            {
                WindOffset += WindMod * TheClient.TheRegion.ActualWind * SimplexNoiseInternal.Generate((start.X + TheClient.GlobalTickTimeLocal) * 0.2, (start.Y + TheClient.GlobalTickTimeLocal) * 0.2, start.Z * 0.2) * 0.1;
            }
            Vector4 light   = TheClient.TheRegion.GetLightAmountAdjusted(start.GetBlockLocation(), start, Location.UnitZ);
            Vector4 scolor  = new Vector4((float)Color.X * light.X, (float)Color.Y * light.Y, (float)Color.Z * light.Z, Alpha * light.W);
            Vector4 scolor2 = new Vector4((float)Color2.X * light.X, (float)Color2.Y * light.Y, (float)Color2.Z * light.Z, Alpha * light.W);
            Vector4 rcol    = scolor * rel + scolor2 * (1 - rel);
            float   scale   = (float)End(this).X;

            if (TID == -1)
            {
                TID = TheClient.Particles.Engine.GetTextureID(texture.Name); // TODO: make sure this gets set prior to now?
            }
            return(new Tuple <Location, Vector4, Vector2>(start, rcol, new Vector2(scale, TID)));
        }
Esempio n. 2
0
        public Tuple <Location, Vector4> GetDetails()
        {
            if (lTT != TheClient.GlobalTickTimeLocal)
            {
                TTL -= (float)TheClient.gDelta;
                lTT  = TheClient.GlobalTickTimeLocal;
            }
            if (TTL <= 0)
            {
                return(null);
            }
            if (AltAlpha != null)
            {
                Alpha = AltAlpha(this);
                if (Alpha <= 0.01)
                {
                    return(null);
                }
            }
            else if (Fades)
            {
                Alpha -= (float)TheClient.gDelta / O_TTL;
                if (Alpha <= 0.01)
                {
                    TTL = 0;
                    return(null);
                }
            }
            float rel = TTL / O_TTL;

            if (rel >= 1 || rel <= 0)
            {
                return(null);
            }
            Location start = Start(this) + WindOffset;

            if (BlowsInWind)
            {
                WindOffset += TheClient.TheRegion.ActualWind * SimplexNoiseInternal.Generate((start.X + TheClient.GlobalTickTimeLocal) * 0.2, (start.Y + TheClient.GlobalTickTimeLocal) * 0.2, start.Z * 0.2) * 0.1;
            }
            Vector4 light   = TheClient.TheRegion.GetLightAmountAdjusted(start, Location.UnitZ);
            Vector4 scolor  = new Vector4((float)Color.X * light.X, (float)Color.Y * light.Y, (float)Color.Z * light.Z, Alpha * light.W);
            Vector4 scolor2 = new Vector4((float)Color2.X * light.X, (float)Color2.Y * light.Y, (float)Color2.Z * light.Z, Alpha * light.W);
            Vector4 rcol    = scolor * rel + scolor2 * (1 - rel);

            return(new Tuple <Location, Vector4>(start, rcol));
        }
Esempio n. 3
0
 public static double Generate(double x, double y)
 {
     x = System.Math.Abs(x);
     y = System.Math.Abs(y);
     return((SimplexNoiseInternal.Generate(x, y) + 1f) * 0.5f);
 }
Esempio n. 4
0
        public void Render()
        {
            if (lTT != TheClient.GlobalTickTimeLocal)
            {
                TTL -= (float)TheClient.gDelta;
                lTT  = TheClient.GlobalTickTimeLocal;
            }
            if (TTL <= 0)
            {
                return;
            }
            if (AltAlpha != null)
            {
                Alpha = AltAlpha(this);
                if (Alpha <= 0.01)
                {
                    return;
                }
            }
            else if (Fades)
            {
                Alpha -= (float)TheClient.gDelta / O_TTL;
                if (Alpha <= 0.01)
                {
                    TTL = 0;
                    return;
                }
            }
            float rel = TTL / O_TTL;

            if (rel >= 1 || rel <= 0)
            {
                return;
            }
            texture.Bind();
            Location start = Start(this) + WindOffset;

            if (WindMod != 0)
            {
                WindOffset += WindMod * TheClient.TheRegion.ActualWind * SimplexNoiseInternal.Generate((start.X + TheClient.GlobalTickTimeLocal) * 0.2, (start.Y + TheClient.GlobalTickTimeLocal) * 0.2, start.Z * 0.2) * 0.1;
            }
            Vector4 light   = TheClient.TheRegion.GetLightAmountAdjusted(start.GetBlockLocation(), start, Location.UnitZ);
            Vector4 scolor  = new Vector4((float)Color.X * light.X, (float)Color.Y * light.Y, (float)Color.Z * light.Z, Alpha * light.W);
            Vector4 scolor2 = new Vector4((float)Color2.X * light.X, (float)Color2.Y * light.Y, (float)Color2.Z * light.Z, Alpha * light.W);
            Vector4 rcol    = scolor * rel + scolor2 * (1 - rel);

            rcol = Vector4.Max(rcol, new Vector4(MinimumLight, MinimumLight, MinimumLight, 0f));
            TheClient.Rendering.SetColor(rcol, TheClient.MainWorldView);
            TheClient.Rendering.SetMinimumLight(MinimumLight, TheClient.MainWorldView);
            switch (Type)
            {
            case ParticleEffectType.LINE:
            {
                float dat = FData(this);
                if (dat != 1)
                {
                    GL.LineWidth(dat);
                }
                TheClient.Rendering.RenderLine(start, End(this), TheClient.MainWorldView);
                if (dat != 1)
                {
                    GL.LineWidth(1);
                }
            }
            break;

            case ParticleEffectType.CYLINDER:
            {
                TheClient.Rendering.RenderCylinder(start, End(this), FData(this), TheClient.MainWorldView);
            }
            break;

            case ParticleEffectType.LINEBOX:
            {
                float dat = FData(this);
                if (dat != 1)
                {
                    GL.LineWidth(dat);
                }
                TheClient.Rendering.RenderLineBox(start, End(this), TheClient.MainWorldView);
                if (dat != 1)
                {
                    GL.LineWidth(1);
                }
            }
            break;

            case ParticleEffectType.BOX:
            {
                Matrix4d mat = Matrix4d.Scale(ClientUtilities.ConvertD(End(this))) * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(start));
                TheClient.MainWorldView.SetMatrix(2, mat);
                TheClient.Models.Cube.Draw();
            }
            break;

            case ParticleEffectType.SPHERE:
            {
                Matrix4d mat = Matrix4d.Scale(ClientUtilities.ConvertD(End(this))) * Matrix4d.CreateTranslation(ClientUtilities.ConvertD(start));
                TheClient.MainWorldView.SetMatrix(2, mat);
                TheClient.Models.Sphere.Draw();
            }
            break;

            case ParticleEffectType.SQUARE:
            {
                TheClient.Rendering.RenderBillboard(start, End(this), TheClient.MainWorldView.CameraPos, TheClient.MainWorldView);
            }
            break;

            default:
                throw new NotImplementedException();
            }
        }