Example #1
0
        internal unsafe void Render(GLContext ctx)
        {
            if (!_render)
            {
                return;
            }

            if (_boneColor != Color.Transparent)
            {
                ctx.glColor(_boneColor.R, _boneColor.G, _boneColor.B, _boneColor.A);
            }
            else
            {
                ctx.glColor(DefaultBoneColor.R, DefaultBoneColor.G, DefaultBoneColor.B, DefaultBoneColor.A);
            }

            Vector3 v = _frameState._translate;

            ctx.glBegin(GLPrimitiveType.Lines);

            ctx.glVertex(0.0f, 0.0f, 0.0f);
            ctx.glVertex3v((float *)&v);

            ctx.glEnd();

            ctx.glPushMatrix();

            ctx.glTranslate(v._x, v._y, v._z);

            //Render node
            GLDisplayList ndl = ctx.FindOrCreate <GLDisplayList>("BoneNodeOrb", CreateNodeOrb);

            if (_nodeColor != Color.Transparent)
            {
                ctx.glColor(_nodeColor.R, _nodeColor.G, _nodeColor.B, _nodeColor.A);
            }
            else
            {
                ctx.glColor(DefaultNodeColor.R, DefaultNodeColor.G, DefaultNodeColor.B, DefaultNodeColor.A);
            }

            ndl.Call();

            DrawNodeOrients(ctx);

            ctx.glTranslate(-v._x, -v._y, -v._z);

            //Transform Bones
            fixed(Matrix *m = &_frameState._transform)
            ctx.glMultMatrix((float *)m);

            //Render children
            foreach (MDL0BoneNode n in Children)
            {
                n.Render(ctx);
            }

            ctx.glPopMatrix();
        }
Example #2
0
        private unsafe void RenderCatchCollision(Vector3 cam)
        {
            ResourceNode[] bl = _model._linker.BoneCache;

            int boneindex = _parameters[1];
            int size      = HitboxSize;

            Root.GetBoneIndex(ref boneindex);

            if (boneindex == 0) // if a hitbox is on TopN, make it follow TransN
            {
                if (Root.Data != null)
                {
                    boneindex = Root.Data._misc._boneRefs[4].boneIndex;
                    Root.GetBoneIndex(ref boneindex);
                }
                else
                {
                    int transindex = 0;
                    foreach (MDL0BoneNode bn in bl)
                    {
                        if (bn.Name.Equals("TransN"))
                        {
                            break;
                        }
                        transindex++;
                    }
                    if (transindex != bl.Length)
                    {
                        boneindex = transindex;
                    }
                }
            }
            MDL0BoneNode b = bl[boneindex] as MDL0BoneNode;

            Matrix     r         = b.Matrix.GetRotationMatrix();
            FrameState state     = b.Matrix.Derive();
            Vector3    bonePos   = state._translate;
            Vector3    pos       = new Vector3(Util.UnScalar(_parameters[3]), Util.UnScalar(_parameters[4]), Util.UnScalar(_parameters[5])) / state._scale;
            Vector3    globalPos = r.Multiply(pos);

            Matrix  m         = Matrix.TransformMatrix(new Vector3(1), state._rotate, globalPos + bonePos);
            Vector3 resultPos = m.GetPoint();

            m = Matrix.TransformMatrix(new Vector3(Util.UnScalar(size)), new Vector3(), resultPos);
            GL.PushMatrix();
            GL.MultMatrix((float *)&m);
            int    res       = 16;
            double drawangle = 360.0 / res;

            Vector3 color = Util.GetTypeColor(Util.HitboxType.Throwing);

            GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.375f);
            GLDisplayList spheres = TKContext.GetSphereList();

            spheres.Call();

            GL.PopMatrix();
        }
Example #3
0
        private unsafe void RenderOrb(MDL0BoneNode bone, GLDisplayList list)
        {
            Matrix m = Matrix.TransformMatrix(new Vector3(MDL0BoneNode._nodeRadius), new Vector3(), bone._frameMatrix.GetPoint());

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            list.Call();
            GL.PopMatrix();
        }
Example #4
0
        public unsafe void RenderOrb(IBoneNode bone, GLDisplayList list, ModelPanelViewport v, bool doScale)
        {
            float radius = MDL0BoneNode._nodeRadius * (doScale ? OrbRadius(bone, v) : 1.0f);

            Matrix m = Matrix.TransformMatrix(new Vector3(radius), new Vector3(), bone.Matrix.GetPoint());

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            list.Call();
            GL.PopMatrix();
        }
        private unsafe void RenderOrbRecursive(MDL0BoneNode bone, GLContext ctx, GLDisplayList list)
        {
            Matrix m = Matrix.TransformMatrix(new Vector3(MDL0BoneNode._nodeRadius), new Vector3(), bone._frameMatrix.GetPoint());

            ctx.glPushMatrix();
            ctx.glMultMatrix((float *)&m);

            list.Call();
            ctx.glPopMatrix();

            foreach (MDL0BoneNode b in bone.Children)
            {
                RenderOrbRecursive(b, ctx, list);
            }
        }
