Hi,
I'm having great problems using the IndexedQuadArray class. I've
included a little demo program below, which can be started with "java
Buggy" (after compilation).
As is, this program works fine: it displays a big white square, which
can be rotated using the mouse (due to culling effects, only the front
face of the square is visible, but that's ok). The square was
constructed using an IndexedQuadArray geometry (which contains just one
quadrilateral, being the square itself).
The problem comes into being only if you uncomment the marked line,
which simply adds a ColorCube to the scene graph. The former square now
turns into a TRIANGLE. But what happened to the specified SQUARE?
Now, can anyone tell where this bug comes from? Did I miss something?
BTW, I'm running this on Solaris 2.6 with OpenGL 1.1.2.
I am not interested in any workarounds, since I could (hopefully) figure
out them by myself :-), but I'd really like to know what causes the bug
(me, Java or OpenGL).
thx
Heiko
------------------ cut here ---------------------
import javax.swing.JFrame;
import javax.media.j3d.*;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.behaviors.mouse.*;
import javax.vecmath.*;
public class Buggy extends JFrame {
public Buggy() {
super("Buggy");
Canvas3D canvas = new Canvas3D(null);
getContentPane().add(canvas);
BranchGroup scene = createSceneGraph();
scene.compile();
SimpleUniverse universe = new SimpleUniverse(canvas);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(scene);
setSize(500, 600);
setVisible(true);
}
public BranchGroup createSceneGraph() {
BranchGroup scene = new BranchGroup();
TransformGroup trans = new TransformGroup();
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
Shape3D buggyShape = createBuggyShape();
trans.addChild(buggyShape);
MouseRotate mouseRotate = new MouseRotate(trans);
mouseRotate.setSchedulingBounds(new BoundingSphere());
scene.addChild(mouseRotate);
scene.addChild(trans);
// ------------------ This is the line!!!! ---------------
// If this line is uncommented, the bug will appear
// scene.addChild(new ColorCube(0.1f));
// ------------------ This was the line!!!! ---------------
return scene;
}
// here the shape is created using a IndexedQuadArray
public Shape3D createBuggyShape() {
Shape3D buggyShape = new Shape3D();
// define 4 triples of coordinates (x, y, z) = a square
float c[] = { -0.5f, -0.5f, 0,
0.5f, -0.5f, 0,
0.5f, 0.5f, 0,
-0.5f, 0.5f, 0 };
int i[] = { 0, 1, 2 , 3};
IndexedQuadArray quadArray = new IndexedQuadArray(4,
IndexedQuadArray.COORDINATES,4);
quadArray.setCoordinates(0, c);
quadArray.setCoordinateIndices(0,i);
buggyShape.setGeometry(quadArray);
return buggyShape;
}
public static void main(String[] args) {
new Buggy();
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".