Normand Briere
2019-08-01 29d5516687020263d3ae0454ce81879a3a450af0
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 byte[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 byte[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,30 @@
742847 radio.layout.doClick();
743848 //frame.setVisible(true);
744849 }
745
-
746
- cameraView.ToggleFullScreen();
850
+ frame.validate();
747851 }
852
+
853
+ private byte[] CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ byte[] versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ byte[] compress = Compress(copy);
865
+
866
+ copy.versions = versions;
867
+
868
+ copy.RestoreBigData(versiontable);
869
+
870
+ CameraPane.SWITCH = temp;
871
+
872
+ return compress;
873
+ }
748874
749875 private JTextPane createTextPane()
750876 {
....@@ -876,7 +1002,7 @@
8761002 // NumberSlider vDivsField;
8771003 // JCheckBox endcaps;
8781004 JCheckBox liveCB;
879
- JCheckBox selectCB;
1005
+ JCheckBox selectableCB;
8801006 JCheckBox hideCB;
8811007 JCheckBox link2masterCB;
8821008 JCheckBox markCB;
....@@ -884,7 +1010,12 @@
8841010 JCheckBox speedupCB;
8851011 JCheckBox rewindCB;
8861012 JCheckBox flipVCB;
1013
+
1014
+ cCheckBox toggleTextureCB;
1015
+ cCheckBox toggleSwitchCB;
1016
+
8871017 JComboBox texresMenu;
1018
+
8881019 JButton resetButton;
8891020 JButton stepButton;
8901021 JButton stepAllButton;
....@@ -1071,38 +1202,42 @@
10711202 namePanel = new cGridBag();
10721203
10731204 nameField = AddText(namePanel, copy.GetName());
1074
- namePanel.add(nameField);
1205
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10751206 oe.ctrlPanel.add(namePanel);
10761207
10771208 oe.ctrlPanel.Return();
10781209
1079
- if (!GroupEditor.allparams)
1210
+ if (!allparams)
10801211 return;
10811212
10821213 setupPanel = new cGridBag().setVertical(false);
10831214
10841215 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10851216 liveCB.setToolTipText("Animate object");
1086
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1087
- selectCB.setToolTipText("Make object selectable");
1217
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1218
+ selectableCB.setToolTipText("Make object selectable");
10881219 // Return();
1220
+
10891221 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10901222 hideCB.setToolTipText("Hide object");
10911223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1092
- markCB.setToolTipText("Set the animation target transform");
1224
+ markCB.setToolTipText("As animation target transform");
1225
+
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10931227
10941228 setupPanel2 = new cGridBag().setVertical(false);
10951229
10961230 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10971231 rewindCB.setToolTipText("Rewind animation");
10981232
1099
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1100
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1233
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1234
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11011235
1236
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1237
+ link2masterCB.setToolTipText("Attach to support");
1238
+
11021239 if (Globals.ADVANCED)
11031240 {
1104
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1105
- link2masterCB.setToolTipText("Attach to support");
11061241 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11071242 speedupCB.setToolTipText("Option motion capture");
11081243 }
....@@ -1376,6 +1511,7 @@
13761511 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13771512 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13781513 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1514
+ //XYZPanel.setName("XYZ");
13791515
13801516 /*
13811517 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1412,14 +1548,30 @@
14121548
14131549 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14141550 //tmp.setName("Edit");
1415
- objectPanel.add(toolboxPanel);
14161551 objectPanel.add(materialPanel);
1552
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
14171555 // JPanel north = new JPanel(new BorderLayout());
14181556 // north.setName("Edit");
14191557 // north.add(ctrlPanel, BorderLayout.NORTH);
14201558 // objectPanel.add(north);
14211559 objectPanel.add(editPanel);
1422
- objectPanel.add(infoPanel);
1560
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
1562
+
1563
+ //if (Globals.ADVANCED)
1564
+ objectPanel.add(infoPanel);
1565
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
1567
+
1568
+ objectPanel.add(XYZPanel);
1569
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1571
+
1572
+ objectPanel.add(toolboxPanel);
1573
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
14231575
14241576 /*
14251577 aConstraints.gridx = 0;
....@@ -1428,7 +1580,7 @@
14281580 aConstraints.gridy += 1;
14291581 aConstraints.gridwidth = 1;
14301582 mainPanel.add(objectPanel, aConstraints);
1431
- */
1583
+ */
14321584
14331585 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14341586 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1440,14 +1592,12 @@
14401592 scrollpane.addMouseWheelListener(this); // Default not fast enough
14411593
14421594 /*JTabbedPane*/ scenePanel = new cGridBag();
1443
- scenePanel.preferredWidth = 6;
1595
+ scenePanel.preferredWidth = 5;
14441596
14451597 JTabbedPane tabbedPane = new JTabbedPane();
14461598 tabbedPane.add(scrollpane);
14471599
1448
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1449
-
1450
- optionsPanel = new cGridBag().setVertical(true);
1600
+ optionsPanel = new cGridBag().setVertical(false);
14511601
14521602 optionsPanel.setName("Options");
14531603
....@@ -1455,6 +1605,8 @@
14551605
14561606 tabbedPane.add(optionsPanel);
14571607
1608
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1609
+
14581610 scenePanel.add(tabbedPane);
14591611
14601612 /*
....@@ -1518,7 +1670,7 @@
15181670 bigThree = new cGridBag();
15191671 bigThree.addComponent(scenePanel);
15201672 bigThree.addComponent(centralPanel);
1521
- bigThree.addComponent(XYZPanel);
1673
+ //bigThree.addComponent(XYZPanel);
15221674
15231675 // // SIDE EFFECT!!!
15241676 // aConstraints.gridx = 0;
....@@ -1527,9 +1679,9 @@
15271679 // aConstraints.gridheight = 1;
15281680
15291681 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1530
- framePanel.setContinuousLayout(true);
1531
- framePanel.setOneTouchExpandable(true);
1532
- framePanel.setDividerLocation(0.8);
1682
+ framePanel.setContinuousLayout(false);
1683
+ framePanel.setOneTouchExpandable(false);
1684
+ //.setDividerLocation(0.8);
15331685 //framePanel.setDividerSize(15);
15341686 //framePanel.setResizeWeight(0.15);
15351687 framePanel.setName("Frame");
....@@ -1547,16 +1699,18 @@
15471699 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15481700
15491701 frame.setSize(1280, 860);
1550
- frame.setVisible(true);
1551
-
1702
+
15521703 cameraView.requestFocusInWindow();
15531704
15541705 gridPanel.setDividerLocation(1.0);
1706
+
1707
+ frame.validate();
1708
+
1709
+ frame.setVisible(true);
15551710
15561711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15571712 frame.addWindowListener(new WindowAdapter()
15581713 {
1559
-
15601714 public void windowClosing(WindowEvent e)
15611715 {
15621716 Close();
....@@ -1618,45 +1772,48 @@
16181772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16191773
16201774 cGridBag colorSection = new cGridBag().setVertical(true);
1775
+
1776
+ cGridBag huepanel = new cGridBag();
1777
+ cGridBag huelabel = new cGridBag();
1778
+ huelabel.add(GetLabel("icons/hue.png", false));
1779
+ huelabel.preferredWidth = 20;
1780
+ huepanel.add(new cGridBag()); // Label
1781
+ huepanel.add(huelabel); // Field/slider
1782
+
1783
+ huepanel.preferredHeight = 7;
1784
+
1785
+ colorSection.add(huepanel);
16211786
16221787 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);
1788
+
1789
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1790
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1791
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1792
+
16261793 //colorField.preferredWidth = 200;
16271794 colorSection.add(color);
16281795
16291796 cGridBag modulation = new cGridBag();
16301797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16311798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1632
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16331800 colorSection.add(modulation);
16341801
1802
+ cGridBag opacity = new cGridBag();
1803
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1804
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1805
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1806
+ colorSection.add(opacity);
1807
+
1808
+ colorSection.add(GetSeparator());
1809
+
16351810 cGridBag texture = new cGridBag();
16361811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16371812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16381813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16391814 colorSection.add(texture);
16401815
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());
1816
+ panel.add(GetSeparator());
16601817
16611818 panel.add(colorSection);
16621819
....@@ -1706,7 +1863,13 @@
17061863 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17071864 diffuseSection.add(fakedepth);
17081865
1709
- panel.add(new JSeparator());
1866
+ cGridBag shadowbias = new cGridBag();
1867
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1868
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1869
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1870
+ diffuseSection.add(shadowbias);
1871
+
1872
+ panel.add(GetSeparator());
17101873
17111874 panel.add(diffuseSection);
17121875
....@@ -1756,42 +1919,48 @@
17561919 // aConstraints.gridy += 1;
17571920 // aConstraints.gridwidth = 1;
17581921
1922
+ cGridBag anisoU = new cGridBag();
1923
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1924
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1925
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1926
+ specularSection.add(anisoU);
17591927
1760
- panel.add(new JSeparator());
1928
+ cGridBag anisoV = new cGridBag();
1929
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1930
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1931
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1932
+ specularSection.add(anisoV);
1933
+
1934
+
1935
+ panel.add(GetSeparator());
17611936
17621937 panel.add(specularSection);
17631938
17641939 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17651940
1766
- cGridBag globalSection = new cGridBag().setVertical(true);
1941
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17671942
17681943 cGridBag camera = new cGridBag();
17691944 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17701945 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17711946 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1772
- globalSection.add(camera);
1947
+ colorSection.add(camera);
17731948
17741949 cGridBag ambient = new cGridBag();
17751950 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17761951 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17771952 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1778
- globalSection.add(ambient);
1953
+ colorSection.add(ambient);
17791954
17801955 cGridBag backlit = new cGridBag();
17811956 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17821957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17831958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1784
- globalSection.add(backlit);
1959
+ colorSection.add(backlit);
17851960
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());
1961
+ //panel.add(new JSeparator());
17931962
1794
- panel.add(globalSection);
1963
+ //panel.add(globalSection);
17951964
17961965 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17971966
....@@ -1833,7 +2002,7 @@
18332002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18342003 textureSection.add(opacityPower);
18352004
1836
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
18372006
18382007 panel.add(textureSection);
18392008
....@@ -1898,8 +2067,9 @@
18982067 // 3D models
18992068 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19002069 {
1901
- lastConverter = new com.jmex.model.converters.MaxToJme();
1902
- LoadFile(filename, lastConverter);
2070
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2071
+ //LoadFile(filename, lastConverter);
2072
+ LoadObjFile(filename); // New 3ds loader
19032073 continue;
19042074 }
19052075 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2625,6 +2795,7 @@
26252795 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26262796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26272797 }
2798
+
26282799 //cJME.count++;
26292800 //cJME.count %= 12;
26302801 if (gc)
....@@ -2808,6 +2979,7 @@
28082979 }
28092980 }
28102981 }
2982
+
28112983 cFileSystemPane FSPane;
28122984
28132985 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2861,11 +3033,14 @@
28613033 }
28623034 }
28633035 }
3036
+
28643037 freezematerial = false;
28653038 }
28663039
28673040 void SetMaterial(Object3D object)
28683041 {
3042
+ latestObject = object;
3043
+
28693044 cMaterial mat = object.material;
28703045
28713046 if (mat == null)
....@@ -2977,12 +3152,17 @@
29773152 // }
29783153
29793154 /**/
2980
- if (deselect)
3155
+ if (deselect || child == null)
29813156 {
29823157 //group.deselectAll();
29833158 //freeze = true;
29843159 GetTree().clearSelection();
29853160 //freeze = false;
3161
+
3162
+ if (child == null)
3163
+ {
3164
+ return;
3165
+ }
29863166 }
29873167
29883168 //group.addSelectee(child);
....@@ -3051,7 +3231,7 @@
30513231 cameraView.ToggleDL();
30523232 cameraView.repaint();
30533233 return;
3054
- } else if (event.getSource() == toggleTextureItem)
3234
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30553235 {
30563236 cameraView.ToggleTexture();
30573237 // june 2013 copy.HardTouch();
....@@ -3090,7 +3270,7 @@
30903270 frame.validate();
30913271
30923272 return;
3093
- } else if (event.getSource() == toggleSwitchItem)
3273
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30943274 {
30953275 cameraView.ToggleSwitch();
30963276 cameraView.repaint();
....@@ -3121,7 +3301,7 @@
31213301 {
31223302 copy.live ^= true;
31233303 return;
3124
- } else if (event.getSource() == selectCB)
3304
+ } else if (event.getSource() == selectableCB)
31253305 {
31263306 copy.dontselect ^= true;
31273307 return;
....@@ -3306,9 +3486,9 @@
33063486 {
33073487 Close();
33083488 //return true;
3309
- } else if (source == loadItem)
3489
+ } else if (source == openItem)
33103490 {
3311
- load();
3491
+ Open();
33123492 //return true;
33133493 } else if (source == newItem)
33143494 {
....@@ -3333,6 +3513,10 @@
33333513 {
33343514 generatePOV();
33353515 //return true;
3516
+ } else if (event.getSource() == archiveItem)
3517
+ {
3518
+ cTools.Archive(frame);
3519
+ return;
33363520 } else if (source == zBufferItem)
33373521 {
33383522 try
....@@ -3384,8 +3568,8 @@
33843568 try
33853569 {
33863570 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3387
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3388
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3571
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3572
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33893573
33903574 Object3D parent = o.parent;
33913575 o.parent = null;
....@@ -3396,10 +3580,14 @@
33963580
33973581 out.flush();
33983582
3399
- zstream.close();
3583
+ baos //zstream
3584
+ .close();
34003585 out.close();
34013586
3402
- return baos.toByteArray();
3587
+ byte[] bytes = baos.toByteArray();
3588
+
3589
+ System.out.println("save #bytes = " + bytes.length);
3590
+ return bytes;
34033591 } catch (Exception e)
34043592 {
34053593 System.err.println(e);
....@@ -3409,13 +3597,16 @@
34093597
34103598 static public Object Uncompress(byte[] bytes)
34113599 {
3412
- System.out.println("#bytes = " + bytes.length);
3600
+ System.out.println("restore #bytes = " + bytes.length);
34133601 try
34143602 {
34153603 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3416
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3417
- ObjectInputStream in = new ObjectInputStream(istream);
3604
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3605
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34183606 Object obj = in.readObject();
3607
+
3608
+ bais //istream
3609
+ .close();
34193610 in.close();
34203611
34213612 return obj;
....@@ -3470,39 +3661,77 @@
34703661 return null;
34713662 }
34723663
3473
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34743664
34753665 public void Save()
3666
+ {
3667
+ //Save(true);
3668
+ Replace();
3669
+ }
3670
+
3671
+ private boolean Equal(byte[] compress, byte[] name)
3672
+ {
3673
+ if (compress.length != name.length)
3674
+ {
3675
+ return false;
3676
+ }
3677
+
3678
+ for (int i=compress.length; --i>=0;)
3679
+ {
3680
+ if (compress[i] != name[i])
3681
+ return false;
3682
+ }
3683
+
3684
+ return true;
3685
+ }
3686
+
3687
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3688
+
3689
+ public boolean Save(boolean user)
34763690 {
34773691 System.err.println("Save");
34783692
34793693 cRadio tab = GetCurrentTab();
34803694
3481
- boolean temp = CameraPane.SWITCH;
3482
- CameraPane.SWITCH = false;
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
34833696
3484
- copy.ExtractBigData(hashtable);
3697
+ boolean thesame = false;
3698
+
3699
+ // Quick heuristic using length. Works only when stream is compressed.
3700
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3701
+ {
3702
+ thesame = true;
3703
+ }
34853704
34863705 //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++)
3706
+ if (!thesame)
34963707 {
3497
- tab.graphs[i] = null;
3708
+ //tab.user[tab.versionindex] = user;
3709
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3710
+
3711
+ copy.versions[++copy.versionindex] = compress;
3712
+
3713
+ // if (increment)
3714
+ // tab.versionindex++;
34983715 }
34993716
3717
+ //copy.RestoreBigData(versiontable);
3718
+
3719
+ //assert(hashtable.isEmpty());
3720
+
3721
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3722
+ {
3723
+ //tab.user[i] = false;
3724
+ copy.versions[i] = null;
3725
+ }
3726
+
3727
+ SetUndoStates();
3728
+
35003729 // test save
35013730 if (false)
35023731 {
35033732 try
35043733 {
3505
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3734
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35063735 ObjectOutputStream p = new ObjectOutputStream(ostream);
35073736
35083737 p.writeObject(copy);
....@@ -3515,23 +3744,30 @@
35153744 e.printStackTrace();
35163745 }
35173746 }
3747
+
3748
+ return !thesame;
35183749 }
35193750
35203751 void CopyChanged(Object3D obj)
35213752 {
3753
+ SetUndoStates();
3754
+
35223755 boolean temp = CameraPane.SWITCH;
35233756 CameraPane.SWITCH = false;
35243757
3525
- copy.ExtractBigData(hashtable);
3758
+ copy.ExtractBigData(versiontable);
35263759
35273760 copy.clear();
35283761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
35293765 for (int i=0; i<obj.Size(); i++)
35303766 {
35313767 copy.add(obj.get(i));
35323768 }
35333769
3534
- copy.RestoreBigData(hashtable);
3770
+ copy.RestoreBigData(versiontable);
35353771
35363772 CameraPane.SWITCH = temp;
35373773
....@@ -3558,42 +3794,130 @@
35583794 refreshContents();
35593795 }
35603796
3561
- public void Undo()
3797
+ cButton undoButton;
3798
+ cButton restoreButton;
3799
+ cButton replaceButton;
3800
+ cButton redoButton;
3801
+
3802
+ boolean muteSlider;
3803
+
3804
+ int VersionCount()
35623805 {
3806
+ int count = 0;
3807
+
3808
+ for (int i = copy.versions.length; --i >= 0;)
3809
+ {
3810
+ if (copy.versions[i] != null)
3811
+ count++;
3812
+ }
3813
+
3814
+ return count;
3815
+ }
3816
+
3817
+ void SetUndoStates()
3818
+ {
3819
+ cRadio tab = GetCurrentTab();
3820
+
3821
+ restoreButton.setEnabled(copy.versionindex != -1);
3822
+ replaceButton.setEnabled(copy.versionindex != -1);
3823
+
3824
+ undoButton.setEnabled(copy.versionindex > 0);
3825
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3826
+
3827
+ muteSlider = true;
3828
+ versionSlider.setMaximum(VersionCount() - 1);
3829
+ versionSlider.setInteger(copy.versionindex);
3830
+ muteSlider = false;
3831
+ }
3832
+
3833
+ public boolean Undo()
3834
+ {
3835
+ // Option?
3836
+ Replace();
3837
+
35633838 System.err.println("Undo");
35643839
35653840 cRadio tab = GetCurrentTab();
35663841
3567
- if (tab.undoindex == 0)
3842
+ if (copy.versionindex == 0)
35683843 {
35693844 java.awt.Toolkit.getDefaultToolkit().beep();
3570
- return;
3845
+ return false;
35713846 }
35723847
3573
- if (tab.graphs[tab.undoindex] == null)
3848
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3849
+// {
3850
+// if (Save(false))
3851
+// tab.versionindex -= 1;
3852
+// else
3853
+// {
3854
+// if (tab.versionindex <= 0)
3855
+// return false;
3856
+// else
3857
+// tab.versionindex -= 1;
3858
+// }
3859
+// }
3860
+
3861
+ copy.versionindex -= 1;
3862
+
3863
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3864
+
3865
+ return true;
3866
+ }
3867
+
3868
+ public boolean Restore()
3869
+ {
3870
+ System.err.println("Restore");
3871
+
3872
+ cRadio tab = GetCurrentTab();
3873
+
3874
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
35743875 {
3575
- Save();
3576
- tab.undoindex -= 1;
3876
+ java.awt.Toolkit.getDefaultToolkit().beep();
3877
+ return false;
35773878 }
35783879
3579
- tab.undoindex -= 1;
3880
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3881
+
3882
+ return true;
3883
+ }
35803884
3581
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3885
+ public boolean Replace()
3886
+ {
3887
+ System.err.println("Replace");
3888
+
3889
+ cRadio tab = GetCurrentTab();
3890
+
3891
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3892
+ {
3893
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3894
+ return false;
3895
+ }
3896
+
3897
+ copy.versions[copy.versionindex] = CompressCopy();
3898
+
3899
+ return true;
35823900 }
35833901
35843902 public void Redo()
35853903 {
3904
+ // Option?
3905
+ Replace();
3906
+
35863907 cRadio tab = GetCurrentTab();
35873908
3588
- if (tab.graphs[tab.undoindex + 1] == null)
3909
+ if (copy.versions[copy.versionindex + 1] == null)
35893910 {
35903911 java.awt.Toolkit.getDefaultToolkit().beep();
35913912 return;
35923913 }
35933914
3594
- tab.undoindex += 1;
3915
+ copy.versionindex += 1;
35953916
3596
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3917
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3918
+
3919
+ //if (!tab.user[tab.versionindex])
3920
+ // tab.graphs[tab.versionindex] = null;
35973921 }
35983922
35993923 void ImportGFD()
....@@ -3889,9 +4213,25 @@
38894213 //copy.Touch();
38904214 }
38914215
4216
+ cNumberSlider versionSlider;
4217
+
38924218 public void stateChanged(ChangeEvent e)
38934219 {
38944220 // assert(false);
4221
+ if (e.getSource() == versionSlider)
4222
+ {
4223
+ if (muteSlider)
4224
+ return;
4225
+
4226
+ int version = versionSlider.getInteger();
4227
+
4228
+ if (copy.versions[version] != null)
4229
+ {
4230
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4231
+ }
4232
+
4233
+ return;
4234
+ }
38954235
38964236 if (freezematerial)
38974237 {
....@@ -4240,7 +4580,7 @@
42404580
42414581 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42424582 {
4243
- if (Globals.SAVEONMAKE) // && resetmodel)
4583
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42444584 Save();
42454585 //Tween.set(thing, 0).target(1).start(tweenManager);
42464586 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4482,7 +4822,9 @@
44824822 readobj.ResetDisplayList();
44834823 } catch (Exception e)
44844824 {
4485
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
44864828 try
44874829 {
44884830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4556,12 +4898,14 @@
45564898
45574899 if (readobj != null)
45584900 {
4559
- if (Globals.SAVEONMAKE)
4560
- Save();
4901
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4902
+ // Save();
45614903 try
45624904 {
45634905 //readobj.deepCopySelf(copy);
45644906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
45654909 for (int i = 0; i < readobj.size(); i++)
45664910 {
45674911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4602,6 +4946,7 @@
46024946 }
46034947 } catch (ClassCastException e)
46044948 {
4949
+ e.printStackTrace();
46054950 assert (false);
46064951 Composite c = (Composite) copy;
46074952 c.children.clear();
....@@ -4612,13 +4957,24 @@
46124957 c.addChild(csg);
46134958 }
46144959
4960
+ copy.versions = readobj.versions;
4961
+ copy.versionindex = readobj.versionindex;
4962
+
4963
+ if (copy.versions == null)
4964
+ {
4965
+ copy.versions = new byte[100][];
4966
+ copy.versionindex = -1;
4967
+ }
4968
+
4969
+ //? SetUndoStates();
4970
+
46154971 ResetModel();
46164972 copy.HardTouch(); // recompile?
46174973 refreshContents();
46184974 }
46194975 }
46204976
4621
- void load() // throws ClassNotFoundException
4977
+ void Open() // throws ClassNotFoundException
46224978 {
46234979 if (Grafreed.standAlone)
46244980 {
....@@ -4721,6 +5077,7 @@
47215077 //ps.print(buffer.toString());
47225078 } catch (IOException e)
47235079 {
5080
+ e.printStackTrace();
47245081 }
47255082 }
47265083
....@@ -4735,6 +5092,8 @@
47355092 String filename = browser.getFile();
47365093 if (filename != null && filename.length() > 0)
47375094 {
5095
+ if (!filename.endsWith(".gfd"))
5096
+ filename += ".gfd";
47385097 lastname = browser.getDirectory() + filename;
47395098 save();
47405099 }
....@@ -4901,7 +5260,7 @@
49015260 MenuBar menuBar;
49025261 Menu fileMenu;
49035262 MenuItem newItem;
4904
- MenuItem loadItem;
5263
+ MenuItem openItem;
49055264 MenuItem saveItem;
49065265 MenuItem saveAsItem;
49075266 MenuItem exportAsItem;
....@@ -4924,6 +5283,7 @@
49245283 CheckboxMenuItem toggleSwitchItem;
49255284 CheckboxMenuItem toggleRootItem;
49265285 CheckboxMenuItem animationItem;
5286
+ MenuItem archiveItem;
49275287 CheckboxMenuItem toggleHandleItem;
49285288 CheckboxMenuItem togglePaintItem;
49295289 JSplitPane mainPanel;
....@@ -4945,6 +5305,8 @@
49455305 cGridBag optionsPanel;
49465306
49475307 JTabbedPane objectPanel;
5308
+ boolean materialFlushed;
5309
+ Object3D latestObject;
49485310
49495311 cGridBag XYZPanel;
49505312