Example #6
0
        public unsafe void RenderTranslationControl(TKContext context, Vector3 position, float radius)
        {
            GLDisplayList axis = GetAxes();

            //Enter local space
            Matrix m = Matrix.TransformMatrix(new Vector3(radius), new Vector3(), position);

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            axis.Call();

            GL.PopMatrix();

            modelPanel.ScreenText["X"] = modelPanel.Project(new Vector3(_axisLDist + 0.1f, 0, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            modelPanel.ScreenText["Y"] = modelPanel.Project(new Vector3(0, _axisLDist + 0.1f, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            modelPanel.ScreenText["Z"] = modelPanel.Project(new Vector3(0, 0, _axisLDist + 0.1f) * m) - new Vector3(8.0f, 8.0f, 0);
        }
Example #7
0
        public unsafe void RenderScaleControl(TKContext context)
        {
            GLDisplayList axis = GetScaleControl();

            //Enter local space
            Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc);

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            axis.Call();

            GL.PopMatrix();

            modelPanel.ScreenText["X"] = modelPanel.Project(new Vector3(_axisLDist + 0.1f, 0, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            modelPanel.ScreenText["Y"] = modelPanel.Project(new Vector3(0, _axisLDist + 0.1f, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            modelPanel.ScreenText["Z"] = modelPanel.Project(new Vector3(0, 0, _axisLDist + 0.1f) * m) - new Vector3(8.0f, 8.0f, 0);
        }
Example #8
0
        public static GLDisplayList CreateNodeOrb(GLContext ctx)
        {
            GLDisplayList circle = ctx.GetRingList();
            GLDisplayList orb    = new GLDisplayList(ctx);

            orb.Begin();
            ctx.glPushMatrix();

            ctx.glScale(_nodeRadius, _nodeRadius, _nodeRadius);
            circle.Call();
            ctx.glRotate(90.0f, 0.0f, 1.0f, 0.0f);
            circle.Call();
            ctx.glRotate(90.0f, 1.0f, 0.0f, 0.0f);
            circle.Call();

            ctx.glPopMatrix();
            orb.End();
            return(orb);
        }
Example #9
0
        public static GLDisplayList CreateNodeOrb()
        {
            GLDisplayList circle = TKContext.GetRingList();
            GLDisplayList orb    = new GLDisplayList();

            orb.Begin();
            GL.PushMatrix();

            GL.Scale(_nodeRadius, _nodeRadius, _nodeRadius);
            circle.Call();
            GL.Rotate(90.0f, 0.0f, 1.0f, 0.0f);
            circle.Call();
            GL.Rotate(90.0f, 1.0f, 0.0f, 0.0f);
            circle.Call();

            GL.PopMatrix();
            orb.End();
            return(orb);
        }
Example #10
0
        public static GLDisplayList CreateNodeOrb(GLContext ctx)
        {
            GLDisplayList circle = ctx.GetRingList();
            GLDisplayList orb    = new GLDisplayList(ctx);

            orb.Begin();
            ctx.glPushMatrix();
            ctx.glScale(_nodeRadius, _nodeRadius, _nodeRadius);

            circle.Call();
            ctx.glRotate(90.0f, 0.0f, 1.0f, 0.0f);
            circle.Call();
            ctx.glRotate(90.0f, 1.0f, 0.0f, 0.0f);
            circle.Call();

            ctx.glPopMatrix();
            orb.End();
            return(orb);

            //GLDisplayList ndl = ctx.FindOrCreate<GLDisplayList>("OrbOrients", CreateOrbOrients);
            //GLDisplayList orb = new GLDisplayList(ctx);

            //int quad = ctx.gluNewQuadric();
            //ctx.gluQuadricDrawStyle(quad, GLUQuadricDrawStyle.GLU_FILL);
            //ctx.gluQuadricOrientation(quad, GLUQuadricOrientation.Outside);

            //orb.Begin();

            //ctx.gluSphere(quad, _nodeRadius, 20, 20);
            //ndl.Call();

            //orb.End();

            //ctx.gluDeleteQuadric(quad);

            //return orb;
        }
Example #11
0
        public unsafe override void modelPanel1_PostRender(GLPanel sender)
        {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.DepthTest);

            Attributes.PostRender();

            //Render hurtboxes
            if (chkHurtboxes.Checked)
            {
                for (int i = 0; i < listPanel.lstHurtboxes.Items.Count; i++)
                {
                    if (listPanel.lstHurtboxes.GetItemChecked(i))
                    {
                        ((MiscHurtBox)listPanel.lstHurtboxes.Items[i]).Render(SelectedHurtbox != null && SelectedHurtbox.Index == i, Scriptor._hurtBoxType);
                    }
                }
            }

            //Render hitboxes
            if (chkHitboxes.Checked && Manager.Moveset != null)
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                GLDisplayList c = TKContext.GetRingList();
                GLDisplayList s = TKContext.GetSphereList();

                foreach (HitBox e in RunTime._hitBoxes)
                {
                    e.Render(modelPanel.Camera.GetPoint());
                }
            }

            base.modelPanel1_PostRender(sender);
        }
Example #12
0
        public unsafe void RenderRotationControl(TKContext context)
        {
            Matrix m = CamFacingMatrix;

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            GLDisplayList sphere = context.GetCircleList();
            GLDisplayList circle = context.GetRingList();

            //Orb
            GL.Color4(0.7f, 0.7f, 0.7f, 0.15f);
            sphere.Call();

            GL.Disable(EnableCap.DepthTest);

            //Container
            GL.Color4(0.4f, 0.4f, 0.4f, 1.0f);
            circle.Call();

            //Circ
            if (_snapCirc || _hiCirc)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(1.0f, 0.8f, 0.5f, 1.0f);
            }
            GL.Scale(_circOrbScale, _circOrbScale, _circOrbScale);
            circle.Call();

            //Pop
            GL.PopMatrix();

            GL.Enable(EnableCap.DepthTest);

            //Enter local space
            m = Matrix.TransformMatrix(new Vector3(OrbRadius), SelectedBone._frameMatrix.GetAngles(), BoneLoc);

            modelPanel.ScreenText["X"] = modelPanel.Project(new Vector3(1.1f, 0, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            modelPanel.ScreenText["Y"] = modelPanel.Project(new Vector3(0, 1.1f, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            modelPanel.ScreenText["Z"] = modelPanel.Project(new Vector3(0, 0, 1.1f) * m) - new Vector3(8.0f, 8.0f, 0);

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            //Z
            if (_snapZ || _hiZ)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(0.0f, 0.0f, 1.0f, 1.0f);
            }

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

            //X
            if (_snapX || _hiX)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }

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

            //Y
            if (_snapY || _hiY)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }

            circle.Call();

            //Pop
            GL.PopMatrix();
        }
        private unsafe void RenderOrb(MDL0BoneNode bone, GLDisplayList list)
        {
            Matrix m = Matrix.TransformMatrix(new Vector3(MDL0BoneNode._nodeRadius), new Vector3(), bone._frameMatrix.GetPoint());
            GL.PushMatrix();
            GL.MultMatrix((float*)&m);

            list.Call();
            GL.PopMatrix();
        }
Example #14
0
        private unsafe void RenderSpecialOffensiveCollision(TKContext c, Vector3 cam)
        {
            if (_event != 0x06150F00) //Special Offensive Collision
            {
                return;
            }

            ResourceNode[] bl = _model._linker.BoneCache;

            int boneindex = (int)_parameters[0] >> 16;
            int size      = HitboxSize;
            int angle     = _parameters[2];

            Root.GetBoneIndex(ref boneindex);

            if (boneindex == 0) //If a hitbox is on TopN, make it follow TransN
            {
                if (Root.Data != null)
                {
                    boneindex = Root.Data._misc._boneRefs[4].boneIndex;
                    Root.GetBoneIndex(ref boneindex);
                }
                else
                {
                    int transindex = 0;
                    foreach (MDL0BoneNode bn in bl)
                    {
                        if (bn.Name.Equals("TransN"))
                        {
                            break;
                        }
                        transindex++;
                    }
                    if (transindex != bl.Length)
                    {
                        boneindex = transindex;
                    }
                }
            }
            MDL0BoneNode b;

            b = bl[boneindex] as MDL0BoneNode;

            Matrix     r         = b.Matrix.GetRotationMatrix();
            FrameState state     = b.Matrix.Derive();
            Vector3    bonePos   = state._translate;
            Vector3    pos       = new Vector3(Util.UnScalar(_parameters[6]), Util.UnScalar(_parameters[7]), Util.UnScalar(_parameters[8])) / state._scale;
            Vector3    globalPos = r.Multiply(pos);

            Matrix  m         = Matrix.TransformMatrix(new Vector3(1), state._rotate, globalPos + bonePos);
            Vector3 resultPos = m.GetPoint();

            int id = (int)_parameters[0] & 0xFFFF;

            RunTime.MainWindow.ModelPanel.ScreenText[id.ToString()] = RunTime.MainWindow.ModelPanel.Project(resultPos);

            m = Matrix.TransformMatrix(new Vector3(Util.UnScalar(size)), new Vector3(), resultPos);
            GL.PushMatrix();
            GL.MultMatrix((float *)&m);
            int    res       = 16;
            double drawangle = 360.0 / res;

            Vector3 color = Util.GetTypeColor(flags.Type);

            GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.5f);

            GLDisplayList spheres = c.GetSphereList();

            spheres.Call();
            if (specialFlags.Stretches)
            {
                GL.PushMatrix();
                m = Matrix.TransformMatrix(new Vector3(1), state._rotate, new Vector3());
                GL.MultMatrix((float *)&m);
                Vector3 reversepos = new Vector3(-pos._x / Util.UnScalar(size), -pos._y / Util.UnScalar(size), -pos._z / Util.UnScalar(size));

                color = Util.GetEffectColor(flags.Effect);
                GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.5f);

                GL.Translate(reversepos._x, reversepos._y, reversepos._z);
                GL.Begin(BeginMode.Lines); // stretch lines
                GL.Vertex3(1, 0, 0);
                GL.Vertex3(1 - reversepos._x, 0 - reversepos._y, 0 - reversepos._z);
                GL.Vertex3(-1, 0, 0);
                GL.Vertex3(-1 - reversepos._x, 0 - reversepos._y, 0 - reversepos._z);
                GL.Vertex3(0, 1, 0);
                GL.Vertex3(0 - reversepos._x, 1 - reversepos._y, 0 - reversepos._z);
                GL.Vertex3(0, -1, 0);
                GL.Vertex3(0 - reversepos._x, -1 - reversepos._y, 0 - reversepos._z);
                GL.Vertex3(0, 0, 1);
                GL.Vertex3(0 - reversepos._x, 0 - reversepos._y, 1 - reversepos._z);
                GL.Vertex3(0, 0, -1);
                GL.Vertex3(0 - reversepos._x, 0 - reversepos._y, -1 - reversepos._z);
                GL.End();

                color = Util.GetTypeColor(flags.Type);
                GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.25f);

                spheres.Call(); // root sphere
                GL.Translate(-reversepos._x, -reversepos._y, -reversepos._z);
                GL.PopMatrix();
            }

            // angle indicator
            double  rangle       = angle / 180.0 * Math.PI;
            Vector3 effectcolour = Util.GetEffectColor(flags.Effect);

            GL.Color4((effectcolour._x / 255.0f), (effectcolour._y / 225.0f), (effectcolour._z / 255.0f), 0.75f);
            GL.PushMatrix();
            if (angle == 361)
            {
                m = Matrix.TransformMatrix(new Vector3(0.5f), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3(0));
                GL.MultMatrix((float *)&m);
                GL.Begin(BeginMode.Quads);
                for (int i = 0; i < 16; i += 2)
                {
                    GL.Vertex3(Math.Cos((i - 1) * Math.PI / 8) * 0.5, Math.Sin((i - 1) * Math.PI / 8) * 0.5, 0);
                    GL.Vertex3(Math.Cos(i * Math.PI / 8), Math.Sin(i * Math.PI / 8), 0);
                    GL.Vertex3(Math.Cos((i + 1) * Math.PI / 8) * 0.5, Math.Sin((i + 1) * Math.PI / 8) * 0.5, 0);
                    GL.Vertex3(0, 0, 0);
                }
                GL.End();
            }
            else
            {
                long a         = -angle; // otherwise 90 would point down
                int  angleflip = 0;
                if (resultPos._z < 0)
                {
                    angleflip = 180;
                }
                m = Matrix.TransformMatrix(new Vector3(1), new Vector3(a, angleflip, 0), new Vector3());
                GL.MultMatrix((float *)&m);
                GL.Begin(BeginMode.Quads);
                // left face
                GL.Vertex3(0.1, 0.1, 0);
                GL.Vertex3(0.1, 0.1, 1);
                GL.Vertex3(0.1, -0.1, 1);
                GL.Vertex3(0.1, -0.1, 0);
                // right face
                GL.Vertex3(-0.1, -0.1, 0);
                GL.Vertex3(-0.1, -0.1, 1);
                GL.Vertex3(-0.1, 0.1, 1);
                GL.Vertex3(-0.1, 0.1, 0);
                // top face
                GL.Vertex3(-0.1, 0.1, 0);
                GL.Vertex3(-0.1, 0.1, 1);
                GL.Vertex3(0.1, 0.1, 1);
                GL.Vertex3(0.1, 0.1, 0);
                // bottom face
                GL.Vertex3(0.1, -0.1, 0);
                GL.Vertex3(0.1, -0.1, 1);
                GL.Vertex3(-0.1, -0.1, 1);
                GL.Vertex3(-0.1, -0.1, 0);
                // front face
                GL.Vertex3(-0.1, -0.1, 1);
                GL.Vertex3(0.1, -0.1, 1);
                GL.Vertex3(0.1, 0.1, 1);
                GL.Vertex3(-0.1, 0.1, 1);
                // back face
                GL.Vertex3(-0.1, 0.1, 0);
                GL.Vertex3(0.1, 0.1, 0);
                GL.Vertex3(0.1, -0.1, 0);
                GL.Vertex3(-0.1, -0.1, 0);
                GL.End();
            }
            GL.PopMatrix();

            // border
            GLDisplayList rings = c.GetRingList();

            for (int i = -5; i <= 5; i++)
            {
                GL.PushMatrix();
                m = Matrix.TransformMatrix(new Vector3(1 + 0.0025f * i), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3());
                GL.MultMatrix((float *)&m);
                if (flags.Clang)
                {
                    rings.Call();
                }
                else
                {
                    for (double j = 0; j < 360 / (drawangle / 2); j += 2)
                    {
                        double ang1 = (j * (drawangle / 2)) / 180 * Math.PI;
                        double ang2 = ((j + 1) * (drawangle / 2)) / 180 * Math.PI;
                        int    q    = 0;
                        GL.Begin(BeginMode.LineStrip);
                        GL.Vertex3(Math.Cos(ang1), Math.Sin(ang1), 0);
                        GL.Vertex3(Math.Cos(ang2), Math.Sin(ang2), 0);
                        GL.End();
                    }
                }
                GL.PopMatrix();
            }

            GL.PopMatrix();
            GL.PopMatrix();
        }
        private unsafe void modelPanel1_PostRender(object sender, TKContext context)
        {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.Lighting);
            GL.Enable(EnableCap.DepthTest);

            if (RenderVertices)
                if (_editingAll && _targetModels != null)
                    foreach (MDL0Node m in _targetModels)
                        m.RenderVertices(context, false);
                else if (TargetModel != null)
                    TargetModel.RenderVertices(context, false);

            if (RenderNormals)
                if (_editingAll && _targetModels != null)
                    foreach (MDL0Node m in _targetModels)
                        m.RenderNormals(context);
                else if (TargetModel != null)
                    TargetModel.RenderNormals(context);

            //Show the user where the light source is
            if (_renderLightDisplay)
            {
                GL.Color4(Color.Blue);
                GL.Disable(EnableCap.Lighting);
                GL.Disable(EnableCap.DepthTest);

                GL.Scale(ModelPanel.LightPosition._x, ModelPanel.LightPosition._x, ModelPanel.LightPosition._x);

                GL.Rotate(90.0f, 1, 0, 0);

                float azimuth = ModelPanel.LightPosition._y.Clamp180Deg();
                float elevation = ModelPanel.LightPosition._z.Clamp180Deg();

                if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0)
                {
                    azimuth = 0;
                    elevation = 0;
                }

                int i; float x;
                float e = azimuth;

                bool flip = false;
                if (e < 0)
                {
                    e = -e;
                    flip = true;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                float f = (float)((int)e);
                float diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }
                GL.End();

                if (flip) GL.Rotate(-180.0f, 1, 0, 0);

                GL.Rotate(90.0f, 0, 1, 0);
                GL.Rotate(90.0f, 0, 0, 1);
                GL.Rotate(180.0f, 1, 0, 0);
                GL.Rotate(90.0f - azimuth, 0, 1, 0);

                e = elevation;

                if (e < 0)
                {
                    e = -e;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                f = (float)((int)e);
                diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }

                GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                GL.Color4(Color.Orange);
                GL.Vertex3(0, 0, 0);

                GL.End();
            }

            GL.Clear(ClearBufferMask.DepthBufferBit);

            RenderSCN0Controls(context);
            RenderTransformControl(context);

            if (!ModelPanel._grabbing && !ModelPanel._scrolling && !_playing)
            {
                GL.Color4(Color.Black);
                GL.ColorMask(false, false, false, false);

                if (RenderVertices)
                    if (_editingAll && _targetModels != null)
                        foreach (MDL0Node m in _targetModels)
                            m.RenderVertices(context, true);
                    else if (TargetModel != null)
                        TargetModel.RenderVertices(context, true);

                if (RenderBones)
                {
                    //Render invisible depth orbs
                    GLDisplayList list = context.GetSphereList();
                    if (_editingAll)
                    {
                        foreach (MDL0Node m in _targetModels)
                            foreach (MDL0BoneNode bone in m._linker.BoneCache)
                                if (bone != SelectedBone)
                                    RenderOrb(bone, list);
                    }
                    else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null)
                        foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache)
                            if (bone != SelectedBone)
                                RenderOrb(bone, list);
                }

                //Render invisible depth planes for translation and scale controls
                if (_editType != TransformType.Rotation && ((SelectedBone != null && RenderBones) || (VertexLoc != null && RenderVertices)))
                {
                    #region Axis Selection Display List

                    GLDisplayList selList = new GLDisplayList();

                    selList.Begin();

                    GL.Begin(BeginMode.Quads);

                    //X Axis
                    //XY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f);
                    //XZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange);

                    //Y Axis
                    //YX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f);
                    GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f);
                    //YZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange);

                    //Z Axis
                    //ZX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist);
                    GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist);
                    //ZY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, _axisLDist);
                    GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist);

                    GL.End();

                    selList.End();

                    #endregion

                    if (_editType != TransformType.Rotation && SelectedBone != null)
                    {
                        Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc);
                        GL.PushMatrix();
                        GL.MultMatrix((float*)&m);

                        selList.Call();

                        if (_editType == TransformType.Translation)
                        {
                            GL.Begin(BeginMode.Quads);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);
                            GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);
                            GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);

                            GL.End();
                        }
                        else
                        {
                            GL.Begin(BeginMode.Triangles);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange);
                            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist);
                            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

                            GL.End();
                        }

                        GL.PopMatrix();
                    }

                    if (VertexLoc != null && RenderVertices)
                    {
                        Matrix m = Matrix.TransformMatrix(new Vector3(VertexOrbRadius), new Vector3(), ((Vector3)VertexLoc));
                        GL.PushMatrix();
                        GL.MultMatrix((float*)&m);

                        selList.Call();

                        GL.Begin(BeginMode.Quads);

                        //XY
                        GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                        GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f);
                        GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);
                        GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);

                        //YZ
                        GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                        GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange);
                        GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);
                        GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);

                        //XZ
                        GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                        GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist);
                        GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);
                        GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);

                        GL.End();

                        GL.PopMatrix();
                    }
                }

                GL.ColorMask(true, true, true, true);
            }
        }
        public GLDisplayList GetScaleControl()
        {
            //Create the axes.
            GLDisplayList axis = new GLDisplayList();
            axis.Begin();

            //Disable culling so square bases for the arrows aren't necessary to draw
            GL.Disable(EnableCap.CullFace);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            GL.Begin(BeginMode.Lines);

            //X
            if ((_snapY && _snapZ) || (_hiY && _hiZ))
                GL.Color4(Color.Yellow);
            else
                GL.Color4(Color.Red);
            GL.Vertex3(0.0f, _scaleHalf1LDist, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _scaleHalf1LDist);
            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);

            if (_snapX || _hiX)
                GL.Color4(Color.Yellow);
            else
                GL.Color4(Color.Red);

            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(_dst, 0.0f, 0.0f);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, _apthm, -_apthm);
            GL.Vertex3(_dst, _apthm, _apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, -_apthm, _apthm);
            GL.Vertex3(_dst, -_apthm, -_apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, _apthm, _apthm);
            GL.Vertex3(_dst, -_apthm, _apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, -_apthm, -_apthm);
            GL.Vertex3(_dst, _apthm, -_apthm);

            GL.End();

            GL.Begin(BeginMode.Lines);

            //Y
            if ((_snapZ && _snapX) || (_hiZ && _hiX))
                GL.Color4(Color.Yellow);
            else
                GL.Color4(Color.Green);
            GL.Vertex3(0.0f, 0.0f, _scaleHalf1LDist);
            GL.Vertex3(_scaleHalf1LDist, 0.0f, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);
            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

            if (_snapY || _hiY)
                GL.Color4(Color.Yellow);
            else
                GL.Color4(Color.Green);
            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(0.0f, _dst, 0.0f);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(_apthm, _dst, -_apthm);
            GL.Vertex3(_apthm, _dst, _apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(-_apthm, _dst, _apthm);
            GL.Vertex3(-_apthm, _dst, -_apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(_apthm, _dst, _apthm);
            GL.Vertex3(-_apthm, _dst, _apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(-_apthm, _dst, -_apthm);
            GL.Vertex3(_apthm, _dst, -_apthm);

            GL.End();

            GL.Begin(BeginMode.Lines);

            //Z
            if ((_snapX && _snapY) || (_hiX && _hiY))
                GL.Color4(Color.Yellow);
            else
                GL.Color4(Color.Blue);
            GL.Vertex3(0.0f, _scaleHalf1LDist, 0.0f);
            GL.Vertex3(_scaleHalf1LDist, 0.0f, 0.0f);
            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);
            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

            if (_snapZ || _hiZ)
                GL.Color4(Color.Yellow);
            else
                GL.Color4(Color.Blue);
            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _dst);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(_apthm, -_apthm, _dst);
            GL.Vertex3(_apthm, _apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(-_apthm, _apthm, _dst);
            GL.Vertex3(-_apthm, -_apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(_apthm, _apthm, _dst);
            GL.Vertex3(-_apthm, _apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(-_apthm, -_apthm, _dst);
            GL.Vertex3(_apthm, -_apthm, _dst);

            GL.End();

            axis.End();

            return axis;
        }
Example #17
0
        public GLDisplayList GetTranslationAxes(SelectionParams selection)
        {
            //Create the axes.
            GLDisplayList axis = new GLDisplayList();

            axis.Begin();

            //Disable culling so square bases for the arrows aren't necessary to draw
            GL.Disable(EnableCap.CullFace);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            GL.Begin(BeginMode.Lines);

            //X

            if (selection._snapX && selection._snapY || selection._hiX && selection._hiY)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }

            GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);
            GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);

            if (selection._snapX && selection._snapZ || selection._hiX && selection._hiZ)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }

            GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);
            GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);

            if (selection._snapX || selection._hiX)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }

            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(_dst, 0.0f, 0.0f);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, _apthm, -_apthm);
            GL.Vertex3(_dst, _apthm, _apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, -_apthm, _apthm);
            GL.Vertex3(_dst, -_apthm, -_apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, _apthm, _apthm);
            GL.Vertex3(_dst, -_apthm, _apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, -_apthm, -_apthm);
            GL.Vertex3(_dst, _apthm, -_apthm);

            GL.End();

            GL.Begin(BeginMode.Lines);

            //Y

            if (selection._snapY && selection._snapX || selection._hiY && selection._hiX)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }

            GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);
            GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);

            if (selection._snapY && selection._snapZ || selection._hiY && selection._hiZ)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }

            GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);
            GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);

            if (selection._snapY || selection._hiY)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }

            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(0.0f, _dst, 0.0f);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(_apthm, _dst, -_apthm);
            GL.Vertex3(_apthm, _dst, _apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(-_apthm, _dst, _apthm);
            GL.Vertex3(-_apthm, _dst, -_apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(_apthm, _dst, _apthm);
            GL.Vertex3(-_apthm, _dst, _apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(-_apthm, _dst, -_apthm);
            GL.Vertex3(_apthm, _dst, -_apthm);

            GL.End();

            GL.Begin(BeginMode.Lines);

            //Z

            if (selection._snapZ && selection._snapX || selection._hiZ && selection._hiX)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Blue);
            }

            GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);
            GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);

            if (selection._snapZ && selection._snapY || selection._hiZ && selection._hiY)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Blue);
            }

            GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);
            GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);

            if (selection._snapZ || selection._hiZ)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Blue);
            }

            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _dst);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(_apthm, -_apthm, _dst);
            GL.Vertex3(_apthm, _apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(-_apthm, _apthm, _dst);
            GL.Vertex3(-_apthm, -_apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(_apthm, _apthm, _dst);
            GL.Vertex3(-_apthm, _apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(-_apthm, -_apthm, _dst);
            GL.Vertex3(_apthm, -_apthm, _dst);

            GL.End();

            axis.End();

            return(axis);
        }
Example #18
0
        public virtual unsafe void RenderDepth(ModelPanelViewport v)
        {
            if (v._grabbing || v._scrolling || _playing)
            {
                return;
            }

            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Always);

            GL.Color4(Color.Black);
#if DEBUG
            GL.ColorMask(_renderDepth, false, false, false);
#else
            GL.ColorMask(false, false, false, false);
#endif

            if (v._renderAttrib._renderVertices)
            {
                if (EditingAll && _targetModels != null)
                {
                    foreach (IModel m in _targetModels)
                    {
                        m.RenderVertices(true, SelectedBone, v.Camera);
                    }
                }
                else
                {
                    TargetModel?.RenderVertices(true, SelectedBone, v.Camera);
                }
            }

            if (v._renderAttrib._renderBones)
            {
                //Render invisible depth orbs
                GLDisplayList list    = TKContext.GetSphereList();
                bool          doScale = v._renderAttrib._scaleBones;
                if (EditingAll)
                {
                    foreach (IModel m in _targetModels)
                    {
                        foreach (IBoneNode bone in m.BoneCache)
                        {
                            if (bone != SelectedBone)
                            {
                                RenderOrb(bone, list, v, doScale);
                            }
                        }
                    }
                }
                else if (TargetModel != null)
                {
                    foreach (IBoneNode bone in _targetModel.BoneCache)
                    {
                        if (bone != SelectedBone)
                        {
                            RenderOrb(bone, list, v, doScale);
                        }
                    }
                }
            }

            GL.ColorMask(true, true, true, true);
        }
Example #19
0
        public static unsafe void OnRenderLightDisplay(ModelPanelViewport v)
        {
            GL.PushAttrib(AttribMask.AllAttribBits);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.PushMatrix();

            GL.Color4(Color.Blue);
            GL.Disable(EnableCap.Lighting);
            //GL.Disable(EnableCap.DepthTest);

            Vector4 lightPos = v.LightPosition;

            if (!v.LightDirectional)
            {
                GL.Enable(EnableCap.DepthTest);

                Vector3 pos = (Vector3)v._posLight;

                GLDisplayList list = TKContext.GetSphereList();
                GL.Translate((OpenTK.Vector3)pos);

                GL.Color4(Color.FromArgb(120, 100, 100, 255));

                //Matrix m = CameraFacingRotationMatrix(v.Camera, pos);
                //GL.MultMatrix((float*)&m);

                GL.Scale(lightPos._x, lightPos._x, lightPos._x);

                list.Call();
            }
            else
            {
                GL.Disable(EnableCap.DepthTest);

                GL.Scale(lightPos._x, lightPos._x, lightPos._x);

                GL.Rotate(90.0f, 1, 0, 0);

                float
                    azimuth   = lightPos._y.RemapToRange(-180.0f, 180.0f),
                    elevation = lightPos._z.RemapToRange(-180.0f, 180.0f);

                if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0)
                {
                    azimuth   = 0;
                    elevation = 0;
                }

                int   i;
                float e = azimuth, x;

                bool flip = false;
                if (e < 0)
                {
                    e    = -e;
                    flip = true;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                float f    = (int)e;
                float diff = (float)Math.Round(e - f, 1);

                GL.Begin(BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }

                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + i) * Maths._deg2radf), Math.Sin((x + i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + i) * Maths._deg2radf), Math.Sin((x + 0.1f + i) * Maths._deg2radf));
                }

                GL.End();

                if (flip)
                {
                    GL.Rotate(-180.0f, 1, 0, 0);
                }

                GL.Rotate(90.0f, 0, 1, 0);
                GL.Rotate(90.0f, 0, 0, 1);
                GL.Rotate(180.0f, 1, 0, 0);
                GL.Rotate(90.0f - azimuth, 0, 1, 0);

                e = elevation;

                if (e < 0)
                {
                    e = -e;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                f    = (int)e;
                diff = (float)Math.Round(e - f, 1);

                GL.Begin(BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }

                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + i) * Maths._deg2radf), Math.Sin((x + i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + i) * Maths._deg2radf), Math.Sin((x + 0.1f + i) * Maths._deg2radf));
                }

                GL.Vertex2(Math.Cos((x + i) * Maths._deg2radf), Math.Sin((x + i) * Maths._deg2radf));
                GL.Color4(Color.Orange);
                GL.Vertex3(0, 0, 0);
                GL.End();

                GL.Scale(0.01f, 0.01f, 0.01f);
                GL.Rotate(azimuth, 0, 1, 0);
                GL.Enable(EnableCap.DepthTest);

                GL.PopAttrib();
                GL.PopMatrix();
            }
        }
