Normand Briere
2019-06-24 914255f70cf047897212839cbf3a6722703f4457
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -35,6 +36,54 @@
3536
3637 GroupEditor callee;
3738 JFrame frame;
39
+
40
+ static ObjEditor theFrame;
41
+
42
+ cButton GetButton(String name, boolean border)
43
+ {
44
+ try
45
+ {
46
+ ImageIcon icon = GetIcon(name);
47
+ return new cButton(icon, border);
48
+ }
49
+ catch (Exception e)
50
+ {
51
+ return new cButton(name, border);
52
+ }
53
+ }
54
+
55
+ cCheckBox GetCheckBox(String name, boolean border)
56
+ {
57
+ try
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cCheckBox(icon, border);
61
+ }
62
+ catch (Exception e)
63
+ {
64
+ return new cCheckBox(name, border);
65
+ }
66
+ }
67
+
68
+ private ImageIcon GetIcon(String name) throws IOException
69
+ {
70
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
71
+
72
+ if (image.getWidth() != 24 && image.getHeight() != 24)
73
+ {
74
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
75
+ Graphics2D g = resized.createGraphics();
76
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
77
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
78
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
79
+ g.dispose();
80
+
81
+ image = resized;
82
+ }
83
+
84
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
85
+ return icon;
86
+ }
3887
3988 // SCRIPT
4089
....@@ -138,34 +187,42 @@
138187 public void closeUI()
139188 {
140189 //new Exception().printStackTrace();
141
- System.out.println("this = " + this);
142
- System.out.println("objEditor = " + objEditor);
190
+// System.out.println("this = " + this);
191
+// System.out.println("objEditor = " + objEditor);
143192 //nameField.removeActionListener(this);
144
- objEditor.ctrlPanel.remove(nameField);
193
+// objEditor.ctrlPanel.remove(nameField);
194
+
195
+ objEditor.ctrlPanel.remove(namePanel);
145196
146197 if (!GroupEditor.allparams)
147198 return;
148199
149
- objEditor.ctrlPanel.remove(liveCB);
150
- objEditor.ctrlPanel.remove(hideCB);
151
- objEditor.ctrlPanel.remove(markCB);
152
-
153
- objEditor.ctrlPanel.remove(randomCB);
154
- objEditor.ctrlPanel.remove(speedupCB);
155
- objEditor.ctrlPanel.remove(rewindCB);
156
-
157
- objEditor.ctrlPanel.remove(resetButton);
158
- objEditor.ctrlPanel.remove(stepButton);
159
-// objEditor.ctrlPanel.remove(stepAllButton);
160
-// objEditor.ctrlPanel.remove(resetAllButton);
161
- objEditor.ctrlPanel.remove(link2masterCB);
162
- //objEditor.ctrlPanel.remove(flipVCB);
163
- //objEditor.ctrlPanel.remove(texresMenu);
164
- objEditor.ctrlPanel.remove(slowerButton);
165
- objEditor.ctrlPanel.remove(fasterButton);
166
- objEditor.ctrlPanel.remove(remarkButton);
200
+// objEditor.ctrlPanel.remove(liveCB);
201
+// objEditor.ctrlPanel.remove(hideCB);
202
+// objEditor.ctrlPanel.remove(markCB);
203
+//
204
+// objEditor.ctrlPanel.remove(randomCB);
205
+// objEditor.ctrlPanel.remove(speedupCB);
206
+// objEditor.ctrlPanel.remove(rewindCB);
207
+//
208
+// objEditor.ctrlPanel.remove(resetButton);
209
+// objEditor.ctrlPanel.remove(stepButton);
210
+//// objEditor.ctrlPanel.remove(stepAllButton);
211
+//// objEditor.ctrlPanel.remove(resetAllButton);
212
+// objEditor.ctrlPanel.remove(link2masterCB);
213
+// //objEditor.ctrlPanel.remove(flipVCB);
214
+// //objEditor.ctrlPanel.remove(texresMenu);
215
+// objEditor.ctrlPanel.remove(slowerButton);
216
+// objEditor.ctrlPanel.remove(fasterButton);
217
+// objEditor.ctrlPanel.remove(remarkButton);
167218
168
- Remove(normalpushField);
219
+ objEditor.ctrlPanel.remove(setupPanel);
220
+ objEditor.ctrlPanel.remove(setupPanel2);
221
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
222
+ objEditor.ctrlPanel.remove(pushPanel);
223
+ //objEditor.ctrlPanel.remove(fillPanel);
224
+
225
+ //Remove(normalpushField);
169226 }
170227
171228 public ObjEditor GetEditor()
....@@ -236,6 +293,7 @@
236293 //localCopy.parent = null;
237294
238295 frame = new JFrame();
296
+ frame.setUndecorated(true);
239297 objEditor = this;
240298 this.callee = callee;
241299
....@@ -269,24 +327,40 @@
269327 void SetupMenu()
270328 {
271329 frame.setMenuBar(menuBar = new MenuBar());
272
- menuBar.add(windowMenu = new Menu("File"));
273
- windowMenu.add(loadItem = new MenuItem("Load..."));
274
- windowMenu.add("-");
275
- windowMenu.add(saveItem = new MenuItem("Save"));
276
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
330
+ menuBar.add(fileMenu = new Menu("File"));
331
+ fileMenu.add(newItem = new MenuItem("New"));
332
+ fileMenu.add(loadItem = new MenuItem("Open..."));
333
+
334
+ //oe.menuBar.add(menu = new Menu("Include"));
335
+ Menu menu = new Menu("Import");
336
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
337
+ importOBJItem.addActionListener(this);
338
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
339
+ import3DSItem.addActionListener(this);
340
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
341
+ importVRMLX3DItem.addActionListener(this);
342
+ menu.add("-");
343
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
344
+ importGFDItem.addActionListener(this);
345
+ fileMenu.add(menu);
346
+ fileMenu.add("-");
347
+
348
+ fileMenu.add(saveItem = new MenuItem("Save"));
349
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277350 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
278
- windowMenu.add("-");
279
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
280
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
281
- windowMenu.add("-");
351
+ fileMenu.add("-");
352
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
353
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
354
+ fileMenu.add("-");
282355 if (client.parent != null)
283356 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
357
+ fileMenu.add(closeItem = new MenuItem("Close"));
285358 } else
286359 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
360
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288361 }
289362
363
+ newItem.addActionListener(this);
290364 loadItem.addActionListener(this);
291365 saveItem.addActionListener(this);
292366 saveAsItem.addActionListener(this);
....@@ -295,79 +369,35 @@
295369 //povItem.addActionListener(this);
296370 closeItem.addActionListener(this);
297371
298
- menuBar.add(cameraMenu = new Menu("View"));
299
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
300
- //zBufferItem.addActionListener(this);
301
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
302
- //normalLensItem.addActionListener(this);
303
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
304
- revertCameraItem.addActionListener(this);
305
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
306
- toggleTimelineItem.addItemListener(this);
307
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
308
- toggleFullScreenItem.addItemListener(this);
309
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
310
- cameraMenu.add("-");
311
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
312
- toggleTextureItem.addItemListener(this);
313
- toggleTextureItem.setState(CameraPane.textureon);
314
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
315
- toggleLiveItem.addItemListener(this);
316
- toggleLiveItem.setState(Globals.isLIVE());
317
- cameraMenu.add(stepItem = new MenuItem("Step"));
318
- stepItem.addActionListener(this);
319
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
320
-// toggleDLItem.addItemListener(this);
321
-// toggleDLItem.setState(false);
322
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
323
- toggleRenderItem.addItemListener(this);
324
- toggleRenderItem.setState(!CameraPane.frozen);
325
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
326
- toggleDebugItem.addItemListener(this);
327
- toggleDebugItem.setState(CameraPane.DEBUG);
328
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
329
- toggleFrustumItem.addItemListener(this);
330
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
331
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
332
- toggleFootContactItem.addItemListener(this);
333
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
334
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
335
- toggleRandomItem.addItemListener(this);
336
- toggleRandomItem.setState(CameraPane.RANDOM);
337
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
338
- toggleHandleItem.addItemListener(this);
339
- toggleHandleItem.setState(CameraPane.HANDLES);
340
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
341
- togglePaintItem.addItemListener(this);
342
- togglePaintItem.setState(CameraPane.PAINTMODE);
343
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
344
-// toggleRootItem.addItemListener(this);
345
-// toggleRootItem.setState(false);
346
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
347
-// animationItem.addItemListener(this);
348
-// animationItem.setState(CameraPane.ANIMATION);
349
- cameraMenu.add("-");
350
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
351
- editCameraItem.addActionListener(this);
352
-
353372 objectPanel = new JTabbedPane();
354373 toolbarPanel = new JPanel();
355374 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
375
+ treePanel = new cGridBag();
357376 treePanel.setName("Tree");
358
- ctrlPanel = new cGridBag(); // new GridBagLayout());
359
- ctrlPanel.setName("Edit");
377
+
378
+ editPanel = new cGridBag().setVertical(true);
379
+ editPanel.setName("Edit");
380
+
381
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
382
+
383
+ editCommandsPanel = new cGridBag();
384
+ editPanel.add(editCommandsPanel);
385
+ editPanel.add(ctrlPanel);
386
+
360387 materialPanel = new cGridBag().setVertical(true);
388
+
361389 materialPanel.setName("Material");
362390 /*JTextPane*/
363391 infoarea = createTextPane();
392
+ doc = infoarea.getStyledDocument();
393
+
364394 infoarea.setEditable(true);
365395 SetText();
366396 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367397 // infoarea.setOpaque(false);
368398 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
399
+// TEXTAREA infoarea.setLineWrap(true);
400
+// TEXTAREA infoarea.setWrapStyleWord(true);
371401 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372402 infoPanel.setPreferredSize(new Dimension(50, 200));
373403 infoPanel.setName("Info");
....@@ -378,15 +408,15 @@
378408 mainPanel.setName("Main");
379409 mainPanel.setContinuousLayout(true);
380410 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382411 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
412
+ mainPanel.setDividerLocation(0.5); //1.0);
413
+ mainPanel.setResizeWeight(0.5);
384414
385415 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386416 //mainPanel.setLayout(new GridBagLayout());
387417 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
418
+// treePanel.setLayout(new GridBagLayout());
419
+ //ctrlPanel.setLayout(new GridBagLayout());
390420 //materialPanel.setLayout(new GridBagLayout());
391421
392422 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
....@@ -426,7 +456,7 @@
426456 static String newline = "\n";
427457 protected static final String buttonString = "JButton";
428458 StyledDocument doc;
429
- JTextArea infoarea;
459
+ JTextPane infoarea;
430460
431461 void ClearInfo()
432462 {
....@@ -449,10 +479,10 @@
449479 e.printStackTrace();
450480 }
451481
452
- String selection = infoarea.getText();
453
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
454
- java.awt.datatransfer.Clipboard clipboard =
455
- Toolkit.getDefaultToolkit().getSystemClipboard();
482
+// String selection = infoarea.getText();
483
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
484
+// java.awt.datatransfer.Clipboard clipboard =
485
+// Toolkit.getDefaultToolkit().getSystemClipboard();
456486 //clipboard.setContents(data, data);
457487 }
458488
....@@ -475,13 +505,13 @@
475505 //SendInfo("Name:", "bold");
476506 if (sel.GetTextures() != null || debug)
477507 {
478
- si.SendInfo(sel.toString(), "bold");
508
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
479509 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
480510 if (sel.Size() > 0)
481511 {
482512 si.SendInfo("#children = " + sel.Size(), "regular");
483513 }
484
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
514
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
485515 if (debug)
486516 {
487517 try
....@@ -493,7 +523,10 @@
493523 }
494524
495525 if (full)
496
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
526
+ {
527
+ si.SendInfo(" BBox min: " + minima, "regular");
528
+ si.SendInfo(" BBox max: " + maxima, "regular");
529
+ }
497530
498531 if (sel.bRep != null)
499532 {
....@@ -520,7 +553,7 @@
520553 }
521554 if (sel.support != null)
522555 {
523
- si.SendInfo(" support: " + sel.support, "regular");
556
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
524557 }
525558 if (sel.scriptnode != null)
526559 {
....@@ -591,6 +624,9 @@
591624 {
592625 CameraPane.pointflow = (PointFlow) sel;
593626 }
627
+
628
+ si.SendInfo("_____________________", "regular");
629
+ si.SendInfo("", "regular");
594630 }
595631 }
596632
....@@ -606,68 +642,138 @@
606642 }
607643 }
608644
645
+static GraphicsDevice device = GraphicsEnvironment
646
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
647
+
648
+ Rectangle keeprect;
649
+ cRadio radio;
650
+
651
+cButton keepButton;
652
+ cButton twoButton; // Full 3D
653
+ cButton sixButton;
654
+ cButton threeButton;
655
+ cButton sevenButton;
656
+ cButton fourButton; // full panel
657
+ cButton oneButton; // full XYZ
658
+ //cButton currentLayout;
659
+
660
+ boolean maximized;
661
+
662
+ void Minimize()
663
+ {
664
+ frame.setState(Frame.ICONIFIED);
665
+ }
666
+
667
+ void Maximize()
668
+ {
669
+ if (maximized)
670
+ {
671
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
672
+ }
673
+ else
674
+ {
675
+ keeprect = frame.getBounds();
676
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
677
+ Dimension rect2 = frame.getToolkit().getScreenSize();
678
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
679
+// frame.setState(Frame.MAXIMIZED_BOTH);
680
+ }
681
+
682
+ maximized ^= true;
683
+ }
684
+
609685 void ToggleFullScreen()
610686 {
611687 if (CameraPane.FULLSCREEN)
612688 {
613
- frame.getContentPane().remove(/*"Center",*/bigThree);
614
- framePanel.add(bigThree);
615
- frame.getContentPane().add(/*"Center",*/framePanel);
689
+ device.setFullScreenWindow(null);
690
+ //frame.setVisible(false);
691
+// frame.removeNotify();
692
+// frame.setUndecorated(false);
693
+// frame.addNotify();
694
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
695
+
696
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
697
+// X framePanel.add(bigThree);
698
+// X frame.getContentPane().add(/*"Center",*/framePanel);
699
+ framePanel.setDividerLocation(1);
700
+
701
+ //frame.setVisible(true);
702
+ radio.layout = keepButton;
703
+ //theFrame = null;
704
+ keepButton = null;
705
+ radio.layout.doClick();
706
+
616707 } else
617708 {
618
- frame.getContentPane().remove(/*"Center",*/framePanel);
619
- framePanel.remove(bigThree);
620
- frame.getContentPane().add(/*"Center",*/bigThree);
709
+ keepButton = radio.layout;
710
+ //keeprect = frame.getBounds();
711
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
712
+// frame.getToolkit().getScreenSize().height);
713
+ //frame.setVisible(false);
714
+ device.setFullScreenWindow(frame);
715
+// frame.removeNotify();
716
+// frame.setUndecorated(true);
717
+// frame.addNotify();
718
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
719
+// X framePanel.remove(bigThree);
720
+// X frame.getContentPane().add(/*"Center",*/bigThree);
721
+ framePanel.setDividerLocation(0);
722
+
723
+ radio.layout = twoButton;
724
+ radio.layout.doClick();
725
+ //frame.setVisible(true);
621726 }
727
+
622728 cameraView.ToggleFullScreen();
623729 }
624730
625
- private JTextArea createTextPane()
731
+ private JTextPane createTextPane()
626732 {
627
- String[] initString =
628
- {
629
- "This is an editable JTextPane, ", //regular
630
- "another ", //italic
631
- "styled ", //bold
632
- "text ", //small
633
- "component, ", //large
634
- "which supports embedded components..." + newline,//regular
635
- " " + newline, //button
636
- "...and embedded icons..." + newline, //regular
637
- " ", //icon
638
- newline + "JTextPane is a subclass of JEditorPane that "
639
- + "uses a StyledEditorKit and StyledDocument, and provides "
640
- + "cover methods for interacting with those objects."
641
- };
733
+// TEXTAREA String[] initString =
734
+// {
735
+// "This is an editable JTextPane, ", //regular
736
+// "another ", //italic
737
+// "styled ", //bold
738
+// "text ", //small
739
+// "component, ", //large
740
+// "which supports embedded components..." + newline,//regular
741
+// " " + newline, //button
742
+// "...and embedded icons..." + newline, //regular
743
+// " ", //icon
744
+// newline + "JTextPane is a subclass of JEditorPane that "
745
+// + "uses a StyledEditorKit and StyledDocument, and provides "
746
+// + "cover methods for interacting with those objects."
747
+// };
748
+//
749
+// String[] initStyles =
750
+// {
751
+// "regular", "italic", "bold", "small", "large",
752
+// "regular", "button", "regular", "icon",
753
+// "regular"
754
+// };
755
+//
756
+// JTextPane textPane = new JTextPane();
757
+// textPane.setEditable(true);
758
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
759
+// addStylesToDocument(doc);
760
+//
761
+// try
762
+// {
763
+// for (int j = 0; j < 2; j++)
764
+// {
765
+// for (int i = 0; i < initString.length; i++)
766
+// {
767
+// doc.insertString(doc.getLength(), initString[i],
768
+// doc.getStyle(initStyles[i]));
769
+// }
770
+// }
771
+// } catch (BadLocationException ble)
772
+// {
773
+// System.err.println("Couldn't insert initial text into text pane.");
774
+// }
642775
643
- String[] initStyles =
644
- {
645
- "regular", "italic", "bold", "small", "large",
646
- "regular", "button", "regular", "icon",
647
- "regular"
648
- };
649
-
650
- JTextPane textPane = new JTextPane();
651
- textPane.setEditable(true);
652
- /*StyledDocument*/ doc = textPane.getStyledDocument();
653
- addStylesToDocument(doc);
654
-
655
- try
656
- {
657
- for (int j = 0; j < 2; j++)
658
- {
659
- for (int i = 0; i < initString.length; i++)
660
- {
661
- doc.insertString(doc.getLength(), initString[i],
662
- doc.getStyle(initStyles[i]));
663
- }
664
- }
665
- } catch (BadLocationException ble)
666
- {
667
- System.err.println("Couldn't insert initial text into text pane.");
668
- }
669
-
670
- return new JTextArea(); // textPane;
776
+ return new JTextPane(); // textPane;
671777 }
672778
673779 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +826,7 @@
720826 protected static ImageIcon createImageIcon(String path,
721827 String description)
722828 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
829
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724830 if (imgURL != null)
725831 {
726832 return new ImageIcon(imgURL, description);
....@@ -752,6 +858,7 @@
752858 // NumberSlider vDivsField;
753859 // JCheckBox endcaps;
754860 JCheckBox liveCB;
861
+ JCheckBox selectCB;
755862 JCheckBox hideCB;
756863 JCheckBox link2masterCB;
757864 JCheckBox markCB;
....@@ -767,54 +874,48 @@
767874 JButton slowerButton;
768875 JButton fasterButton;
769876 JButton remarkButton;
877
+
878
+ cGridBag editPanel;
879
+ cGridBag editCommandsPanel;
880
+
881
+ cGridBag namePanel;
882
+ cGridBag setupPanel;
883
+ cGridBag setupPanel2;
884
+ cGridBag objectCommandsPanel;
885
+ cGridBag pushPanel;
886
+ cGridBag fillPanel;
770887
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
888
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772889 {
773890 JCheckBox cb;
774891
775
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
776
- oe.aConstraints.gridwidth = 1; // 3;
777
-// oe.aConstraints.weightx = 1;
778
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
779
- oe.ctrlPanel.add(cb = new JCheckBox(label, on), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
892
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780893 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784894
785895 return cb;
786896 }
787897
788
- cButton AddButton(ObjEditor oe, String label)
898
+ cButton AddButton(cGridBag panel, String label)
789899 {
790900 cButton cb;
791901
792
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
793
- oe.aConstraints.gridwidth = 1;
794
-// oe.aConstraints.weightx = 1;
795
-// oe.aConstraints.anchor = GridBagConstraints.WEST;
796
- oe.ctrlPanel.add(cb = new cButton(label), oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
902
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797903 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801904
802905 return cb;
803906 }
804907
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
908
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
806909 {
807910 JComboBox combo;
808911
809
- oe.aConstraints.fill = GridBagConstraints.HORIZONTAL;
810
- oe.ctrlPanel.add(combo = new JComboBox(new cListModel(list, item)), oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
811
- oe.aConstraints.gridx += 1;
912
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812913 combo.addActionListener(this);
813914
814915 return combo;
815916 }
816917
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
918
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
818919 {
819920 cGridBag control = new cGridBag();
820921
....@@ -826,12 +927,12 @@
826927 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
827928 combo.setFloat(current);
828929
829
- ctrlPanel.add(control);
930
+ panel.add(control);
830931
831
- return combo;
932
+ return control;
832933 }
833934
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
935
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
835936 {
836937 cGridBag control = new cGridBag();
837938
....@@ -839,25 +940,21 @@
839940
840941 JLabel jlabel = new JLabel(label);
841942 jlabel.setHorizontalAlignment(SwingConstants.TRAILING);
842
- ctrlPanel.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
843
- ctrlPanel.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
943
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
944
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
844945 combo.setInteger(current);
845946
846
- ctrlPanel.add(control);
947
+ panel.add(control);
847948
848
- return combo;
949
+ return control;
849950 }
850951
851952 JTextArea AddText(cGridBag ctrlPanel, String name)
852953 {
853954 JTextArea text;
854955
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
857956 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
858957 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
861958
862959 return text;
863960 }
....@@ -896,7 +993,7 @@
896993
897994 /*
898995 */
899
- void Return() // ObjEditor oe)
996
+ void Return0() // ObjEditor oe)
900997 {
901998 aConstraints.gridy += 1;
902999 aConstraints.gridx = 0;
....@@ -951,37 +1048,76 @@
9511048
9521049 void SetupUI2(ObjEditor oe)
9531050 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
1051
+ //SetupName(oe);
1052
+
1053
+ namePanel = new cGridBag();
1054
+
1055
+ nameField = AddText(namePanel, copy.GetName());
1056
+ namePanel.add(nameField);
1057
+ oe.ctrlPanel.add(namePanel);
1058
+
1059
+ oe.ctrlPanel.Return();
9591060
9601061 if (!GroupEditor.allparams)
9611062 return;
9621063
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1064
+ setupPanel = new cGridBag().setVertical(false);
1065
+
1066
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1067
+ liveCB.setToolTipText("Animate object");
1068
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1069
+ selectCB.setToolTipText("Make object selectable");
9661070 // Return();
967
- markCB = AddCheckBox(oe, "Mark", copy.marked);
968
- rewindCB = AddCheckBox(oe, "Rew", copy.rewind);
969
- randomCB = AddCheckBox(oe, "Rand", copy.random);
970
- Return();
971
- resetButton = AddButton(oe, "Reset");
972
- stepButton = AddButton(oe, "Step");
1071
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1072
+ hideCB.setToolTipText("Hide object");
1073
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1074
+ markCB.setToolTipText("Set the animation target transform");
1075
+
1076
+ setupPanel2 = new cGridBag().setVertical(false);
1077
+
1078
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1079
+ rewindCB.setToolTipText("Rewind animation");
1080
+
1081
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1082
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1083
+
1084
+ if (Globals.ADVANCED)
1085
+ {
1086
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1087
+ link2masterCB.setToolTipText("Attach to support");
1088
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1089
+ speedupCB.setToolTipText("Option motion capture");
1090
+ }
1091
+
1092
+ oe.ctrlPanel.add(setupPanel);
1093
+ oe.ctrlPanel.Return();
1094
+ oe.ctrlPanel.add(setupPanel2);
1095
+ oe.ctrlPanel.Return();
1096
+
1097
+ objectCommandsPanel = new cGridBag().setVertical(false);
1098
+
1099
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1100
+ resetButton.setToolTipText("Jump to frame zero");
1101
+ stepButton = AddButton(objectCommandsPanel, "Step");
1102
+ stepButton.setToolTipText("Step one frame");
9731103 // resetAllButton = AddButton(oe, "Reset All");
9741104 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9761105 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
1106
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1107
+ slowerButton.setToolTipText("Decrease animation speed");
1108
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1109
+ fasterButton.setToolTipText("Increase animation speed");
1110
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1111
+ remarkButton.setToolTipText("Set the current transform as the target");
9801112
981
- Return();
1113
+ oe.ctrlPanel.add(objectCommandsPanel);
1114
+ oe.ctrlPanel.Return();
9821115
983
- normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
984
- Return();
1116
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1117
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
1118
+ //Return();
1119
+
1120
+ oe.ctrlPanel.Return();
9851121
9861122 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9871123 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1212,7 @@
10761212 oe.aConstraints.gridwidth = 1;
10771213 /**/
10781214 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1215
+ oe.ctrlPanel.Return();
10801216
10811217 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821218 //textureButton.setEnabled(false);
....@@ -1180,8 +1316,11 @@
11801316 //worldPanel.setName("World");
11811317 centralPanel = new cGridBag();
11821318 centralPanel.preferredWidth = 20;
1183
- timelinePanel = new JPanel(new BorderLayout());
1184
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1319
+
1320
+ if (Globals.ADVANCED)
1321
+ {
1322
+ timelinePanel = new JPanel(new BorderLayout());
1323
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11851324
11861325 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11871326 cameraPanel.setContinuousLayout(true);
....@@ -1190,7 +1329,10 @@
11901329 // cameraPanel.setDividerSize(9);
11911330 cameraPanel.setResizeWeight(1.0);
11921331
1332
+ }
1333
+
11931334 centralPanel.add(cameraView);
1335
+ centralPanel.setFocusable(true);
11941336 //frame.setJMenuBar(timelineMenubar);
11951337 //centralPanel.add(timelinePanel);
11961338
....@@ -1253,10 +1395,11 @@
12531395 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541396 //tmp.setName("Edit");
12551397 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1398
+// JPanel north = new JPanel(new BorderLayout());
1399
+// north.setName("Edit");
1400
+// north.add(ctrlPanel, BorderLayout.NORTH);
1401
+// objectPanel.add(north);
1402
+ objectPanel.add(editPanel);
12601403 objectPanel.add(infoPanel);
12611404
12621405 /*
....@@ -1278,7 +1421,7 @@
12781421 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791422
12801423 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1424
+ scenePanel.preferredWidth = 6;
12821425
12831426 JTabbedPane tabbedPane = new JTabbedPane();
12841427 tabbedPane.add(scrollpane);
....@@ -1384,9 +1527,11 @@
13841527
13851528 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861529
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1530
+ frame.setSize(1280, 860);
1531
+ frame.setVisible(true);
13891532
1533
+ cameraView.requestFocusInWindow();
1534
+
13901535 gridPanel.setDividerLocation(1.0);
13911536
13921537 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1415,7 +1560,7 @@
14151560 ctrlPanel.removeAll();
14161561 }
14171562
1418
- void SetupMaterial(cGridBag ctrlPanel)
1563
+ void SetupMaterial(cGridBag panel)
14191564 {
14201565 /*
14211566 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
....@@ -1424,18 +1569,26 @@
14241569
14251570 cGridBag editBar = new cGridBag().setVertical(false);
14261571
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1572
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1573
+ createMaterialButton.setToolTipText("Create material");
14281574
14291575 /*
14301576 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14311577 */
14321578
1433
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1434
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1435
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1436
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1579
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1580
+ clearMaterialButton.setToolTipText("Clear material");
1581
+
1582
+ if (Globals.ADVANCED)
1583
+ {
1584
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1585
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1586
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1587
+ }
14371588
1438
- ctrlPanel.add(editBar);
1589
+ editBar.preferredHeight = 15;
1590
+
1591
+ panel.add(editBar);
14391592
14401593 /**/
14411594 //aConstraints.weighty = 0;
....@@ -1445,17 +1598,13 @@
14451598 //aConstraints.gridx += 1;
14461599 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14471600
1448
- JPanel colorPanel = new JPanel(new BorderLayout());
1449
- colorPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1450
-
14511601 cGridBag colorSection = new cGridBag().setVertical(true);
1452
-
1453
- colorPanel.add(colorSection);
14541602
14551603 cGridBag color = new cGridBag();
14561604 color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
14571605 colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14581606 color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1607
+ //colorField.preferredWidth = 200;
14591608 colorSection.add(color);
14601609
14611610 cGridBag modulation = new cGridBag();
....@@ -1488,16 +1637,13 @@
14881637 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
14891638 colorSection.add(shadowbias);
14901639
1491
- ctrlPanel.add(colorPanel);
1640
+ panel.add(new JSeparator());
1641
+
1642
+ panel.add(colorSection);
14921643
14931644 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14941645
1495
- JPanel diffusePanel = new JPanel(new BorderLayout());
1496
- diffusePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1497
-
14981646 cGridBag diffuseSection = new cGridBag().setVertical(true);
1499
-
1500
- diffusePanel.add(diffuseSection);
15011647
15021648 cGridBag diffuse = new cGridBag();
15031649 diffuse.add(diffuseLabel = new JLabel("Diffuse")); // , aConstraints);
....@@ -1541,16 +1687,13 @@
15411687 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421688 diffuseSection.add(fakedepth);
15431689
1544
- ctrlPanel.add(diffusePanel);
1690
+ panel.add(new JSeparator());
1691
+
1692
+ panel.add(diffuseSection);
15451693
15461694 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15471695
1548
- JPanel specularPanel = new JPanel(new BorderLayout());
1549
- specularPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1550
-
15511696 cGridBag specularSection = new cGridBag().setVertical(true);
1552
-
1553
- specularPanel.add(specularSection);
15541697
15551698 cGridBag specular = new cGridBag();
15561699 specular.add(specularLabel = new JLabel("Specular")); // , aConstraints);
....@@ -1582,7 +1725,7 @@
15821725 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15831726 specularSection.add(velvet);
15841727
1585
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
1728
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15861729 //Return();
15871730 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15881731 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1595,16 +1738,13 @@
15951738 // aConstraints.gridwidth = 1;
15961739
15971740
1598
- ctrlPanel.add(specularPanel);
1741
+ panel.add(new JSeparator());
1742
+
1743
+ panel.add(specularSection);
15991744
16001745 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16011746
1602
- JPanel globalPanel = new JPanel(new BorderLayout());
1603
- globalPanel.setBorder(BorderFactory.createLineBorder(Color.black));
1604
-
16051747 cGridBag globalSection = new cGridBag().setVertical(true);
1606
-
1607
- globalPanel.add(globalSection);
16081748
16091749 cGridBag camera = new cGridBag();
16101750 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
....@@ -1630,16 +1770,13 @@
16301770 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16311771 globalSection.add(opacity);
16321772
1633
- ctrlPanel.add(globalPanel);
1773
+ panel.add(new JSeparator());
1774
+
1775
+ panel.add(globalSection);
16341776
16351777 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16361778
1637
- JPanel texturePanel = new JPanel(new BorderLayout());
1638
- texturePanel.setBorder(BorderFactory.createLineBorder(Color.black));
1639
-
16401779 cGridBag textureSection = new cGridBag().setVertical(true);
1641
-
1642
- texturePanel.add(textureSection);
16431780
16441781 cGridBag bump = new cGridBag();
16451782 bump.add(bumpLabel = new JLabel("Bump")); // , aConstraints);
....@@ -1677,7 +1814,9 @@
16771814 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16781815 textureSection.add(opacityPower);
16791816
1680
- ctrlPanel.add(texturePanel);
1817
+ panel.add(new JSeparator());
1818
+
1819
+ panel.add(textureSection);
16811820
16821821 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16831822
....@@ -1714,12 +1853,15 @@
17141853 opacityPowerField.addChangeListener(this);
17151854 /**/
17161855
1717
- resetSlidersButton.addActionListener(this);
17181856 clearMaterialButton.addActionListener(this);
17191857 createMaterialButton.addActionListener(this);
1720
-
1721
- propagateToggle.addItemListener(this);
1722
- multiplyToggle.addItemListener(this);
1858
+
1859
+ if (Globals.ADVANCED)
1860
+ {
1861
+ resetSlidersButton.addActionListener(this);
1862
+ propagateToggle.addItemListener(this);
1863
+ multiplyToggle.addItemListener(this);
1864
+ }
17231865 }
17241866
17251867 void DropFile(java.io.File[] files, boolean textures)
....@@ -1890,7 +2032,7 @@
18902032
18912033 //? flashIt = false;
18922034 CameraPane pane = (CameraPane) cameraView;
1893
- pane.clickStart(location.x, location.y, 0);
2035
+ pane.clickStart(location.x, location.y, 0, 0);
18942036 pane.clickEnd(location.x, location.y, 0, true);
18952037
18962038 if (group.selection.size() == 1)
....@@ -1939,6 +2081,7 @@
19392081 e2.printStackTrace();
19402082 }
19412083 }
2084
+
19422085 LoadJMEThread loadThread;
19432086
19442087 class LoadJMEThread extends Thread
....@@ -1996,6 +2139,7 @@
19962139 //LoadFile0(filename, converter);
19972140 }
19982141 }
2142
+
19992143 LoadOBJThread loadObjThread;
20002144
20012145 class LoadOBJThread extends Thread
....@@ -2074,19 +2218,19 @@
20742218
20752219 void LoadObjFile(String fullname)
20762220 {
2077
- /*
2221
+ System.out.println("Loading " + fullname);
2222
+ /**/
20782223 //lastFilename = fullname;
20792224 if(loadObjThread == null)
20802225 {
2081
- loadObjThread = new LoadOBJThread();
2082
- loadObjThread.start();
2226
+ loadObjThread = new LoadOBJThread();
2227
+ loadObjThread.start();
20832228 }
20842229
20852230 loadObjThread.add(fullname);
2086
- */
2231
+ /**/
20872232
2088
- System.out.println("Loading " + fullname);
2089
- makeSomething(new FileObject(fullname, true), true);
2233
+ //makeSomething(new FileObject(fullname, true), true);
20902234 }
20912235
20922236 void LoadGFDFile(String fullname)
....@@ -2347,11 +2491,11 @@
23472491
23482492 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23492493 {
2350
- if (GrafreeD.standAlone)
2494
+ if (Grafreed.standAlone)
23512495 {
23522496 /**/
23532497 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2354
- browser.show();
2498
+ browser.setVisible(true);
23552499 String filename = browser.getFile();
23562500 if (filename != null && filename.length() > 0)
23572501 {
....@@ -2496,6 +2640,7 @@
24962640 }
24972641 if (input == null)
24982642 {
2643
+ new Exception().printStackTrace();
24992644 System.exit(0);
25002645 }
25012646
....@@ -2710,7 +2855,8 @@
27102855 return;
27112856 }
27122857
2713
- multiplyToggle.setSelected(mat.multiply);
2858
+ if (multiplyToggle != null)
2859
+ multiplyToggle.setSelected(mat.multiply);
27142860
27152861 assert (object.projectedVertices != null);
27162862
....@@ -2925,9 +3071,9 @@
29253071 frame.validate();
29263072
29273073 return;
2928
- } else if (event.getSource() == toggleRandomItem)
3074
+ } else if (event.getSource() == toggleSwitchItem)
29293075 {
2930
- cameraView.ToggleRandom();
3076
+ cameraView.ToggleSwitch();
29313077 cameraView.repaint();
29323078 return;
29333079 } else if (event.getSource() == toggleHandleItem)
....@@ -2956,6 +3102,10 @@
29563102 {
29573103 copy.live ^= true;
29583104 return;
3105
+ } else if (event.getSource() == selectCB)
3106
+ {
3107
+ copy.dontselect ^= true;
3108
+ return;
29593109 } else if (event.getSource() == hideCB)
29603110 {
29613111 copy.hide ^= true;
....@@ -2970,6 +3120,7 @@
29703120 if (event.getSource() == randomCB)
29713121 {
29723122 copy.random ^= true;
3123
+ objEditor.refreshContents();
29733124 return;
29743125 }
29753126 if (event.getSource() == speedupCB)
....@@ -2993,8 +3144,9 @@
29933144
29943145 public void actionPerformed(ActionEvent event)
29953146 {
3147
+ Object source = event.getSource();
29963148 // SCRIPT DIALOG
2997
- if (event.getSource() == okbutton)
3149
+ if (source == okbutton)
29983150 {
29993151 textpanel.setVisible(false);
30003152 textpanel.remove(textarea);
....@@ -3006,7 +3158,7 @@
30063158 textarea = null;
30073159 textpanel = null;
30083160 }
3009
- if (event.getSource() == cancelbutton)
3161
+ if (source == cancelbutton)
30103162 {
30113163 textpanel.setVisible(false);
30123164 textpanel.remove(textarea);
....@@ -3018,50 +3170,50 @@
30183170 //applySelf();
30193171 //client.refreshEditWindow();
30203172 //refreshContents();
3021
- if (event.getSource() == nameField)
3173
+ if (source == nameField)
30223174 {
30233175 //System.out.println("ObjEditor " + event);
30243176 applySelf0(true);
30253177 //parent.applySelf();
30263178 objEditor.refreshContents();
3027
- } else if (event.getSource() == resetButton)
3179
+ } else if (source == resetButton)
30283180 {
30293181 CameraPane.fullreset = true;
30303182 copy.Reset(); // ResetMeshes();
30313183 copy.Touch();
30323184 objEditor.refreshContents();
3033
- } else if (event.getSource() == stepItem)
3185
+ } else if (source == stepItem)
30343186 {
30353187 //cameraView.ONESTEP = true;
30363188 Globals.ONESTEP = true;
30373189 cameraView.repaint();
30383190 return;
3039
- } else if (event.getSource() == stepButton)
3191
+ } else if (source == stepButton)
30403192 {
30413193 copy.Step();
30423194 copy.Touch();
30433195 objEditor.refreshContents();
3044
- } else if (event.getSource() == slowerButton)
3196
+ } else if (source == slowerButton)
30453197 {
30463198 copy.Slower();
30473199 copy.Touch();
30483200 objEditor.refreshContents();
3049
- } else if (event.getSource() == fasterButton)
3201
+ } else if (source == fasterButton)
30503202 {
30513203 copy.Faster();
30523204 copy.Touch();
30533205 objEditor.refreshContents();
3054
- } else if (event.getSource() == remarkButton)
3206
+ } else if (source == remarkButton)
30553207 {
30563208 copy.Remark();
30573209 copy.Touch();
30583210 objEditor.refreshContents();
3059
- } else if (event.getSource() == stepAllButton)
3211
+ } else if (source == stepAllButton)
30603212 {
30613213 copy.StepAll();
30623214 copy.Touch();
30633215 objEditor.refreshContents();
3064
- } else if (event.getSource() == resetAllButton)
3216
+ } else if (source == resetAllButton)
30653217 {
30663218 //CameraPane.fullreset = true;
30673219 copy.ResetAll(); // ResetMeshes();
....@@ -3094,53 +3246,75 @@
30943246 // Close();
30953247 // }
30963248 // else
3097
- if (event.getSource() == resetSlidersButton)
3249
+ if (source == resetSlidersButton)
30983250 {
30993251 ResetSliders();
3100
- } else if (event.getSource() == clearMaterialButton)
3252
+ } else if (source == clearMaterialButton)
31013253 {
31023254 ClearMaterial();
3103
- } else if (event.getSource() == createMaterialButton)
3255
+ } else if (source == createMaterialButton)
31043256 {
31053257 CreateMaterial();
3106
- } else if (event.getSource() == clearPanelButton)
3258
+ } else if (source == clearPanelButton)
31073259 {
31083260 copy.ClearUI();
31093261 refreshContents(true);
3110
- } /*
3111
- }
3112
-
3113
- public boolean action(Event event, Object arg)
3114
- {
3115
- */ else if (event.getSource() == closeItem)
3262
+ } else if (source == importGFDItem)
3263
+ {
3264
+ ImportGFD();
3265
+ } else
3266
+ if (source == importVRMLX3DItem)
3267
+ {
3268
+ ImportVRMLX3D();
3269
+ } else
3270
+ if (source == import3DSItem)
3271
+ {
3272
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3273
+ } else
3274
+ if (source == importOBJItem)
3275
+ {
3276
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3277
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3278
+ browser.setVisible(true);
3279
+ String filename = browser.getFile();
3280
+ if (filename != null && filename.length() > 0)
3281
+ {
3282
+ String fullname = browser.getDirectory() + filename;
3283
+ makeSomething(ReadOBJ(fullname), true);
3284
+ }
3285
+ } else
3286
+ if (source == closeItem)
31163287 {
31173288 Close();
31183289 //return true;
3119
- } else if (event.getSource() == loadItem)
3290
+ } else if (source == loadItem)
31203291 {
31213292 load();
31223293 //return true;
3123
- } else if (event.getSource() == saveItem)
3294
+ } else if (source == newItem)
3295
+ {
3296
+ New();
3297
+ } else if (source == saveItem)
31243298 {
31253299 save();
31263300 //return true;
3127
- } else if (event.getSource() == saveAsItem)
3301
+ } else if (source == saveAsItem)
31283302 {
31293303 saveAs();
31303304 //return true;
3131
- } else if (event.getSource() == reexportItem)
3305
+ } else if (source == reexportItem)
31323306 {
31333307 reexport();
31343308 //return true;
3135
- } else if (event.getSource() == exportAsItem)
3309
+ } else if (source == exportAsItem)
31363310 {
31373311 export();
31383312 //return true;
3139
- } else if (event.getSource() == povItem)
3313
+ } else if (source == povItem)
31403314 {
31413315 generatePOV();
31423316 //return true;
3143
- } else if (event.getSource() == zBufferItem)
3317
+ } else if (source == zBufferItem)
31443318 {
31453319 try
31463320 {
....@@ -3162,21 +3336,8 @@
31623336 cameraView.repaint();
31633337 //return true;
31643338 }
3165
- */ else if (event.getSource() == editCameraItem)
3166
- {
3167
- cameraView.ProtectCamera();
3168
- cameraView.repaint();
3169
- return;
3170
- } else if (event.getSource() == revertCameraItem)
3171
- {
3172
- cameraView.RevertCamera();
3173
- cameraView.repaint();
3174
- return;
3175
-// } else if (event.getSource() == textureButton)
3176
-// {
3177
-// return; // true;
3178
- } else // combos...
3179
- if (event.getSource() == texresMenu)
3339
+ */ else // combos...
3340
+ if (source == texresMenu)
31803341 {
31813342 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31823343 copy.texres = texresMenu.getSelectedIndex();
....@@ -3188,12 +3349,272 @@
31883349 }
31893350 }
31903351
3352
+ void New()
3353
+ {
3354
+ while (copy.Size() > 1)
3355
+ {
3356
+ copy.remove(1);
3357
+ }
3358
+
3359
+ ResetModel();
3360
+ objEditor.refreshContents();
3361
+ }
3362
+
3363
+ static public byte[] Compress(Object3D o)
3364
+ {
3365
+ try
3366
+ {
3367
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3368
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3369
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3370
+
3371
+ Object3D parent = o.parent;
3372
+ o.parent = null;
3373
+
3374
+ out.writeObject(o);
3375
+
3376
+ o.parent = parent;
3377
+
3378
+ out.flush();
3379
+
3380
+ zstream.close();
3381
+ out.close();
3382
+
3383
+ return baos.toByteArray();
3384
+ } catch (Exception e)
3385
+ {
3386
+ System.err.println(e);
3387
+ return null;
3388
+ }
3389
+ }
3390
+
3391
+ static public Object Uncompress(byte[] bytes)
3392
+ {
3393
+ System.out.println("#bytes = " + bytes.length);
3394
+ try
3395
+ {
3396
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3397
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3398
+ ObjectInputStream in = new ObjectInputStream(istream);
3399
+ Object obj = in.readObject();
3400
+ in.close();
3401
+
3402
+ return obj;
3403
+ } catch (Exception e)
3404
+ {
3405
+ System.err.println(e);
3406
+ return null;
3407
+ }
3408
+ }
3409
+
3410
+ static public Object clone(Object o)
3411
+ {
3412
+ try
3413
+ {
3414
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3415
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3416
+
3417
+ out.writeObject(o);
3418
+
3419
+ out.flush();
3420
+ out.close();
3421
+
3422
+ byte[] bytes = baos.toByteArray();
3423
+
3424
+ System.out.println("clone = " + bytes.length);
3425
+
3426
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3427
+ ObjectInputStream in = new ObjectInputStream(bais);
3428
+ Object obj = in.readObject();
3429
+ in.close();
3430
+
3431
+ return obj;
3432
+ } catch (Exception e)
3433
+ {
3434
+ System.err.println(e);
3435
+ return null;
3436
+ }
3437
+ }
3438
+
3439
+ cRadio GetCurrentTab()
3440
+ {
3441
+ cRadio ab;
3442
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3443
+ {
3444
+ ab = (cRadio)e.nextElement();
3445
+ if(ab.GetObject() == copy)
3446
+ {
3447
+ return ab;
3448
+ }
3449
+ }
3450
+
3451
+ return null;
3452
+ }
3453
+
3454
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3455
+
3456
+ public void Save()
3457
+ {
3458
+ System.err.println("Save");
3459
+
3460
+ cRadio tab = GetCurrentTab();
3461
+
3462
+ boolean temp = CameraPane.SWITCH;
3463
+ CameraPane.SWITCH = false;
3464
+
3465
+ copy.ExtractBigData(hashtable);
3466
+
3467
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3468
+ tab.graphs[tab.undoindex++] = Compress(copy);
3469
+
3470
+ copy.RestoreBigData(hashtable);
3471
+
3472
+ CameraPane.SWITCH = temp;
3473
+
3474
+ //assert(hashtable.isEmpty());
3475
+
3476
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3477
+ {
3478
+ tab.graphs[i] = null;
3479
+ }
3480
+
3481
+ // test save
3482
+ if (false)
3483
+ {
3484
+ try
3485
+ {
3486
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3487
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3488
+
3489
+ p.writeObject(copy);
3490
+
3491
+ p.flush();
3492
+
3493
+ ostream.close();
3494
+ } catch (Exception e)
3495
+ {
3496
+ e.printStackTrace();
3497
+ }
3498
+ }
3499
+ }
3500
+
3501
+ void CopyChanged(Object3D obj)
3502
+ {
3503
+ boolean temp = CameraPane.SWITCH;
3504
+ CameraPane.SWITCH = false;
3505
+
3506
+ copy.ExtractBigData(hashtable);
3507
+
3508
+ copy.clear();
3509
+
3510
+ for (int i=0; i<obj.Size(); i++)
3511
+ {
3512
+ copy.add(obj.get(i));
3513
+ }
3514
+
3515
+ copy.RestoreBigData(hashtable);
3516
+
3517
+ CameraPane.SWITCH = temp;
3518
+
3519
+ //assert(hashtable.isEmpty());
3520
+
3521
+ copy.Touch();
3522
+
3523
+ ResetModel();
3524
+ copy.HardTouch(); // recompile?
3525
+
3526
+ cRadio ab;
3527
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3528
+ {
3529
+ ab = (cRadio)e.nextElement();
3530
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3531
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3532
+ if (test != null)
3533
+ {
3534
+ test.editWindow = ab.object.editWindow;
3535
+ ab.object = test;
3536
+ }
3537
+ }
3538
+
3539
+ refreshContents();
3540
+ }
3541
+
3542
+ public void Undo()
3543
+ {
3544
+ System.err.println("Undo");
3545
+
3546
+ cRadio tab = GetCurrentTab();
3547
+
3548
+ if (tab.undoindex == 0)
3549
+ {
3550
+ java.awt.Toolkit.getDefaultToolkit().beep();
3551
+ return;
3552
+ }
3553
+
3554
+ if (tab.graphs[tab.undoindex] == null)
3555
+ {
3556
+ Save();
3557
+ tab.undoindex -= 1;
3558
+ }
3559
+
3560
+ tab.undoindex -= 1;
3561
+
3562
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3563
+ }
3564
+
3565
+ public void Redo()
3566
+ {
3567
+ cRadio tab = GetCurrentTab();
3568
+
3569
+ if (tab.graphs[tab.undoindex + 1] == null)
3570
+ {
3571
+ java.awt.Toolkit.getDefaultToolkit().beep();
3572
+ return;
3573
+ }
3574
+
3575
+ tab.undoindex += 1;
3576
+
3577
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3578
+ }
3579
+
3580
+ void ImportGFD()
3581
+ {
3582
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3583
+ browser.show();
3584
+ String filename = browser.getFile();
3585
+ if (filename != null && filename.length() > 0)
3586
+ {
3587
+ String fullname = browser.getDirectory() + filename;
3588
+
3589
+ //Object3D readobj =
3590
+ objEditor.ReadGFD(fullname, objEditor);
3591
+ //makeSomething(readobj);
3592
+ }
3593
+ }
3594
+
3595
+ void ImportVRMLX3D()
3596
+ {
3597
+ if (Grafreed.standAlone)
3598
+ {
3599
+ /**/
3600
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3601
+ browser.show();
3602
+ String filename = browser.getFile();
3603
+ if (filename != null && filename.length() > 0)
3604
+ {
3605
+ String fullname = browser.getDirectory() + filename;
3606
+ LoadVRMLX3D(fullname);
3607
+ }
3608
+ /**/
3609
+ }
3610
+ }
3611
+
31913612 void ToggleAnimation()
31923613 {
31933614 if (!Globals.ANIMATION)
31943615 {
31953616 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3196
- browser.show();
3617
+ browser.setVisible(true);
31973618 String filename = browser.getFile();
31983619 if (filename != null && filename.length() > 0)
31993620 {
....@@ -3203,8 +3624,8 @@
32033624
32043625 Globals.ANIMATION ^= true;
32053626
3206
- GrafreeD.wav.cursor = 0;
3207
- GrafreeD.wav.loop = 0;
3627
+ Grafreed.wav.cursor = 0;
3628
+ Grafreed.wav.loop = 0;
32083629 }
32093630 } else
32103631 {
....@@ -3254,7 +3675,7 @@
32543675 void CreateMaterial()
32553676 {
32563677 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3678
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583679 if (copy.selection.size() > 0)
32593680 //SetMaterial(copy);
32603681 {
....@@ -3313,11 +3734,11 @@
33133734 {
33143735 copy.ResetBlockLoop(); // temporary problem
33153736
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3737
+ boolean random = CameraPane.SWITCH;
3738
+ CameraPane.SWITCH = false; // parse everything
33183739 copy.ResetDisplayList();
33193740 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3741
+ CameraPane.SWITCH = random;
33213742 }
33223743
33233744 // public void applySelf()
....@@ -3391,6 +3812,36 @@
33913812 {
33923813 //System.out.println("Propagate = " + propagate);
33933814 copy.UpdateMaterial(anchor, current, propagate);
3815
+
3816
+ if (copy.material != null)
3817
+ {
3818
+ cMaterial mat = copy.material;
3819
+
3820
+ colorField.SetToolTipValue((mat.color));
3821
+ modulationField.SetToolTipValue((mat.modulation));
3822
+ metalnessField.SetToolTipValue((mat.metalness));
3823
+ diffuseField.SetToolTipValue((mat.diffuse));
3824
+ specularField.SetToolTipValue((mat.specular));
3825
+ shininessField.SetToolTipValue((mat.shininess));
3826
+ shiftField.SetToolTipValue((mat.shift));
3827
+ ambientField.SetToolTipValue((mat.ambient));
3828
+ lightareaField.SetToolTipValue((mat.lightarea));
3829
+ diffusenessField.SetToolTipValue((mat.factor));
3830
+ velvetField.SetToolTipValue((mat.velvet));
3831
+ sheenField.SetToolTipValue((mat.sheen));
3832
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3833
+ backlitField.SetToolTipValue((mat.bump));
3834
+ anisoField.SetToolTipValue((mat.aniso));
3835
+ anisoVField.SetToolTipValue((mat.anisoV));
3836
+ cameraField.SetToolTipValue((mat.cameralight));
3837
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3838
+ shadowField.SetToolTipValue((mat.shadow));
3839
+ textureField.SetToolTipValue((mat.texture));
3840
+ opacityField.SetToolTipValue((mat.opacity));
3841
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3842
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3843
+ }
3844
+
33943845 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953846 {
33963847 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3435,6 +3886,7 @@
34353886 || e.getSource() == apertureField
34363887 || e.getSource() == shadowblurField)
34373888 {
3889
+ new Exception().printStackTrace();
34383890 System.exit(0);
34393891 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34403892 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3505,7 +3957,7 @@
35053957 }
35063958
35073959 if (normalpushField != null)
3508
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
3960
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35093961 }
35103962
35113963 void SnapObject()
....@@ -3769,6 +4221,8 @@
37694221
37704222 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37714223 {
4224
+ if (Globals.SAVEONMAKE)
4225
+ Save();
37724226 //Tween.set(thing, 0).target(1).start(tweenManager);
37734227 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37744228 // if (thing instanceof GenericJointDemo)
....@@ -3972,6 +4426,7 @@
39724426 }
39734427 }
39744428 }
4429
+
39754430 LoadGFDThread loadGFDThread;
39764431
39774432 void ReadGFD(String fullname, iCallBack cb)
....@@ -3991,8 +4446,10 @@
39914446
39924447 try
39934448 {
4449
+ // Try compressed version first.
39944450 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3995
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4451
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4452
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39964453
39974454 readobj = (Object3D) p.readObject();
39984455 istream.close();
....@@ -4000,7 +4457,20 @@
40004457 readobj.ResetDisplayList();
40014458 } catch (Exception e)
40024459 {
4003
- e.printStackTrace();
4460
+ //e.printStackTrace();
4461
+ try
4462
+ {
4463
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4464
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4465
+
4466
+ readobj = (Object3D) p.readObject();
4467
+ istream.close();
4468
+
4469
+ readobj.ResetDisplayList();
4470
+ } catch (Exception e2)
4471
+ {
4472
+ e2.printStackTrace();
4473
+ }
40044474 }
40054475 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40064476 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4046,6 +4516,12 @@
40464516
40474517 void LoadIt(Object obj)
40484518 {
4519
+ if (obj == null)
4520
+ {
4521
+ // Invalid file
4522
+ return;
4523
+ }
4524
+
40494525 System.out.println("Loaded " + obj);
40504526 //new Exception().printStackTrace();
40514527 Object3D readobj = (Object3D) obj;
....@@ -4055,6 +4531,8 @@
40554531
40564532 if (readobj != null)
40574533 {
4534
+ if (Globals.SAVEONMAKE)
4535
+ Save();
40584536 try
40594537 {
40604538 //readobj.deepCopySelf(copy);
....@@ -4117,7 +4595,7 @@
41174595
41184596 void load() // throws ClassNotFoundException
41194597 {
4120
- if (GrafreeD.standAlone)
4598
+ if (Grafreed.standAlone)
41214599 {
41224600 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41234601 browser.show();
....@@ -4204,11 +4682,13 @@
42044682 try
42054683 {
42064684 FileOutputStream ostream = new FileOutputStream(lastname);
4207
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4685
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4686
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42084687
42094688 p.writeObject(copy);
42104689 p.flush();
42114690
4691
+ zstream.close();
42124692 ostream.close();
42134693
42144694 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4218,11 +4698,12 @@
42184698 {
42194699 }
42204700 }
4701
+
42214702 String lastname;
42224703
42234704 void saveAs()
42244705 {
4225
- if (GrafreeD.standAlone)
4706
+ if (Grafreed.standAlone)
42264707 {
42274708 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42284709 browser.setVisible(true);
....@@ -4327,13 +4808,13 @@
43274808 try
43284809 {
43294810 FileOutputStream ostream = new FileOutputStream(filename);
4330
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4331
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4811
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4812
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43324813
43334814 Object3D objectparent = obj.parent;
43344815 obj.parent = null;
43354816
4336
- Object3D object = (Object3D) GrafreeD.clone(obj);
4817
+ Object3D object = (Object3D) Grafreed.clone(obj);
43374818
43384819 obj.parent = objectparent;
43394820
....@@ -4345,8 +4826,8 @@
43454826 p.writeObject(object);
43464827 p.flush();
43474828
4829
+ zstream.close();
43484830 ostream.close();
4349
- // zstream.close();
43504831
43514832 // group.selection.get(0).parent = parent;
43524833 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4367,7 +4848,7 @@
43674848 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43684849 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43694850 copy.generatePOV(buffer);
4370
- if (GrafreeD.standAlone)
4851
+ if (Grafreed.standAlone)
43714852 {
43724853 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43734854 browser.show();
....@@ -4393,7 +4874,8 @@
43934874 Object3D client;
43944875 Object3D copy;
43954876 MenuBar menuBar;
4396
- Menu windowMenu;
4877
+ Menu fileMenu;
4878
+ MenuItem newItem;
43974879 MenuItem loadItem;
43984880 MenuItem saveItem;
43994881 MenuItem saveAsItem;
....@@ -4401,13 +4883,11 @@
44014883 MenuItem reexportItem;
44024884 MenuItem povItem;
44034885 MenuItem closeItem;
4404
- Menu cameraMenu;
4886
+
44054887 CheckboxMenuItem zBufferItem;
44064888 //MenuItem normalLensItem;
4407
- MenuItem editCameraItem;
4408
- MenuItem revertCameraItem;
4409
- CheckboxMenuItem toggleLiveItem;
44104889 MenuItem stepItem;
4890
+ CheckboxMenuItem toggleLiveItem;
44114891 CheckboxMenuItem toggleFullScreenItem;
44124892 CheckboxMenuItem toggleTimelineItem;
44134893 CheckboxMenuItem toggleRenderItem;
....@@ -4416,7 +4896,7 @@
44164896 CheckboxMenuItem toggleFootContactItem;
44174897 CheckboxMenuItem toggleDLItem;
44184898 CheckboxMenuItem toggleTextureItem;
4419
- CheckboxMenuItem toggleRandomItem;
4899
+ CheckboxMenuItem toggleSwitchItem;
44204900 CheckboxMenuItem toggleRootItem;
44214901 CheckboxMenuItem animationItem;
44224902 CheckboxMenuItem toggleHandleItem;
....@@ -4424,7 +4904,7 @@
44244904 JSplitPane mainPanel;
44254905 JScrollPane scrollpane;
44264906 JPanel toolbarPanel;
4427
- JPanel treePanel;
4907
+ cGridBag treePanel;
44284908 JPanel radioPanel;
44294909 ButtonGroup buttonGroup;
44304910 cGridBag ctrlPanel;
....@@ -4553,4 +5033,9 @@
45535033 //ObjectUI parent;
45545034
45555035 cNumberSlider normalpushField;
5036
+
5037
+ private MenuItem importGFDItem;
5038
+ private MenuItem importVRMLX3DItem;
5039
+ private MenuItem import3DSItem;
5040
+ private MenuItem importOBJItem;
45565041 }