Selaa lähdekoodia

Added debug console

Thomas Buck 13 vuotta sitten
vanhempi
commit
688f9d909e
3 muutettua tiedostoa jossa 51 lisäystä ja 9 poistoa
  1. 1
    1
      Cube Control/cubeWorker.java
  2. 48
    6
      Cube Control/frame.java
  3. 2
    2
      Cube Control/makefile

+ 1
- 1
Cube Control/cubeWorker.java Näytä tiedosto

289
 		}
289
 		}
290
 		String[] arg = {"p"};
290
 		String[] arg = {"p"};
291
 		String portLines = HelperUtility.runHelper(arg);
291
 		String portLines = HelperUtility.runHelper(arg);
292
-		System.out.println("Output: " + portLines);
292
+		// System.out.println("Output: " + portLines);
293
 		if (portLines == null) {
293
 		if (portLines == null) {
294
 			return ports;
294
 			return ports;
295
 		}
295
 		}

+ 48
- 6
Cube Control/frame.java Näytä tiedosto

49
 
49
 
50
 	private Point3d eye = new Point3d(3.5, 3.5, -13.0);
50
 	private Point3d eye = new Point3d(3.5, 3.5, -13.0);
51
 	private Point3d look = new Point3d(3.5, 3.5, 0.0);
51
 	private Point3d look = new Point3d(3.5, 3.5, 0.0);
52
-	private Vector3d lookVect = new Vector3d(1.0, 1.0, 0.0);
52
+	private Vector3d lookVect = new Vector3d(1.0, 1.0, 1.0);
53
 
53
 
54
   Led3D(Canvas3D canv) {
54
   Led3D(Canvas3D canv) {
55
 
55
 
58
     // Position viewer, so we are looking at object
58
     // Position viewer, so we are looking at object
59
     trans3D = new Transform3D();
59
     trans3D = new Transform3D();
60
     trans3D.lookAt(eye, look, lookVect);
60
     trans3D.lookAt(eye, look, lookVect);
61
-    trans3D.invert();
62
-    //transGroup = new TransformGroup(trans3D);
61
+	trans3D.invert();
62
+	transGroup = new TransformGroup(trans3D);
63
     transGroup = new TransformGroup();
63
     transGroup = new TransformGroup();
64
     ViewingPlatform viewingPlatform = new ViewingPlatform();
64
     ViewingPlatform viewingPlatform = new ViewingPlatform();
65
     transGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
65
     transGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
71
     universe = new SimpleUniverse(viewingPlatform, viewer);
71
     universe = new SimpleUniverse(viewingPlatform, viewer);
72
     group.addChild(transGroup);
72
     group.addChild(transGroup);
73
     universe.getViewingPlatform().getViewPlatformTransform().setTransform(trans3D);
73
     universe.getViewingPlatform().getViewPlatformTransform().setTransform(trans3D);
74
-    universe.addBranchGraph(group); // Add group to universe
74
+    // universe.getViewingPlatform().setNominalViewingTransform();
75
+	universe.addBranchGraph(group); // Add group to universe
75
 
76
 
76
     BoundingBox boundBox = new BoundingBox(new Point3d(-5.0, -5.0, -5.0), new Point3d(13.0, 13.0, 13.0));
77
     BoundingBox boundBox = new BoundingBox(new Point3d(-5.0, -5.0, -5.0), new Point3d(13.0, 13.0, 13.0));
77
     // roration with left mouse button
78
     // roration with left mouse button
146
     inBetween.addChild(fffuuuuu);
147
     inBetween.addChild(fffuuuuu);
147
   }
148
   }
148
 
149
 
150
+  	public void printTranslationData() {
151
+		Matrix4d mat = new Matrix4d();
152
+		Transform3D t = new Transform3D();
153
+		transGroup.getTransform(t);
154
+		t.get(mat);
155
+		String s = mat.toString();
156
+		System.out.println(s.replaceAll(", ", "\t"));
157
+	}
158
+
149
 	// 64 Element byte array
159
 	// 64 Element byte array
150
 	public void setData(short[] data) {
160
 	public void setData(short[] data) {
151
 		for (int y = 0; y < 8; y++) {
161
 		for (int y = 0; y < 8; y++) {
897
          }
907
          }
898
   }
908
   }
899
 
909
 
910
+  public Led3D get3D() {
911
+	  return ledView;
912
+  }
913
+
900
   // Ende Ereignisprozeduren
914
   // Ende Ereignisprozeduren
901
 
915
 
902
   public static void main(String[] args) {
916
   public static void main(String[] args) {
903
-    new frame("Cube Control");
917
+    frame f = new frame("Cube Control");
918
+	Led3D l = f.get3D();
919
+	java.util.Scanner sc = new java.util.Scanner(System.in);
920
+
921
+	System.out.println("## Cube Control Debug Console ##");
922
+	System.out.println("Enter a Command ('h' for help)\n");
923
+	
924
+	System.out.print("$> ");
925
+
926
+	do {
927
+		if (sc.hasNext()) {
928
+			String s = sc.next();
929
+			
930
+			if (s.equals("p") || (s.equals("print")))
931
+				l.printTranslationData();
932
+
933
+			if (s.equals("q") || s.equals("quit"))
934
+				System.exit(0);
935
+
936
+			if (s.equals("h") || (s.equals("help"))) {
937
+				System.out.println("Commands:");
938
+				System.out.println("\t'print' / 'p'\t:\tPrint 3D Translation Matrix Data");
939
+				System.out.println("\t'help' / 'h'\t:\tShow this message");
940
+				System.out.println("\t'quit' / 'q'\t:\tExit Cube Control");
941
+			}
942
+
943
+			System.out.print("$> ");
944
+		}
945
+	} while (true);
904
   }
946
   }
905
   // Ende Methoden
947
   // Ende Methoden
906
-}
948
+}

+ 2
- 2
Cube Control/makefile Näytä tiedosto

1
 JAVAC = javac
1
 JAVAC = javac
2
 CC = gcc
2
 CC = gcc
3
-#TARGET = unix
4
-TARGET = win
3
+TARGET = unix
4
+#TARGET = win
5
 
5
 
6
 # Java files to be compiled
6
 # Java files to be compiled
7
 ifeq ($(TARGET),win)
7
 ifeq ($(TARGET),win)

Loading…
Peruuta
Tallenna