public void EvaluateNormals(OutputMesh mesh, CPNGuide guide) { int N = guide.GetN(); if (N <= 0) { return; } bool doTangents = mesh.DoUseTangents(); bool doNormals = mesh.DoNormals(); if (doNormals) { float step = 1.0f / N; for (int j = 1; j < N; j++) { EvalAt(j * step, guide); Vector3 dev; Vector3 normal = EvalNormal(guide, out dev); int index = guide.GetIndex(j); mesh.SetNormal(index, normal.normalized); if (doTangents) { mesh.SetTangent(index, GetTangent(guide, dev, normal).normalized); } } if (doTangents) { for (int j = 0; j <= N; j += N) { EvalAt(j * step, guide); Vector3 dev = EvalDev(guide); int index = guide.GetIndex(j); Vector3 normal = mesh.GetNormal(index); mesh.SetTangent(index, GetTangent(guide, dev, normal).normalized); } } } }