The lib only generates tesselation data (tris) for you from one or more polygons. You will be in charge of actually constructing a mesh from it.
Docs: GitHub - speps/LibTessDotNet: C# port of the famous GLU Tessellator - prebuilt binaries now available in "releases" tab
Here is the method I used in some of my code:
/// <summary>
/// Generate Mesh using LibTess.
/// </summary>
/// <param name="pointLists"></param>
/// <param name="textureScale"></param>
public void GenerateGeometryWithLibTess(List<List<Vector3>> pointLists, float textureScale)
{
// Libtess stuff
var triangulatedShape = new TriangulatedShape2D(pointLists);
// Your own mesh generation code (this one generates a mesh and applies it to a MeshFilter component)
int triCount = triangulatedShape.TriangleCount;
int[] tris = triangulatedShape.Triangles;
ContourVertex[] vertices = triangulatedShape.Vertices;
Vec3 p0, p1, p2;
Vector3[] meshVertices = new Vector3[triCount * 3];
Vector2[] meshUVs = new Vector2[triCount * 3];
int[] meshTriangles = new int[triCount * 3];
// uv start point
Vector3 uvPoint03D, uvPoint13D, uvPoint23D;
for (int i = 0; i < triCount; i++)
{
p0 = vertices[tris[i * 3]].Position;
p1 = vertices[tris[i * 3 + 1]].Position;
p2 = vertices[tris[i * 3 + 2]].Position;
meshVertices[i * 3] = new Vector3(p0.X, p0.Y, p0.Z);
meshVertices[i * 3 + 1] = new Vector3(p1.X, p1.Y, p1.Z);
meshVertices[i * 3 + 2] = new Vector3(p2.X, p2.Y, p2.Z);
uvPoint03D = this.transform.TransformPoint(new Vector3(p0.X, p0.Y, 0));
uvPoint13D = this.transform.TransformPoint(new Vector3(p1.X, p1.Y, 0));
uvPoint23D = this.transform.TransformPoint(new Vector3(p2.X, p2.Y, 0));
meshUVs[i * 3] = new Vector2(uvPoint03D.x / textureScale, uvPoint03D.y / textureScale);
meshUVs[i * 3 + 1] = new Vector2(uvPoint13D.x / textureScale, uvPoint13D.y / textureScale);
meshUVs[i * 3 + 2] = new Vector2(uvPoint23D.x / textureScale, uvPoint23D.y / textureScale);
meshTriangles[i * 3] = i * 3;
meshTriangles[i * 3 + 1] = i * 3 + 1;
meshTriangles[i * 3 + 2] = i * 3 + 2;
}
Mesh mesh;
if (MeshFilter.sharedMesh == null)
{
mesh = new Mesh();
}
else
{
mesh = MeshFilter.sharedMesh;
mesh.Clear();
}
mesh.vertices = meshVertices;
mesh.uv = meshUVs;
mesh.triangles = meshTriangles;
mesh.RecalculateNormals();
//mesh.RecalculateBounds();
MeshFilter.sharedMesh = mesh;
}
using UnityEngine;
using System.Collections.Generic;
namespace Kamgam.SBR2.LibTessDotNet
{
public class TriangulatedShape2D
{
protected Tess _tess;
public int[] Triangles
{
get { return _tess.Elements; }
set { }
}
public int TriangleCount
{
get { return _tess.ElementCount; }
set { }
}
public ContourVertex[] Vertices
{
get { return _tess.Vertices; }
set { }
}
public int VertexCount
{
get { return _tess.VertexCount; }
set { }
}
public TriangulatedShape2D(List<Vector2> pointList)
{
tesselate(new List<List<Vector2>>() { pointList });
}
public TriangulatedShape2D(List<List<Vector2>> pointLists)
{
tesselate(pointLists);
}
public TriangulatedShape2D(List<Vector3> pointList)
{
tesselate(new List<List<Vector3>>() { pointList });
}
public TriangulatedShape2D(List<List<Vector3>> pointLists)
{
tesselate(pointLists);
}
// First list is the contour. Second, third, ... are holes iirc.
protected void tesselate(List<List<Vector3>> pointLists)
{
_tess = new LibTessDotNet.Tess();
for (int p = 0; p < pointLists.Count; p++)
{
var contour = new LibTessDotNet.ContourVertex[pointLists[p].Count];
for (int i = 0; i < pointLists[p].Count; i++)
{
contour[i].Position = new LibTessDotNet.Vec3(pointLists[p][i].x, pointLists[p][i].y, pointLists[p][i].z);
}
_tess.AddContour(contour, LibTessDotNet.ContourOrientation.Original);
}
_tess.Tessellate(LibTessDotNet.WindingRule.EvenOdd, LibTessDotNet.ElementType.Polygons, 3);
}
protected void tesselate(List<List<Vector2>> pointLists)
{
_tess = new LibTessDotNet.Tess();
for (int p = 0; p < pointLists.Count; p++)
{
var contour = new LibTessDotNet.ContourVertex[pointLists[p].Count];
for (int i = 0; i < pointLists[p].Count; i++)
{
contour[i].Position = new LibTessDotNet.Vec3(pointLists[p][i].x, pointLists[p][i].y, 0);
}
_tess.AddContour(contour, LibTessDotNet.ContourOrientation.Original);
}
_tess.Tessellate(LibTessDotNet.WindingRule.EvenOdd, LibTessDotNet.ElementType.Polygons, 3);
}
}
}
The code is just an excerpt, don’t expect it to work out of the box. It should help you to get started.
You will have to write your own mesh generation code based on your needs anyhow. I think I only used tri-planar shaders on those mehses, so I am not sure if the generated UVs are any good.