Question about Java3D and Transformations.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about Java3D and Transformations.

ZacharyABCD
This post was updated on .
If I have a Java3D Shape3D on a Node, and a Transform3D as its parent in the TransformGroup above it,

-How and where do I make a Transform3D itself fire?

-If I change the Transform3D with a different one, or in fact concatenate it with another one, how do I make
that transformation fire again?  Does this involve java3D itself automatically reparsing the entire node tree, or not?
Is this the firing call?

TransformGroup.setTransform(...);

-If the programming is running, and I alter the Node tree, will the tree auto update, go through the changes,
and execute any updates of removed sections and added sections, automatically?
Reply | Threaded
Open this post in threaded view
|

Re: Question about Java3D and Transformations.

philjord
The tree traversal is totally automatic and happens on each render pass. You don't need to fire the change or tell anything to update, calling setTransform() will cause the next rendered frame to be updated.

Java3D manages a somewhat complex structure to achieve this, with the values used for rendering being copies of the values you set, so there is never any concurrent modification issues, you can call the setTransfrom whenever you like.

If you are doing something that needs to update on a per frame basis or even on a transform update called by a different thread then the Behavior mechanism of Java3D is very powerful and full featured.

One exception to the concurrency rule is that you can't update by reference geometry data at will, so in that case you need to give a call back GeometryUpdater  to the GeometryArray.updateData()

These sorts of complexity removal features are the heart and soul of why a scene graph engine exists.

 
Reply | Threaded
Open this post in threaded view
|

Re: Question about Java3D and Transformations.

ZacharyABCD
Is a call to GeometryArray.updateData() tantamount to just altering the write permission
on some Geometry or Shape object?
Reply | Threaded
Open this post in threaded view
|

Re: Question about Java3D and Transformations.

Phil on his phone
Not really, the passed in callback object will get the updategeometry method called on the j3d geometry thread that is carefully managed to not occur during rendering, java3d has a large number of threads it manages so that concurrency is maximised but synchronization is maintained
Reply | Threaded
Open this post in threaded view
|

Re: Question about Java3D and Transformations.

philjord
In fact I just found some notes I made and one area where thread concurrency must be handled carefully is the BranchGroup addChild and removeChild methods; these are structure update calls and must not be called by 2 different threads.

My solution is to put structure updates into a behavior that wakes each frame and processes a queue of pending updates.