Ejemplo n.º 1
0
        public void Render(Color4 clr, float mult)
        {
            if (_highlight)
            {
                GL.Color4(1.0f, 1.0f, 0.0f, 1.0f);
            }
            else
            {
                GL.Color4(clr);
            }

            Vector2 v = Value;

            TKContext.DrawBox(
                new Vector3(v._x - mult * BoxRadius, v._y - mult * BoxRadius, LineWidth),
                new Vector3(v._x + mult * BoxRadius, v._y + mult * BoxRadius, -LineWidth));
        }
Ejemplo n.º 2
0
        public void Render(TKContext ctx)
        {
            if (_highlight)
            {
                GL.Color4(1.0f, 1.0f, 0.0f, 1.0f);
            }
            else
            {
                GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);
            }

            Vector2 v = Value;

            ctx.DrawBox(
                new Vector3(v._x - BoxRadius, v._y - BoxRadius, LineWidth),
                new Vector3(v._x + BoxRadius, v._y + BoxRadius, -LineWidth));
        }
Ejemplo n.º 3
0
        public void RenderBrawlStageData(ModelPanelViewport panel)
        {
            //If you ever make changes to GL attributes (enabled and disabled things)
            //and don't want to keep track of what you changed,
            //you can push all attributes and then pop them when you're done, like this.
            //This will make sure the GL state is back to how it was before you changed it.
            GL.PushAttrib(AttribMask.AllAttribBits);

            GL.Disable(EnableCap.DepthTest);

            if (RenderCollisions)
            {
                foreach (CollisionNode node in _collisions)
                {
                    node.Render();
                }
            }

            #region RenderOverlays

            List <MDL0BoneNode> ItemBones = new List <MDL0BoneNode>();

            MDL0Node stgPos = null;

            MDL0BoneNode CamBone0   = null,
                         CamBone1   = null,
                         DeathBone0 = null,
                         DeathBone1 = null;

            //Get bones and render spawns if checked
            if (_targetModel != null &&
                _targetModel is MDL0Node &&
                (((ResourceNode)_targetModel).Name.Contains("StgPosition") ||
                 ((ResourceNode)_targetModel).Name.Contains("stagePosition")))
            {
                stgPos = _targetModel as MDL0Node;
            }
            else if (_targetModels != null)
            {
                stgPos = _targetModels.Find(x => x is MDL0Node &&
                                            ((ResourceNode)x).Name.Contains("StgPosition") ||
                                            ((ResourceNode)x).Name.Contains("stagePosition")) as MDL0Node;
            }

            if (stgPos != null)
            {
                foreach (MDL0BoneNode bone in stgPos._linker.BoneCache)
                {
                    if (bone._name == "CamLimit0N")
                    {
                        CamBone0 = bone;
                    }
                    else if (bone.Name == "CamLimit1N")
                    {
                        CamBone1 = bone;
                    }
                    else if (bone.Name == "Dead0N")
                    {
                        DeathBone0 = bone;
                    }
                    else if (bone.Name == "Dead1N")
                    {
                        DeathBone1 = bone;
                    }
                    else if (bone._name.StartsWith("Player") && bone._name.Length == 8 && chkSpawns.Checked)
                    {
                        Vector3 position = bone._frameMatrix.GetPoint();
                        if (PointCollides(position))
                        {
                            GL.Color4(0.0f, 1.0f, 0.0f, 0.5f);
                        }
                        else
                        {
                            GL.Color4(1.0f, 0.0f, 0.0f, 0.5f);
                        }

                        TKContext.DrawSphere(position, 5.0f, 32);
                        if (int.TryParse(bone._name.Substring(6, 1), out int playernum))
                        {
                            panel.NoSettingsScreenText[playernum.ToString()] =
                                panel.Camera.Project(position) - new Vector3(8.0f, 8.0f, 0);
                        }
                    }
                    else if (bone._name.StartsWith("Rebirth") && bone._name.Length == 9 && chkSpawns.Checked)
                    {
                        GL.Color4(1.0f, 1.0f, 1.0f, 0.1f);
                        TKContext.DrawSphere(bone._frameMatrix.GetPoint(), 5.0f, 32);
                        if (int.TryParse(bone._name.Substring(7, 1), out int playernum))
                        {
                            panel.NoSettingsScreenText[playernum.ToString()] =
                                panel.Camera.Project(bone._frameMatrix.GetPoint()) - new Vector3(8.0f, 8.0f, 0);
                        }
                    }
                    else if (bone._name.StartsWith("Item"))
                    {
                        ItemBones.Add(bone);
                    }
                }
            }

            //Render item fields if checked
            if (ItemBones != null && chkItems.Checked)
            {
                GL.Color4(0.5f, 0.0f, 1.0f, 0.4f);
                for (int i = 0; i < ItemBones.Count; i += 2)
                {
                    Vector3 pos1, pos2;
                    if (ItemBones[i]._frameMatrix.GetPoint()._y == ItemBones[i + 1]._frameMatrix.GetPoint()._y)
                    {
                        pos1 = new Vector3(ItemBones[i]._frameMatrix.GetPoint()._x,
                                           ItemBones[i]._frameMatrix.GetPoint()._y + 1.5f, 1.0f);
                        pos2 = new Vector3(ItemBones[i + 1]._frameMatrix.GetPoint()._x,
                                           ItemBones[i + 1]._frameMatrix.GetPoint()._y - 1.5f, 1.0f);
                    }
                    else
                    {
                        pos1 = new Vector3(ItemBones[i]._frameMatrix.GetPoint()._x,
                                           ItemBones[i]._frameMatrix.GetPoint()._y, 1.0f);
                        pos2 = new Vector3(ItemBones[i + 1]._frameMatrix.GetPoint()._x,
                                           ItemBones[i + 1]._frameMatrix.GetPoint()._y, 1.0f);
                    }


                    if (pos1._x != pos2._x)
                    {
                        TKContext.DrawBox(pos1, pos2);
                    }
                    else
                    {
                        TKContext.DrawSphere(
                            new Vector3(ItemBones[i]._frameMatrix.GetPoint()._x,
                                        ItemBones[i]._frameMatrix.GetPoint()._y, pos1._z), 3.0f, 32);
                    }
                }
            }

            //Render boundaries if checked
            if (CamBone0 != null && CamBone1 != null && chkBoundaries.Checked)
            {
                //GL.Clear(ClearBufferMask.DepthBufferBit);
                GL.Disable(EnableCap.DepthTest);
                GL.Disable(EnableCap.Lighting);
                GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                GL.Enable(EnableCap.CullFace);
                GL.CullFace(CullFaceMode.Front);

                GL.Color4(Color.Blue);
                GL.Begin(BeginMode.LineLoop);
                GL.LineWidth(15.0f);

                Vector3
                    camBone0   = CamBone0._frameMatrix.GetPoint(),
                    camBone1   = CamBone1._frameMatrix.GetPoint(),
                    deathBone0 = DeathBone0._frameMatrix.GetPoint(),
                    deathBone1 = DeathBone1._frameMatrix.GetPoint();

                GL.Vertex2(camBone0._x, camBone0._y);
                GL.Vertex2(camBone1._x, camBone0._y);
                GL.Vertex2(camBone1._x, camBone1._y);
                GL.Vertex2(camBone0._x, camBone1._y);
                GL.End();
                GL.Begin(BeginMode.LineLoop);
                GL.Color4(Color.Red);
                GL.Vertex2(deathBone0._x, deathBone0._y);
                GL.Vertex2(deathBone1._x, deathBone0._y);
                GL.Vertex2(deathBone1._x, deathBone1._y);
                GL.Vertex2(deathBone0._x, deathBone1._y);
                GL.End();
                GL.Color4(0.0f, 0.5f, 1.0f, 0.3f);
                GL.Begin(BeginMode.TriangleFan);
                GL.Vertex2(camBone0._x, camBone0._y);
                GL.Vertex2(deathBone0._x, deathBone0._y);
                GL.Vertex2(deathBone1._x, deathBone0._y);
                GL.Vertex2(camBone1._x, camBone0._y);
                GL.End();
                GL.Begin(BeginMode.TriangleFan);
                GL.Vertex2(camBone1._x, camBone1._y);
                GL.Vertex2(deathBone1._x, deathBone1._y);
                GL.Vertex2(deathBone0._x, deathBone1._y);
                GL.Vertex2(camBone0._x, camBone1._y);
                GL.End();
                GL.Begin(BeginMode.TriangleFan);
                GL.Vertex2(camBone1._x, camBone0._y);
                GL.Vertex2(deathBone1._x, deathBone0._y);
                GL.Vertex2(deathBone1._x, deathBone1._y);
                GL.Vertex2(camBone1._x, camBone1._y);
                GL.End();
                GL.Begin(BeginMode.TriangleFan);
                GL.Vertex2(camBone0._x, camBone1._y);
                GL.Vertex2(deathBone0._x, deathBone1._y);
                GL.Vertex2(deathBone0._x, deathBone0._y);
                GL.Vertex2(camBone0._x, camBone0._y);
                GL.End();
            }

            #endregion

            GL.PopAttrib();
        }
        public void Render(TKContext ctx)
        {
            if (_highlight)
                GL.Color4(1.0f, 1.0f, 0.0f, 1.0f);
            else
                GL.Color4(1.0f, 1.0f, 1.0f, 1.0f);

            Vector2 v = Value;

            ctx.DrawBox(
                new Vector3(v._x - BoxRadius, v._y - BoxRadius, LineWidth),
                new Vector3(v._x + BoxRadius, v._y + BoxRadius, -LineWidth));
        }
        private unsafe void _modelPanel_PostRender(object sender, TKContext context)
        {
            //Clear depth buffer so we can hit-detect
            GL.Clear(ClearBufferMask.DepthBufferBit);
            GL.Enable(EnableCap.DepthTest);

            //Render objects
            if (_targetNode != null)
                _targetNode.Render(context, null);

            //Render selection box
            if (!_selecting)
                return;

            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);

            //Draw lines
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
            GL.Color4(0.0f, 0.0f, 1.0f, 0.5f);
            context.DrawBox(_selectStart, _selectEnd);

            //Draw box
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            GL.Color4(1.0f, 1.0f, 0.0f, 0.2f);
            context.DrawBox(_selectStart, _selectEnd);
        }