public void writeWithGuideBack(CPNSideEdge guide, int N, float step, OutputMesh mesh, CPNGuideEvaluator evaluator) { this.step = step; requestSize(N + 1); //We should have only one thickness on multisided edge, you know? this.thickness = 1; for (int i = 0; i <= N; i++) { //This is the eval-back evaluator.EvalAt(1.0f - i * step, guide); Vector3 dev = evaluator.EvalDev(guide); vertices[i] = evaluator.EvalVertex(guide); if (i == 0) { devFirst = dev; } if (i == N) { devLast = dev; } evaluator.EvalAt(i * step + DELTA, guide); verticesDplus[i] = evaluator.EvalVertex(guide); evaluator.EvalAt(i * step - DELTA, guide); verticesDminus[i] = evaluator.EvalVertex(guide); normals[i] = evaluator.EvalNormal(guide, dev).normalized; uvs[i] = evaluator.EvalUV(guide); for (int k = 0; k < countP; k++) { properties[k][i] = evaluator.EvalProperty(guide, k); } } }
private float approximateGuideSize(CPNGuide guide) { CPNGuideEvaluator evaluator = new CPNGuideEvaluator(); int STEPS = 8; float step = 1.0f / STEPS; Vector3 preV = guide.vBuffer[0]; float distance = 0; for (int i = 1; i <= STEPS; i++) { evaluator.EvalAt(i * step, guide); Vector3 V = evaluator.EvalVertex(guide); distance += Vector3.Distance(V, preV); preV = V; } if (distance == 0) { distance = 0.001f; } return(distance); }
public void writeWithGuideBack(CPNSideEdge guide, int N, OutputMesh mesh, CPNGuideEvaluator evaluator) { writeWithGuideBack(guide, N, 1.0f / N, mesh, evaluator); }