Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -38,64 +41,78 @@
3841 JFrame frame;
3942
4043 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4152
4253 cButton GetButton(String name, boolean border)
4354 {
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
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5363 }
5464
5565 cToggleButton GetToggleButton(String name, boolean border)
5666 {
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
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6669 }
6770
6871 cCheckBox GetCheckBox(String name, boolean border)
6972 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7079 try
7180 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7497 }
7598 catch (Exception e)
7699 {
77
- return new cCheckBox(name, border);
100
+ return null;
78101 }
79102 }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
82105 {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
86107 {
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;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
95111 }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
99116 }
100117
101118 // SCRIPT
....@@ -207,7 +224,7 @@
207224
208225 objEditor.ctrlPanel.remove(namePanel);
209226
210
- if (!GroupEditor.allparams)
227
+ if (!allparams)
211228 return;
212229
213230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -279,6 +296,12 @@
279296 client = inClient;
280297 copy = client;
281298
299
+ if (copy.versions == null)
300
+ {
301
+ copy.versions = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
282305 // "this" is not called: SetupUI2(objEditor);
283306 }
284307
....@@ -292,6 +315,12 @@
292315 client = inClient;
293316 copy = client;
294317
318
+ if (copy.versions == null)
319
+ {
320
+ copy.versions = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
295324 SetupUI2(callee.GetEditor());
296325 }
297326
....@@ -306,7 +335,7 @@
306335 //localCopy.parent = null;
307336
308337 frame = new JFrame();
309
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
310339 objEditor = this;
311340 this.callee = callee;
312341
....@@ -324,6 +353,12 @@
324353 copy = localCopy;
325354 copy.editWindow = this;
326355
356
+ if (copy.versions == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
327362 SetupMenu();
328363
329364 //SetupName(objEditor); // new
....@@ -337,12 +372,17 @@
337372 return frame.action(event, obj);
338373 }
339374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
340380 void SetupMenu()
341381 {
342382 frame.setMenuBar(menuBar = new MenuBar());
343383 menuBar.add(fileMenu = new Menu("File"));
344384 fileMenu.add(newItem = new MenuItem("New"));
345
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
346386
347387 //oe.menuBar.add(menu = new Menu("Include"));
348388 Menu menu = new Menu("Import");
....@@ -374,7 +414,7 @@
374414 }
375415
376416 newItem.addActionListener(this);
377
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
378418 saveItem.addActionListener(this);
379419 saveAsItem.addActionListener(this);
380420 exportAsItem.addActionListener(this);
....@@ -383,13 +423,40 @@
383423 closeItem.addActionListener(this);
384424
385425 objectPanel = new JTabbedPane();
426
+
427
+ ChangeListener changeListener = new ChangeListener()
428
+ {
429
+ public void stateChanged(ChangeEvent changeEvent)
430
+ {
431
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
432
+// {
433
+// if (latestObject != null)
434
+// {
435
+// refreshContents(true);
436
+// SetMaterial(latestObject);
437
+// }
438
+//
439
+// materialFlushed = true;
440
+// }
441
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
442
+// {
443
+// if (listUI.size() == 0)
444
+// EditSelection(false);
445
+// }
446
+
447
+ refreshContents(false); // To refresh Info tab
448
+ }
449
+ };
450
+ objectPanel.addChangeListener(changeListener);
451
+
386452 toolbarPanel = new JPanel();
387453 toolbarPanel.setName("Toolbar");
454
+
388455 treePanel = new cGridBag();
389456 treePanel.setName("Tree");
390457
391458 editPanel = new cGridBag().setVertical(true);
392
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
393460
394461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
395462
....@@ -397,11 +464,11 @@
397464 editPanel.add(editCommandsPanel);
398465 editPanel.add(ctrlPanel);
399466
400
- toolboxPanel = new cGridBag().setVertical(false);
401
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
402469
403470 materialPanel = new cGridBag().setVertical(true);
404
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
405472
406473 /*JTextPane*/
407474 infoarea = createTextPane();
....@@ -409,14 +476,15 @@
409476
410477 infoarea.setEditable(true);
411478 SetText();
479
+
412480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
413481 // infoarea.setOpaque(false);
414482 // //infoarea.setForeground(textcolor);
415483 // TEXTAREA infoarea.setLineWrap(true);
416484 // TEXTAREA infoarea.setWrapStyleWord(true);
417485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
418
- infoPanel.setPreferredSize(new Dimension(50, 200));
419
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
420488 //infoPanel.setLayout(new BorderLayout());
421489 //infoPanel.add(createTextPane());
422490
....@@ -427,7 +495,14 @@
427495 mainPanel.setDividerSize(9);
428496 mainPanel.setDividerLocation(0.5); //1.0);
429497 mainPanel.setResizeWeight(0.5);
430
-
498
+
499
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
500
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
501
+ divider.setDividerSize(15);
502
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
503
+
504
+ mainPanel.setUI(new BasicSplitPaneUI());
505
+
431506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
432507 //mainPanel.setLayout(new GridBagLayout());
433508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -658,8 +733,8 @@
658733 }
659734 }
660735
661
-static GraphicsDevice device = GraphicsEnvironment
662
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
663738
664739 Rectangle keeprect;
665740 cRadio radio;
....@@ -680,10 +755,19 @@
680755 void Minimize()
681756 {
682757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
683759 }
684760
761
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
762
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
763
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
685764 void Maximize()
686765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
687771 if (maximized)
688772 {
689773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -691,20 +775,36 @@
691775 else
692776 {
693777 keeprect = frame.getBounds();
694
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
695
- Dimension rect2 = frame.getToolkit().getScreenSize();
696
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
697781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
698783 }
699784
700785 maximized ^= true;
786
+
787
+ frame.validate();
701788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
702793
703794 void ToggleFullScreen()
704795 {
705
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
706801 {
707802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
708808 //frame.setVisible(false);
709809 // frame.removeNotify();
710810 // frame.setUndecorated(false);
....@@ -714,7 +814,7 @@
714814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
715815 // X framePanel.add(bigThree);
716816 // X frame.getContentPane().add(/*"Center",*/framePanel);
717
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
718818
719819 //frame.setVisible(true);
720820 radio.layout = keepButton;
....@@ -729,7 +829,12 @@
729829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
730830 // frame.getToolkit().getScreenSize().height);
731831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
732835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
733838 // frame.removeNotify();
734839 // frame.setUndecorated(true);
735840 // frame.addNotify();
....@@ -742,9 +847,31 @@
742847 radio.layout.doClick();
743848 //frame.setVisible(true);
744849 }
745
-
746
- cameraView.ToggleFullScreen();
850
+ frame.validate();
747851 }
852
+
853
+ private Object3D CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ Object3D versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versions = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
748875
749876 private JTextPane createTextPane()
750877 {
....@@ -876,7 +1003,7 @@
8761003 // NumberSlider vDivsField;
8771004 // JCheckBox endcaps;
8781005 JCheckBox liveCB;
879
- JCheckBox selectCB;
1006
+ JCheckBox selectableCB;
8801007 JCheckBox hideCB;
8811008 JCheckBox link2masterCB;
8821009 JCheckBox markCB;
....@@ -884,7 +1011,12 @@
8841011 JCheckBox speedupCB;
8851012 JCheckBox rewindCB;
8861013 JCheckBox flipVCB;
1014
+
1015
+ cCheckBox toggleTextureCB;
1016
+ cCheckBox toggleSwitchCB;
1017
+
8871018 JComboBox texresMenu;
1019
+
8881020 JButton resetButton;
8891021 JButton stepButton;
8901022 JButton stepAllButton;
....@@ -1071,38 +1203,42 @@
10711203 namePanel = new cGridBag();
10721204
10731205 nameField = AddText(namePanel, copy.GetName());
1074
- namePanel.add(nameField);
1206
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10751207 oe.ctrlPanel.add(namePanel);
10761208
10771209 oe.ctrlPanel.Return();
10781210
1079
- if (!GroupEditor.allparams)
1211
+ if (!allparams)
10801212 return;
10811213
10821214 setupPanel = new cGridBag().setVertical(false);
10831215
10841216 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10851217 liveCB.setToolTipText("Animate object");
1086
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1087
- selectCB.setToolTipText("Make object selectable");
1218
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1219
+ selectableCB.setToolTipText("Make object selectable");
10881220 // Return();
1221
+
10891222 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10901223 hideCB.setToolTipText("Hide object");
10911224 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1092
- markCB.setToolTipText("Set the animation target transform");
1225
+ markCB.setToolTipText("As animation target transform");
1226
+
1227
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10931228
10941229 setupPanel2 = new cGridBag().setVertical(false);
10951230
10961231 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10971232 rewindCB.setToolTipText("Rewind animation");
10981233
1099
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1100
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1234
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1235
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11011236
1237
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1238
+ link2masterCB.setToolTipText("Attach to support");
1239
+
11021240 if (Globals.ADVANCED)
11031241 {
1104
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1105
- link2masterCB.setToolTipText("Attach to support");
11061242 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11071243 speedupCB.setToolTipText("Option motion capture");
11081244 }
....@@ -1376,6 +1512,7 @@
13761512 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13771513 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13781514 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1515
+ //XYZPanel.setName("XYZ");
13791516
13801517 /*
13811518 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1412,14 +1549,30 @@
14121549
14131550 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14141551 //tmp.setName("Edit");
1415
- objectPanel.add(toolboxPanel);
14161552 objectPanel.add(materialPanel);
1553
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
+ objectPanel.setToolTipTextAt(0, "Material panel");
1555
+
14171556 // JPanel north = new JPanel(new BorderLayout());
14181557 // north.setName("Edit");
14191558 // north.add(ctrlPanel, BorderLayout.NORTH);
14201559 // objectPanel.add(north);
14211560 objectPanel.add(editPanel);
1422
- objectPanel.add(infoPanel);
1561
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
+ objectPanel.setToolTipTextAt(1, "Edit panel");
1563
+
1564
+ //if (Globals.ADVANCED)
1565
+ objectPanel.add(infoPanel);
1566
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
+ objectPanel.setToolTipTextAt(2, "Info panel");
1568
+
1569
+ objectPanel.add(XYZPanel);
1570
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1572
+
1573
+ objectPanel.add(toolboxPanel);
1574
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
14231576
14241577 /*
14251578 aConstraints.gridx = 0;
....@@ -1428,7 +1581,7 @@
14281581 aConstraints.gridy += 1;
14291582 aConstraints.gridwidth = 1;
14301583 mainPanel.add(objectPanel, aConstraints);
1431
- */
1584
+ */
14321585
14331586 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14341587 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1440,14 +1593,12 @@
14401593 scrollpane.addMouseWheelListener(this); // Default not fast enough
14411594
14421595 /*JTabbedPane*/ scenePanel = new cGridBag();
1443
- scenePanel.preferredWidth = 6;
1596
+ scenePanel.preferredWidth = 5;
14441597
14451598 JTabbedPane tabbedPane = new JTabbedPane();
14461599 tabbedPane.add(scrollpane);
14471600
1448
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1449
-
1450
- optionsPanel = new cGridBag().setVertical(true);
1601
+ optionsPanel = new cGridBag().setVertical(false);
14511602
14521603 optionsPanel.setName("Options");
14531604
....@@ -1455,6 +1606,8 @@
14551606
14561607 tabbedPane.add(optionsPanel);
14571608
1609
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1610
+
14581611 scenePanel.add(tabbedPane);
14591612
14601613 /*
....@@ -1518,7 +1671,7 @@
15181671 bigThree = new cGridBag();
15191672 bigThree.addComponent(scenePanel);
15201673 bigThree.addComponent(centralPanel);
1521
- bigThree.addComponent(XYZPanel);
1674
+ //bigThree.addComponent(XYZPanel);
15221675
15231676 // // SIDE EFFECT!!!
15241677 // aConstraints.gridx = 0;
....@@ -1527,9 +1680,9 @@
15271680 // aConstraints.gridheight = 1;
15281681
15291682 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1530
- framePanel.setContinuousLayout(true);
1531
- framePanel.setOneTouchExpandable(true);
1532
- framePanel.setDividerLocation(0.8);
1683
+ framePanel.setContinuousLayout(false);
1684
+ framePanel.setOneTouchExpandable(false);
1685
+ //.setDividerLocation(0.8);
15331686 //framePanel.setDividerSize(15);
15341687 //framePanel.setResizeWeight(0.15);
15351688 framePanel.setName("Frame");
....@@ -1547,16 +1700,18 @@
15471700 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15481701
15491702 frame.setSize(1280, 860);
1550
- frame.setVisible(true);
1551
-
1703
+
15521704 cameraView.requestFocusInWindow();
15531705
15541706 gridPanel.setDividerLocation(1.0);
1707
+
1708
+ frame.validate();
1709
+
1710
+ frame.setVisible(true);
15551711
15561712 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15571713 frame.addWindowListener(new WindowAdapter()
15581714 {
1559
-
15601715 public void windowClosing(WindowEvent e)
15611716 {
15621717 Close();
....@@ -1618,45 +1773,48 @@
16181773 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16191774
16201775 cGridBag colorSection = new cGridBag().setVertical(true);
1776
+
1777
+ cGridBag huepanel = new cGridBag();
1778
+ cGridBag huelabel = new cGridBag();
1779
+ huelabel.add(GetLabel("icons/hue.png", false));
1780
+ huelabel.preferredWidth = 20;
1781
+ huepanel.add(new cGridBag()); // Label
1782
+ huepanel.add(huelabel); // Field/slider
1783
+
1784
+ huepanel.preferredHeight = 7;
1785
+
1786
+ colorSection.add(huepanel);
16211787
16221788 cGridBag color = new cGridBag();
1623
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1624
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1789
+
1790
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1791
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1792
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1793
+
16261794 //colorField.preferredWidth = 200;
16271795 colorSection.add(color);
16281796
16291797 cGridBag modulation = new cGridBag();
16301798 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16311799 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1632
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1800
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16331801 colorSection.add(modulation);
16341802
1803
+ cGridBag opacity = new cGridBag();
1804
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1805
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1806
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1807
+ colorSection.add(opacity);
1808
+
1809
+ colorSection.add(GetSeparator());
1810
+
16351811 cGridBag texture = new cGridBag();
16361812 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16371813 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16381814 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16391815 colorSection.add(texture);
16401816
1641
- cGridBag anisoU = new cGridBag();
1642
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1643
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1644
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1645
- colorSection.add(anisoU);
1646
-
1647
- cGridBag anisoV = new cGridBag();
1648
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1649
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1650
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1651
- colorSection.add(anisoV);
1652
-
1653
- cGridBag shadowbias = new cGridBag();
1654
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1655
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1656
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1657
- colorSection.add(shadowbias);
1658
-
1659
- panel.add(new JSeparator());
1817
+ panel.add(GetSeparator());
16601818
16611819 panel.add(colorSection);
16621820
....@@ -1706,7 +1864,13 @@
17061864 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17071865 diffuseSection.add(fakedepth);
17081866
1709
- panel.add(new JSeparator());
1867
+ cGridBag shadowbias = new cGridBag();
1868
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1869
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1871
+ diffuseSection.add(shadowbias);
1872
+
1873
+ panel.add(GetSeparator());
17101874
17111875 panel.add(diffuseSection);
17121876
....@@ -1756,42 +1920,48 @@
17561920 // aConstraints.gridy += 1;
17571921 // aConstraints.gridwidth = 1;
17581922
1923
+ cGridBag anisoU = new cGridBag();
1924
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1925
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1926
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1927
+ specularSection.add(anisoU);
17591928
1760
- panel.add(new JSeparator());
1929
+ cGridBag anisoV = new cGridBag();
1930
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1931
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1932
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1933
+ specularSection.add(anisoV);
1934
+
1935
+
1936
+ panel.add(GetSeparator());
17611937
17621938 panel.add(specularSection);
17631939
17641940 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17651941
1766
- cGridBag globalSection = new cGridBag().setVertical(true);
1942
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17671943
17681944 cGridBag camera = new cGridBag();
17691945 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17701946 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17711947 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1772
- globalSection.add(camera);
1948
+ colorSection.add(camera);
17731949
17741950 cGridBag ambient = new cGridBag();
17751951 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17761952 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17771953 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1778
- globalSection.add(ambient);
1954
+ colorSection.add(ambient);
17791955
17801956 cGridBag backlit = new cGridBag();
17811957 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17821958 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17831959 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1784
- globalSection.add(backlit);
1960
+ colorSection.add(backlit);
17851961
1786
- cGridBag opacity = new cGridBag();
1787
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1788
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1789
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1790
- globalSection.add(opacity);
1791
-
1792
- panel.add(new JSeparator());
1962
+ //panel.add(new JSeparator());
17931963
1794
- panel.add(globalSection);
1964
+ //panel.add(globalSection);
17951965
17961966 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17971967
....@@ -1833,7 +2003,7 @@
18332003 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18342004 textureSection.add(opacityPower);
18352005
1836
- panel.add(new JSeparator());
2006
+ panel.add(GetSeparator());
18372007
18382008 panel.add(textureSection);
18392009
....@@ -1898,8 +2068,9 @@
18982068 // 3D models
18992069 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19002070 {
1901
- lastConverter = new com.jmex.model.converters.MaxToJme();
1902
- LoadFile(filename, lastConverter);
2071
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2072
+ //LoadFile(filename, lastConverter);
2073
+ LoadObjFile(filename); // New 3ds loader
19032074 continue;
19042075 }
19052076 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2625,6 +2796,7 @@
26252796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26262797 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26272798 }
2799
+
26282800 //cJME.count++;
26292801 //cJME.count %= 12;
26302802 if (gc)
....@@ -2808,6 +2980,7 @@
28082980 }
28092981 }
28102982 }
2983
+
28112984 cFileSystemPane FSPane;
28122985
28132986 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2861,11 +3034,14 @@
28613034 }
28623035 }
28633036 }
3037
+
28643038 freezematerial = false;
28653039 }
28663040
28673041 void SetMaterial(Object3D object)
28683042 {
3043
+ latestObject = object;
3044
+
28693045 cMaterial mat = object.material;
28703046
28713047 if (mat == null)
....@@ -2977,12 +3153,17 @@
29773153 // }
29783154
29793155 /**/
2980
- if (deselect)
3156
+ if (deselect || child == null)
29813157 {
29823158 //group.deselectAll();
29833159 //freeze = true;
29843160 GetTree().clearSelection();
29853161 //freeze = false;
3162
+
3163
+ if (child == null)
3164
+ {
3165
+ return;
3166
+ }
29863167 }
29873168
29883169 //group.addSelectee(child);
....@@ -3051,7 +3232,7 @@
30513232 cameraView.ToggleDL();
30523233 cameraView.repaint();
30533234 return;
3054
- } else if (event.getSource() == toggleTextureItem)
3235
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30553236 {
30563237 cameraView.ToggleTexture();
30573238 // june 2013 copy.HardTouch();
....@@ -3090,7 +3271,7 @@
30903271 frame.validate();
30913272
30923273 return;
3093
- } else if (event.getSource() == toggleSwitchItem)
3274
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30943275 {
30953276 cameraView.ToggleSwitch();
30963277 cameraView.repaint();
....@@ -3121,7 +3302,7 @@
31213302 {
31223303 copy.live ^= true;
31233304 return;
3124
- } else if (event.getSource() == selectCB)
3305
+ } else if (event.getSource() == selectableCB)
31253306 {
31263307 copy.dontselect ^= true;
31273308 return;
....@@ -3306,9 +3487,9 @@
33063487 {
33073488 Close();
33083489 //return true;
3309
- } else if (source == loadItem)
3490
+ } else if (source == openItem)
33103491 {
3311
- load();
3492
+ Open();
33123493 //return true;
33133494 } else if (source == newItem)
33143495 {
....@@ -3333,6 +3514,10 @@
33333514 {
33343515 generatePOV();
33353516 //return true;
3517
+ } else if (event.getSource() == archiveItem)
3518
+ {
3519
+ cTools.Archive(frame);
3520
+ return;
33363521 } else if (source == zBufferItem)
33373522 {
33383523 try
....@@ -3381,11 +3566,12 @@
33813566
33823567 static public byte[] Compress(Object3D o)
33833568 {
3569
+ // Slower to actually compress.
33843570 try
33853571 {
33863572 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3387
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3388
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3573
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3574
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33893575
33903576 Object3D parent = o.parent;
33913577 o.parent = null;
....@@ -3396,10 +3582,14 @@
33963582
33973583 out.flush();
33983584
3399
- zstream.close();
3585
+ baos //zstream
3586
+ .close();
34003587 out.close();
34013588
3402
- return baos.toByteArray();
3589
+ byte[] bytes = baos.toByteArray();
3590
+
3591
+ System.out.println("save #bytes = " + bytes.length);
3592
+ return bytes;
34033593 } catch (Exception e)
34043594 {
34053595 System.err.println(e);
....@@ -3409,13 +3599,16 @@
34093599
34103600 static public Object Uncompress(byte[] bytes)
34113601 {
3412
- System.out.println("#bytes = " + bytes.length);
3602
+ System.out.println("restore #bytes = " + bytes.length);
34133603 try
34143604 {
34153605 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3416
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3417
- ObjectInputStream in = new ObjectInputStream(istream);
3606
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3607
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34183608 Object obj = in.readObject();
3609
+
3610
+ bais //istream
3611
+ .close();
34193612 in.close();
34203613
34213614 return obj;
....@@ -3470,39 +3663,76 @@
34703663 return null;
34713664 }
34723665
3473
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34743666
34753667 public void Save()
3668
+ {
3669
+ //Save(true);
3670
+ Replace();
3671
+ }
3672
+
3673
+ private boolean Equal(byte[] compress, byte[] name)
3674
+ {
3675
+ if (compress.length != name.length)
3676
+ {
3677
+ return false;
3678
+ }
3679
+
3680
+ for (int i=compress.length; --i>=0;)
3681
+ {
3682
+ if (compress[i] != name[i])
3683
+ return false;
3684
+ }
3685
+
3686
+ return true;
3687
+ }
3688
+
3689
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3690
+
3691
+ public boolean Save(boolean user)
34763692 {
34773693 System.err.println("Save");
34783694
34793695 cRadio tab = GetCurrentTab();
34803696
3481
- boolean temp = CameraPane.SWITCH;
3482
- CameraPane.SWITCH = false;
3697
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
34833698
3484
- copy.ExtractBigData(hashtable);
3699
+ boolean thesame = false;
3700
+
3701
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3702
+// {
3703
+// thesame = true;
3704
+// }
34853705
34863706 //EditorFrame.m_MainFrame.requestFocusInWindow();
3487
- tab.graphs[tab.undoindex++] = Compress(copy);
3488
-
3489
- copy.RestoreBigData(hashtable);
3490
-
3491
- CameraPane.SWITCH = temp;
3492
-
3493
- //assert(hashtable.isEmpty());
3494
-
3495
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3707
+ if (!thesame)
34963708 {
3497
- tab.graphs[i] = null;
3709
+ //tab.user[tab.versionindex] = user;
3710
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3711
+
3712
+ copy.versions[++copy.versionindex] = compress;
3713
+
3714
+ // if (increment)
3715
+ // tab.versionindex++;
34983716 }
34993717
3718
+ //copy.RestoreBigData(versiontable);
3719
+
3720
+ //assert(hashtable.isEmpty());
3721
+
3722
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3723
+ {
3724
+ //tab.user[i] = false;
3725
+ copy.versions[i] = null;
3726
+ }
3727
+
3728
+ SetUndoStates();
3729
+
35003730 // test save
35013731 if (false)
35023732 {
35033733 try
35043734 {
3505
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3735
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35063736 ObjectOutputStream p = new ObjectOutputStream(ostream);
35073737
35083738 p.writeObject(copy);
....@@ -3515,23 +3745,30 @@
35153745 e.printStackTrace();
35163746 }
35173747 }
3748
+
3749
+ return !thesame;
35183750 }
35193751
35203752 void CopyChanged(Object3D obj)
35213753 {
3754
+ SetUndoStates();
3755
+
35223756 boolean temp = CameraPane.SWITCH;
35233757 CameraPane.SWITCH = false;
35243758
3525
- copy.ExtractBigData(hashtable);
3759
+ copy.ExtractBigData(versiontable);
35263760
35273761 copy.clear();
35283762
3763
+ copy.skyboxname = obj.skyboxname;
3764
+ copy.skyboxext = obj.skyboxext;
3765
+
35293766 for (int i=0; i<obj.Size(); i++)
35303767 {
35313768 copy.add(obj.get(i));
35323769 }
35333770
3534
- copy.RestoreBigData(hashtable);
3771
+ copy.RestoreBigData(versiontable);
35353772
35363773 CameraPane.SWITCH = temp;
35373774
....@@ -3558,42 +3795,131 @@
35583795 refreshContents();
35593796 }
35603797
3561
- public void Undo()
3798
+ cButton undoButton;
3799
+ cButton restoreButton;
3800
+ cButton replaceButton;
3801
+ cButton redoButton;
3802
+
3803
+ boolean muteSlider;
3804
+
3805
+ int VersionCount()
35623806 {
3807
+ int count = 0;
3808
+
3809
+ for (int i = copy.versions.length; --i >= 0;)
3810
+ {
3811
+ if (copy.versions[i] != null)
3812
+ count++;
3813
+ }
3814
+
3815
+ return count;
3816
+ }
3817
+
3818
+ void SetUndoStates()
3819
+ {
3820
+ cRadio tab = GetCurrentTab();
3821
+
3822
+ restoreButton.setEnabled(copy.versionindex != -1);
3823
+ replaceButton.setEnabled(copy.versionindex != -1);
3824
+
3825
+ undoButton.setEnabled(copy.versionindex > 0);
3826
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3827
+
3828
+ muteSlider = true;
3829
+ versionSlider.setMaximum(VersionCount() - 1);
3830
+ versionSlider.setInteger(copy.versionindex);
3831
+ muteSlider = false;
3832
+ }
3833
+
3834
+ public boolean Undo()
3835
+ {
3836
+ // Option?
3837
+ Replace();
3838
+
35633839 System.err.println("Undo");
35643840
35653841 cRadio tab = GetCurrentTab();
35663842
3567
- if (tab.undoindex == 0)
3843
+ if (copy.versionindex == 0)
35683844 {
35693845 java.awt.Toolkit.getDefaultToolkit().beep();
3570
- return;
3846
+ return false;
35713847 }
35723848
3573
- if (tab.graphs[tab.undoindex] == null)
3849
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3850
+// {
3851
+// if (Save(false))
3852
+// tab.versionindex -= 1;
3853
+// else
3854
+// {
3855
+// if (tab.versionindex <= 0)
3856
+// return false;
3857
+// else
3858
+// tab.versionindex -= 1;
3859
+// }
3860
+// }
3861
+
3862
+ copy.versionindex -= 1;
3863
+
3864
+ CopyChanged((Object3D)copy.versions[copy.versionindex]);
3865
+
3866
+ return true;
3867
+ }
3868
+
3869
+ public boolean Restore()
3870
+ {
3871
+ System.err.println("Restore");
3872
+
3873
+ cRadio tab = GetCurrentTab();
3874
+
3875
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
35743876 {
3575
- Save();
3576
- tab.undoindex -= 1;
3877
+ java.awt.Toolkit.getDefaultToolkit().beep();
3878
+ return false;
35773879 }
35783880
3579
- tab.undoindex -= 1;
3881
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
+ CopyChanged(copy.versions[copy.versionindex]);
3883
+
3884
+ return true;
3885
+ }
35803886
3581
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3887
+ public boolean Replace()
3888
+ {
3889
+ System.err.println("Replace");
3890
+
3891
+ cRadio tab = GetCurrentTab();
3892
+
3893
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3894
+ {
3895
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3896
+ return false;
3897
+ }
3898
+
3899
+ copy.versions[copy.versionindex] = CompressCopy();
3900
+
3901
+ return true;
35823902 }
35833903
35843904 public void Redo()
35853905 {
3906
+ // Option?
3907
+ Replace();
3908
+
35863909 cRadio tab = GetCurrentTab();
35873910
3588
- if (tab.graphs[tab.undoindex + 1] == null)
3911
+ if (copy.versions[copy.versionindex + 1] == null)
35893912 {
35903913 java.awt.Toolkit.getDefaultToolkit().beep();
35913914 return;
35923915 }
35933916
3594
- tab.undoindex += 1;
3917
+ copy.versionindex += 1;
35953918
3596
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3919
+ CopyChanged(copy.versions[copy.versionindex]);
3920
+
3921
+ //if (!tab.user[tab.versionindex])
3922
+ // tab.graphs[tab.versionindex] = null;
35973923 }
35983924
35993925 void ImportGFD()
....@@ -3889,9 +4215,25 @@
38894215 //copy.Touch();
38904216 }
38914217
4218
+ cNumberSlider versionSlider;
4219
+
38924220 public void stateChanged(ChangeEvent e)
38934221 {
38944222 // assert(false);
4223
+ if (e.getSource() == versionSlider)
4224
+ {
4225
+ if (muteSlider)
4226
+ return;
4227
+
4228
+ int version = versionSlider.getInteger();
4229
+
4230
+ if (copy.versions[version] != null)
4231
+ {
4232
+ CopyChanged(copy.versions[copy.versionindex = version]);
4233
+ }
4234
+
4235
+ return;
4236
+ }
38954237
38964238 if (freezematerial)
38974239 {
....@@ -4240,7 +4582,7 @@
42404582
42414583 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42424584 {
4243
- if (Globals.SAVEONMAKE) // && resetmodel)
4585
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42444586 Save();
42454587 //Tween.set(thing, 0).target(1).start(tweenManager);
42464588 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4482,7 +4824,9 @@
44824824 readobj.ResetDisplayList();
44834825 } catch (Exception e)
44844826 {
4485
- //e.printStackTrace();
4827
+ if (!e.toString().contains("GZIP"))
4828
+ e.printStackTrace();
4829
+
44864830 try
44874831 {
44884832 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4556,12 +4900,14 @@
45564900
45574901 if (readobj != null)
45584902 {
4559
- if (Globals.SAVEONMAKE)
4560
- Save();
4903
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4904
+ // Save();
45614905 try
45624906 {
45634907 //readobj.deepCopySelf(copy);
45644908 copy.clear(); // june 2014
4909
+ copy.skyboxname = readobj.skyboxname;
4910
+ copy.skyboxext = readobj.skyboxext;
45654911 for (int i = 0; i < readobj.size(); i++)
45664912 {
45674913 Object3D child = readobj.get(i); // reserve(i);
....@@ -4602,6 +4948,7 @@
46024948 }
46034949 } catch (ClassCastException e)
46044950 {
4951
+ e.printStackTrace();
46054952 assert (false);
46064953 Composite c = (Composite) copy;
46074954 c.children.clear();
....@@ -4612,13 +4959,24 @@
46124959 c.addChild(csg);
46134960 }
46144961
4962
+ copy.versions = readobj.versions;
4963
+ copy.versionindex = readobj.versionindex;
4964
+
4965
+ if (copy.versions == null)
4966
+ {
4967
+ copy.versions = new Object3D[100];
4968
+ copy.versionindex = -1;
4969
+ }
4970
+
4971
+ //? SetUndoStates();
4972
+
46154973 ResetModel();
46164974 copy.HardTouch(); // recompile?
46174975 refreshContents();
46184976 }
46194977 }
46204978
4621
- void load() // throws ClassNotFoundException
4979
+ void Open() // throws ClassNotFoundException
46224980 {
46234981 if (Grafreed.standAlone)
46244982 {
....@@ -4721,6 +5079,7 @@
47215079 //ps.print(buffer.toString());
47225080 } catch (IOException e)
47235081 {
5082
+ e.printStackTrace();
47245083 }
47255084 }
47265085
....@@ -4735,6 +5094,8 @@
47355094 String filename = browser.getFile();
47365095 if (filename != null && filename.length() > 0)
47375096 {
5097
+ if (!filename.endsWith(".gfd"))
5098
+ filename += ".gfd";
47385099 lastname = browser.getDirectory() + filename;
47395100 save();
47405101 }
....@@ -4901,7 +5262,7 @@
49015262 MenuBar menuBar;
49025263 Menu fileMenu;
49035264 MenuItem newItem;
4904
- MenuItem loadItem;
5265
+ MenuItem openItem;
49055266 MenuItem saveItem;
49065267 MenuItem saveAsItem;
49075268 MenuItem exportAsItem;
....@@ -4924,6 +5285,7 @@
49245285 CheckboxMenuItem toggleSwitchItem;
49255286 CheckboxMenuItem toggleRootItem;
49265287 CheckboxMenuItem animationItem;
5288
+ MenuItem archiveItem;
49275289 CheckboxMenuItem toggleHandleItem;
49285290 CheckboxMenuItem togglePaintItem;
49295291 JSplitPane mainPanel;
....@@ -4945,6 +5307,8 @@
49455307 cGridBag optionsPanel;
49465308
49475309 JTabbedPane objectPanel;
5310
+ boolean materialFlushed;
5311
+ Object3D latestObject;
49485312
49495313 cGridBag XYZPanel;
49505314