Пример #1
0
 /// <summary>
 /// Free resources used by OpenGL
 /// </summary>
 public void destroy()
 {
     SelectManager.FreeGUID(myGUID);
     foreach (VBOMesh mesh in models)
     {
         mesh.destroy();
     }
 }
Пример #2
0
        /// <summary>
        /// Create a new OGL_RigidNode from existing data
        /// </summary>
        /// <remarks>
        /// This is used primarily for converting another subclass of RigidNode_Base to an OGL_RigidNode.
        /// For conversion from a RigidNode_Base, casting will suffice.
        /// </remarks>
        /// <param name="baseData">The rigid node containing existing model data</param>
        public OGL_RigidNode(RigidNode_Base baseData)
            : base(baseData.GUID)
        {
            myGUID        = SelectManager.AllocateGUID(this);
            ModelFullID   = baseData.ModelFullID;
            ModelFileName = baseData.ModelFileName;

            foreach (KeyValuePair <SkeletalJoint_Base, RigidNode_Base> child in baseData.Children)
            {
                AddChild(child.Key, new OGL_RigidNode(child.Value));
            }
        }
Пример #3
0
        /// <summary>
        /// Render the node and tint it based on any highlights it may have
        /// </summary>
        /// <param name="select">Whether or not the node is being rendered for highlight selection</param>
        /// <param name="highlightColor">The color to highlight the node if it is active</param>
        /// <param name="tintColor">The color to tint the node on hover</param>
        public void render(bool select = false, uint highlightColor = 0xFFFF0000, uint tintColor = 0xFFBBFFBB)
        {
            int            tintLocation = 0;
            HighlightState tmpHighlight = highlight;

            GL.PushMatrix();
            {
                GL.MultMatrix(ref myTrans);

                if (!select)
                {
                    GL.Enable(EnableCap.Lighting);
                    GL.UseProgram(ShaderLoader.PartShader);
                    if (tmpHighlight > 0)
                    {
                        tintLocation = GL.GetUniformLocation(ShaderLoader.PartShader, "tintColor");

                        if ((tmpHighlight & HighlightState.ACTIVE_HOVERING) == HighlightState.ACTIVE_HOVERING)
                        {
                            uint activeHoverColor = highlightColor & tintColor;
                            byte a = (byte)(activeHoverColor >> 24);
                            byte r = (byte)((((activeHoverColor >> 16) & 0xFF) + 0xFF) / 2);
                            byte g = (byte)((((activeHoverColor >> 8) & 0xFF) + 0xFF) / 2);
                            byte b = (byte)(((activeHoverColor & 0xFF) + 0xFF) / 2);

                            GL.Uniform4(tintLocation, 1, new float[] { (float)r / 255f,
                                                                       (float)g / 255f,
                                                                       (float)b / 255f,
                                                                       (float)a / 255f });
                        }
                        else if ((tmpHighlight & HighlightState.ACTIVE) == HighlightState.ACTIVE)
                        {
                            GL.Uniform4(tintLocation, 1, new float[] { (float)(highlightColor >> 16 & 0xFF) / 255f,
                                                                       (float)(highlightColor >> 8 & 0xFF) / 255f,
                                                                       (float)(highlightColor & 0xFF) / 255f,
                                                                       (float)(highlightColor >> 24 & 0xFF) / 255f });
                        }
                        else if ((tmpHighlight & HighlightState.HOVERING) == HighlightState.HOVERING)
                        {
                            GL.Uniform4(tintLocation, 1, new float[] { (float)(tintColor >> 16 & 0xFF) / 255f,
                                                                       (float)(tintColor >> 8 & 0xFF) / 255f,
                                                                       (float)(tintColor & 0xFF) / 255f,
                                                                       (float)(tintColor >> 24 & 0xFF) / 255f });
                        }
                    }
                }
                else
                {
                    GL.Disable(EnableCap.Lighting);
                    GL.UseProgram(0);
                    GL.Color4(SelectManager.GUIDToColor(myGUID)); //Render it the color assigned to it by the GUID manager
                }

                foreach (VBOMesh mesh in models)
                {
                    mesh.draw(!select);
                }

                if (!select)
                {
                    if (tmpHighlight > 0)
                    {
                        GL.Uniform4(tintLocation, 1, new float[] { 1, 1, 1, 1 });
                    }
                }

                GL.UseProgram(0);
            }
            GL.PopMatrix();
        }
Пример #4
0
 /// <summary>
 /// Create a blank OGL_RigidNode with a unique GUID
 /// </summary>
 public OGL_RigidNode(Guid guid)
     : base(guid)
 {
     myGUID = SelectManager.AllocateGUID(this);
 }