Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
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,81 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ 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
+ }
38117
39118 // SCRIPT
40119
....@@ -145,7 +224,7 @@
145224
146225 objEditor.ctrlPanel.remove(namePanel);
147226
148
- if (!GroupEditor.allparams)
227
+ if (!allparams)
149228 return;
150229
151230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +247,8 @@
168247 // objEditor.ctrlPanel.remove(remarkButton);
169248
170249 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
250
+ objEditor.ctrlPanel.remove(setupPanel2);
251
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172252 objEditor.ctrlPanel.remove(pushPanel);
173253 //objEditor.ctrlPanel.remove(fillPanel);
174254
....@@ -216,6 +296,12 @@
216296 client = inClient;
217297 copy = client;
218298
299
+ if (copy.versions == null)
300
+ {
301
+ copy.versions = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
219305 // "this" is not called: SetupUI2(objEditor);
220306 }
221307
....@@ -229,6 +315,12 @@
229315 client = inClient;
230316 copy = client;
231317
318
+ if (copy.versions == null)
319
+ {
320
+ copy.versions = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
232324 SetupUI2(callee.GetEditor());
233325 }
234326
....@@ -243,6 +335,7 @@
243335 //localCopy.parent = null;
244336
245337 frame = new JFrame();
338
+ frame.setUndecorated(false);
246339 objEditor = this;
247340 this.callee = callee;
248341
....@@ -260,6 +353,12 @@
260353 copy = localCopy;
261354 copy.editWindow = this;
262355
356
+ if (copy.versions == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
263362 SetupMenu();
264363
265364 //SetupName(objEditor); // new
....@@ -273,12 +372,17 @@
273372 return frame.action(event, obj);
274373 }
275374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
276380 void SetupMenu()
277381 {
278382 frame.setMenuBar(menuBar = new MenuBar());
279383 menuBar.add(fileMenu = new Menu("File"));
280384 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
282386
283387 //oe.menuBar.add(menu = new Menu("Include"));
284388 Menu menu = new Menu("Import");
....@@ -310,7 +414,7 @@
310414 }
311415
312416 newItem.addActionListener(this);
313
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
314418 saveItem.addActionListener(this);
315419 saveAsItem.addActionListener(this);
316420 exportAsItem.addActionListener(this);
....@@ -319,28 +423,68 @@
319423 closeItem.addActionListener(this);
320424
321425 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
+
322452 toolbarPanel = new JPanel();
323453 toolbarPanel.setName("Toolbar");
454
+
324455 treePanel = new cGridBag();
325456 treePanel.setName("Tree");
457
+
458
+ editPanel = new cGridBag().setVertical(true);
459
+ //editPanel.setName("Edit");
460
+
326461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- 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
+
328470 materialPanel = new cGridBag().setVertical(true);
329
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
472
+
330473 /*JTextPane*/
331474 infoarea = createTextPane();
332475 doc = infoarea.getStyledDocument();
333476
334477 infoarea.setEditable(true);
335478 SetText();
479
+
336480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
337481 // infoarea.setOpaque(false);
338482 // //infoarea.setForeground(textcolor);
339483 // TEXTAREA infoarea.setLineWrap(true);
340484 // TEXTAREA infoarea.setWrapStyleWord(true);
341485 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");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
344488 //infoPanel.setLayout(new BorderLayout());
345489 //infoPanel.add(createTextPane());
346490
....@@ -351,7 +495,14 @@
351495 mainPanel.setDividerSize(9);
352496 mainPanel.setDividerLocation(0.5); //1.0);
353497 mainPanel.setResizeWeight(0.5);
354
-
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
+
355506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
356507 //mainPanel.setLayout(new GridBagLayout());
357508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -419,10 +570,10 @@
419570 e.printStackTrace();
420571 }
421572
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();
573
+// String selection = infoarea.getText();
574
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
575
+// java.awt.datatransfer.Clipboard clipboard =
576
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426577 //clipboard.setContents(data, data);
427578 }
428579
....@@ -582,21 +733,145 @@
582733 }
583734 }
584735
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
738
+
739
+ Rectangle keeprect;
740
+ cRadio radio;
741
+
742
+cButton keepButton;
743
+ cButton twoButton; // Full 3D
744
+ cButton sixButton;
745
+ cButton threeButton;
746
+ cButton sevenButton;
747
+ cButton fourButton; // full panel
748
+ cButton oneButton; // full XYZ
749
+ //cButton currentLayout;
750
+
751
+ boolean maximized;
752
+
753
+ cButton fullscreenLayout;
754
+
755
+ void Minimize()
756
+ {
757
+ frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
759
+ }
760
+
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={}
764
+ void Maximize()
765
+ {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
771
+ if (maximized)
772
+ {
773
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
774
+ }
775
+ else
776
+ {
777
+ keeprect = frame.getBounds();
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
781
+// frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
783
+ }
784
+
785
+ maximized ^= true;
786
+
787
+ frame.validate();
788
+ }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
793
+
585794 void ToggleFullScreen()
586795 {
587
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
588801 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
802
+ device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
808
+ //frame.setVisible(false);
809
+// frame.removeNotify();
810
+// frame.setUndecorated(false);
811
+// frame.addNotify();
812
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
813
+
814
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
815
+// X framePanel.add(bigThree);
816
+// X frame.getContentPane().add(/*"Center",*/framePanel);
817
+ framePanel.setDividerLocation(46);
818
+
819
+ //frame.setVisible(true);
820
+ radio.layout = keepButton;
821
+ //theFrame = null;
822
+ keepButton = null;
823
+ radio.layout.doClick();
824
+
592825 } else
593826 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
827
+ keepButton = radio.layout;
828
+ //keeprect = frame.getBounds();
829
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
830
+// frame.getToolkit().getScreenSize().height);
831
+ //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
835
+ device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
838
+// frame.removeNotify();
839
+// frame.setUndecorated(true);
840
+// frame.addNotify();
841
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
842
+// X framePanel.remove(bigThree);
843
+// X frame.getContentPane().add(/*"Center",*/bigThree);
844
+ framePanel.setDividerLocation(0);
845
+
846
+ radio.layout = fullscreenLayout;
847
+ radio.layout.doClick();
848
+ //frame.setVisible(true);
597849 }
598
- cameraView.ToggleFullScreen();
850
+ frame.validate();
599851 }
852
+
853
+ private Object3D CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ Object3D versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versions = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
600875
601876 private JTextPane createTextPane()
602877 {
....@@ -728,7 +1003,7 @@
7281003 // NumberSlider vDivsField;
7291004 // JCheckBox endcaps;
7301005 JCheckBox liveCB;
731
- JCheckBox selectCB;
1006
+ JCheckBox selectableCB;
7321007 JCheckBox hideCB;
7331008 JCheckBox link2masterCB;
7341009 JCheckBox markCB;
....@@ -736,7 +1011,12 @@
7361011 JCheckBox speedupCB;
7371012 JCheckBox rewindCB;
7381013 JCheckBox flipVCB;
1014
+
1015
+ cCheckBox toggleTextureCB;
1016
+ cCheckBox toggleSwitchCB;
1017
+
7391018 JComboBox texresMenu;
1019
+
7401020 JButton resetButton;
7411021 JButton stepButton;
7421022 JButton stepAllButton;
....@@ -745,9 +1025,13 @@
7451025 JButton fasterButton;
7461026 JButton remarkButton;
7471027
1028
+ cGridBag editPanel;
1029
+ cGridBag editCommandsPanel;
1030
+
7481031 cGridBag namePanel;
7491032 cGridBag setupPanel;
750
- cGridBag commandsPanel;
1033
+ cGridBag setupPanel2;
1034
+ cGridBag objectCommandsPanel;
7511035 cGridBag pushPanel;
7521036 cGridBag fillPanel;
7531037
....@@ -919,60 +1203,68 @@
9191203 namePanel = new cGridBag();
9201204
9211205 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1206
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231207 oe.ctrlPanel.add(namePanel);
9241208
9251209 oe.ctrlPanel.Return();
9261210
927
- if (!GroupEditor.allparams)
1211
+ if (!allparams)
9281212 return;
9291213
9301214 setupPanel = new cGridBag().setVertical(false);
9311215
9321216 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9331217 liveCB.setToolTipText("Animate object");
934
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
- selectCB.setToolTipText("Make object selectable");
1218
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1219
+ selectableCB.setToolTipText("Make object selectable");
9361220 // Return();
1221
+
9371222 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381223 hideCB.setToolTipText("Hide object");
9391224 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
1225
+ markCB.setToolTipText("As animation target transform");
9411226
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1227
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1228
+
1229
+ setupPanel2 = new cGridBag().setVertical(false);
1230
+
1231
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431232 rewindCB.setToolTipText("Rewind animation");
9441233
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1234
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1235
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471236
1237
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1238
+ link2masterCB.setToolTipText("Attach to support");
1239
+
9481240 if (Globals.ADVANCED)
9491241 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
- link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1242
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531243 speedupCB.setToolTipText("Option motion capture");
9541244 }
9551245
9561246 oe.ctrlPanel.add(setupPanel);
9571247 oe.ctrlPanel.Return();
1248
+ oe.ctrlPanel.add(setupPanel2);
1249
+ oe.ctrlPanel.Return();
9581250
959
- commandsPanel = new cGridBag().setVertical(false);
1251
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601252
961
- resetButton = AddButton(commandsPanel, "Reset");
1253
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621254 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1255
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641256 stepButton.setToolTipText("Step one frame");
9651257 // resetAllButton = AddButton(oe, "Reset All");
9661258 // stepAllButton = AddButton(oe, "Step All");
9671259 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1260
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691261 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1262
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711263 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1264
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731265 remarkButton.setToolTipText("Set the current transform as the target");
9741266
975
- oe.ctrlPanel.add(commandsPanel);
1267
+ oe.ctrlPanel.add(objectCommandsPanel);
9761268 oe.ctrlPanel.Return();
9771269
9781270 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1178,8 +1470,11 @@
11781470 //worldPanel.setName("World");
11791471 centralPanel = new cGridBag();
11801472 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1473
+
1474
+ if (Globals.ADVANCED)
1475
+ {
1476
+ timelinePanel = new JPanel(new BorderLayout());
1477
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831478
11841479 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851480 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1483,10 @@
11881483 // cameraPanel.setDividerSize(9);
11891484 cameraPanel.setResizeWeight(1.0);
11901485
1486
+ }
1487
+
11911488 centralPanel.add(cameraView);
1489
+ centralPanel.setFocusable(true);
11921490 //frame.setJMenuBar(timelineMenubar);
11931491 //centralPanel.add(timelinePanel);
11941492
....@@ -1214,6 +1512,7 @@
12141512 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12151513 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12161514 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1515
+ //XYZPanel.setName("XYZ");
12171516
12181517 /*
12191518 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1251,12 +1550,29 @@
12511550 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12521551 //tmp.setName("Edit");
12531552 objectPanel.add(materialPanel);
1553
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
+ objectPanel.setToolTipTextAt(0, "Material panel");
1555
+
12541556 // JPanel north = new JPanel(new BorderLayout());
12551557 // north.setName("Edit");
12561558 // north.add(ctrlPanel, BorderLayout.NORTH);
12571559 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1259
- objectPanel.add(infoPanel);
1560
+ objectPanel.add(editPanel);
1561
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
+ objectPanel.setToolTipTextAt(1, "Edit panel");
1563
+
1564
+ //if (Globals.ADVANCED)
1565
+ objectPanel.add(infoPanel);
1566
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
+ objectPanel.setToolTipTextAt(2, "Info panel");
1568
+
1569
+ objectPanel.add(XYZPanel);
1570
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1572
+
1573
+ objectPanel.add(toolboxPanel);
1574
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
12601576
12611577 /*
12621578 aConstraints.gridx = 0;
....@@ -1265,7 +1581,7 @@
12651581 aConstraints.gridy += 1;
12661582 aConstraints.gridwidth = 1;
12671583 mainPanel.add(objectPanel, aConstraints);
1268
- */
1584
+ */
12691585
12701586 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711587 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1277,14 +1593,12 @@
12771593 scrollpane.addMouseWheelListener(this); // Default not fast enough
12781594
12791595 /*JTabbedPane*/ scenePanel = new cGridBag();
1280
- scenePanel.preferredWidth = 6;
1596
+ scenePanel.preferredWidth = 5;
12811597
12821598 JTabbedPane tabbedPane = new JTabbedPane();
12831599 tabbedPane.add(scrollpane);
12841600
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1601
+ optionsPanel = new cGridBag().setVertical(false);
12881602
12891603 optionsPanel.setName("Options");
12901604
....@@ -1292,6 +1606,8 @@
12921606
12931607 tabbedPane.add(optionsPanel);
12941608
1609
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1610
+
12951611 scenePanel.add(tabbedPane);
12961612
12971613 /*
....@@ -1355,7 +1671,7 @@
13551671 bigThree = new cGridBag();
13561672 bigThree.addComponent(scenePanel);
13571673 bigThree.addComponent(centralPanel);
1358
- bigThree.addComponent(XYZPanel);
1674
+ //bigThree.addComponent(XYZPanel);
13591675
13601676 // // SIDE EFFECT!!!
13611677 // aConstraints.gridx = 0;
....@@ -1364,9 +1680,9 @@
13641680 // aConstraints.gridheight = 1;
13651681
13661682 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1367
- framePanel.setContinuousLayout(true);
1368
- framePanel.setOneTouchExpandable(true);
1369
- framePanel.setDividerLocation(0.8);
1683
+ framePanel.setContinuousLayout(false);
1684
+ framePanel.setOneTouchExpandable(false);
1685
+ //.setDividerLocation(0.8);
13701686 //framePanel.setDividerSize(15);
13711687 //framePanel.setResizeWeight(0.15);
13721688 framePanel.setName("Frame");
....@@ -1384,14 +1700,18 @@
13841700 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851701
13861702 frame.setSize(1280, 860);
1387
- frame.setVisible(true);
1388
-
1703
+
1704
+ cameraView.requestFocusInWindow();
1705
+
13891706 gridPanel.setDividerLocation(1.0);
1707
+
1708
+ frame.validate();
1709
+
1710
+ frame.setVisible(true);
13901711
13911712 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13921713 frame.addWindowListener(new WindowAdapter()
13931714 {
1394
-
13951715 public void windowClosing(WindowEvent e)
13961716 {
13971717 Close();
....@@ -1453,45 +1773,48 @@
14531773 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14541774
14551775 cGridBag colorSection = new cGridBag().setVertical(true);
1776
+
1777
+ cGridBag huepanel = new cGridBag();
1778
+ cGridBag huelabel = new cGridBag();
1779
+ huelabel.add(GetLabel("icons/hue.png", false));
1780
+ huelabel.preferredWidth = 20;
1781
+ huepanel.add(new cGridBag()); // Label
1782
+ huepanel.add(huelabel); // Field/slider
1783
+
1784
+ huepanel.preferredHeight = 7;
1785
+
1786
+ colorSection.add(huepanel);
14561787
14571788 cGridBag color = new cGridBag();
1458
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1459
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1460
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1789
+
1790
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1791
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1792
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1793
+
14611794 //colorField.preferredWidth = 200;
14621795 colorSection.add(color);
14631796
14641797 cGridBag modulation = new cGridBag();
14651798 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14661799 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1467
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1800
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14681801 colorSection.add(modulation);
14691802
1803
+ cGridBag opacity = new cGridBag();
1804
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1805
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1806
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1807
+ colorSection.add(opacity);
1808
+
1809
+ colorSection.add(GetSeparator());
1810
+
14701811 cGridBag texture = new cGridBag();
14711812 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14721813 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14731814 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14741815 colorSection.add(texture);
14751816
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
-
1494
- panel.add(new JSeparator());
1817
+ panel.add(GetSeparator());
14951818
14961819 panel.add(colorSection);
14971820
....@@ -1541,7 +1864,13 @@
15411864 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421865 diffuseSection.add(fakedepth);
15431866
1544
- panel.add(new JSeparator());
1867
+ cGridBag shadowbias = new cGridBag();
1868
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1869
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1871
+ diffuseSection.add(shadowbias);
1872
+
1873
+ panel.add(GetSeparator());
15451874
15461875 panel.add(diffuseSection);
15471876
....@@ -1591,42 +1920,48 @@
15911920 // aConstraints.gridy += 1;
15921921 // aConstraints.gridwidth = 1;
15931922
1923
+ cGridBag anisoU = new cGridBag();
1924
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1925
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1926
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1927
+ specularSection.add(anisoU);
15941928
1595
- panel.add(new JSeparator());
1929
+ cGridBag anisoV = new cGridBag();
1930
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1931
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1932
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1933
+ specularSection.add(anisoV);
1934
+
1935
+
1936
+ panel.add(GetSeparator());
15961937
15971938 panel.add(specularSection);
15981939
15991940 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16001941
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
1942
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16021943
16031944 cGridBag camera = new cGridBag();
16041945 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16051946 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16061947 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
1948
+ colorSection.add(camera);
16081949
16091950 cGridBag ambient = new cGridBag();
16101951 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16111952 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121953 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
1954
+ colorSection.add(ambient);
16141955
16151956 cGridBag backlit = new cGridBag();
16161957 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16171958 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16181959 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
1960
+ colorSection.add(backlit);
16201961
1621
- cGridBag opacity = new cGridBag();
1622
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1623
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1624
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1625
- globalSection.add(opacity);
1626
-
1627
- panel.add(new JSeparator());
1962
+ //panel.add(new JSeparator());
16281963
1629
- panel.add(globalSection);
1964
+ //panel.add(globalSection);
16301965
16311966 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16321967
....@@ -1668,7 +2003,7 @@
16682003 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16692004 textureSection.add(opacityPower);
16702005
1671
- panel.add(new JSeparator());
2006
+ panel.add(GetSeparator());
16722007
16732008 panel.add(textureSection);
16742009
....@@ -1733,8 +2068,9 @@
17332068 // 3D models
17342069 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17352070 {
1736
- lastConverter = new com.jmex.model.converters.MaxToJme();
1737
- LoadFile(filename, lastConverter);
2071
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2072
+ //LoadFile(filename, lastConverter);
2073
+ LoadObjFile(filename); // New 3ds loader
17382074 continue;
17392075 }
17402076 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -1935,6 +2271,7 @@
19352271 e2.printStackTrace();
19362272 }
19372273 }
2274
+
19382275 LoadJMEThread loadThread;
19392276
19402277 class LoadJMEThread extends Thread
....@@ -1992,6 +2329,7 @@
19922329 //LoadFile0(filename, converter);
19932330 }
19942331 }
2332
+
19952333 LoadOBJThread loadObjThread;
19962334
19972335 class LoadOBJThread extends Thread
....@@ -2070,19 +2408,19 @@
20702408
20712409 void LoadObjFile(String fullname)
20722410 {
2073
- /*
2411
+ System.out.println("Loading " + fullname);
2412
+ /**/
20742413 //lastFilename = fullname;
20752414 if(loadObjThread == null)
20762415 {
2077
- loadObjThread = new LoadOBJThread();
2078
- loadObjThread.start();
2416
+ loadObjThread = new LoadOBJThread();
2417
+ loadObjThread.start();
20792418 }
20802419
20812420 loadObjThread.add(fullname);
2082
- */
2421
+ /**/
20832422
2084
- System.out.println("Loading " + fullname);
2085
- makeSomething(new FileObject(fullname, true), true);
2423
+ //makeSomething(new FileObject(fullname, true), true);
20862424 }
20872425
20882426 void LoadGFDFile(String fullname)
....@@ -2458,6 +2796,7 @@
24582796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24592797 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24602798 }
2799
+
24612800 //cJME.count++;
24622801 //cJME.count %= 12;
24632802 if (gc)
....@@ -2641,6 +2980,7 @@
26412980 }
26422981 }
26432982 }
2983
+
26442984 cFileSystemPane FSPane;
26452985
26462986 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2694,11 +3034,14 @@
26943034 }
26953035 }
26963036 }
3037
+
26973038 freezematerial = false;
26983039 }
26993040
27003041 void SetMaterial(Object3D object)
27013042 {
3043
+ latestObject = object;
3044
+
27023045 cMaterial mat = object.material;
27033046
27043047 if (mat == null)
....@@ -2810,12 +3153,17 @@
28103153 // }
28113154
28123155 /**/
2813
- if (deselect)
3156
+ if (deselect || child == null)
28143157 {
28153158 //group.deselectAll();
28163159 //freeze = true;
28173160 GetTree().clearSelection();
28183161 //freeze = false;
3162
+
3163
+ if (child == null)
3164
+ {
3165
+ return;
3166
+ }
28193167 }
28203168
28213169 //group.addSelectee(child);
....@@ -2884,7 +3232,7 @@
28843232 cameraView.ToggleDL();
28853233 cameraView.repaint();
28863234 return;
2887
- } else if (event.getSource() == toggleTextureItem)
3235
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28883236 {
28893237 cameraView.ToggleTexture();
28903238 // june 2013 copy.HardTouch();
....@@ -2923,9 +3271,9 @@
29233271 frame.validate();
29243272
29253273 return;
2926
- } else if (event.getSource() == toggleSwitchItem)
3274
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29273275 {
2928
- cameraView.ToggleRandom();
3276
+ cameraView.ToggleSwitch();
29293277 cameraView.repaint();
29303278 return;
29313279 } else if (event.getSource() == toggleHandleItem)
....@@ -2954,7 +3302,7 @@
29543302 {
29553303 copy.live ^= true;
29563304 return;
2957
- } else if (event.getSource() == selectCB)
3305
+ } else if (event.getSource() == selectableCB)
29583306 {
29593307 copy.dontselect ^= true;
29603308 return;
....@@ -3139,9 +3487,9 @@
31393487 {
31403488 Close();
31413489 //return true;
3142
- } else if (source == loadItem)
3490
+ } else if (source == openItem)
31433491 {
3144
- load();
3492
+ Open();
31453493 //return true;
31463494 } else if (source == newItem)
31473495 {
....@@ -3166,6 +3514,10 @@
31663514 {
31673515 generatePOV();
31683516 //return true;
3517
+ } else if (event.getSource() == archiveItem)
3518
+ {
3519
+ cTools.Archive(frame);
3520
+ return;
31693521 } else if (source == zBufferItem)
31703522 {
31713523 try
....@@ -3207,10 +3559,369 @@
32073559 {
32083560 copy.remove(1);
32093561 }
3562
+
32103563 ResetModel();
32113564 objEditor.refreshContents();
32123565 }
32133566
3567
+ static public byte[] Compress(Object3D o)
3568
+ {
3569
+ // Slower to actually compress.
3570
+ try
3571
+ {
3572
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3573
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3574
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
3575
+
3576
+ Object3D parent = o.parent;
3577
+ o.parent = null;
3578
+
3579
+ out.writeObject(o);
3580
+
3581
+ o.parent = parent;
3582
+
3583
+ out.flush();
3584
+
3585
+ baos //zstream
3586
+ .close();
3587
+ out.close();
3588
+
3589
+ byte[] bytes = baos.toByteArray();
3590
+
3591
+ System.out.println("save #bytes = " + bytes.length);
3592
+ return bytes;
3593
+ } catch (Exception e)
3594
+ {
3595
+ System.err.println(e);
3596
+ return null;
3597
+ }
3598
+ }
3599
+
3600
+ static public Object Uncompress(byte[] bytes)
3601
+ {
3602
+ System.out.println("restore #bytes = " + bytes.length);
3603
+ try
3604
+ {
3605
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3606
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3607
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
3608
+ Object obj = in.readObject();
3609
+
3610
+ bais //istream
3611
+ .close();
3612
+ in.close();
3613
+
3614
+ return obj;
3615
+ } catch (Exception e)
3616
+ {
3617
+ System.err.println(e);
3618
+ return null;
3619
+ }
3620
+ }
3621
+
3622
+ static public Object clone(Object o)
3623
+ {
3624
+ try
3625
+ {
3626
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
3627
+ ObjectOutputStream out = new ObjectOutputStream(baos);
3628
+
3629
+ out.writeObject(o);
3630
+
3631
+ out.flush();
3632
+ out.close();
3633
+
3634
+ byte[] bytes = baos.toByteArray();
3635
+
3636
+ System.out.println("clone = " + bytes.length);
3637
+
3638
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3639
+ ObjectInputStream in = new ObjectInputStream(bais);
3640
+ Object obj = in.readObject();
3641
+ in.close();
3642
+
3643
+ return obj;
3644
+ } catch (Exception e)
3645
+ {
3646
+ System.err.println(e);
3647
+ return null;
3648
+ }
3649
+ }
3650
+
3651
+ cRadio GetCurrentTab()
3652
+ {
3653
+ cRadio ab;
3654
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3655
+ {
3656
+ ab = (cRadio)e.nextElement();
3657
+ if(ab.GetObject() == copy)
3658
+ {
3659
+ return ab;
3660
+ }
3661
+ }
3662
+
3663
+ return null;
3664
+ }
3665
+
3666
+
3667
+ public void Save()
3668
+ {
3669
+ //Save(true);
3670
+ Replace();
3671
+ }
3672
+
3673
+ private boolean Equal(byte[] compress, byte[] name)
3674
+ {
3675
+ if (compress.length != name.length)
3676
+ {
3677
+ return false;
3678
+ }
3679
+
3680
+ for (int i=compress.length; --i>=0;)
3681
+ {
3682
+ if (compress[i] != name[i])
3683
+ return false;
3684
+ }
3685
+
3686
+ return true;
3687
+ }
3688
+
3689
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3690
+
3691
+ public boolean Save(boolean user)
3692
+ {
3693
+ System.err.println("Save");
3694
+
3695
+ cRadio tab = GetCurrentTab();
3696
+
3697
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
3698
+
3699
+ boolean thesame = false;
3700
+
3701
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3702
+// {
3703
+// thesame = true;
3704
+// }
3705
+
3706
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3707
+ if (!thesame)
3708
+ {
3709
+ //tab.user[tab.versionindex] = user;
3710
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3711
+
3712
+ copy.versions[++copy.versionindex] = compress;
3713
+
3714
+ // if (increment)
3715
+ // tab.versionindex++;
3716
+ }
3717
+
3718
+ //copy.RestoreBigData(versiontable);
3719
+
3720
+ //assert(hashtable.isEmpty());
3721
+
3722
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3723
+ {
3724
+ //tab.user[i] = false;
3725
+ copy.versions[i] = null;
3726
+ }
3727
+
3728
+ SetUndoStates();
3729
+
3730
+ // test save
3731
+ if (false)
3732
+ {
3733
+ try
3734
+ {
3735
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
3736
+ ObjectOutputStream p = new ObjectOutputStream(ostream);
3737
+
3738
+ p.writeObject(copy);
3739
+
3740
+ p.flush();
3741
+
3742
+ ostream.close();
3743
+ } catch (Exception e)
3744
+ {
3745
+ e.printStackTrace();
3746
+ }
3747
+ }
3748
+
3749
+ return !thesame;
3750
+ }
3751
+
3752
+ void CopyChanged(Object3D obj)
3753
+ {
3754
+ SetUndoStates();
3755
+
3756
+ boolean temp = CameraPane.SWITCH;
3757
+ CameraPane.SWITCH = false;
3758
+
3759
+ copy.ExtractBigData(versiontable);
3760
+
3761
+ copy.clear();
3762
+
3763
+ copy.skyboxname = obj.skyboxname;
3764
+ copy.skyboxext = obj.skyboxext;
3765
+
3766
+ for (int i=0; i<obj.Size(); i++)
3767
+ {
3768
+ copy.add(obj.get(i));
3769
+ }
3770
+
3771
+ copy.RestoreBigData(versiontable);
3772
+
3773
+ CameraPane.SWITCH = temp;
3774
+
3775
+ //assert(hashtable.isEmpty());
3776
+
3777
+ copy.Touch();
3778
+
3779
+ ResetModel();
3780
+ copy.HardTouch(); // recompile?
3781
+
3782
+ cRadio ab;
3783
+ for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
3784
+ {
3785
+ ab = (cRadio)e.nextElement();
3786
+ Object3D test = copy.GetObject(ab.object.GetUUID());
3787
+ //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
3788
+ if (test != null)
3789
+ {
3790
+ test.editWindow = ab.object.editWindow;
3791
+ ab.object = test;
3792
+ }
3793
+ }
3794
+
3795
+ refreshContents();
3796
+ }
3797
+
3798
+ cButton undoButton;
3799
+ cButton restoreButton;
3800
+ cButton replaceButton;
3801
+ cButton redoButton;
3802
+
3803
+ boolean muteSlider;
3804
+
3805
+ int VersionCount()
3806
+ {
3807
+ int count = 0;
3808
+
3809
+ for (int i = copy.versions.length; --i >= 0;)
3810
+ {
3811
+ if (copy.versions[i] != null)
3812
+ count++;
3813
+ }
3814
+
3815
+ return count;
3816
+ }
3817
+
3818
+ void SetUndoStates()
3819
+ {
3820
+ cRadio tab = GetCurrentTab();
3821
+
3822
+ restoreButton.setEnabled(copy.versionindex != -1);
3823
+ replaceButton.setEnabled(copy.versionindex != -1);
3824
+
3825
+ undoButton.setEnabled(copy.versionindex > 0);
3826
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3827
+
3828
+ muteSlider = true;
3829
+ versionSlider.setMaximum(VersionCount() - 1);
3830
+ versionSlider.setInteger(copy.versionindex);
3831
+ muteSlider = false;
3832
+ }
3833
+
3834
+ public boolean Undo()
3835
+ {
3836
+ // Option?
3837
+ Replace();
3838
+
3839
+ System.err.println("Undo");
3840
+
3841
+ cRadio tab = GetCurrentTab();
3842
+
3843
+ if (copy.versionindex == 0)
3844
+ {
3845
+ java.awt.Toolkit.getDefaultToolkit().beep();
3846
+ return false;
3847
+ }
3848
+
3849
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3850
+// {
3851
+// if (Save(false))
3852
+// tab.versionindex -= 1;
3853
+// else
3854
+// {
3855
+// if (tab.versionindex <= 0)
3856
+// return false;
3857
+// else
3858
+// tab.versionindex -= 1;
3859
+// }
3860
+// }
3861
+
3862
+ copy.versionindex -= 1;
3863
+
3864
+ CopyChanged((Object3D)copy.versions[copy.versionindex]);
3865
+
3866
+ return true;
3867
+ }
3868
+
3869
+ public boolean Restore()
3870
+ {
3871
+ System.err.println("Restore");
3872
+
3873
+ cRadio tab = GetCurrentTab();
3874
+
3875
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3876
+ {
3877
+ java.awt.Toolkit.getDefaultToolkit().beep();
3878
+ return false;
3879
+ }
3880
+
3881
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
+ CopyChanged(copy.versions[copy.versionindex]);
3883
+
3884
+ return true;
3885
+ }
3886
+
3887
+ public boolean Replace()
3888
+ {
3889
+ System.err.println("Replace");
3890
+
3891
+ cRadio tab = GetCurrentTab();
3892
+
3893
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3894
+ {
3895
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3896
+ return false;
3897
+ }
3898
+
3899
+ copy.versions[copy.versionindex] = CompressCopy();
3900
+
3901
+ return true;
3902
+ }
3903
+
3904
+ public void Redo()
3905
+ {
3906
+ // Option?
3907
+ Replace();
3908
+
3909
+ cRadio tab = GetCurrentTab();
3910
+
3911
+ if (copy.versions[copy.versionindex + 1] == null)
3912
+ {
3913
+ java.awt.Toolkit.getDefaultToolkit().beep();
3914
+ return;
3915
+ }
3916
+
3917
+ copy.versionindex += 1;
3918
+
3919
+ CopyChanged(copy.versions[copy.versionindex]);
3920
+
3921
+ //if (!tab.user[tab.versionindex])
3922
+ // tab.graphs[tab.versionindex] = null;
3923
+ }
3924
+
32143925 void ImportGFD()
32153926 {
32163927 FileDialog browser = new FileDialog(objEditor.frame, "Import GrafreeD", FileDialog.LOAD);
....@@ -3360,7 +4071,7 @@
33604071 assert false;
33614072 }
33624073
3363
- void EditSelection()
4074
+ void EditSelection(boolean newWindow)
33644075 {
33654076 }
33664077
....@@ -3504,9 +4215,25 @@
35044215 //copy.Touch();
35054216 }
35064217
4218
+ cNumberSlider versionSlider;
4219
+
35074220 public void stateChanged(ChangeEvent e)
35084221 {
35094222 // assert(false);
4223
+ if (e.getSource() == versionSlider)
4224
+ {
4225
+ if (muteSlider)
4226
+ return;
4227
+
4228
+ int version = versionSlider.getInteger();
4229
+
4230
+ if (copy.versions[version] != null)
4231
+ {
4232
+ CopyChanged(copy.versions[copy.versionindex = version]);
4233
+ }
4234
+
4235
+ return;
4236
+ }
35104237
35114238 if (freezematerial)
35124239 {
....@@ -3855,6 +4582,8 @@
38554582
38564583 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
38574584 {
4585
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4586
+ Save();
38584587 //Tween.set(thing, 0).target(1).start(tweenManager);
38594588 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
38604589 // if (thing instanceof GenericJointDemo)
....@@ -3941,6 +4670,12 @@
39414670 {
39424671 ResetModel();
39434672 Select(thing.GetTreePath(), true, false); // unselect... false);
4673
+
4674
+ if (thing.Size() == 0)
4675
+ {
4676
+ //EditSelection(false);
4677
+ }
4678
+
39444679 refreshContents();
39454680 }
39464681
....@@ -4078,6 +4813,7 @@
40784813
40794814 try
40804815 {
4816
+ // Try compressed version first.
40814817 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
40824818 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
40834819 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4088,7 +4824,9 @@
40884824 readobj.ResetDisplayList();
40894825 } catch (Exception e)
40904826 {
4091
- //e.printStackTrace();
4827
+ if (!e.toString().contains("GZIP"))
4828
+ e.printStackTrace();
4829
+
40924830 try
40934831 {
40944832 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4147,6 +4885,12 @@
41474885
41484886 void LoadIt(Object obj)
41494887 {
4888
+ if (obj == null)
4889
+ {
4890
+ // Invalid file
4891
+ return;
4892
+ }
4893
+
41504894 System.out.println("Loaded " + obj);
41514895 //new Exception().printStackTrace();
41524896 Object3D readobj = (Object3D) obj;
....@@ -4156,10 +4900,14 @@
41564900
41574901 if (readobj != null)
41584902 {
4903
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4904
+ // Save();
41594905 try
41604906 {
41614907 //readobj.deepCopySelf(copy);
41624908 copy.clear(); // june 2014
4909
+ copy.skyboxname = readobj.skyboxname;
4910
+ copy.skyboxext = readobj.skyboxext;
41634911 for (int i = 0; i < readobj.size(); i++)
41644912 {
41654913 Object3D child = readobj.get(i); // reserve(i);
....@@ -4200,6 +4948,7 @@
42004948 }
42014949 } catch (ClassCastException e)
42024950 {
4951
+ e.printStackTrace();
42034952 assert (false);
42044953 Composite c = (Composite) copy;
42054954 c.children.clear();
....@@ -4210,13 +4959,24 @@
42104959 c.addChild(csg);
42114960 }
42124961
4962
+ copy.versions = readobj.versions;
4963
+ copy.versionindex = readobj.versionindex;
4964
+
4965
+ if (copy.versions == null)
4966
+ {
4967
+ copy.versions = new Object3D[100];
4968
+ copy.versionindex = -1;
4969
+ }
4970
+
4971
+ //? SetUndoStates();
4972
+
42134973 ResetModel();
42144974 copy.HardTouch(); // recompile?
42154975 refreshContents();
42164976 }
42174977 }
42184978
4219
- void load() // throws ClassNotFoundException
4979
+ void Open() // throws ClassNotFoundException
42204980 {
42214981 if (Grafreed.standAlone)
42224982 {
....@@ -4319,6 +5079,7 @@
43195079 //ps.print(buffer.toString());
43205080 } catch (IOException e)
43215081 {
5082
+ e.printStackTrace();
43225083 }
43235084 }
43245085
....@@ -4333,6 +5094,8 @@
43335094 String filename = browser.getFile();
43345095 if (filename != null && filename.length() > 0)
43355096 {
5097
+ if (!filename.endsWith(".gfd"))
5098
+ filename += ".gfd";
43365099 lastname = browser.getDirectory() + filename;
43375100 save();
43385101 }
....@@ -4499,7 +5262,7 @@
44995262 MenuBar menuBar;
45005263 Menu fileMenu;
45015264 MenuItem newItem;
4502
- MenuItem loadItem;
5265
+ MenuItem openItem;
45035266 MenuItem saveItem;
45045267 MenuItem saveAsItem;
45055268 MenuItem exportAsItem;
....@@ -4522,22 +5285,36 @@
45225285 CheckboxMenuItem toggleSwitchItem;
45235286 CheckboxMenuItem toggleRootItem;
45245287 CheckboxMenuItem animationItem;
5288
+ MenuItem archiveItem;
45255289 CheckboxMenuItem toggleHandleItem;
45265290 CheckboxMenuItem togglePaintItem;
45275291 JSplitPane mainPanel;
45285292 JScrollPane scrollpane;
5293
+
45295294 JPanel toolbarPanel;
5295
+
45305296 cGridBag treePanel;
5297
+
45315298 JPanel radioPanel;
45325299 ButtonGroup buttonGroup;
4533
- cGridBag ctrlPanel;
5300
+
5301
+ cGridBag toolboxPanel;
45345302 cGridBag materialPanel;
5303
+ cGridBag ctrlPanel;
5304
+
45355305 JScrollPane infoPanel;
5306
+
45365307 cGridBag optionsPanel;
5308
+
45375309 JTabbedPane objectPanel;
5310
+ boolean materialFlushed;
5311
+ Object3D latestObject;
5312
+
45385313 cGridBag XYZPanel;
5314
+
45395315 JSplitPane gridPanel;
45405316 JSplitPane bigPanel;
5317
+
45415318 cGridBag bigThree;
45425319 cGridBag scenePanel;
45435320 cGridBag centralPanel;
....@@ -4652,7 +5429,7 @@
46525429 cNumberSlider fogField;
46535430 JLabel opacityPowerLabel;
46545431 cNumberSlider opacityPowerField;
4655
- JTree jTree;
5432
+ cTree jTree;
46565433 //ObjectUI parent;
46575434
46585435 cNumberSlider normalpushField;