Can anyone update me on the use of Behaviors in Xith3D? I noticed some of the default Behaviors available in Java3D are not available in Xith yet but is the present implementation of Behaviors at a usable level? I’ve written a simple behavior based on a sample in Java3D but it does not work, the initialization method is never called. Having never used behaviors before, I’m not sure if I am just doing something wrong or that the implementation is incomplete at this time. Here’s some code snippets explaining how I’ve set this up:
This code creates a quad, establishes its appearance and adds it to the scene. That works fine, as expected. The code also creates a SimpleBehavior that should initialize and print something every 2000ms.
Geometry node1 = createNode();
Appearance appearance = new Appearance();
ColoringAttributes colorAttribs = new ColoringAttributes(new Color3f(1,0,0), ColoringAttributes.SHADE_GOURAUD);
appearance.setColoringAttributes(colorAttribs);
Shape3D node1Shape = new Shape3D(node1, appearance);
SimpleBehavior behavior = new SimpleBehavior(node1Shape, 2000);
BoundingSphere sphere = new BoundingSphere(new Point3f(0,0,0), 2000.0f);
behavior.setSchedulingBounds(sphere);
scene.addChild(node1Shape);
scene.addChild(behavior);
And here is my SimpleBehavior class. All I wanted it to do was print out the statements seen there every time the wakeup was called. The result of these two sets of code is that nothing is printed out.
public class SimpleBehavior extends Behavior {
WakeupCondition wakeUpCond;
public SimpleBehavior(Shape3D shape, int elapsedTime) {
// save the WakeupCriterion for the behavior
wakeUpCond = new WakeupOnElapsedTime(elapsedTime);
}
public void initialize() {
System.out.println("Initializing...");
wakeupOn(wakeUpCond);
}
public void processStimulus(java.util.Enumeration criteria) {
System.out.println("Stimulating...");
wakeupOn(wakeUpCond);
}
}
I’d appreciate any guidance towards making this work.
Ben