Notifications
Clear all
[Closed] SDK: How do I collect and store vertex normals?
Mar 25, 2016 2:58 am
I’ve got the following:
Mesh mesh;
// ... (get Mesh to work with)
Tab<Point3> VertNormals;
for (int p=0; p<vnum; p++) {
//VertNormals[p] = mesh->getNormal(p); // crashes, try something else
Point3 &vn = mesh->getNormal(p); // so far so good
VertNormals[p] = vn; // back to crashing, but what should I be doing here instead?
}
What is the right way of doing this?
5 Replies
Mar 25, 2016 2:58 am
Your Point3Tab has no members, so trying to access a location in the array by index will crash, of course. You can do that with maxscript, but only because maxscript allows all kinds of cheating.
Append the new members to your tab instead.
Mar 25, 2016 2:58 am
Actually, my mistake in posting, and I can see where that would be the case, but I left a few things out when I posted for the sake of simplicity, including one I should have left in. I actually do have a line
VertNormals->SetCount(vnum);
prior to my for loop. So I don’t think that’s the problem.
Mar 25, 2016 2:58 am
and what happens if you do foll ?
VertNormals.SetCount(0)
..
{
..
VertNormals.Append(1, &vn);
}
btw: did you BuildNormals() ?
Mar 25, 2016 2:58 am
You also need to check for explicit normals (i.e., Edit Normals Modifier).