Procházet zdrojové kódy

Selecting LEDs now works perfectly!

hutattedonmyarm před 12 roky
rodič
revize
605a471d3a
1 změnil soubory, kde provedl 31 přidání a 3 odebrání
  1. 31
    3
      CubeControl/Led3D.java

+ 31
- 3
CubeControl/Led3D.java Zobrazit soubor

@@ -43,8 +43,10 @@ public class Led3D extends MouseAdapter {
43 43
 	private PickCanvas pickCanvas = null;
44 44
 	private SimpleUniverse universe = null;
45 45
 	private BranchGroup group = null;
46
+	private BranchGroup group2 = null;
46 47
 	private Transform3D trans3D = null;
47 48
 	private TransformGroup transGroup = null;
49
+	private TransformGroup feetGroup = null;
48 50
 	private Matrix4d mat = null;
49 51
 	private Matrix4d fullScreenMat = null;
50 52
 	private Frame parentFrame = null;
@@ -70,6 +72,7 @@ public class Led3D extends MouseAdapter {
70 72
 		canvas = canv;
71 73
 		parentFrame = f;
72 74
 		group = new BranchGroup();
75
+		group2 = new BranchGroup();
73 76
 		// Position viewer, so we are looking at object
74 77
 		trans3D = new Transform3D();
75 78
 		mat = new Matrix4d();
@@ -90,6 +93,9 @@ public class Led3D extends MouseAdapter {
90 93
 		transGroup = new TransformGroup(trans3D);
91 94
 		transGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
92 95
 		transGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
96
+		feetGroup = new TransformGroup(trans3D);
97
+		feetGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
98
+		feetGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
93 99
 		ViewingPlatform viewingPlatform = new ViewingPlatform();
94 100
 		Viewer viewer = new Viewer(canvas);
95 101
 		universe = new SimpleUniverse(viewingPlatform, viewer);
@@ -101,20 +107,37 @@ public class Led3D extends MouseAdapter {
101 107
 		behaviour.setSchedulingBounds(boundBox);
102 108
 		transGroup.addChild(behaviour);
103 109
 
110
+		MouseRotate feetBehaviour = new MouseRotate(feetGroup);
111
+		feetBehaviour.setSchedulingBounds(boundBox);
112
+		feetGroup.addChild(feetBehaviour);
113
+
104 114
 		// zoom with middle mouse button
105 115
 		MouseZoom beh2 = new MouseZoom(transGroup);
106 116
 		beh2.setSchedulingBounds(boundBox);
107 117
 		transGroup.addChild(beh2);
108 118
 
119
+		MouseZoom feetBeh2 = new MouseZoom(feetGroup);
120
+		feetBeh2.setSchedulingBounds(boundBox);
121
+		feetGroup.addChild(feetBeh2);
122
+
109 123
 		// move with right mouse button
110 124
 		MouseTranslate beh3 = new MouseTranslate(transGroup);
111 125
 		beh3.setSchedulingBounds(boundBox);
112 126
 		transGroup.addChild(beh3);
113 127
 
128
+		MouseTranslate feetBeh3 = new MouseTranslate(feetGroup);
129
+		feetBeh3.setSchedulingBounds(boundBox);
130
+		feetGroup.addChild(feetBeh3);
131
+
114 132
 		
115 133
 		group.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
116 134
 		group.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
117 135
 		group.setCapability(BranchGroup.ALLOW_DETACH);
136
+
137
+		group2.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
138
+		group2.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
139
+		group2.setCapability(BranchGroup.ALLOW_DETACH);
140
+
118 141
 		background = createBackground();
119 142
 		group.addChild(background);
120 143
 
@@ -163,7 +186,7 @@ public class Led3D extends MouseAdapter {
163 186
 		transform.setTranslation(vector);
164 187
 		tg.setTransform(transform);
165 188
 		tg.addChild(center);
166
-		transGroup.addChild(tg);	
189
+		feetGroup.addChild(tg);	
167 190
 
168 191
 
169 192
 		// Add an ambient light
@@ -175,7 +198,9 @@ public class Led3D extends MouseAdapter {
175 198
 		light2.setEnable(true);
176 199
 		transGroup.addChild(light2);
177 200
 		group.addChild(transGroup);
201
+		group2.addChild(feetGroup);
178 202
 		universe.addBranchGraph(group); // Add group to universe
203
+		universe.addBranchGraph(group2);
179 204
 
180 205
 		// Mouse-Selectable objects
181 206
 		pickCanvas = new PickCanvas(canvas, group);
@@ -239,7 +264,7 @@ public class Led3D extends MouseAdapter {
239 264
 		tg.setTransform(transform);
240 265
 		tg.addChild(c);
241 266
 
242
-		transGroup.addChild(tg);
267
+		feetGroup.addChild(tg);
243 268
 	}
244 269
 
245 270
 	private void drawLedFeetHorizontal(double x, double y, double z,
@@ -260,7 +285,7 @@ public class Led3D extends MouseAdapter {
260 285
 		tg.setTransform(transform);
261 286
 		tg.addChild(c);
262 287
 
263
-		transGroup.addChild(tg);
288
+		feetGroup.addChild(tg);
264 289
 	}
265 290
 
266 291
 	/**
@@ -274,6 +299,7 @@ public class Led3D extends MouseAdapter {
274 299
 		mat.setRow(3, 0.0, 0.0, 0.0, 1.0);
275 300
 		trans3D.set(mat);
276 301
 		transGroup.setTransform(trans3D);
302
+		feetGroup.setTransform(trans3D);
277 303
 	}
278 304
 
279 305
 	/**
@@ -342,6 +368,7 @@ public class Led3D extends MouseAdapter {
342 368
 		toggleFullscreen();
343 369
 		trans3D.set(fullScreenMat);
344 370
 		transGroup.setTransform(trans3D);
371
+		feetGroup.setTransform(trans3D);
345 372
 	}
346 373
 	
347 374
 	/**
@@ -351,5 +378,6 @@ public class Led3D extends MouseAdapter {
351 378
 		toggleFullscreen();
352 379
 		trans3D.set(mat);
353 380
 		transGroup.setTransform(trans3D);
381
+		feetGroup.setTransform(trans3D);
354 382
 	}
355 383
 }

Loading…
Zrušit
Uložit