< Zurück | Inhalt | Weiter >

C.1 Box objects and GeomBuffer

Arguably there is a bug in the Box class because the faces of the cube are defined using two triangles. TriangleArrays are quicker to render than QuadArrays, but when the Box is rendered as a wireframe (i.e., only the edges of the Box are drawn), an extra diagonal line is drawn that separates the two triangles that define a face. This bug was not present in Java 3D 1.1 and was introduced in Java 3D 1.1.1. With luck, the bug will be rectified in subsequent releases.

If you require that your Box objects be rendered as wireframes, the following class can be used instead of Box to ensure the faces are rendered correctly. The Box class must be simply modified to create an OldGeomBuffer object instead of a GeomBuffer.


From CuboidTest\Cuboid.java
OldGeomBuffer gbuf = new OldGeomBuffer(4); gbuf.begin(OldGeomBuffer.QUAD_STRIP);
From CuboidTest\OldGeomBuffer.java
private GeometryArray processQuadStrips()
obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.NORMALS | QuadArray.TEXTURE_COORDINATE_2);
obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.TEXTURE_COORDINATE_2);
obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.NORMALS);
obj = new QuadArray(totalVerts, QuadArray.COORDINATES);