Browse Source

Started fixing 3D Background

Now always loads background for canvas 3D size.
Thomas Buck 12 years ago
parent
commit
2c5deec538
3 changed files with 31 additions and 31 deletions
  1. 19
    26
      CubeControl/Led3D.java
  2. 4
    3
      CubeControl/libSerial/makefile
  3. 8
    2
      CubeControl/makefile

+ 19
- 26
CubeControl/Led3D.java View File

@@ -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
 	}

+ 4
- 3
CubeControl/libSerial/makefile View File

@@ -1,4 +1,5 @@
1 1
 CC = gcc
2
+STANDARD = gnu99
2 3
 # Path to jni.h
3 4
 ifdef SystemRoot
4 5
 HEADERPATH = C:/Program\ Files/Java/jdk1.6.0_29/include
@@ -49,15 +50,15 @@ endif
49 50
 endif
50 51
 
51 52
 libSerial.jnilib: serialHelper.c unixSerial.c serialInterface.h
52
-	$(CC) -x c -I$(HEADERPATH) -c serialHelper.c -o serialHelper.o
53
+	$(CC) -x c -std=$(STANDARD) -I$(HEADERPATH) -c serialHelper.c -o serialHelper.o
53 54
 	$(CC) -dynamiclib -o libSerial.jnilib serialHelper.o
54 55
 
55 56
 libSerial.so: serialHelper.c unixSerial.c serialInterface.h
56
-	$(CC) -x c -I$(HEADERPATH) -c serialHelper.c -o serialHelper.o
57
+	$(CC) -x c -std=$(STANDARD) -I$(HEADERPATH) -c serialHelper.c -o serialHelper.o
57 58
 	$(CC) -dynamiclib -o libSerial.so serialHelper.o
58 59
 
59 60
 Serial.dll: serialHelper.c winSerial.c serialInterface.h
60
-	$(CC) -x c -I$(HEADERPATH) -c serialHelper.c -o serialHelper.o -D winHelper
61
+	$(CC) -x c -std=$(STANDARD) -I$(HEADERPATH) -c serialHelper.c -o serialHelper.o -D winHelper
61 62
 	$(CC) -shared -o Serial.dll serialHelper.o
62 63
 
63 64
 # Delete intermediate files

+ 8
- 2
CubeControl/makefile View File

@@ -1,5 +1,3 @@
1
-# Name of your C-Compiler
2
-CC = gcc
3 1
 INJAR = *.class LEDoff.png LEDon.png splash.png bg.png
4 2
 # Path to jni.h
5 3
 ifdef SystemRoot
@@ -86,10 +84,18 @@ clean:
86 84
 	$(RM) *.o
87 85
 ifdef SystemRoot
88 86
 	$(RM) *.dll
87
+	$(RM) CubeControlWin.jar
89 88
 else
90 89
 ifdef SYSTEMROOT
91 90
 	$(RM) *.dll
91
+	$(RM) CubeControlWin.jar
92 92
 else
93
+ifeq ($(UNAME),Darwin)
93 94
 	$(RM) *.jnilib
95
+	$(RM) CubeControlMac.jar
96
+else
97
+	$(RM) *.so
98
+	$(RM) CubeControlLinux.jar
99
+endif
94 100
 endif
95 101
 endif

Loading…
Cancel
Save