/Users/lyon/j4p/src/j3d/cr325/killTheStudent/JoeSphere.java

1    /** 
2     * Created by IntelliJ IDEA. 
3     * User: jgervasio 
4     * Date: Apr 20, 2004 
5     * Time: 12:18:35 PM 
6     * To change this template use Options | File Templates. 
7     */ 
8    package j3d.cr325.killTheStudent; 
9     
10   import j3d.cr325.killTheStudent.MyLevittownDoomKeyboard; 
11    
12   import javax.media.j3d.*; 
13   import javax.vecmath.Matrix3d; 
14   import javax.vecmath.Vector3d; 
15   import javax.vecmath.Point3d; 
16    
17   public class JoeSphere { 
18    
19       public static BranchGroup getLiveJoeSphere(Switch joeSwitch1, String img) { 
20           BranchGroup theJoeSphere = new BranchGroup(); 
21           joeSwitch1.addChild(Utils.getTextureSphere(1.5, 0, 1.125, img)); 
22           return theJoeSphere; 
23       } 
24    
25       public static BranchGroup getDeadJoeSphere(String img) { 
26           BranchGroup theJoeSphere = new BranchGroup(); 
27           theJoeSphere = (Utils.getTextureSphere(1.5, 0, 1.125, img)); 
28           return theJoeSphere; 
29       } 
30    
31       public static Switch getJoeSwitch() { 
32           Switch s = new Switch(0); 
33           s.setCapability(Switch.ALLOW_SWITCH_WRITE); 
34           return s; 
35       } 
36    
37       public static BranchGroup getJoeGroup(MyLevittownDoomKeyboard myLevittownDoomKeyboard) { 
38           BranchGroup theJoeSphere = new BranchGroup(); 
39    
40           BranchGroup s1 = getDeadJoeSphere("shuttle\\aw673.jpg"); 
41           BranchGroup s2 = getLiveJoeSphere(myLevittownDoomKeyboard.joeSwitch, "gifs\\animation4.gif"); 
42    
43           TransformGroup joeRotXfmGrp = new TransformGroup(); 
44           Transform3D joeRotXfm = new Transform3D(); 
45           Matrix3d joeRotMat = new Matrix3d(); 
46           joeRotMat.rotY(Math.PI / 2); 
47           joeRotXfm.set(joeRotMat, new Vector3d(0.0, 0.0, -30.0), 1.0); 
48           joeRotXfmGrp.setTransform(joeRotXfm); 
49           joeRotXfmGrp.addChild(myLevittownDoomKeyboard.joeSwitch); 
50    
51           myLevittownDoomKeyboard.joeSwitch.addChild(s1); 
52           myLevittownDoomKeyboard.joeSwitch.addChild(s2); 
53    
54           TransformGroup joeMovXfmGrp = new TransformGroup(); 
55           joeMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); 
56           joeMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); 
57    
58           myLevittownDoomKeyboard.keyNavBeh.setTargetTransformGroup(joeMovXfmGrp); 
59           joeMovXfmGrp.addChild(joeRotXfmGrp); 
60    
61           Transform3D axis = new Transform3D(); 
62           PositionInterpolator moveJoe = 
63                   new PositionInterpolator(myLevittownDoomKeyboard.joeAlpha, 
64                           joeMovXfmGrp, 
65                           axis, 
66                           -50.0f, 50.0f); 
67           BoundingSphere bs = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 200); 
68           moveJoe.setSchedulingBounds(bs); 
69           theJoeSphere.addChild(moveJoe); 
70           theJoeSphere.addChild(joeMovXfmGrp); 
71           return theJoeSphere; 
72       } 
73   } 
74