コード例 #1
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);
        }
コード例 #2
0
ファイル: Rendering.cs プロジェクト: PeterHatch/brawltools
        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);
        }
コード例 #3
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);
            }
        }
コード例 #4
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();
        }
コード例 #5
0
        public unsafe void RenderSCN0Controls(ModelPanelViewport vp)
        {
            if (_scn0 == null)
            {
                return;
            }

            int frame = CurrentFrame - 1;

            if (frame < 0)
            {
                return;
            }

            GL.Color3(Color.Blue);
            GL.Disable(EnableCap.Lighting);

            if (_SCN0LightSet != null)
            {
                int i = 0;
                foreach (SCN0LightNode l in _SCN0LightSet._lights)
                {
                    if (l == null)
                    {
                        i++;
                        continue;
                    }

                    Vector3 start = l.GetStart(frame);
                    Vector3 end   = l.GetEnd(frame);

                    switch (l.LightType)
                    {
                    case LightType.Spotlight:
                    case LightType.Directional:
                        GL.Begin(BeginMode.Lines);
                        GL.Color3((Color)l.GetColor(frame, 0));
                        GL.Vertex3((OpenTK.Vector3)start);
                        if (l.SpecularEnabled)
                        {
                            GL.Color3((Color)l.GetColor(frame, 1));
                        }

                        GL.Vertex3((OpenTK.Vector3)end);
                        GL.End();
                        if (l.LightType == LightType.Spotlight)
                        {
                            float radius = start.TrueDistance(end) *
                                           (float)Math.Tan(Maths._deg2radf * l.SpotCut.GetFrameValue(frame));
                            Matrix x = Matrix.TransformMatrix(
                                new Vector3(radius),
                                Maths._rad2degf * end.LookatAngles(start),
                                end);
                            GL.PushMatrix();
                            GL.MultMatrix((float *)&x);
                            TKContext.GetRingList().Call();
                            GL.PopMatrix();
                            break;
                        }

                        break;

                    case LightType.Point:
                        GL.Color4((Color)l.GetColor(frame, 0));
                        GL.PushMatrix();
                        Matrix m = Matrix.TransformMatrix(
                            new Vector3(l.RefDist.GetFrameValue(frame)),
                            CameraFacingRotation(vp.Camera, start),
                            start);
                        GL.MultMatrix((float *)&m);
                        TKContext.GetRingList().Call();
                        GL.PopMatrix();
                        break;
                    }

                    foreach (ModelPanelViewport v in ModelPanel)
                    {
                        v.SettingsScreenText[l.Name] = v.Camera.Project(start);
                        //v.SettingsScreenText[l.Name] = v.Camera.Project(end);
                    }

                    //GL.Color4(Color.MediumPurple);
                    //GL.Begin(PrimitiveType.LineStrip);
                    //for (int i = 0; i < MaxFrame; i++)
                    //    GL.Vertex3(l.GetFrameValue(LightKeyframeMode.StartX, i), l.GetFrameValue(LightKeyframeMode.StartY, i), l.GetFrameValue(LightKeyframeMode.StartZ, i));
                    //GL.End();

                    //GL.Color4(Color.ForestGreen);
                    //GL.Begin(PrimitiveType.LineStrip);
                    //for (int i = 0; i < MaxFrame; i++)
                    //    GL.Vertex3(l.GetFrameValue(LightKeyframeMode.EndX, i), l.GetFrameValue(LightKeyframeMode.EndY, i), l.GetFrameValue(LightKeyframeMode.EndZ, i));
                    //GL.End();

                    //Render these if selected
                    //if ((_lightStartSelected || _lightEndSelected) && l == scn0Editor._light)
                    //{
                    //    Matrix m;
                    //    float s1 = start.TrueDistance(CamLoc) / _orbRadius * 0.1f;
                    //    float e1 = end.TrueDistance(CamLoc) / _orbRadius * 0.1f;
                    //    GLDisplayList axis = GetAxes();
                    //    if (_lightStartSelected)
                    //    {
                    //        m = Matrix.TransformMatrix(new Vector3(s1), new Vector3(), start);

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

                    //        axis.Call();
                    //        GL.PopMatrix();
                    //    }
                    //    if (_lightEndSelected)
                    //    {
                    //        m = Matrix.TransformMatrix(new Vector3(e1), new Vector3(), end);

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

                    //        axis.Call();
                    //        GL.PopMatrix();
                    //    }
                    //}
                    i++;
                }
            }

            if (_SCN0Camera != null)
            {
                Vector3 start = _SCN0Camera.GetStart(frame);
                Vector3 end   = new Vector3();

                if (_SCN0Camera.Type == SCN0CameraType.Aim)
                {
                    end = _SCN0Camera.GetEnd(frame);
                }
                else
                {
                    Matrix r = Matrix.TranslationMatrix(new Vector3(0.0f, 0.0f, -1.0f) *
                                                        Matrix.RotationMatrix(_SCN0Camera.GetRotate(frame)));
                    end = r * start;
                }

                GL.Color3(Color.Green);
                GL.Begin(BeginMode.Lines);

                GL.Vertex3((OpenTK.Vector3)start);
                GL.Vertex3((OpenTK.Vector3)end);

                GL.End();

                foreach (ModelPanelViewport v in ModelPanel)
                {
                    v.SettingsScreenText[_SCN0Camera.Name] = v.Camera.Project(start);
                    //v.SettingsScreenText["Camera Aim"] = v.Camera.Project(end);
                }

                //GL.Color4(Color.OrangeRed);
                //GL.Begin(PrimitiveType.LineStrip);
                //for (int i = 0; i < MaxFrame; i++)
                //    GL.Vertex3(c.GetFrameValue(CameraKeyframeMode.PosX, i), c.GetFrameValue(CameraKeyframeMode.PosY, i), c.GetFrameValue(CameraKeyframeMode.PosZ, i));
                //GL.End();

                //GL.Color4(Color.SkyBlue);
                //GL.Begin(PrimitiveType.LineStrip);
                //for (int i = 0; i < MaxFrame; i++)
                //    GL.Vertex3(c.GetFrameValue(CameraKeyframeMode.AimX, i), c.GetFrameValue(CameraKeyframeMode.AimY, i), c.GetFrameValue(CameraKeyframeMode.AimZ, i));
                //GL.End();

                GL.Color3(Color.Black);

                //Render these if selected
                //if (_lightStartSelected || _lightEndSelected)
                //{
                //    Matrix m;
                //    float s = start.TrueDistance(CamLoc) / _orbRadius * 0.1f;
                //    float e = end.TrueDistance(CamLoc) / _orbRadius * 0.1f;
                //    GLDisplayList axis = GetAxes();
                //    if (_lightStartSelected)
                //    {
                //        m = Matrix.TransformMatrix(new Vector3(s), new Vector3(), start);

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

                //        axis.Call();
                //        GL.PopMatrix();
                //    }
                //    if (_lightEndSelected)
                //    {
                //        m = Matrix.TransformMatrix(new Vector3(e), new Vector3(), end);

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

                //        axis.Call();
                //        GL.PopMatrix();
                //    }
                //}
            }
        }
コード例 #6
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();
        }
コード例 #7
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();
        }
コード例 #8
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();
        }
コード例 #9
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();
        }
コード例 #10
0
ファイル: Event.cs プロジェクト: 0000duck/brawltools
        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();
        }
コード例 #11
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);
            }
        }
コード例 #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();
        }
コード例 #13
0
        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;
        }