Skip to main content

Transparency and/or Normal Issue

No replies
Valentiinro
Offline
Joined: 2011-03-18
Points: 0

My colleage and I are trying to draw a transparent sphere-like object. We've created the geometry for it by creating an array of points on the surface of said sphere, then we go through the array and make it into triangles (by duplicating the relevant points) . We then add this new point array into a new GeometryInfo object set to recieve triangles. Then we do this:

GeometryInfo geometryInfo = ArrangePointsTriangles(generatePoints());
geometryInfo.convertToIndexedTriangles();
normalGenerator.generateNormals(geometryInfo);
stripifier.stripify(geometryInfo);

Which makes the geometry into strips of indexed triangles, which makes it more efficient or some such.

The appearance is made with this next block of code:

appearance = new Appearance ();
appearance.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL,PolygonAttributes.CULL_NONE,(float)0.0,true));
appearance.setMaterial(new Material(new Color3f(r,g,b),new Color3f(0,0,0),new Color3f(r,g,b),new Color3f(r,g,b),shiny));
appearance.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.FASTEST,.8f));

This whole object is contained in a transform group positioned 5 units deep which is itself in a transform group we can rotate with mouse control which is in a simple universe with a directional white light facing towards the object.
In the image below the left (tilted downward a bit) side is the front, and the right (tilted up a bit) is the back.

For some reason it seems the normals are flipping in a weird way (the top is clearly lighter than the bottom, which indicates that the normals start flipping halfway down...

What are we doing wrong here? Could it be that because we are moving a transform group instead of some kind of view object the normals are flipping with respect to the wrong thing?

We havent really experimented with the view and universe much aside from doing this:

universe.getViewingPlatform().setNominalViewingTransform();

In case the image isn't showing up on the forum:
http://hphotos-ash1.fbcdn.net/173092_741673443416_10508597_39496671_5869...