Browse Source

Selecting LEDs now works perfectly!

hutattedonmyarm 12 years ago
parent
commit
605a471d3a
1 changed files with 31 additions and 3 deletions
  1. 31
    3
      CubeControl/Led3D.java

+ 31
- 3
CubeControl/Led3D.java View File

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

Loading…
Cancel
Save