Status of behaviors in Xith3D

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

Behaviors are currently not implemented. Does anyone currently work on Behaviors? I think one of the problems for the things you want to do is the absence of a high-res-timer in Java.

Hires timer in JDK1.4.x
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=share;action=display;num=1066194528

[quote]Hires timer in JDK1.4.x
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=share;action=display;num=1066194528
[/quote]
That timer is not in JDK 1.4.x! The package name is sun.misc and is not part of the spec. There will be a hires timer in 1.5 as we all know however.

Xith3D used to use that timer for some profiling stuff and it caused many windows users strife so it was removed.

Xith3D now has a TimerInterface which all such code should use - anyone wanting timer stuff has to implement TimerInterface (be it sun.misc.Pref or something else) which is a very good idea until we have an official timer.

Sorry if I sound pedantic - but it’s wrong to say that it is in the JDK.

Will.

As I wrote some time ago, I have parts of running Behavior code (at least Interpolator-style behaviors work). These behaviors, besides of they are compiler-compatible with Java3D, not used as a part of scenegraph, and I use them separately. by calling behavior schedulting method between rendering frames from rendering thread.

Yuri

Without a full implementation of Behaviors, how are other projects in Xith managing their animation timings with regard to the scenegraph? The project I’m working on is currently written in GL4Java and doesn’t support animation. I’d like to port it to Xith (for the rendering independence) and implement animation and timing loops so that rendered elements of the program can react to stimuli in the environment or display themselves in certain ways over time. Yuri mentioned his implementation outside of the scenegraph. I’d like to hear additional ideas.

Hi
I have my game loop controll it all. it calls update on my data model, that knows the time since it was last called and that goes round and updates each object. Then I call renderOnce() on view, and repeat, more or less

HTH

Endolf

Generally, I see two major ways how to do this: either Xith3D/Java3D takes control over animations/behaviors, or application will be responsible for that. Having contadictonary experience with Java3D behaviors, I prefer to have full control on what is happening with my scenegraph. From the other side, I see great benefit from convenience/utility scene modification libraries, such as behaviors, physics, animators, etc.

Yuri