unloading models was a bit trickey and took me a lot of hit and miss. You end up getting a lot of "capability not set" exceptions and then you have to go back and set the proper capability bits on the parents and the model you want to remove.
I ended up needing both in game models removed (the flags when I hit them) and the entire branch group when I want to change maps.
This is the capability I set on the main branch group. Looking at this now, it may be over kill, but that would have to be checked out later as I'm out of time to fix stuff that works!
// create a new scene branch
bgMain = new BranchGroup();
bgMain.setCapability(Group.ALLOW_CHILDREN_WRITE); // required to remove objectives from the map
bgMain.setCapability(Group.ALLOW_CHILDREN_EXTEND); // required to remove objectives from the map
On the floor and wall tiles themselves.
bgFloor = new BranchGroup();
bgFloor.setCapability(Group.ALLOW_CHILDREN_WRITE);
bgFloor.setCapability(BranchGroup.ALLOW_DETACH);
This was so I could remove flags that had the floor as the parent.
This is the branch group of the actual flag as I added it to the model.
bgFlag.setCapability(BranchGroup.ALLOW_DETACH);
I had multiple flags sharing the same model and did it like this. sceneFlag was loaded from an external file. You only have to create sharedFlag once and then you use it on different groups. This shares the model data. This is outside of the question you asked.
bg = sceneFlag.getSceneGroup();
if (sharedFlag==null)
{
sharedFlag = new SharedGroup();
sharedFlag.addChild(bg);
sharedFlag.compile();
}
Link leaf = new Link(sharedFlag);
tg.addChild(leaf);
BranchGroup bgTop = new BranchGroup();
bgTop.setCapability(BranchGroup.ALLOW_DETACH);
bgTop.addChild(tg);
bgParent.addChild(bgTop);
bgTraps[i] = bgTop;
Notice I put a transform group in the middle of all this so I could modify the flag with a transform. This isn't completely necessary yet, but I may do things later. This code came from the bumper and I am planning on scaling it up and down briefly when the marble hits it. The transform group would be relative to the floor which is the parent.
This is how I removed the flag once it was hit.
bgTraps[i].detach();
I hope that helps. If not, please ask more questions.
Wood
--
http://www.memorize-it.com
From: bake...@chapman.edu
Sent: Monday, May 15, 2006 2:17 PM
To: GameD...@googlegroups.com
Subject: [GameDev370] Topics for help tonight:
Hi Wood,
Thanks for rearranging your life for us. Some topics I want to ask you
about for tonight, just to give you a heads up:
-Is there a way I can switch from 2D to 3D? I'm trying to think how to do
the splash screen.
-Moving models in 3D
-Can I unload models?
Thanks,
Mike
> Wouldn't you know that my phone would ring within 15 seconds of sending
> the lunch help notice. I have to help load a container for Africa. We have
> a container of stuff going on our next AIDs relief trip to Namibia.
>
> I've cancelled my evening plans so I can come help on campus. I'll leave
> work around 5pm and arrive at the library between 5:30 and 6. If there are
> any problems with room availability I will be in the beckman cafe. I will
> stay as long as needed. I hope this works with everyone's schedule.
>
> Wood
>
>
>
> >