Exemplo n.º 1
0
        private static void DrawWireOverlay(Mesh meshToRender, RenderTypes renderType, Color color, Action meshChanged = null)
        {
            GL.Color4(color.red, color.green, color.blue, color.alpha == 0 ? (byte)255 : color.alpha);

            GL.Disable(EnableCap.Lighting);

            GL.DisableClientState(ArrayCap.TextureCoordArray);
            IEdgeLinesContainer edgeLinesContainer = null;

            if (renderType == RenderTypes.Outlines)
            {
                edgeLinesContainer = GLMeshWirePlugin.Get(meshToRender, MathHelper.Tau / 8, meshChanged);
            }
            else if (renderType == RenderTypes.NonManifold)
            {
                edgeLinesContainer = GLMeshNonManifoldPlugin.Get(meshToRender, meshChanged);
                GL.Color4(255, 0, 0, 255);
            }
            else
            {
                edgeLinesContainer = GLMeshWirePlugin.Get(meshToRender);
            }

            GL.EnableClientState(ArrayCap.VertexArray);
            VectorPOD <WireVertexData> edgeLines = edgeLinesContainer.EdgeLines;

            unsafe
            {
                fixed(WireVertexData *pv = edgeLines.Array)
                {
                    GL.VertexPointer(3, VertexPointerType.Float, 0, new IntPtr(pv));
                    GL.DrawArrays(BeginMode.Lines, 0, edgeLines.Count);
                }
            }

            GL.DisableClientState(ArrayCap.VertexArray);
            GL.Enable(EnableCap.Lighting);
        }
Exemplo n.º 2
0
        public static GLMeshNonManifoldPlugin Get(Mesh mesh, Action meshChanged = null)
        {
            mesh.PropertyBag.TryGetValue(GLMeshNonManifoldPluginName, out object meshData);
            if (meshData is GLMeshNonManifoldPlugin plugin)
            {
                if (mesh.ChangedCount == plugin.meshUpdateCount)
                {
                    return(plugin);
                }

                // else we need to rebuild the data
                plugin.meshUpdateCount = mesh.ChangedCount;
                mesh.PropertyBag.Remove(GLMeshNonManifoldPluginName);
            }

            var newPlugin = new GLMeshNonManifoldPlugin();

            newPlugin.CreateRenderData(mesh, meshChanged);
            newPlugin.meshUpdateCount = mesh.ChangedCount;
            mesh.PropertyBag.Add(GLMeshNonManifoldPluginName, newPlugin);

            return(newPlugin);
        }