Example #20
0
        public unsafe void RenderRotationControl(
            Vector3 position,
            float radius,
            Matrix rotation,
            ModelPanelViewport panel,
            SelectionParams selection)
        {
            Matrix m = Matrix.TransformMatrix(new Vector3(radius), new Vector3(), position) *
                       CameraFacingRotationMatrix(panel, position);

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            GLDisplayList sphere = TKContext.GetCircleList();
            GLDisplayList circle = TKContext.GetRingList();

            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            GL.PushAttrib(AttribMask.DepthBufferBit);
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Lequal);

            //Orb
            GL.Color4(0.7f, 0.7f, 0.7f, 0.15f);
            sphere.Call();

            GL.Disable(EnableCap.DepthTest);

            //Container
            GL.Color4(0.4f, 0.4f, 0.4f, 1.0f);
            circle.Call();

            //Circ
            if (selection._snapCirc || selection._hiCirc)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(1.0f, 0.8f, 0.5f, 1.0f);
            }

            GL.Scale(_circOrbScale, _circOrbScale, _circOrbScale);
            circle.Call();

            //Pop
            GL.PopMatrix();

            GL.Enable(EnableCap.DepthTest);

            //Enter local space
            m = Matrix.TransformMatrix(new Vector3(radius), new Vector3(), position) * rotation;

            panel.SettingsScreenText["X"] =
                panel.Camera.Project(new Vector3(1.1f, 0, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            panel.SettingsScreenText["Y"] =
                panel.Camera.Project(new Vector3(0, 1.1f, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            panel.SettingsScreenText["Z"] =
                panel.Camera.Project(new Vector3(0, 0, 1.1f) * m) - new Vector3(8.0f, 8.0f, 0);

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            //Z
            if (selection._snapZ || selection._hiZ)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(0.0f, 0.0f, 1.0f, 1.0f);
            }

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

            //X
            if (selection._snapX || selection._hiX)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }

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

            //Y
            if (selection._snapY || selection._hiY)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }

            circle.Call();

            //Pop
            GL.PopMatrix();

            GL.PopAttrib();
        }
