|
Hi Dave,
Thank you for your help on repainting J3D. I have
tried dynamic branchgroup and detach() method, but i still can go through. Could
you please have a look at my code, I first create a SimpleUniverse and a
root BranchGraph--scene, and a dynamic node. In drawsceneGraph method, If it is
a first call, active3D is false. Afterwards, detach the dynamic node first, then
add it to scene again.
//////////////////////////////////////////////////////////////////////
GraphicsConfiguration config
=
SimpleUniverse.getPreferredConfiguration(); c = new
Canvas3D(config
add(c,BorderLayout.CENTER); u = new SimpleUniverse(c); scene=createBranchGraph(); // Create a dynamic branch graph dynamicBGroup = new BranchGroup(); dynamicBGroup.setCapability(BranchGroup.ALLOW_DETACH); /////////////////////////////////////////////////////////////
public void drawSceneGraph() {
if(active3D)// if it is not first time to display the scene { dynamicBGroup.detach(); } // Create a bounds for the background and lights BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 300.0 TransformGroup objTrans = new
TransformGroup();
objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_READ ); objTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING); drawShapeObjectToScene(objTrans);
// Create the rotate behavior
node
MouseRotate behavior = new MouseRotate(objTrans); objTrans.addChild(behavior); behavior.setSchedulingBounds(bounds); // Create the zoom behavior
node
MouseZoom behavior2 = new MouseZoom(objTrans); objTrans.addChild(behavior2); behavior2.setSchedulingBounds(bounds dynamicBGroup.addChild(objTrans); scene.addChild(dynamicBGroup); if(!active3D) { scene.compile(); u.addBranchGraph(scene); u.getViewingPlatform().setNominalViewingTransform(); active3D=true; } }
|
