Normand Briere
2019-07-01 9079880942d022ee32fd3a543843e132e52deb1a
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.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -35,6 +39,67 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
47
+ try
48
+ {
49
+ ImageIcon icon = GetIcon(name);
50
+ return new cButton(icon, border);
51
+ }
52
+ catch (Exception e)
53
+ {
54
+ return new cButton(name, border);
55
+ }
56
+ }
57
+
58
+ cToggleButton GetToggleButton(String name, boolean border)
59
+ {
60
+ try
61
+ {
62
+ ImageIcon icon = GetIcon(name);
63
+ return new cToggleButton(icon, border);
64
+ }
65
+ catch (Exception e)
66
+ {
67
+ return new cToggleButton(name, border);
68
+ }
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ try
74
+ {
75
+ ImageIcon icon = GetIcon(name);
76
+ return new cCheckBox(icon, border);
77
+ }
78
+ catch (Exception e)
79
+ {
80
+ return new cCheckBox(name, border);
81
+ }
82
+ }
83
+
84
+ private ImageIcon GetIcon(String name) throws IOException
85
+ {
86
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
+
88
+ if (image.getWidth() != 24 && image.getHeight() != 24)
89
+ {
90
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
+ Graphics2D g = resized.createGraphics();
92
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
+ g.dispose();
96
+
97
+ image = resized;
98
+ }
99
+
100
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
+ return icon;
102
+ }
38103
39104 // SCRIPT
40105
....@@ -143,7 +208,9 @@
143208 //nameField.removeActionListener(this);
144209 // objEditor.ctrlPanel.remove(nameField);
145210
146
- if (!GroupEditor.allparams)
211
+ objEditor.ctrlPanel.remove(namePanel);
212
+
213
+ if (!allparams)
147214 return;
148215
149216 // objEditor.ctrlPanel.remove(liveCB);
....@@ -165,9 +232,9 @@
165232 // objEditor.ctrlPanel.remove(fasterButton);
166233 // objEditor.ctrlPanel.remove(remarkButton);
167234
168
- objEditor.ctrlPanel.remove(namePanel);
169235 objEditor.ctrlPanel.remove(setupPanel);
170
- objEditor.ctrlPanel.remove(commandsPanel);
236
+ objEditor.ctrlPanel.remove(setupPanel2);
237
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
171238 objEditor.ctrlPanel.remove(pushPanel);
172239 //objEditor.ctrlPanel.remove(fillPanel);
173240
....@@ -242,6 +309,7 @@
242309 //localCopy.parent = null;
243310
244311 frame = new JFrame();
312
+ frame.setUndecorated(false);
245313 objEditor = this;
246314 this.callee = callee;
247315
....@@ -272,28 +340,49 @@
272340 return frame.action(event, obj);
273341 }
274342
343
+ // Cannot work without static
344
+ static boolean allparams = true;
345
+
346
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347
+
275348 void SetupMenu()
276349 {
277350 frame.setMenuBar(menuBar = new MenuBar());
278
- menuBar.add(windowMenu = new Menu("File"));
279
- windowMenu.add(loadItem = new MenuItem("Load..."));
280
- windowMenu.add("-");
281
- windowMenu.add(saveItem = new MenuItem("Save"));
282
- windowMenu.add(saveAsItem = new MenuItem("Save As..."));
351
+ menuBar.add(fileMenu = new Menu("File"));
352
+ fileMenu.add(newItem = new MenuItem("New"));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
354
+
355
+ //oe.menuBar.add(menu = new Menu("Include"));
356
+ Menu menu = new Menu("Import");
357
+ importOBJItem = menu.add(new MenuItem("OBJ file..."));
358
+ importOBJItem.addActionListener(this);
359
+ import3DSItem = menu.add(new MenuItem("3DS file..."));
360
+ import3DSItem.addActionListener(this);
361
+ importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
362
+ importVRMLX3DItem.addActionListener(this);
363
+ menu.add("-");
364
+ importGFDItem = menu.add(new MenuItem("Grafreed file..."));
365
+ importGFDItem.addActionListener(this);
366
+ fileMenu.add(menu);
367
+ fileMenu.add("-");
368
+
369
+ fileMenu.add(saveItem = new MenuItem("Save"));
370
+ fileMenu.add(saveAsItem = new MenuItem("Save As..."));
283371 //windowMenu.add(povItem = new MenuItem("Emit POV-Ray..."));
284
- windowMenu.add("-");
285
- windowMenu.add(exportAsItem = new MenuItem("Export Selection..."));
286
- windowMenu.add(reexportItem = new MenuItem("Re-export"));
287
- windowMenu.add("-");
372
+ fileMenu.add("-");
373
+ fileMenu.add(exportAsItem = new MenuItem("Export Selection..."));
374
+ fileMenu.add(reexportItem = new MenuItem("Re-export"));
375
+ fileMenu.add("-");
288376 if (client.parent != null)
289377 {
290
- windowMenu.add(closeItem = new MenuItem("Close"));
378
+ fileMenu.add(closeItem = new MenuItem("Close"));
291379 } else
292380 {
293
- windowMenu.add(closeItem = new MenuItem("Exit"));
381
+ fileMenu.add(closeItem = new MenuItem("Exit"));
294382 }
295383
296
- loadItem.addActionListener(this);
384
+ newItem.addActionListener(this);
385
+ openItem.addActionListener(this);
297386 saveItem.addActionListener(this);
298387 saveAsItem.addActionListener(this);
299388 exportAsItem.addActionListener(this);
....@@ -301,81 +390,66 @@
301390 //povItem.addActionListener(this);
302391 closeItem.addActionListener(this);
303392
304
- menuBar.add(cameraMenu = new Menu("View"));
305
- //cameraMenu.add(zBufferItem = new CheckboxMenuItem("Z Buffer"));
306
- //zBufferItem.addActionListener(this);
307
- //cameraMenu.add(normalLensItem = new MenuItem("Normal Lens"));
308
- //normalLensItem.addActionListener(this);
309
- cameraMenu.add(revertCameraItem = new MenuItem("Revert Camera"));
310
- revertCameraItem.addActionListener(this);
311
- cameraMenu.add(toggleTimelineItem = new CheckboxMenuItem("Timeline"));
312
- toggleTimelineItem.addItemListener(this);
313
- cameraMenu.add(toggleFullScreenItem = new CheckboxMenuItem("Full Screen"));
314
- toggleFullScreenItem.addItemListener(this);
315
- toggleFullScreenItem.setState(CameraPane.FULLSCREEN);
316
- cameraMenu.add("-");
317
- cameraMenu.add(toggleTextureItem = new CheckboxMenuItem("Texture"));
318
- toggleTextureItem.addItemListener(this);
319
- toggleTextureItem.setState(CameraPane.textureon);
320
- cameraMenu.add(toggleLiveItem = new CheckboxMenuItem("Live"));
321
- toggleLiveItem.addItemListener(this);
322
- toggleLiveItem.setState(Globals.isLIVE());
323
- cameraMenu.add(stepItem = new MenuItem("Step"));
324
- stepItem.addActionListener(this);
325
-// cameraMenu.add(toggleDLItem = new CheckboxMenuItem("Display List"));
326
-// toggleDLItem.addItemListener(this);
327
-// toggleDLItem.setState(false);
328
- cameraMenu.add(toggleRenderItem = new CheckboxMenuItem("Render"));
329
- toggleRenderItem.addItemListener(this);
330
- toggleRenderItem.setState(!CameraPane.frozen);
331
- cameraMenu.add(toggleDebugItem = new CheckboxMenuItem("Debug"));
332
- toggleDebugItem.addItemListener(this);
333
- toggleDebugItem.setState(CameraPane.DEBUG);
334
- cameraMenu.add(toggleFrustumItem = new CheckboxMenuItem("Frustum"));
335
- toggleFrustumItem.addItemListener(this);
336
- toggleFrustumItem.setState(CameraPane.FRUSTUM);
337
- cameraMenu.add(toggleFootContactItem = new CheckboxMenuItem("Foot contact"));
338
- toggleFootContactItem.addItemListener(this);
339
- toggleFootContactItem.setState(CameraPane.FOOTCONTACT);
340
- cameraMenu.add(toggleRandomItem = new CheckboxMenuItem("Random"));
341
- toggleRandomItem.addItemListener(this);
342
- toggleRandomItem.setState(CameraPane.RANDOM);
343
- cameraMenu.add(toggleHandleItem = new CheckboxMenuItem("Handles"));
344
- toggleHandleItem.addItemListener(this);
345
- toggleHandleItem.setState(CameraPane.HANDLES);
346
- cameraMenu.add(togglePaintItem = new CheckboxMenuItem("Paint mode"));
347
- togglePaintItem.addItemListener(this);
348
- togglePaintItem.setState(CameraPane.PAINTMODE);
349
-// cameraMenu.add(toggleRootItem = new CheckboxMenuItem("Alternate Root"));
350
-// toggleRootItem.addItemListener(this);
351
-// toggleRootItem.setState(false);
352
-// cameraMenu.add(animationItem = new CheckboxMenuItem("Animation"));
353
-// animationItem.addItemListener(this);
354
-// animationItem.setState(CameraPane.ANIMATION);
355
- cameraMenu.add("-");
356
- cameraMenu.add(editCameraItem = new MenuItem("Freeze Camera"));
357
- editCameraItem.addActionListener(this);
358
-
359393 objectPanel = new JTabbedPane();
394
+
395
+ ChangeListener changeListener = new ChangeListener()
396
+ {
397
+ public void stateChanged(ChangeEvent changeEvent)
398
+ {
399
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
400
+// {
401
+// if (latestObject != null)
402
+// {
403
+// refreshContents(true);
404
+// SetMaterial(latestObject);
405
+// }
406
+//
407
+// materialFlushed = true;
408
+// }
409
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
410
+// {
411
+// if (listUI.size() == 0)
412
+// EditSelection(false);
413
+// }
414
+
415
+ refreshContents(false); // To refresh Info tab
416
+ }
417
+ };
418
+ objectPanel.addChangeListener(changeListener);
419
+
360420 toolbarPanel = new JPanel();
361421 toolbarPanel.setName("Toolbar");
362
- treePanel = new JPanel();
422
+ treePanel = new cGridBag();
363423 treePanel.setName("Tree");
424
+
425
+ editPanel = new cGridBag().setVertical(true);
426
+ editPanel.setName("Edit");
427
+
364428 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
365
- ctrlPanel.setName("Edit");
429
+
430
+ editCommandsPanel = new cGridBag();
431
+ editPanel.add(editCommandsPanel);
432
+ editPanel.add(ctrlPanel);
433
+
434
+ toolboxPanel = new cGridBag().setVertical(false);
435
+ toolboxPanel.setName("Toolbox");
436
+
366437 materialPanel = new cGridBag().setVertical(true);
367438 materialPanel.setName("Material");
439
+
368440 /*JTextPane*/
369441 infoarea = createTextPane();
442
+ doc = infoarea.getStyledDocument();
443
+
370444 infoarea.setEditable(true);
371445 SetText();
372446 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
373447 // infoarea.setOpaque(false);
374448 // //infoarea.setForeground(textcolor);
375
- infoarea.setLineWrap(true);
376
- infoarea.setWrapStyleWord(true);
449
+// TEXTAREA infoarea.setLineWrap(true);
450
+// TEXTAREA infoarea.setWrapStyleWord(true);
377451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
378
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ //infoPanel.setPreferredSize(new Dimension(50, 200));
379453 infoPanel.setName("Info");
380454 //infoPanel.setLayout(new BorderLayout());
381455 //infoPanel.add(createTextPane());
....@@ -384,14 +458,21 @@
384458 mainPanel.setName("Main");
385459 mainPanel.setContinuousLayout(true);
386460 mainPanel.setOneTouchExpandable(true);
387
- mainPanel.setDividerLocation(1.0);
388461 mainPanel.setDividerSize(9);
389
- mainPanel.setResizeWeight(0);
390
-
462
+ mainPanel.setDividerLocation(0.5); //1.0);
463
+ mainPanel.setResizeWeight(0.5);
464
+
465
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+ divider.setDividerSize(15);
468
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469
+
470
+ mainPanel.setUI(new BasicSplitPaneUI());
471
+
391472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
392473 //mainPanel.setLayout(new GridBagLayout());
393474 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
394
- treePanel.setLayout(new GridBagLayout());
475
+// treePanel.setLayout(new GridBagLayout());
395476 //ctrlPanel.setLayout(new GridBagLayout());
396477 //materialPanel.setLayout(new GridBagLayout());
397478
....@@ -432,7 +513,7 @@
432513 static String newline = "\n";
433514 protected static final String buttonString = "JButton";
434515 StyledDocument doc;
435
- JTextArea infoarea;
516
+ JTextPane infoarea;
436517
437518 void ClearInfo()
438519 {
....@@ -455,10 +536,10 @@
455536 e.printStackTrace();
456537 }
457538
458
- String selection = infoarea.getText();
459
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
460
- java.awt.datatransfer.Clipboard clipboard =
461
- Toolkit.getDefaultToolkit().getSystemClipboard();
539
+// String selection = infoarea.getText();
540
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
541
+// java.awt.datatransfer.Clipboard clipboard =
542
+// Toolkit.getDefaultToolkit().getSystemClipboard();
462543 //clipboard.setContents(data, data);
463544 }
464545
....@@ -481,13 +562,13 @@
481562 //SendInfo("Name:", "bold");
482563 if (sel.GetTextures() != null || debug)
483564 {
484
- si.SendInfo(sel.toString(), "bold");
565
+ si.SendInfo(sel.toString() + (Globals.ADVANCED?"":" " + System.identityHashCode(sel)), "bold");
485566 //SendInfo("#children virtual = " + sel.size() + "; real = " + sel.Size() + newline, "regular");
486567 if (sel.Size() > 0)
487568 {
488569 si.SendInfo("#children = " + sel.Size(), "regular");
489570 }
490
- si.SendInfo((debug ? " Parent: " : " ") + sel.parent, "regular");
571
+ si.SendInfo((debug ? " Parent: " : " ") + sel.parent + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.parent)), "regular");
491572 if (debug)
492573 {
493574 try
....@@ -499,7 +580,10 @@
499580 }
500581
501582 if (full)
502
- si.SendInfo(" BBox: " + minima + " - " + maxima, "regular");
583
+ {
584
+ si.SendInfo(" BBox min: " + minima, "regular");
585
+ si.SendInfo(" BBox max: " + maxima, "regular");
586
+ }
503587
504588 if (sel.bRep != null)
505589 {
....@@ -526,7 +610,7 @@
526610 }
527611 if (sel.support != null)
528612 {
529
- si.SendInfo(" support: " + sel.support, "regular");
613
+ si.SendInfo(" support: " + sel.support + (Globals.ADVANCED?"":" " + System.identityHashCode(sel.support)), "regular");
530614 }
531615 if (sel.scriptnode != null)
532616 {
....@@ -597,6 +681,9 @@
597681 {
598682 CameraPane.pointflow = (PointFlow) sel;
599683 }
684
+
685
+ si.SendInfo("_____________________", "regular");
686
+ si.SendInfo("", "regular");
600687 }
601688 }
602689
....@@ -612,68 +699,169 @@
612699 }
613700 }
614701
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704
+
705
+ Rectangle keeprect;
706
+ cRadio radio;
707
+
708
+cButton keepButton;
709
+ cButton twoButton; // Full 3D
710
+ cButton sixButton;
711
+ cButton threeButton;
712
+ cButton sevenButton;
713
+ cButton fourButton; // full panel
714
+ cButton oneButton; // full XYZ
715
+ //cButton currentLayout;
716
+
717
+ boolean maximized;
718
+
719
+ cButton fullscreenLayout;
720
+
721
+ void Minimize()
722
+ {
723
+ frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
725
+ }
726
+
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
730
+ void Maximize()
731
+ {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
737
+ if (maximized)
738
+ {
739
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
740
+ }
741
+ else
742
+ {
743
+ keeprect = frame.getBounds();
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
747
+// frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
749
+ }
750
+
751
+ maximized ^= true;
752
+
753
+ frame.validate();
754
+ }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
759
+
615760 void ToggleFullScreen()
616761 {
617
- if (CameraPane.FULLSCREEN)
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
764
+ cameraView.ToggleFullScreen();
765
+
766
+ if (!CameraPane.FULLSCREEN)
618767 {
619
- frame.getContentPane().remove(/*"Center",*/bigThree);
620
- framePanel.add(bigThree);
621
- frame.getContentPane().add(/*"Center",*/framePanel);
768
+ device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
774
+ //frame.setVisible(false);
775
+// frame.removeNotify();
776
+// frame.setUndecorated(false);
777
+// frame.addNotify();
778
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
779
+
780
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
781
+// X framePanel.add(bigThree);
782
+// X frame.getContentPane().add(/*"Center",*/framePanel);
783
+ framePanel.setDividerLocation(46);
784
+
785
+ //frame.setVisible(true);
786
+ radio.layout = keepButton;
787
+ //theFrame = null;
788
+ keepButton = null;
789
+ radio.layout.doClick();
790
+
622791 } else
623792 {
624
- frame.getContentPane().remove(/*"Center",*/framePanel);
625
- framePanel.remove(bigThree);
626
- frame.getContentPane().add(/*"Center",*/bigThree);
793
+ keepButton = radio.layout;
794
+ //keeprect = frame.getBounds();
795
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
796
+// frame.getToolkit().getScreenSize().height);
797
+ //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
801
+ device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
804
+// frame.removeNotify();
805
+// frame.setUndecorated(true);
806
+// frame.addNotify();
807
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
808
+// X framePanel.remove(bigThree);
809
+// X frame.getContentPane().add(/*"Center",*/bigThree);
810
+ framePanel.setDividerLocation(0);
811
+
812
+ radio.layout = fullscreenLayout;
813
+ radio.layout.doClick();
814
+ //frame.setVisible(true);
627815 }
628
- cameraView.ToggleFullScreen();
816
+ frame.validate();
629817 }
630818
631
- private JTextArea createTextPane()
819
+ private JTextPane createTextPane()
632820 {
633
- String[] initString =
634
- {
635
- "This is an editable JTextPane, ", //regular
636
- "another ", //italic
637
- "styled ", //bold
638
- "text ", //small
639
- "component, ", //large
640
- "which supports embedded components..." + newline,//regular
641
- " " + newline, //button
642
- "...and embedded icons..." + newline, //regular
643
- " ", //icon
644
- newline + "JTextPane is a subclass of JEditorPane that "
645
- + "uses a StyledEditorKit and StyledDocument, and provides "
646
- + "cover methods for interacting with those objects."
647
- };
821
+// TEXTAREA String[] initString =
822
+// {
823
+// "This is an editable JTextPane, ", //regular
824
+// "another ", //italic
825
+// "styled ", //bold
826
+// "text ", //small
827
+// "component, ", //large
828
+// "which supports embedded components..." + newline,//regular
829
+// " " + newline, //button
830
+// "...and embedded icons..." + newline, //regular
831
+// " ", //icon
832
+// newline + "JTextPane is a subclass of JEditorPane that "
833
+// + "uses a StyledEditorKit and StyledDocument, and provides "
834
+// + "cover methods for interacting with those objects."
835
+// };
836
+//
837
+// String[] initStyles =
838
+// {
839
+// "regular", "italic", "bold", "small", "large",
840
+// "regular", "button", "regular", "icon",
841
+// "regular"
842
+// };
843
+//
844
+// JTextPane textPane = new JTextPane();
845
+// textPane.setEditable(true);
846
+// /*StyledDocument*/ doc = textPane.getStyledDocument();
847
+// addStylesToDocument(doc);
848
+//
849
+// try
850
+// {
851
+// for (int j = 0; j < 2; j++)
852
+// {
853
+// for (int i = 0; i < initString.length; i++)
854
+// {
855
+// doc.insertString(doc.getLength(), initString[i],
856
+// doc.getStyle(initStyles[i]));
857
+// }
858
+// }
859
+// } catch (BadLocationException ble)
860
+// {
861
+// System.err.println("Couldn't insert initial text into text pane.");
862
+// }
648863
649
- String[] initStyles =
650
- {
651
- "regular", "italic", "bold", "small", "large",
652
- "regular", "button", "regular", "icon",
653
- "regular"
654
- };
655
-
656
- JTextPane textPane = new JTextPane();
657
- textPane.setEditable(true);
658
- /*StyledDocument*/ doc = textPane.getStyledDocument();
659
- addStylesToDocument(doc);
660
-
661
- try
662
- {
663
- for (int j = 0; j < 2; j++)
664
- {
665
- for (int i = 0; i < initString.length; i++)
666
- {
667
- doc.insertString(doc.getLength(), initString[i],
668
- doc.getStyle(initStyles[i]));
669
- }
670
- }
671
- } catch (BadLocationException ble)
672
- {
673
- System.err.println("Couldn't insert initial text into text pane.");
674
- }
675
-
676
- return new JTextArea(); // textPane;
864
+ return new JTextPane(); // textPane;
677865 }
678866
679867 protected void addStylesToDocument(StyledDocument doc)
....@@ -726,7 +914,7 @@
726914 protected static ImageIcon createImageIcon(String path,
727915 String description)
728916 {
729
- java.net.URL imgURL = GrafreeD.class.getResource(path);
917
+ java.net.URL imgURL = Grafreed.class.getResource(path);
730918 if (imgURL != null)
731919 {
732920 return new ImageIcon(imgURL, description);
....@@ -758,6 +946,7 @@
758946 // NumberSlider vDivsField;
759947 // JCheckBox endcaps;
760948 JCheckBox liveCB;
949
+ JCheckBox selectCB;
761950 JCheckBox hideCB;
762951 JCheckBox link2masterCB;
763952 JCheckBox markCB;
....@@ -765,7 +954,12 @@
765954 JCheckBox speedupCB;
766955 JCheckBox rewindCB;
767956 JCheckBox flipVCB;
957
+
958
+ cCheckBox toggleTextureCB;
959
+ cCheckBox toggleSwitchCB;
960
+
768961 JComboBox texresMenu;
962
+
769963 JButton resetButton;
770964 JButton stepButton;
771965 JButton stepAllButton;
....@@ -774,9 +968,13 @@
774968 JButton fasterButton;
775969 JButton remarkButton;
776970
971
+ cGridBag editPanel;
972
+ cGridBag editCommandsPanel;
973
+
777974 cGridBag namePanel;
778975 cGridBag setupPanel;
779
- cGridBag commandsPanel;
976
+ cGridBag setupPanel2;
977
+ cGridBag objectCommandsPanel;
780978 cGridBag pushPanel;
781979 cGridBag fillPanel;
782980
....@@ -943,52 +1141,72 @@
9431141
9441142 void SetupUI2(ObjEditor oe)
9451143 {
946
-// oe.aConstraints.weightx = 0;
947
-// oe.aConstraints.weighty = 0;
948
-// oe.aConstraints.gridx = 0;
949
-// oe.aConstraints.gridy = 0;
9501144 //SetupName(oe);
9511145
9521146 namePanel = new cGridBag();
9531147
9541148 nameField = AddText(namePanel, copy.GetName());
955
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9561150 oe.ctrlPanel.add(namePanel);
9571151
9581152 oe.ctrlPanel.Return();
9591153
960
- if (!GroupEditor.allparams)
1154
+ if (!allparams)
9611155 return;
9621156
9631157 setupPanel = new cGridBag().setVertical(false);
9641158
9651159 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
966
- link2masterCB = AddCheckBox(setupPanel, "Supp", copy.link2master);
967
- hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1160
+ liveCB.setToolTipText("Animate object");
1161
+ selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
+ selectCB.setToolTipText("Make object selectable");
9681163 // Return();
1164
+ hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
1165
+ hideCB.setToolTipText("Hide object");
9691166 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
970
- rewindCB = AddCheckBox(setupPanel, "Rew", copy.rewind);
971
- randomCB = AddCheckBox(setupPanel, "Rand", copy.random);
1167
+ markCB.setToolTipText("As animation target transform");
1168
+
1169
+ setupPanel2 = new cGridBag().setVertical(false);
1170
+
1171
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
1172
+ rewindCB.setToolTipText("Rewind animation");
1173
+
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1175
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9721176
1177
+ if (Globals.ADVANCED)
1178
+ {
1179
+ link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1180
+ link2masterCB.setToolTipText("Attach to support");
1181
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
1182
+ speedupCB.setToolTipText("Option motion capture");
1183
+ }
1184
+
9731185 oe.ctrlPanel.add(setupPanel);
9741186 oe.ctrlPanel.Return();
1187
+ oe.ctrlPanel.add(setupPanel2);
1188
+ oe.ctrlPanel.Return();
9751189
976
- commandsPanel = new cGridBag().setVertical(false);
1190
+ objectCommandsPanel = new cGridBag().setVertical(false);
9771191
978
- resetButton = AddButton(commandsPanel, "Reset");
979
- stepButton = AddButton(commandsPanel, "Step");
1192
+ resetButton = AddButton(objectCommandsPanel, "Reset");
1193
+ resetButton.setToolTipText("Jump to frame zero");
1194
+ stepButton = AddButton(objectCommandsPanel, "Step");
1195
+ stepButton.setToolTipText("Step one frame");
9801196 // resetAllButton = AddButton(oe, "Reset All");
9811197 // stepAllButton = AddButton(oe, "Step All");
982
- speedupCB = AddCheckBox(commandsPanel, "Speed", copy.speedup);
9831198 // Return();
984
- slowerButton = AddButton(commandsPanel, "Slow");
985
- fasterButton = AddButton(commandsPanel, "Fast");
986
- remarkButton = AddButton(commandsPanel, "Remark");
1199
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
1200
+ slowerButton.setToolTipText("Decrease animation speed");
1201
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
1202
+ fasterButton.setToolTipText("Increase animation speed");
1203
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
1204
+ remarkButton.setToolTipText("Set the current transform as the target");
9871205
988
- oe.ctrlPanel.add(commandsPanel);
1206
+ oe.ctrlPanel.add(objectCommandsPanel);
9891207 oe.ctrlPanel.Return();
9901208
991
- pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);
1209
+ pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
9921210 normalpushField = (cNumberSlider)pushPanel.getComponent(1);
9931211 //Return();
9941212
....@@ -1191,8 +1409,11 @@
11911409 //worldPanel.setName("World");
11921410 centralPanel = new cGridBag();
11931411 centralPanel.preferredWidth = 20;
1194
- timelinePanel = new JPanel(new BorderLayout());
1195
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1412
+
1413
+ if (Globals.ADVANCED)
1414
+ {
1415
+ timelinePanel = new JPanel(new BorderLayout());
1416
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11961417
11971418 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11981419 cameraPanel.setContinuousLayout(true);
....@@ -1201,7 +1422,10 @@
12011422 // cameraPanel.setDividerSize(9);
12021423 cameraPanel.setResizeWeight(1.0);
12031424
1425
+ }
1426
+
12041427 centralPanel.add(cameraView);
1428
+ centralPanel.setFocusable(true);
12051429 //frame.setJMenuBar(timelineMenubar);
12061430 //centralPanel.add(timelinePanel);
12071431
....@@ -1268,8 +1492,12 @@
12681492 // north.setName("Edit");
12691493 // north.add(ctrlPanel, BorderLayout.NORTH);
12701494 // objectPanel.add(north);
1271
- objectPanel.add(ctrlPanel);
1272
- objectPanel.add(infoPanel);
1495
+ objectPanel.add(editPanel);
1496
+
1497
+ if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
1500
+ objectPanel.add(toolboxPanel);
12731501
12741502 /*
12751503 aConstraints.gridx = 0;
....@@ -1278,7 +1506,7 @@
12781506 aConstraints.gridy += 1;
12791507 aConstraints.gridwidth = 1;
12801508 mainPanel.add(objectPanel, aConstraints);
1281
- */
1509
+ */
12821510
12831511 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12841512 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1290,14 +1518,12 @@
12901518 scrollpane.addMouseWheelListener(this); // Default not fast enough
12911519
12921520 /*JTabbedPane*/ scenePanel = new cGridBag();
1293
- scenePanel.preferredWidth = 7;
1521
+ scenePanel.preferredWidth = 6;
12941522
12951523 JTabbedPane tabbedPane = new JTabbedPane();
12961524 tabbedPane.add(scrollpane);
12971525
1298
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1299
-
1300
- optionsPanel = new cGridBag().setVertical(true);
1526
+ optionsPanel = new cGridBag().setVertical(false);
13011527
13021528 optionsPanel.setName("Options");
13031529
....@@ -1305,6 +1531,8 @@
13051531
13061532 tabbedPane.add(optionsPanel);
13071533
1534
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1535
+
13081536 scenePanel.add(tabbedPane);
13091537
13101538 /*
....@@ -1377,9 +1605,9 @@
13771605 // aConstraints.gridheight = 1;
13781606
13791607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1380
- framePanel.setContinuousLayout(true);
1381
- framePanel.setOneTouchExpandable(true);
1382
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
13831611 //framePanel.setDividerSize(15);
13841612 //framePanel.setResizeWeight(0.15);
13851613 framePanel.setName("Frame");
....@@ -1396,10 +1624,15 @@
13961624
13971625 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13981626
1399
- frame.setSize(1024, 768);
1400
- frame.show();
1401
-
1627
+ frame.setSize(1280, 860);
1628
+
1629
+ cameraView.requestFocusInWindow();
1630
+
14021631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
14031636
14041637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14051638 frame.addWindowListener(new WindowAdapter()
....@@ -1436,17 +1669,25 @@
14361669
14371670 cGridBag editBar = new cGridBag().setVertical(false);
14381671
1439
- editBar.add(createMaterialButton = new cButton("Create")); // , aConstraints);
1672
+ editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
1673
+ createMaterialButton.setToolTipText("Create material");
14401674
14411675 /*
14421676 ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
14431677 */
14441678
1445
- editBar.add(clearMaterialButton = new cButton("Clear")); // , aConstraints);
1446
- editBar.add(resetSlidersButton = new cButton("Reset")); // , aConstraints);
1447
- editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1448
- editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1679
+ editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
1680
+ clearMaterialButton.setToolTipText("Clear material");
1681
+
1682
+ if (Globals.ADVANCED)
1683
+ {
1684
+ editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
1685
+ editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
1686
+ editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
1687
+ }
14491688
1689
+ editBar.preferredHeight = 15;
1690
+
14501691 panel.add(editBar);
14511692
14521693 /**/
....@@ -1477,24 +1718,6 @@
14771718 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14781719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14791720 colorSection.add(texture);
1480
-
1481
- cGridBag anisoU = new cGridBag();
1482
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1483
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1484
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1485
- colorSection.add(anisoU);
1486
-
1487
- cGridBag anisoV = new cGridBag();
1488
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1489
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1490
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1491
- colorSection.add(anisoV);
1492
-
1493
- cGridBag shadowbias = new cGridBag();
1494
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1495
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1496
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1497
- colorSection.add(shadowbias);
14981721
14991722 panel.add(new JSeparator());
15001723
....@@ -1546,6 +1769,12 @@
15461769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15471770 diffuseSection.add(fakedepth);
15481771
1772
+ cGridBag shadowbias = new cGridBag();
1773
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1774
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1776
+ diffuseSection.add(shadowbias);
1777
+
15491778 panel.add(new JSeparator());
15501779
15511780 panel.add(diffuseSection);
....@@ -1596,6 +1825,18 @@
15961825 // aConstraints.gridy += 1;
15971826 // aConstraints.gridwidth = 1;
15981827
1828
+ cGridBag anisoU = new cGridBag();
1829
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1830
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1831
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1832
+ specularSection.add(anisoU);
1833
+
1834
+ cGridBag anisoV = new cGridBag();
1835
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1836
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
+ specularSection.add(anisoV);
1839
+
15991840
16001841 panel.add(new JSeparator());
16011842
....@@ -1603,35 +1844,35 @@
16031844
16041845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16051846
1606
- cGridBag globalSection = new cGridBag().setVertical(true);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16071848
16081849 cGridBag camera = new cGridBag();
16091850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16101851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16111852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1612
- globalSection.add(camera);
1853
+ colorSection.add(camera);
16131854
16141855 cGridBag ambient = new cGridBag();
16151856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16161857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16171858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1618
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
16191860
16201861 cGridBag backlit = new cGridBag();
16211862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16221863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16231864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1624
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
16251866
16261867 cGridBag opacity = new cGridBag();
16271868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16281869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16291870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1630
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
16311872
1632
- panel.add(new JSeparator());
1873
+ //panel.add(new JSeparator());
16331874
1634
- panel.add(globalSection);
1875
+ //panel.add(globalSection);
16351876
16361877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16371878
....@@ -1712,12 +1953,15 @@
17121953 opacityPowerField.addChangeListener(this);
17131954 /**/
17141955
1715
- resetSlidersButton.addActionListener(this);
17161956 clearMaterialButton.addActionListener(this);
17171957 createMaterialButton.addActionListener(this);
1718
-
1719
- propagateToggle.addItemListener(this);
1720
- multiplyToggle.addItemListener(this);
1958
+
1959
+ if (Globals.ADVANCED)
1960
+ {
1961
+ resetSlidersButton.addActionListener(this);
1962
+ propagateToggle.addItemListener(this);
1963
+ multiplyToggle.addItemListener(this);
1964
+ }
17211965 }
17221966
17231967 void DropFile(java.io.File[] files, boolean textures)
....@@ -1888,7 +2132,7 @@
18882132
18892133 //? flashIt = false;
18902134 CameraPane pane = (CameraPane) cameraView;
1891
- pane.clickStart(location.x, location.y, 0);
2135
+ pane.clickStart(location.x, location.y, 0, 0);
18922136 pane.clickEnd(location.x, location.y, 0, true);
18932137
18942138 if (group.selection.size() == 1)
....@@ -1937,6 +2181,7 @@
19372181 e2.printStackTrace();
19382182 }
19392183 }
2184
+
19402185 LoadJMEThread loadThread;
19412186
19422187 class LoadJMEThread extends Thread
....@@ -1994,6 +2239,7 @@
19942239 //LoadFile0(filename, converter);
19952240 }
19962241 }
2242
+
19972243 LoadOBJThread loadObjThread;
19982244
19992245 class LoadOBJThread extends Thread
....@@ -2072,19 +2318,19 @@
20722318
20732319 void LoadObjFile(String fullname)
20742320 {
2075
- /*
2321
+ System.out.println("Loading " + fullname);
2322
+ /**/
20762323 //lastFilename = fullname;
20772324 if(loadObjThread == null)
20782325 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2326
+ loadObjThread = new LoadOBJThread();
2327
+ loadObjThread.start();
20812328 }
20822329
20832330 loadObjThread.add(fullname);
2084
- */
2331
+ /**/
20852332
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2333
+ //makeSomething(new FileObject(fullname, true), true);
20882334 }
20892335
20902336 void LoadGFDFile(String fullname)
....@@ -2345,11 +2591,11 @@
23452591
23462592 void ImportJME(com.jmex.model.converters.FormatConverter converter, String ext, String dialogName)
23472593 {
2348
- if (GrafreeD.standAlone)
2594
+ if (Grafreed.standAlone)
23492595 {
23502596 /**/
23512597 FileDialog browser = new FileDialog(frame, dialogName, FileDialog.LOAD);
2352
- browser.show();
2598
+ browser.setVisible(true);
23532599 String filename = browser.getFile();
23542600 if (filename != null && filename.length() > 0)
23552601 {
....@@ -2701,6 +2947,8 @@
27012947
27022948 void SetMaterial(Object3D object)
27032949 {
2950
+ latestObject = object;
2951
+
27042952 cMaterial mat = object.material;
27052953
27062954 if (mat == null)
....@@ -2709,7 +2957,8 @@
27092957 return;
27102958 }
27112959
2712
- multiplyToggle.setSelected(mat.multiply);
2960
+ if (multiplyToggle != null)
2961
+ multiplyToggle.setSelected(mat.multiply);
27132962
27142963 assert (object.projectedVertices != null);
27152964
....@@ -2811,12 +3060,17 @@
28113060 // }
28123061
28133062 /**/
2814
- if (deselect)
3063
+ if (deselect || child == null)
28153064 {
28163065 //group.deselectAll();
28173066 //freeze = true;
28183067 GetTree().clearSelection();
28193068 //freeze = false;
3069
+
3070
+ if (child == null)
3071
+ {
3072
+ return;
3073
+ }
28203074 }
28213075
28223076 //group.addSelectee(child);
....@@ -2885,7 +3139,7 @@
28853139 cameraView.ToggleDL();
28863140 cameraView.repaint();
28873141 return;
2888
- } else if (event.getSource() == toggleTextureItem)
3142
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28893143 {
28903144 cameraView.ToggleTexture();
28913145 // june 2013 copy.HardTouch();
....@@ -2924,9 +3178,9 @@
29243178 frame.validate();
29253179
29263180 return;
2927
- } else if (event.getSource() == toggleRandomItem)
3181
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29283182 {
2929
- cameraView.ToggleRandom();
3183
+ cameraView.ToggleSwitch();
29303184 cameraView.repaint();
29313185 return;
29323186 } else if (event.getSource() == toggleHandleItem)
....@@ -2947,6 +3201,10 @@
29473201 {
29483202 ToggleAnimation();
29493203 return;
3204
+ } else if (event.getSource() == archiveItem)
3205
+ {
3206
+ cTools.Archive(frame);
3207
+ return;
29503208 } else if (event.getSource() == flipVCB)
29513209 {
29523210 copy.flipV ^= true;
....@@ -2954,6 +3212,10 @@
29543212 } else if (event.getSource() == liveCB)
29553213 {
29563214 copy.live ^= true;
3215
+ return;
3216
+ } else if (event.getSource() == selectCB)
3217
+ {
3218
+ copy.dontselect ^= true;
29573219 return;
29583220 } else if (event.getSource() == hideCB)
29593221 {
....@@ -2969,6 +3231,7 @@
29693231 if (event.getSource() == randomCB)
29703232 {
29713233 copy.random ^= true;
3234
+ objEditor.refreshContents();
29723235 return;
29733236 }
29743237 if (event.getSource() == speedupCB)
....@@ -2992,8 +3255,9 @@
29923255
29933256 public void actionPerformed(ActionEvent event)
29943257 {
3258
+ Object source = event.getSource();
29953259 // SCRIPT DIALOG
2996
- if (event.getSource() == okbutton)
3260
+ if (source == okbutton)
29973261 {
29983262 textpanel.setVisible(false);
29993263 textpanel.remove(textarea);
....@@ -3005,7 +3269,7 @@
30053269 textarea = null;
30063270 textpanel = null;
30073271 }
3008
- if (event.getSource() == cancelbutton)
3272
+ if (source == cancelbutton)
30093273 {
30103274 textpanel.setVisible(false);
30113275 textpanel.remove(textarea);
....@@ -3017,50 +3281,50 @@
30173281 //applySelf();
30183282 //client.refreshEditWindow();
30193283 //refreshContents();
3020
- if (event.getSource() == nameField)
3284
+ if (source == nameField)
30213285 {
30223286 //System.out.println("ObjEditor " + event);
30233287 applySelf0(true);
30243288 //parent.applySelf();
30253289 objEditor.refreshContents();
3026
- } else if (event.getSource() == resetButton)
3290
+ } else if (source == resetButton)
30273291 {
30283292 CameraPane.fullreset = true;
30293293 copy.Reset(); // ResetMeshes();
30303294 copy.Touch();
30313295 objEditor.refreshContents();
3032
- } else if (event.getSource() == stepItem)
3296
+ } else if (source == stepItem)
30333297 {
30343298 //cameraView.ONESTEP = true;
30353299 Globals.ONESTEP = true;
30363300 cameraView.repaint();
30373301 return;
3038
- } else if (event.getSource() == stepButton)
3302
+ } else if (source == stepButton)
30393303 {
30403304 copy.Step();
30413305 copy.Touch();
30423306 objEditor.refreshContents();
3043
- } else if (event.getSource() == slowerButton)
3307
+ } else if (source == slowerButton)
30443308 {
30453309 copy.Slower();
30463310 copy.Touch();
30473311 objEditor.refreshContents();
3048
- } else if (event.getSource() == fasterButton)
3312
+ } else if (source == fasterButton)
30493313 {
30503314 copy.Faster();
30513315 copy.Touch();
30523316 objEditor.refreshContents();
3053
- } else if (event.getSource() == remarkButton)
3317
+ } else if (source == remarkButton)
30543318 {
30553319 copy.Remark();
30563320 copy.Touch();
30573321 objEditor.refreshContents();
3058
- } else if (event.getSource() == stepAllButton)
3322
+ } else if (source == stepAllButton)
30593323 {
30603324 copy.StepAll();
30613325 copy.Touch();
30623326 objEditor.refreshContents();
3063
- } else if (event.getSource() == resetAllButton)
3327
+ } else if (source == resetAllButton)
30643328 {
30653329 //CameraPane.fullreset = true;
30663330 copy.ResetAll(); // ResetMeshes();
....@@ -3093,53 +3357,75 @@
30933357 // Close();
30943358 // }
30953359 // else
3096
- if (event.getSource() == resetSlidersButton)
3360
+ if (source == resetSlidersButton)
30973361 {
30983362 ResetSliders();
3099
- } else if (event.getSource() == clearMaterialButton)
3363
+ } else if (source == clearMaterialButton)
31003364 {
31013365 ClearMaterial();
3102
- } else if (event.getSource() == createMaterialButton)
3366
+ } else if (source == createMaterialButton)
31033367 {
31043368 CreateMaterial();
3105
- } else if (event.getSource() == clearPanelButton)
3369
+ } else if (source == clearPanelButton)
31063370 {
31073371 copy.ClearUI();
31083372 refreshContents(true);
3109
- } /*
3110
- }
3111
-
3112
- public boolean action(Event event, Object arg)
3113
- {
3114
- */ else if (event.getSource() == closeItem)
3373
+ } else if (source == importGFDItem)
3374
+ {
3375
+ ImportGFD();
3376
+ } else
3377
+ if (source == importVRMLX3DItem)
3378
+ {
3379
+ ImportVRMLX3D();
3380
+ } else
3381
+ if (source == import3DSItem)
3382
+ {
3383
+ objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
3384
+ } else
3385
+ if (source == importOBJItem)
3386
+ {
3387
+ //objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
3388
+ FileDialog browser = new FileDialog(frame, "Import OBJ", FileDialog.LOAD);
3389
+ browser.setVisible(true);
3390
+ String filename = browser.getFile();
3391
+ if (filename != null && filename.length() > 0)
3392
+ {
3393
+ String fullname = browser.getDirectory() + filename;
3394
+ makeSomething(ReadOBJ(fullname), true);
3395
+ }
3396
+ } else
3397
+ if (source == closeItem)
31153398 {
31163399 Close();
31173400 //return true;
3118
- } else if (event.getSource() == loadItem)
3401
+ } else if (source == openItem)
31193402 {
3120
- load();
3403
+ Open();
31213404 //return true;
3122
- } else if (event.getSource() == saveItem)
3405
+ } else if (source == newItem)
3406
+ {
3407
+ New();
3408
+ } else if (source == saveItem)
31233409 {
31243410 save();
31253411 //return true;
3126
- } else if (event.getSource() == saveAsItem)
3412
+ } else if (source == saveAsItem)
31273413 {
31283414 saveAs();
31293415 //return true;
3130
- } else if (event.getSource() == reexportItem)
3416
+ } else if (source == reexportItem)
31313417 {
31323418 reexport();
31333419 //return true;
3134
- } else if (event.getSource() == exportAsItem)
3420
+ } else if (source == exportAsItem)
31353421 {
31363422 export();
31373423 //return true;
3138
- } else if (event.getSource() == povItem)
3424
+ } else if (source == povItem)
31393425 {
31403426 generatePOV();
31413427 //return true;
3142
- } else if (event.getSource() == zBufferItem)
3428
+ } else if (source == zBufferItem)
31433429 {
31443430 try
31453431 {
....@@ -3161,21 +3447,8 @@
31613447 cameraView.repaint();
31623448 //return true;
31633449 }
3164
- */ else if (event.getSource() == editCameraItem)
3165
- {
3166
- cameraView.ProtectCamera();
3167
- cameraView.repaint();
3168
- return;
3169
- } else if (event.getSource() == revertCameraItem)
3170
- {
3171
- cameraView.RevertCamera();
3172
- cameraView.repaint();
3173
- return;
3174
-// } else if (event.getSource() == textureButton)
3175
-// {
3176
-// return; // true;
3177
- } else // combos...
3178
- if (event.getSource() == texresMenu)
3450
+ */ else // combos...
3451
+ if (source == texresMenu)
31793452 {
31803453 System.err.println("Object = " + copy + "; change value " + copy.texres + " to " + texresMenu.getSelectedIndex());
31813454 copy.texres = texresMenu.getSelectedIndex();
....@@ -3187,12 +3460,289 @@
31873460 }
31883461 }
31893462
3463
+ void New()
3464
+ {
3465
+ while (copy.Size() > 1)
3466
+ {
3467
+ copy.remove(1);
3468
+ }
3469
+
3470
+ ResetModel();
3471
+ objEditor.refreshContents();
3472
+ }
3473
+
3474
+ static public byte[] Compress(Object3D o)
3475
+ {
3476
+ try
3477
+ {
3478
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3479
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3480
+ ObjectOutputStream out = new ObjectOutputStream(zstream);
3481
+
3482
+ Object3D parent = o.parent;
3483
+ o.parent = null;
3484
+
3485
+ out.writeObject(o);
3486
+
3487
+ o.parent = parent;
3488
+
3489
+ out.flush();
3490
+
3491
+ zstream.close();
3492
+ out.close();
3493
+
3494
+ return baos.toByteArray();
3495
+ } catch (Exception e)
3496
+ {
3497
+ System.err.println(e);
3498
+ return null;
3499
+ }
3500
+ }
3501
+
3502
+ static public Object Uncompress(byte[] bytes)
3503
+ {
3504
+ System.out.println("#bytes = " + bytes.length);
3505
+ try
3506
+ {
3507
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3508
+ java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3509
+ ObjectInputStream in = new ObjectInputStream(istream);
3510
+ Object obj = in.readObject();
3511
+ in.close();
3512
+
3513
+ return obj;
3514
+ } catch (Exception e)
3515
+ {
3516
+ System.err.println(e);
3517
+ return null;
3518
+ }
3519
+ }
3520
+
3521
+ static public Object clone(Object o)
3522
+ {
3523
+ try
3524
+ {
3525
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3526
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3527
+
3528
+ out.writeObject(o);
3529
+
3530
+ out.flush();
3531
+ out.close();
3532
+
3533
+ byte[] bytes = baos.toByteArray();
3534
+
3535
+ System.out.println("clone = " + bytes.length);
3536
+
3537
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3538
+ ObjectInputStream in = new ObjectInputStream(bais);
3539
+ Object obj = in.readObject();
3540
+ in.close();
3541
+
3542
+ return obj;
3543
+ } catch (Exception e)
3544
+ {
3545
+ System.err.println(e);
3546
+ return null;
3547
+ }
3548
+ }
3549
+
3550
+ cRadio GetCurrentTab()
3551
+ {
3552
+ cRadio ab;
3553
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3554
+ {
3555
+ ab = (cRadio)e.nextElement();
3556
+ if(ab.GetObject() == copy)
3557
+ {
3558
+ return ab;
3559
+ }
3560
+ }
3561
+
3562
+ return null;
3563
+ }
3564
+
3565
+ java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
3566
+
3567
+ public void Save()
3568
+ {
3569
+ System.err.println("Save");
3570
+
3571
+ cRadio tab = GetCurrentTab();
3572
+
3573
+ boolean temp = CameraPane.SWITCH;
3574
+ CameraPane.SWITCH = false;
3575
+
3576
+ copy.ExtractBigData(hashtable);
3577
+
3578
+ byte[] compress = Compress(copy);
3579
+
3580
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3581
+ tab.graphs[tab.undoindex++] = compress;
3582
+
3583
+ copy.RestoreBigData(hashtable);
3584
+
3585
+ CameraPane.SWITCH = temp;
3586
+
3587
+ //assert(hashtable.isEmpty());
3588
+
3589
+ for (int i = tab.undoindex; i < tab.graphs.length; i++)
3590
+ {
3591
+ tab.graphs[i] = null;
3592
+ }
3593
+
3594
+ SetUndoStates();
3595
+
3596
+ // test save
3597
+ if (false)
3598
+ {
3599
+ try
3600
+ {
3601
+ FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3602
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3603
+
3604
+ p.writeObject(copy);
3605
+
3606
+ p.flush();
3607
+
3608
+ ostream.close();
3609
+ } catch (Exception e)
3610
+ {
3611
+ e.printStackTrace();
3612
+ }
3613
+ }
3614
+ }
3615
+
3616
+ void CopyChanged(Object3D obj)
3617
+ {
3618
+ SetUndoStates();
3619
+
3620
+ boolean temp = CameraPane.SWITCH;
3621
+ CameraPane.SWITCH = false;
3622
+
3623
+ copy.ExtractBigData(hashtable);
3624
+
3625
+ copy.clear();
3626
+
3627
+ for (int i=0; i<obj.Size(); i++)
3628
+ {
3629
+ copy.add(obj.get(i));
3630
+ }
3631
+
3632
+ copy.RestoreBigData(hashtable);
3633
+
3634
+ CameraPane.SWITCH = temp;
3635
+
3636
+ //assert(hashtable.isEmpty());
3637
+
3638
+ copy.Touch();
3639
+
3640
+ ResetModel();
3641
+ copy.HardTouch(); // recompile?
3642
+
3643
+ cRadio ab;
3644
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3645
+ {
3646
+ ab = (cRadio)e.nextElement();
3647
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3648
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3649
+ if (test != null)
3650
+ {
3651
+ test.editWindow = ab.object.editWindow;
3652
+ ab.object = test;
3653
+ }
3654
+ }
3655
+
3656
+ refreshContents();
3657
+ }
3658
+
3659
+ cButton undoButton;
3660
+ cButton redoButton;
3661
+
3662
+ void SetUndoStates()
3663
+ {
3664
+ cRadio tab = GetCurrentTab();
3665
+
3666
+ undoButton.setEnabled(tab.undoindex > 0);
3667
+ redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3668
+ }
3669
+
3670
+ public void Undo()
3671
+ {
3672
+ System.err.println("Undo");
3673
+
3674
+ cRadio tab = GetCurrentTab();
3675
+
3676
+ if (tab.undoindex == 0)
3677
+ {
3678
+ java.awt.Toolkit.getDefaultToolkit().beep();
3679
+ return;
3680
+ }
3681
+
3682
+ if (tab.graphs[tab.undoindex] == null)
3683
+ {
3684
+ Save();
3685
+ tab.undoindex -= 1;
3686
+ }
3687
+
3688
+ tab.undoindex -= 1;
3689
+
3690
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3691
+ }
3692
+
3693
+ public void Redo()
3694
+ {
3695
+ cRadio tab = GetCurrentTab();
3696
+
3697
+ if (tab.graphs[tab.undoindex + 1] == null)
3698
+ {
3699
+ java.awt.Toolkit.getDefaultToolkit().beep();
3700
+ return;
3701
+ }
3702
+
3703
+ tab.undoindex += 1;
3704
+
3705
+ CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3706
+ }
3707
+
3708
+ void ImportGFD()
3709
+ {
3710
+ FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
3711
+ browser.show();
3712
+ String filename = browser.getFile();
3713
+ if (filename != null && filename.length() > 0)
3714
+ {
3715
+ String fullname = browser.getDirectory() + filename;
3716
+
3717
+ //Object3D readobj =
3718
+ objEditor.ReadGFD(fullname, objEditor);
3719
+ //makeSomething(readobj);
3720
+ }
3721
+ }
3722
+
3723
+ void ImportVRMLX3D()
3724
+ {
3725
+ if (Grafreed.standAlone)
3726
+ {
3727
+ /**/
3728
+ FileDialog browser = new FileDialog(objEditor.frame, "Import VRML/X3D", FileDialog.LOAD);
3729
+ browser.show();
3730
+ String filename = browser.getFile();
3731
+ if (filename != null && filename.length() > 0)
3732
+ {
3733
+ String fullname = browser.getDirectory() + filename;
3734
+ LoadVRMLX3D(fullname);
3735
+ }
3736
+ /**/
3737
+ }
3738
+ }
3739
+
31903740 void ToggleAnimation()
31913741 {
31923742 if (!Globals.ANIMATION)
31933743 {
31943744 FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
3195
- browser.show();
3745
+ browser.setVisible(true);
31963746 String filename = browser.getFile();
31973747 if (filename != null && filename.length() > 0)
31983748 {
....@@ -3202,8 +3752,8 @@
32023752
32033753 Globals.ANIMATION ^= true;
32043754
3205
- GrafreeD.wav.cursor = 0;
3206
- GrafreeD.wav.loop = 0;
3755
+ Grafreed.wav.cursor = 0;
3756
+ Grafreed.wav.loop = 0;
32073757 }
32083758 } else
32093759 {
....@@ -3224,7 +3774,6 @@
32243774 callee.refreshContents();
32253775 } else
32263776 {
3227
- new Exception().printStackTrace();
32283777 System.exit(0);
32293778 }
32303779 }
....@@ -3254,7 +3803,7 @@
32543803 void CreateMaterial()
32553804 {
32563805 //copy.ClearMaterial(); // PATCH
3257
- copy.CreateMaterialS(multiplyToggle.isSelected());
3806
+ copy.CreateMaterialS(multiplyToggle != null && multiplyToggle.isSelected());
32583807 if (copy.selection.size() > 0)
32593808 //SetMaterial(copy);
32603809 {
....@@ -3305,7 +3854,7 @@
33053854 assert false;
33063855 }
33073856
3308
- void EditSelection()
3857
+ void EditSelection(boolean newWindow)
33093858 {
33103859 }
33113860
....@@ -3313,11 +3862,11 @@
33133862 {
33143863 copy.ResetBlockLoop(); // temporary problem
33153864
3316
- boolean random = CameraPane.RANDOM;
3317
- CameraPane.RANDOM = false; // parse everything
3865
+ boolean random = CameraPane.SWITCH;
3866
+ CameraPane.SWITCH = false; // parse everything
33183867 copy.ResetDisplayList();
33193868 copy.HardTouch();
3320
- CameraPane.RANDOM = random;
3869
+ CameraPane.SWITCH = random;
33213870 }
33223871
33233872 // public void applySelf()
....@@ -3391,6 +3940,36 @@
33913940 {
33923941 //System.out.println("Propagate = " + propagate);
33933942 copy.UpdateMaterial(anchor, current, propagate);
3943
+
3944
+ if (copy.material != null)
3945
+ {
3946
+ cMaterial mat = copy.material;
3947
+
3948
+ colorField.SetToolTipValue((mat.color));
3949
+ modulationField.SetToolTipValue((mat.modulation));
3950
+ metalnessField.SetToolTipValue((mat.metalness));
3951
+ diffuseField.SetToolTipValue((mat.diffuse));
3952
+ specularField.SetToolTipValue((mat.specular));
3953
+ shininessField.SetToolTipValue((mat.shininess));
3954
+ shiftField.SetToolTipValue((mat.shift));
3955
+ ambientField.SetToolTipValue((mat.ambient));
3956
+ lightareaField.SetToolTipValue((mat.lightarea));
3957
+ diffusenessField.SetToolTipValue((mat.factor));
3958
+ velvetField.SetToolTipValue((mat.velvet));
3959
+ sheenField.SetToolTipValue((mat.sheen));
3960
+ subsurfaceField.SetToolTipValue((mat.subsurface));
3961
+ backlitField.SetToolTipValue((mat.bump));
3962
+ anisoField.SetToolTipValue((mat.aniso));
3963
+ anisoVField.SetToolTipValue((mat.anisoV));
3964
+ cameraField.SetToolTipValue((mat.cameralight));
3965
+ selfshadowField.SetToolTipValue((mat.diffuseness));
3966
+ shadowField.SetToolTipValue((mat.shadow));
3967
+ textureField.SetToolTipValue((mat.texture));
3968
+ opacityField.SetToolTipValue((mat.opacity));
3969
+ fakedepthField.SetToolTipValue((mat.fakedepth));
3970
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
3971
+ }
3972
+
33943973 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
33953974 {
33963975 copy.projectedVertices[0].x = (int) (bumpField.getFloat() * 1000);
....@@ -3506,7 +4085,7 @@
35064085 }
35074086
35084087 if (normalpushField != null)
3509
- copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;
4088
+ copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
35104089 }
35114090
35124091 void SnapObject()
....@@ -3770,6 +4349,8 @@
37704349
37714350 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
37724351 {
4352
+ if (Globals.SAVEONMAKE) // && resetmodel)
4353
+ Save();
37734354 //Tween.set(thing, 0).target(1).start(tweenManager);
37744355 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
37754356 // if (thing instanceof GenericJointDemo)
....@@ -3856,6 +4437,12 @@
38564437 {
38574438 ResetModel();
38584439 Select(thing.GetTreePath(), true, false); // unselect... false);
4440
+
4441
+ if (thing.Size() == 0)
4442
+ {
4443
+ //EditSelection(false);
4444
+ }
4445
+
38594446 refreshContents();
38604447 }
38614448
....@@ -3973,6 +4560,7 @@
39734560 }
39744561 }
39754562 }
4563
+
39764564 LoadGFDThread loadGFDThread;
39774565
39784566 void ReadGFD(String fullname, iCallBack cb)
....@@ -3992,8 +4580,10 @@
39924580
39934581 try
39944582 {
4583
+ // Try compressed version first.
39954584 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
3996
- java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4585
+ java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
4586
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
39974587
39984588 readobj = (Object3D) p.readObject();
39994589 istream.close();
....@@ -4001,7 +4591,20 @@
40014591 readobj.ResetDisplayList();
40024592 } catch (Exception e)
40034593 {
4004
- e.printStackTrace();
4594
+ //e.printStackTrace();
4595
+ try
4596
+ {
4597
+ java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
4598
+ java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);
4599
+
4600
+ readobj = (Object3D) p.readObject();
4601
+ istream.close();
4602
+
4603
+ readobj.ResetDisplayList();
4604
+ } catch (Exception e2)
4605
+ {
4606
+ e2.printStackTrace();
4607
+ }
40054608 }
40064609 // catch(java.io.StreamCorruptedException e) { e.printStackTrace(); }
40074610 // catch(java.io.IOException e) { System.out.println("IOexception"); e.printStackTrace(); }
....@@ -4047,6 +4650,12 @@
40474650
40484651 void LoadIt(Object obj)
40494652 {
4653
+ if (obj == null)
4654
+ {
4655
+ // Invalid file
4656
+ return;
4657
+ }
4658
+
40504659 System.out.println("Loaded " + obj);
40514660 //new Exception().printStackTrace();
40524661 Object3D readobj = (Object3D) obj;
....@@ -4056,6 +4665,8 @@
40564665
40574666 if (readobj != null)
40584667 {
4668
+ if (Globals.SAVEONMAKE)
4669
+ Save();
40594670 try
40604671 {
40614672 //readobj.deepCopySelf(copy);
....@@ -4116,9 +4727,9 @@
41164727 }
41174728 }
41184729
4119
- void load() // throws ClassNotFoundException
4730
+ void Open() // throws ClassNotFoundException
41204731 {
4121
- if (GrafreeD.standAlone)
4732
+ if (Grafreed.standAlone)
41224733 {
41234734 FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
41244735 browser.show();
....@@ -4205,11 +4816,13 @@
42054816 try
42064817 {
42074818 FileOutputStream ostream = new FileOutputStream(lastname);
4208
- ObjectOutputStream p = new ObjectOutputStream(ostream);
4819
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4820
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
42094821
42104822 p.writeObject(copy);
42114823 p.flush();
42124824
4825
+ zstream.close();
42134826 ostream.close();
42144827
42154828 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4219,17 +4832,20 @@
42194832 {
42204833 }
42214834 }
4835
+
42224836 String lastname;
42234837
42244838 void saveAs()
42254839 {
4226
- if (GrafreeD.standAlone)
4840
+ if (Grafreed.standAlone)
42274841 {
42284842 FileDialog browser = new FileDialog(frame, "Save As", FileDialog.SAVE);
42294843 browser.setVisible(true);
42304844 String filename = browser.getFile();
42314845 if (filename != null && filename.length() > 0)
42324846 {
4847
+ if (!filename.endsWith(".gfd"))
4848
+ filename += ".gfd";
42334849 lastname = browser.getDirectory() + filename;
42344850 save();
42354851 }
....@@ -4328,13 +4944,13 @@
43284944 try
43294945 {
43304946 FileOutputStream ostream = new FileOutputStream(filename);
4331
- // ?? java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4332
- ObjectOutputStream p = new ObjectOutputStream(/*z*/ostream);
4947
+ java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(ostream);
4948
+ ObjectOutputStream p = new ObjectOutputStream(zstream);
43334949
43344950 Object3D objectparent = obj.parent;
43354951 obj.parent = null;
43364952
4337
- Object3D object = (Object3D) GrafreeD.clone(obj);
4953
+ Object3D object = (Object3D) Grafreed.clone(obj);
43384954
43394955 obj.parent = objectparent;
43404956
....@@ -4346,8 +4962,8 @@
43464962 p.writeObject(object);
43474963 p.flush();
43484964
4965
+ zstream.close();
43494966 ostream.close();
4350
- // zstream.close();
43514967
43524968 // group.selection.get(0).parent = parent;
43534969 //FileOutputStream fos = new FileOutputStream(fullname);
....@@ -4368,7 +4984,7 @@
43684984 buffer.append("background { color rgb <0.8,0.8,0.8> }\n\n");
43694985 cameraView.renderCamera.generatePOV(buffer, bnds.width, bnds.height);
43704986 copy.generatePOV(buffer);
4371
- if (GrafreeD.standAlone)
4987
+ if (Grafreed.standAlone)
43724988 {
43734989 FileDialog browser = new FileDialog(frame, "Export POV", 1);
43744990 browser.show();
....@@ -4394,19 +5010,18 @@
43945010 Object3D client;
43955011 Object3D copy;
43965012 MenuBar menuBar;
4397
- Menu windowMenu;
4398
- MenuItem loadItem;
5013
+ Menu fileMenu;
5014
+ MenuItem newItem;
5015
+ MenuItem openItem;
43995016 MenuItem saveItem;
44005017 MenuItem saveAsItem;
44015018 MenuItem exportAsItem;
44025019 MenuItem reexportItem;
44035020 MenuItem povItem;
44045021 MenuItem closeItem;
4405
- Menu cameraMenu;
5022
+
44065023 CheckboxMenuItem zBufferItem;
44075024 //MenuItem normalLensItem;
4408
- MenuItem editCameraItem;
4409
- MenuItem revertCameraItem;
44105025 MenuItem stepItem;
44115026 CheckboxMenuItem toggleLiveItem;
44125027 CheckboxMenuItem toggleFullScreenItem;
....@@ -4417,25 +5032,39 @@
44175032 CheckboxMenuItem toggleFootContactItem;
44185033 CheckboxMenuItem toggleDLItem;
44195034 CheckboxMenuItem toggleTextureItem;
4420
- CheckboxMenuItem toggleRandomItem;
5035
+ CheckboxMenuItem toggleSwitchItem;
44215036 CheckboxMenuItem toggleRootItem;
44225037 CheckboxMenuItem animationItem;
5038
+ CheckboxMenuItem archiveItem;
44235039 CheckboxMenuItem toggleHandleItem;
44245040 CheckboxMenuItem togglePaintItem;
44255041 JSplitPane mainPanel;
44265042 JScrollPane scrollpane;
5043
+
44275044 JPanel toolbarPanel;
4428
- JPanel treePanel;
5045
+
5046
+ cGridBag treePanel;
5047
+
44295048 JPanel radioPanel;
44305049 ButtonGroup buttonGroup;
4431
- cGridBag ctrlPanel;
5050
+
5051
+ cGridBag toolboxPanel;
44325052 cGridBag materialPanel;
5053
+ cGridBag ctrlPanel;
5054
+
44335055 JScrollPane infoPanel;
5056
+
44345057 cGridBag optionsPanel;
5058
+
44355059 JTabbedPane objectPanel;
5060
+ boolean materialFlushed;
5061
+ Object3D latestObject;
5062
+
44365063 cGridBag XYZPanel;
5064
+
44375065 JSplitPane gridPanel;
44385066 JSplitPane bigPanel;
5067
+
44395068 cGridBag bigThree;
44405069 cGridBag scenePanel;
44415070 cGridBag centralPanel;
....@@ -4550,8 +5179,13 @@
45505179 cNumberSlider fogField;
45515180 JLabel opacityPowerLabel;
45525181 cNumberSlider opacityPowerField;
4553
- JTree jTree;
5182
+ cTree jTree;
45545183 //ObjectUI parent;
45555184
45565185 cNumberSlider normalpushField;
5186
+
5187
+ private MenuItem importGFDItem;
5188
+ private MenuItem importVRMLX3DItem;
5189
+ private MenuItem import3DSItem;
5190
+ private MenuItem importOBJItem;
45575191 }