Murat,
 
You can use only one Switch to show  the cubes you want by using 
 
setChildMask(java.util.BitSet childMask)
were childMask is a  java.util.BitSet object (see javadocs).
 
By using it you can select correctly what will appear or not.
Use constans to label your TGs
 
 
    BG
     |
    SW
 /   |   \    
TG1 TG2 TG3
 
 
// use same sequence you add to switch
int TG1_BIT = 01;
int TG2_BIT = 02;
int TG3_BIT = 03;
 
 
BitSet mask = new BitSet();
...
Swich switch = new Switch();
switch.setWhichChild(Switch.CHILD_MASK);
...
//to show TG1
mask = switch.getChildMask();
mask.set(TG1_BIT);
switch.setChildMask(mask);
 
// to show TG2, no show Tg3, show TG1
mask = switch.getChildMask();
mask.set(TG1_BIT);
mask.set(TG2_BIT);
mask.clear(TG3_BIT);
 
 
I did not test above code, but I use a "look alike" one in a demo.
 
Alessandro
 
----- Original Message -----
Sent: Monday, March 17, 2003 9:12 AM
Subject: [JAVA3D] help

Dear all,

I am working on a small test program. I have three ColorCubes in my scene, all attached to different switches (see attached for the scenegraph). I am rendering only the first of these cubes by the switch statements.

I want to wakeup the other two cubes three seconds after I press the button on the GUI. I created a time behaviour class which uses WakeupOnElapsedTime(3000). But the problem is that the cubes are woke up three seconds after the scene is constructed. How can I link my behaviour with the JButton event so that the cubes are woke up when I press the button?

Thanks



public void initialize()
{
System.out.println("INITIALIZED");
critter = new WakeupOnElapsedTime(3000);
resetEvents();
}

protected final void resetEvents()
{
wakeupOn(critter);
}

// protected abstract void processAWTEvent(AWTEvent evt);

public void processStimulus(Enumeration criteria)
{
System.out.println("RUNNING PROCESS STIMULUS");
WakeupCondition cond;

while(criteria.hasMoreElements())
{
cond = (WakeupCondition)criteria.nextElement();
if(cond instanceof WakeupOnElapsedTime)
{
System.out.println("WAKE UP");

Switch1.setWhichChild(Switch.CHILD_NONE);
Switch2.setWhichChild(Switch.CHILD_ALL);
Switch3.setWhichChild(Switch.CHILD_ALL);
}
}
}



Reply via email to