Ear-Clipping-Triangulation
Ear-Clipping-Triangulation copied to clipboard
"Error triangulating mesh. Aborted." Error
I'm trying to make test mesh from 4 points and get this error:
Error triangulating mesh. Aborted.
UnityEngine.Debug:LogError(Object)
Sebastian.Geometry.Triangulator:Triangulate() (at Assets/Ear-Clipping-Triangulation/Triangulator.cs:72)
Sebastian.Geometry.CompositeShape:Process() (at Assets/Ear-Clipping-Triangulation/CompositeShape.cs:87)
Sebastian.Geometry.CompositeShape:GetMesh() (at Assets/Ear-Clipping-Triangulation/CompositeShape.cs:29)
TrianTest:Start() (at Assets/TrianTest.cs:29)
This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sebastian.Geometry;
public class TrianTest : MonoBehaviour {
public MeshFilter meshFilter;
public List<Shape> shapes = new List<Shape>();
Shape basicShape = new Shape();
void init(){
shapes.Add(basicShape);
}
void Start () {
init();
addPointToShape(-1.0f, 0.0f);
addPointToShape(1.0f, 0.0f);
addPointToShape(1.0f, 2.0f);
addPointToShape(-1.0f, 2.0f);
CompositeShape compShape = new CompositeShape(shapes);
meshFilter.mesh = compShape.GetMesh();
}
void addPointToShape(float newX, float newY) {
basicShape.points.Add(new Vector3(newX, newY,0));
}
}
did you manage to fix this? ty!
basicShape.points.Add(new Vector3(newX, 0, newY));
CompositeShapeData ignores y coodinates. Try to swap z for y.