예제 #1
0
        private void DrawModel(KCL.KCLModel m, ShaderProgram shader, bool drawSelection = false)
        {
            if (m.faces.Count <= 3)
            {
                return;
            }

            SetVertexAttributes(m, shader);

            if (m.Checked)
            {
                if ((m.IsSelected))
                {
                    DrawModelSelection(m, shader);
                }
                else
                {
                    if (Runtime.RenderModelWireframe)
                    {
                        DrawModelWireframe(m, shader);
                    }

                    if (Runtime.RenderModels)
                    {
                        GL.DrawElements(PrimitiveType.Triangles, m.displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
                    }
                }
            }
        }
예제 #2
0
 private void SetVertexAttributes(KCL.KCLModel m, ShaderProgram shader)
 {
     GL.BindBuffer(BufferTarget.ArrayBuffer, vbo_position);
     GL.VertexAttribPointer(shader.GetAttribute("vPosition"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 0);
     GL.VertexAttribPointer(shader.GetAttribute("vNormal"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 12);
     GL.VertexAttribPointer(shader.GetAttribute("vColor"), 3, VertexAttribPointerType.Float, false, KCL.DisplayVertex.Size, 24);
     GL.BindBuffer(BufferTarget.ElementArrayBuffer, ibo_elements);
 }
예제 #3
0
 private static void DrawModelWireframe(KCL.KCLModel p, ShaderProgram shader)
 {
     // use vertex color for wireframe color
     GL.Uniform1(shader["colorOverride"], 1);
     GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
     GL.Enable(EnableCap.LineSmooth);
     GL.LineWidth(1.5f);
     GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
     GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
     GL.Uniform1(shader["colorOverride"], 0);
 }
예제 #4
0
        private void DrawModel(KCL.KCLModel m, bool drawSelection = false)
        {
            if (m.faces.Count <= 3)
            {
                return;
            }

            SetVertexAttributes(m);

            if (Runtime.RenderModels)
            {
                GL.DrawElements(PrimitiveType.Triangles, m.displayFaceSize, DrawElementsType.UnsignedInt, m.Offset);
            }
        }
예제 #5
0
        private static void DrawModelSelection(KCL.KCLModel p, ShaderProgram shader)
        {
            //This part needs to be reworked for proper outline. Currently would make model disappear

            GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);

            GL.Enable(EnableCap.StencilTest);
            // use vertex color for wireframe color
            GL.Uniform1(shader["colorOverride"], 1);
            GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
            GL.Enable(EnableCap.LineSmooth);
            GL.LineWidth(1.5f);
            GL.DrawElements(PrimitiveType.Triangles, p.displayFaceSize, DrawElementsType.UnsignedInt, p.Offset);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            GL.Uniform1(shader["colorOverride"], 0);

            GL.Enable(EnableCap.DepthTest);
        }