Example #21
0
        public unsafe void RenderRotationControl(TKContext context, Vector3 position, float radius, Vector3 rotate)
        {
            Matrix m = Matrix.TransformMatrix(new Vector3(radius), position.LookatAngles(CamLoc) * Maths._rad2degf, position);

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            GLDisplayList sphere = context.GetCircleList();
            GLDisplayList circle = context.GetRingList();

            //Orb
            GL.Color4(0.7f, 0.7f, 0.7f, 0.15f);
            sphere.Call();

            GL.Disable(EnableCap.DepthTest);

            //Container
            GL.Color4(0.4f, 0.4f, 0.4f, 1.0f);
            circle.Call();

            //Circ
            if (_snapCirc || _hiCirc)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(1.0f, 0.8f, 0.5f, 1.0f);
            }
            GL.Scale(_circOrbScale, _circOrbScale, _circOrbScale);
            circle.Call();

            //Pop
            GL.PopMatrix();

            GL.Enable(EnableCap.DepthTest);

            //Enter local space
            m = Matrix.TransformMatrix(new Vector3(radius), rotate, position);

            ModelPanel.ScreenText["X"] = ModelPanel.Project(new Vector3(1.1f, 0, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            ModelPanel.ScreenText["Y"] = ModelPanel.Project(new Vector3(0, 1.1f, 0) * m) - new Vector3(8.0f, 8.0f, 0);
            ModelPanel.ScreenText["Z"] = ModelPanel.Project(new Vector3(0, 0, 1.1f) * m) - new Vector3(8.0f, 8.0f, 0);

            GL.PushMatrix();
            GL.MultMatrix((float *)&m);

            //Z
            if (_snapZ || _hiZ)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(0.0f, 0.0f, 1.0f, 1.0f);
            }

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

            //X
            if (_snapX || _hiX)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }

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

            //Y
            if (_snapY || _hiY)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }

            circle.Call();

            //Pop
            GL.PopMatrix();
        }
