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);
}
}