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 ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
| ============== TestBehavior =========== import java.awt.*; import javax.swing.*; import javax.media.j3d.*; import com.sun.j3d.utils.universe.*; class TestBehavior{ SimpleUniverse simpleU; BranchGroup rootBG; Transform3D saberTrans; JPanel panel; Canvas3D canvas3D; 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); } } |