Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -37,6 +41,79 @@
3741 JFrame frame;
3842
3943 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
52
+
53
+ cButton GetButton(String name, boolean border)
54
+ {
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
63
+ }
64
+
65
+ cToggleButton GetToggleButton(String name, boolean border)
66
+ {
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
79
+ try
80
+ {
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
97
+ }
98
+ catch (Exception e)
99
+ {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ BufferedImage GetImage(String name)
105
+ {
106
+ try
107
+ {
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
111
+ }
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
116
+ }
40117
41118 // SCRIPT
42119
....@@ -147,7 +224,7 @@
147224
148225 objEditor.ctrlPanel.remove(namePanel);
149226
150
- if (!GroupEditor.allparams)
227
+ if (!allparams)
151228 return;
152229
153230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -219,6 +296,12 @@
219296 client = inClient;
220297 copy = client;
221298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
222305 // "this" is not called: SetupUI2(objEditor);
223306 }
224307
....@@ -232,6 +315,12 @@
232315 client = inClient;
233316 copy = client;
234317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
235324 SetupUI2(callee.GetEditor());
236325 }
237326
....@@ -246,7 +335,7 @@
246335 //localCopy.parent = null;
247336
248337 frame = new JFrame();
249
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
250339 objEditor = this;
251340 this.callee = callee;
252341
....@@ -264,6 +353,12 @@
264353 copy = localCopy;
265354 copy.editWindow = this;
266355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
267362 SetupMenu();
268363
269364 //SetupName(objEditor); // new
....@@ -277,12 +372,17 @@
277372 return frame.action(event, obj);
278373 }
279374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
280380 void SetupMenu()
281381 {
282382 frame.setMenuBar(menuBar = new MenuBar());
283383 menuBar.add(fileMenu = new Menu("File"));
284384 fileMenu.add(newItem = new MenuItem("New"));
285
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
286386
287387 //oe.menuBar.add(menu = new Menu("Include"));
288388 Menu menu = new Menu("Import");
....@@ -314,7 +414,7 @@
314414 }
315415
316416 newItem.addActionListener(this);
317
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
318418 saveItem.addActionListener(this);
319419 saveAsItem.addActionListener(this);
320420 exportAsItem.addActionListener(this);
....@@ -323,13 +423,40 @@
323423 closeItem.addActionListener(this);
324424
325425 objectPanel = new JTabbedPane();
426
+
427
+ ChangeListener changeListener = new ChangeListener()
428
+ {
429
+ public void stateChanged(ChangeEvent changeEvent)
430
+ {
431
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
432
+// {
433
+// if (latestObject != null)
434
+// {
435
+// refreshContents(true);
436
+// SetMaterial(latestObject);
437
+// }
438
+//
439
+// materialFlushed = true;
440
+// }
441
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
442
+// {
443
+// if (listUI.size() == 0)
444
+// EditSelection(false);
445
+// }
446
+
447
+ refreshContents(false); // To refresh Info tab
448
+ }
449
+ };
450
+ objectPanel.addChangeListener(changeListener);
451
+
326452 toolbarPanel = new JPanel();
327453 toolbarPanel.setName("Toolbar");
454
+
328455 treePanel = new cGridBag();
329456 treePanel.setName("Tree");
330457
331458 editPanel = new cGridBag().setVertical(true);
332
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
333460
334461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
335462
....@@ -337,23 +464,27 @@
337464 editPanel.add(editCommandsPanel);
338465 editPanel.add(ctrlPanel);
339466
340
- materialPanel = new cGridBag().setVertical(true);
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
341469
342
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
472
+
343473 /*JTextPane*/
344474 infoarea = createTextPane();
345475 doc = infoarea.getStyledDocument();
346476
347477 infoarea.setEditable(true);
348478 SetText();
479
+
349480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
350481 // infoarea.setOpaque(false);
351482 // //infoarea.setForeground(textcolor);
352483 // TEXTAREA infoarea.setLineWrap(true);
353484 // TEXTAREA infoarea.setWrapStyleWord(true);
354485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
355
- infoPanel.setPreferredSize(new Dimension(50, 200));
356
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
357488 //infoPanel.setLayout(new BorderLayout());
358489 //infoPanel.add(createTextPane());
359490
....@@ -364,7 +495,14 @@
364495 mainPanel.setDividerSize(9);
365496 mainPanel.setDividerLocation(0.5); //1.0);
366497 mainPanel.setResizeWeight(0.5);
367
-
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
+
368506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
369507 //mainPanel.setLayout(new GridBagLayout());
370508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -595,8 +733,8 @@
595733 }
596734 }
597735
598
-static GraphicsDevice device = GraphicsEnvironment
599
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
600738
601739 Rectangle keeprect;
602740 cRadio radio;
....@@ -612,13 +750,24 @@
612750
613751 boolean maximized;
614752
753
+ cButton fullscreenLayout;
754
+
615755 void Minimize()
616756 {
617757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
618759 }
619760
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={}
620764 void Maximize()
621765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
622771 if (maximized)
623772 {
624773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -626,20 +775,36 @@
626775 else
627776 {
628777 keeprect = frame.getBounds();
629
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
630
- Dimension rect2 = frame.getToolkit().getScreenSize();
631
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
632781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
633783 }
634784
635785 maximized ^= true;
786
+
787
+ frame.validate();
636788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
637793
638794 void ToggleFullScreen()
639795 {
640
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
641801 {
642802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
643808 //frame.setVisible(false);
644809 // frame.removeNotify();
645810 // frame.setUndecorated(false);
....@@ -649,7 +814,7 @@
649814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
650815 // X framePanel.add(bigThree);
651816 // X frame.getContentPane().add(/*"Center",*/framePanel);
652
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
653818
654819 //frame.setVisible(true);
655820 radio.layout = keepButton;
....@@ -664,7 +829,12 @@
664829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
665830 // frame.getToolkit().getScreenSize().height);
666831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
667835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
668838 // frame.removeNotify();
669839 // frame.setUndecorated(true);
670840 // frame.addNotify();
....@@ -673,13 +843,35 @@
673843 // X frame.getContentPane().add(/*"Center",*/bigThree);
674844 framePanel.setDividerLocation(0);
675845
676
- radio.layout = twoButton;
846
+ radio.layout = fullscreenLayout;
677847 radio.layout.doClick();
678848 //frame.setVisible(true);
679849 }
680
-
681
- cameraView.ToggleFullScreen();
850
+ frame.validate();
682851 }
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.versionlist;
862
+ copy.versionlist = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versionlist = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
683875
684876 private JTextPane createTextPane()
685877 {
....@@ -802,6 +994,7 @@
802994 {
803995 SetupMaterial(materialPanel);
804996 }
997
+
805998 //SetupName();
806999 //SetupViews();
8071000 }
....@@ -811,7 +1004,7 @@
8111004 // NumberSlider vDivsField;
8121005 // JCheckBox endcaps;
8131006 JCheckBox liveCB;
814
- JCheckBox selectCB;
1007
+ JCheckBox selectableCB;
8151008 JCheckBox hideCB;
8161009 JCheckBox link2masterCB;
8171010 JCheckBox markCB;
....@@ -819,7 +1012,12 @@
8191012 JCheckBox speedupCB;
8201013 JCheckBox rewindCB;
8211014 JCheckBox flipVCB;
1015
+
1016
+ cCheckBox toggleTextureCB;
1017
+ cCheckBox toggleSwitchCB;
1018
+
8221019 JComboBox texresMenu;
1020
+
8231021 JButton resetButton;
8241022 JButton stepButton;
8251023 JButton stepAllButton;
....@@ -1006,38 +1204,42 @@
10061204 namePanel = new cGridBag();
10071205
10081206 nameField = AddText(namePanel, copy.GetName());
1009
- namePanel.add(nameField);
1207
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10101208 oe.ctrlPanel.add(namePanel);
10111209
10121210 oe.ctrlPanel.Return();
10131211
1014
- if (!GroupEditor.allparams)
1212
+ if (!allparams)
10151213 return;
10161214
10171215 setupPanel = new cGridBag().setVertical(false);
10181216
10191217 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10201218 liveCB.setToolTipText("Animate object");
1021
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1022
- selectCB.setToolTipText("Make object selectable");
1219
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1220
+ selectableCB.setToolTipText("Make object selectable");
10231221 // Return();
1222
+
10241223 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10251224 hideCB.setToolTipText("Hide object");
10261225 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1027
- markCB.setToolTipText("Set the animation target transform");
1226
+ markCB.setToolTipText("As animation target transform");
1227
+
1228
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10281229
10291230 setupPanel2 = new cGridBag().setVertical(false);
10301231
10311232 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10321233 rewindCB.setToolTipText("Rewind animation");
10331234
1034
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1035
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1235
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1236
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10361237
1238
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1239
+ link2masterCB.setToolTipText("Attach to support");
1240
+
10371241 if (Globals.ADVANCED)
10381242 {
1039
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1040
- link2masterCB.setToolTipText("Attach to support");
10411243 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10421244 speedupCB.setToolTipText("Option motion capture");
10431245 }
....@@ -1311,6 +1513,7 @@
13111513 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13121514 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13131515 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1516
+ //XYZPanel.setName("XYZ");
13141517
13151518 /*
13161519 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1348,12 +1551,29 @@
13481551 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13491552 //tmp.setName("Edit");
13501553 objectPanel.add(materialPanel);
1554
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
+ objectPanel.setToolTipTextAt(0, "Material");
1556
+
13511557 // JPanel north = new JPanel(new BorderLayout());
13521558 // north.setName("Edit");
13531559 // north.add(ctrlPanel, BorderLayout.NORTH);
13541560 // objectPanel.add(north);
13551561 objectPanel.add(editPanel);
1356
- objectPanel.add(infoPanel);
1562
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1563
+ objectPanel.setToolTipTextAt(1, "Edit controls");
1564
+
1565
+ //if (Globals.ADVANCED)
1566
+ objectPanel.add(infoPanel);
1567
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1568
+ objectPanel.setToolTipTextAt(2, "Information");
1569
+
1570
+ objectPanel.add(XYZPanel);
1571
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1572
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1573
+
1574
+ objectPanel.add(toolboxPanel);
1575
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1576
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
13571577
13581578 /*
13591579 aConstraints.gridx = 0;
....@@ -1362,7 +1582,7 @@
13621582 aConstraints.gridy += 1;
13631583 aConstraints.gridwidth = 1;
13641584 mainPanel.add(objectPanel, aConstraints);
1365
- */
1585
+ */
13661586
13671587 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13681588 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1374,14 +1594,12 @@
13741594 scrollpane.addMouseWheelListener(this); // Default not fast enough
13751595
13761596 /*JTabbedPane*/ scenePanel = new cGridBag();
1377
- scenePanel.preferredWidth = 6;
1597
+ scenePanel.preferredWidth = 5;
13781598
13791599 JTabbedPane tabbedPane = new JTabbedPane();
13801600 tabbedPane.add(scrollpane);
13811601
1382
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1383
-
1384
- optionsPanel = new cGridBag().setVertical(true);
1602
+ optionsPanel = new cGridBag().setVertical(false);
13851603
13861604 optionsPanel.setName("Options");
13871605
....@@ -1389,6 +1607,8 @@
13891607
13901608 tabbedPane.add(optionsPanel);
13911609
1610
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1611
+
13921612 scenePanel.add(tabbedPane);
13931613
13941614 /*
....@@ -1452,7 +1672,7 @@
14521672 bigThree = new cGridBag();
14531673 bigThree.addComponent(scenePanel);
14541674 bigThree.addComponent(centralPanel);
1455
- bigThree.addComponent(XYZPanel);
1675
+ //bigThree.addComponent(XYZPanel);
14561676
14571677 // // SIDE EFFECT!!!
14581678 // aConstraints.gridx = 0;
....@@ -1461,9 +1681,9 @@
14611681 // aConstraints.gridheight = 1;
14621682
14631683 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1464
- framePanel.setContinuousLayout(true);
1465
- framePanel.setOneTouchExpandable(true);
1466
- framePanel.setDividerLocation(0.8);
1684
+ framePanel.setContinuousLayout(false);
1685
+ framePanel.setOneTouchExpandable(false);
1686
+ //.setDividerLocation(0.8);
14671687 //framePanel.setDividerSize(15);
14681688 //framePanel.setResizeWeight(0.15);
14691689 framePanel.setName("Frame");
....@@ -1481,16 +1701,18 @@
14811701 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14821702
14831703 frame.setSize(1280, 860);
1484
- frame.setVisible(true);
1485
-
1704
+
14861705 cameraView.requestFocusInWindow();
14871706
14881707 gridPanel.setDividerLocation(1.0);
1708
+
1709
+ frame.validate();
1710
+
1711
+ frame.setVisible(true);
14891712
14901713 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14911714 frame.addWindowListener(new WindowAdapter()
14921715 {
1493
-
14941716 public void windowClosing(WindowEvent e)
14951717 {
14961718 Close();
....@@ -1513,12 +1735,56 @@
15131735 ctrlPanel.removeAll();
15141736 }
15151737
1516
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
15171739 {
1518
- /*
1740
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1741
+ cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
+ label.addMouseListener(new MouseAdapter()
1743
+ {
1744
+ public void mouseClicked(MouseEvent e)
1745
+ {
1746
+ colorField.setFloat(0);
1747
+ saturationField.setFloat(1);
1748
+ materialtouched = true;
1749
+ applySelf();
1750
+ }
1751
+ });
1752
+ presetpanel.add(label);
1753
+
1754
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
1755
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1756
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1757
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1758
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1759
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1760
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1761
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1762
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1763
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1764
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1765
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1766
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1767
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1768
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1769
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1770
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1771
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));
1772
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));
1773
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));
1774
+
1775
+ cGridBag panel = new cGridBag().setVertical(true);
1776
+
1777
+ presetpanel.preferredWidth = 1;
1778
+
1779
+ materialpanel.add(panel);
1780
+ materialpanel.add(presetpanel);
1781
+
1782
+ panel.preferredWidth = 8;
1783
+
1784
+ /*
15191785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
15201786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1521
- */
1787
+ */
15221788
15231789 cGridBag editBar = new cGridBag().setVertical(false);
15241790
....@@ -1552,45 +1818,50 @@
15521818 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15531819
15541820 cGridBag colorSection = new cGridBag().setVertical(true);
1821
+
1822
+ cGridBag huepanel = new cGridBag();
1823
+ cGridBag huelabel = new cGridBag();
1824
+ label = GetLabel("icons/hue.png", false);
1825
+ label.fit = true;
1826
+ huelabel.add(label);
1827
+ huelabel.preferredWidth = 20;
1828
+ huepanel.add(new cGridBag()); // Label
1829
+ huepanel.add(huelabel); // Field/slider
1830
+
1831
+ huepanel.preferredHeight = 7;
1832
+
1833
+ colorSection.add(huepanel);
15551834
15561835 cGridBag color = new cGridBag();
1557
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1558
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1559
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1836
+
1837
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1838
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1839
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1840
+
15601841 //colorField.preferredWidth = 200;
15611842 colorSection.add(color);
15621843
15631844 cGridBag modulation = new cGridBag();
15641845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
15651846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1566
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
15671848 colorSection.add(modulation);
15681849
1850
+ cGridBag opacity = new cGridBag();
1851
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1852
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1853
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1854
+ colorSection.add(opacity);
1855
+
1856
+ colorSection.add(GetSeparator());
1857
+
15691858 cGridBag texture = new cGridBag();
15701859 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
15711860 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15721861 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15731862 colorSection.add(texture);
15741863
1575
- cGridBag anisoU = new cGridBag();
1576
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1577
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1578
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1579
- colorSection.add(anisoU);
1580
-
1581
- cGridBag anisoV = new cGridBag();
1582
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1583
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1584
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1585
- colorSection.add(anisoV);
1586
-
1587
- cGridBag shadowbias = new cGridBag();
1588
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1589
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1590
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1591
- colorSection.add(shadowbias);
1592
-
1593
- panel.add(new JSeparator());
1864
+ panel.add(GetSeparator());
15941865
15951866 panel.add(colorSection);
15961867
....@@ -1640,7 +1911,13 @@
16401911 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16411912 diffuseSection.add(fakedepth);
16421913
1643
- panel.add(new JSeparator());
1914
+ cGridBag shadowbias = new cGridBag();
1915
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1916
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1917
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1918
+ diffuseSection.add(shadowbias);
1919
+
1920
+ panel.add(GetSeparator());
16441921
16451922 panel.add(diffuseSection);
16461923
....@@ -1690,42 +1967,48 @@
16901967 // aConstraints.gridy += 1;
16911968 // aConstraints.gridwidth = 1;
16921969
1970
+ cGridBag anisoU = new cGridBag();
1971
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1972
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1973
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1974
+ specularSection.add(anisoU);
16931975
1694
- panel.add(new JSeparator());
1976
+ cGridBag anisoV = new cGridBag();
1977
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1978
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1979
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1980
+ specularSection.add(anisoV);
1981
+
1982
+
1983
+ panel.add(GetSeparator());
16951984
16961985 panel.add(specularSection);
16971986
16981987 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16991988
1700
- cGridBag globalSection = new cGridBag().setVertical(true);
1989
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17011990
17021991 cGridBag camera = new cGridBag();
17031992 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17041993 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17051994 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1706
- globalSection.add(camera);
1995
+ colorSection.add(camera);
17071996
17081997 cGridBag ambient = new cGridBag();
17091998 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17101999 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17112000 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1712
- globalSection.add(ambient);
2001
+ colorSection.add(ambient);
17132002
17142003 cGridBag backlit = new cGridBag();
17152004 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17162005 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17172006 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1718
- globalSection.add(backlit);
2007
+ colorSection.add(backlit);
17192008
1720
- cGridBag opacity = new cGridBag();
1721
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1722
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1723
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1724
- globalSection.add(opacity);
1725
-
1726
- panel.add(new JSeparator());
2009
+ //panel.add(new JSeparator());
17272010
1728
- panel.add(globalSection);
2011
+ //panel.add(globalSection);
17292012
17302013 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17312014
....@@ -1767,7 +2050,7 @@
17672050 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
17682051 textureSection.add(opacityPower);
17692052
1770
- panel.add(new JSeparator());
2053
+ panel.add(GetSeparator());
17712054
17722055 panel.add(textureSection);
17732056
....@@ -1832,8 +2115,9 @@
18322115 // 3D models
18332116 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18342117 {
1835
- lastConverter = new com.jmex.model.converters.MaxToJme();
1836
- LoadFile(filename, lastConverter);
2118
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2119
+ //LoadFile(filename, lastConverter);
2120
+ LoadObjFile(filename); // New 3ds loader
18372121 continue;
18382122 }
18392123 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2559,6 +2843,7 @@
25592843 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25602844 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25612845 }
2846
+
25622847 //cJME.count++;
25632848 //cJME.count %= 12;
25642849 if (gc)
....@@ -2742,6 +3027,7 @@
27423027 }
27433028 }
27443029 }
3030
+
27453031 cFileSystemPane FSPane;
27463032
27473033 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2751,7 +3037,7 @@
27513037
27523038 freezematerial = true;
27533039 colorField.setFloat(mat.color);
2754
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
27553041 metalnessField.setFloat(mat.metalness);
27563042 diffuseField.setFloat(mat.diffuse);
27573043 specularField.setFloat(mat.specular);
....@@ -2795,11 +3081,14 @@
27953081 }
27963082 }
27973083 }
3084
+
27983085 freezematerial = false;
27993086 }
28003087
28013088 void SetMaterial(Object3D object)
28023089 {
3090
+ latestObject = object;
3091
+
28033092 cMaterial mat = object.material;
28043093
28053094 if (mat == null)
....@@ -2911,12 +3200,17 @@
29113200 // }
29123201
29133202 /**/
2914
- if (deselect)
3203
+ if (deselect || child == null)
29153204 {
29163205 //group.deselectAll();
29173206 //freeze = true;
29183207 GetTree().clearSelection();
29193208 //freeze = false;
3209
+
3210
+ if (child == null)
3211
+ {
3212
+ return;
3213
+ }
29203214 }
29213215
29223216 //group.addSelectee(child);
....@@ -2985,7 +3279,7 @@
29853279 cameraView.ToggleDL();
29863280 cameraView.repaint();
29873281 return;
2988
- } else if (event.getSource() == toggleTextureItem)
3282
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29893283 {
29903284 cameraView.ToggleTexture();
29913285 // june 2013 copy.HardTouch();
....@@ -3024,7 +3318,7 @@
30243318 frame.validate();
30253319
30263320 return;
3027
- } else if (event.getSource() == toggleSwitchItem)
3321
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30283322 {
30293323 cameraView.ToggleSwitch();
30303324 cameraView.repaint();
....@@ -3054,8 +3348,9 @@
30543348 } else if (event.getSource() == liveCB)
30553349 {
30563350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
30573352 return;
3058
- } else if (event.getSource() == selectCB)
3353
+ } else if (event.getSource() == selectableCB)
30593354 {
30603355 copy.dontselect ^= true;
30613356 return;
....@@ -3063,7 +3358,7 @@
30633358 {
30643359 copy.hide ^= true;
30653360 copy.Touch(); // display list issue
3066
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
30673362 return;
30683363 } else if (event.getSource() == link2masterCB)
30693364 {
....@@ -3240,9 +3535,9 @@
32403535 {
32413536 Close();
32423537 //return true;
3243
- } else if (source == loadItem)
3538
+ } else if (source == openItem)
32443539 {
3245
- load();
3540
+ Open();
32463541 //return true;
32473542 } else if (source == newItem)
32483543 {
....@@ -3267,6 +3562,10 @@
32673562 {
32683563 generatePOV();
32693564 //return true;
3565
+ } else if (event.getSource() == archiveItem)
3566
+ {
3567
+ cTools.Archive(frame);
3568
+ return;
32703569 } else if (source == zBufferItem)
32713570 {
32723571 try
....@@ -3315,11 +3614,12 @@
33153614
33163615 static public byte[] Compress(Object3D o)
33173616 {
3617
+ // Slower to actually compress.
33183618 try
33193619 {
33203620 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3321
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3322
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3621
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3622
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33233623
33243624 Object3D parent = o.parent;
33253625 o.parent = null;
....@@ -3330,10 +3630,14 @@
33303630
33313631 out.flush();
33323632
3333
- zstream.close();
3633
+ baos //zstream
3634
+ .close();
33343635 out.close();
33353636
3336
- return baos.toByteArray();
3637
+ byte[] bytes = baos.toByteArray();
3638
+
3639
+ System.out.println("save #bytes = " + bytes.length);
3640
+ return bytes;
33373641 } catch (Exception e)
33383642 {
33393643 System.err.println(e);
....@@ -3343,13 +3647,16 @@
33433647
33443648 static public Object Uncompress(byte[] bytes)
33453649 {
3346
- System.out.println("#bytes = " + bytes.length);
3650
+ System.out.println("restore #bytes = " + bytes.length);
33473651 try
33483652 {
33493653 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3350
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3351
- ObjectInputStream in = new ObjectInputStream(istream);
3654
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3655
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33523656 Object obj = in.readObject();
3657
+
3658
+ bais //istream
3659
+ .close();
33533660 in.close();
33543661
33553662 return obj;
....@@ -3404,37 +3711,78 @@
34043711 return null;
34053712 }
34063713
3407
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34083714
34093715 public void Save()
34103716 {
3717
+ //Save(true);
3718
+ Replace();
3719
+ SetUndoStates();
3720
+ }
3721
+
3722
+ private boolean Equal(byte[] compress, byte[] name)
3723
+ {
3724
+ if (compress.length != name.length)
3725
+ {
3726
+ return false;
3727
+ }
3728
+
3729
+ for (int i=compress.length; --i>=0;)
3730
+ {
3731
+ if (compress[i] != name[i])
3732
+ return false;
3733
+ }
3734
+
3735
+ return true;
3736
+ }
3737
+
3738
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3739
+
3740
+ public boolean Save(boolean user)
3741
+ {
3742
+ System.err.println("Save");
3743
+ Replace();
3744
+
34113745 cRadio tab = GetCurrentTab();
34123746
3413
- boolean temp = CameraPane.SWITCH;
3414
- CameraPane.SWITCH = false;
3747
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
34153748
3416
- copy.ExtractBigData(hashtable);
3749
+ boolean thesame = false;
3750
+
3751
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3752
+// {
3753
+// thesame = true;
3754
+// }
34173755
34183756 //EditorFrame.m_MainFrame.requestFocusInWindow();
3419
- tab.graphs[tab.undoindex++] = Compress(copy);
3420
-
3421
- copy.RestoreBigData(hashtable);
3422
-
3423
- CameraPane.SWITCH = temp;
3424
-
3425
- //assert(hashtable.isEmpty());
3426
-
3427
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3757
+ if (!thesame)
34283758 {
3429
- tab.graphs[i] = null;
3759
+ //tab.user[tab.versionindex] = user;
3760
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3761
+
3762
+ copy.versionlist[++copy.versionindex] = compress;
3763
+
3764
+ // if (increment)
3765
+ // tab.versionindex++;
34303766 }
34313767
3768
+ //copy.RestoreBigData(versiontable);
3769
+
3770
+ //assert(hashtable.isEmpty());
3771
+
3772
+ for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3773
+ {
3774
+ //tab.user[i] = false;
3775
+ copy.versionlist[i] = null;
3776
+ }
3777
+
3778
+ SetUndoStates();
3779
+
34323780 // test save
34333781 if (false)
34343782 {
34353783 try
34363784 {
3437
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3785
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34383786 ObjectOutputStream p = new ObjectOutputStream(ostream);
34393787
34403788 p.writeObject(copy);
....@@ -3447,26 +3795,66 @@
34473795 e.printStackTrace();
34483796 }
34493797 }
3798
+
3799
+ return !thesame;
3800
+ }
3801
+
3802
+ boolean flashIt = true;
3803
+
3804
+ void RefreshSelection()
3805
+ {
3806
+ Object3D selection = new Object3D();
3807
+
3808
+ for (int i = 0; i < copy.selection.size(); i++)
3809
+ {
3810
+ Object3D elem = copy.selection.elementAt(i);
3811
+
3812
+ Object3D obj = copy.GetObject(elem.GetUUID());
3813
+
3814
+ if (obj == null)
3815
+ {
3816
+ copy.selection.remove(i--);
3817
+ }
3818
+ else
3819
+ {
3820
+ selection.add(obj);
3821
+ copy.selection.setElementAt(obj, i);
3822
+ }
3823
+ }
3824
+
3825
+ flashIt = false;
3826
+ GetTree().clearSelection();
3827
+ for (int i = 0; i < selection.size(); i++)
3828
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3829
+ flashIt = true;
3830
+
3831
+ refreshContents(false);
34503832 }
34513833
34523834 void CopyChanged(Object3D obj)
34533835 {
3836
+ SetUndoStates();
3837
+
34543838 boolean temp = CameraPane.SWITCH;
34553839 CameraPane.SWITCH = false;
34563840
3457
- copy.ExtractBigData(hashtable);
3841
+ copy.ExtractBigData(versiontable);
34583842
34593843 copy.clear();
34603844
3845
+ copy.skyboxname = obj.skyboxname;
3846
+ copy.skyboxext = obj.skyboxext;
3847
+
34613848 for (int i=0; i<obj.Size(); i++)
34623849 {
34633850 copy.add(obj.get(i));
34643851 }
34653852
3466
- copy.RestoreBigData(hashtable);
3853
+ copy.RestoreBigData(versiontable);
34673854
34683855 CameraPane.SWITCH = temp;
34693856
3857
+ RefreshSelection();
34703858 //assert(hashtable.isEmpty());
34713859
34723860 copy.Touch();
....@@ -3490,40 +3878,131 @@
34903878 refreshContents();
34913879 }
34923880
3493
- public void Undo()
3881
+ cButton undoButton;
3882
+ cButton restoreButton;
3883
+ cButton replaceButton;
3884
+ cButton redoButton;
3885
+
3886
+ boolean muteSlider;
3887
+
3888
+ int VersionCount()
3889
+ {
3890
+ int count = 0;
3891
+
3892
+ for (int i = copy.versionlist.length; --i >= 0;)
3893
+ {
3894
+ if (copy.versionlist[i] != null)
3895
+ count++;
3896
+ }
3897
+
3898
+ return count;
3899
+ }
3900
+
3901
+ void SetUndoStates()
34943902 {
34953903 cRadio tab = GetCurrentTab();
34963904
3497
- if (tab.undoindex == 0)
3905
+ restoreButton.setEnabled(copy.versionindex != -1);
3906
+ replaceButton.setEnabled(copy.versionindex != -1);
3907
+
3908
+ undoButton.setEnabled(copy.versionindex > 0);
3909
+ redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3910
+
3911
+ muteSlider = true;
3912
+ versionSlider.setMaximum(VersionCount() - 1);
3913
+ versionSlider.setInteger(copy.versionindex);
3914
+ muteSlider = false;
3915
+ }
3916
+
3917
+ public boolean Undo()
3918
+ {
3919
+ // Option?
3920
+ Replace();
3921
+
3922
+ System.err.println("Undo");
3923
+
3924
+ cRadio tab = GetCurrentTab();
3925
+
3926
+ if (copy.versionindex == 0)
34983927 {
34993928 java.awt.Toolkit.getDefaultToolkit().beep();
3500
- return;
3929
+ return false;
35013930 }
35023931
3503
- if (tab.graphs[tab.undoindex] == null)
3932
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3933
+// {
3934
+// if (Save(false))
3935
+// tab.versionindex -= 1;
3936
+// else
3937
+// {
3938
+// if (tab.versionindex <= 0)
3939
+// return false;
3940
+// else
3941
+// tab.versionindex -= 1;
3942
+// }
3943
+// }
3944
+
3945
+ copy.versionindex -= 1;
3946
+
3947
+ CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
3948
+
3949
+ return true;
3950
+ }
3951
+
3952
+ public boolean Restore()
3953
+ {
3954
+ System.err.println("Restore");
3955
+
3956
+ cRadio tab = GetCurrentTab();
3957
+
3958
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
35043959 {
3505
- Save();
3506
- tab.undoindex -= 1;
3960
+ java.awt.Toolkit.getDefaultToolkit().beep();
3961
+ return false;
35073962 }
35083963
3509
- tab.undoindex -= 1;
3964
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
3966
+
3967
+ return true;
3968
+ }
35103969
3511
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3970
+ public boolean Replace()
3971
+ {
3972
+ System.err.println("Replace");
3973
+
3974
+ cRadio tab = GetCurrentTab();
3975
+
3976
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
3977
+ {
3978
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3979
+ return false;
3980
+ }
3981
+
3982
+ copy.versionlist[copy.versionindex] = CompressCopy();
3983
+
3984
+ return true;
35123985 }
35133986
35143987 public void Redo()
35153988 {
3989
+ // Option?
3990
+ Replace();
3991
+
35163992 cRadio tab = GetCurrentTab();
35173993
3518
- if (tab.graphs[tab.undoindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
35193995 {
35203996 java.awt.Toolkit.getDefaultToolkit().beep();
35213997 return;
35223998 }
35233999
3524
- tab.undoindex += 1;
4000
+ copy.versionindex += 1;
35254001
3526
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
4003
+
4004
+ //if (!tab.user[tab.versionindex])
4005
+ // tab.graphs[tab.versionindex] = null;
35274006 }
35284007
35294008 void ImportGFD()
....@@ -3675,7 +4154,7 @@
36754154 assert false;
36764155 }
36774156
3678
- void EditSelection()
4157
+ void EditSelection(boolean newWindow)
36794158 {
36804159 }
36814160
....@@ -3734,7 +4213,7 @@
37344213 //copy.material = new cMaterial(copy.GetMaterial());
37354214
37364215 current.color = (float) colorField.getFloat();
3737
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
37384217 current.metalness = (float) metalnessField.getFloat();
37394218 current.diffuse = (float) diffuseField.getFloat();
37404219 current.specular = (float) specularField.getFloat();
....@@ -3767,7 +4246,7 @@
37674246 cMaterial mat = copy.material;
37684247
37694248 colorField.SetToolTipValue((mat.color));
3770
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
37714250 metalnessField.SetToolTipValue((mat.metalness));
37724251 diffuseField.SetToolTipValue((mat.diffuse));
37734252 specularField.SetToolTipValue((mat.specular));
....@@ -3819,9 +4298,25 @@
38194298 //copy.Touch();
38204299 }
38214300
4301
+ cNumberSlider versionSlider;
4302
+
38224303 public void stateChanged(ChangeEvent e)
38234304 {
38244305 // assert(false);
4306
+ if (e.getSource() == versionSlider)
4307
+ {
4308
+ if (muteSlider)
4309
+ return;
4310
+
4311
+ int version = versionSlider.getInteger();
4312
+
4313
+ if (copy.versionlist[version] != null)
4314
+ {
4315
+ CopyChanged(copy.versionlist[copy.versionindex = version]);
4316
+ }
4317
+
4318
+ return;
4319
+ }
38254320
38264321 if (freezematerial)
38274322 {
....@@ -3857,6 +4352,12 @@
38574352 {
38584353 //System.out.println("stateChanged = " + this);
38594354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
38604361 applySelf();
38614362 //System.out.println("this = " + this);
38624363 //System.out.println("PARENT = " + parent);
....@@ -4156,6 +4657,7 @@
41564657 {
41574658 if (GetTree() != null)
41584659 {
4660
+ GetTree().revalidate();
41594661 GetTree().repaint();
41604662 }
41614663
....@@ -4170,7 +4672,8 @@
41704672
41714673 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41724674 {
4173
- Save();
4675
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4676
+ Save();
41744677 //Tween.set(thing, 0).target(1).start(tweenManager);
41754678 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41764679 // if (thing instanceof GenericJointDemo)
....@@ -4257,6 +4760,12 @@
42574760 {
42584761 ResetModel();
42594762 Select(thing.GetTreePath(), true, false); // unselect... false);
4763
+
4764
+ if (thing.Size() == 0)
4765
+ {
4766
+ //EditSelection(false);
4767
+ }
4768
+
42604769 refreshContents();
42614770 }
42624771
....@@ -4405,7 +4914,9 @@
44054914 readobj.ResetDisplayList();
44064915 } catch (Exception e)
44074916 {
4408
- //e.printStackTrace();
4917
+ if (!e.toString().contains("GZIP"))
4918
+ e.printStackTrace();
4919
+
44094920 try
44104921 {
44114922 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4479,11 +4990,14 @@
44794990
44804991 if (readobj != null)
44814992 {
4482
- Save();
4993
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4994
+ // Save();
44834995 try
44844996 {
44854997 //readobj.deepCopySelf(copy);
44864998 copy.clear(); // june 2014
4999
+ copy.skyboxname = readobj.skyboxname;
5000
+ copy.skyboxext = readobj.skyboxext;
44875001 for (int i = 0; i < readobj.size(); i++)
44885002 {
44895003 Object3D child = readobj.get(i); // reserve(i);
....@@ -4524,6 +5038,7 @@
45245038 }
45255039 } catch (ClassCastException e)
45265040 {
5041
+ e.printStackTrace();
45275042 assert (false);
45285043 Composite c = (Composite) copy;
45295044 c.children.clear();
....@@ -4534,13 +5049,24 @@
45345049 c.addChild(csg);
45355050 }
45365051
5052
+ copy.versionlist = readobj.versionlist;
5053
+ copy.versionindex = readobj.versionindex;
5054
+
5055
+ if (copy.versionlist == null)
5056
+ {
5057
+ copy.versionlist = new Object3D[100];
5058
+ copy.versionindex = -1;
5059
+ }
5060
+
5061
+ //? SetUndoStates();
5062
+
45375063 ResetModel();
45385064 copy.HardTouch(); // recompile?
45395065 refreshContents();
45405066 }
45415067 }
45425068
4543
- void load() // throws ClassNotFoundException
5069
+ void Open() // throws ClassNotFoundException
45445070 {
45455071 if (Grafreed.standAlone)
45465072 {
....@@ -4643,6 +5169,7 @@
46435169 //ps.print(buffer.toString());
46445170 } catch (IOException e)
46455171 {
5172
+ e.printStackTrace();
46465173 }
46475174 }
46485175
....@@ -4657,6 +5184,8 @@
46575184 String filename = browser.getFile();
46585185 if (filename != null && filename.length() > 0)
46595186 {
5187
+ if (!filename.endsWith(".gfd"))
5188
+ filename += ".gfd";
46605189 lastname = browser.getDirectory() + filename;
46615190 save();
46625191 }
....@@ -4823,7 +5352,7 @@
48235352 MenuBar menuBar;
48245353 Menu fileMenu;
48255354 MenuItem newItem;
4826
- MenuItem loadItem;
5355
+ MenuItem openItem;
48275356 MenuItem saveItem;
48285357 MenuItem saveAsItem;
48295358 MenuItem exportAsItem;
....@@ -4846,22 +5375,36 @@
48465375 CheckboxMenuItem toggleSwitchItem;
48475376 CheckboxMenuItem toggleRootItem;
48485377 CheckboxMenuItem animationItem;
5378
+ MenuItem archiveItem;
48495379 CheckboxMenuItem toggleHandleItem;
48505380 CheckboxMenuItem togglePaintItem;
48515381 JSplitPane mainPanel;
48525382 JScrollPane scrollpane;
5383
+
48535384 JPanel toolbarPanel;
5385
+
48545386 cGridBag treePanel;
5387
+
48555388 JPanel radioPanel;
48565389 ButtonGroup buttonGroup;
4857
- cGridBag ctrlPanel;
5390
+
5391
+ cGridBag toolboxPanel;
48585392 cGridBag materialPanel;
5393
+ cGridBag ctrlPanel;
5394
+
48595395 JScrollPane infoPanel;
5396
+
48605397 cGridBag optionsPanel;
5398
+
48615399 JTabbedPane objectPanel;
5400
+ boolean materialFlushed;
5401
+ Object3D latestObject;
5402
+
48625403 cGridBag XYZPanel;
5404
+
48635405 JSplitPane gridPanel;
48645406 JSplitPane bigPanel;
5407
+
48655408 cGridBag bigThree;
48665409 cGridBag scenePanel;
48675410 cGridBag centralPanel;
....@@ -4919,7 +5462,7 @@
49195462 JLabel colorLabel;
49205463 cNumberSlider colorField;
49215464 JLabel modulationLabel;
4922
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
49235466 JLabel metalnessLabel;
49245467 cNumberSlider metalnessField;
49255468 JLabel diffuseLabel;
....@@ -4976,7 +5519,7 @@
49765519 cNumberSlider fogField;
49775520 JLabel opacityPowerLabel;
49785521 cNumberSlider opacityPowerField;
4979
- JTree jTree;
5522
+ cTree jTree;
49805523 //ObjectUI parent;
49815524
49825525 cNumberSlider normalpushField;