public static Mesh TriangulateFaces(this IVertexSource vertexSource, CachedTesselator teselatedSource = null) { if (teselatedSource == null) { teselatedSource = new CachedTesselator(); } VertexSourceToTesselator.SendShapeToTesselator(teselatedSource, vertexSource); Mesh mesh = new Mesh(); int numIndicies = teselatedSource.IndicesCache.Count; // turn the tessellation output into mesh faces for (int i = 0; i < numIndicies; i += 3) { Vector2 v0 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 0].Index].Position; Vector2 v1 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 1].Index].Position; Vector2 v2 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 2].Index].Position; if (v0 == v1 || v1 == v2 || v2 == v0) { continue; } mesh.CreateFace(new Vector3[] { new Vector3(v0, 0), new Vector3(v1, 0), new Vector3(v2, 0) }); } return(mesh); }
public override void Render(IVertexSource vertexSource, int pathIndexToRender, IColorType colorIn) { PreRender(); if (DoEdgeAntiAliasing) { DrawAAShape(vertexSource, colorIn); } else { vertexSource.rewind(pathIndexToRender); Affine transform = GetTransform(); if (!transform.is_identity()) { vertexSource = new VertexSourceApplyTransform(vertexSource, transform); } RGBA_Bytes colorBytes = colorIn.GetAsRGBA_Bytes(); GL.Color4(colorBytes.red, colorBytes.green, colorBytes.blue, colorBytes.alpha); renderNowTesselator.Clear(); VertexSourceToTesselator.SendShapeToTesselator(renderNowTesselator, vertexSource); } PopOrthoProjection(); }
private static Mesh TriangulateFaces(IVertexSource vertexSource, CachedTesselator teselatedSource) { VertexSourceToTesselator.SendShapeToTesselator(teselatedSource, vertexSource); Mesh teselatedMesh = new Mesh(); int numIndicies = teselatedSource.IndicesCache.Count; // turn the tessellation output into mesh faces for (int i = 0; i < numIndicies; i += 3) { Vector2 v0 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 0].Index].Position; Vector2 v1 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 1].Index].Position; Vector2 v2 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 2].Index].Position; if (v0 == v1 || v1 == v2 || v2 == v0) { continue; } IVertex topVertex0 = teselatedMesh.CreateVertex(new Vector3(v0, 0)); IVertex topVertex1 = teselatedMesh.CreateVertex(new Vector3(v1, 0)); IVertex topVertex2 = teselatedMesh.CreateVertex(new Vector3(v2, 0)); teselatedMesh.CreateFace(new IVertex[] { topVertex0, topVertex1, topVertex2 }); } return(teselatedMesh); }
private static Mesh TriangulateFaces(IVertexSource vertexSource, CachedTesselator teselatedSource) { VertexSourceToTesselator.SendShapeToTesselator(teselatedSource, vertexSource); Mesh extrudedVertexSource = new Mesh(); int numIndicies = teselatedSource.IndicesCache.Count; // build the top first so it will render first when we are translucent for (int i = 0; i < numIndicies; i += 3) { Vector2 v0 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 0].Index].Position; Vector2 v1 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 1].Index].Position; Vector2 v2 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 2].Index].Position; if (v0 == v1 || v1 == v2 || v2 == v0) { continue; } Vertex topVertex0 = extrudedVertexSource.CreateVertex(new Vector3(v0, 0)); Vertex topVertex1 = extrudedVertexSource.CreateVertex(new Vector3(v1, 0)); Vertex topVertex2 = extrudedVertexSource.CreateVertex(new Vector3(v2, 0)); extrudedVertexSource.CreateFace(new Vertex[] { topVertex0, topVertex1, topVertex2 }); } return(extrudedVertexSource); }
public static Mesh TriangulateFaces(this IEnumerable <VertexData> vertexSource, CachedTesselator teselatedSource = null, Mesh meshToAddTo = null, double zHeight = 0) { if (teselatedSource == null) { teselatedSource = new CachedTesselator(); } VertexSourceToTesselator.SendShapeToTesselator(teselatedSource, vertexSource); if (meshToAddTo == null) { meshToAddTo = new Mesh(); } int numIndicies = teselatedSource.IndicesCache.Count; // turn the tessellation output into mesh faces for (int i = 0; i < numIndicies; i += 3) { Vector2 v0 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 0].Index].Position; Vector2 v1 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 1].Index].Position; Vector2 v2 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 2].Index].Position; if (v0 == v1 || v1 == v2 || v2 == v0) { continue; } meshToAddTo.CreateFace(new Vector3[] { new Vector3(v0, zHeight), new Vector3(v1, zHeight), new Vector3(v2, zHeight) }); } return(meshToAddTo); }
public static Mesh TriangulateFaces(this IEnumerable <VertexData> vertexSource, CachedTesselator teselatedSource = null, Mesh meshToAddTo = null, double zHeight = 0, Matrix4X4?inMatrix = null) { bool isIdentity = inMatrix == null || inMatrix.Value == Matrix4X4.Identity; if (teselatedSource == null) { teselatedSource = new CachedTesselator(); } VertexSourceToTesselator.SendShapeToTesselator(teselatedSource, vertexSource); if (meshToAddTo == null) { meshToAddTo = new Mesh(); } int numIndicies = teselatedSource.IndicesCache.Count; // turn the tessellation output into mesh faces for (int i = 0; i < numIndicies; i += 3) { Vector2 v0 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 0].Index].Position; Vector2 v1 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 1].Index].Position; Vector2 v2 = teselatedSource.VerticesCache[teselatedSource.IndicesCache[i + 2].Index].Position; if (v0 == v1 || v1 == v2 || v2 == v0) { continue; } if (!isIdentity) { var matrix = inMatrix.Value; meshToAddTo.CreateFace(new Vector3[] { new Vector3(v0, zHeight).Transform(matrix), new Vector3(v1, zHeight).Transform(matrix), new Vector3(v2, zHeight).Transform(matrix) }); } else { meshToAddTo.CreateFace(new Vector3[] { new Vector3(v0, zHeight), new Vector3(v1, zHeight), new Vector3(v2, zHeight) }); } } return(meshToAddTo); }
public static void RenderPath(this WorldView world, IVertexSource vertexSource, Color color, bool doDepthTest) { AAGLTesselator tesselator; if (!TesselatorsByWorld.TryGetValue(world, out tesselator)) { // Update reference and store in dictionary tesselator = new AAGLTesselator(world); TesselatorsByWorld.Add(world, tesselator); } // TODO: Necessary? // CheckLineImageCache(); // GL.Enable(EnableCap.Texture2D); // GL.BindTexture(TextureTarget.Texture2D, RenderOpenGl.ImageGlPlugin.GetImageGlPlugin(AATextureImages[color.Alpha0To255], false).GLTextureHandle); // the source is always all white so has no does not have its color changed by the alpha GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); GL.Enable(EnableCap.Blend); GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.Lighting); if (doDepthTest) { GL.Enable(EnableCap.DepthTest); } else { GL.Disable(EnableCap.DepthTest); } vertexSource.rewind(0); // the alpha has to come from the bound texture GL.Color4(color.red, color.green, color.blue, (byte)255); tesselator.Clear(); VertexSourceToTesselator.SendShapeToTesselator(tesselator, vertexSource); // now render it tesselator.RenderLastToGL(); }
public void DrawAAShape(IVertexSource vertexSource, IColorType colorIn) { vertexSource.rewind(0); Affine transform = GetTransform(); if (!transform.is_identity()) { vertexSource = new VertexSourceApplyTransform(vertexSource, transform); } RGBA_Bytes colorBytes = colorIn.GetAsRGBA_Bytes(); GL.Color4(colorBytes.red, colorBytes.green, colorBytes.blue, colorBytes.alpha); triangleEddgeInfo.Clear(); VertexSourceToTesselator.SendShapeToTesselator(triangleEddgeInfo, vertexSource); // now render it triangleEddgeInfo.RenderLastToGL(); }
private void DrawAAShape(IVertexSource vertexSource, IColorType colorIn) { vertexSource.rewind(0); Affine transform = GetTransform(); if (!transform.is_identity()) { vertexSource = new VertexSourceApplyTransform(vertexSource, transform); } Color colorBytes = colorIn.ToColor(); // the alpha has come from the bound texture GL.Color4(colorBytes.red, colorBytes.green, colorBytes.blue, (byte)255); triangleEdgeInfo.Clear(); VertexSourceToTesselator.SendShapeToTesselator(triangleEdgeInfo, vertexSource); // now render it triangleEdgeInfo.RenderLastToGL(); }