Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -35,6 +39,53 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
47
+ ImageIcon icon = GetIcon(name);
48
+ return new cButton(icon, border);
49
+ }
50
+
51
+ cToggleButton GetToggleButton(String name, boolean border)
52
+ {
53
+ ImageIcon icon = GetIcon(name);
54
+ return new cToggleButton(icon, border);
55
+ }
56
+
57
+ cCheckBox GetCheckBox(String name, boolean border)
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cCheckBox(icon, border);
61
+ }
62
+
63
+ private ImageIcon GetIcon(String name)
64
+ {
65
+ try
66
+ {
67
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
68
+
69
+ if (image.getWidth() != 24 && image.getHeight() != 24)
70
+ {
71
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
72
+ Graphics2D g = resized.createGraphics();
73
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
74
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
76
+ g.dispose();
77
+
78
+ image = resized;
79
+ }
80
+
81
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
82
+ return icon;
83
+ }
84
+ catch (Exception e)
85
+ {
86
+ return null;
87
+ }
88
+ }
3889
3990 // SCRIPT
4091
....@@ -145,7 +196,7 @@
145196
146197 objEditor.ctrlPanel.remove(namePanel);
147198
148
- if (!GroupEditor.allparams)
199
+ if (!allparams)
149200 return;
150201
151202 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +219,8 @@
168219 // objEditor.ctrlPanel.remove(remarkButton);
169220
170221 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
222
+ objEditor.ctrlPanel.remove(setupPanel2);
223
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172224 objEditor.ctrlPanel.remove(pushPanel);
173225 //objEditor.ctrlPanel.remove(fillPanel);
174226
....@@ -216,6 +268,12 @@
216268 client = inClient;
217269 copy = client;
218270
271
+ if (copy.versions == null)
272
+ {
273
+ copy.versions = new byte[100][];
274
+ copy.versionindex = -1;
275
+ }
276
+
219277 // "this" is not called: SetupUI2(objEditor);
220278 }
221279
....@@ -229,6 +287,12 @@
229287 client = inClient;
230288 copy = client;
231289
290
+ if (copy.versions == null)
291
+ {
292
+ copy.versions = new byte[100][];
293
+ copy.versionindex = -1;
294
+ }
295
+
232296 SetupUI2(callee.GetEditor());
233297 }
234298
....@@ -243,6 +307,7 @@
243307 //localCopy.parent = null;
244308
245309 frame = new JFrame();
310
+ frame.setUndecorated(false);
246311 objEditor = this;
247312 this.callee = callee;
248313
....@@ -260,6 +325,12 @@
260325 copy = localCopy;
261326 copy.editWindow = this;
262327
328
+ if (copy.versions == null)
329
+ {
330
+ copy.versions = new byte[100][];
331
+ copy.versionindex = -1;
332
+ }
333
+
263334 SetupMenu();
264335
265336 //SetupName(objEditor); // new
....@@ -273,12 +344,17 @@
273344 return frame.action(event, obj);
274345 }
275346
347
+ // Cannot work without static
348
+ static boolean allparams = true;
349
+
350
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
351
+
276352 void SetupMenu()
277353 {
278354 frame.setMenuBar(menuBar = new MenuBar());
279355 menuBar.add(fileMenu = new Menu("File"));
280356 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
357
+ fileMenu.add(openItem = new MenuItem("Open..."));
282358
283359 //oe.menuBar.add(menu = new Menu("Include"));
284360 Menu menu = new Menu("Import");
....@@ -310,7 +386,7 @@
310386 }
311387
312388 newItem.addActionListener(this);
313
- loadItem.addActionListener(this);
389
+ openItem.addActionListener(this);
314390 saveItem.addActionListener(this);
315391 saveAsItem.addActionListener(this);
316392 exportAsItem.addActionListener(this);
....@@ -319,28 +395,68 @@
319395 closeItem.addActionListener(this);
320396
321397 objectPanel = new JTabbedPane();
398
+
399
+ ChangeListener changeListener = new ChangeListener()
400
+ {
401
+ public void stateChanged(ChangeEvent changeEvent)
402
+ {
403
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
404
+// {
405
+// if (latestObject != null)
406
+// {
407
+// refreshContents(true);
408
+// SetMaterial(latestObject);
409
+// }
410
+//
411
+// materialFlushed = true;
412
+// }
413
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
414
+// {
415
+// if (listUI.size() == 0)
416
+// EditSelection(false);
417
+// }
418
+
419
+ refreshContents(false); // To refresh Info tab
420
+ }
421
+ };
422
+ objectPanel.addChangeListener(changeListener);
423
+
322424 toolbarPanel = new JPanel();
323425 toolbarPanel.setName("Toolbar");
426
+
324427 treePanel = new cGridBag();
325428 treePanel.setName("Tree");
429
+
430
+ editPanel = new cGridBag().setVertical(true);
431
+ //editPanel.setName("Edit");
432
+
326433 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
434
+
435
+ editCommandsPanel = new cGridBag();
436
+ editPanel.add(editCommandsPanel);
437
+ editPanel.add(ctrlPanel);
438
+
439
+ toolboxPanel = new cGridBag().setVertical(false);
440
+ //toolboxPanel.setName("Toolbox");
441
+
328442 materialPanel = new cGridBag().setVertical(true);
329
- materialPanel.setName("Material");
443
+ //materialPanel.setName("Material");
444
+
330445 /*JTextPane*/
331446 infoarea = createTextPane();
332447 doc = infoarea.getStyledDocument();
333448
334449 infoarea.setEditable(true);
335450 SetText();
451
+
336452 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
337453 // infoarea.setOpaque(false);
338454 // //infoarea.setForeground(textcolor);
339455 // TEXTAREA infoarea.setLineWrap(true);
340456 // TEXTAREA infoarea.setWrapStyleWord(true);
341457 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
342
- infoPanel.setPreferredSize(new Dimension(50, 200));
343
- infoPanel.setName("Info");
458
+ infoPanel.setPreferredSize(new Dimension(1, 1));
459
+ //infoPanel.setName("Info");
344460 //infoPanel.setLayout(new BorderLayout());
345461 //infoPanel.add(createTextPane());
346462
....@@ -351,7 +467,14 @@
351467 mainPanel.setDividerSize(9);
352468 mainPanel.setDividerLocation(0.5); //1.0);
353469 mainPanel.setResizeWeight(0.5);
354
-
470
+
471
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
472
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
473
+ divider.setDividerSize(15);
474
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
475
+
476
+ mainPanel.setUI(new BasicSplitPaneUI());
477
+
355478 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
356479 //mainPanel.setLayout(new GridBagLayout());
357480 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -419,10 +542,10 @@
419542 e.printStackTrace();
420543 }
421544
422
- String selection = infoarea.getText();
423
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
424
- java.awt.datatransfer.Clipboard clipboard =
425
- Toolkit.getDefaultToolkit().getSystemClipboard();
545
+// String selection = infoarea.getText();
546
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
547
+// java.awt.datatransfer.Clipboard clipboard =
548
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426549 //clipboard.setContents(data, data);
427550 }
428551
....@@ -582,21 +705,144 @@
582705 }
583706 }
584707
708
+//static GraphicsDevice device = GraphicsEnvironment
709
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
710
+
711
+ Rectangle keeprect;
712
+ cRadio radio;
713
+
714
+cButton keepButton;
715
+ cButton twoButton; // Full 3D
716
+ cButton sixButton;
717
+ cButton threeButton;
718
+ cButton sevenButton;
719
+ cButton fourButton; // full panel
720
+ cButton oneButton; // full XYZ
721
+ //cButton currentLayout;
722
+
723
+ boolean maximized;
724
+
725
+ cButton fullscreenLayout;
726
+
727
+ void Minimize()
728
+ {
729
+ frame.setState(Frame.ICONIFIED);
730
+ frame.validate();
731
+ }
732
+
733
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
734
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
735
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
736
+ void Maximize()
737
+ {
738
+ if (CameraPane.FULLSCREEN)
739
+ {
740
+ ToggleFullScreen();
741
+ }
742
+
743
+ if (maximized)
744
+ {
745
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
746
+ }
747
+ else
748
+ {
749
+ keeprect = frame.getBounds();
750
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
751
+// Dimension rect2 = frame.getToolkit().getScreenSize();
752
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
753
+// frame.setState(Frame.MAXIMIZED_BOTH);
754
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
755
+ }
756
+
757
+ maximized ^= true;
758
+
759
+ frame.validate();
760
+ }
761
+
762
+ cButton minButton;
763
+ cButton maxButton;
764
+ cButton fullButton;
765
+
585766 void ToggleFullScreen()
586767 {
587
- if (CameraPane.FULLSCREEN)
768
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769
+
770
+ cameraView.ToggleFullScreen();
771
+
772
+ if (!CameraPane.FULLSCREEN)
588773 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
774
+ device.setFullScreenWindow(null);
775
+ frame.dispose();
776
+ frame.setUndecorated(false);
777
+ frame.validate();
778
+ frame.setVisible(true);
779
+
780
+ //frame.setVisible(false);
781
+// frame.removeNotify();
782
+// frame.setUndecorated(false);
783
+// frame.addNotify();
784
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
785
+
786
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
787
+// X framePanel.add(bigThree);
788
+// X frame.getContentPane().add(/*"Center",*/framePanel);
789
+ framePanel.setDividerLocation(46);
790
+
791
+ //frame.setVisible(true);
792
+ radio.layout = keepButton;
793
+ //theFrame = null;
794
+ keepButton = null;
795
+ radio.layout.doClick();
796
+
592797 } else
593798 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
799
+ keepButton = radio.layout;
800
+ //keeprect = frame.getBounds();
801
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
802
+// frame.getToolkit().getScreenSize().height);
803
+ //frame.setVisible(false);
804
+
805
+ frame.dispose();
806
+ frame.setUndecorated(true);
807
+ device.setFullScreenWindow(frame);
808
+ frame.validate();
809
+ frame.setVisible(true);
810
+// frame.removeNotify();
811
+// frame.setUndecorated(true);
812
+// frame.addNotify();
813
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
814
+// X framePanel.remove(bigThree);
815
+// X frame.getContentPane().add(/*"Center",*/bigThree);
816
+ framePanel.setDividerLocation(0);
817
+
818
+ radio.layout = fullscreenLayout;
819
+ radio.layout.doClick();
820
+ //frame.setVisible(true);
597821 }
598
- cameraView.ToggleFullScreen();
822
+ frame.validate();
599823 }
824
+
825
+ private byte[] CompressCopy()
826
+ {
827
+ boolean temp = CameraPane.SWITCH;
828
+ CameraPane.SWITCH = false;
829
+
830
+ copy.ExtractBigData(versiontable);
831
+ // if (copy == client)
832
+
833
+ byte[] versions[] = copy.versions;
834
+ copy.versions = null;
835
+
836
+ byte[] compress = Compress(copy);
837
+
838
+ copy.versions = versions;
839
+
840
+ copy.RestoreBigData(versiontable);
841
+
842
+ CameraPane.SWITCH = temp;
843
+
844
+ return compress;
845
+ }
600846
601847 private JTextPane createTextPane()
602848 {
....@@ -736,7 +982,12 @@
736982 JCheckBox speedupCB;
737983 JCheckBox rewindCB;
738984 JCheckBox flipVCB;
985
+
986
+ cCheckBox toggleTextureCB;
987
+ cCheckBox toggleSwitchCB;
988
+
739989 JComboBox texresMenu;
990
+
740991 JButton resetButton;
741992 JButton stepButton;
742993 JButton stepAllButton;
....@@ -745,9 +996,13 @@
745996 JButton fasterButton;
746997 JButton remarkButton;
747998
999
+ cGridBag editPanel;
1000
+ cGridBag editCommandsPanel;
1001
+
7481002 cGridBag namePanel;
7491003 cGridBag setupPanel;
750
- cGridBag commandsPanel;
1004
+ cGridBag setupPanel2;
1005
+ cGridBag objectCommandsPanel;
7511006 cGridBag pushPanel;
7521007 cGridBag fillPanel;
7531008
....@@ -919,12 +1174,12 @@
9191174 namePanel = new cGridBag();
9201175
9211176 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1177
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231178 oe.ctrlPanel.add(namePanel);
9241179
9251180 oe.ctrlPanel.Return();
9261181
927
- if (!GroupEditor.allparams)
1182
+ if (!allparams)
9281183 return;
9291184
9301185 setupPanel = new cGridBag().setVertical(false);
....@@ -937,42 +1192,47 @@
9371192 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381193 hideCB.setToolTipText("Hide object");
9391194 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
1195
+ markCB.setToolTipText("As animation target transform");
9411196
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1197
+ setupPanel2 = new cGridBag().setVertical(false);
1198
+
1199
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431200 rewindCB.setToolTipText("Rewind animation");
9441201
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1202
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1203
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471204
1205
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1206
+ link2masterCB.setToolTipText("Attach to support");
1207
+
9481208 if (Globals.ADVANCED)
9491209 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
- link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1210
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531211 speedupCB.setToolTipText("Option motion capture");
9541212 }
9551213
9561214 oe.ctrlPanel.add(setupPanel);
9571215 oe.ctrlPanel.Return();
1216
+ oe.ctrlPanel.add(setupPanel2);
1217
+ oe.ctrlPanel.Return();
9581218
959
- commandsPanel = new cGridBag().setVertical(false);
1219
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601220
961
- resetButton = AddButton(commandsPanel, "Reset");
1221
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621222 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1223
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641224 stepButton.setToolTipText("Step one frame");
9651225 // resetAllButton = AddButton(oe, "Reset All");
9661226 // stepAllButton = AddButton(oe, "Step All");
9671227 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1228
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691229 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1230
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711231 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1232
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731233 remarkButton.setToolTipText("Set the current transform as the target");
9741234
975
- oe.ctrlPanel.add(commandsPanel);
1235
+ oe.ctrlPanel.add(objectCommandsPanel);
9761236 oe.ctrlPanel.Return();
9771237
9781238 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1178,8 +1438,11 @@
11781438 //worldPanel.setName("World");
11791439 centralPanel = new cGridBag();
11801440 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1441
+
1442
+ if (Globals.ADVANCED)
1443
+ {
1444
+ timelinePanel = new JPanel(new BorderLayout());
1445
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831446
11841447 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851448 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1451,10 @@
11881451 // cameraPanel.setDividerSize(9);
11891452 cameraPanel.setResizeWeight(1.0);
11901453
1454
+ }
1455
+
11911456 centralPanel.add(cameraView);
1457
+ centralPanel.setFocusable(true);
11921458 //frame.setJMenuBar(timelineMenubar);
11931459 //centralPanel.add(timelinePanel);
11941460
....@@ -1214,6 +1480,7 @@
12141480 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12151481 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12161482 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1483
+ //XYZPanel.setName("XYZ");
12171484
12181485 /*
12191486 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1251,12 +1518,23 @@
12511518 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12521519 //tmp.setName("Edit");
12531520 objectPanel.add(materialPanel);
1521
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
12541522 // JPanel north = new JPanel(new BorderLayout());
12551523 // north.setName("Edit");
12561524 // north.add(ctrlPanel, BorderLayout.NORTH);
12571525 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1259
- objectPanel.add(infoPanel);
1526
+ objectPanel.add(editPanel);
1527
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1528
+
1529
+ //if (Globals.ADVANCED)
1530
+ objectPanel.add(infoPanel);
1531
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1532
+
1533
+ objectPanel.add(XYZPanel);
1534
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1535
+
1536
+ objectPanel.add(toolboxPanel);
1537
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
12601538
12611539 /*
12621540 aConstraints.gridx = 0;
....@@ -1265,7 +1543,7 @@
12651543 aConstraints.gridy += 1;
12661544 aConstraints.gridwidth = 1;
12671545 mainPanel.add(objectPanel, aConstraints);
1268
- */
1546
+ */
12691547
12701548 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711549 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1277,14 +1555,12 @@
12771555 scrollpane.addMouseWheelListener(this); // Default not fast enough
12781556
12791557 /*JTabbedPane*/ scenePanel = new cGridBag();
1280
- scenePanel.preferredWidth = 6;
1558
+ scenePanel.preferredWidth = 5;
12811559
12821560 JTabbedPane tabbedPane = new JTabbedPane();
12831561 tabbedPane.add(scrollpane);
12841562
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1563
+ optionsPanel = new cGridBag().setVertical(false);
12881564
12891565 optionsPanel.setName("Options");
12901566
....@@ -1292,6 +1568,8 @@
12921568
12931569 tabbedPane.add(optionsPanel);
12941570
1571
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1572
+
12951573 scenePanel.add(tabbedPane);
12961574
12971575 /*
....@@ -1355,7 +1633,7 @@
13551633 bigThree = new cGridBag();
13561634 bigThree.addComponent(scenePanel);
13571635 bigThree.addComponent(centralPanel);
1358
- bigThree.addComponent(XYZPanel);
1636
+ //bigThree.addComponent(XYZPanel);
13591637
13601638 // // SIDE EFFECT!!!
13611639 // aConstraints.gridx = 0;
....@@ -1364,9 +1642,9 @@
13641642 // aConstraints.gridheight = 1;
13651643
13661644 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1367
- framePanel.setContinuousLayout(true);
1368
- framePanel.setOneTouchExpandable(true);
1369
- framePanel.setDividerLocation(0.8);
1645
+ framePanel.setContinuousLayout(false);
1646
+ framePanel.setOneTouchExpandable(false);
1647
+ //.setDividerLocation(0.8);
13701648 //framePanel.setDividerSize(15);
13711649 //framePanel.setResizeWeight(0.15);
13721650 framePanel.setName("Frame");
....@@ -1384,9 +1662,14 @@
13841662 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851663
13861664 frame.setSize(1280, 860);
1387
- frame.setVisible(true);
1388
-
1665
+
1666
+ cameraView.requestFocusInWindow();
1667
+
13891668 gridPanel.setDividerLocation(1.0);
1669
+
1670
+ frame.validate();
1671
+
1672
+ frame.setVisible(true);
13901673
13911674 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13921675 frame.addWindowListener(new WindowAdapter()
....@@ -1473,24 +1756,6 @@
14731756 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14741757 colorSection.add(texture);
14751758
1476
- cGridBag anisoU = new cGridBag();
1477
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1478
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1479
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1480
- colorSection.add(anisoU);
1481
-
1482
- cGridBag anisoV = new cGridBag();
1483
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1484
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1486
- colorSection.add(anisoV);
1487
-
1488
- cGridBag shadowbias = new cGridBag();
1489
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1490
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1492
- colorSection.add(shadowbias);
1493
-
14941759 panel.add(new JSeparator());
14951760
14961761 panel.add(colorSection);
....@@ -1540,6 +1805,12 @@
15401805 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15411806 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421807 diffuseSection.add(fakedepth);
1808
+
1809
+ cGridBag shadowbias = new cGridBag();
1810
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1811
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1812
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1813
+ diffuseSection.add(shadowbias);
15431814
15441815 panel.add(new JSeparator());
15451816
....@@ -1591,6 +1862,18 @@
15911862 // aConstraints.gridy += 1;
15921863 // aConstraints.gridwidth = 1;
15931864
1865
+ cGridBag anisoU = new cGridBag();
1866
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1867
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1868
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1869
+ specularSection.add(anisoU);
1870
+
1871
+ cGridBag anisoV = new cGridBag();
1872
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1873
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1874
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1875
+ specularSection.add(anisoV);
1876
+
15941877
15951878 panel.add(new JSeparator());
15961879
....@@ -1598,35 +1881,35 @@
15981881
15991882 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16001883
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
1884
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16021885
16031886 cGridBag camera = new cGridBag();
16041887 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16051888 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16061889 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
1890
+ colorSection.add(camera);
16081891
16091892 cGridBag ambient = new cGridBag();
16101893 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16111894 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121895 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
1896
+ colorSection.add(ambient);
16141897
16151898 cGridBag backlit = new cGridBag();
16161899 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16171900 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181901 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
1902
+ colorSection.add(backlit);
16201903
16211904 cGridBag opacity = new cGridBag();
16221905 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
16231906 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16241907 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1625
- globalSection.add(opacity);
1908
+ colorSection.add(opacity);
16261909
1627
- panel.add(new JSeparator());
1910
+ //panel.add(new JSeparator());
16281911
1629
- panel.add(globalSection);
1912
+ //panel.add(globalSection);
16301913
16311914 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16321915
....@@ -1733,8 +2016,9 @@
17332016 // 3D models
17342017 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17352018 {
1736
- lastConverter = new com.jmex.model.converters.MaxToJme();
1737
- LoadFile(filename, lastConverter);
2019
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2020
+ //LoadFile(filename, lastConverter);
2021
+ LoadObjFile(filename); // New 3ds loader
17382022 continue;
17392023 }
17402024 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1935,6 +2219,7 @@
19352219 e2.printStackTrace();
19362220 }
19372221 }
2222
+
19382223 LoadJMEThread loadThread;
19392224
19402225 class LoadJMEThread extends Thread
....@@ -1992,6 +2277,7 @@
19922277 //LoadFile0(filename, converter);
19932278 }
19942279 }
2280
+
19952281 LoadOBJThread loadObjThread;
19962282
19972283 class LoadOBJThread extends Thread
....@@ -2070,19 +2356,19 @@
20702356
20712357 void LoadObjFile(String fullname)
20722358 {
2073
- /*
2359
+ System.out.println("Loading " + fullname);
2360
+ /**/
20742361 //lastFilename = fullname;
20752362 if(loadObjThread == null)
20762363 {
2077
- loadObjThread = new LoadOBJThread();
2078
- loadObjThread.start();
2364
+ loadObjThread = new LoadOBJThread();
2365
+ loadObjThread.start();
20792366 }
20802367
20812368 loadObjThread.add(fullname);
2082
- */
2369
+ /**/
20832370
2084
- System.out.println("Loading " + fullname);
2085
- makeSomething(new FileObject(fullname, true), true);
2371
+ //makeSomething(new FileObject(fullname, true), true);
20862372 }
20872373
20882374 void LoadGFDFile(String fullname)
....@@ -2458,6 +2744,7 @@
24582744 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24592745 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24602746 }
2747
+
24612748 //cJME.count++;
24622749 //cJME.count %= 12;
24632750 if (gc)
....@@ -2641,6 +2928,7 @@
26412928 }
26422929 }
26432930 }
2931
+
26442932 cFileSystemPane FSPane;
26452933
26462934 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2694,11 +2982,14 @@
26942982 }
26952983 }
26962984 }
2985
+
26972986 freezematerial = false;
26982987 }
26992988
27002989 void SetMaterial(Object3D object)
27012990 {
2991
+ latestObject = object;
2992
+
27022993 cMaterial mat = object.material;
27032994
27042995 if (mat == null)
....@@ -2810,12 +3101,17 @@
28103101 // }
28113102
28123103 /**/
2813
- if (deselect)
3104
+ if (deselect || child == null)
28143105 {
28153106 //group.deselectAll();
28163107 //freeze = true;
28173108 GetTree().clearSelection();
28183109 //freeze = false;
3110
+
3111
+ if (child == null)
3112
+ {
3113
+ return;
3114
+ }
28193115 }
28203116
28213117 //group.addSelectee(child);
....@@ -2884,7 +3180,7 @@
28843180 cameraView.ToggleDL();
28853181 cameraView.repaint();
28863182 return;
2887
- } else if (event.getSource() == toggleTextureItem)
3183
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28883184 {
28893185 cameraView.ToggleTexture();
28903186 // june 2013 copy.HardTouch();
....@@ -2923,9 +3219,9 @@
29233219 frame.validate();
29243220
29253221 return;
2926
- } else if (event.getSource() == toggleSwitchItem)
3222
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29273223 {
2928
- cameraView.ToggleRandom();
3224
+ cameraView.ToggleSwitch();
29293225 cameraView.repaint();
29303226 return;
29313227 } else if (event.getSource() == toggleHandleItem)
....@@ -3139,9 +3435,9 @@
31393435 {
31403436 Close();
31413437 //return true;
3142
- } else if (source == loadItem)
3438
+ } else if (source == openItem)
31433439 {
3144
- load();
3440
+ Open();
31453441 //return true;
31463442 } else if (source == newItem)
31473443 {
....@@ -3166,6 +3462,10 @@
31663462 {
31673463 generatePOV();
31683464 //return true;
3465
+ } else if (event.getSource() == archiveItem)
3466
+ {
3467
+ cTools.Archive(frame);
3468
+ return;
31693469 } else if (source == zBufferItem)
31703470 {
31713471 try
....@@ -3212,23 +3512,52 @@
32123512 objEditor.refreshContents();
32133513 }
32143514
3215
- Object3D graphs[] = new Object3D[10000];
3216
- int undoindex = 0;
3217
-
3218
- static public Object clone(Object o)
3515
+ static public byte[] Compress(Object3D o)
32193516 {
32203517 try
32213518 {
32223519 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3223
- ObjectOutputStream out = new ObjectOutputStream(baos);
3520
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3521
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32243522
3523
+ Object3D parent = o.parent;
3524
+ o.parent = null;
3525
+
32253526 out.writeObject(o);
3527
+
3528
+ o.parent = parent;
3529
+
3530
+ out.flush();
32263531
3227
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
3228
- ObjectInputStream in = new ObjectInputStream(bais);
3229
- Object obj = in.readObject();
3230
- in.close();
3532
+ baos //zstream
3533
+ .close();
32313534 out.close();
3535
+
3536
+ byte[] bytes = baos.toByteArray();
3537
+
3538
+ System.out.println("save #bytes = " + bytes.length);
3539
+ return bytes;
3540
+ } catch (Exception e)
3541
+ {
3542
+ System.err.println(e);
3543
+ return null;
3544
+ }
3545
+ }
3546
+
3547
+ static public Object Uncompress(byte[] bytes)
3548
+ {
3549
+ System.out.println("restore #bytes = " + bytes.length);
3550
+ try
3551
+ {
3552
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3553
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3554
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
3555
+ Object obj = in.readObject();
3556
+
3557
+ bais //istream
3558
+ .close();
3559
+ in.close();
3560
+
32323561 return obj;
32333562 } catch (Exception e)
32343563 {
....@@ -3237,24 +3566,121 @@
32373566 }
32383567 }
32393568
3569
+ static public Object clone(Object o)
3570
+ {
3571
+ try
3572
+ {
3573
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3574
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3575
+
3576
+ out.writeObject(o);
3577
+
3578
+ out.flush();
3579
+ out.close();
3580
+
3581
+ byte[] bytes = baos.toByteArray();
3582
+
3583
+ System.out.println("clone = " + bytes.length);
3584
+
3585
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3586
+ ObjectInputStream in = new ObjectInputStream(bais);
3587
+ Object obj = in.readObject();
3588
+ in.close();
3589
+
3590
+ return obj;
3591
+ } catch (Exception e)
3592
+ {
3593
+ System.err.println(e);
3594
+ return null;
3595
+ }
3596
+ }
3597
+
3598
+ cRadio GetCurrentTab()
3599
+ {
3600
+ cRadio ab;
3601
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3602
+ {
3603
+ ab = (cRadio)e.nextElement();
3604
+ if(ab.GetObject() == copy)
3605
+ {
3606
+ return ab;
3607
+ }
3608
+ }
3609
+
3610
+ return null;
3611
+ }
3612
+
3613
+
32403614 public void Save()
32413615 {
3242
- if (true) return;
3616
+ //Save(true);
3617
+ Replace();
3618
+ }
3619
+
3620
+ private boolean Equal(byte[] compress, byte[] name)
3621
+ {
3622
+ if (compress.length != name.length)
3623
+ {
3624
+ return false;
3625
+ }
3626
+
3627
+ for (int i=compress.length; --i>=0;)
3628
+ {
3629
+ if (compress[i] != name[i])
3630
+ return false;
3631
+ }
3632
+
3633
+ return true;
3634
+ }
3635
+
3636
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3637
+
3638
+ public boolean Save(boolean user)
3639
+ {
3640
+ System.err.println("Save");
3641
+
3642
+ cRadio tab = GetCurrentTab();
3643
+
3644
+ byte[] compress = CompressCopy();
3645
+
3646
+ boolean thesame = false;
3647
+
3648
+ // Quick heuristic using length. Works only when stream is compressed.
3649
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3650
+ {
3651
+ thesame = true;
3652
+ }
32433653
32443654 //EditorFrame.m_MainFrame.requestFocusInWindow();
3245
- graphs[undoindex++] = (Object3D)clone(copy);
3246
-
3247
- for (int i = undoindex; i < graphs.length; i++)
3655
+ if (!thesame)
32483656 {
3249
- graphs[i] = null;
3657
+ //tab.user[tab.versionindex] = user;
3658
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3659
+
3660
+ copy.versions[++copy.versionindex] = compress;
3661
+
3662
+ // if (increment)
3663
+ // tab.versionindex++;
32503664 }
32513665
3666
+ //copy.RestoreBigData(versiontable);
3667
+
3668
+ //assert(hashtable.isEmpty());
3669
+
3670
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3671
+ {
3672
+ //tab.user[i] = false;
3673
+ copy.versions[i] = null;
3674
+ }
3675
+
3676
+ SetUndoStates();
3677
+
32523678 // test save
32533679 if (false)
32543680 {
32553681 try
32563682 {
3257
- FileOutputStream ostream = new FileOutputStream("save" + undoindex);
3683
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
32583684 ObjectOutputStream p = new ObjectOutputStream(ostream);
32593685
32603686 p.writeObject(copy);
....@@ -3267,50 +3693,177 @@
32673693 e.printStackTrace();
32683694 }
32693695 }
3696
+
3697
+ return !thesame;
32703698 }
32713699
3272
- public void Undo()
3700
+ void CopyChanged(Object3D obj)
32733701 {
3274
- if (undoindex == 0)
3275
- {
3276
- java.awt.Toolkit.getDefaultToolkit().beep();
3277
- return;
3278
- }
3279
-
3280
- if (graphs[undoindex] == null)
3281
- {
3282
- Save();
3283
- undoindex -= 1;
3284
- }
3285
-
3286
- undoindex -= 1;
3287
-
3288
- copy = graphs[undoindex];
3702
+ SetUndoStates();
32893703
3290
- cameraView.object = copy;
3704
+ boolean temp = CameraPane.SWITCH;
3705
+ CameraPane.SWITCH = false;
3706
+
3707
+ copy.ExtractBigData(versiontable);
3708
+
3709
+ copy.clear();
3710
+
3711
+ for (int i=0; i<obj.Size(); i++)
3712
+ {
3713
+ copy.add(obj.get(i));
3714
+ }
3715
+
3716
+ copy.RestoreBigData(versiontable);
3717
+
3718
+ CameraPane.SWITCH = temp;
3719
+
3720
+ //assert(hashtable.isEmpty());
3721
+
32913722 copy.Touch();
32923723
32933724 ResetModel();
3725
+ copy.HardTouch(); // recompile?
3726
+
3727
+ cRadio ab;
3728
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3729
+ {
3730
+ ab = (cRadio)e.nextElement();
3731
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3732
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3733
+ if (test != null)
3734
+ {
3735
+ test.editWindow = ab.object.editWindow;
3736
+ ab.object = test;
3737
+ }
3738
+ }
3739
+
32943740 refreshContents();
3741
+ }
3742
+
3743
+ cButton undoButton;
3744
+ cButton restoreButton;
3745
+ cButton replaceButton;
3746
+ cButton redoButton;
3747
+
3748
+ boolean muteSlider;
3749
+
3750
+ int VersionCount()
3751
+ {
3752
+ int count = 0;
3753
+
3754
+ for (int i = copy.versions.length; --i >= 0;)
3755
+ {
3756
+ if (copy.versions[i] != null)
3757
+ count++;
3758
+ }
3759
+
3760
+ return count;
3761
+ }
3762
+
3763
+ void SetUndoStates()
3764
+ {
3765
+ cRadio tab = GetCurrentTab();
3766
+
3767
+ restoreButton.setEnabled(copy.versionindex != -1);
3768
+ replaceButton.setEnabled(copy.versionindex != -1);
3769
+
3770
+ undoButton.setEnabled(copy.versionindex > 0);
3771
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3772
+
3773
+ muteSlider = true;
3774
+ versionSlider.setMaximum(VersionCount() - 1);
3775
+ versionSlider.setInteger(copy.versionindex);
3776
+ muteSlider = false;
3777
+ }
3778
+
3779
+ public boolean Undo()
3780
+ {
3781
+ // Option?
3782
+ Replace();
3783
+
3784
+ System.err.println("Undo");
3785
+
3786
+ cRadio tab = GetCurrentTab();
3787
+
3788
+ if (copy.versionindex == 0)
3789
+ {
3790
+ java.awt.Toolkit.getDefaultToolkit().beep();
3791
+ return false;
3792
+ }
3793
+
3794
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3795
+// {
3796
+// if (Save(false))
3797
+// tab.versionindex -= 1;
3798
+// else
3799
+// {
3800
+// if (tab.versionindex <= 0)
3801
+// return false;
3802
+// else
3803
+// tab.versionindex -= 1;
3804
+// }
3805
+// }
3806
+
3807
+ copy.versionindex -= 1;
3808
+
3809
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3810
+
3811
+ return true;
3812
+ }
3813
+
3814
+ public boolean Restore()
3815
+ {
3816
+ System.err.println("Restore");
3817
+
3818
+ cRadio tab = GetCurrentTab();
3819
+
3820
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3821
+ {
3822
+ java.awt.Toolkit.getDefaultToolkit().beep();
3823
+ return false;
3824
+ }
3825
+
3826
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3827
+
3828
+ return true;
3829
+ }
3830
+
3831
+ public boolean Replace()
3832
+ {
3833
+ System.err.println("Replace");
3834
+
3835
+ cRadio tab = GetCurrentTab();
3836
+
3837
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3838
+ {
3839
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3840
+ return false;
3841
+ }
3842
+
3843
+ copy.versions[copy.versionindex] = CompressCopy();
3844
+
3845
+ return true;
32953846 }
32963847
32973848 public void Redo()
32983849 {
3299
- if (graphs[undoindex + 1] == null)
3850
+ // Option?
3851
+ Replace();
3852
+
3853
+ cRadio tab = GetCurrentTab();
3854
+
3855
+ if (copy.versions[copy.versionindex + 1] == null)
33003856 {
33013857 java.awt.Toolkit.getDefaultToolkit().beep();
33023858 return;
33033859 }
33043860
3305
- undoindex += 1;
3861
+ copy.versionindex += 1;
33063862
3307
- copy = graphs[undoindex];
3308
-
3309
- cameraView.object = copy;
3310
- copy.Touch();
3863
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
33113864
3312
- ResetModel();
3313
- refreshContents();
3865
+ //if (!tab.user[tab.versionindex])
3866
+ // tab.graphs[tab.versionindex] = null;
33143867 }
33153868
33163869 void ImportGFD()
....@@ -3462,7 +4015,7 @@
34624015 assert false;
34634016 }
34644017
3465
- void EditSelection()
4018
+ void EditSelection(boolean newWindow)
34664019 {
34674020 }
34684021
....@@ -3606,9 +4159,25 @@
36064159 //copy.Touch();
36074160 }
36084161
4162
+ cNumberSlider versionSlider;
4163
+
36094164 public void stateChanged(ChangeEvent e)
36104165 {
36114166 // assert(false);
4167
+ if (e.getSource() == versionSlider)
4168
+ {
4169
+ if (muteSlider)
4170
+ return;
4171
+
4172
+ int version = versionSlider.getInteger();
4173
+
4174
+ if (copy.versions[version] != null)
4175
+ {
4176
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4177
+ }
4178
+
4179
+ return;
4180
+ }
36124181
36134182 if (freezematerial)
36144183 {
....@@ -3957,7 +4526,8 @@
39574526
39584527 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
39594528 {
3960
- Save();
4529
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4530
+ Save();
39614531 //Tween.set(thing, 0).target(1).start(tweenManager);
39624532 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
39634533 // if (thing instanceof GenericJointDemo)
....@@ -4044,6 +4614,12 @@
40444614 {
40454615 ResetModel();
40464616 Select(thing.GetTreePath(), true, false); // unselect... false);
4617
+
4618
+ if (thing.Size() == 0)
4619
+ {
4620
+ //EditSelection(false);
4621
+ }
4622
+
40474623 refreshContents();
40484624 }
40494625
....@@ -4181,6 +4757,7 @@
41814757
41824758 try
41834759 {
4760
+ // Try compressed version first.
41844761 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
41854762 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
41864763 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4250,6 +4827,12 @@
42504827
42514828 void LoadIt(Object obj)
42524829 {
4830
+ if (obj == null)
4831
+ {
4832
+ // Invalid file
4833
+ return;
4834
+ }
4835
+
42534836 System.out.println("Loaded " + obj);
42544837 //new Exception().printStackTrace();
42554838 Object3D readobj = (Object3D) obj;
....@@ -4259,6 +4842,8 @@
42594842
42604843 if (readobj != null)
42614844 {
4845
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4846
+ // Save();
42624847 try
42634848 {
42644849 //readobj.deepCopySelf(copy);
....@@ -4313,13 +4898,24 @@
43134898 c.addChild(csg);
43144899 }
43154900
4901
+ copy.versions = readobj.versions;
4902
+ copy.versionindex = readobj.versionindex;
4903
+
4904
+ if (copy.versions == null)
4905
+ {
4906
+ copy.versions = new byte[100][];
4907
+ copy.versionindex = -1;
4908
+ }
4909
+
4910
+ //? SetUndoStates();
4911
+
43164912 ResetModel();
43174913 copy.HardTouch(); // recompile?
43184914 refreshContents();
43194915 }
43204916 }
43214917
4322
- void load() // throws ClassNotFoundException
4918
+ void Open() // throws ClassNotFoundException
43234919 {
43244920 if (Grafreed.standAlone)
43254921 {
....@@ -4436,6 +5032,8 @@
44365032 String filename = browser.getFile();
44375033 if (filename != null && filename.length() > 0)
44385034 {
5035
+ if (!filename.endsWith(".gfd"))
5036
+ filename += ".gfd";
44395037 lastname = browser.getDirectory() + filename;
44405038 save();
44415039 }
....@@ -4602,7 +5200,7 @@
46025200 MenuBar menuBar;
46035201 Menu fileMenu;
46045202 MenuItem newItem;
4605
- MenuItem loadItem;
5203
+ MenuItem openItem;
46065204 MenuItem saveItem;
46075205 MenuItem saveAsItem;
46085206 MenuItem exportAsItem;
....@@ -4625,22 +5223,36 @@
46255223 CheckboxMenuItem toggleSwitchItem;
46265224 CheckboxMenuItem toggleRootItem;
46275225 CheckboxMenuItem animationItem;
5226
+ MenuItem archiveItem;
46285227 CheckboxMenuItem toggleHandleItem;
46295228 CheckboxMenuItem togglePaintItem;
46305229 JSplitPane mainPanel;
46315230 JScrollPane scrollpane;
5231
+
46325232 JPanel toolbarPanel;
5233
+
46335234 cGridBag treePanel;
5235
+
46345236 JPanel radioPanel;
46355237 ButtonGroup buttonGroup;
4636
- cGridBag ctrlPanel;
5238
+
5239
+ cGridBag toolboxPanel;
46375240 cGridBag materialPanel;
5241
+ cGridBag ctrlPanel;
5242
+
46385243 JScrollPane infoPanel;
5244
+
46395245 cGridBag optionsPanel;
5246
+
46405247 JTabbedPane objectPanel;
5248
+ boolean materialFlushed;
5249
+ Object3D latestObject;
5250
+
46415251 cGridBag XYZPanel;
5252
+
46425253 JSplitPane gridPanel;
46435254 JSplitPane bigPanel;
5255
+
46445256 cGridBag bigThree;
46455257 cGridBag scenePanel;
46465258 cGridBag centralPanel;
....@@ -4755,7 +5367,7 @@
47555367 cNumberSlider fogField;
47565368 JLabel opacityPowerLabel;
47575369 cNumberSlider opacityPowerField;
4758
- JTree jTree;
5370
+ cTree jTree;
47595371 //ObjectUI parent;
47605372
47615373 cNumberSlider normalpushField;