Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -38,64 +41,78 @@
3841 JFrame frame;
3942
4043 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4152
4253 cButton GetButton(String name, boolean border)
4354 {
44
- try
45
- {
46
- ImageIcon icon = GetIcon(name);
47
- return new cButton(icon, border);
48
- }
49
- catch (Exception e)
50
- {
51
- return new cButton(name, border);
52
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5363 }
5464
5565 cToggleButton GetToggleButton(String name, boolean border)
5666 {
57
- try
58
- {
59
- ImageIcon icon = GetIcon(name);
60
- return new cToggleButton(icon, border);
61
- }
62
- catch (Exception e)
63
- {
64
- return new cToggleButton(name, border);
65
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6669 }
6770
6871 cCheckBox GetCheckBox(String name, boolean border)
6972 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7079 try
7180 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7497 }
7598 catch (Exception e)
7699 {
77
- return new cCheckBox(name, border);
100
+ return null;
78101 }
79102 }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
82105 {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
86107 {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
95111 }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
99116 }
100117
101118 // SCRIPT
....@@ -279,6 +296,12 @@
279296 client = inClient;
280297 copy = client;
281298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
282305 // "this" is not called: SetupUI2(objEditor);
283306 }
284307
....@@ -292,6 +315,12 @@
292315 client = inClient;
293316 copy = client;
294317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
295324 SetupUI2(callee.GetEditor());
296325 }
297326
....@@ -306,7 +335,7 @@
306335 //localCopy.parent = null;
307336
308337 frame = new JFrame();
309
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
310339 objEditor = this;
311340 this.callee = callee;
312341
....@@ -324,6 +353,12 @@
324353 copy = localCopy;
325354 copy.editWindow = this;
326355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
327362 SetupMenu();
328363
329364 //SetupName(objEditor); // new
....@@ -347,7 +382,7 @@
347382 frame.setMenuBar(menuBar = new MenuBar());
348383 menuBar.add(fileMenu = new Menu("File"));
349384 fileMenu.add(newItem = new MenuItem("New"));
350
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
351386
352387 //oe.menuBar.add(menu = new Menu("Include"));
353388 Menu menu = new Menu("Import");
....@@ -379,7 +414,7 @@
379414 }
380415
381416 newItem.addActionListener(this);
382
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
383418 saveItem.addActionListener(this);
384419 saveAsItem.addActionListener(this);
385420 exportAsItem.addActionListener(this);
....@@ -416,11 +451,12 @@
416451
417452 toolbarPanel = new JPanel();
418453 toolbarPanel.setName("Toolbar");
454
+
419455 treePanel = new cGridBag();
420456 treePanel.setName("Tree");
421457
422458 editPanel = new cGridBag().setVertical(true);
423
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
424460
425461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
426462
....@@ -428,11 +464,11 @@
428464 editPanel.add(editCommandsPanel);
429465 editPanel.add(ctrlPanel);
430466
431
- toolboxPanel = new cGridBag().setVertical(false);
432
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
433469
434
- materialPanel = new cGridBag().setVertical(true);
435
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
436472
437473 /*JTextPane*/
438474 infoarea = createTextPane();
....@@ -440,14 +476,15 @@
440476
441477 infoarea.setEditable(true);
442478 SetText();
479
+
443480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
444481 // infoarea.setOpaque(false);
445482 // //infoarea.setForeground(textcolor);
446483 // TEXTAREA infoarea.setLineWrap(true);
447484 // TEXTAREA infoarea.setWrapStyleWord(true);
448485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
449
- infoPanel.setPreferredSize(new Dimension(50, 200));
450
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
451488 //infoPanel.setLayout(new BorderLayout());
452489 //infoPanel.add(createTextPane());
453490
....@@ -458,7 +495,14 @@
458495 mainPanel.setDividerSize(9);
459496 mainPanel.setDividerLocation(0.5); //1.0);
460497 mainPanel.setResizeWeight(0.5);
461
-
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
+
462506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
463507 //mainPanel.setLayout(new GridBagLayout());
464508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -689,8 +733,8 @@
689733 }
690734 }
691735
692
-static GraphicsDevice device = GraphicsEnvironment
693
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
694738
695739 Rectangle keeprect;
696740 cRadio radio;
....@@ -711,10 +755,19 @@
711755 void Minimize()
712756 {
713757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
714759 }
715760
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={}
716764 void Maximize()
717765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
718771 if (maximized)
719772 {
720773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -722,22 +775,36 @@
722775 else
723776 {
724777 keeprect = frame.getBounds();
725
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
- Dimension rect2 = frame.getToolkit().getScreenSize();
727
- 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);
728781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
729783 }
730784
731785 maximized ^= true;
786
+
787
+ frame.validate();
732788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
733793
734794 void ToggleFullScreen()
735795 {
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
736798 cameraView.ToggleFullScreen();
737799
738800 if (!CameraPane.FULLSCREEN)
739801 {
740802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
741808 //frame.setVisible(false);
742809 // frame.removeNotify();
743810 // frame.setUndecorated(false);
....@@ -747,7 +814,7 @@
747814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
748815 // X framePanel.add(bigThree);
749816 // X frame.getContentPane().add(/*"Center",*/framePanel);
750
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
751818
752819 //frame.setVisible(true);
753820 radio.layout = keepButton;
....@@ -762,7 +829,12 @@
762829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763830 // frame.getToolkit().getScreenSize().height);
764831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
765835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
766838 // frame.removeNotify();
767839 // frame.setUndecorated(true);
768840 // frame.addNotify();
....@@ -775,7 +847,33 @@
775847 radio.layout.doClick();
776848 //frame.setVisible(true);
777849 }
850
+ frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
778853 }
854
+
855
+ private Object3D CompressCopy()
856
+ {
857
+ boolean temp = CameraPane.SWITCH;
858
+ CameraPane.SWITCH = false;
859
+
860
+ copy.ExtractBigData(versiontable);
861
+ // if (copy == client)
862
+
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
865
+
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
868
+
869
+ copy.versionlist = versions;
870
+
871
+ copy.RestoreBigData(versiontable);
872
+
873
+ CameraPane.SWITCH = temp;
874
+
875
+ return compress;
876
+ }
779877
780878 private JTextPane createTextPane()
781879 {
....@@ -898,6 +996,7 @@
898996 {
899997 SetupMaterial(materialPanel);
900998 }
999
+
9011000 //SetupName();
9021001 //SetupViews();
9031002 }
....@@ -907,7 +1006,7 @@
9071006 // NumberSlider vDivsField;
9081007 // JCheckBox endcaps;
9091008 JCheckBox liveCB;
910
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
9111010 JCheckBox hideCB;
9121011 JCheckBox link2masterCB;
9131012 JCheckBox markCB;
....@@ -1107,7 +1206,7 @@
11071206 namePanel = new cGridBag();
11081207
11091208 nameField = AddText(namePanel, copy.GetName());
1110
- namePanel.add(nameField);
1209
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11111210 oe.ctrlPanel.add(namePanel);
11121211
11131212 oe.ctrlPanel.Return();
....@@ -1119,26 +1218,30 @@
11191218
11201219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11211220 liveCB.setToolTipText("Animate object");
1122
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1123
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
11241223 // Return();
1224
+
11251225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11261226 hideCB.setToolTipText("Hide object");
11271227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
- markCB.setToolTipText("Set the animation target transform");
1228
+ markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11291231
11301232 setupPanel2 = new cGridBag().setVertical(false);
11311233
11321234 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11331235 rewindCB.setToolTipText("Rewind animation");
11341236
1135
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1237
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1238
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11371239
1240
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1241
+ link2masterCB.setToolTipText("Attach to support");
1242
+
11381243 if (Globals.ADVANCED)
11391244 {
1140
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
- link2masterCB.setToolTipText("Attach to support");
11421245 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11431246 speedupCB.setToolTipText("Option motion capture");
11441247 }
....@@ -1412,6 +1515,7 @@
14121515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14131516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14141517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
14151519
14161520 /*
14171521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1449,13 +1553,29 @@
14491553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14501554 //tmp.setName("Edit");
14511555 objectPanel.add(materialPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
14521559 // JPanel north = new JPanel(new BorderLayout());
14531560 // north.setName("Edit");
14541561 // north.add(ctrlPanel, BorderLayout.NORTH);
14551562 // objectPanel.add(north);
14561563 objectPanel.add(editPanel);
1457
- objectPanel.add(infoPanel);
1564
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
1566
+
1567
+ //if (Globals.ADVANCED)
1568
+ objectPanel.add(infoPanel);
1569
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
1571
+
1572
+ objectPanel.add(XYZPanel);
1573
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1575
+
14581576 objectPanel.add(toolboxPanel);
1577
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
14591579
14601580 /*
14611581 aConstraints.gridx = 0;
....@@ -1476,7 +1596,7 @@
14761596 scrollpane.addMouseWheelListener(this); // Default not fast enough
14771597
14781598 /*JTabbedPane*/ scenePanel = new cGridBag();
1479
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
14801600
14811601 JTabbedPane tabbedPane = new JTabbedPane();
14821602 tabbedPane.add(scrollpane);
....@@ -1554,7 +1674,7 @@
15541674 bigThree = new cGridBag();
15551675 bigThree.addComponent(scenePanel);
15561676 bigThree.addComponent(centralPanel);
1557
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
15581678
15591679 // // SIDE EFFECT!!!
15601680 // aConstraints.gridx = 0;
....@@ -1563,9 +1683,9 @@
15631683 // aConstraints.gridheight = 1;
15641684
15651685 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1566
- framePanel.setContinuousLayout(true);
1567
- framePanel.setOneTouchExpandable(true);
1568
- framePanel.setDividerLocation(0.8);
1686
+ framePanel.setContinuousLayout(false);
1687
+ framePanel.setOneTouchExpandable(false);
1688
+ //.setDividerLocation(0.8);
15691689 //framePanel.setDividerSize(15);
15701690 //framePanel.setResizeWeight(0.15);
15711691 framePanel.setName("Frame");
....@@ -1584,17 +1704,17 @@
15841704
15851705 frame.setSize(1280, 860);
15861706
1587
- frame.validate();
1588
- frame.setVisible(true);
1589
-
15901707 cameraView.requestFocusInWindow();
15911708
15921709 gridPanel.setDividerLocation(1.0);
1710
+
1711
+ frame.validate();
1712
+
1713
+ frame.setVisible(true);
15931714
15941715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15951716 frame.addWindowListener(new WindowAdapter()
15961717 {
1597
-
15981718 public void windowClosing(WindowEvent e)
15991719 {
16001720 Close();
....@@ -1617,12 +1737,85 @@
16171737 ctrlPanel.removeAll();
16181738 }
16191739
1620
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
16211741 {
1622
- /*
1742
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1743
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1744
+ skin.addMouseListener(new MouseAdapter()
1745
+ {
1746
+ public void mouseClicked(MouseEvent e)
1747
+ {
1748
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1749
+ cMaterial material = object.material;
1750
+
1751
+ // Skin
1752
+ colorField.setFloat(material.color);
1753
+ saturationField.setFloat(material.modulation);
1754
+ subsurfaceField.setFloat(material.subsurface);
1755
+ selfshadowField.setFloat(material.diffuseness);
1756
+ diffusenessField.setFloat(material.factor);
1757
+ shininessField.setFloat(material.shininess);
1758
+ shadowbiasField.setFloat(material.shadowbias);
1759
+ diffuseField.setFloat(material.diffuse);
1760
+ specularField.setFloat(material.specular);
1761
+
1762
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1763
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1764
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1765
+
1766
+ materialtouched = true;
1767
+ applySelf();
1768
+ }
1769
+ });
1770
+ presetpanel.add(skin);
1771
+
1772
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1773
+ rough2.addMouseListener(new MouseAdapter()
1774
+ {
1775
+ public void mouseClicked(MouseEvent e)
1776
+ {
1777
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1778
+ cMaterial material = object.material;
1779
+
1780
+ shininessField.setFloat(material.shininess);
1781
+ velvetField.setFloat(material.velvet);
1782
+
1783
+ materialtouched = true;
1784
+ applySelf();
1785
+ }
1786
+ });
1787
+ presetpanel.add(rough2);
1788
+
1789
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1790
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1791
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1792
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1793
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1794
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1795
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1796
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1797
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1798
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1799
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1800
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1801
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1802
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1803
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1804
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1805
+
1806
+ cGridBag panel = new cGridBag().setVertical(true);
1807
+
1808
+ presetpanel.preferredWidth = 1;
1809
+
1810
+ materialpanel.add(panel);
1811
+ materialpanel.add(presetpanel);
1812
+
1813
+ panel.preferredWidth = 8;
1814
+
1815
+ /*
16231816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16241817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- */
1818
+ */
16261819
16271820 cGridBag editBar = new cGridBag().setVertical(false);
16281821
....@@ -1656,45 +1849,50 @@
16561849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16571850
16581851 cGridBag colorSection = new cGridBag().setVertical(true);
1852
+
1853
+ cGridBag huepanel = new cGridBag();
1854
+ cGridBag huelabel = new cGridBag();
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
1858
+ huelabel.preferredWidth = 20;
1859
+ huepanel.add(new cGridBag()); // Label
1860
+ huepanel.add(huelabel); // Field/slider
1861
+
1862
+ huepanel.preferredHeight = 7;
1863
+
1864
+ colorSection.add(huepanel);
16591865
16601866 cGridBag color = new cGridBag();
1661
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1662
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1663
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1867
+
1868
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1869
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1871
+
16641872 //colorField.preferredWidth = 200;
16651873 colorSection.add(color);
16661874
16671875 cGridBag modulation = new cGridBag();
16681876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16691877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1670
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16711879 colorSection.add(modulation);
16721880
1881
+ cGridBag opacity = new cGridBag();
1882
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1883
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1884
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1885
+ colorSection.add(opacity);
1886
+
1887
+ colorSection.add(GetSeparator());
1888
+
16731889 cGridBag texture = new cGridBag();
16741890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16751891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16761892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16771893 colorSection.add(texture);
16781894
1679
- cGridBag anisoU = new cGridBag();
1680
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1681
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1683
- colorSection.add(anisoU);
1684
-
1685
- cGridBag anisoV = new cGridBag();
1686
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1687
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1688
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1689
- colorSection.add(anisoV);
1690
-
1691
- cGridBag shadowbias = new cGridBag();
1692
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1693
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1694
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1695
- colorSection.add(shadowbias);
1696
-
1697
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
16981896
16991897 panel.add(colorSection);
17001898
....@@ -1744,7 +1942,13 @@
17441942 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17451943 diffuseSection.add(fakedepth);
17461944
1747
- panel.add(new JSeparator());
1945
+ cGridBag shadowbias = new cGridBag();
1946
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1947
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1948
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1949
+ diffuseSection.add(shadowbias);
1950
+
1951
+ panel.add(GetSeparator());
17481952
17491953 panel.add(diffuseSection);
17501954
....@@ -1794,42 +1998,48 @@
17941998 // aConstraints.gridy += 1;
17951999 // aConstraints.gridwidth = 1;
17962000
2001
+ cGridBag anisoU = new cGridBag();
2002
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2003
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2004
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2005
+ specularSection.add(anisoU);
17972006
1798
- panel.add(new JSeparator());
2007
+ cGridBag anisoV = new cGridBag();
2008
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2009
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2010
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2011
+ specularSection.add(anisoV);
2012
+
2013
+
2014
+ panel.add(GetSeparator());
17992015
18002016 panel.add(specularSection);
18012017
18022018 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18032019
1804
- cGridBag globalSection = new cGridBag().setVertical(true);
2020
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18052021
18062022 cGridBag camera = new cGridBag();
18072023 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18082024 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18092025 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
- globalSection.add(camera);
2026
+ colorSection.add(camera);
18112027
18122028 cGridBag ambient = new cGridBag();
18132029 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18142030 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18152031 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
- globalSection.add(ambient);
2032
+ colorSection.add(ambient);
18172033
18182034 cGridBag backlit = new cGridBag();
18192035 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18202036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18212037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
- globalSection.add(backlit);
2038
+ colorSection.add(backlit);
18232039
1824
- cGridBag opacity = new cGridBag();
1825
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1826
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1827
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
- globalSection.add(opacity);
1829
-
1830
- panel.add(new JSeparator());
2040
+ //panel.add(new JSeparator());
18312041
1832
- panel.add(globalSection);
2042
+ //panel.add(globalSection);
18332043
18342044 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18352045
....@@ -1871,7 +2081,7 @@
18712081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18722082 textureSection.add(opacityPower);
18732083
1874
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
18752085
18762086 panel.add(textureSection);
18772087
....@@ -1936,8 +2146,9 @@
19362146 // 3D models
19372147 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19382148 {
1939
- lastConverter = new com.jmex.model.converters.MaxToJme();
1940
- LoadFile(filename, lastConverter);
2149
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2150
+ //LoadFile(filename, lastConverter);
2151
+ LoadObjFile(filename); // New 3ds loader
19412152 continue;
19422153 }
19432154 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2663,6 +2874,7 @@
26632874 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26642875 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26652876 }
2877
+
26662878 //cJME.count++;
26672879 //cJME.count %= 12;
26682880 if (gc)
....@@ -2846,6 +3058,7 @@
28463058 }
28473059 }
28483060 }
3061
+
28493062 cFileSystemPane FSPane;
28503063
28513064 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2855,7 +3068,7 @@
28553068
28563069 freezematerial = true;
28573070 colorField.setFloat(mat.color);
2858
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
28593072 metalnessField.setFloat(mat.metalness);
28603073 diffuseField.setFloat(mat.diffuse);
28613074 specularField.setFloat(mat.specular);
....@@ -2899,6 +3112,7 @@
28993112 }
29003113 }
29013114 }
3115
+
29023116 freezematerial = false;
29033117 }
29043118
....@@ -3017,12 +3231,17 @@
30173231 // }
30183232
30193233 /**/
3020
- if (deselect)
3234
+ if (deselect || child == null)
30213235 {
30223236 //group.deselectAll();
30233237 //freeze = true;
30243238 GetTree().clearSelection();
30253239 //freeze = false;
3240
+
3241
+ if (child == null)
3242
+ {
3243
+ return;
3244
+ }
30263245 }
30273246
30283247 //group.addSelectee(child);
....@@ -3160,8 +3379,9 @@
31603379 } else if (event.getSource() == liveCB)
31613380 {
31623381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
31633383 return;
3164
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
31653385 {
31663386 copy.dontselect ^= true;
31673387 return;
....@@ -3169,7 +3389,7 @@
31693389 {
31703390 copy.hide ^= true;
31713391 copy.Touch(); // display list issue
3172
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
31733393 return;
31743394 } else if (event.getSource() == link2masterCB)
31753395 {
....@@ -3346,9 +3566,9 @@
33463566 {
33473567 Close();
33483568 //return true;
3349
- } else if (source == loadItem)
3569
+ } else if (source == openItem)
33503570 {
3351
- load();
3571
+ Open();
33523572 //return true;
33533573 } else if (source == newItem)
33543574 {
....@@ -3373,6 +3593,10 @@
33733593 {
33743594 generatePOV();
33753595 //return true;
3596
+ } else if (event.getSource() == archiveItem)
3597
+ {
3598
+ cTools.Archive(frame);
3599
+ return;
33763600 } else if (source == zBufferItem)
33773601 {
33783602 try
....@@ -3421,11 +3645,12 @@
34213645
34223646 static public byte[] Compress(Object3D o)
34233647 {
3648
+ // Slower to actually compress.
34243649 try
34253650 {
34263651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3652
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3653
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34293654
34303655 Object3D parent = o.parent;
34313656 o.parent = null;
....@@ -3436,10 +3661,14 @@
34363661
34373662 out.flush();
34383663
3439
- zstream.close();
3664
+ baos //zstream
3665
+ .close();
34403666 out.close();
34413667
3442
- return baos.toByteArray();
3668
+ byte[] bytes = baos.toByteArray();
3669
+
3670
+ System.out.println("save #bytes = " + bytes.length);
3671
+ return bytes;
34433672 } catch (Exception e)
34443673 {
34453674 System.err.println(e);
....@@ -3449,13 +3678,16 @@
34493678
34503679 static public Object Uncompress(byte[] bytes)
34513680 {
3452
- System.out.println("#bytes = " + bytes.length);
3681
+ System.out.println("restore #bytes = " + bytes.length);
34533682 try
34543683 {
34553684 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
- ObjectInputStream in = new ObjectInputStream(istream);
3685
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3686
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34583687 Object obj = in.readObject();
3688
+
3689
+ bais //istream
3690
+ .close();
34593691 in.close();
34603692
34613693 return obj;
....@@ -3510,32 +3742,86 @@
35103742 return null;
35113743 }
35123744
3513
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35143745
35153746 public void Save()
35163747 {
3748
+ //Save(true);
3749
+ Replace();
3750
+ SetUndoStates();
3751
+ }
3752
+
3753
+ private boolean Equal(byte[] compress, byte[] name)
3754
+ {
3755
+ if (compress.length != name.length)
3756
+ {
3757
+ return false;
3758
+ }
3759
+
3760
+ for (int i=compress.length; --i>=0;)
3761
+ {
3762
+ if (compress[i] != name[i])
3763
+ return false;
3764
+ }
3765
+
3766
+ return true;
3767
+ }
3768
+
3769
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3770
+
3771
+ void DeleteVersion()
3772
+ {
3773
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
3774
+ {
3775
+ copy.versionlist[i] = copy.versionlist[i+1];
3776
+ }
3777
+
3778
+ CopyChanged();
3779
+
3780
+ SetUndoStates();
3781
+ }
3782
+
3783
+ public boolean Save(boolean user)
3784
+ {
35173785 System.err.println("Save");
3786
+ //Replace();
35183787
35193788 cRadio tab = GetCurrentTab();
35203789
3521
- boolean temp = CameraPane.SWITCH;
3522
- CameraPane.SWITCH = false;
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
35233791
3524
- copy.ExtractBigData(hashtable);
3792
+ boolean thesame = false;
3793
+
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
35253798
35263799 //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
- tab.graphs[tab.undoindex++] = Compress(copy);
3800
+ if (!thesame)
3801
+ {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
3807
+ //tab.user[tab.versionindex] = user;
3808
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3809
+
3810
+ copy.versionlist[++copy.versionindex] = compress;
3811
+
3812
+ // if (increment)
3813
+ // tab.versionindex++;
3814
+ }
35283815
3529
- copy.RestoreBigData(hashtable);
3816
+ //copy.RestoreBigData(versiontable);
35303817
3531
- CameraPane.SWITCH = temp;
3532
-
35333818 //assert(hashtable.isEmpty());
35343819
3535
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3536
- {
3537
- tab.graphs[i] = null;
3538
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
35393825
35403826 SetUndoStates();
35413827
....@@ -3544,7 +3830,7 @@
35443830 {
35453831 try
35463832 {
3547
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3833
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35483834 ObjectOutputStream p = new ObjectOutputStream(ostream);
35493835
35503836 p.writeObject(copy);
....@@ -3557,28 +3843,68 @@
35573843 e.printStackTrace();
35583844 }
35593845 }
3846
+
3847
+ return !thesame;
3848
+ }
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
3853
+ {
3854
+ Object3D selection = new Object3D();
3855
+
3856
+ for (int i = 0; i < copy.selection.size(); i++)
3857
+ {
3858
+ Object3D elem = copy.selection.elementAt(i);
3859
+
3860
+ Object3D obj = copy.GetObject(elem.GetUUID());
3861
+
3862
+ if (obj == null)
3863
+ {
3864
+ copy.selection.remove(i--);
3865
+ }
3866
+ else
3867
+ {
3868
+ selection.add(obj);
3869
+ copy.selection.setElementAt(obj, i);
3870
+ }
3871
+ }
3872
+
3873
+ flashIt = false;
3874
+ GetTree().clearSelection();
3875
+ for (int i = 0; i < selection.size(); i++)
3876
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3877
+ flashIt = true;
3878
+
3879
+ //refreshContents(false);
35603880 }
35613881
3562
- void CopyChanged(Object3D obj)
3882
+ void CopyChanged()
35633883 {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
35643886 SetUndoStates();
35653887
35663888 boolean temp = CameraPane.SWITCH;
35673889 CameraPane.SWITCH = false;
35683890
3569
- copy.ExtractBigData(hashtable);
3891
+ copy.ExtractBigData(versiontable);
35703892
35713893 copy.clear();
35723894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
35733898 for (int i=0; i<obj.Size(); i++)
35743899 {
35753900 copy.add(obj.get(i));
35763901 }
35773902
3578
- copy.RestoreBigData(hashtable);
3903
+ copy.RestoreBigData(versiontable);
35793904
35803905 CameraPane.SWITCH = temp;
35813906
3907
+ RefreshSelection();
35823908 //assert(hashtable.isEmpty());
35833909
35843910 copy.Touch();
....@@ -3599,56 +3925,139 @@
35993925 }
36003926 }
36013927
3602
- refreshContents();
3928
+ refreshContents(true);
36033929 }
36043930
3605
- cButton undoButton;
3606
- cButton redoButton;
3931
+ cButton previousVersionButton;
3932
+ cButton restoreButton;
3933
+ cButton replaceButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
36073937
3938
+ boolean muteSlider;
3939
+
3940
+ int VersionCount()
3941
+ {
3942
+ int count = 0;
3943
+
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
3945
+ {
3946
+ if (copy.versionlist[i] != null)
3947
+ count++;
3948
+ }
3949
+
3950
+ return count;
3951
+ }
3952
+
36083953 void SetUndoStates()
36093954 {
36103955 cRadio tab = GetCurrentTab();
36113956
3612
- undoButton.setEnabled(tab.undoindex > 0);
3613
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
3959
+
3960
+ previousVersionButton.setEnabled(copy.versionindex > 0);
3961
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3962
+
3963
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
3964
+ copy.versionlist[copy.versionindex + 1] != null);
3965
+
3966
+ muteSlider = true;
3967
+ versionSlider.setMaximum(VersionCount() - 1);
3968
+ versionSlider.setInteger(copy.versionindex);
3969
+ muteSlider = false;
36143970 }
36153971
3616
- public void Undo()
3972
+ public boolean PreviousVersion()
36173973 {
3974
+ // Option?
3975
+ Replace();
3976
+
36183977 System.err.println("Undo");
36193978
36203979 cRadio tab = GetCurrentTab();
36213980
3622
- if (tab.undoindex == 0)
3981
+ if (copy.versionindex == 0)
36233982 {
36243983 java.awt.Toolkit.getDefaultToolkit().beep();
3625
- return;
3984
+ return false;
36263985 }
36273986
3628
- if (tab.graphs[tab.undoindex] == null)
3629
- {
3630
- Save();
3631
- tab.undoindex -= 1;
3632
- }
3987
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3988
+// {
3989
+// if (Save(false))
3990
+// tab.versionindex -= 1;
3991
+// else
3992
+// {
3993
+// if (tab.versionindex <= 0)
3994
+// return false;
3995
+// else
3996
+// tab.versionindex -= 1;
3997
+// }
3998
+// }
36333999
3634
- tab.undoindex -= 1;
4000
+ copy.versionindex -= 1;
36354001
3636
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged();
4003
+
4004
+ return true;
36374005 }
36384006
3639
- public void Redo()
4007
+ public boolean Restore()
36404008 {
4009
+ System.err.println("Restore");
4010
+
36414011 cRadio tab = GetCurrentTab();
36424012
3643
- if (tab.graphs[tab.undoindex + 1] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4014
+ {
4015
+ java.awt.Toolkit.getDefaultToolkit().beep();
4016
+ return false;
4017
+ }
4018
+
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
4021
+
4022
+ return true;
4023
+ }
4024
+
4025
+ public boolean Replace()
4026
+ {
4027
+ System.err.println("Replace");
4028
+
4029
+ cRadio tab = GetCurrentTab();
4030
+
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4032
+ {
4033
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4034
+ return false;
4035
+ }
4036
+
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
4038
+
4039
+ return true;
4040
+ }
4041
+
4042
+ public void NextVersion()
4043
+ {
4044
+ // Option?
4045
+ Replace();
4046
+
4047
+ cRadio tab = GetCurrentTab();
4048
+
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
36444050 {
36454051 java.awt.Toolkit.getDefaultToolkit().beep();
36464052 return;
36474053 }
36484054
3649
- tab.undoindex += 1;
4055
+ copy.versionindex += 1;
36504056
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4057
+ CopyChanged();
4058
+
4059
+ //if (!tab.user[tab.versionindex])
4060
+ // tab.graphs[tab.versionindex] = null;
36524061 }
36534062
36544063 void ImportGFD()
....@@ -3859,7 +4268,7 @@
38594268 //copy.material = new cMaterial(copy.GetMaterial());
38604269
38614270 current.color = (float) colorField.getFloat();
3862
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
38634272 current.metalness = (float) metalnessField.getFloat();
38644273 current.diffuse = (float) diffuseField.getFloat();
38654274 current.specular = (float) specularField.getFloat();
....@@ -3892,7 +4301,7 @@
38924301 cMaterial mat = copy.material;
38934302
38944303 colorField.SetToolTipValue((mat.color));
3895
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
38964305 metalnessField.SetToolTipValue((mat.metalness));
38974306 diffuseField.SetToolTipValue((mat.diffuse));
38984307 specularField.SetToolTipValue((mat.specular));
....@@ -3944,9 +4353,26 @@
39444353 //copy.Touch();
39454354 }
39464355
4356
+ cNumberSlider versionSlider;
4357
+
39474358 public void stateChanged(ChangeEvent e)
39484359 {
39494360 // assert(false);
4361
+ if (e.getSource() == versionSlider)
4362
+ {
4363
+ if (muteSlider)
4364
+ return;
4365
+
4366
+ int version = versionSlider.getInteger();
4367
+
4368
+ if (copy.versionlist[version] != null)
4369
+ {
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
4372
+ }
4373
+
4374
+ return;
4375
+ }
39504376
39514377 if (freezematerial)
39524378 {
....@@ -3982,6 +4408,12 @@
39824408 {
39834409 //System.out.println("stateChanged = " + this);
39844410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
39854417 applySelf();
39864418 //System.out.println("this = " + this);
39874419 //System.out.println("PARENT = " + parent);
....@@ -4281,6 +4713,7 @@
42814713 {
42824714 if (GetTree() != null)
42834715 {
4716
+ GetTree().revalidate();
42844717 GetTree().repaint();
42854718 }
42864719
....@@ -4289,13 +4722,16 @@
42894722 ctrlPanel.validate(); // ? new
42904723 ctrlPanel.repaint();
42914724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
42924728 }
42934729
42944730 static TweenManager tweenManager = new TweenManager();
42954731
42964732 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42974733 {
4298
- if (Globals.SAVEONMAKE) // && resetmodel)
4734
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42994735 Save();
43004736 //Tween.set(thing, 0).target(1).start(tweenManager);
43014737 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4537,7 +4973,9 @@
45374973 readobj.ResetDisplayList();
45384974 } catch (Exception e)
45394975 {
4540
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
45414979 try
45424980 {
45434981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4611,12 +5049,14 @@
46115049
46125050 if (readobj != null)
46135051 {
4614
- if (Globals.SAVEONMAKE)
4615
- Save();
5052
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5053
+ // Save();
46165054 try
46175055 {
46185056 //readobj.deepCopySelf(copy);
46195057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
46205060 for (int i = 0; i < readobj.size(); i++)
46215061 {
46225062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4657,6 +5097,7 @@
46575097 }
46585098 } catch (ClassCastException e)
46595099 {
5100
+ e.printStackTrace();
46605101 assert (false);
46615102 Composite c = (Composite) copy;
46625103 c.children.clear();
....@@ -4667,17 +5108,28 @@
46675108 c.addChild(csg);
46685109 }
46695110
5111
+ copy.versionlist = readobj.versionlist;
5112
+ copy.versionindex = readobj.versionindex;
5113
+
5114
+ if (copy.versionlist == null)
5115
+ {
5116
+ copy.versionlist = new Object3D[100];
5117
+ copy.versionindex = -1;
5118
+ }
5119
+
5120
+ //? SetUndoStates();
5121
+
46705122 ResetModel();
46715123 copy.HardTouch(); // recompile?
46725124 refreshContents();
46735125 }
46745126 }
46755127
4676
- void load() // throws ClassNotFoundException
5128
+ void Open() // throws ClassNotFoundException
46775129 {
46785130 if (Grafreed.standAlone)
46795131 {
4680
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46815133 browser.show();
46825134 String filename = browser.getFile();
46835135 if (filename != null && filename.length() > 0)
....@@ -4776,6 +5228,7 @@
47765228 //ps.print(buffer.toString());
47775229 } catch (IOException e)
47785230 {
5231
+ e.printStackTrace();
47795232 }
47805233 }
47815234
....@@ -4958,7 +5411,7 @@
49585411 MenuBar menuBar;
49595412 Menu fileMenu;
49605413 MenuItem newItem;
4961
- MenuItem loadItem;
5414
+ MenuItem openItem;
49625415 MenuItem saveItem;
49635416 MenuItem saveAsItem;
49645417 MenuItem exportAsItem;
....@@ -4981,6 +5434,7 @@
49815434 CheckboxMenuItem toggleSwitchItem;
49825435 CheckboxMenuItem toggleRootItem;
49835436 CheckboxMenuItem animationItem;
5437
+ MenuItem archiveItem;
49845438 CheckboxMenuItem toggleHandleItem;
49855439 CheckboxMenuItem togglePaintItem;
49865440 JSplitPane mainPanel;
....@@ -5067,7 +5521,7 @@
50675521 JLabel colorLabel;
50685522 cNumberSlider colorField;
50695523 JLabel modulationLabel;
5070
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
50715525 JLabel metalnessLabel;
50725526 cNumberSlider metalnessField;
50735527 JLabel diffuseLabel;