To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: Re: [java3d] Threading/scheduling issues
Hi Eric,
The only reliable way to do what you want to do is to stop the
traverser and renderer by stopping the view. This is done as
follows:
In your thread following all of your scene graph updates:
view.stopView();
canvasReady = true;
view.startView();
In your Canvas3D.postSwap() method:
if (canvasReady) {
takeSnapshot();
canvasReady = false;
}
You need to ensure that the scene graph doesn't change between setting
canvasReady and taking the snapshot. If you have free running
behaviors, you may want to stop the behavior scheduler
(View.stopBehaviorScheduler) prior to stopping the view, and restart
it after the snapshot is taken.
--
Kevin Rushforth
Java 3D Team
Sun Microsystems
[EMAIL PROTECTED]
>Date: Tue, 18 May 1999 13:44:43 -0700
>From: Eric Hawthorne <[EMAIL PROTECTED]>
>
>I'm trying to write a Java3D program where, in a separate thread from
>the rendering loop, I directly make a change to a live transformgroup
>in order to move/turn the viewplatform. I then need to capture as an
>image a rendered frame which has been rendered AFTER the move or turn
>has been accomplished. The frame image is being captured in my
>overridden Canvas3D.postSwap() method.
>
>The problem I'm facing is being able to figure out which frame to
>capture in order to guarantee that my frame was rendered after the
>transformgroup change takes effect.
>
>Currently, I set a flag (viewChanged) after the call to set the
>transformGroup's transform has returned (all this in my own
>application's separate thread.)
>
>Now, in preRender(), if the viewChanged flag is true (i.e. supposedly
>the transformgroup has been changed before this render is going to
>take place), I set another flag that tells my postSwap() to capture
>the frame. Flags are reset after capturing.
>
>However, using this method, I am finding that almost always, if not
>always, the frame I get as an image is a frame that reflects the state
>of the model just BEFORE to transformgroup change takes effect.
>
>Does anyone know why this is? It seems to me that my
>transformGroup.setTransform(Transform3D) call should not return until
>after it has effectively changed the scenegraph, and that a
>render-sequence whose preRender() is called AFTER setTransform()
>returned (regardless of thread) should reflect the changed scenegraph.
>
>Does anyone know a better way I could accomplish this?
>
>Eric
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/