public virtual void render(GLUtessellatorImpl tess, Mogre.Utils.GluTesselator.GLUhalfEdge e, long size) { /* Render as many CCW triangles as possible in a strip starting from * edge "e". The strip *should* contain exactly "size" triangles * (otherwise we've goofed up somewhere). */ tess.callBeginOrBeginData(GL.GL_TRIANGLE_STRIP); tess.callVertexOrVertexData(e.Org.data); tess.callVertexOrVertexData(e.Sym.Org.data); while (!Mogre.Utils.GluTesselator.Render.Marked(e.Lface)) { e.Lface.marked = true; --size; e = e.Lnext.Sym; tess.callVertexOrVertexData(e.Org.data); if (Mogre.Utils.GluTesselator.Render.Marked(e.Lface)) { break; } e.Lface.marked = true; --size; e = e.Onext; tess.callVertexOrVertexData(e.Sym.Org.data); } //assert(size == 0); tess.callEndOrEndData(); }
internal static void RenderLonelyTriangles(GLUtessellatorImpl tess, Mogre.Utils.GluTesselator.GLUface f) { /* Now we render all the separate triangles which could not be * grouped into a triangle fan or strip. */ Mogre.Utils.GluTesselator.GLUhalfEdge e; int newState; int edgeState = -1; /* force edge state output for first vertex */ tess.callBeginOrBeginData(GL.GL_TRIANGLES); for (; f != null; f = f.trail) { /* Loop once for each edge (there will always be 3 edges) */ e = f.anEdge; do { if (tess.flagBoundary) { /* Set the "edge state" to true just before we output the * first vertex of each edge on the polygon boundary. */ newState = (!e.Sym.Lface.inside)?1:0; if (edgeState != newState) { edgeState = newState; tess.callEdgeFlagOrEdgeFlagData(edgeState != 0); } } tess.callVertexOrVertexData(e.Org.data); e = e.Lnext; }while (e != f.anEdge); } tess.callEndOrEndData(); }
/// <summary>********************* Boundary contour decomposition *****************</summary> /* __gl_renderBoundary( tess, mesh ) takes a mesh, and outputs one * contour for each face marked "inside". The rendering output is * provided as callbacks (see the api). */ public static void __gl_renderBoundary(GLUtessellatorImpl tess, Mogre.Utils.GluTesselator.GLUmesh mesh) { Mogre.Utils.GluTesselator.GLUface f; Mogre.Utils.GluTesselator.GLUhalfEdge e; for (f = mesh.fHead.next; f != mesh.fHead; f = f.next) { if (f.inside) { tess.callBeginOrBeginData(GL.GL_LINE_LOOP); e = f.anEdge; do { tess.callVertexOrVertexData(e.Org.data); e = e.Lnext; } while (e != f.anEdge); tess.callEndOrEndData(); } } }
public virtual void render(GLUtessellatorImpl tess, Mogre.Utils.GluTesselator.GLUhalfEdge e, long size) { /* Render as many CCW triangles as possible in a strip starting from * edge "e". The strip *should* contain exactly "size" triangles * (otherwise we've goofed up somewhere). */ tess.callBeginOrBeginData(GL.GL_TRIANGLE_STRIP); tess.callVertexOrVertexData(e.Org.data); tess.callVertexOrVertexData(e.Sym.Org.data); while (!Mogre.Utils.GluTesselator.Render.Marked(e.Lface)) { e.Lface.marked = true; --size; e = e.Lnext.Sym; tess.callVertexOrVertexData(e.Org.data); if (Mogre.Utils.GluTesselator.Render.Marked(e.Lface)) break; e.Lface.marked = true; --size; e = e.Onext; tess.callVertexOrVertexData(e.Sym.Org.data); } //assert(size == 0); tess.callEndOrEndData(); }
internal static void RenderLonelyTriangles(GLUtessellatorImpl tess, Mogre.Utils.GluTesselator.GLUface f) { /* Now we render all the separate triangles which could not be * grouped into a triangle fan or strip. */ Mogre.Utils.GluTesselator.GLUhalfEdge e; int newState; int edgeState = - 1; /* force edge state output for first vertex */ tess.callBeginOrBeginData(GL.GL_TRIANGLES); for (; f != null; f = f.trail) { /* Loop once for each edge (there will always be 3 edges) */ e = f.anEdge; do { if (tess.flagBoundary) { /* Set the "edge state" to true just before we output the * first vertex of each edge on the polygon boundary. */ newState = (!e.Sym.Lface.inside)?1:0; if (edgeState != newState) { edgeState = newState; tess.callEdgeFlagOrEdgeFlagData(edgeState != 0); } } tess.callVertexOrVertexData(e.Org.data); e = e.Lnext; } while (e != f.anEdge); } tess.callEndOrEndData(); }
/* __gl_renderCache( tess ) takes a single contour and tries to render it * as a triangle fan. This handles convex polygons, as well as some * non-convex polygons if we get lucky. * * Returns true if the polygon was successfully rendered. The rendering * output is provided as callbacks (see the api). */ public static bool __gl_renderCache(GLUtessellatorImpl tess) { Mogre.Utils.GluTesselator.CachedVertex[] v = tess.cache; // CachedVertex vn = v0 + tess.cacheCount; int vn = tess.cacheCount; // CachedVertex vc; int vc; double[] norm = new double[3]; int sign; if (tess.cacheCount < 3) { /* Degenerate contour -- no output */ return true; } norm[0] = tess.normal[0]; norm[1] = tess.normal[1]; norm[2] = tess.normal[2]; if (norm[0] == 0 && norm[1] == 0 && norm[2] == 0) { ComputeNormal(tess, norm, false); } sign = ComputeNormal(tess, norm, true); if (sign == SIGN_INCONSISTENT) { /* Fan triangles did not have a consistent orientation */ return false; } if (sign == 0) { /* All triangles were degenerate */ return true; } if (!USE_OPTIMIZED_CODE_PATH) { return false; } else { /* Make sure we do the right thing for each winding rule */ switch (tess.windingRule) { case GLU.GLU_TESS_WINDING_ODD: case GLU.GLU_TESS_WINDING_NONZERO: break; case GLU.GLU_TESS_WINDING_POSITIVE: if (sign < 0) return true; break; case GLU.GLU_TESS_WINDING_NEGATIVE: if (sign > 0) return true; break; case GLU.GLU_TESS_WINDING_ABS_GEQ_TWO: return true; } tess.callBeginOrBeginData(tess.boundaryOnly?GL.GL_LINE_LOOP:((tess.cacheCount > 3)?GL.GL_TRIANGLE_FAN:GL.GL_TRIANGLES)); tess.callVertexOrVertexData(v[0].data); if (sign > 0) { for (vc = 1; vc < vn; ++vc) { tess.callVertexOrVertexData(v[vc].data); } } else { for (vc = vn - 1; vc > 0; --vc) { tess.callVertexOrVertexData(v[vc].data); } } tess.callEndOrEndData(); return true; } }