Normand Briere
2019-08-01 29d5516687020263d3ae0454ce81879a3a450af0
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
....@@ -37,6 +41,79 @@
3741 JFrame frame;
3842
3943 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
+ }
52
+
53
+ cButton GetButton(String name, boolean border)
54
+ {
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);
63
+ }
64
+
65
+ cToggleButton GetToggleButton(String name, boolean border)
66
+ {
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
79
+ try
80
+ {
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;
97
+ }
98
+ catch (Exception e)
99
+ {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ BufferedImage GetImage(String name)
105
+ {
106
+ try
107
+ {
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
111
+ }
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
116
+ }
40117
41118 // SCRIPT
42119
....@@ -147,7 +224,7 @@
147224
148225 objEditor.ctrlPanel.remove(namePanel);
149226
150
- if (!GroupEditor.allparams)
227
+ if (!allparams)
151228 return;
152229
153230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -171,7 +248,7 @@
171248
172249 objEditor.ctrlPanel.remove(setupPanel);
173250 objEditor.ctrlPanel.remove(setupPanel2);
174
- objEditor.ctrlPanel.remove(commandsPanel);
251
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
175252 objEditor.ctrlPanel.remove(pushPanel);
176253 //objEditor.ctrlPanel.remove(fillPanel);
177254
....@@ -219,6 +296,12 @@
219296 client = inClient;
220297 copy = client;
221298
299
+ if (copy.versions == null)
300
+ {
301
+ copy.versions = new byte[100][];
302
+ copy.versionindex = -1;
303
+ }
304
+
222305 // "this" is not called: SetupUI2(objEditor);
223306 }
224307
....@@ -232,6 +315,12 @@
232315 client = inClient;
233316 copy = client;
234317
318
+ if (copy.versions == null)
319
+ {
320
+ copy.versions = new byte[100][];
321
+ copy.versionindex = -1;
322
+ }
323
+
235324 SetupUI2(callee.GetEditor());
236325 }
237326
....@@ -246,7 +335,7 @@
246335 //localCopy.parent = null;
247336
248337 frame = new JFrame();
249
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
250339 objEditor = this;
251340 this.callee = callee;
252341
....@@ -264,6 +353,12 @@
264353 copy = localCopy;
265354 copy.editWindow = this;
266355
356
+ if (copy.versions == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
267362 SetupMenu();
268363
269364 //SetupName(objEditor); // new
....@@ -277,12 +372,17 @@
277372 return frame.action(event, obj);
278373 }
279374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
280380 void SetupMenu()
281381 {
282382 frame.setMenuBar(menuBar = new MenuBar());
283383 menuBar.add(fileMenu = new Menu("File"));
284384 fileMenu.add(newItem = new MenuItem("New"));
285
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
286386
287387 //oe.menuBar.add(menu = new Menu("Include"));
288388 Menu menu = new Menu("Import");
....@@ -314,7 +414,7 @@
314414 }
315415
316416 newItem.addActionListener(this);
317
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
318418 saveItem.addActionListener(this);
319419 saveAsItem.addActionListener(this);
320420 exportAsItem.addActionListener(this);
....@@ -323,28 +423,68 @@
323423 closeItem.addActionListener(this);
324424
325425 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
+
326452 toolbarPanel = new JPanel();
327453 toolbarPanel.setName("Toolbar");
454
+
328455 treePanel = new cGridBag();
329456 treePanel.setName("Tree");
457
+
458
+ editPanel = new cGridBag().setVertical(true);
459
+ //editPanel.setName("Edit");
460
+
330461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
331
- ctrlPanel.setName("Edit");
462
+
463
+ editCommandsPanel = new cGridBag();
464
+ editPanel.add(editCommandsPanel);
465
+ editPanel.add(ctrlPanel);
466
+
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
469
+
332470 materialPanel = new cGridBag().setVertical(true);
333
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
472
+
334473 /*JTextPane*/
335474 infoarea = createTextPane();
336475 doc = infoarea.getStyledDocument();
337476
338477 infoarea.setEditable(true);
339478 SetText();
479
+
340480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
341481 // infoarea.setOpaque(false);
342482 // //infoarea.setForeground(textcolor);
343483 // TEXTAREA infoarea.setLineWrap(true);
344484 // TEXTAREA infoarea.setWrapStyleWord(true);
345485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
346
- infoPanel.setPreferredSize(new Dimension(50, 200));
347
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
348488 //infoPanel.setLayout(new BorderLayout());
349489 //infoPanel.add(createTextPane());
350490
....@@ -355,7 +495,14 @@
355495 mainPanel.setDividerSize(9);
356496 mainPanel.setDividerLocation(0.5); //1.0);
357497 mainPanel.setResizeWeight(0.5);
358
-
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
+
359506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
360507 //mainPanel.setLayout(new GridBagLayout());
361508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -586,8 +733,8 @@
586733 }
587734 }
588735
589
-static GraphicsDevice device = GraphicsEnvironment
590
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
591738
592739 Rectangle keeprect;
593740 cRadio radio;
....@@ -603,13 +750,24 @@
603750
604751 boolean maximized;
605752
753
+ cButton fullscreenLayout;
754
+
606755 void Minimize()
607756 {
608757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
609759 }
610760
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={}
611764 void Maximize()
612765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
613771 if (maximized)
614772 {
615773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -617,20 +775,36 @@
617775 else
618776 {
619777 keeprect = frame.getBounds();
620
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
621
- Dimension rect2 = frame.getToolkit().getScreenSize();
622
- 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);
623781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
624783 }
625784
626785 maximized ^= true;
786
+
787
+ frame.validate();
627788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
628793
629794 void ToggleFullScreen()
630795 {
631
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
632801 {
633802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
634808 //frame.setVisible(false);
635809 // frame.removeNotify();
636810 // frame.setUndecorated(false);
....@@ -640,7 +814,7 @@
640814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
641815 // X framePanel.add(bigThree);
642816 // X frame.getContentPane().add(/*"Center",*/framePanel);
643
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
644818
645819 //frame.setVisible(true);
646820 radio.layout = keepButton;
....@@ -655,7 +829,12 @@
655829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
656830 // frame.getToolkit().getScreenSize().height);
657831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
658835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
659838 // frame.removeNotify();
660839 // frame.setUndecorated(true);
661840 // frame.addNotify();
....@@ -664,13 +843,34 @@
664843 // X frame.getContentPane().add(/*"Center",*/bigThree);
665844 framePanel.setDividerLocation(0);
666845
667
- radio.layout = twoButton;
846
+ radio.layout = fullscreenLayout;
668847 radio.layout.doClick();
669848 //frame.setVisible(true);
670849 }
671
-
672
- cameraView.ToggleFullScreen();
850
+ frame.validate();
673851 }
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
+ }
674874
675875 private JTextPane createTextPane()
676876 {
....@@ -802,7 +1002,7 @@
8021002 // NumberSlider vDivsField;
8031003 // JCheckBox endcaps;
8041004 JCheckBox liveCB;
805
- JCheckBox selectCB;
1005
+ JCheckBox selectableCB;
8061006 JCheckBox hideCB;
8071007 JCheckBox link2masterCB;
8081008 JCheckBox markCB;
....@@ -810,7 +1010,12 @@
8101010 JCheckBox speedupCB;
8111011 JCheckBox rewindCB;
8121012 JCheckBox flipVCB;
1013
+
1014
+ cCheckBox toggleTextureCB;
1015
+ cCheckBox toggleSwitchCB;
1016
+
8131017 JComboBox texresMenu;
1018
+
8141019 JButton resetButton;
8151020 JButton stepButton;
8161021 JButton stepAllButton;
....@@ -819,10 +1024,13 @@
8191024 JButton fasterButton;
8201025 JButton remarkButton;
8211026
1027
+ cGridBag editPanel;
1028
+ cGridBag editCommandsPanel;
1029
+
8221030 cGridBag namePanel;
8231031 cGridBag setupPanel;
8241032 cGridBag setupPanel2;
825
- cGridBag commandsPanel;
1033
+ cGridBag objectCommandsPanel;
8261034 cGridBag pushPanel;
8271035 cGridBag fillPanel;
8281036
....@@ -994,38 +1202,42 @@
9941202 namePanel = new cGridBag();
9951203
9961204 nameField = AddText(namePanel, copy.GetName());
997
- namePanel.add(nameField);
1205
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9981206 oe.ctrlPanel.add(namePanel);
9991207
10001208 oe.ctrlPanel.Return();
10011209
1002
- if (!GroupEditor.allparams)
1210
+ if (!allparams)
10031211 return;
10041212
10051213 setupPanel = new cGridBag().setVertical(false);
10061214
10071215 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10081216 liveCB.setToolTipText("Animate object");
1009
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1010
- selectCB.setToolTipText("Make object selectable");
1217
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1218
+ selectableCB.setToolTipText("Make object selectable");
10111219 // Return();
1220
+
10121221 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10131222 hideCB.setToolTipText("Hide object");
10141223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1015
- markCB.setToolTipText("Set the animation target transform");
1224
+ markCB.setToolTipText("As animation target transform");
1225
+
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10161227
10171228 setupPanel2 = new cGridBag().setVertical(false);
10181229
10191230 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10201231 rewindCB.setToolTipText("Rewind animation");
10211232
1022
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1023
- 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)");
10241235
1236
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1237
+ link2masterCB.setToolTipText("Attach to support");
1238
+
10251239 if (Globals.ADVANCED)
10261240 {
1027
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1028
- link2masterCB.setToolTipText("Attach to support");
10291241 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10301242 speedupCB.setToolTipText("Option motion capture");
10311243 }
....@@ -1035,23 +1247,23 @@
10351247 oe.ctrlPanel.add(setupPanel2);
10361248 oe.ctrlPanel.Return();
10371249
1038
- commandsPanel = new cGridBag().setVertical(false);
1250
+ objectCommandsPanel = new cGridBag().setVertical(false);
10391251
1040
- resetButton = AddButton(commandsPanel, "Reset");
1252
+ resetButton = AddButton(objectCommandsPanel, "Reset");
10411253 resetButton.setToolTipText("Jump to frame zero");
1042
- stepButton = AddButton(commandsPanel, "Step");
1254
+ stepButton = AddButton(objectCommandsPanel, "Step");
10431255 stepButton.setToolTipText("Step one frame");
10441256 // resetAllButton = AddButton(oe, "Reset All");
10451257 // stepAllButton = AddButton(oe, "Step All");
10461258 // Return();
1047
- slowerButton = AddButton(commandsPanel, "Slow");
1259
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
10481260 slowerButton.setToolTipText("Decrease animation speed");
1049
- fasterButton = AddButton(commandsPanel, "Fast");
1261
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
10501262 fasterButton.setToolTipText("Increase animation speed");
1051
- remarkButton = AddButton(commandsPanel, "Remark");
1263
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
10521264 remarkButton.setToolTipText("Set the current transform as the target");
10531265
1054
- oe.ctrlPanel.add(commandsPanel);
1266
+ oe.ctrlPanel.add(objectCommandsPanel);
10551267 oe.ctrlPanel.Return();
10561268
10571269 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1299,6 +1511,7 @@
12991511 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13001512 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13011513 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1514
+ //XYZPanel.setName("XYZ");
13021515
13031516 /*
13041517 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1336,12 +1549,29 @@
13361549 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13371550 //tmp.setName("Edit");
13381551 objectPanel.add(materialPanel);
1552
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
13391555 // JPanel north = new JPanel(new BorderLayout());
13401556 // north.setName("Edit");
13411557 // north.add(ctrlPanel, BorderLayout.NORTH);
13421558 // objectPanel.add(north);
1343
- objectPanel.add(ctrlPanel);
1344
- objectPanel.add(infoPanel);
1559
+ objectPanel.add(editPanel);
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");
13451575
13461576 /*
13471577 aConstraints.gridx = 0;
....@@ -1350,7 +1580,7 @@
13501580 aConstraints.gridy += 1;
13511581 aConstraints.gridwidth = 1;
13521582 mainPanel.add(objectPanel, aConstraints);
1353
- */
1583
+ */
13541584
13551585 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13561586 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1362,14 +1592,12 @@
13621592 scrollpane.addMouseWheelListener(this); // Default not fast enough
13631593
13641594 /*JTabbedPane*/ scenePanel = new cGridBag();
1365
- scenePanel.preferredWidth = 6;
1595
+ scenePanel.preferredWidth = 5;
13661596
13671597 JTabbedPane tabbedPane = new JTabbedPane();
13681598 tabbedPane.add(scrollpane);
13691599
1370
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1371
-
1372
- optionsPanel = new cGridBag().setVertical(true);
1600
+ optionsPanel = new cGridBag().setVertical(false);
13731601
13741602 optionsPanel.setName("Options");
13751603
....@@ -1377,6 +1605,8 @@
13771605
13781606 tabbedPane.add(optionsPanel);
13791607
1608
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1609
+
13801610 scenePanel.add(tabbedPane);
13811611
13821612 /*
....@@ -1440,7 +1670,7 @@
14401670 bigThree = new cGridBag();
14411671 bigThree.addComponent(scenePanel);
14421672 bigThree.addComponent(centralPanel);
1443
- bigThree.addComponent(XYZPanel);
1673
+ //bigThree.addComponent(XYZPanel);
14441674
14451675 // // SIDE EFFECT!!!
14461676 // aConstraints.gridx = 0;
....@@ -1449,9 +1679,9 @@
14491679 // aConstraints.gridheight = 1;
14501680
14511681 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1452
- framePanel.setContinuousLayout(true);
1453
- framePanel.setOneTouchExpandable(true);
1454
- framePanel.setDividerLocation(0.8);
1682
+ framePanel.setContinuousLayout(false);
1683
+ framePanel.setOneTouchExpandable(false);
1684
+ //.setDividerLocation(0.8);
14551685 //framePanel.setDividerSize(15);
14561686 //framePanel.setResizeWeight(0.15);
14571687 framePanel.setName("Frame");
....@@ -1469,16 +1699,18 @@
14691699 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14701700
14711701 frame.setSize(1280, 860);
1472
- frame.setVisible(true);
1473
-
1702
+
14741703 cameraView.requestFocusInWindow();
14751704
14761705 gridPanel.setDividerLocation(1.0);
1706
+
1707
+ frame.validate();
1708
+
1709
+ frame.setVisible(true);
14771710
14781711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14791712 frame.addWindowListener(new WindowAdapter()
14801713 {
1481
-
14821714 public void windowClosing(WindowEvent e)
14831715 {
14841716 Close();
....@@ -1540,45 +1772,48 @@
15401772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15411773
15421774 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);
15431786
15441787 cGridBag color = new cGridBag();
1545
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1546
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1547
- 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
+
15481793 //colorField.preferredWidth = 200;
15491794 colorSection.add(color);
15501795
15511796 cGridBag modulation = new cGridBag();
15521797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
15531798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1554
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
15551800 colorSection.add(modulation);
15561801
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
+
15571810 cGridBag texture = new cGridBag();
15581811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
15591812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15601813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15611814 colorSection.add(texture);
15621815
1563
- cGridBag anisoU = new cGridBag();
1564
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1565
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1566
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1567
- colorSection.add(anisoU);
1568
-
1569
- cGridBag anisoV = new cGridBag();
1570
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1571
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1572
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1573
- colorSection.add(anisoV);
1574
-
1575
- cGridBag shadowbias = new cGridBag();
1576
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1577
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1578
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1579
- colorSection.add(shadowbias);
1580
-
1581
- panel.add(new JSeparator());
1816
+ panel.add(GetSeparator());
15821817
15831818 panel.add(colorSection);
15841819
....@@ -1628,7 +1863,13 @@
16281863 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16291864 diffuseSection.add(fakedepth);
16301865
1631
- 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());
16321873
16331874 panel.add(diffuseSection);
16341875
....@@ -1678,42 +1919,48 @@
16781919 // aConstraints.gridy += 1;
16791920 // aConstraints.gridwidth = 1;
16801921
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);
16811927
1682
- 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());
16831936
16841937 panel.add(specularSection);
16851938
16861939 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16871940
1688
- cGridBag globalSection = new cGridBag().setVertical(true);
1941
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16891942
16901943 cGridBag camera = new cGridBag();
16911944 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16921945 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16931946 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1694
- globalSection.add(camera);
1947
+ colorSection.add(camera);
16951948
16961949 cGridBag ambient = new cGridBag();
16971950 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16981951 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16991952 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1700
- globalSection.add(ambient);
1953
+ colorSection.add(ambient);
17011954
17021955 cGridBag backlit = new cGridBag();
17031956 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17041957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17051958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1706
- globalSection.add(backlit);
1959
+ colorSection.add(backlit);
17071960
1708
- cGridBag opacity = new cGridBag();
1709
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1710
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1711
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1712
- globalSection.add(opacity);
1713
-
1714
- panel.add(new JSeparator());
1961
+ //panel.add(new JSeparator());
17151962
1716
- panel.add(globalSection);
1963
+ //panel.add(globalSection);
17171964
17181965 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17191966
....@@ -1755,7 +2002,7 @@
17552002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
17562003 textureSection.add(opacityPower);
17572004
1758
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
17592006
17602007 panel.add(textureSection);
17612008
....@@ -1820,8 +2067,9 @@
18202067 // 3D models
18212068 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18222069 {
1823
- lastConverter = new com.jmex.model.converters.MaxToJme();
1824
- LoadFile(filename, lastConverter);
2070
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2071
+ //LoadFile(filename, lastConverter);
2072
+ LoadObjFile(filename); // New 3ds loader
18252073 continue;
18262074 }
18272075 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2547,6 +2795,7 @@
25472795 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25482796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25492797 }
2798
+
25502799 //cJME.count++;
25512800 //cJME.count %= 12;
25522801 if (gc)
....@@ -2730,6 +2979,7 @@
27302979 }
27312980 }
27322981 }
2982
+
27332983 cFileSystemPane FSPane;
27342984
27352985 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2783,11 +3033,14 @@
27833033 }
27843034 }
27853035 }
3036
+
27863037 freezematerial = false;
27873038 }
27883039
27893040 void SetMaterial(Object3D object)
27903041 {
3042
+ latestObject = object;
3043
+
27913044 cMaterial mat = object.material;
27923045
27933046 if (mat == null)
....@@ -2899,12 +3152,17 @@
28993152 // }
29003153
29013154 /**/
2902
- if (deselect)
3155
+ if (deselect || child == null)
29033156 {
29043157 //group.deselectAll();
29053158 //freeze = true;
29063159 GetTree().clearSelection();
29073160 //freeze = false;
3161
+
3162
+ if (child == null)
3163
+ {
3164
+ return;
3165
+ }
29083166 }
29093167
29103168 //group.addSelectee(child);
....@@ -2973,7 +3231,7 @@
29733231 cameraView.ToggleDL();
29743232 cameraView.repaint();
29753233 return;
2976
- } else if (event.getSource() == toggleTextureItem)
3234
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29773235 {
29783236 cameraView.ToggleTexture();
29793237 // june 2013 copy.HardTouch();
....@@ -3012,7 +3270,7 @@
30123270 frame.validate();
30133271
30143272 return;
3015
- } else if (event.getSource() == toggleSwitchItem)
3273
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30163274 {
30173275 cameraView.ToggleSwitch();
30183276 cameraView.repaint();
....@@ -3043,7 +3301,7 @@
30433301 {
30443302 copy.live ^= true;
30453303 return;
3046
- } else if (event.getSource() == selectCB)
3304
+ } else if (event.getSource() == selectableCB)
30473305 {
30483306 copy.dontselect ^= true;
30493307 return;
....@@ -3228,9 +3486,9 @@
32283486 {
32293487 Close();
32303488 //return true;
3231
- } else if (source == loadItem)
3489
+ } else if (source == openItem)
32323490 {
3233
- load();
3491
+ Open();
32343492 //return true;
32353493 } else if (source == newItem)
32363494 {
....@@ -3255,6 +3513,10 @@
32553513 {
32563514 generatePOV();
32573515 //return true;
3516
+ } else if (event.getSource() == archiveItem)
3517
+ {
3518
+ cTools.Archive(frame);
3519
+ return;
32583520 } else if (source == zBufferItem)
32593521 {
32603522 try
....@@ -3306,8 +3568,8 @@
33063568 try
33073569 {
33083570 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3309
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3310
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3571
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3572
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33113573
33123574 Object3D parent = o.parent;
33133575 o.parent = null;
....@@ -3318,10 +3580,14 @@
33183580
33193581 out.flush();
33203582
3321
- zstream.close();
3583
+ baos //zstream
3584
+ .close();
33223585 out.close();
33233586
3324
- return baos.toByteArray();
3587
+ byte[] bytes = baos.toByteArray();
3588
+
3589
+ System.out.println("save #bytes = " + bytes.length);
3590
+ return bytes;
33253591 } catch (Exception e)
33263592 {
33273593 System.err.println(e);
....@@ -3331,13 +3597,16 @@
33313597
33323598 static public Object Uncompress(byte[] bytes)
33333599 {
3334
- System.out.println("#bytes = " + bytes.length);
3600
+ System.out.println("restore #bytes = " + bytes.length);
33353601 try
33363602 {
33373603 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3338
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3339
- ObjectInputStream in = new ObjectInputStream(istream);
3604
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3605
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33403606 Object obj = in.readObject();
3607
+
3608
+ bais //istream
3609
+ .close();
33413610 in.close();
33423611
33433612 return obj;
....@@ -3392,37 +3661,77 @@
33923661 return null;
33933662 }
33943663
3395
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
33963664
33973665 public void Save()
33983666 {
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)
3690
+ {
3691
+ System.err.println("Save");
3692
+
33993693 cRadio tab = GetCurrentTab();
34003694
3401
- boolean temp = CameraPane.SWITCH;
3402
- CameraPane.SWITCH = false;
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
34033696
3404
- 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
+ }
34053704
34063705 //EditorFrame.m_MainFrame.requestFocusInWindow();
3407
- tab.graphs[tab.undoindex++] = Compress(copy);
3408
-
3409
- copy.RestoreBigData(hashtable);
3410
-
3411
- CameraPane.SWITCH = temp;
3412
-
3413
- //assert(hashtable.isEmpty());
3414
-
3415
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3706
+ if (!thesame)
34163707 {
3417
- 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++;
34183715 }
34193716
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
+
34203729 // test save
34213730 if (false)
34223731 {
34233732 try
34243733 {
3425
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3734
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34263735 ObjectOutputStream p = new ObjectOutputStream(ostream);
34273736
34283737 p.writeObject(copy);
....@@ -3435,23 +3744,30 @@
34353744 e.printStackTrace();
34363745 }
34373746 }
3747
+
3748
+ return !thesame;
34383749 }
34393750
34403751 void CopyChanged(Object3D obj)
34413752 {
3753
+ SetUndoStates();
3754
+
34423755 boolean temp = CameraPane.SWITCH;
34433756 CameraPane.SWITCH = false;
34443757
3445
- copy.ExtractBigData(hashtable);
3758
+ copy.ExtractBigData(versiontable);
34463759
34473760 copy.clear();
34483761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
34493765 for (int i=0; i<obj.Size(); i++)
34503766 {
34513767 copy.add(obj.get(i));
34523768 }
34533769
3454
- copy.RestoreBigData(hashtable);
3770
+ copy.RestoreBigData(versiontable);
34553771
34563772 CameraPane.SWITCH = temp;
34573773
....@@ -3478,40 +3794,130 @@
34783794 refreshContents();
34793795 }
34803796
3481
- public void Undo()
3797
+ cButton undoButton;
3798
+ cButton restoreButton;
3799
+ cButton replaceButton;
3800
+ cButton redoButton;
3801
+
3802
+ boolean muteSlider;
3803
+
3804
+ int VersionCount()
3805
+ {
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()
34823818 {
34833819 cRadio tab = GetCurrentTab();
34843820
3485
- if (tab.undoindex == 0)
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
+
3838
+ System.err.println("Undo");
3839
+
3840
+ cRadio tab = GetCurrentTab();
3841
+
3842
+ if (copy.versionindex == 0)
34863843 {
34873844 java.awt.Toolkit.getDefaultToolkit().beep();
3488
- return;
3845
+ return false;
34893846 }
34903847
3491
- 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)
34923875 {
3493
- Save();
3494
- tab.undoindex -= 1;
3876
+ java.awt.Toolkit.getDefaultToolkit().beep();
3877
+ return false;
34953878 }
34963879
3497
- tab.undoindex -= 1;
3880
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3881
+
3882
+ return true;
3883
+ }
34983884
3499
- 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;
35003900 }
35013901
35023902 public void Redo()
35033903 {
3904
+ // Option?
3905
+ Replace();
3906
+
35043907 cRadio tab = GetCurrentTab();
35053908
3506
- if (tab.graphs[tab.undoindex + 1] == null)
3909
+ if (copy.versions[copy.versionindex + 1] == null)
35073910 {
35083911 java.awt.Toolkit.getDefaultToolkit().beep();
35093912 return;
35103913 }
35113914
3512
- tab.undoindex += 1;
3915
+ copy.versionindex += 1;
35133916
3514
- 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;
35153921 }
35163922
35173923 void ImportGFD()
....@@ -3663,7 +4069,7 @@
36634069 assert false;
36644070 }
36654071
3666
- void EditSelection()
4072
+ void EditSelection(boolean newWindow)
36674073 {
36684074 }
36694075
....@@ -3807,9 +4213,25 @@
38074213 //copy.Touch();
38084214 }
38094215
4216
+ cNumberSlider versionSlider;
4217
+
38104218 public void stateChanged(ChangeEvent e)
38114219 {
38124220 // 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
+ }
38134235
38144236 if (freezematerial)
38154237 {
....@@ -4158,7 +4580,8 @@
41584580
41594581 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41604582 {
4161
- Save();
4583
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4584
+ Save();
41624585 //Tween.set(thing, 0).target(1).start(tweenManager);
41634586 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41644587 // if (thing instanceof GenericJointDemo)
....@@ -4245,6 +4668,12 @@
42454668 {
42464669 ResetModel();
42474670 Select(thing.GetTreePath(), true, false); // unselect... false);
4671
+
4672
+ if (thing.Size() == 0)
4673
+ {
4674
+ //EditSelection(false);
4675
+ }
4676
+
42484677 refreshContents();
42494678 }
42504679
....@@ -4393,7 +4822,9 @@
43934822 readobj.ResetDisplayList();
43944823 } catch (Exception e)
43954824 {
4396
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
43974828 try
43984829 {
43994830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4467,11 +4898,14 @@
44674898
44684899 if (readobj != null)
44694900 {
4470
- Save();
4901
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4902
+ // Save();
44714903 try
44724904 {
44734905 //readobj.deepCopySelf(copy);
44744906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
44754909 for (int i = 0; i < readobj.size(); i++)
44764910 {
44774911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4512,6 +4946,7 @@
45124946 }
45134947 } catch (ClassCastException e)
45144948 {
4949
+ e.printStackTrace();
45154950 assert (false);
45164951 Composite c = (Composite) copy;
45174952 c.children.clear();
....@@ -4522,13 +4957,24 @@
45224957 c.addChild(csg);
45234958 }
45244959
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
+
45254971 ResetModel();
45264972 copy.HardTouch(); // recompile?
45274973 refreshContents();
45284974 }
45294975 }
45304976
4531
- void load() // throws ClassNotFoundException
4977
+ void Open() // throws ClassNotFoundException
45324978 {
45334979 if (Grafreed.standAlone)
45344980 {
....@@ -4631,6 +5077,7 @@
46315077 //ps.print(buffer.toString());
46325078 } catch (IOException e)
46335079 {
5080
+ e.printStackTrace();
46345081 }
46355082 }
46365083
....@@ -4645,6 +5092,8 @@
46455092 String filename = browser.getFile();
46465093 if (filename != null && filename.length() > 0)
46475094 {
5095
+ if (!filename.endsWith(".gfd"))
5096
+ filename += ".gfd";
46485097 lastname = browser.getDirectory() + filename;
46495098 save();
46505099 }
....@@ -4811,7 +5260,7 @@
48115260 MenuBar menuBar;
48125261 Menu fileMenu;
48135262 MenuItem newItem;
4814
- MenuItem loadItem;
5263
+ MenuItem openItem;
48155264 MenuItem saveItem;
48165265 MenuItem saveAsItem;
48175266 MenuItem exportAsItem;
....@@ -4834,22 +5283,36 @@
48345283 CheckboxMenuItem toggleSwitchItem;
48355284 CheckboxMenuItem toggleRootItem;
48365285 CheckboxMenuItem animationItem;
5286
+ MenuItem archiveItem;
48375287 CheckboxMenuItem toggleHandleItem;
48385288 CheckboxMenuItem togglePaintItem;
48395289 JSplitPane mainPanel;
48405290 JScrollPane scrollpane;
5291
+
48415292 JPanel toolbarPanel;
5293
+
48425294 cGridBag treePanel;
5295
+
48435296 JPanel radioPanel;
48445297 ButtonGroup buttonGroup;
4845
- cGridBag ctrlPanel;
5298
+
5299
+ cGridBag toolboxPanel;
48465300 cGridBag materialPanel;
5301
+ cGridBag ctrlPanel;
5302
+
48475303 JScrollPane infoPanel;
5304
+
48485305 cGridBag optionsPanel;
5306
+
48495307 JTabbedPane objectPanel;
5308
+ boolean materialFlushed;
5309
+ Object3D latestObject;
5310
+
48505311 cGridBag XYZPanel;
5312
+
48515313 JSplitPane gridPanel;
48525314 JSplitPane bigPanel;
5315
+
48535316 cGridBag bigThree;
48545317 cGridBag scenePanel;
48555318 cGridBag centralPanel;
....@@ -4964,7 +5427,7 @@
49645427 cNumberSlider fogField;
49655428 JLabel opacityPowerLabel;
49665429 cNumberSlider opacityPowerField;
4967
- JTree jTree;
5430
+ cTree jTree;
49685431 //ObjectUI parent;
49695432
49705433 cNumberSlider normalpushField;