|
Hi everyone
I had i similar problem like Lee - i was only too
busy to post it. Now it seems to the right moment...
First, i have to explain a couple of things. In my
program there's a "ExplosionPool" class. It has "Explosion"
Objects(OrientedShape3D with a animated texture). The pool reuses Explosion
objects. The Explosions are attached and detached to the live scene as
needed.
Okay, the weird thing was that my "Laser"
objects(OrientedShape3D) disappeared sometimes after the detach() call of the
Explosion object. Other scene members were still visible. *All* Laser objects
were visible again, when a new Explosion was attached to the scene.
It drove me nuts because i couldn't find any errors
in my code or scenegraph structure. I came to the conclusion that it's a Java3D
bug. Anyways, i finally found a weird work-around for that weird problem: i
detached the Explosion not right away when the Explosion is over. Instead it was
detached before it was going to be reused and attached again. I still don't know
why it worked fine then...
Here's a "hot spot" of the code:
public synchronized void
startExplosion(Vector3d position, float scaleFactor,Informable
informMe)
{ Explosion ex; if(list.isEmpty()) ex=createElement(); else ex=(Explosion)list.remove(0); ex.reset(position,scaleFactor,informMe); BranchGroup exBG=ex.getBranchGroup(); if(exBG.isLive()) exBG.detach(); // Does work group.addChild(exBG); } protected synchronized void finishedExplosion(Explosion ex) { BranchGroup exBG=ex.getBranchGroup(); //if(exBG.isLive()) exBG.detach(); // Does NOT work!! list.add(ex); } The .java is attached...
(The complete program isn't suitable to be
posted)
I hope this helps.
Regards,
Markus
|
- [JAVA3D] HELP! Re-attach of BranchGraph() with >1 ligh... J. Lee Dixon
- Re: [JAVA3D] HELP! Re-attach of BranchGraph() with &... Markus Junginger
- Re: [JAVA3D] HELP! Re-attach of BranchGraph() with &... Yazel, David J.
- Re: [JAVA3D] HELP! Re-attach of BranchGraph() with &... Kelvin Chung
ExplosionPool.java