Beispiel #1
0
        public void Render(VBN Skeleton)
        {
            if (!Runtime.renderHitboxes || Skeleton == null)
            {
                return;
            }

            if (Hitboxes.Count <= 0)
            {
                return;
            }

            GL.Enable(EnableCap.Blend);
            GL.Disable(EnableCap.CullFace);
            foreach (var pair in Hitboxes)
            {
                var h = pair.Value;

                if (Runtime.HiddenHitboxes.Contains(h.ID))
                {
                    continue;
                }

                Bone b = getBone(h.Bone, Skeleton);
                h.va = Vector3.TransformPosition(new Vector3(h.X, h.Y, h.Z), b.transform.ClearScale());

                // Draw angle marker
                RenderHitboxAngles(h, Skeleton);

                GL.Color4(h.GetDisplayColor());

                // Draw everything to the stencil buffer
                RenderTools.beginTopLevelStencil();
                if (!h.IsSphere())
                {
                    h.va2 = new Vector3(h.X2, h.Y2, h.Z2);
                    if (h.Bone != -1)
                    {
                        h.va2 = Vector3.TransformPosition(h.va2, b.transform.ClearScale());
                    }
                    RenderTools.drawCylinder(h.va, h.va2, h.Size);
                }
                else
                {
                    RenderTools.drawSphere(h.va, h.Size, 30);
                }

                // n factorial (n!) algorithm (NOT EFFICIENT) to draw subsequent hitboxes around each other.
                // Will work fine for the low amounts of hitboxes in smash4.
                if (Runtime.renderHitboxesNoOverlap)
                {
                    // Remove the stencil for the already drawn hitboxes
                    RenderTools.beginTopLevelAntiStencil();
                    foreach (var pair2 in Hitboxes.Reverse())
                    {
                        if (pair2.Key == pair.Key)
                        {
                            break;  // this only works because the list is sorted
                        }
                        var h2 = pair2.Value;

                        if (!Runtime.HiddenHitboxes.Contains(h2.ID))
                        {
                            Bone b2 = getBone(h2.Bone, Skeleton);
                            var  va = Vector3.TransformPosition(new Vector3(h2.X, h2.Y, h2.Z), b2.transform.ClearScale());
                            if (!h2.IsSphere())
                            {
                                var va2 = new Vector3(h2.X2, h2.Y2, h2.Z2);
                                if (h2.Bone != -1)
                                {
                                    va2 = Vector3.TransformPosition(va2, b2.transform.ClearScale());
                                }
                                RenderTools.drawCylinder(va, va2, h2.Size);
                            }
                            else
                            {
                                RenderTools.drawSphere(va, h2.Size, 30);
                            }
                        }
                    }
                }

                if (Runtime.SelectedHitboxID == h.ID)
                {
                    GL.Color4(Color.FromArgb(Runtime.hurtboxAlpha, Runtime.hurtboxColorSelected));
                    if (!h.IsSphere())
                    {
                        RenderTools.drawWireframeCylinder(h.va, h.va2, h.Size);
                    }
                    else
                    {
                        RenderTools.drawWireframeSphere(h.va, h.Size, 10);
                    }
                }

                // End stenciling and draw over all the stenciled bits
                RenderTools.endTopLevelStencilAndDraw();
            }
            GL.Enable(EnableCap.CullFace);
            GL.Disable(EnableCap.Blend);
        }