Skip to main content

Geometry not being rendered

1 reply [Last post]
Joined: 2004-12-20

We have a situation where objects which we can verify are in the Java3D scene graph, and are marked as live, are not being rendered - we have a simple utility which walks the tree and lists the objects. The problem occurs when expanding/pairing (addChild/detach) the scene graph, and is not always reproducible, indicating a threading/timing issue and Java3D state inconsistency. It occurs more frequently if the addChild/detach occur on different threads, in close time proximity to one another. Interestingly, if we detach/addChild on an object which should be rendered, but isn't, it will appear in the display. The final state is fine if we simply toggle off the removed object via a switch, but of course the detach is necessary to free-up resources. We've tried using Behaviors, and manually synchronizing our access to the scene graph, but to no avail. We're sorta at our wits end here, does anyone have any experience with a problem like this, or suggest a possible work around, or perhaps a safer way to manage the scene graph?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-06-07

Hi, just a little brainstorming about a safer way to manage the scene graph:

- Object means BranchGroup which holds Shape3Ds directly or somewhere in its subgraph

- Atomic addChild and detach invocations are (should be !) reliable if one invocation is initiated not before another one is fully executed on several internal threads in later engine loops. The methods addChild and detach do not wait.

- The key issues seem to be:

[b]A.[/b] When is an addChild or detach invocation completely executed and does the engine give any hint when this has happened?
[b]B.[/b] How to manage that these calls are executed consecutively?

- The GraphStructureChangeListener which is to be added to the VirtualUniverse doesn't really help here. Listeners are notified on the same thread as the addChild and detach methods are called and don't wait either. The branchGroupAdded callback is invoked just before the child is added to the parent.

[b]To A[/b].
Unfortunately, I'm not aware of any Java 3D feature that informs about the termination of all internal state updates and a rerun of the renderer. I don't think that we can rely on a Canvas3D callback method in this case. But, there is an indicator that something has happened. After adding or removing objects the frame number of the View increments (see View.getFrameNumber()). After a period of about 5 frames all states should be updated.

[b]To B.[/b]
Instances of a [i]Task[/i] class holding a single object and all data for adding or removing it could be queued in an appropriate collection (java.util.Queue). As soon as and as long as this collection has elements, a Behavior is started (WakeupOnBehaviorPost) and kept running (WakeupOnElapsedFrames(0)). This Behavior calls the Task instances to invoke addChild or detach, removes them from the queue, and takes care that between these calls more than a specific amount of frames has elapsed.

HTH and good luck. It would be great if you'd share the concept of your solution with the community.