Example #22
0
        private unsafe void modelPanel1_PostRender(object sender, TKContext context)
        {
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.Lighting);
            GL.Enable(EnableCap.DepthTest);

            if (RenderVertices)
            {
                if (_editingAll && _targetModels != null)
                {
                    foreach (MDL0Node m in _targetModels)
                    {
                        m.RenderVertices(context, false);
                    }
                }
                else if (TargetModel != null)
                {
                    TargetModel.RenderVertices(context, false);
                }
            }

            if (RenderNormals)
            {
                if (_editingAll && _targetModels != null)
                {
                    foreach (MDL0Node m in _targetModels)
                    {
                        m.RenderNormals(context);
                    }
                }
                else if (TargetModel != null)
                {
                    TargetModel.RenderNormals(context);
                }
            }

            //Show the user where the light source is
            if (_renderLightDisplay)
            {
                GL.Color4(Color.Blue);
                GL.Disable(EnableCap.Lighting);
                GL.Disable(EnableCap.DepthTest);

                GL.Scale(ModelPanel.LightPosition._x, ModelPanel.LightPosition._x, ModelPanel.LightPosition._x);

                GL.Rotate(90.0f, 1, 0, 0);

                float azimuth   = ModelPanel.LightPosition._y.Clamp180Deg();
                float elevation = ModelPanel.LightPosition._z.Clamp180Deg();

                if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0)
                {
                    azimuth   = 0;
                    elevation = 0;
                }

                int   i; float x;
                float e = azimuth;

                bool flip = false;
                if (e < 0)
                {
                    e    = -e;
                    flip = true;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                float f    = (float)((int)e);
                float diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }
                GL.End();

                if (flip)
                {
                    GL.Rotate(-180.0f, 1, 0, 0);
                }

                GL.Rotate(90.0f, 0, 1, 0);
                GL.Rotate(90.0f, 0, 0, 1);
                GL.Rotate(180.0f, 1, 0, 0);
                GL.Rotate(90.0f - azimuth, 0, 1, 0);

                e = elevation;

                if (e < 0)
                {
                    e = -e;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                f    = (float)((int)e);
                diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }

                GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                GL.Color4(Color.Orange);
                GL.Vertex3(0, 0, 0);

                GL.End();
            }

            GL.Clear(ClearBufferMask.DepthBufferBit);

            RenderSCN0Controls(context);
            RenderTransformControl(context);

            if (!ModelPanel._grabbing && !ModelPanel._scrolling && !_playing)
            {
                GL.Color4(Color.Black);
                GL.ColorMask(false, false, false, false);

                if (RenderVertices)
                {
                    if (_editingAll && _targetModels != null)
                    {
                        foreach (MDL0Node m in _targetModels)
                        {
                            m.RenderVertices(context, true);
                        }
                    }
                    else if (TargetModel != null)
                    {
                        TargetModel.RenderVertices(context, true);
                    }
                }

                if (RenderBones)
                {
                    //Render invisible depth orbs
                    GLDisplayList list = context.GetSphereList();
                    if (_editingAll)
                    {
                        foreach (MDL0Node m in _targetModels)
                        {
                            foreach (MDL0BoneNode bone in m._linker.BoneCache)
                            {
                                if (bone != SelectedBone)
                                {
                                    RenderOrb(bone, list);
                                }
                            }
                        }
                    }
                    else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null)
                    {
                        foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache)
                        {
                            if (bone != SelectedBone)
                            {
                                RenderOrb(bone, list);
                            }
                        }
                    }
                }

                //Render invisible depth planes for translation and scale controls
                if (_editType != TransformType.Rotation && ((SelectedBone != null && RenderBones) || (VertexLoc != null && RenderVertices)))
                {
                    #region Axis Selection Display List

                    GLDisplayList selList = new GLDisplayList();

                    selList.Begin();

                    GL.Begin(BeginMode.Quads);

                    //X Axis
                    //XY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f);
                    //XZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange);

                    //Y Axis
                    //YX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f);
                    GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f);
                    //YZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange);

                    //Z Axis
                    //ZX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist);
                    GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist);
                    //ZY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, _axisLDist);
                    GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist);

                    GL.End();

                    selList.End();

                    #endregion

                    if (_editType != TransformType.Rotation && SelectedBone != null)
                    {
                        Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc);
                        GL.PushMatrix();
                        GL.MultMatrix((float *)&m);

                        selList.Call();

                        if (_editType == TransformType.Translation)
                        {
                            GL.Begin(BeginMode.Quads);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);
                            GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);
                            GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);

                            GL.End();
                        }
                        else
                        {
                            GL.Begin(BeginMode.Triangles);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange);
                            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist);
                            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

                            GL.End();
                        }

                        GL.PopMatrix();
                    }

                    if (VertexLoc != null && RenderVertices)
                    {
                        Matrix m = Matrix.TransformMatrix(new Vector3(VertexOrbRadius), new Vector3(), ((Vector3)VertexLoc));
                        GL.PushMatrix();
                        GL.MultMatrix((float *)&m);

                        selList.Call();

                        GL.Begin(BeginMode.Quads);

                        //XY
                        GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                        GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f);
                        GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);
                        GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);

                        //YZ
                        GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                        GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange);
                        GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);
                        GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);

                        //XZ
                        GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                        GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist);
                        GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);
                        GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);

                        GL.End();

                        GL.PopMatrix();
                    }
                }

                GL.ColorMask(true, true, true, true);
            }
        }
