Sfoglia il codice sorgente

played around with 3D..... no result...

Max Nuding 13 anni fa
parent
commit
ba93cfe88b
1 ha cambiato i file con 64 aggiunte e 54 eliminazioni
  1. 64
    54
      Cube Control/frame.java

+ 64
- 54
Cube Control/frame.java Vedi File

@@ -6,6 +6,7 @@ import java.io.File;
6 6
 import com.sun.j3d.utils.universe.*;
7 7
 import com.sun.j3d.utils.geometry.*;
8 8
 import javax.media.j3d.*;
9
+import javax.vecmath.*;
9 10
 
10 11
 /*
11 12
  * frame.java
@@ -130,17 +131,26 @@ public class frame extends JFrame {
130 131
     cp.setLayout(null);
131 132
     // Anfang Komponenten
132 133
 
134
+    //----- 3D-----
135
+    //-------------
133 136
     cubeCanvas.setBounds(8, 8, 250, 250);
134 137
     cp.add(cubeCanvas);
135 138
 
136
-	universe = new SimpleUniverse(cubeCanvas);
137
-	universe.getViewingPlatform().setNominalViewingTransform();
138
-	transform3d = new Transform3D();
139
-	transroot = new TransformGroup(transform3d);
140
-	transroot.addChild(new ColorCube(0.3));
141
-	branchgroup = new BranchGroup();
142
-	branchgroup.addChild(transroot);
143
-	universe.addBranchGraph(branchgroup);
139
+    ColorCube cube1 = new ColorCube(0.3);
140
+    universe = new SimpleUniverse(cubeCanvas);
141
+    universe.getViewingPlatform().setNominalViewingTransform();
142
+    transform3d = new Transform3D();
143
+    transroot = new TransformGroup(transform3d);
144
+    transform3d.rotZ (Math.toRadians(30));
145
+    transroot.addChild(cube1);
146
+    transform3d.setTranslation(new Vector3d(2,2,2));
147
+    branchgroup = new BranchGroup();
148
+    branchgroup.addChild(transroot);
149
+    universe.addBranchGraph(branchgroup);
150
+    
151
+    
152
+    
153
+    //-------------
144 154
 
145 155
     editA.setBounds(264, 8, 107, 25);
146 156
     editA.setText("Layer A");
@@ -335,15 +345,15 @@ public class frame extends JFrame {
335 345
       }
336 346
     });
337 347
 
338
-	saveAs.setBounds(564, 296, 90, 25);
339
-	saveAs.setText("Save As");
340
-	saveAs.setFont(new Font("Dialog", Font.PLAIN, 13));
341
-	cp.add(saveAs);
342
-	saveAs.addActionListener(new ActionListener() {
343
-		public void actionPerformed(ActionEvent evt) {
344
-			saveAs_ActionPerformed(evt);
345
-		}
346
-	});
348
+  saveAs.setBounds(564, 296, 90, 25);
349
+  saveAs.setText("Save As");
350
+  saveAs.setFont(new Font("Dialog", Font.PLAIN, 13));
351
+  cp.add(saveAs);
352
+  saveAs.addActionListener(new ActionListener() {
353
+    public void actionPerformed(ActionEvent evt) {
354
+      saveAs_ActionPerformed(evt);
355
+    }
356
+  });
347 357
 
348 358
     jComboBox1.setBounds(344, 328, 305, 24);
349 359
     jComboBox1.setFont(new Font("Dialog", Font.PLAIN, 13));
@@ -486,49 +496,49 @@ public class frame extends JFrame {
486 496
   }
487 497
 
488 498
   public void load_ActionPerformed(ActionEvent evt) {
489
-	JFileChooser fc = new JFileChooser();
490
-	int ret = fc.showOpenDialog(this);
491
-	if (ret == JFileChooser.APPROVE_OPTION) {
492
-		File file = fc.getSelectedFile();
493
-		if (fileSelected == false) {
494
-			fileSelected = true;
495
-		}
496
-		animPath.setText(file.getPath());
497
-		worker.loadState(animPath.getText());
498
-	}
499
+  JFileChooser fc = new JFileChooser();
500
+  int ret = fc.showOpenDialog(this);
501
+  if (ret == JFileChooser.APPROVE_OPTION) {
502
+    File file = fc.getSelectedFile();
503
+    if (fileSelected == false) {
504
+      fileSelected = true;
505
+    }
506
+    animPath.setText(file.getPath());
507
+    worker.loadState(animPath.getText());
508
+  }
499 509
   }
500 510
 
501 511
   public void save_ActionPerformed(ActionEvent evt) {
502
-	if (fileSelected == false) {
503
-		JFileChooser fc = new JFileChooser();
504
-		int ret = fc.showSaveDialog(this);
505
-		if (ret == JFileChooser.APPROVE_OPTION) {
506
-			File file = fc.getSelectedFile();
507
-			fileSelected = true;
508
-			animPath.setText(file.getPath());
509
-			worker.saveState(animPath.getText());
510
-		}
511
-	} else {
512
-		worker.saveState(animPath.getText());
513
-	}
512
+  if (fileSelected == false) {
513
+    JFileChooser fc = new JFileChooser();
514
+    int ret = fc.showSaveDialog(this);
515
+    if (ret == JFileChooser.APPROVE_OPTION) {
516
+      File file = fc.getSelectedFile();
517
+      fileSelected = true;
518
+      animPath.setText(file.getPath());
519
+      worker.saveState(animPath.getText());
520
+    }
521
+  } else {
522
+    worker.saveState(animPath.getText());
523
+  }
514 524
   }
515 525
 
516 526
   public void saveAs_ActionPerformed(ActionEvent evt) {
517
-	JFileChooser fc;
518
-	if (fileSelected == true) {
519
-		fc = new JFileChooser(new File(animPath.getText()).getParentFile());
520
-	} else {
521
-		fc = new JFileChooser();
522
-	}
523
-	int ret = fc.showSaveDialog(this);
524
-	if (ret == JFileChooser.APPROVE_OPTION) {
525
-		File file = fc.getSelectedFile();
526
-		if (fileSelected == false) {
527
-			fileSelected = true;
528
-		}
529
-		animPath.setText(file.getPath());
530
-		worker.saveState(animPath.getText());
531
-	}
527
+  JFileChooser fc;
528
+  if (fileSelected == true) {
529
+    fc = new JFileChooser(new File(animPath.getText()).getParentFile());
530
+  } else {
531
+    fc = new JFileChooser();
532
+  }
533
+  int ret = fc.showSaveDialog(this);
534
+  if (ret == JFileChooser.APPROVE_OPTION) {
535
+    File file = fc.getSelectedFile();
536
+    if (fileSelected == false) {
537
+      fileSelected = true;
538
+    }
539
+    animPath.setText(file.getPath());
540
+    worker.saveState(animPath.getText());
541
+  }
532 542
   }
533 543
 
534 544
 

Loading…
Annulla
Salva