Normand Briere
2019-06-25 26b24f5b623e709a88e91e9bce0864f9d5e8f084
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,67 @@
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
+ cToggleButton GetToggleButton(String name, boolean border)
56
+ {
57
+ try
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cToggleButton(icon, border);
61
+ }
62
+ catch (Exception e)
63
+ {
64
+ return new cToggleButton(name, border);
65
+ }
66
+ }
67
+
68
+ cCheckBox GetCheckBox(String name, boolean border)
69
+ {
70
+ try
71
+ {
72
+ ImageIcon icon = GetIcon(name);
73
+ return new cCheckBox(icon, border);
74
+ }
75
+ catch (Exception e)
76
+ {
77
+ return new cCheckBox(name, border);
78
+ }
79
+ }
80
+
81
+ private ImageIcon GetIcon(String name) throws IOException
82
+ {
83
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
+
85
+ if (image.getWidth() != 24 && image.getHeight() != 24)
86
+ {
87
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
+ Graphics2D g = resized.createGraphics();
89
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
+ g.dispose();
93
+
94
+ image = resized;
95
+ }
96
+
97
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
+ return icon;
99
+ }
38100
39101 // SCRIPT
40102
....@@ -138,34 +200,42 @@
138200 public void closeUI()
139201 {
140202 //new Exception().printStackTrace();
141
- System.out.println("this = " + this);
142
- System.out.println("objEditor = " + objEditor);
203
+// System.out.println("this = " + this);
204
+// System.out.println("objEditor = " + objEditor);
143205 //nameField.removeActionListener(this);
144
- objEditor.ctrlPanel.remove(nameField);
206
+// objEditor.ctrlPanel.remove(nameField);
207
+
208
+ objEditor.ctrlPanel.remove(namePanel);
145209
146210 if (!GroupEditor.allparams)
147211 return;
148212
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);
213
+// objEditor.ctrlPanel.remove(liveCB);
214
+// objEditor.ctrlPanel.remove(hideCB);
215
+// objEditor.ctrlPanel.remove(markCB);
216
+//
217
+// objEditor.ctrlPanel.remove(randomCB);
218
+// objEditor.ctrlPanel.remove(speedupCB);
219
+// objEditor.ctrlPanel.remove(rewindCB);
220
+//
221
+// objEditor.ctrlPanel.remove(resetButton);
222
+// objEditor.ctrlPanel.remove(stepButton);
223
+//// objEditor.ctrlPanel.remove(stepAllButton);
224
+//// objEditor.ctrlPanel.remove(resetAllButton);
225
+// objEditor.ctrlPanel.remove(link2masterCB);
226
+// //objEditor.ctrlPanel.remove(flipVCB);
227
+// //objEditor.ctrlPanel.remove(texresMenu);
228
+// objEditor.ctrlPanel.remove(slowerButton);
229
+// objEditor.ctrlPanel.remove(fasterButton);
230
+// objEditor.ctrlPanel.remove(remarkButton);
167231
168
- Remove(normalpushField);
232
+ objEditor.ctrlPanel.remove(setupPanel);
233
+ objEditor.ctrlPanel.remove(setupPanel2);
234
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
235
+ objEditor.ctrlPanel.remove(pushPanel);
236
+ //objEditor.ctrlPanel.remove(fillPanel);
237
+
238
+ //Remove(normalpushField);
169239 }
170240
171241 public ObjEditor GetEditor()
....@@ -236,6 +306,7 @@
236306 //localCopy.parent = null;
237307
238308 frame = new JFrame();
309
+ frame.setUndecorated(true);
239310 objEditor = this;
240311 this.callee = callee;
241312
....@@ -269,24 +340,40 @@
269340 void SetupMenu()
270341 {
271342 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..."));
343
+ menuBar.add(fileMenu = new Menu("File"));
344
+ fileMenu.add(newItem = new MenuItem("New"));
345
+ fileMenu.add(loadItem = new MenuItem("Open..."));
346
+
347
+ //oe.menuBar.add(menu = new Menu("Include"));
348
+ Menu menu = new Menu("Import");
349
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
350
+ importOBJItem.addActionListener(this);
351
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
352
+ import3DSItem.addActionListener(this);
353
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
354
+ importVRMLX3DItem.addActionListener(this);
355
+ menu.add("-");
356
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
357
+ importGFDItem.addActionListener(this);
358
+ fileMenu.add(menu);
359
+ fileMenu.add("-");
360
+
361
+ fileMenu.add(saveItem = new MenuItem("Save"));
362
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
277363 //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("-");
364
+ fileMenu.add("-");
365
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
366
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
367
+ fileMenu.add("-");
282368 if (client.parent != null)
283369 {
284
- windowMenu.add(closeItem = new MenuItem("Close"));
370
+ fileMenu.add(closeItem = new MenuItem("Close"));
285371 } else
286372 {
287
- windowMenu.add(closeItem = new MenuItem("Exit"));
373
+ fileMenu.add(closeItem = new MenuItem("Exit"));
288374 }
289375
376
+ newItem.addActionListener(this);
290377 loadItem.addActionListener(this);
291378 saveItem.addActionListener(this);
292379 saveAsItem.addActionListener(this);
....@@ -295,79 +382,59 @@
295382 //povItem.addActionListener(this);
296383 closeItem.addActionListener(this);
297384
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
-
353385 objectPanel = new JTabbedPane();
386
+
387
+ ChangeListener changeListener = new ChangeListener()
388
+ {
389
+ public void stateChanged(ChangeEvent changeEvent)
390
+ {
391
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
392
+// {
393
+// if (latestObject != null)
394
+// {
395
+// refreshContents(true);
396
+// SetMaterial(latestObject);
397
+// }
398
+//
399
+// materialFlushed = true;
400
+// }
401
+
402
+ refreshContents(false); // To refresh Info tab
403
+ }
404
+ };
405
+ objectPanel.addChangeListener(changeListener);
406
+
354407 toolbarPanel = new JPanel();
355408 toolbarPanel.setName("Toolbar");
356
- treePanel = new JPanel();
409
+ treePanel = new cGridBag();
357410 treePanel.setName("Tree");
358
- ctrlPanel = new cGridBag(); // new GridBagLayout());
359
- ctrlPanel.setName("Edit");
411
+
412
+ editPanel = new cGridBag().setVertical(true);
413
+ editPanel.setName("Edit");
414
+
415
+ ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
416
+
417
+ editCommandsPanel = new cGridBag();
418
+ editPanel.add(editCommandsPanel);
419
+ editPanel.add(ctrlPanel);
420
+
421
+ toolboxPanel = new cGridBag().setVertical(false);
422
+ toolboxPanel.setName("Toolbox");
423
+
360424 materialPanel = new cGridBag().setVertical(true);
361425 materialPanel.setName("Material");
426
+
362427 /*JTextPane*/
363428 infoarea = createTextPane();
429
+ doc = infoarea.getStyledDocument();
430
+
364431 infoarea.setEditable(true);
365432 SetText();
366433 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
367434 // infoarea.setOpaque(false);
368435 // //infoarea.setForeground(textcolor);
369
- infoarea.setLineWrap(true);
370
- infoarea.setWrapStyleWord(true);
436
+// TEXTAREA infoarea.setLineWrap(true);
437
+// TEXTAREA infoarea.setWrapStyleWord(true);
371438 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
372439 infoPanel.setPreferredSize(new Dimension(50, 200));
373440 infoPanel.setName("Info");
....@@ -378,15 +445,15 @@
378445 mainPanel.setName("Main");
379446 mainPanel.setContinuousLayout(true);
380447 mainPanel.setOneTouchExpandable(true);
381
- mainPanel.setDividerLocation(1.0);
382448 mainPanel.setDividerSize(9);
383
- mainPanel.setResizeWeight(0);
449
+ mainPanel.setDividerLocation(0.5); //1.0);
450
+ mainPanel.setResizeWeight(0.5);
384451
385452 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
386453 //mainPanel.setLayout(new GridBagLayout());
387454 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
388
- treePanel.setLayout(new GridBagLayout());
389
- ctrlPanel.setLayout(new GridBagLayout());
455
+// treePanel.setLayout(new GridBagLayout());
456
+ //ctrlPanel.setLayout(new GridBagLayout());
390457 //materialPanel.setLayout(new GridBagLayout());
391458
392459 aConstraints = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
....@@ -426,7 +493,7 @@
426493 static String newline = "\n";
427494 protected static final String buttonString = "JButton";
428495 StyledDocument doc;
429
- JTextArea infoarea;
496
+ JTextPane infoarea;
430497
431498 void ClearInfo()
432499 {
....@@ -449,10 +516,10 @@
449516 e.printStackTrace();
450517 }
451518
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();
519
+// String selection = infoarea.getText();
520
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
521
+// java.awt.datatransfer.Clipboard clipboard =
522
+// Toolkit.getDefaultToolkit().getSystemClipboard();
456523 //clipboard.setContents(data, data);
457524 }
458525
....@@ -475,13 +542,13 @@
475542 //SendInfo("Name:", "bold");
476543 if (sel.GetTextures() != null || debug)
477544 {
478
- si.SendInfo(sel.toString(), "bold");
545
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
479546 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
480547 if (sel.Size() > 0)
481548 {
482549 si.SendInfo("#children = " + sel.Size(), "regular");
483550 }
484
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
551
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
485552 if (debug)
486553 {
487554 try
....@@ -493,7 +560,10 @@
493560 }
494561
495562 if (full)
496
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
563
+ {
564
+ si.SendInfo(" BBox min: " + minima, "regular");
565
+ si.SendInfo(" BBox max: " + maxima, "regular");
566
+ }
497567
498568 if (sel.bRep != null)
499569 {
....@@ -520,7 +590,7 @@
520590 }
521591 if (sel.support != null)
522592 {
523
- si.SendInfo(" support: " + sel.support, "regular");
593
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
524594 }
525595 if (sel.scriptnode != null)
526596 {
....@@ -591,6 +661,9 @@
591661 {
592662 CameraPane.pointflow = (PointFlow) sel;
593663 }
664
+
665
+ si.SendInfo("_____________________", "regular");
666
+ si.SendInfo("", "regular");
594667 }
595668 }
596669
....@@ -606,68 +679,140 @@
606679 }
607680 }
608681
682
+static GraphicsDevice device = GraphicsEnvironment
683
+ .getLocalGraphicsEnvironment().getScreenDevices()[0];
684
+
685
+ Rectangle keeprect;
686
+ cRadio radio;
687
+
688
+cButton keepButton;
689
+ cButton twoButton; // Full 3D
690
+ cButton sixButton;
691
+ cButton threeButton;
692
+ cButton sevenButton;
693
+ cButton fourButton; // full panel
694
+ cButton oneButton; // full XYZ
695
+ //cButton currentLayout;
696
+
697
+ boolean maximized;
698
+
699
+ cButton fullscreenLayout;
700
+
701
+ void Minimize()
702
+ {
703
+ frame.setState(Frame.ICONIFIED);
704
+ }
705
+
706
+ void Maximize()
707
+ {
708
+ if (maximized)
709
+ {
710
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
711
+ }
712
+ else
713
+ {
714
+ keeprect = frame.getBounds();
715
+ Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
+ Dimension rect2 = frame.getToolkit().getScreenSize();
717
+ frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
718
+// frame.setState(Frame.MAXIMIZED_BOTH);
719
+ }
720
+
721
+ maximized ^= true;
722
+ }
723
+
609724 void ToggleFullScreen()
610725 {
611
- if (CameraPane.FULLSCREEN)
726
+ cameraView.ToggleFullScreen();
727
+
728
+ if (!CameraPane.FULLSCREEN)
612729 {
613
- frame.getContentPane().remove(/*"Center",*/bigThree);
614
- framePanel.add(bigThree);
615
- frame.getContentPane().add(/*"Center",*/framePanel);
730
+ device.setFullScreenWindow(null);
731
+ //frame.setVisible(false);
732
+// frame.removeNotify();
733
+// frame.setUndecorated(false);
734
+// frame.addNotify();
735
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
736
+
737
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
738
+// X framePanel.add(bigThree);
739
+// X frame.getContentPane().add(/*"Center",*/framePanel);
740
+ framePanel.setDividerLocation(1);
741
+
742
+ //frame.setVisible(true);
743
+ radio.layout = keepButton;
744
+ //theFrame = null;
745
+ keepButton = null;
746
+ radio.layout.doClick();
747
+
616748 } else
617749 {
618
- frame.getContentPane().remove(/*"Center",*/framePanel);
619
- framePanel.remove(bigThree);
620
- frame.getContentPane().add(/*"Center",*/bigThree);
750
+ keepButton = radio.layout;
751
+ //keeprect = frame.getBounds();
752
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
753
+// frame.getToolkit().getScreenSize().height);
754
+ //frame.setVisible(false);
755
+ device.setFullScreenWindow(frame);
756
+// frame.removeNotify();
757
+// frame.setUndecorated(true);
758
+// frame.addNotify();
759
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
760
+// X framePanel.remove(bigThree);
761
+// X frame.getContentPane().add(/*"Center",*/bigThree);
762
+ framePanel.setDividerLocation(0);
763
+
764
+ radio.layout = fullscreenLayout;
765
+ radio.layout.doClick();
766
+ //frame.setVisible(true);
621767 }
622
- cameraView.ToggleFullScreen();
623768 }
624769
625
- private JTextArea createTextPane()
770
+ private JTextPane createTextPane()
626771 {
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
- };
772
+// TEXTAREA String[] initString =
773
+// {
774
+// "This is an editable JTextPane, ", //regular
775
+// "another ", //italic
776
+// "styled ", //bold
777
+// "text ", //small
778
+// "component, ", //large
779
+// "which supports embedded components..." + newline,//regular
780
+// " " + newline, //button
781
+// "...and embedded icons..." + newline, //regular
782
+// " ", //icon
783
+// newline + "JTextPane is a subclass of JEditorPane that "
784
+// + "uses a StyledEditorKit and StyledDocument, and provides "
785
+// + "cover methods for interacting with those objects."
786
+// };
787
+//
788
+// String[] initStyles =
789
+// {
790
+// "regular", "italic", "bold", "small", "large",
791
+// "regular", "button", "regular", "icon",
792
+// "regular"
793
+// };
794
+//
795
+// JTextPane textPane = new JTextPane();
796
+// textPane.setEditable(true);
797
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
798
+// addStylesToDocument(doc);
799
+//
800
+// try
801
+// {
802
+// for (int j = 0; j < 2; j++)
803
+// {
804
+// for (int i = 0; i < initString.length; i++)
805
+// {
806
+// doc.insertString(doc.getLength(), initString[i],
807
+// doc.getStyle(initStyles[i]));
808
+// }
809
+// }
810
+// } catch (BadLocationException ble)
811
+// {
812
+// System.err.println("Couldn't insert initial text into text pane.");
813
+// }
642814
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;
815
+ return new JTextPane(); // textPane;
671816 }
672817
673818 protected void addStylesToDocument(StyledDocument doc)
....@@ -720,7 +865,7 @@
720865 protected static ImageIcon createImageIcon(String path,
721866 String description)
722867 {
723
- java.net.URL imgURL = GrafreeD.class.getResource(path);
868
+ java.net.URL imgURL = Grafreed.class.getResource(path);
724869 if (imgURL != null)
725870 {
726871 return new ImageIcon(imgURL, description);
....@@ -752,6 +897,7 @@
752897 // NumberSlider vDivsField;
753898 // JCheckBox endcaps;
754899 JCheckBox liveCB;
900
+ JCheckBox selectCB;
755901 JCheckBox hideCB;
756902 JCheckBox link2masterCB;
757903 JCheckBox markCB;
....@@ -759,7 +905,12 @@
759905 JCheckBox speedupCB;
760906 JCheckBox rewindCB;
761907 JCheckBox flipVCB;
908
+
909
+ cCheckBox toggleTextureCB;
910
+ cCheckBox toggleSwitchCB;
911
+
762912 JComboBox texresMenu;
913
+
763914 JButton resetButton;
764915 JButton stepButton;
765916 JButton stepAllButton;
....@@ -767,54 +918,48 @@
767918 JButton slowerButton;
768919 JButton fasterButton;
769920 JButton remarkButton;
921
+
922
+ cGridBag editPanel;
923
+ cGridBag editCommandsPanel;
924
+
925
+ cGridBag namePanel;
926
+ cGridBag setupPanel;
927
+ cGridBag setupPanel2;
928
+ cGridBag objectCommandsPanel;
929
+ cGridBag pushPanel;
930
+ cGridBag fillPanel;
770931
771
- JCheckBox AddCheckBox(ObjEditor oe, String label, boolean on)
932
+ JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
772933 {
773934 JCheckBox cb;
774935
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);
936
+ panel.add(cb = new JCheckBox(label, on)); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
780937 cb.addItemListener(this);
781
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
782
- oe.aConstraints.gridwidth = 1;
783
- oe.aConstraints.gridx += 1;
784938
785939 return cb;
786940 }
787941
788
- cButton AddButton(ObjEditor oe, String label)
942
+ cButton AddButton(cGridBag panel, String label)
789943 {
790944 cButton cb;
791945
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);
946
+ panel.add(cb = new cButton(label)); //, oe.aConstraints, oe.ctrlPanel.getComponentCount() - 1);
797947 cb.addActionListener(this);
798
-// oe.aConstraints.anchor = GridBagConstraints.EAST;
799
- oe.aConstraints.gridwidth = 1;
800
- oe.aConstraints.gridx += 1;
801948
802949 return cb;
803950 }
804951
805
- JComboBox AddCombo(ObjEditor oe, java.util.Vector list, int item)
952
+ JComboBox AddCombo(cGridBag panel, java.util.Vector list, int item)
806953 {
807954 JComboBox combo;
808955
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;
956
+ panel.add(combo = new JComboBox(new cListModel(list, item))); //, oe.aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
812957 combo.addActionListener(this);
813958
814959 return combo;
815960 }
816961
817
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, double min, double max, double current, double pow)
962
+ cGridBag AddSlider(cGridBag panel, String label, double min, double max, double current, double pow)
818963 {
819964 cGridBag control = new cGridBag();
820965
....@@ -826,12 +971,12 @@
826971 control.add(combo = new cNumberSlider(this, min, max, pow)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
827972 combo.setFloat(current);
828973
829
- ctrlPanel.add(control);
974
+ panel.add(control);
830975
831
- return combo;
976
+ return control;
832977 }
833978
834
- cNumberSlider AddSlider(cGridBag ctrlPanel, String label, int min, int max, int current)
979
+ cGridBag AddSlider(cGridBag panel, String label, int min, int max, int current)
835980 {
836981 cGridBag control = new cGridBag();
837982
....@@ -839,25 +984,21 @@
839984
840985 JLabel jlabel = new JLabel(label);
841986 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);
987
+ control.add(jlabel); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
988
+ control.add(combo = new cNumberSlider(this, min, max)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
844989 combo.setInteger(current);
845990
846
- ctrlPanel.add(control);
991
+ panel.add(control);
847992
848
- return combo;
993
+ return control;
849994 }
850995
851996 JTextArea AddText(cGridBag ctrlPanel, String name)
852997 {
853998 JTextArea text;
854999
855
- aConstraints.fill = GridBagConstraints.HORIZONTAL;
856
- aConstraints.gridwidth = ObjEditor.GRIDWIDTH;
8571000 ctrlPanel.add(text = new JTextArea(name)); //, aConstraints); //, oe.ctrlPanel.getComponentCount()-1);
8581001 text.addCaretListener(this);
859
- aConstraints.gridx += 1;
860
- aConstraints.gridwidth = 1;
8611002
8621003 return text;
8631004 }
....@@ -896,7 +1037,7 @@
8961037
8971038 /*
8981039 */
899
- void Return() // ObjEditor oe)
1040
+ void Return0() // ObjEditor oe)
9001041 {
9011042 aConstraints.gridy += 1;
9021043 aConstraints.gridx = 0;
....@@ -951,37 +1092,76 @@
9511092
9521093 void SetupUI2(ObjEditor oe)
9531094 {
954
-// oe.aConstraints.weightx = 0;
955
-// oe.aConstraints.weighty = 0;
956
-// oe.aConstraints.gridx = 0;
957
-// oe.aConstraints.gridy = 0;
958
- SetupName(oe);
1095
+ //SetupName(oe);
1096
+
1097
+ namePanel = new cGridBag();
1098
+
1099
+ nameField = AddText(namePanel, copy.GetName());
1100
+ namePanel.add(nameField);
1101
+ oe.ctrlPanel.add(namePanel);
1102
+
1103
+ oe.ctrlPanel.Return();
9591104
9601105 if (!GroupEditor.allparams)
9611106 return;
9621107
963
- liveCB = AddCheckBox(oe, "Live", copy.live);
964
- link2masterCB = AddCheckBox(oe, "Supp", copy.link2master);
965
- hideCB = AddCheckBox(oe, "Hide", copy.hide);
1108
+ setupPanel = new cGridBag().setVertical(false);
1109
+
1110
+ liveCB = AddCheckBox(setupPanel, "Live", copy.live);
1111
+ liveCB.setToolTipText("Animate object");
1112
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1113
+ selectCB.setToolTipText("Make object selectable");
9661114 // 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");
1115
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1116
+ hideCB.setToolTipText("Hide object");
1117
+ markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1118
+ markCB.setToolTipText("Set the animation target transform");
1119
+
1120
+ setupPanel2 = new cGridBag().setVertical(false);
1121
+
1122
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1123
+ rewindCB.setToolTipText("Rewind animation");
1124
+
1125
+ randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
+ randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1127
+
1128
+ if (Globals.ADVANCED)
1129
+ {
1130
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1131
+ link2masterCB.setToolTipText("Attach to support");
1132
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1133
+ speedupCB.setToolTipText("Option motion capture");
1134
+ }
1135
+
1136
+ oe.ctrlPanel.add(setupPanel);
1137
+ oe.ctrlPanel.Return();
1138
+ oe.ctrlPanel.add(setupPanel2);
1139
+ oe.ctrlPanel.Return();
1140
+
1141
+ objectCommandsPanel = new cGridBag().setVertical(false);
1142
+
1143
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1144
+ resetButton.setToolTipText("Jump to frame zero");
1145
+ stepButton = AddButton(objectCommandsPanel, "Step");
1146
+ stepButton.setToolTipText("Step one frame");
9731147 // resetAllButton = AddButton(oe, "Reset All");
9741148 // stepAllButton = AddButton(oe, "Step All");
975
- speedupCB = AddCheckBox(oe, "Speed", copy.speedup);
9761149 // Return();
977
- slowerButton = AddButton(oe, "Slow");
978
- fasterButton = AddButton(oe, "Fast");
979
- remarkButton = AddButton(oe, "Rem");
1150
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1151
+ slowerButton.setToolTipText("Decrease animation speed");
1152
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1153
+ fasterButton.setToolTipText("Increase animation speed");
1154
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1155
+ remarkButton.setToolTipText("Set the current transform as the target");
9801156
981
- //Return();
1157
+ oe.ctrlPanel.add(objectCommandsPanel);
1158
+ oe.ctrlPanel.Return();
9821159
983
- //normalpushField = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, -1);
1160
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
1161
+ normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9841162 //Return();
1163
+
1164
+ oe.ctrlPanel.Return();
9851165
9861166 // oe.ctrlPanel.add(stepButton = new cButton("Step"), ObjEditor.aConstraints, oe.ctrlPanel.getComponentCount() - 2);
9871167 // ObjEditor.aConstraints.gridx += 1;
....@@ -1076,7 +1256,7 @@
10761256 oe.aConstraints.gridwidth = 1;
10771257 /**/
10781258 nameField = AddText(oe.ctrlPanel, copy.GetName());
1079
- Return();
1259
+ oe.ctrlPanel.Return();
10801260
10811261 //ctrlPanel.add(textureButton = new Button("Texture..."));
10821262 //textureButton.setEnabled(false);
....@@ -1180,8 +1360,11 @@
11801360 //worldPanel.setName("World");
11811361 centralPanel = new cGridBag();
11821362 centralPanel.preferredWidth = 20;
1183
- timelinePanel = new JPanel(new BorderLayout());
1184
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1363
+
1364
+ if (Globals.ADVANCED)
1365
+ {
1366
+ timelinePanel = new JPanel(new BorderLayout());
1367
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11851368
11861369 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11871370 cameraPanel.setContinuousLayout(true);
....@@ -1190,7 +1373,10 @@
11901373 // cameraPanel.setDividerSize(9);
11911374 cameraPanel.setResizeWeight(1.0);
11921375
1376
+ }
1377
+
11931378 centralPanel.add(cameraView);
1379
+ centralPanel.setFocusable(true);
11941380 //frame.setJMenuBar(timelineMenubar);
11951381 //centralPanel.add(timelinePanel);
11961382
....@@ -1253,10 +1439,12 @@
12531439 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12541440 //tmp.setName("Edit");
12551441 objectPanel.add(materialPanel);
1256
- JPanel north = new JPanel(new BorderLayout());
1257
- north.setName("Edit");
1258
- north.add(ctrlPanel, BorderLayout.NORTH);
1259
- objectPanel.add(north);
1442
+ objectPanel.add(toolboxPanel);
1443
+// JPanel north = new JPanel(new BorderLayout());
1444
+// north.setName("Edit");
1445
+// north.add(ctrlPanel, BorderLayout.NORTH);
1446
+// objectPanel.add(north);
1447
+ objectPanel.add(editPanel);
12601448 objectPanel.add(infoPanel);
12611449
12621450 /*
....@@ -1278,14 +1466,12 @@
12781466 scrollpane.addMouseWheelListener(this); // Default not fast enough
12791467
12801468 /*JTabbedPane*/ scenePanel = new cGridBag();
1281
- scenePanel.preferredWidth = 7;
1469
+ scenePanel.preferredWidth = 6;
12821470
12831471 JTabbedPane tabbedPane = new JTabbedPane();
12841472 tabbedPane.add(scrollpane);
12851473
1286
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1287
-
1288
- optionsPanel = new cGridBag().setVertical(true);
1474
+ optionsPanel = new cGridBag().setVertical(false);
12891475
12901476 optionsPanel.setName("Options");
12911477
....@@ -1293,6 +1479,8 @@
12931479
12941480 tabbedPane.add(optionsPanel);
12951481
1482
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1483
+
12961484 scenePanel.add(tabbedPane);
12971485
12981486 /*
....@@ -1384,9 +1572,13 @@
13841572
13851573 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13861574
1387
- frame.setSize(1024, 768);
1388
- frame.show();
1575
+ frame.setSize(1280, 860);
1576
+
1577
+ frame.validate();
1578
+ frame.setVisible(true);
13891579
1580
+ cameraView.requestFocusInWindow();
1581
+
13901582 gridPanel.setDividerLocation(1.0);
13911583
13921584 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
....@@ -1415,7 +1607,7 @@
14151607 ctrlPanel.removeAll();
14161608 }
14171609
1418
- void SetupMaterial(cGridBag ctrlPanel)
1610
+ void SetupMaterial(cGridBag panel)
14191611 {
14201612 /*
14211613 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
....@@ -1424,18 +1616,26 @@
14241616
14251617 cGridBag editBar = new cGridBag().setVertical(false);
14261618
1427
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1619
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1620
+ createMaterialButton.setToolTipText("Create material");
14281621
14291622 /*
14301623 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14311624 */
14321625
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);
1626
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1627
+ clearMaterialButton.setToolTipText("Clear material");
1628
+
1629
+ if (Globals.ADVANCED)
1630
+ {
1631
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1632
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1633
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1634
+ }
14371635
1438
- ctrlPanel.add(editBar);
1636
+ editBar.preferredHeight = 15;
1637
+
1638
+ panel.add(editBar);
14391639
14401640 /**/
14411641 //aConstraints.weighty = 0;
....@@ -1484,9 +1684,9 @@
14841684 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
14851685 colorSection.add(shadowbias);
14861686
1487
- ctrlPanel.add(new JSeparator());
1687
+ panel.add(new JSeparator());
14881688
1489
- ctrlPanel.add(colorSection);
1689
+ panel.add(colorSection);
14901690
14911691 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14921692
....@@ -1534,9 +1734,9 @@
15341734 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15351735 diffuseSection.add(fakedepth);
15361736
1537
- ctrlPanel.add(new JSeparator());
1737
+ panel.add(new JSeparator());
15381738
1539
- ctrlPanel.add(diffuseSection);
1739
+ panel.add(diffuseSection);
15401740
15411741 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15421742
....@@ -1572,7 +1772,7 @@
15721772 velvet.add(velvetField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15731773 specularSection.add(velvet);
15741774
1575
- shiftField = AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1);
1775
+ shiftField = (cNumberSlider)AddSlider(specularSection, "Shift", 0.001, 50, copy.material.shift, -1).getComponent(1);
15761776 //Return();
15771777 // ctrlPanel.add(shiftLabel = new JLabel("Shift"), aConstraints);
15781778 // shiftLabel.setHorizontalAlignment(SwingConstants.TRAILING);
....@@ -1585,9 +1785,9 @@
15851785 // aConstraints.gridwidth = 1;
15861786
15871787
1588
- ctrlPanel.add(new JSeparator());
1788
+ panel.add(new JSeparator());
15891789
1590
- ctrlPanel.add(specularSection);
1790
+ panel.add(specularSection);
15911791
15921792 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15931793
....@@ -1617,9 +1817,9 @@
16171817 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16181818 globalSection.add(opacity);
16191819
1620
- ctrlPanel.add(new JSeparator());
1820
+ panel.add(new JSeparator());
16211821
1622
- ctrlPanel.add(globalSection);
1822
+ panel.add(globalSection);
16231823
16241824 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16251825
....@@ -1661,9 +1861,9 @@
16611861 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16621862 textureSection.add(opacityPower);
16631863
1664
- ctrlPanel.add(new JSeparator());
1864
+ panel.add(new JSeparator());
16651865
1666
- ctrlPanel.add(textureSection);
1866
+ panel.add(textureSection);
16671867
16681868 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16691869
....@@ -1700,12 +1900,15 @@
17001900 opacityPowerField.addChangeListener(this);
17011901 /**/
17021902
1703
- resetSlidersButton.addActionListener(this);
17041903 clearMaterialButton.addActionListener(this);
17051904 createMaterialButton.addActionListener(this);
1706
-
1707
- propagateToggle.addItemListener(this);
1708
- multiplyToggle.addItemListener(this);
1905
+
1906
+ if (Globals.ADVANCED)
1907
+ {
1908
+ resetSlidersButton.addActionListener(this);
1909
+ propagateToggle.addItemListener(this);
1910
+ multiplyToggle.addItemListener(this);
1911
+ }
17091912 }
17101913
17111914 void DropFile(java.io.File[] files, boolean textures)
....@@ -1876,7 +2079,7 @@
18762079
18772080 //? flashIt = false;
18782081 CameraPane pane = (CameraPane) cameraView;
1879
- pane.clickStart(location.x, location.y, 0);
2082
+ pane.clickStart(location.x, location.y, 0, 0);
18802083 pane.clickEnd(location.x, location.y, 0, true);
18812084
18822085 if (group.selection.size() == 1)
....@@ -1925,6 +2128,7 @@
19252128 e2.printStackTrace();
19262129 }
19272130 }
2131
+
19282132 LoadJMEThread loadThread;
19292133
19302134 class LoadJMEThread extends Thread
....@@ -1982,6 +2186,7 @@
19822186 //LoadFile0(filename, converter);
19832187 }
19842188 }
2189
+
19852190 LoadOBJThread loadObjThread;
19862191
19872192 class LoadOBJThread extends Thread
....@@ -2060,19 +2265,19 @@
20602265
20612266 void LoadObjFile(String fullname)
20622267 {
2063
- /*
2268
+ System.out.println("Loading " + fullname);
2269
+ /**/
20642270 //lastFilename = fullname;
20652271 if(loadObjThread == null)
20662272 {
2067
- loadObjThread = new LoadOBJThread();
2068
- loadObjThread.start();
2273
+ loadObjThread = new LoadOBJThread();
2274
+ loadObjThread.start();
20692275 }
20702276
20712277 loadObjThread.add(fullname);
2072
- */
2278
+ /**/
20732279
2074
- System.out.println("Loading " + fullname);
2075
- makeSomething(new FileObject(fullname, true), true);
2280
+ //makeSomething(new FileObject(fullname, true), true);
20762281 }
20772282
20782283 void LoadGFDFile(String fullname)
....@@ -2333,11 +2538,11 @@
23332538
23342539 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23352540 {
2336
- if (GrafreeD.standAlone)
2541
+ if (Grafreed.standAlone)
23372542 {
23382543 /**/
23392544 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2340
- browser.show();
2545
+ browser.setVisible(true);
23412546 String filename = browser.getFile();
23422547 if (filename != null && filename.length() > 0)
23432548 {
....@@ -2482,6 +2687,7 @@
24822687 }
24832688 if (input == null)
24842689 {
2690
+ new Exception().printStackTrace();
24852691 System.exit(0);
24862692 }
24872693
....@@ -2688,6 +2894,8 @@
26882894
26892895 void SetMaterial(Object3D object)
26902896 {
2897
+ latestObject = object;
2898
+
26912899 cMaterial mat = object.material;
26922900
26932901 if (mat == null)
....@@ -2696,7 +2904,8 @@
26962904 return;
26972905 }
26982906
2699
- multiplyToggle.setSelected(mat.multiply);
2907
+ if (multiplyToggle != null)
2908
+ multiplyToggle.setSelected(mat.multiply);
27002909
27012910 assert (object.projectedVertices != null);
27022911
....@@ -2872,7 +3081,7 @@
28723081 cameraView.ToggleDL();
28733082 cameraView.repaint();
28743083 return;
2875
- } else if (event.getSource() == toggleTextureItem)
3084
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28763085 {
28773086 cameraView.ToggleTexture();
28783087 // june 2013 copy.HardTouch();
....@@ -2911,9 +3120,9 @@
29113120 frame.validate();
29123121
29133122 return;
2914
- } else if (event.getSource() == toggleRandomItem)
3123
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29153124 {
2916
- cameraView.ToggleRandom();
3125
+ cameraView.ToggleSwitch();
29173126 cameraView.repaint();
29183127 return;
29193128 } else if (event.getSource() == toggleHandleItem)
....@@ -2942,6 +3151,10 @@
29423151 {
29433152 copy.live ^= true;
29443153 return;
3154
+ } else if (event.getSource() == selectCB)
3155
+ {
3156
+ copy.dontselect ^= true;
3157
+ return;
29453158 } else if (event.getSource() == hideCB)
29463159 {
29473160 copy.hide ^= true;
....@@ -2956,6 +3169,7 @@
29563169 if (event.getSource() == randomCB)
29573170 {
29583171 copy.random ^= true;
3172
+ objEditor.refreshContents();
29593173 return;
29603174 }
29613175 if (event.getSource() == speedupCB)
....@@ -2979,8 +3193,9 @@
29793193
29803194 public void actionPerformed(ActionEvent event)
29813195 {
3196
+ Object source = event.getSource();
29823197 // SCRIPT DIALOG
2983
- if (event.getSource() == okbutton)
3198
+ if (source == okbutton)
29843199 {
29853200 textpanel.setVisible(false);
29863201 textpanel.remove(textarea);
....@@ -2992,7 +3207,7 @@
29923207 textarea = null;
29933208 textpanel = null;
29943209 }
2995
- if (event.getSource() == cancelbutton)
3210
+ if (source == cancelbutton)
29963211 {
29973212 textpanel.setVisible(false);
29983213 textpanel.remove(textarea);
....@@ -3004,50 +3219,50 @@
30043219 //applySelf();
30053220 //client.refreshEditWindow();
30063221 //refreshContents();
3007
- if (event.getSource() == nameField)
3222
+ if (source == nameField)
30083223 {
30093224 //System.out.println("ObjEditor " + event);
30103225 applySelf0(true);
30113226 //parent.applySelf();
30123227 objEditor.refreshContents();
3013
- } else if (event.getSource() == resetButton)
3228
+ } else if (source == resetButton)
30143229 {
30153230 CameraPane.fullreset = true;
30163231 copy.Reset(); // ResetMeshes();
30173232 copy.Touch();
30183233 objEditor.refreshContents();
3019
- } else if (event.getSource() == stepItem)
3234
+ } else if (source == stepItem)
30203235 {
30213236 //cameraView.ONESTEP = true;
30223237 Globals.ONESTEP = true;
30233238 cameraView.repaint();
30243239 return;
3025
- } else if (event.getSource() == stepButton)
3240
+ } else if (source == stepButton)
30263241 {
30273242 copy.Step();
30283243 copy.Touch();
30293244 objEditor.refreshContents();
3030
- } else if (event.getSource() == slowerButton)
3245
+ } else if (source == slowerButton)
30313246 {
30323247 copy.Slower();
30333248 copy.Touch();
30343249 objEditor.refreshContents();
3035
- } else if (event.getSource() == fasterButton)
3250
+ } else if (source == fasterButton)
30363251 {
30373252 copy.Faster();
30383253 copy.Touch();
30393254 objEditor.refreshContents();
3040
- } else if (event.getSource() == remarkButton)
3255
+ } else if (source == remarkButton)
30413256 {
30423257 copy.Remark();
30433258 copy.Touch();
30443259 objEditor.refreshContents();
3045
- } else if (event.getSource() == stepAllButton)
3260
+ } else if (source == stepAllButton)
30463261 {
30473262 copy.StepAll();
30483263 copy.Touch();
30493264 objEditor.refreshContents();
3050
- } else if (event.getSource() == resetAllButton)
3265
+ } else if (source == resetAllButton)
30513266 {
30523267 //CameraPane.fullreset = true;
30533268 copy.ResetAll(); // ResetMeshes();
....@@ -3080,53 +3295,75 @@
30803295 // Close();
30813296 // }
30823297 // else
3083
- if (event.getSource() == resetSlidersButton)
3298
+ if (source == resetSlidersButton)
30843299 {
30853300 ResetSliders();
3086
- } else if (event.getSource() == clearMaterialButton)
3301
+ } else if (source == clearMaterialButton)
30873302 {
30883303 ClearMaterial();
3089
- } else if (event.getSource() == createMaterialButton)
3304
+ } else if (source == createMaterialButton)
30903305 {
30913306 CreateMaterial();
3092
- } else if (event.getSource() == clearPanelButton)
3307
+ } else if (source == clearPanelButton)
30933308 {
30943309 copy.ClearUI();
30953310 refreshContents(true);
3096
- } /*
3097
- }
3098
-
3099
- public boolean action(Event event, Object arg)
3100
- {
3101
- */ else if (event.getSource() == closeItem)
3311
+ } else if (source == importGFDItem)
3312
+ {
3313
+ ImportGFD();
3314
+ } else
3315
+ if (source == importVRMLX3DItem)
3316
+ {
3317
+ ImportVRMLX3D();
3318
+ } else
3319
+ if (source == import3DSItem)
3320
+ {
3321
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3322
+ } else
3323
+ if (source == importOBJItem)
3324
+ {
3325
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3326
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3327
+ browser.setVisible(true);
3328
+ String filename = browser.getFile();
3329
+ if (filename != null && filename.length() > 0)
3330
+ {
3331
+ String fullname = browser.getDirectory() + filename;
3332
+ makeSomething(ReadOBJ(fullname), true);
3333
+ }
3334
+ } else
3335
+ if (source == closeItem)
31023336 {
31033337 Close();
31043338 //return true;
3105
- } else if (event.getSource() == loadItem)
3339
+ } else if (source == loadItem)
31063340 {
31073341 load();
31083342 //return true;
3109
- } else if (event.getSource() == saveItem)
3343
+ } else if (source == newItem)
3344
+ {
3345
+ New();
3346
+ } else if (source == saveItem)
31103347 {
31113348 save();
31123349 //return true;
3113
- } else if (event.getSource() == saveAsItem)
3350
+ } else if (source == saveAsItem)
31143351 {
31153352 saveAs();
31163353 //return true;
3117
- } else if (event.getSource() == reexportItem)
3354
+ } else if (source == reexportItem)
31183355 {
31193356 reexport();
31203357 //return true;
3121
- } else if (event.getSource() == exportAsItem)
3358
+ } else if (source == exportAsItem)
31223359 {
31233360 export();
31243361 //return true;
3125
- } else if (event.getSource() == povItem)
3362
+ } else if (source == povItem)
31263363 {
31273364 generatePOV();
31283365 //return true;
3129
- } else if (event.getSource() == zBufferItem)
3366
+ } else if (source == zBufferItem)
31303367 {
31313368 try
31323369 {
....@@ -3148,21 +3385,8 @@
31483385 cameraView.repaint();
31493386 //return true;
31503387 }
3151
- */ else if (event.getSource() == editCameraItem)
3152
- {
3153
- cameraView.ProtectCamera();
3154
- cameraView.repaint();
3155
- return;
3156
- } else if (event.getSource() == revertCameraItem)
3157
- {
3158
- cameraView.RevertCamera();
3159
- cameraView.repaint();
3160
- return;
3161
-// } else if (event.getSource() == textureButton)
3162
-// {
3163
-// return; // true;
3164
- } else // combos...
3165
- if (event.getSource() == texresMenu)
3388
+ */ else // combos...
3389
+ if (source == texresMenu)
31663390 {
31673391 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31683392 copy.texres = texresMenu.getSelectedIndex();
....@@ -3174,12 +3398,272 @@
31743398 }
31753399 }
31763400
3401
+ void New()
3402
+ {
3403
+ while (copy.Size() > 1)
3404
+ {
3405
+ copy.remove(1);
3406
+ }
3407
+
3408
+ ResetModel();
3409
+ objEditor.refreshContents();
3410
+ }
3411
+
3412
+ static public byte[] Compress(Object3D o)
3413
+ {
3414
+ try
3415
+ {
3416
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3417
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3418
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3419
+
3420
+ Object3D parent = o.parent;
3421
+ o.parent = null;
3422
+
3423
+ out.writeObject(o);
3424
+
3425
+ o.parent = parent;
3426
+
3427
+ out.flush();
3428
+
3429
+ zstream.close();
3430
+ out.close();
3431
+
3432
+ return baos.toByteArray();
3433
+ } catch (Exception e)
3434
+ {
3435
+ System.err.println(e);
3436
+ return null;
3437
+ }
3438
+ }
3439
+
3440
+ static public Object Uncompress(byte[] bytes)
3441
+ {
3442
+ System.out.println("#bytes = " + bytes.length);
3443
+ try
3444
+ {
3445
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3446
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3447
+ ObjectInputStream in = new ObjectInputStream(istream);
3448
+ Object obj = in.readObject();
3449
+ in.close();
3450
+
3451
+ return obj;
3452
+ } catch (Exception e)
3453
+ {
3454
+ System.err.println(e);
3455
+ return null;
3456
+ }
3457
+ }
3458
+
3459
+ static public Object clone(Object o)
3460
+ {
3461
+ try
3462
+ {
3463
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3464
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3465
+
3466
+ out.writeObject(o);
3467
+
3468
+ out.flush();
3469
+ out.close();
3470
+
3471
+ byte[] bytes = baos.toByteArray();
3472
+
3473
+ System.out.println("clone = " + bytes.length);
3474
+
3475
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3476
+ ObjectInputStream in = new ObjectInputStream(bais);
3477
+ Object obj = in.readObject();
3478
+ in.close();
3479
+
3480
+ return obj;
3481
+ } catch (Exception e)
3482
+ {
3483
+ System.err.println(e);
3484
+ return null;
3485
+ }
3486
+ }
3487
+
3488
+ cRadio GetCurrentTab()
3489
+ {
3490
+ cRadio ab;
3491
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3492
+ {
3493
+ ab = (cRadio)e.nextElement();
3494
+ if(ab.GetObject() == copy)
3495
+ {
3496
+ return ab;
3497
+ }
3498
+ }
3499
+
3500
+ return null;
3501
+ }
3502
+
3503
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3504
+
3505
+ public void Save()
3506
+ {
3507
+ System.err.println("Save");
3508
+
3509
+ cRadio tab = GetCurrentTab();
3510
+
3511
+ boolean temp = CameraPane.SWITCH;
3512
+ CameraPane.SWITCH = false;
3513
+
3514
+ copy.ExtractBigData(hashtable);
3515
+
3516
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3517
+ tab.graphs[tab.undoindex++] = Compress(copy);
3518
+
3519
+ copy.RestoreBigData(hashtable);
3520
+
3521
+ CameraPane.SWITCH = temp;
3522
+
3523
+ //assert(hashtable.isEmpty());
3524
+
3525
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3526
+ {
3527
+ tab.graphs[i] = null;
3528
+ }
3529
+
3530
+ // test save
3531
+ if (false)
3532
+ {
3533
+ try
3534
+ {
3535
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3536
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3537
+
3538
+ p.writeObject(copy);
3539
+
3540
+ p.flush();
3541
+
3542
+ ostream.close();
3543
+ } catch (Exception e)
3544
+ {
3545
+ e.printStackTrace();
3546
+ }
3547
+ }
3548
+ }
3549
+
3550
+ void CopyChanged(Object3D obj)
3551
+ {
3552
+ boolean temp = CameraPane.SWITCH;
3553
+ CameraPane.SWITCH = false;
3554
+
3555
+ copy.ExtractBigData(hashtable);
3556
+
3557
+ copy.clear();
3558
+
3559
+ for (int i=0; i<obj.Size(); i++)
3560
+ {
3561
+ copy.add(obj.get(i));
3562
+ }
3563
+
3564
+ copy.RestoreBigData(hashtable);
3565
+
3566
+ CameraPane.SWITCH = temp;
3567
+
3568
+ //assert(hashtable.isEmpty());
3569
+
3570
+ copy.Touch();
3571
+
3572
+ ResetModel();
3573
+ copy.HardTouch(); // recompile?
3574
+
3575
+ cRadio ab;
3576
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3577
+ {
3578
+ ab = (cRadio)e.nextElement();
3579
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3580
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3581
+ if (test != null)
3582
+ {
3583
+ test.editWindow = ab.object.editWindow;
3584
+ ab.object = test;
3585
+ }
3586
+ }
3587
+
3588
+ refreshContents();
3589
+ }
3590
+
3591
+ public void Undo()
3592
+ {
3593
+ System.err.println("Undo");
3594
+
3595
+ cRadio tab = GetCurrentTab();
3596
+
3597
+ if (tab.undoindex == 0)
3598
+ {
3599
+ java.awt.Toolkit.getDefaultToolkit().beep();
3600
+ return;
3601
+ }
3602
+
3603
+ if (tab.graphs[tab.undoindex] == null)
3604
+ {
3605
+ Save();
3606
+ tab.undoindex -= 1;
3607
+ }
3608
+
3609
+ tab.undoindex -= 1;
3610
+
3611
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3612
+ }
3613
+
3614
+ public void Redo()
3615
+ {
3616
+ cRadio tab = GetCurrentTab();
3617
+
3618
+ if (tab.graphs[tab.undoindex + 1] == null)
3619
+ {
3620
+ java.awt.Toolkit.getDefaultToolkit().beep();
3621
+ return;
3622
+ }
3623
+
3624
+ tab.undoindex += 1;
3625
+
3626
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3627
+ }
3628
+
3629
+ void ImportGFD()
3630
+ {
3631
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3632
+ browser.show();
3633
+ String filename = browser.getFile();
3634
+ if (filename != null && filename.length() > 0)
3635
+ {
3636
+ String fullname = browser.getDirectory() + filename;
3637
+
3638
+ //Object3D readobj =
3639
+ objEditor.ReadGFD(fullname, objEditor);
3640
+ //makeSomething(readobj);
3641
+ }
3642
+ }
3643
+
3644
+ void ImportVRMLX3D()
3645
+ {
3646
+ if (Grafreed.standAlone)
3647
+ {
3648
+ /**/
3649
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3650
+ browser.show();
3651
+ String filename = browser.getFile();
3652
+ if (filename != null && filename.length() > 0)
3653
+ {
3654
+ String fullname = browser.getDirectory() + filename;
3655
+ LoadVRMLX3D(fullname);
3656
+ }
3657
+ /**/
3658
+ }
3659
+ }
3660
+
31773661 void ToggleAnimation()
31783662 {
31793663 if (!Globals.ANIMATION)
31803664 {
31813665 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3182
- browser.show();
3666
+ browser.setVisible(true);
31833667 String filename = browser.getFile();
31843668 if (filename != null && filename.length() > 0)
31853669 {
....@@ -3189,8 +3673,8 @@
31893673
31903674 Globals.ANIMATION ^= true;
31913675
3192
- GrafreeD.wav.cursor = 0;
3193
- GrafreeD.wav.loop = 0;
3676
+ Grafreed.wav.cursor = 0;
3677
+ Grafreed.wav.loop = 0;
31943678 }
31953679 } else
31963680 {
....@@ -3240,7 +3724,7 @@
32403724 void CreateMaterial()
32413725 {
32423726 //copy.ClearMaterial(); // PATCH
3243
- copy.CreateMaterialS(multiplyToggle.isSelected());
3727
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32443728 if (copy.selection.size() > 0)
32453729 //SetMaterial(copy);
32463730 {
....@@ -3291,7 +3775,7 @@
32913775 assert false;
32923776 }
32933777
3294
- void EditSelection()
3778
+ void EditSelection(boolean newWindow)
32953779 {
32963780 }
32973781
....@@ -3299,11 +3783,11 @@
32993783 {
33003784 copy.ResetBlockLoop(); // temporary problem
33013785
3302
- boolean random = CameraPane.RANDOM;
3303
- CameraPane.RANDOM = false; // parse everything
3786
+ boolean random = CameraPane.SWITCH;
3787
+ CameraPane.SWITCH = false; // parse everything
33043788 copy.ResetDisplayList();
33053789 copy.HardTouch();
3306
- CameraPane.RANDOM = random;
3790
+ CameraPane.SWITCH = random;
33073791 }
33083792
33093793 // public void applySelf()
....@@ -3377,6 +3861,36 @@
33773861 {
33783862 //System.out.println("Propagate = " + propagate);
33793863 copy.UpdateMaterial(anchor, current, propagate);
3864
+
3865
+ if (copy.material != null)
3866
+ {
3867
+ cMaterial mat = copy.material;
3868
+
3869
+ colorField.SetToolTipValue((mat.color));
3870
+ modulationField.SetToolTipValue((mat.modulation));
3871
+ metalnessField.SetToolTipValue((mat.metalness));
3872
+ diffuseField.SetToolTipValue((mat.diffuse));
3873
+ specularField.SetToolTipValue((mat.specular));
3874
+ shininessField.SetToolTipValue((mat.shininess));
3875
+ shiftField.SetToolTipValue((mat.shift));
3876
+ ambientField.SetToolTipValue((mat.ambient));
3877
+ lightareaField.SetToolTipValue((mat.lightarea));
3878
+ diffusenessField.SetToolTipValue((mat.factor));
3879
+ velvetField.SetToolTipValue((mat.velvet));
3880
+ sheenField.SetToolTipValue((mat.sheen));
3881
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3882
+ backlitField.SetToolTipValue((mat.bump));
3883
+ anisoField.SetToolTipValue((mat.aniso));
3884
+ anisoVField.SetToolTipValue((mat.anisoV));
3885
+ cameraField.SetToolTipValue((mat.cameralight));
3886
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3887
+ shadowField.SetToolTipValue((mat.shadow));
3888
+ textureField.SetToolTipValue((mat.texture));
3889
+ opacityField.SetToolTipValue((mat.opacity));
3890
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3891
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3892
+ }
3893
+
33803894 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33813895 {
33823896 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3421,6 +3935,7 @@
34213935 || e.getSource() == apertureField
34223936 || e.getSource() == shadowblurField)
34233937 {
3938
+ new Exception().printStackTrace();
34243939 System.exit(0);
34253940 cameraView.options1[0] = (float) focusField.getFloat() * 10;
34263941 cameraView.options1[1] = (float) apertureField.getFloat() / 1000;
....@@ -3491,7 +4006,7 @@
34914006 }
34924007
34934008 if (normalpushField != null)
3494
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4009
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
34954010 }
34964011
34974012 void SnapObject()
....@@ -3755,6 +4270,8 @@
37554270
37564271 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37574272 {
4273
+ if (Globals.SAVEONMAKE) // && resetmodel)
4274
+ Save();
37584275 //Tween.set(thing, 0).target(1).start(tweenManager);
37594276 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37604277 // if (thing instanceof GenericJointDemo)
....@@ -3841,6 +4358,12 @@
38414358 {
38424359 ResetModel();
38434360 Select(thing.GetTreePath(), true, false); // unselect... false);
4361
+
4362
+ if (thing.Size() == 0)
4363
+ {
4364
+ //EditSelection(false);
4365
+ }
4366
+
38444367 refreshContents();
38454368 }
38464369
....@@ -3958,6 +4481,7 @@
39584481 }
39594482 }
39604483 }
4484
+
39614485 LoadGFDThread loadGFDThread;
39624486
39634487 void ReadGFD(String fullname, iCallBack cb)
....@@ -3977,8 +4501,10 @@
39774501
39784502 try
39794503 {
4504
+ // Try compressed version first.
39804505 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3981
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4506
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4507
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39824508
39834509 readobj = (Object3D) p.readObject();
39844510 istream.close();
....@@ -3986,7 +4512,20 @@
39864512 readobj.ResetDisplayList();
39874513 } catch (Exception e)
39884514 {
3989
- e.printStackTrace();
4515
+ //e.printStackTrace();
4516
+ try
4517
+ {
4518
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4519
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4520
+
4521
+ readobj = (Object3D) p.readObject();
4522
+ istream.close();
4523
+
4524
+ readobj.ResetDisplayList();
4525
+ } catch (Exception e2)
4526
+ {
4527
+ e2.printStackTrace();
4528
+ }
39904529 }
39914530 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
39924531 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4032,6 +4571,12 @@
40324571
40334572 void LoadIt(Object obj)
40344573 {
4574
+ if (obj == null)
4575
+ {
4576
+ // Invalid file
4577
+ return;
4578
+ }
4579
+
40354580 System.out.println("Loaded " + obj);
40364581 //new Exception().printStackTrace();
40374582 Object3D readobj = (Object3D) obj;
....@@ -4041,6 +4586,8 @@
40414586
40424587 if (readobj != null)
40434588 {
4589
+ if (Globals.SAVEONMAKE)
4590
+ Save();
40444591 try
40454592 {
40464593 //readobj.deepCopySelf(copy);
....@@ -4103,7 +4650,7 @@
41034650
41044651 void load() // throws ClassNotFoundException
41054652 {
4106
- if (GrafreeD.standAlone)
4653
+ if (Grafreed.standAlone)
41074654 {
41084655 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41094656 browser.show();
....@@ -4190,11 +4737,13 @@
41904737 try
41914738 {
41924739 FileOutputStream ostream = new FileOutputStream(lastname);
4193
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4740
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4741
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
41944742
41954743 p.writeObject(copy);
41964744 p.flush();
41974745
4746
+ zstream.close();
41984747 ostream.close();
41994748
42004749 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4204,11 +4753,12 @@
42044753 {
42054754 }
42064755 }
4756
+
42074757 String lastname;
42084758
42094759 void saveAs()
42104760 {
4211
- if (GrafreeD.standAlone)
4761
+ if (Grafreed.standAlone)
42124762 {
42134763 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42144764 browser.setVisible(true);
....@@ -4313,13 +4863,13 @@
43134863 try
43144864 {
43154865 FileOutputStream ostream = new FileOutputStream(filename);
4316
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4317
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4866
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4867
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43184868
43194869 Object3D objectparent = obj.parent;
43204870 obj.parent = null;
43214871
4322
- Object3D object = (Object3D) GrafreeD.clone(obj);
4872
+ Object3D object = (Object3D) Grafreed.clone(obj);
43234873
43244874 obj.parent = objectparent;
43254875
....@@ -4331,8 +4881,8 @@
43314881 p.writeObject(object);
43324882 p.flush();
43334883
4884
+ zstream.close();
43344885 ostream.close();
4335
- // zstream.close();
43364886
43374887 // group.selection.get(0).parent = parent;
43384888 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4353,7 +4903,7 @@
43534903 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43544904 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43554905 copy.generatePOV(buffer);
4356
- if (GrafreeD.standAlone)
4906
+ if (Grafreed.standAlone)
43574907 {
43584908 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43594909 browser.show();
....@@ -4379,7 +4929,8 @@
43794929 Object3D client;
43804930 Object3D copy;
43814931 MenuBar menuBar;
4382
- Menu windowMenu;
4932
+ Menu fileMenu;
4933
+ MenuItem newItem;
43834934 MenuItem loadItem;
43844935 MenuItem saveItem;
43854936 MenuItem saveAsItem;
....@@ -4387,13 +4938,11 @@
43874938 MenuItem reexportItem;
43884939 MenuItem povItem;
43894940 MenuItem closeItem;
4390
- Menu cameraMenu;
4941
+
43914942 CheckboxMenuItem zBufferItem;
43924943 //MenuItem normalLensItem;
4393
- MenuItem editCameraItem;
4394
- MenuItem revertCameraItem;
4395
- CheckboxMenuItem toggleLiveItem;
43964944 MenuItem stepItem;
4945
+ CheckboxMenuItem toggleLiveItem;
43974946 CheckboxMenuItem toggleFullScreenItem;
43984947 CheckboxMenuItem toggleTimelineItem;
43994948 CheckboxMenuItem toggleRenderItem;
....@@ -4402,25 +4951,38 @@
44024951 CheckboxMenuItem toggleFootContactItem;
44034952 CheckboxMenuItem toggleDLItem;
44044953 CheckboxMenuItem toggleTextureItem;
4405
- CheckboxMenuItem toggleRandomItem;
4954
+ CheckboxMenuItem toggleSwitchItem;
44064955 CheckboxMenuItem toggleRootItem;
44074956 CheckboxMenuItem animationItem;
44084957 CheckboxMenuItem toggleHandleItem;
44094958 CheckboxMenuItem togglePaintItem;
44104959 JSplitPane mainPanel;
44114960 JScrollPane scrollpane;
4961
+
44124962 JPanel toolbarPanel;
4413
- JPanel treePanel;
4963
+
4964
+ cGridBag treePanel;
4965
+
44144966 JPanel radioPanel;
44154967 ButtonGroup buttonGroup;
4416
- cGridBag ctrlPanel;
4968
+
4969
+ cGridBag toolboxPanel;
44174970 cGridBag materialPanel;
4971
+ cGridBag ctrlPanel;
4972
+
44184973 JScrollPane infoPanel;
4974
+
44194975 cGridBag optionsPanel;
4976
+
44204977 JTabbedPane objectPanel;
4978
+ boolean materialFlushed;
4979
+ Object3D latestObject;
4980
+
44214981 cGridBag XYZPanel;
4982
+
44224983 JSplitPane gridPanel;
44234984 JSplitPane bigPanel;
4985
+
44244986 cGridBag bigThree;
44254987 cGridBag scenePanel;
44264988 cGridBag centralPanel;
....@@ -4535,8 +5097,13 @@
45355097 cNumberSlider fogField;
45365098 JLabel opacityPowerLabel;
45375099 cNumberSlider opacityPowerField;
4538
- JTree jTree;
5100
+ cTree jTree;
45395101 //ObjectUI parent;
45405102
45415103 cNumberSlider normalpushField;
5104
+
5105
+ private MenuItem importGFDItem;
5106
+ private MenuItem importVRMLX3DItem;
5107
+ private MenuItem import3DSItem;
5108
+ private MenuItem importOBJItem;
45425109 }