Beispiel #1
0
        public virtual void Recalculate()
        {
            CalculatedStyle calculatedStyle  = Parent?.InnerDimensions ?? UserInterface.ActiveInstance.Dimensions;
            CalculatedStyle calculatedStyle2 = default;

            calculatedStyle2.X = Left.GetValue(calculatedStyle.Width) + calculatedStyle.X;
            calculatedStyle2.Y = Top.GetValue(calculatedStyle.Height) + calculatedStyle.Y;
            float value  = MinWidth.GetValue(calculatedStyle.Width);
            float value2 = MaxWidth.GetValue(calculatedStyle.Width);
            float value3 = MinHeight.GetValue(calculatedStyle.Height);
            float value4 = MaxHeight.GetValue(calculatedStyle.Height);

            calculatedStyle2.Width   = MathHelper.Clamp(Width.GetValue(calculatedStyle.Width), value, value2);
            calculatedStyle2.Height  = MathHelper.Clamp(Height.GetValue(calculatedStyle.Height), value3, value4);
            calculatedStyle2.Width  += MarginLeft + MarginRight;
            calculatedStyle2.Height += MarginTop + MarginBottom;
            calculatedStyle2.X      += calculatedStyle.Width * HAlign - calculatedStyle2.Width * HAlign;
            calculatedStyle2.Y      += calculatedStyle.Height * VAlign - calculatedStyle2.Height * VAlign;
            OuterDimensions          = calculatedStyle2;

            calculatedStyle2.X      += MarginLeft;
            calculatedStyle2.Y      += MarginTop;
            calculatedStyle2.Width  -= MarginLeft + MarginRight;
            calculatedStyle2.Height -= MarginTop + MarginBottom;
            Dimensions = calculatedStyle2;

            calculatedStyle2.X      += PaddingLeft;
            calculatedStyle2.Y      += PaddingTop;
            calculatedStyle2.Width  -= PaddingLeft + PaddingRight;
            calculatedStyle2.Height -= PaddingTop + PaddingBottom;
            InnerDimensions          = calculatedStyle2;

            RecalculateChildren();
        }
Beispiel #2
0
 private void Update(EvaluationContext context)
 {
     Output.Value = new RawViewportF
     {
         X        = X.GetValue(context),
         Y        = Y.GetValue(context),
         Width    = Width.GetValue(context),
         Height   = Height.GetValue(context),
         MinDepth = MinDepth.GetValue(context),
         MaxDepth = MaxDepth.GetValue(context)
     };
 }
Beispiel #3
0
 public new void Update(EvaluationContext context)
 {
     if (InputConnection.Count > 0)
     {
         Value = InputConnection[0].GetValue(context);
     }
     else
     {
         if (Width.InputConnection != null)
         {
             Value.Width = Width.GetValue(context);
         }
         if (Height.InputConnection != null)
         {
             Value.Height = Height.GetValue(context);
         }
     }
 }
Beispiel #4
0
        public void DrawBeamApp(PolylineRender poly, float globalTime, NodeReference reference, ParticleEffectInstance instance, ref Matrix4x4 transform, float sparam)
        {
            //get particles!
            var beam = instance.Beams[reference.BeamIndex];
            if (beam.ParticleCount < 2) { beam.ParticleCount = 0;  return; }
            AgeComparer.Instance.Particles = instance.Pool.Particles;
            Array.Sort(beam.ParticleIndices, 0, beam.ParticleCount, AgeComparer.Instance);
            //draw
            var node_tr = GetAttachment(reference, transform);
            Texture2D tex;
            Vector2 tl, tr, bl, br;
            var res = instance.Resources;
            TextureHandler.Update(Texture, res);
            var frame = GetFrame(globalTime, sparam, ref instance.Pool.Particles[beam.ParticleIndices[0]]);
            int index = (int) Math.Floor((TextureHandler.FrameCount - 1) * frame) * 4;
            tl = TextureHandler.Coordinates[index];
            tr = TextureHandler.Coordinates[index + 1];
            bl = TextureHandler.Coordinates[index + 2];
            br = TextureHandler.Coordinates[index + 3];
            //Sorting hack kinda
            var z = RenderHelpers.GetZ(instance.Pool.Camera.Position, Vector3.Transform(Vector3.Zero, node_tr));
            for (int j = 0; j < 2; j++) //two planes
            {
                poly.StartLine(TextureHandler.Texture ?? res.WhiteTexture, BlendInfo);
                bool odd = true;
                Vector3 dir = Vector3.Zero;

                for (int i = 0; i < beam.ParticleCount; i++)
                {
                    var pos = Vector3.Transform(instance.Pool.Particles[beam.ParticleIndices[i]].Position, node_tr);
                    if (i + 1 < beam.ParticleCount) {
                        var pos2 = Vector3.Transform(instance.Pool.Particles[beam.ParticleIndices[i + 1]].Position, node_tr);
                        var forward = (pos2 - pos).Normalized();
                        var toCamera = (instance.Pool.Camera.Position - pos).Normalized();
                        var up = Vector3.Cross(toCamera, forward);
                        up.Normalize();
                        dir = up;
                        if (j == 1)
                        {
                            //Broken? Doesn't show up
                            var right = Vector3.Cross(up, forward).Normalized();
                            dir = right;
                        }
                    }
                    var time = instance.Pool.Particles[beam.ParticleIndices[i]].TimeAlive / instance.Pool.Particles[beam.ParticleIndices[i]].LifeSpan;
                    var w = Width.GetValue(sparam, time);
                    poly.AddPoint(
                        pos + (dir * w / 2),
                        pos - (dir * w / 2),
                        odd ? tl : bl,
                        odd ? tr : br,
                        new Color4(
                            Color.GetValue(sparam, time),
                            Alpha.GetValue(sparam, time)
                        )
                    );
                    odd = !odd;
                }
                poly.FinishLine(z);
            }
            beam.ParticleCount = 0;
        }
