Thanks for the quick response.
Unfortunately it doesn't quiet solve the problem - simply detaching OR attaching
works fine.
The problem appears when I try doing following sequence:
- Attach the BG to a locale
- Do whatever's to be done..
- Detach the BG from the locale
- Reattach the BG (same instance) to another locale
In fact, my BG is a tiny guy who walks through several scenes.
Scenes change, but the guy doesn't - so I told myself why create an instance of
it in each scene..?
Chris
Desiree Hilbring wrote:
> Hi Chris,
> I do not know, if this solves your problem,
> I am detaching and attaching several light BranchGroups in my scene due to
> user interaction. I have for each light direction one BranchGroup which I
> am detaching and attaching.
>
> DirectionalLight
> northWest,northEast,south,southWest,southEast,west,east;
> DirectionalLight zenith;
> BranchGroup zenithBg,northWestBg,northEastBg,southBg,southWestBg;
> BranchGroup southEastBg,westBg,eastBg;
>
> I am instanciating them in the constructor:
>
> northWestBg = new BranchGroup();
> northWestBg.setCapability(BranchGroup.ALLOW_DETACH);
> northWest = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(1,-1,1));
> northWest.setInfluencingBounds(mouseBounds);
> northWestBg.addChild(northWest);
>
> northEastBg = new BranchGroup();
> northEastBg.setCapability(BranchGroup.ALLOW_DETACH);
> northEast = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(-1,-1,1));
> northEast.setInfluencingBounds(mouseBounds);
> northEastBg.addChild(northEast);
>
> eastBg = new BranchGroup();
> eastBg.setCapability(BranchGroup.ALLOW_DETACH);
> east = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(-1,-1,0));
> east.setInfluencingBounds(mouseBounds);
> eastBg.addChild(east);
>
> westBg = new BranchGroup();
> westBg.setCapability(BranchGroup.ALLOW_DETACH);
> west = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(1,-1,0));
> west.setInfluencingBounds(mouseBounds);
> westBg.addChild(west);
>
> southWestBg = new BranchGroup();
> southWestBg.setCapability(BranchGroup.ALLOW_DETACH);
> southWest = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(1,-1,-1));
> southWest.setInfluencingBounds(mouseBounds);
> southWestBg.addChild(southWest);
>
> southEastBg = new BranchGroup();
> southEastBg.setCapability(BranchGroup.ALLOW_DETACH);
> southEast = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(-1,-1,-1));
> southEast.setInfluencingBounds(mouseBounds);
> southEastBg.addChild(southEast);
>
> southBg = new BranchGroup();
> southBg.setCapability(BranchGroup.ALLOW_DETACH);
> south = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(0,-1,-1));
> south.setInfluencingBounds(mouseBounds);
> southBg.addChild(south);
>
> zenithBg = new BranchGroup();
> zenithBg.setCapability(BranchGroup.ALLOW_DETACH);
> zenith = new DirectionalLight(new Color3f(1,1,1),new
> Vector3f(0,-1,0));
> zenith.setInfluencingBounds(mouseBounds);
> zenithBg.addChild(zenith);
> scene.addChild(northWestBg);
> sunset = Property3DSceneDialog.NorthWest;
>
> and in the following method, I am attaching and detaching to the scene:
>
> public void setSunset(int type) {
> sunset = type;
> Enumeration childs = scene.getAllChildren();
> while (childs.hasMoreElements()) {
> Object oc = childs.nextElement();
> if (oc instanceof BranchGroup) {
> BranchGroup bgl = (BranchGroup) oc;
> bgl.detach();
> switch(type) {
> case Property3DSceneDialog.Zenith: {
> scene.addChild(zenithBg);
> break;
> }
> case Property3DSceneDialog.NorthWest: {
> scene.addChild(northWestBg);
> break;
> }
> case Property3DSceneDialog.NorthEast: {
> scene.addChild(northEastBg);
> break;
> }
> case Property3DSceneDialog.West: {
> scene.addChild(westBg);
> break;
> }
> case Property3DSceneDialog.East: {
> scene.addChild(eastBg);
> break;
> }
> case Property3DSceneDialog.SouthWest: {
> scene.addChild(southWestBg);
> break;
> }
> case Property3DSceneDialog.SouthEast: {
> scene.addChild(southEastBg);
> break;
> }
> case Property3DSceneDialog.South: {
> scene.addChild(southBg);
> break;
> }
> }
> }
> }
> }
>
> Hope, this helps, Desiree
>
> o------------------------------------------------------------------------o
> | Desiree Hilbring Institut fuer Photogrammetrie und Fernerkundung |
> | Universitaet Karlsruhe, Germany |
> | |
> | email: [EMAIL PROTECTED] |
> | # 0721 6083676 |
> o------------------------------------------------------------------------o
>
> On Mon, 30 Oct 2000, Wyss Christian wrote:
>
> > Hi all
> > Is there anyone out there who could explain, how I have to do if I
> > d'like to reattach a BranchGroup I took out of a Tree by detach() in
> > another Tree without getting a "multiple parent exception" or something
> > even worse ?
> >
> > Thanks,
> > Chris
> >
> > ===========================================================================
> > 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".