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
 			new Color3f(1.0f, 0.0f, 0.0f), new Color3f(1.0f, 0.0f, 0.0f),
59
 			new Color3f(1.0f, 0.0f, 0.0f), new Color3f(1.0f, 0.0f, 0.0f),
60
 			new Color3f(1.0f, 0.0f, 0.0f), new Color3f(1.0f, 0.0f, 0.0f), 64.0f);
60
 			new Color3f(1.0f, 0.0f, 0.0f), new Color3f(1.0f, 0.0f, 0.0f), 64.0f);
61
 	private Background background;
61
 	private Background background;
62
-	private Background fullscreenBackground;
63
 
62
 
64
 	/**
63
 	/**
65
 	 * @param canv The Canvas3D we render our cube in
64
 	 * @param canv The Canvas3D we render our cube in
114
 		group.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
113
 		group.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
115
 		group.setCapability(BranchGroup.ALLOW_DETACH);
114
 		group.setCapability(BranchGroup.ALLOW_DETACH);
116
 		background = createBackground();
115
 		background = createBackground();
117
-		fullscreenBackground = createFullscreenBackground();
118
 		group.addChild(background);
116
 		group.addChild(background);
119
-		
120
-		
121
 
117
 
122
 		// Add all our led sphares to the universe
118
 		// Add all our led sphares to the universe
123
 		for (int x = 0; x < 8; x++) {
119
 		for (int x = 0; x < 8; x++) {
255
 
251
 
256
 	// create nice background
252
 	// create nice background
257
 	private Background createBackground() {
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
 		Background bg = new Background(0.0f, 0.0f, 1.0f);
254
 		Background bg = new Background(0.0f, 0.0f, 1.0f);
269
-		int radius = Toolkit.getDefaultToolkit().getScreenSize().width;
255
+		int radius = canvas.getWidth();
270
 		bg.setApplicationBounds(new BoundingSphere(new Point3d(0.0, 0.0, 0.0), radius));
256
 		bg.setApplicationBounds(new BoundingSphere(new Point3d(0.0, 0.0, 0.0), radius));
271
 		return bg;
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
 		group.detach();
264
 		group.detach();
277
 		if(group.indexOfChild(background) != -1){
265
 		if(group.indexOfChild(background) != -1){
278
 			group.removeChild(background);
266
 			group.removeChild(background);
279
 		}
267
 		}
280
-		group.addChild(fullscreenBackground);
268
+		background = createBackground();
269
+		group.addChild(background);
281
 		universe.addBranchGraph(group);
270
 		universe.addBranchGraph(group);
271
+	}
272
+	
273
+	/**
274
+	 * Create new background and adjust view.
275
+	 */
276
+	public void enterFullscreen() {
277
+		toggleFullscreen();
282
 		trans3D.set(fullScreenMat);
278
 		trans3D.set(fullScreenMat);
283
 		transGroup.setTransform(trans3D);
279
 		transGroup.setTransform(trans3D);
284
 	}
280
 	}
285
 	
281
 	
282
+	/**
283
+	 * Create new background and adjust view.
284
+	 */
286
 	public void leaveFullscreen() {
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
 		trans3D.set(mat);
287
 		trans3D.set(mat);
295
 		transGroup.setTransform(trans3D);
288
 		transGroup.setTransform(trans3D);
296
 	}
289
 	}

+ 4
- 3
CubeControl/libSerial/makefile View File

1
 CC = gcc
1
 CC = gcc
2
+STANDARD = gnu99
2
 # Path to jni.h
3
 # Path to jni.h
3
 ifdef SystemRoot
4
 ifdef SystemRoot
4
 HEADERPATH = C:/Program\ Files/Java/jdk1.6.0_29/include
5
 HEADERPATH = C:/Program\ Files/Java/jdk1.6.0_29/include
49
 endif
50
 endif
50
 
51
 
51
 libSerial.jnilib: serialHelper.c unixSerial.c serialInterface.h
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
 	$(CC) -dynamiclib -o libSerial.jnilib serialHelper.o
54
 	$(CC) -dynamiclib -o libSerial.jnilib serialHelper.o
54
 
55
 
55
 libSerial.so: serialHelper.c unixSerial.c serialInterface.h
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
 	$(CC) -dynamiclib -o libSerial.so serialHelper.o
58
 	$(CC) -dynamiclib -o libSerial.so serialHelper.o
58
 
59
 
59
 Serial.dll: serialHelper.c winSerial.c serialInterface.h
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
 	$(CC) -shared -o Serial.dll serialHelper.o
62
 	$(CC) -shared -o Serial.dll serialHelper.o
62
 
63
 
63
 # Delete intermediate files
64
 # Delete intermediate files

+ 8
- 2
CubeControl/makefile View File

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

Loading…
Cancel
Save