Beispiel #5
0
        public unsafe void DrawBeamApp(PolylineRender poly, LineBuffer points, float globalTime, NodeReference reference, ParticleEffectInstance instance, ResourceManager res, Billboards billboards, ref Matrix4 transform, float sparam)
        {
            //TODO: Cross-plane not showing
            //TODO: In some cases particles are going backwards? (Broken emitter or LineBuffer)
            //TODO: See if z sorting can be better for Polyline
            //TODO: Implement FLBeamAppearance properties
            if (points.Count() < 2)
            {
                return;
            }
            //Get only active indices, alloc on stack for 0 GC pressure
            //int* indices = stackalloc int[512];
            var indices   = new int[512];
            var particles = new Particle[512];

            for (int i = 0; i < 512; i++)
            {
                indices[i] = -1;
            }
            int ptCount = 0;

            for (int i = 0; i < points.Count(); i++)
            {
                if (points[i].Active)
                {
                    indices[ptCount++] = points[i].ParticleIndex;
                }
            }
            if (ptCount < 2)
            {
                return;
            }
            for (int i = 0; i < ptCount; i++)
            {
                particles[i] = instance.Particles[indices[i]];
            }
            for (int i = 1; i < ptCount; i++)
            {
                if (particles[i - 1].TimeAlive > particles[i].TimeAlive)
                {
                    Console.WriteLine("bad order");
                }
            }
            var       node_tr = GetAttachment(reference, transform);
            Texture2D tex;
            Vector2   tl, tr, bl, br;

            HandleTexture(res, globalTime, sparam, ref instance.Particles[indices[0]], out tex, out tl, out tr, out bl, out br);
            //Sorting hack kinda
            var z = RenderHelpers.GetZ(billboards.Camera.Position, node_tr.Transform(Vector3.Zero));

            for (int j = 0; j < 2; j++)             //two planes
            {
                poly.StartLine(tex, BlendInfo);
                bool    odd = true;
                Vector3 dir = Vector3.Zero;

                for (int i = 0; i < ptCount; i++)
                {
                    var pos = node_tr.Transform(instance.Particles[indices[i]].Position);
                    if (i + 1 < ptCount)
                    {
                        var pos2     = node_tr.Transform(instance.Particles[indices[i + 1]].Position);
                        var forward  = (pos2 - pos).Normalized();
                        var toCamera = (billboards.Camera.Position - pos).Normalized();
                        var up       = Vector3.Cross(toCamera, forward);
                        up.Normalize();
                        dir = up;
                        if (j == 1)
                        {
                            //Broken? Doesn't show up
                            var right = Vector3.Cross(up, forward).Normalized();
                            dir = right;
                        }
                    }
                    var time = instance.Particles[indices[i]].TimeAlive / instance.Particles[indices[i]].LifeSpan;
                    var w    = Width.GetValue(sparam, time);
                    poly.AddPoint(
                        pos + (dir * w / 2),
                        pos - (dir * w / 2),
                        odd ? tl : bl,
                        odd ? tr : br,
                        new Color4(
                            Color.GetValue(sparam, time),
                            Alpha.GetValue(sparam, time)
                            )
                        );
                    odd = !odd;
                }
                poly.FinishLine(z);
            }
        }
Beispiel #6
0
 private void Update(EvaluationContext context)
 {
     Size.Value = new Size2(Width.GetValue(context), Height.GetValue(context));
 }