Using Behaviors without a canvas

Ok. So does anyone know how to use a Behavior without using a View that is attached to a Canavs3D object?

I ask this because I am implementing AI and do not need to see what the thing is doing b/c it sends its updates to a server (that sends to other players). So theoretically I shouldn’t need to create a ViewPlatform, View, nore Canvas3D; however, I dug around a bit in the Behavior documentation and found that 1 of the requirements for Behavior activation is an intersection of bounds between the Behavior and ViewPlatform.

This is fine, because I can add a ViewPlatform without the need of a canvas3D object. But it looks like the ViewPlatform needs a View object to do its activation stuff??? You can build a View object w/out a Canvas3D object (which I did) but the behavior never wakes up.

Any Suggestions?

Hi
It sounds like the client just uses the scenegraph as a data representation of the server, and you then want to run behaviors in this, correct?, just trying to get some more info on what you are actually trying to do here.

Cheers

Endolf

Yep thats right. In fact, the client is the same for both the computer controlled opponent as it is for a human player (minus the canvas3d stuff).

I don’t think behaviours have to be associated with the view at all- they just need to be added to the scenegraph.

Ok, so I wrote a smiple test program to show what is happening - sort-of.
TestBehavior.java has two confingurations, one with a canvas3D that I created and one with just a simple universe called with an empty constructor. (note, in my previous question I DO NOT use SimpleUnivrse but it is easier to show my problem here with SU).

So to execute the code do thsi
java TestBehavior 1
or
java TestBeahavior 2

1 means to use the canvas3D I created and 2 means to use empty constructor.
The program works fine w/ the empty constructor; however, it does not work with 1. There is something wrong with the bounds intersection and this is what I suspect is my problem (conserning my post above). Any suggestions?

Code below …



============== TestBehavior ===========
import java.awt.*;
import javax.swing.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
                                                                                                             
class TestBehavior{
                                                                                                             
   //3D INFORMATION
   SimpleUniverse simpleU;
   BranchGroup rootBG;
   Transform3D saberTrans;
   JPanel panel;
                                                                                                             
   Canvas3D canvas3D;
                                                                                                             
   /**
    * Create a new model 3D.
    */
   public TestBehavior(boolean doView){
      if(doView){
         panel = new JPanel();
         panel.setLayout(new BorderLayout());
         GraphicsConfiguration config =          SimpleUniverse.getPreferredConfiguration();
         canvas3D = new Canvas3D(config);
         panel.add(canvas3D,BorderLayout.CENTER);
                                                                                                             
         simpleU = new SimpleUniverse(canvas3D);
      }
      else{
         simpleU = new SimpleUniverse();
      }                                             
      rootBG = new BranchGroup();                                                                                                        
      TestB testB = new TestB();
      testB.setSchedulingBounds(new BoundingSphere());
                                                                                                             
      rootBG.addChild(testB);
                                                                                                             
      simpleU.addBranchGraph(rootBG);
   }
                                                                                                             
   public static void main (String []args){
                                                                                                             
      if(args.length != 1){
System.out.println("useage 1 or 2");
      }
      else if(args[0].equals("1")){
         TestBehavior tb = new TestBehavior(true);
      }
      else{
         TestBehavior tb = new TestBehavior(false);
      }
   }
}


======== TestB ===========
import javax.media.j3d.*;
import java.util.*;
                                                                                                             
class TestB extends Behavior{
                                                                                                             
   WakeupOnElapsedTime timeEvt;
                                                                                                             
   public TestB(){
   }
                                                                                                             
   public void initialize(){
      timeEvt = new WakeupOnElapsedTime(120);
System.out.println("[TestB] initializing Behavior");
      this.wakeupOn(timeEvt);
   }
                                                                                                             
   public void processStimulus(Enumeration enumerate){
System.out.println("[TestB] doing behavio");
      this.wakeupOn(timeEvt);
   }
}