public void TestComputeNormal() { PointList list = new PointList(); list.Add(0f, 0f, 0f); list.Add(1f, 0f, 0f); Assert.AreEqual(Vector3.zero, list.ComputeNormal()); list.Add(0f, 1f, 0f); Assert.AreEqual(new Vector3(0f, 0f, 1f), list.ComputeNormal()); }
// // Get the best UV Mapper // private static IUVMapper ComputeUVMapper(PointList points) { IUVMapper result = null; Vector3 normal = points.ComputeNormal().normalized; if (Mathf.Abs(normal.y) > 0.95f) { result = new FlatXZMapper(); } else if (Mathf.Abs(normal.x) > 0.95f) { result = new FlatYZMapper(); } else if (Mathf.Abs(normal.z) > 0.95f) { result = new FlatXYMapper(); } else { // More computation needed FlatMapper mapper = new FlatMapper(); mapper.InitLastSideU(points); mapper.SetConstraint(new Vector3(-0.5f, 0, 0), new Vector2(0, 0)); result = mapper; } return(result); }
void Extend(PointList points, MeshBuilder builder) { Vector3 n = points.ComputeNormal(); PointList pointsB = points.Translate(0.4f * n.normalized); builder.Cap(points.Bridge(pointsB, PointList.BridgeMode.CloseReuse)); DigHole(pointsB, builder); }
void DigHole(PointList points, MeshBuilder builder) { Vector3 n = points.ComputeNormal(); PointList pointsC = points.Scale(0.5f); PointList pointsD = pointsC.Translate(-0.1f * n.normalized); builder.Cap(points.Bridge(pointsC, PointList.BridgeMode.CloseReuse)); builder.Cap(pointsC.Bridge(pointsD, PointList.BridgeMode.CloseReuse)); builder.Cap(pointsD); }
// Init with 1:1 scale between geometry space and uv space, and no rotation // Enough to set uVec and vVec, uCst and vCst are left as is public void InitLastSideU(PointList points) { uVec = (points [points.Count - 1] - points [0]).normalized; vVec = Vector3.Cross(uVec, points.ComputeNormal()).normalized; }
// Init with 1:1 scale between geometry space and uv space, and no rotation // Enough to set uVec and vVec, uCst and vCst are left as is public void InitFirstSideV(PointList points) { vVec = (points [1] - points [0]).normalized; uVec = Vector3.Cross(points.ComputeNormal(), vVec).normalized; }