THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/08/2007 at 09:11, xxxxxxxx wrote:
I wouldn't just normalize the x,y,z vertex coordinates. This is just the vector from the object's origin to that point which will result in incorrect vertex normals.
For CreatePhongNormals(), you could pick out the values in the array returned. First, make sure that there is a Phong tag - since it is required. You can easily add one temporarily while doing the export:
// Check for existing Phong tag
Bool phongAdded = FALSE;
if (obj->MakeTag(Tphong)) phongAdded = TRUE;
else // whoops, couldn't add a Phong tag, so try the other method of calculating vertex normals
// continue on with CreatePhongNormals()
// after processing, remove added Phong tag
if (phongAdded) obj->KillTag(Tphong);
You'll probably also want to remove n-gons as CreatePhongNormals() doesn't appear to consider them. Unfortunately, it gets complex so if you never expect n-gons you might assume standard polygons.
Then you call CreatePhongNormals() to get your 4*polygoncount 'CPN' array. Create a vector 'VN' array the size of GetPointCount(). Now, you need to go through both the CPN array and the Polygon array simultaneously and fill in the VN array by vertex index. Unless you have another array to track which VN elements have already been set, you'll just fill in the same values multiple times. In the end, you'll have a single array with the vertex normals correlated to the point array. GeFree() the CPN array.