What is the correct approach to have my behavior do all object and
view updates before rendering? Do I need to do offscreen rendering to
fix this?
Thanks
I would highly suggest that you use something other than Java 3D if
you can at all help it. It is no longer supported by the Java
community (or even Sun) it seems. jME (J Monkey Engine) is a decent
alternative and there are a few other alternatives you can look at.
Anyway, abandoning Java 3D is an option and makes sense over the long
term, but it might not be the best option short term if one has a lot
of code invested in it, especially when a fix for a specific problem
is available and well-known:
Java 3D has a 1-frame latency between the view parameters currently in
use by the renderer and the scene graph view platform position that
the application sets. So if you take the view parameters from
something like Canvas3D's ImagePlateToVworld and align some geometry
in the scene graph to it, it will end up being 1 frame behind the
actual view by the time the scene graph is actually updated by the
system.
The ViewInfo utility class (somewhere in com.sun.j3d.utils.universe)
will give you view info that is up-to-date with respect to the current
state of the scene graph.
-- Mark
i give a example:
ColorCube cube=new ColorCube();
BranchGroup modelObj=new BranchGroup();
TransformGroup trasnformModel=new TransformGroup();
TransformGroup rotateModel=new TrasnformGroup();
rotateModel.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
rotateModel.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
rotateModel.addChild(cube);
transformModel.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
transformModel.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
transformModel.addChild(rotateModel);
modelObj.addChild(transformModel);
//Transform to Move the object and rotate
Transform3D t3d= new Transform3D();
Transform3D t3dRot= new Transform3D();
Transform3D t3dMov= new Transform3D();
//Movement
t3dMov.setTranslation(new Vector3d(0.0f,0.0f,1.0f));
t3d.mul(t3dMov);
transformModel.setTransform(t3d);
//Rotate all the object
t3dRot.rotX(x);
t3d.mul(t3dRot);
transformModel.setTransform(t3d);
//New Transform to Rotate the object but doesnt change his egde
Transform3D t3d2= new Transform3D();
Transform3D t3dRot2= new Transform3D();
//Rotate the object but in the same edgde
t3dRot2.rotZ(z);
t3d2.mul(t3dRot2);
rotateModel.setTransform(t3d2);
i hope it's help you! :)
pd: sorry my english