Hello again,
I’ve written my own Behaviour class which should
wake up on “WakeupOnAWTEvent(KeyEvent.KEY_PRESSED)”. The “initialize();”
method starts (I’ve checked with a print), but the “processStimulus()”
method never starts. I’ve checked the Tutorial but I’ve set a
really big BoundingSphere as schedulingBounds (for try) and I added it to the TransformGroup
it changes (not to the root), so that the schedulingBounds isn’t needed,
is it? I checked, if the Behaviour is live and yes it is. So what’s going
wrong?
The code looks like that (not exactly):
In the
behavior class:
//BEGIN
OF CODE
private targetTG;
public
MyBehavior(TransformGroup targetTG) {
this.targetTG
= targetTG;
}
public void
initialize() {
System.out.println("initialize");
//is printed
this.wakeupOn(new
WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
}
public void processStimulus() {
//make
something
System.out.println(“processStimulus”);
//isn’t printed!!!!
this.wakeupOn(new
WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
}
//END OF CODE
In the main class:
//BEGIN OIF CODE
BranchGroup bg = new BranchGroup();
TransformGroup targetTG = new TransformGroup();
targetTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
bg.addChild(targetTG);
MyBehavior myB = new MyBehavior(targetTG);
targetTG.addChild(myB);
bg.compile();
UniverseBuilder myUniverse = new UniverseBuilder();
//a class from me
myUniverse.addBranchGraph(bg);
System.out.println(myB.isLive());
//prints out true!!!
//END OF CODE
Every help is welcome ;)!
Thank you very much,
Sincerely,
Johannes Neubauer
P.S.: According to my last mail: I
don’t think Java is slow. But there ARE rumors AND Java is slower than C
or C++. On the other hand, programming with Java is much more fun. I didn’t
want to hurt anyone’s deep connection to this language I love it, too! ;)