Hi all, I need some help figuring out what's the best way to compute per-point or per-vertex normals on geometry that only has them per-primitive.
My first attempt has been to average the normal vector of all faces/primitives of which a point is part of. This is what I'm doing (in pseudo-code): for each point { N = (0,0,0) for each primitive { for each vertex in this primitive { prim->build_indices(...) check if point index == current point if it does: add this primitive's normal to N } } divide N by number of primitives that use this point normalize N } Now, this works, but it's extremely slow, mainly becauseof the rather redundant set of loops (looping through all primitives for each point). In trying to optimize this, I've seen some methods in the Primitive class that look like they could help, but I haven't been able to get anything out of them. Particularly: Primitive::get_geometric_normal() Primitive::get_face_normal() Can't get anything out of neither of them. They both return a (0,0,0) vector. They both take a PointList*. Am I right in assuming I should feed them the full PointList* for my object as returned by GeoInfo::point_list() ? Also tried with: Primitive::get_vertex_faces() which is supposed to fill in an std::vector of face indices, but I'm always getting 0 out of it. Any help on the best approach to compute per point normals would be greatly appreciated. Also, how are the Primitive methods mentioned above meant to work? It looks like they could be extremely useful in this case, but I must be missing a step somewhere. Thanks, Ivan
_______________________________________________ Nuke-dev mailing list Nuke-dev@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-dev