/* * Create the VBO for the border * */ void CreateBorderVBO() { borderVBO = new VertexBufferObject(); List <TriangleEdge> borderEdges = mesh.GetBorder(); Color4 borderColor = Color4.Pink; List <RenderVertex> renderVertices = new List <RenderVertex>(); for (int i = 0; i < borderEdges.Count; i++) { TriangleEdge edge = borderEdges[i]; Vector3 a = mesh.GetVertex(edge.A); Vector3 b = mesh.GetVertex(edge.B); renderVertices.Add(new RenderVertex(a, new Vector3(0, 1, 0), borderColor)); renderVertices.Add(new RenderVertex(b, new Vector3(0, 1, 0), borderColor)); } borderVBO.Setup(renderVertices, PrimitiveType.Lines); }
/* * Vreate the VBO for the normals * */ void CreateNormalsVBO() { normalsVBO = new VertexBufferObject(); List <RenderVertex> renderVertices = new List <RenderVertex>(); float scale = 0.05f; Color4 normalColor = Color4.DarkGray; for (int triangleIndex = 0; triangleIndex < mesh.GetNumberOfTriangles(); triangleIndex++) { Triangle t = mesh.GetTriangle(triangleIndex); Vector3 centroid = Vector3.Multiply( Vector3.Add(mesh.GetVertex(t.GetVertexIndex(0)), Vector3.Add(mesh.GetVertex(t.GetVertexIndex(1)), mesh.GetVertex(t.GetVertexIndex(2)))), 1.0f / 3.0f); Vector3 centroid2normal = Vector3.Add(centroid, Vector3.Multiply(t.Normal, scale)); renderVertices.Add(new RenderVertex(centroid, t.Normal, normalColor)); renderVertices.Add(new RenderVertex(centroid2normal, t.Normal, normalColor)); } normalsVBO.Setup(renderVertices, PrimitiveType.Lines); }