Example #23
0
        private unsafe void RenderOffensiveCollision(Vector3 cam)
        {
            MovesetNode node = Root;

            ResourceNode[] bl = _model._linker.BoneCache;

            int boneindex = (int)_parameters[0] >> 16;
            int size      = HitboxSize;
            int angle     = _parameters[2];

            node.GetBoneIndex(ref boneindex);

            if (boneindex == 0) //If a hitbox is on TopN, make it follow TransN
            {
                //Use assigned references
                if (node.Data != null)
                {
                    boneindex = node.Data._misc._boneRefs[4].boneIndex;
                    node.GetBoneIndex(ref boneindex);
                }
                else //Search manually
                {
                    int transindex = 0;
                    foreach (MDL0BoneNode bn in bl)
                    {
                        if (bn.Name.Equals("TransN"))
                        {
                            break;
                        }
                        transindex++;
                    }
                    if (transindex != bl.Length)
                    {
                        boneindex = transindex;
                    }
                }
            }

            MDL0BoneNode b;

            b = bl[boneindex] as MDL0BoneNode;

            Matrix     r         = b.Matrix.GetRotationMatrix();
            FrameState state     = b.Matrix.Derive();
            Vector3    bonePos   = state._translate;
            Vector3    globalPos = r.Multiply(new Vector3(Util.UnScalar(_parameters[6]), Util.UnScalar(_parameters[7]), Util.UnScalar(_parameters[8])) / state._scale);

            Matrix  m         = Matrix.TransformMatrix(new Vector3(1), state._rotate, globalPos + bonePos);
            Vector3 resultPos = m.GetPoint();

            int id = (int)_parameters[0] & 0xFFFF;

            RunTime.MainWindow.ModelPanel.CurrentViewport.ScreenText[id.ToString()] =
                RunTime.MainWindow.ModelPanel.CurrentViewport.Camera.Project(resultPos);

            m = Matrix.TransformMatrix(new Vector3(Util.UnScalar(size)), new Vector3(), resultPos);
            GL.PushMatrix();
            GL.MultMatrix((float *)&m);
            int    res       = 16;
            double drawAngle = 360.0 / res;

            Vector3 color = Util.GetTypeColor(flags.Type);

            GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.5f);

            GLDisplayList spheres = TKContext.GetSphereList();

            spheres.Call();

            //Angle indicator
            double rangle = angle / 180.0 * Math.PI;

            //Apply color
            color = Util.GetEffectColor(flags.Effect);
            GL.Color4((color._x / 255.0f), (color._y / 225.0f), (color._z / 255.0f), 0.75f);

            GL.PushMatrix();
            if (angle == 361) //Sakurai angle
            {
                m = Matrix.TransformMatrix(new Vector3(0.5f), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3(0));
                GL.MultMatrix((float *)&m);
                GL.Begin(BeginMode.Quads);
                for (int i = 0; i < 16; i += 2)
                {
                    GL.Vertex3(Math.Cos((i - 1) * Math.PI / 8) * 0.5, Math.Sin((i - 1) * Math.PI / 8) * 0.5, 0);
                    GL.Vertex3(Math.Cos(i * Math.PI / 8), Math.Sin(i * Math.PI / 8), 0);
                    GL.Vertex3(Math.Cos((i + 1) * Math.PI / 8) * 0.5, Math.Sin((i + 1) * Math.PI / 8) * 0.5, 0);
                    GL.Vertex3(0, 0, 0);
                }
                GL.End();
            }
            else
            {
                long a         = -angle; //Otherwise 90 would point down
                int  angleflip = 0;
                if (resultPos._z < 0)
                {
                    angleflip = 180;
                }
                m = Matrix.TransformMatrix(new Vector3(1), new Vector3(a, angleflip, 0), new Vector3());
                GL.MultMatrix((float *)&m);
                GL.Begin(BeginMode.Quads);
                // left face
                GL.Vertex3(0.1, 0.1, 0);
                GL.Vertex3(0.1, 0.1, 1);
                GL.Vertex3(0.1, -0.1, 1);
                GL.Vertex3(0.1, -0.1, 0);
                // right face
                GL.Vertex3(-0.1, -0.1, 0);
                GL.Vertex3(-0.1, -0.1, 1);
                GL.Vertex3(-0.1, 0.1, 1);
                GL.Vertex3(-0.1, 0.1, 0);
                // top face
                GL.Vertex3(-0.1, 0.1, 0);
                GL.Vertex3(-0.1, 0.1, 1);
                GL.Vertex3(0.1, 0.1, 1);
                GL.Vertex3(0.1, 0.1, 0);
                // bottom face
                GL.Vertex3(0.1, -0.1, 0);
                GL.Vertex3(0.1, -0.1, 1);
                GL.Vertex3(-0.1, -0.1, 1);
                GL.Vertex3(-0.1, -0.1, 0);
                // front face
                GL.Vertex3(-0.1, -0.1, 1);
                GL.Vertex3(0.1, -0.1, 1);
                GL.Vertex3(0.1, 0.1, 1);
                GL.Vertex3(-0.1, 0.1, 1);
                // back face
                GL.Vertex3(-0.1, 0.1, 0);
                GL.Vertex3(0.1, 0.1, 0);
                GL.Vertex3(0.1, -0.1, 0);
                GL.Vertex3(-0.1, -0.1, 0);
                GL.End();
            }
            GL.PopMatrix();

            // border
            GLDisplayList rings = TKContext.GetRingList();

            for (int i = -5; i <= 5; i++)
            {
                GL.PushMatrix();
                m = Matrix.TransformMatrix(new Vector3(1 + 0.0025f * i), (globalPos + bonePos).LookatAngles(cam) * Maths._rad2degf, new Vector3());
                GL.MultMatrix((float *)&m);
                if (flags.Clang)
                {
                    rings.Call();
                }
                else
                {
                    for (double j = 0; j < 360 / (drawAngle / 2); j += 2)
                    {
                        double ang1 = (j * (drawAngle / 2)) / 180 * Math.PI;
                        double ang2 = ((j + 1) * (drawAngle / 2)) / 180 * Math.PI;
                        GL.Begin(BeginMode.LineStrip);
                        GL.Vertex3(Math.Cos(ang1), Math.Sin(ang1), 0);
                        GL.Vertex3(Math.Cos(ang2), Math.Sin(ang2), 0);
                        GL.End();
                    }
                }
                GL.PopMatrix();
            }

            GL.PopMatrix();
            GL.PopMatrix();
        }
        private unsafe void modelPanel1_PostRender(object sender, TKContext context)
        {
            //GL.LineWidth(2.0f);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.DepthTest);

            //Attributes.PostRender();

            //Render hurtboxes
            if (chkHurtboxes.Checked)
                for (int i = 0; i < listPanel.lstHurtboxes.Items.Count; i++)
                    if (listPanel.lstHurtboxes.GetItemChecked(i))
                        ((MiscHurtBox)listPanel.lstHurtboxes.Items[i]).Render(SelectedHurtbox != null && SelectedHurtbox.Index == i, Scriptor._hurtBoxType);

            //Render hitboxes
            if (chkHitboxes.Checked && Manager.Moveset != null)
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                GLDisplayList c = context.GetRingList();
                GLDisplayList s = context.GetSphereList();

                foreach (HitBox e in RunTime._hitBoxes)
                    e.Render(context, modelPanel._camera.GetPoint());
            }

            GL.Enable(EnableCap.DepthTest);

            //Show the user where the light source is
            if (_renderLightDisplay)
            {
                GL.PushAttrib(AttribMask.AllAttribBits);

                GL.Color4(Color.Blue);
                GL.Disable(EnableCap.Lighting);
                GL.Disable(EnableCap.DepthTest);

                GL.Scale(modelPanel.LightPosition._x, modelPanel.LightPosition._x, modelPanel.LightPosition._x);

                GL.Rotate(90.0f, 1, 0, 0);

                float azimuth = modelPanel.LightPosition._y.Clamp180Deg();
                float elevation = modelPanel.LightPosition._z.Clamp180Deg();

                if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0)
                {
                    azimuth = 0;
                    elevation = 0;
                }

                int i; float x;
                float e = azimuth;

                bool flip = false;
                if (e < 0)
                {
                    e = -e;
                    flip = true;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                float f = (float)((int)e);
                float diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }
                GL.End();

                if (flip) GL.Rotate(-180.0f, 1, 0, 0);

                GL.Rotate(90.0f, 0, 1, 0);
                GL.Rotate(90.0f, 0, 0, 1);
                GL.Rotate(180.0f, 1, 0, 0);
                GL.Rotate(90.0f - azimuth, 0, 1, 0);

                e = elevation;

                if (e < 0)
                {
                    e = -e;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                f = (float)((int)e);
                diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }

                GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                GL.Color4(Color.Orange);
                GL.Vertex3(0, 0, 0);

                GL.End();

                GL.PopAttrib();
            }

            GL.Clear(ClearBufferMask.DepthBufferBit);

            RenderTransformControl(context);

            if (!modelPanel._grabbing && !modelPanel._scrolling && !_playing)
            {
                GL.Color4(Color.Black);
                GL.ColorMask(false, false, false, false);

                if (RenderBones)
                {
                    //Render invisible depth orbs
                    GLDisplayList list = context.GetSphereList();
                    if (_editingAll)
                    {
                        foreach (MDL0Node m in _targetModels)
                            foreach (MDL0BoneNode bone in m._linker.BoneCache)
                                if (bone != SelectedBone)
                                    RenderOrb(bone, list);
                    }
                    else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null)
                        foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache)
                            if (bone != SelectedBone)
                                RenderOrb(bone, list);
                }

                //Render invisible depth planes for translation and scale controls
                if (_editType != 0 && SelectedBone != null && RenderBones)
                {
                    #region Axis Selection Display List

                    GLDisplayList selList = new GLDisplayList();

                    selList.Begin();

                    GL.Begin(BeginMode.Quads);

                    //X Axis
                    //XY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f);
                    //XZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange);

                    //Y Axis
                    //YX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f);
                    GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f);
                    //YZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange);

                    //Z Axis
                    //ZX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist);
                    GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist);
                    //ZY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, _axisLDist);
                    GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist);

                    GL.End();

                    selList.End();

                    #endregion

                    if (_editType != 0 && SelectedBone != null)
                    {
                        Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc);
                        GL.PushMatrix();
                        GL.MultMatrix((float*)&m);

                        selList.Call();

                        if (_editType == TransformType.Translation)
                        {
                            GL.Begin(BeginMode.Quads);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);
                            GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);
                            GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);

                            GL.End();
                        }
                        else
                        {
                            GL.Begin(BeginMode.Triangles);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange);
                            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist);
                            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

                            GL.End();
                        }

                        GL.PopMatrix();
                    }
                }
                GL.ColorMask(true, true, true, true);
            }
        }
