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;
}
}
----- Original Message -----
Sent: Wednesday, March 14, 2001
11:54 AM
Subject: Re: [JAVA3D] How to
repaint the J3D scene after an interactive input
Try putting a BranchGroup called root in
the simple universe, then attaching your dynamic branchgroups to root,
then using the detach() method to remove the dynamic branch groups from
root. Make sure you set the capabilities of the nodes to
allow detaching.
Dave Yazel
----- Original Message -----
Sent: Wednesday, March 14, 2001
4:08 AM
Subject: [JAVA3D] How to
repaint the J3D scene after an interactive input
Hi All,
I have met a problem in updating scence
graph (display). In interactive computer graphics, we need to update
the screen display after adding a new graphics primitive. In
Java 2D, we can use repaint() mothed. Now, I use SimpleUniverser to
setup a virtualUniverse and a Locale, After adding the first 3D
shape, I add a Branchgraph to the Universer. The screen can display
the scene correctly. However, after inputting another 3D shape from
menu, I can not romove the old BranchGraph, and can not update the
scene to include the newly input. It seems that there is
no removeBranchGraph() method in SimpleUniverser object. How can I
use Java3D in an interactive way?
Thanks
Sheng
Qin