Okay. Before changing your normals, verify if the two faces you are testing have an angle of more than 89.99 degrees or not. if they have more, don't merge the vectors. In that case, each polygon 's point at this place must have its vector, so don't merge the points (if ever you do). That vector should be perpendicular to the polygon.
Is there any reason you don't use java3d's normal calculation? It has a parameter for angle smoothing and takes care of everything while optimising your object. Very nice utils.
For example, here is how i use it for a landscape program of mine.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| GeometryInfo gi = new GeometryInfo(GeometryInfo.TRIANGLE_ARRAY); gi.setCoordinates(pts); gi.setTextureCoordinateParams(1,2); gi.setTexCoordSetMap(new int[]{0, 0, 0}); gi.setTextureCoordinates(0,texCoords);gi.setColors(colors);NormalGenerator ng = new NormalGenerator();ng.generateNormals(gi);gi.recomputeIndices();Stripifier st = new Stripifier();st.stripify(gi); gi.recomputeIndices();Shape3D scape=new Shape3D(); scape.setGeometry(gi.getGeometryArray()); |