Example #25
0
        public GLDisplayList GetScaleControl()
        {
            //Create the axes.
            GLDisplayList axis = new GLDisplayList();

            axis.Begin();

            //Disable culling so square bases for the arrows aren't necessary to draw
            GL.Disable(EnableCap.CullFace);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);

            GL.Begin(BeginMode.Lines);

            //X
            if ((_snapY && _snapZ) || (_hiY && _hiZ))
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }
            GL.Vertex3(0.0f, _scaleHalf1LDist, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _scaleHalf1LDist);
            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);

            if (_snapX || _hiX)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Red);
            }

            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(_dst, 0.0f, 0.0f);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, _apthm, -_apthm);
            GL.Vertex3(_dst, _apthm, _apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, -_apthm, _apthm);
            GL.Vertex3(_dst, -_apthm, -_apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, _apthm, _apthm);
            GL.Vertex3(_dst, -_apthm, _apthm);

            GL.Vertex3(_axisLDist, 0.0f, 0.0f);
            GL.Vertex3(_dst, -_apthm, -_apthm);
            GL.Vertex3(_dst, _apthm, -_apthm);

            GL.End();

            GL.Begin(BeginMode.Lines);

            //Y
            if ((_snapZ && _snapX) || (_hiZ && _hiX))
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }
            GL.Vertex3(0.0f, 0.0f, _scaleHalf1LDist);
            GL.Vertex3(_scaleHalf1LDist, 0.0f, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);
            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

            if (_snapY || _hiY)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Green);
            }
            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(0.0f, _dst, 0.0f);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(_apthm, _dst, -_apthm);
            GL.Vertex3(_apthm, _dst, _apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(-_apthm, _dst, _apthm);
            GL.Vertex3(-_apthm, _dst, -_apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(_apthm, _dst, _apthm);
            GL.Vertex3(-_apthm, _dst, _apthm);

            GL.Vertex3(0.0f, _axisLDist, 0.0f);
            GL.Vertex3(-_apthm, _dst, -_apthm);
            GL.Vertex3(_apthm, _dst, -_apthm);

            GL.End();

            GL.Begin(BeginMode.Lines);

            //Z
            if ((_snapX && _snapY) || (_hiX && _hiY))
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Blue);
            }
            GL.Vertex3(0.0f, _scaleHalf1LDist, 0.0f);
            GL.Vertex3(_scaleHalf1LDist, 0.0f, 0.0f);
            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);
            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

            if (_snapZ || _hiZ)
            {
                GL.Color4(Color.Yellow);
            }
            else
            {
                GL.Color4(Color.Blue);
            }
            GL.Vertex3(0.0f, 0.0f, 0.0f);
            GL.Vertex3(0.0f, 0.0f, _dst);

            GL.End();

            GL.Begin(BeginMode.Triangles);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(_apthm, -_apthm, _dst);
            GL.Vertex3(_apthm, _apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(-_apthm, _apthm, _dst);
            GL.Vertex3(-_apthm, -_apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(_apthm, _apthm, _dst);
            GL.Vertex3(-_apthm, _apthm, _dst);

            GL.Vertex3(0.0f, 0.0f, _axisLDist);
            GL.Vertex3(-_apthm, -_apthm, _dst);
            GL.Vertex3(_apthm, -_apthm, _dst);

            GL.End();

            axis.End();

            return(axis);
        }
        private unsafe void modelPanel1_PostRender(object sender, GLContext context)
        {
            context.glClear(GLClearMask.DepthBuffer);
            context.glEnable(GLEnableCap.DepthTest);

            if (pnlAssets.SelectedBone != null)
            {
                context.glDisable((uint)GLEnableCap.Lighting);

                //Render rotation orb
                MDL0BoneNode  bone   = pnlAssets.SelectedBone;
                GLDisplayList circle = context.GetRingList();
                GLDisplayList sphere = context.GetCircleList();
                Matrix        m;

                //Prepare camera-facing matrix
                Vector3 center = bone._frameMatrix.GetPoint();
                Vector3 cam    = modelPanel1._camera.GetPoint();
                float   radius = center.TrueDistance(cam) / _orbRadius * 0.1f;

                m = Matrix.TransformMatrix(new Vector3(radius), center.LookatAngles(cam) * Maths._rad2degf, center);
                context.glPushMatrix();
                context.glMultMatrix((float *)&m);

                //Orb
                context.glColor(0.7f, 0.7f, 0.7f, 0.15f);
                sphere.Call();

                context.glDisable((uint)GLEnableCap.DepthTest);

                //Container
                context.glColor(0.4f, 0.4f, 0.4f, 1.0f);
                circle.Call();

                //Circ
                if (_snapCirc)
                {
                    context.glColor(1.0f, 1.0f, 0.0f, 1.0f);
                }
                else
                {
                    context.glColor(1.0f, 0.8f, 0.5f, 1.0f);
                }
                context.glScale(_circOrbScale, _circOrbScale, _circOrbScale);
                circle.Call();

                //Pop
                context.glPopMatrix();

                context.glEnable(GLEnableCap.DepthTest);

                //Enter local space
                m = Matrix.TransformMatrix(new Vector3(radius), bone._frameMatrix.GetAngles(), center);
                context.glPushMatrix();
                context.glMultMatrix((float *)&m);

                //Z
                if (_snapZ)
                {
                    context.glColor(1.0f, 1.0f, 0.0f, 1.0f);
                }
                else
                {
                    context.glColor(0.0f, 0.0f, 1.0f, 1.0f);
                }
                circle.Call();

                context.glRotate(90.0f, 0.0f, 1.0f, 0.0f);

                //X
                if (_snapX)
                {
                    context.glColor(1.0f, 1.0f, 0.0f, 1.0f);
                }
                else
                {
                    context.glColor(1.0f, 0.0f, 0.0f, 1.0f);
                }
                circle.Call();

                context.glRotate(90.0f, 1.0f, 0.0f, 0.0f);

                //Y
                if (_snapY)
                {
                    context.glColor(1.0f, 1.0f, 0.0f, 1.0f);
                }
                else
                {
                    context.glColor(0.0f, 1.0f, 0.0f, 1.0f);
                }
                circle.Call();

                //Pop
                context.glPopMatrix();

                //Clear depth buffer for next operation
                context.glClear(GLClearMask.DepthBuffer);
            }

            //Render invisible depth orbs
            context.glColorMask(false, false, false, false);

            if (_targetModel != null && _targetModel._boneList != null)
            {
                GLDisplayList list = context.GetSphereList();
                foreach (MDL0BoneNode bone in _targetModel._boneList)
                {
                    RenderOrbRecursive(bone, context, list);
                }
            }

            context.glColorMask(true, true, true, true);
        }
Example #27
0
        internal unsafe void Render(TKContext ctx, ModelPanel mainWindow)
        {
            if (!_render)
            {
                return;
            }

            if (_boneColor != Color.Transparent)
            {
                GL.Color4(_boneColor.R / 255.0f, _boneColor.G / 255.0f, _boneColor.B / 255.0f, 1.0f);
            }
            else
            {
                GL.Color4(DefaultBoneColor.R / 255.0f, DefaultBoneColor.G / 255.0f, DefaultBoneColor.B / 255.0f, 1.0f);
            }

            //GL.LineWidth(1.0f);

            //Draw name if selected
            if (mainWindow != null && _nodeColor != Color.Transparent)
            {
                Vector3 pt = _frameMatrix.GetPoint();
                Vector3 v2 = mainWindow.Project(pt);
                mainWindow.ScreenText[Name] = new Vector3(v2._x, v2._y - 9.0f, v2._z);
            }

            Vector3 v1 = (_parent == null || !(_parent is MDL0BoneNode)) ? new Vector3(0.0f) : ((MDL0BoneNode)_parent)._frameMatrix.GetPoint();
            Vector3 v  = _frameMatrix.GetPoint();

            GL.Begin(BeginMode.Lines);

            GL.Vertex3((float *)&v1);
            GL.Vertex3((float *)&v);

            GL.End();

            GL.PushMatrix();

            fixed(Matrix *m = &_frameMatrix)
            GL.MultMatrix((float *)m);

            //Render node
            GLDisplayList ndl = ctx.FindOrCreate <GLDisplayList>("BoneNodeOrb", CreateNodeOrb);

            if (_nodeColor != Color.Transparent)
            {
                GL.Color4(_nodeColor.R / 255.0f, _nodeColor.G / 255.0f, _nodeColor.B / 255.0f, 1.0f);
            }
            else
            {
                GL.Color4(DefaultNodeColor.R / 255.0f, DefaultNodeColor.G / 255.0f, DefaultNodeColor.B / 255.0f, 1.0f);
            }

            ndl.Call();

            DrawNodeOrients();

            if (BillboardSetting != 0 && mainWindow != null)
            {
                Vector3 center = _frameMatrix.GetPoint();
                Vector3 cam    = mainWindow._camera.GetPoint();
                Matrix  m2     = new Matrix();
                Vector3 scale  = new Vector3(1);
                Vector3 rot    = new Vector3();
                Vector3 trans  = new Vector3();

                if (BillboardSetting == BillboardFlags.PerspectiveSTD)
                {
                    rot = center.LookatAngles(cam) * Maths._rad2degf;
                }

                m2 = Matrix.TransformMatrix(scale, rot, trans);
                GL.PushMatrix();
                GL.MultMatrix((float *)&m2);
            }

            if (BillboardSetting != 0 && mainWindow != null)
            {
                GL.PopMatrix();
            }

            GL.PopMatrix();

            //Render children
            foreach (MDL0BoneNode n in Children)
            {
                n.Render(ctx, mainWindow);
            }
        }
Example #28
0
        private unsafe void modelPanel1_PostRender(object sender, TKContext context)
        {
            //GL.LineWidth(2.0f);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.Lighting);
            GL.Disable(EnableCap.DepthTest);

            //Attributes.PostRender();

            //Render hurtboxes
            if (chkHurtboxes.Checked)
            {
                for (int i = 0; i < listPanel.lstHurtboxes.Items.Count; i++)
                {
                    if (listPanel.lstHurtboxes.GetItemChecked(i))
                    {
                        ((MiscHurtBox)listPanel.lstHurtboxes.Items[i]).Render(SelectedHurtbox != null && SelectedHurtbox.Index == i, Scriptor._hurtBoxType);
                    }
                }
            }

            //Render hitboxes
            if (chkHitboxes.Checked && Manager.Moveset != null)
            {
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                GLDisplayList c = context.GetRingList();
                GLDisplayList s = context.GetSphereList();

                foreach (HitBox e in RunTime._hitBoxes)
                {
                    e.Render(context, modelPanel._camera.GetPoint());
                }
            }

            GL.Enable(EnableCap.DepthTest);

            //Show the user where the light source is
            if (_renderLightDisplay)
            {
                GL.PushAttrib(AttribMask.AllAttribBits);

                GL.Color4(Color.Blue);
                GL.Disable(EnableCap.Lighting);
                GL.Disable(EnableCap.DepthTest);

                GL.Scale(modelPanel.LightPosition._x, modelPanel.LightPosition._x, modelPanel.LightPosition._x);

                GL.Rotate(90.0f, 1, 0, 0);

                float azimuth   = modelPanel.LightPosition._y.Clamp180Deg();
                float elevation = modelPanel.LightPosition._z.Clamp180Deg();

                if (Math.Abs(azimuth) == Math.Abs(elevation) && azimuth % 180.0f == 0 && elevation % 180.0f == 0)
                {
                    azimuth   = 0;
                    elevation = 0;
                }

                int   i; float x;
                float e = azimuth;

                bool flip = false;
                if (e < 0)
                {
                    e    = -e;
                    flip = true;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                float f    = (float)((int)e);
                float diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }
                GL.End();

                if (flip)
                {
                    GL.Rotate(-180.0f, 1, 0, 0);
                }

                GL.Rotate(90.0f, 0, 1, 0);
                GL.Rotate(90.0f, 0, 0, 1);
                GL.Rotate(180.0f, 1, 0, 0);
                GL.Rotate(90.0f - azimuth, 0, 1, 0);

                e = elevation;

                if (e < 0)
                {
                    e = -e;
                    GL.Rotate(180.0f, 1, 0, 0);
                }

                f    = (float)((int)e);
                diff = (float)Math.Round(e - f, 1);

                GL.Begin(OpenTK.Graphics.OpenGL.BeginMode.Lines);
                for (i = 0; i < f; i++)
                {
                    GL.Vertex2(Math.Cos(i * Maths._deg2radf), Math.Sin(i * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((i + 1) * Maths._deg2radf), Math.Sin((i + 1) * Maths._deg2radf));
                }
                for (x = 0; x < diff; x += 0.1f)
                {
                    GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                    GL.Vertex2(Math.Cos((x + 0.1f + (float)i) * Maths._deg2radf), Math.Sin((x + 0.1f + (float)i) * Maths._deg2radf));
                }

                GL.Vertex2(Math.Cos((x + (float)i) * Maths._deg2radf), Math.Sin((x + (float)i) * Maths._deg2radf));
                GL.Color4(Color.Orange);
                GL.Vertex3(0, 0, 0);

                GL.End();

                GL.PopAttrib();
            }

            GL.Clear(ClearBufferMask.DepthBufferBit);

            RenderTransformControl(context);

            if (!modelPanel._grabbing && !modelPanel._scrolling && !_playing)
            {
                GL.Color4(Color.Black);
                GL.ColorMask(false, false, false, false);

                if (RenderBones)
                {
                    //Render invisible depth orbs
                    GLDisplayList list = context.GetSphereList();
                    if (_editingAll)
                    {
                        foreach (MDL0Node m in _targetModels)
                        {
                            foreach (MDL0BoneNode bone in m._linker.BoneCache)
                            {
                                if (bone != SelectedBone)
                                {
                                    RenderOrb(bone, list);
                                }
                            }
                        }
                    }
                    else if (TargetModel != null && TargetModel._linker != null && TargetModel._linker.BoneCache != null)
                    {
                        foreach (MDL0BoneNode bone in _targetModel._linker.BoneCache)
                        {
                            if (bone != SelectedBone)
                            {
                                RenderOrb(bone, list);
                            }
                        }
                    }
                }

                //Render invisible depth planes for translation and scale controls
                if (_editType != 0 && SelectedBone != null && RenderBones)
                {
                    #region Axis Selection Display List

                    GLDisplayList selList = new GLDisplayList();

                    selList.Begin();

                    GL.Begin(BeginMode.Quads);

                    //X Axis
                    //XY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, _axisSelectRange, 0.0f);
                    GL.Vertex3(_axisLDist, -_axisSelectRange, 0.0f);
                    //XZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, _axisSelectRange);
                    GL.Vertex3(_axisLDist, 0.0f, -_axisSelectRange);

                    //Y Axis
                    //YX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, _axisLDist, 0.0f);
                    GL.Vertex3(-_axisSelectRange, _axisLDist, 0.0f);
                    //YZ quad
                    GL.Vertex3(0.0f, 0.0f, -_axisSelectRange);
                    GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, _axisSelectRange);
                    GL.Vertex3(0.0f, _axisLDist, -_axisSelectRange);

                    //Z Axis
                    //ZX quad
                    GL.Vertex3(-_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                    GL.Vertex3(_axisSelectRange, 0.0f, _axisLDist);
                    GL.Vertex3(-_axisSelectRange, 0.0f, _axisLDist);
                    //ZY quad
                    GL.Vertex3(0.0f, -_axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                    GL.Vertex3(0.0f, _axisSelectRange, _axisLDist);
                    GL.Vertex3(0.0f, -_axisSelectRange, _axisLDist);

                    GL.End();

                    selList.End();

                    #endregion

                    if (_editType != 0 && SelectedBone != null)
                    {
                        Matrix m = Matrix.TransformMatrix(new Vector3(OrbRadius), new Vector3(), BoneLoc);
                        GL.PushMatrix();
                        GL.MultMatrix((float *)&m);

                        selList.Call();

                        if (_editType == TransformType.Translation)
                        {
                            GL.Begin(BeginMode.Quads);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(_axisHalfLDist, _axisHalfLDist, 0.0f);
                            GL.Vertex3(0.0f, _axisHalfLDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisSelectRange);
                            GL.Vertex3(0.0f, _axisHalfLDist, _axisHalfLDist);
                            GL.Vertex3(0.0f, 0.0f, _axisHalfLDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, _axisHalfLDist);
                            GL.Vertex3(_axisHalfLDist, 0.0f, 0.0f);

                            GL.End();
                        }
                        else
                        {
                            GL.Begin(BeginMode.Triangles);

                            //XY
                            GL.Vertex3(0.0f, _axisSelectRange, 0.0f);
                            GL.Vertex3(_scaleHalf2LDist, _axisSelectRange, 0.0f);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, 0.0f);

                            //YZ
                            GL.Vertex3(0.0f, 0.0f, _axisSelectRange);
                            GL.Vertex3(0.0f, _scaleHalf2LDist, _axisSelectRange);
                            GL.Vertex3(0.0f, 0.0f, _scaleHalf2LDist);

                            //XZ
                            GL.Vertex3(_axisSelectRange, 0.0f, 0.0f);
                            GL.Vertex3(_axisSelectRange, 0.0f, _scaleHalf2LDist);
                            GL.Vertex3(_scaleHalf2LDist, 0.0f, 0.0f);

                            GL.End();
                        }

                        GL.PopMatrix();
                    }
                }
                GL.ColorMask(true, true, true, true);
            }
        }
        public static GLDisplayList CreateNodeOrb(TKContext ctx)
        {
            GLDisplayList circle = ctx.GetRingList();
            GLDisplayList orb = new GLDisplayList();

            orb.Begin();
            GL.PushMatrix();

            GL.Scale(_nodeRadius, _nodeRadius, _nodeRadius);
            circle.Call();
            GL.Rotate(90.0f, 0.0f, 1.0f, 0.0f);
            circle.Call();
            GL.Rotate(90.0f, 1.0f, 0.0f, 0.0f);
            circle.Call();

            GL.PopMatrix();
            orb.End();
            return orb;
        }