How do I set up a Behavior? My code looks like this:
// camera behavior
cameraBehavior = new EarthCameraBehavior(this.env.getView());
cameraBehavior.setEnable(true);
cameraBehavior.setSchedulingBounds(new BoundingSphere(new Vector3f(), Float.MAX_VALUE));
this.addMouseEventListener(cameraBehavior);
and later in the code I add it to the scene:
bg.addChild(this.cameraBehavior);
It seems that the initialize() and processStimulus() events are never called. I've set up the appropriate WakeupCriterion in my Behavior class.
Are Behaviors the preferred way to manipulate scene graph objects in Xith, or is there a better way?
I've never used Behaviors. So I cannot tell you, if or how they work (nor if they are the best way to go). But I can tell you, there's a very convenient and definitely working way using ScheduledOperation or Animatable interfaces (or implementation Atapters).
Please have a look at org.xith3d.test.animation.BulletTest or org.xith3d.test.animation.RotatableGroup or the Model Loader Tests (they use a test class called RotatableModel).
You seem to try to get a player movement by mouse to work, aren't you? I wrote a class called org.xith3d.utility.input.EgoInputAdapter. It is specially for first person shooter like mouse and keyboard input abstraction. But it should be quite simple to port it to a third person perspective or what ever... Have a look at it's usage in org.xith3d.test.benchmark.Q3FlightBenchmark or org.xith3d.test.loaders.BSPLoaderTest.
ScheduledOperation basically works like this:
ScheduledOperation schedOp = new MyOwnScheduledOperationClass();
OperationScheduler opScheder = this; // where 'this' is your ExtRenderLoop (can be used without OperationScheduler, too. But I wanted to point it out ;).
opScheder.scheduleOperation( schedOp );
And Animatable basically works like this:
Animatable anim = new MyAnimatedThing();
Animator animator = this; // where 'this' is your ExtRenderLoop (can be used without Animator, too. But I wanted to point it out ;).
animator.addAnimatableObject( anim );
Please watch the Type Hierarchy of ScheduledOperation and Animatable (F4 in Eclipse) to see the numerous classes making use of them.
Marvin