Пример #1
0
        public static void DrawShape(DamageShape s)
        {
            GL.LineWidth(2);
            GL.Color4(Color.FromArgb(128, Color.Yellow));

            Vector3 sPos = s.useStartPos ? s.startPos : new Vector3(0, 0, 0);
            Vector3 pos  = new Vector3(s.x, s.y, s.z);
            Vector3 posd = new Vector3(s.dx, s.dy, s.dz);

            if (s.type == 2)
            {
                RenderTools.drawSphere(sPos + pos, s.radius, 24);
            }
            if (s.type == 3)
            {
                RenderTools.drawCylinder(sPos + pos, sPos + pos + posd, s.radius);
            }
        }
Пример #2
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);
        }
Пример #3
0
        private void RenderRotationTool(Camera Camera, Ray Ray)
        {
            Matrix4 mat          = b.transform.ClearScale();
            Vector3 center       = Vector3.TransformPosition(Vector3.Zero, mat);
            Matrix4 invTrasnform = b.transform.ClearScale().Inverted();
            Vector3 point;

            if (state == 0)
            {
                hit = Ray.LineSphereIntersect(center, Size, out point);
                if (hit)
                {
                    Vector3 angle = Angles(Vector3.TransformPosition(point, invTrasnform)) * new Vector3(180f / (float)Math.PI);
                    angle.X = Math.Abs(angle.X);
                    angle.Y = Math.Abs(angle.Y);
                    angle.Z = Math.Abs(angle.Z);

                    _hiX = false;
                    _hiY = false;
                    _hiZ = false;
                    float _axisSnapRange = 14f;
                    if (Math.Abs(angle.Y - 90.0f) <= _axisSnapRange)
                    {
                        _hiX = true;
                    }
                    else if (angle.X >= (180.0f - _axisSnapRange) || angle.X <= _axisSnapRange)
                    {
                        _hiY = true;
                    }
                    else if (angle.Y >= (180.0f - _axisSnapRange) || angle.Y <= _axisSnapRange)
                    {
                        _hiZ = true;
                    }
                }
                if (!_hiX && !_hiZ && !_hiY)
                {
                    hit = false;
                }
            }

            if (state == 1)
            {
                float sx = (Ray.mouse_x - PrevPoint.X) / 100;
                float sy = (Ray.mouse_y - PrevPoint.Y) / 100;
                float s  = sx + sy;
                if (_hiX)
                {
                    b.rot = b.rot * Quaternion.FromAxisAngle(Vector3.UnitX, s);
                }
                if (_hiY)
                {
                    b.rot = b.rot * Quaternion.FromAxisAngle(Vector3.UnitY, s);
                }
                if (_hiZ)
                {
                    b.rot = b.rot * Quaternion.FromAxisAngle(Vector3.UnitZ, s);
                }
                b.vbnParent.update();
            }

            GL.PushMatrix();
            GL.MultMatrix(ref mat);

            GL.Color4(0.25f, 0.25f, 0.25f, 0.2f);
            RenderTools.drawSphere(Vector3.Zero, Size, 25);

            GL.Color3(_hiZ ? Color.Yellow : Color.Green);
            GL.LineWidth(3);
            RenderTools.drawCircleOutline(Vector3.Zero, Size, 25);

            GL.Rotate(90.0f, 0.0f, 1.0f, 0.0f);

            GL.Color3(_hiX ? Color.Yellow : Color.Red);
            RenderTools.drawCircleOutline(Vector3.Zero, Size, 25);

            GL.Rotate(90.0f, 1.0f, 0.0f, 0.0f);

            GL.Color3(_hiY ? Color.Yellow : Color.Blue);
            RenderTools.drawCircleOutline(Vector3.Zero, Size, 25);

            GL.PopMatrix();
        }