Hi, I have a behavior problem in my program.
I implemented variations of PickTranslateBehavior & PickRotateBehavior and they worked 
fine, until I changed from a SimpleUniverse to my own custom one in order to allow for 
multiple 'viewports'. I will show a segment of the 'before' & 'after' code, if anyone 
could help I would appreciate it very much.
Regards, Ben
 
BEFORE
.................
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
c = new Canvas3D(config);
scene = createSceneGraph();
u = new SimpleUniverse(c);
viewPlatform = u.getViewingPlatform();
 
orbit = new OrbitBehavior(c);
orbit.setSchedulingBounds(infiniteBounds);
.................
public BranchGroup createSceneGraph() {
  BranchGroup objRoot = new BranchGroup(); 

  behavior1 = new MyPickTranslateBehavior(objRoot, c, infiniteBounds);
  objRoot.addChild(behavior1);

 
 
AFTER
 
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
c = new Canvas3D[numViews];
u = new BasicUniverse(numViews);
 
scene = createSceneGraph();
for(int s = 0; s < numViews; s++) {
  c[s] = new Canvas3D(config);
}
u.addBranchGraph(u.setupView(c[0], viewTransform1));
u.addBranchGraph(u.setupView(c[1], viewTransform2));
 
orbit = new OrbitBehavior(c[0]);    //doesnt work anymore
orbit.setSchedulingBounds(infiniteBounds);
.................

public BranchGroup createSceneGraph() {
  BranchGroup objRoot = new BranchGroup(); 
  behavior1 = new MyPickTranslateBehavior(objRoot, c[0], infiniteBounds);  //doesnt 
work anymore
  objRoot.addChild(behavior1);

// THE BASIC UNIVERSE SOURCE CODE

public class BasicUniverse extends Object implements Constants {
  VirtualUniverse universe;
  ViewPlatform viewPlatform;
  TransformGroup[] transformGroup;
  Locale locale;
  View view;
  int currentCanvas = 0;
  public BasicUniverse(int numCanvases) {
    universe = new VirtualUniverse();
    locale = new Locale(universe);
    transformGroup = new TransformGroup[numCanvases];
  }
  public BranchGroup setupView(Canvas3D extCanvas, Transform3D t){
    viewPlatform = new ViewPlatform();
    view = new View();
    view.addCanvas3D(extCanvas);
    view.setPhysicalBody(new PhysicalBody());
    view.setPhysicalEnvironment(new PhysicalEnvironment());
     view.setBackClipDistance(5000);
    view.attachViewPlatform(viewPlatform);
    transformGroup[currentCanvas] = new TransformGroup();
    transformGroup[currentCanvas].setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    transformGroup[currentCanvas].setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
   
    transformGroup[currentCanvas].setTransform(t);
    transformGroup[currentCanvas].addChild(viewPlatform);
    BranchGroup toReturn = new BranchGroup();
    toReturn.addChild(transformGroup[currentCanvas]);
    currentCanvas++;
    return toReturn;
  }
  public void addBranchGraph(BranchGroup bg) {
    locale.addBranchGraph(bg);
  }
  public void setView(Transform3D t, int canvas) {
    transformGroup[canvas].setTransform(t);
  }
  public Transform3D getViewTransform(int canvas){
    Transform3D temp = new Transform3D();
    transformGroup[canvas].getTransform(temp);
    return temp;
  }
  public void setViewBehavior(Behavior b) {  // am i on the right track????
    //viewPlatform.setViewPlatformBehavior(b);
  }
  public View getView() {
    return view;
  }
}
 
 
Any queries, dont hesitate to ask, basically if i debug on picking i just get 
nullpointerexceptions now, which i assume means it isnt finding the shape, i have 
highlighted where the problem is. Any ideas, anyone???
 
Thanks

Reply via email to