|
@@ -59,7 +59,6 @@ public class Led3D {
|
59
|
59
|
new Color3f(1.0f, 0.0f, 0.0f), new Color3f(1.0f, 0.0f, 0.0f),
|
60
|
60
|
new Color3f(1.0f, 0.0f, 0.0f), new Color3f(1.0f, 0.0f, 0.0f), 64.0f);
|
61
|
61
|
private Background background;
|
62
|
|
- private Background fullscreenBackground;
|
63
|
62
|
|
64
|
63
|
/**
|
65
|
64
|
* @param canv The Canvas3D we render our cube in
|
|
@@ -114,10 +113,7 @@ public class Led3D {
|
114
|
113
|
group.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
|
115
|
114
|
group.setCapability(BranchGroup.ALLOW_DETACH);
|
116
|
115
|
background = createBackground();
|
117
|
|
- fullscreenBackground = createFullscreenBackground();
|
118
|
116
|
group.addChild(background);
|
119
|
|
-
|
120
|
|
-
|
121
|
117
|
|
122
|
118
|
// Add all our led sphares to the universe
|
123
|
119
|
for (int x = 0; x < 8; x++) {
|
|
@@ -255,42 +251,39 @@ public class Led3D {
|
255
|
251
|
|
256
|
252
|
// create nice background
|
257
|
253
|
private Background createBackground() {
|
258
|
|
- ImageComponent2D image = new TextureLoader(getClass().getResource(
|
259
|
|
- "bg.png"), null).getImage();
|
260
|
|
- Background bg = new Background(image);
|
261
|
|
- bg.setApplicationBounds(new BoundingSphere(new Point3d(0.0, 0.0, 0.0),
|
262
|
|
- 100.0));
|
263
|
|
- return bg;
|
264
|
|
- }
|
265
|
|
-
|
266
|
|
- //create fullscreen background
|
267
|
|
- private Background createFullscreenBackground() {
|
268
|
254
|
Background bg = new Background(0.0f, 0.0f, 1.0f);
|
269
|
|
- int radius = Toolkit.getDefaultToolkit().getScreenSize().width;
|
|
255
|
+ int radius = canvas.getWidth();
|
270
|
256
|
bg.setApplicationBounds(new BoundingSphere(new Point3d(0.0, 0.0, 0.0), radius));
|
271
|
257
|
return bg;
|
272
|
|
-
|
273
|
258
|
}
|
274
|
|
-
|
275
|
|
- public void enterFullscreen() {
|
|
259
|
+
|
|
260
|
+ /**
|
|
261
|
+ * Create new background to reflect changed Canvas size.
|
|
262
|
+ */
|
|
263
|
+ private void toggleFullscreen() {
|
276
|
264
|
group.detach();
|
277
|
265
|
if(group.indexOfChild(background) != -1){
|
278
|
266
|
group.removeChild(background);
|
279
|
267
|
}
|
280
|
|
- group.addChild(fullscreenBackground);
|
|
268
|
+ background = createBackground();
|
|
269
|
+ group.addChild(background);
|
281
|
270
|
universe.addBranchGraph(group);
|
|
271
|
+ }
|
|
272
|
+
|
|
273
|
+ /**
|
|
274
|
+ * Create new background and adjust view.
|
|
275
|
+ */
|
|
276
|
+ public void enterFullscreen() {
|
|
277
|
+ toggleFullscreen();
|
282
|
278
|
trans3D.set(fullScreenMat);
|
283
|
279
|
transGroup.setTransform(trans3D);
|
284
|
280
|
}
|
285
|
281
|
|
|
282
|
+ /**
|
|
283
|
+ * Create new background and adjust view.
|
|
284
|
+ */
|
286
|
285
|
public void leaveFullscreen() {
|
287
|
|
- group.detach();
|
288
|
|
- if(group.indexOfChild(fullscreenBackground) != -1) {
|
289
|
|
- group.removeChild(fullscreenBackground);
|
290
|
|
- }
|
291
|
|
- background = createBackground();
|
292
|
|
- group.addChild(background);
|
293
|
|
- universe.addBranchGraph(group);
|
|
286
|
+ toggleFullscreen();
|
294
|
287
|
trans3D.set(mat);
|
295
|
288
|
transGroup.setTransform(trans3D);
|
296
|
289
|
}
|