Re: Mac Canvas3D location bug
Posted by
Manu on
Sep 25, 2013; 11:45pm
URL: https://forum.jogamp.org/Mac-Canvas3D-location-bug-tp4030052p4030116.html
It's still more simple to generate a unit test for me, and it will be easier for you to test your changes.
So, here's a simple test showing a color cube in a canvas 3D laid out with split panes:
import java.awt.GraphicsEnvironment;
import javax.media.j3d.*;
import javax.swing.*;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;
public class Canvas3DPositionTest {
public static void main(String [] args) {
// Create a simple scene with a rotated color cube
BranchGroup root = new BranchGroup();
Transform3D rotation = new Transform3D();
rotation.rotX(Math.PI / 9);
TransformGroup rotationGroup = new TransformGroup(rotation);
root.addChild(rotationGroup);
rotationGroup.addChild(new ColorCube(0.5f));
// Add scene to a new canvas 3D
GraphicsConfigTemplate3D gc = new GraphicsConfigTemplate3D();
Canvas3D canvas = new Canvas3D(GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getBestConfiguration(gc));
SimpleUniverse universe = new SimpleUniverse(canvas);
universe.getViewingPlatform().setNominalViewingTransform();
universe.addBranchGraph(root);
// Build a GUI where the canvas 3D is supposed to be located at the top right
// of the frame and can be resized with split panes dividers
JFrame frame = new JFrame("Canvas3DPositionTest");
JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,
true, new JScrollPane(), canvas);
horizontalSplitPane.setResizeWeight(0.5);
JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
true, horizontalSplitPane, new JScrollPane());
verticalSplitPane.setResizeWeight(0.5);
frame.add(verticalSplitPane);
frame.setSize(400, 400);
frame.setVisible(true);
}
}
Hope this will help.
Emmanuel Puybaret