well...the error is saying you can't remove the TG from the BG...which is
true. You can ONLY detach/reattach BranchGroups (from live/compile
scenegraphs)
So, either change your TransformGroup to BranchGroup...or add the TG to a BG
and then remove the BG.
Mario
Mariusz Zaczek
NASA - Johnson Space Center
Automated Vehicles and Orbit Analysis / DM35
Flight Design and Dynamics Division
Mission Operations Directorate
Bldg: 30A Room: 3040A
Disclaimer: "The opinions, observations and comments expressed in my email
are strictly my own and do not necessarily reflect those of
NASA."
-----Original Message-----
From: tony Lincoln [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 11:00 AM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] HELP! detach(),live, compile() and remove()?!
Dear friends,
I want to remove one child from TransformGroup(TG) by
pressing one button, codes like this:
[/CODES]
class AWTInteractionBehavior extends Behavior
implements ActionListener {
private TransformGroup transformGroup;
private BranchGroup BG;
// create a new AWTInteractionBehavior
public AWTInteractionBehavior(
BranchGroup bg,
TransformGroup tg) {
BG = bg;
BG.setCapability(BranchGroup.ALLOW_DETACH);
BG.setCapability(Group.ALLOW_CHILDREN_WRITE);
BG.setCapability(Group.ALLOW_CHILDREN_EXTEND );
// BG.detach();
transformGroup = tg;
transformGroup.setCapability(
Group.ALLOW_CHILDREN_WRITE );
}
}
// processStimulus to rotate the cube
public void processStimulus(Enumeration criteria)
{
angle += Math.toRadians(10.0);
trans.rotY(angle);
transformGroup.setTransform(trans);
wakeupOn(criterion);
// BG.compile();
// BG.detach();
transformGroup.removeChild(0);
transformGroup.addChild(new Sphere(0.5f));
}
...
[/CODES]
the error is :
javax.media.j3d.RestrictedAccessException: Group: only
a BranchGroup node may be removed.
Actually I want to remove TG from a BG(BranchGroup). I
set the BG ability and tried to detach it. But it can
not work, and I really wonder why. Should I write
removeChild() in method processStimulus()? Maybe I
should not and was wrong here.
Do you have any idea about it? Where should I write
the methods detach(), compile() and removeChild()? And
what is the relationship among detach(),live,
compile() and remove()? I am really confused!
Thank you for your reading.
best regards.
tony
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com
===========================================================================
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".