I'm interested to know why the smooth-shading picture for the JOGL backend looks so odd.
To help debug, there are two static methods, one old and one new, which could help.
First, IndexedFaceSetUtility.displayFaceNormals(...) will display the face normals, and
Second, (new) PointSetUtility.displayVertexNormals(...) does the same for the vertex normals.
Typical usage:
Code: Select all
IndexedFaceSet ifs;
SceneGraphComponent world = new SceneGraphComponent();
world.setGeometry(ifs);
world.addChild(IndexedFaceSetUtility.displayFaceNormals(ifs, .1, Pn.EUCLIDEAN));
The second parameter is a scaling factor, and the third is probably not of interest here.
To see the vertex normals, replace the last line with
Code: Select all
world.addChild(PointSetUtility.displayVertexNormals(ifs, .1, Pn.EUCLIDEAN));
There are various possibilities. Since the problem happens with smooth shading, it's important to know how the JOGL backend does smooth shading. It uses vertex normals if they are present, or if not, it will repeat the face normal for each vertex of the face when rendering the face. The
displayVertexNormals() method will throw an exception if there are no vertex normals attached to the instance, so you'll quickly find out if the geometry has vertex normals, and if so, this method will display them.
If it
doesn't have vertex normals, you can create them for you geometry using the method
IndexedFaceSetUtility.calculateAndSetVertexNormals() (or one of its variants). Compare the smooth-shaded results when you use these vertex normals.
My suspicion is that the normals provided with the object are inconsistently oriented. This should be clear when you display the normals as outlined here.