Hi Florin,

Thanks a lot for your reply.

"I need to update 3 times"  - this means in the life time of the scene.
Initially while creating the scene I have some coarser geometries, which I
want to load and show because that helps me in showing the first scene
quickly. After that I refine these geometry nodes around three times adding
more refined forms at each step.  And in the last round I add the final
geometries which I dont edit till the lifetime of the scene.

"a lot of time" ? Basically I had performance problem with my application
and I went on doing few experiments. The data is given below.
 - for 100 BGs each containing 25 TGs( and java's standard cube geometries
to be replaced with java's standard sphere geometries) addChild( newBG)
takes 1.4 sec and detach takes 0.55 sec.  And for 200 BGs each containing
100 TGs( and )
 - for 200 BGs each containing 100 TGs( and java's standard cube geometries
to be replaced with java's standard sphere geometries) addChild( newBG)
takes 11.2 sec and detach takes 22.5 sec.

above two are experiments that I had done with HelloUniverse demo
j3d1.2.1_03 and jre1.3.1_03 versions.

In my application I have 2000 BGs each of them has a bg, a tg and a shape
with Geometry (varies in size). In this case the total addChild() time is
1.5 minutes and total detach time is 2.5 minutes. Moreover, while doing
this, it makes the application thread( main thread) slower, so the data
pushing thread (fetches data from a remote rmi server and adds the data to
live scenegraph) also takes around 60% more time than it takes if we dont
pop the data into the scenegraph. What is happening is when we call
addChild() and detach() one after another continuously, the whole
application becomes slower and most probably the data pushing threads dont
get CPU attention properly. I even tried to reduce the thread priority of
all java3d rendering threads by using VirtualUniverse.setJ3dThreadPriority()
call which seems to be ignored totally !

question : does application writers have any control on the java3d threads?
I mean can I control the rendering thread by saying that I want to edit the
scenegraph but you dont need to update the view till the time I tell you to
do it explicitly. Since there are so many threads running to keep track of
user inputs, geometry updates, rendering attribute updates, behavior changes
etc, adding & detaching data seems to be a time consuming task. I am aware
of the problems that Java3d will face if they provide the hooks I am looking
for, but still wondering if there is a work around for this !

I will try out the approach you have described. So the steps will be -

1. add a Switch to the scene.
2. add a coarser geometry under the switchBG and set the mask to render it.
3. get a less coarser geometry( little refined form of the earlier one) and
add it to the Switch. And change the mask to render the new Geometry and
mask off the old one.
Note -This will take some time I guess, if this time is less that
"addChild(newBG) + detach(oldBG)" time, there will be an advantage. Anyways
I have to repeat this for 2000 BGs, so actually for me it matters how much
time it takes. The advantage being that I have a control on when to render
what and I can use some logic to change the mask at certain point of time
when I have actually added few geometries and I want to update the view.
4. go on till the final Geometry addition like this.

Do you have any other suggestions as I have given you more details in this
mail? Please let me know.

thanks once again !
- Anir


----- Original Message -----
From: "Florin Herinean" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, February 10, 2003 2:37 PM
Subject: [JAVA3D] AW: [JAVA3D] Performance problem with live scenegraph


> What do you mean "I need to update 3 times" ? Three times in the lifetime
of
> the scene or three times per minute, per second ? (it's obvious that it
> doesn't make sense to update 3 times per frame).
>
> What do you mean by "a lot of time" ? That is dependent of the way you
look
> at the time. Sometimes 0.5 sec means short if it happens once per hour,
> sometimes 0.5 sec means very, very long if it happens every frame! So,
> please give us some figures.
>
> For example:
> Detaching a branch group with 1488 shapes containing 39222 vertices takes
> around 0.5 sec. Strange effects: If I'm detaching immediately after
> attaching, it takes regularly 200 ms more than if I'm waiting a while for
> the scene to "warm up"!
>
> Detaching a branch group with 22958 shapes containing 103987 vertices
takes
> around 80 sec.
>
> Proposal for approach 4 ;-)
>
> Use a "master" Switch. To this one you add the original geometry. When you
> need to change it, add the new geometry (still invisible). When finished
> with adding (you don't care about the amount of time needed), just change
> the switch. Set the mask of the switch so that the new geometry is visible
> and the old one invisible. Now you can take your time to detach the old
> geometry. By geometry I mean a complete branch group.
>
> Cheers,
>
> Florin
>
>
> -----Urspr�ngliche Nachricht-----
> Von: Anirban Bhadore [mailto:[EMAIL PROTECTED]]
> Gesendet: Montag, 10. Februar 2003 07:24
> An: [EMAIL PROTECTED]
> Betreff: [JAVA3D] Performance problem with live scenegraph
>
>
> Hi guys,
>
> I have performance problem with editing a live scenegraph. The problem is
> described below.
>
> Problem : I have 2000 shape3d nodes which I need to update three times in
> the scene.
>
> Approach 1 : I creat a new BranchGroup along with Shape3D and a new
Geometry
> object and "add"( rootBranchGroup.addChild( newBG)) the new BranchGroup to
> the SceneGraph. After this I "detach"( OldBG.detach()) the old BranchGroup
> which was holding the last geometry. This addChild() and detach() calls
are
> taking lot of time.
>
> Approach 2 : I find out the Geometry nodes and update the Geometry
reference
> by executing MyShape3dObj.setGeometry( newGeometryObj). This also is
taking
> almost the same time.
>
> Approach 3 : I tried to stop the renderer of the Canvas3D by calling
> Canvas3D.stopRenderer() and use the Immediate mode rendering to draw the
> geometries directly with the 3dGraphicsContext from the Canvas3D object.
> This also did not give me any performance benifit.
>
> Analysis : I have seen the java 3d code of addChild() and detach()
methods.
> These uses a MasterControl lock in the VirtualUniverse class for rendering
> threads( Behavior Scheduler, Renderer, UserInputHandeler, Geometry change
> handler etc) which makes the whole process of editing a live scene graph
> very slow.
>
> So as it looks like manipulation of a live scene graph has a major
> performance problem. Am I missing something? Any suggestions? How the game
> writers are handling these scenarios in Java3d?
>
> Hope somebody writes back !
>
> thanks
> Anir
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to