Normand Briere
2019-08-12 b1d79b74514041a059b454a9f6fc3970773c0cb8
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,64 +42,78 @@
4142 JFrame frame;
4243
4344 static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
4453
4554 cButton GetButton(String name, boolean border)
4655 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
50
- return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
54
- return new cButton(name, border);
55
- }
56
+ ImageIcon icon = GetIcon(name);
57
+ return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
5664 }
5765
5866 cToggleButton GetToggleButton(String name, boolean border)
5967 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
68
+ ImageIcon icon = GetIcon(name);
69
+ return new cToggleButton(icon, border);
6970 }
7071
7172 cCheckBox GetCheckBox(String name, boolean border)
7273 {
74
+ ImageIcon icon = GetIcon(name);
75
+ return new cCheckBox(icon, border);
76
+ }
77
+
78
+ ImageIcon GetIcon(String name)
79
+ {
7380 try
7481 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
82
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
83
+
84
+// if (image.getWidth() > 48 && image.getHeight() > 48)
85
+// {
86
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
87
+// Graphics2D g = resized.createGraphics();
88
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
89
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
90
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
91
+// g.dispose();
92
+//
93
+// image = resized;
94
+// }
95
+
96
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
97
+ return icon;
7798 }
7899 catch (Exception e)
79100 {
80
- return new cCheckBox(name, border);
101
+ return null;
81102 }
82103 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
104
+
105
+ BufferedImage GetImage(String name)
85106 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
107
+ try
89108 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
109
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
110
+
111
+ return image;
98112 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
113
+ catch (Exception e)
114
+ {
115
+ return null;
116
+ }
102117 }
103118
104119 // SCRIPT
....@@ -282,6 +297,12 @@
282297 client = inClient;
283298 copy = client;
284299
300
+ if (copy.versionlist == null)
301
+ {
302
+ copy.versionlist = new Object3D[100];
303
+ copy.versionindex = -1;
304
+ }
305
+
285306 // "this" is not called: SetupUI2(objEditor);
286307 }
287308
....@@ -295,6 +316,12 @@
295316 client = inClient;
296317 copy = client;
297318
319
+ if (copy.versionlist == null)
320
+ {
321
+ copy.versionlist = new Object3D[100];
322
+ copy.versionindex = -1;
323
+ }
324
+
298325 SetupUI2(callee.GetEditor());
299326 }
300327
....@@ -327,6 +354,12 @@
327354 copy = localCopy;
328355 copy.editWindow = this;
329356
357
+ if (copy.versionlist == null)
358
+ {
359
+// copy.versions = new byte[100][];
360
+// copy.versionindex = -1;
361
+ }
362
+
330363 SetupMenu();
331364
332365 //SetupName(objEditor); // new
....@@ -419,11 +452,12 @@
419452
420453 toolbarPanel = new JPanel();
421454 toolbarPanel.setName("Toolbar");
455
+
422456 treePanel = new cGridBag();
423457 treePanel.setName("Tree");
424458
425459 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
460
+ //editPanel.setName("Edit");
427461
428462 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429463
....@@ -431,11 +465,13 @@
431465 editPanel.add(editCommandsPanel);
432466 editPanel.add(ctrlPanel);
433467
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
468
+ toolboxPanel = new cGridBag().setVertical(true);
469
+ //toolboxPanel.setName("Toolbox");
436470
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
471
+ skyboxPanel = new cGridBag().setVertical(true);
472
+
473
+ materialPanel = new cGridBag().setVertical(false);
474
+ //materialPanel.setName("Material");
439475
440476 /*JTextPane*/
441477 infoarea = createTextPane();
....@@ -443,6 +479,7 @@
443479
444480 infoarea.setEditable(true);
445481 SetText();
482
+
446483 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447484 // infoarea.setOpaque(false);
448485 // //infoarea.setForeground(textcolor);
....@@ -450,7 +487,7 @@
450487 // TEXTAREA infoarea.setWrapStyleWord(true);
451488 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452489 infoPanel.setPreferredSize(new Dimension(1, 1));
453
- infoPanel.setName("Info");
490
+ //infoPanel.setName("Info");
454491 //infoPanel.setLayout(new BorderLayout());
455492 //infoPanel.add(createTextPane());
456493
....@@ -717,6 +754,7 @@
717754 boolean maximized;
718755
719756 cButton fullscreenLayout;
757
+ cButton expandedLayout;
720758
721759 void Minimize()
722760 {
....@@ -756,10 +794,12 @@
756794 cButton minButton;
757795 cButton maxButton;
758796 cButton fullButton;
797
+ cButton collapseButton;
798
+ cButton maximize3DButton;
759799
760800 void ToggleFullScreen()
761801 {
762
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
802
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763803
764804 cameraView.ToggleFullScreen();
765805
....@@ -780,13 +820,13 @@
780820 // X frame.getContentPane().remove(/*"Center",*/bigThree);
781821 // X framePanel.add(bigThree);
782822 // X frame.getContentPane().add(/*"Center",*/framePanel);
783
- framePanel.setDividerLocation(46);
823
+// framePanel.setDividerLocation(46); // icons are 24x24
784824
785825 //frame.setVisible(true);
786
- radio.layout = keepButton;
826
+// radio.layout = keepButton;
787827 //theFrame = null;
788828 keepButton = null;
789
- radio.layout.doClick();
829
+// radio.layout.doClick();
790830
791831 } else
792832 {
....@@ -807,14 +847,47 @@
807847 // X frame.getContentPane().remove(/*"Center",*/framePanel);
808848 // X framePanel.remove(bigThree);
809849 // X frame.getContentPane().add(/*"Center",*/bigThree);
810
- framePanel.setDividerLocation(0);
850
+// framePanel.setDividerLocation(0);
811851
812
- radio.layout = fullscreenLayout;
813
- radio.layout.doClick();
852
+// radio.layout = fullscreenLayout;
853
+// radio.layout.doClick();
814854 //frame.setVisible(true);
815855 }
816856 frame.validate();
857
+
858
+ cameraView.requestFocusInWindow();
817859 }
860
+
861
+ void CollapseToolbar()
862
+ {
863
+ framePanel.setDividerLocation(0);
864
+ //frame.validate();
865
+
866
+ cameraView.requestFocusInWindow();
867
+ }
868
+
869
+ private Object3D Duplicate(Object3D object)
870
+ {
871
+ boolean temp = CameraPane.SWITCH;
872
+ CameraPane.SWITCH = false;
873
+
874
+ object.ExtractBigData(versiontable);
875
+ // if (copy == client)
876
+
877
+ Object3D versions[] = object.versionlist;
878
+ object.versionlist = null;
879
+
880
+ //byte[] compress = Compress(copy);
881
+ Object3D compress = (Object3D)Grafreed.clone(object);
882
+
883
+ object.versionlist = versions;
884
+
885
+ object.RestoreBigData(versiontable);
886
+
887
+ CameraPane.SWITCH = temp;
888
+
889
+ return compress;
890
+ }
818891
819892 private JTextPane createTextPane()
820893 {
....@@ -937,6 +1010,7 @@
9371010 {
9381011 SetupMaterial(materialPanel);
9391012 }
1013
+
9401014 //SetupName();
9411015 //SetupViews();
9421016 }
....@@ -946,7 +1020,7 @@
9461020 // NumberSlider vDivsField;
9471021 // JCheckBox endcaps;
9481022 JCheckBox liveCB;
949
- JCheckBox selectCB;
1023
+ JCheckBox selectableCB;
9501024 JCheckBox hideCB;
9511025 JCheckBox link2masterCB;
9521026 JCheckBox markCB;
....@@ -1145,6 +1219,18 @@
11451219
11461220 namePanel = new cGridBag();
11471221
1222
+ //if (copy.pinned)
1223
+ {
1224
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1225
+ pinButton.setSelected(copy.pinned);
1226
+ cGridBag t = new cGridBag();
1227
+ t.preferredWidth = 2;
1228
+ t.add(pinButton);
1229
+ namePanel.add(t);
1230
+
1231
+ pinButton.addItemListener(this);
1232
+ }
1233
+
11481234 nameField = AddText(namePanel, copy.GetName());
11491235 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11501236 oe.ctrlPanel.add(namePanel);
....@@ -1158,13 +1244,16 @@
11581244
11591245 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11601246 liveCB.setToolTipText("Animate object");
1161
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
- selectCB.setToolTipText("Make object selectable");
1247
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1248
+ selectableCB.setToolTipText("Make object selectable");
11631249 // Return();
1250
+
11641251 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11651252 hideCB.setToolTipText("Hide object");
11661253 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11671254 markCB.setToolTipText("As animation target transform");
1255
+
1256
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11681257
11691258 setupPanel2 = new cGridBag().setVertical(false);
11701259
....@@ -1174,10 +1263,11 @@
11741263 randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11751264 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11761265
1266
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1267
+ link2masterCB.setToolTipText("Attach to support");
1268
+
11771269 if (Globals.ADVANCED)
11781270 {
1179
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1180
- link2masterCB.setToolTipText("Attach to support");
11811271 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11821272 speedupCB.setToolTipText("Option motion capture");
11831273 }
....@@ -1451,6 +1541,7 @@
14511541 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14521542 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14531543 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1544
+ //XYZPanel.setName("XYZ");
14541545
14551546 /*
14561547 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1488,17 +1579,29 @@
14881579 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14891580 //tmp.setName("Edit");
14901581 objectPanel.add(materialPanel);
1582
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1583
+ objectPanel.setToolTipTextAt(0, "Material");
1584
+
1585
+ objectPanel.add(toolboxPanel);
1586
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1587
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1588
+
1589
+ objectPanel.add(skyboxPanel);
1590
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1591
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1592
+
14911593 // JPanel north = new JPanel(new BorderLayout());
14921594 // north.setName("Edit");
14931595 // north.add(ctrlPanel, BorderLayout.NORTH);
14941596 // objectPanel.add(north);
14951597 objectPanel.add(editPanel);
1598
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1599
+ objectPanel.setToolTipTextAt(3, "Edit controls");
14961600
1497
- //if (Globals.ADVANCED)
1498
- objectPanel.add(infoPanel);
1601
+ objectPanel.add(XYZPanel);
1602
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1603
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
14991604
1500
- objectPanel.add(toolboxPanel);
1501
-
15021605 /*
15031606 aConstraints.gridx = 0;
15041607 aConstraints.gridwidth = 1;
....@@ -1518,7 +1621,7 @@
15181621 scrollpane.addMouseWheelListener(this); // Default not fast enough
15191622
15201623 /*JTabbedPane*/ scenePanel = new cGridBag();
1521
- scenePanel.preferredWidth = 6;
1624
+ scenePanel.preferredWidth = 5;
15221625
15231626 JTabbedPane tabbedPane = new JTabbedPane();
15241627 tabbedPane.add(scrollpane);
....@@ -1535,6 +1638,11 @@
15351638
15361639 scenePanel.add(tabbedPane);
15371640
1641
+ //if (Globals.ADVANCED)
1642
+ tabbedPane.add(infoPanel);
1643
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1644
+ tabbedPane.setToolTipTextAt(3, "Information");
1645
+
15381646 /*
15391647 cTree jTree = new cTree(null);
15401648 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1596,7 +1704,7 @@
15961704 bigThree = new cGridBag();
15971705 bigThree.addComponent(scenePanel);
15981706 bigThree.addComponent(centralPanel);
1599
- bigThree.addComponent(XYZPanel);
1707
+ //bigThree.addComponent(XYZPanel);
16001708
16011709 // // SIDE EFFECT!!!
16021710 // aConstraints.gridx = 0;
....@@ -1605,6 +1713,23 @@
16051713 // aConstraints.gridheight = 1;
16061714
16071715 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1716
+
1717
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1718
+ new java.beans.PropertyChangeListener()
1719
+ {
1720
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1721
+ {
1722
+ if ((Integer)pce.getOldValue() == 1)
1723
+ {
1724
+ if (radio.layout != expandedLayout)
1725
+ {
1726
+ radio.layout = expandedLayout;
1727
+ radio.layout.doClick();
1728
+ }
1729
+ }
1730
+ }
1731
+ });
1732
+
16081733 framePanel.setContinuousLayout(false);
16091734 framePanel.setOneTouchExpandable(false);
16101735 //.setDividerLocation(0.8);
....@@ -1637,7 +1762,6 @@
16371762 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16381763 frame.addWindowListener(new WindowAdapter()
16391764 {
1640
-
16411765 public void windowClosing(WindowEvent e)
16421766 {
16431767 Close();
....@@ -1660,12 +1784,403 @@
16601784 ctrlPanel.removeAll();
16611785 }
16621786
1663
- void SetupMaterial(cGridBag panel)
1787
+ void SetupMaterial(cGridBag materialpanel)
16641788 {
1665
- /*
1789
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1790
+
1791
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1792
+ skin.setToolTipText("Skin");
1793
+ skin.addMouseListener(new MouseAdapter()
1794
+ {
1795
+ public void mouseClicked(MouseEvent e)
1796
+ {
1797
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1798
+ cMaterial material = object.material;
1799
+
1800
+ // Skin
1801
+ colorField.setFloat(material.color);
1802
+ saturationField.setFloat(material.modulation);
1803
+ subsurfaceField.setFloat(material.subsurface);
1804
+ selfshadowField.setFloat(material.diffuseness);
1805
+ diffusenessField.setFloat(material.factor);
1806
+ shininessField.setFloat(material.shininess);
1807
+ shadowbiasField.setFloat(material.shadowbias);
1808
+ diffuseField.setFloat(material.diffuse);
1809
+ specularField.setFloat(material.specular);
1810
+
1811
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1812
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1813
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1814
+
1815
+ materialtouched = true;
1816
+ applySelf();
1817
+ }
1818
+ });
1819
+ presetpanel.add(skin);
1820
+
1821
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1822
+ lambert.setToolTipText("Diffuse");
1823
+ lambert.addMouseListener(new MouseAdapter()
1824
+ {
1825
+ public void mouseClicked(MouseEvent e)
1826
+ {
1827
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1828
+ cMaterial material = object.material;
1829
+
1830
+ diffusenessField.setFloat(material.factor);
1831
+ selfshadowField.setFloat(material.diffuseness);
1832
+
1833
+ materialtouched = true;
1834
+ applySelf();
1835
+ }
1836
+ });
1837
+ presetpanel.add(lambert);
1838
+
1839
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1840
+ diffuse2.setToolTipText("Diffuse2");
1841
+ diffuse2.addMouseListener(new MouseAdapter()
1842
+ {
1843
+ public void mouseClicked(MouseEvent e)
1844
+ {
1845
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1846
+ cMaterial material = object.material;
1847
+
1848
+ diffusenessField.setFloat(material.factor);
1849
+ selfshadowField.setFloat(material.diffuseness);
1850
+
1851
+ materialtouched = true;
1852
+ applySelf();
1853
+ }
1854
+ });
1855
+ presetpanel.add(diffuse2);
1856
+
1857
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1858
+ diffusemoon.setToolTipText("Moon");
1859
+ diffusemoon.addMouseListener(new MouseAdapter()
1860
+ {
1861
+ public void mouseClicked(MouseEvent e)
1862
+ {
1863
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1864
+ cMaterial material = object.material;
1865
+
1866
+ diffusenessField.setFloat(material.factor);
1867
+ selfshadowField.setFloat(material.diffuseness);
1868
+
1869
+ materialtouched = true;
1870
+ applySelf();
1871
+ }
1872
+ });
1873
+ presetpanel.add(diffusemoon);
1874
+
1875
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1876
+ diffusemoon2.setToolTipText("Moon2");
1877
+ diffusemoon2.addMouseListener(new MouseAdapter()
1878
+ {
1879
+ public void mouseClicked(MouseEvent e)
1880
+ {
1881
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1882
+ cMaterial material = object.material;
1883
+
1884
+ diffusenessField.setFloat(material.factor);
1885
+ selfshadowField.setFloat(material.diffuseness);
1886
+
1887
+ materialtouched = true;
1888
+ applySelf();
1889
+ }
1890
+ });
1891
+ presetpanel.add(diffusemoon2);
1892
+
1893
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1894
+ diffusemoon3.setToolTipText("Moon3");
1895
+ diffusemoon3.addMouseListener(new MouseAdapter()
1896
+ {
1897
+ public void mouseClicked(MouseEvent e)
1898
+ {
1899
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1900
+ cMaterial material = object.material;
1901
+
1902
+ diffusenessField.setFloat(material.factor);
1903
+ selfshadowField.setFloat(material.diffuseness);
1904
+
1905
+ materialtouched = true;
1906
+ applySelf();
1907
+ }
1908
+ });
1909
+ presetpanel.add(diffusemoon3);
1910
+
1911
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1912
+ diffusesheen.setToolTipText("Sheen");
1913
+ diffusesheen.addMouseListener(new MouseAdapter()
1914
+ {
1915
+ public void mouseClicked(MouseEvent e)
1916
+ {
1917
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1918
+ cMaterial material = object.material;
1919
+
1920
+ sheenField.setFloat(material.sheen);
1921
+
1922
+ materialtouched = true;
1923
+ applySelf();
1924
+ }
1925
+ });
1926
+ presetpanel.add(diffusesheen);
1927
+
1928
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1929
+ rough.setToolTipText("Rough metal");
1930
+ rough.addMouseListener(new MouseAdapter()
1931
+ {
1932
+ public void mouseClicked(MouseEvent e)
1933
+ {
1934
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1935
+ cMaterial material = object.material;
1936
+
1937
+ shininessField.setFloat(material.shininess);
1938
+ velvetField.setFloat(material.velvet);
1939
+
1940
+ materialtouched = true;
1941
+ applySelf();
1942
+ }
1943
+ });
1944
+ presetpanel.add(rough);
1945
+
1946
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1947
+ rough2.setToolTipText("Medium metal");
1948
+ rough2.addMouseListener(new MouseAdapter()
1949
+ {
1950
+ public void mouseClicked(MouseEvent e)
1951
+ {
1952
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1953
+ cMaterial material = object.material;
1954
+
1955
+ shininessField.setFloat(material.shininess);
1956
+ lightareaField.setFloat(material.lightarea);
1957
+
1958
+ materialtouched = true;
1959
+ applySelf();
1960
+ }
1961
+ });
1962
+ presetpanel.add(rough2);
1963
+
1964
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
1965
+ shini0.setToolTipText("Shiny");
1966
+ shini0.addMouseListener(new MouseAdapter()
1967
+ {
1968
+ public void mouseClicked(MouseEvent e)
1969
+ {
1970
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
1971
+ cMaterial material = object.material;
1972
+
1973
+ shininessField.setFloat(material.shininess);
1974
+ lightareaField.setFloat(material.lightarea);
1975
+
1976
+ materialtouched = true;
1977
+ applySelf();
1978
+ }
1979
+ });
1980
+ presetpanel.add(shini0);
1981
+
1982
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
1983
+ shini1.setToolTipText("Shiny2");
1984
+ shini1.addMouseListener(new MouseAdapter()
1985
+ {
1986
+ public void mouseClicked(MouseEvent e)
1987
+ {
1988
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
1989
+ cMaterial material = object.material;
1990
+
1991
+ shininessField.setFloat(material.shininess);
1992
+ lightareaField.setFloat(material.lightarea);
1993
+
1994
+ materialtouched = true;
1995
+ applySelf();
1996
+ }
1997
+ });
1998
+ presetpanel.add(shini1);
1999
+
2000
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2001
+ shini2.setToolTipText("Shiny3");
2002
+ shini2.addMouseListener(new MouseAdapter()
2003
+ {
2004
+ public void mouseClicked(MouseEvent e)
2005
+ {
2006
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2007
+ cMaterial material = object.material;
2008
+
2009
+ shininessField.setFloat(material.shininess);
2010
+ lightareaField.setFloat(material.lightarea);
2011
+
2012
+ materialtouched = true;
2013
+ applySelf();
2014
+ }
2015
+ });
2016
+ presetpanel.add(shini2);
2017
+
2018
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2019
+ aniso.setToolTipText("AnisoU");
2020
+ aniso.addMouseListener(new MouseAdapter()
2021
+ {
2022
+ public void mouseClicked(MouseEvent e)
2023
+ {
2024
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2025
+ cMaterial material = object.material;
2026
+
2027
+ anisoField.setFloat(material.aniso);
2028
+ anisoVField.setFloat(material.anisoV);
2029
+
2030
+ materialtouched = true;
2031
+ applySelf();
2032
+ }
2033
+ });
2034
+ presetpanel.add(aniso);
2035
+
2036
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2037
+ aniso2.setToolTipText("AnisoV");
2038
+ aniso2.addMouseListener(new MouseAdapter()
2039
+ {
2040
+ public void mouseClicked(MouseEvent e)
2041
+ {
2042
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2043
+ cMaterial material = object.material;
2044
+
2045
+ anisoField.setFloat(material.aniso);
2046
+ anisoVField.setFloat(material.anisoV);
2047
+
2048
+ materialtouched = true;
2049
+ applySelf();
2050
+ }
2051
+ });
2052
+ presetpanel.add(aniso2);
2053
+
2054
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2055
+ aniso3.setToolTipText("AnisoUV");
2056
+ aniso3.addMouseListener(new MouseAdapter()
2057
+ {
2058
+ public void mouseClicked(MouseEvent e)
2059
+ {
2060
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2061
+ cMaterial material = object.material;
2062
+
2063
+ anisoField.setFloat(material.aniso);
2064
+ anisoVField.setFloat(material.anisoV);
2065
+
2066
+ materialtouched = true;
2067
+ applySelf();
2068
+ }
2069
+ });
2070
+ presetpanel.add(aniso3);
2071
+
2072
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2073
+ velvet0.setToolTipText("Velvet");
2074
+ velvet0.addMouseListener(new MouseAdapter()
2075
+ {
2076
+ public void mouseClicked(MouseEvent e)
2077
+ {
2078
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2079
+ cMaterial material = object.material;
2080
+
2081
+ diffusenessField.setFloat(material.factor);
2082
+ selfshadowField.setFloat(material.diffuseness);
2083
+ sheenField.setFloat(material.sheen);
2084
+ shininessField.setFloat(material.shininess);
2085
+ velvetField.setFloat(material.velvet);
2086
+ shiftField.setFloat(material.shift);
2087
+
2088
+ materialtouched = true;
2089
+ applySelf();
2090
+ }
2091
+ });
2092
+ presetpanel.add(velvet0);
2093
+
2094
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2095
+ bump0.setToolTipText("Bump texture");
2096
+ bump0.addMouseListener(new MouseAdapter()
2097
+ {
2098
+ public void mouseClicked(MouseEvent e)
2099
+ {
2100
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2101
+ cMaterial material = object.material;
2102
+
2103
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2104
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2105
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2106
+
2107
+ materialtouched = true;
2108
+ applySelf();
2109
+ }
2110
+ });
2111
+ presetpanel.add(bump0);
2112
+
2113
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2114
+ halo.setToolTipText("Halo");
2115
+ halo.addMouseListener(new MouseAdapter()
2116
+ {
2117
+ public void mouseClicked(MouseEvent e)
2118
+ {
2119
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2120
+ cMaterial material = object.material;
2121
+
2122
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2123
+
2124
+ materialtouched = true;
2125
+ applySelf();
2126
+ }
2127
+ });
2128
+ presetpanel.add(halo);
2129
+
2130
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2131
+ candle.setToolTipText("Candle");
2132
+ candle.addMouseListener(new MouseAdapter()
2133
+ {
2134
+ public void mouseClicked(MouseEvent e)
2135
+ {
2136
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2137
+ cMaterial material = object.material;
2138
+
2139
+ subsurfaceField.setFloat(material.subsurface);
2140
+ shadowbiasField.setFloat(material.shadowbias);
2141
+ ambientField.setFloat(material.ambient);
2142
+ specularField.setFloat(material.specular);
2143
+ lightareaField.setFloat(material.lightarea);
2144
+ shininessField.setFloat(material.shininess);
2145
+
2146
+ materialtouched = true;
2147
+ applySelf();
2148
+ }
2149
+ });
2150
+ presetpanel.add(candle);
2151
+
2152
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2153
+ shadowShader.setToolTipText("Shadow");
2154
+ shadowShader.addMouseListener(new MouseAdapter()
2155
+ {
2156
+ public void mouseClicked(MouseEvent e)
2157
+ {
2158
+ diffuseField.setFloat(0.001);
2159
+ ambientField.setFloat(0.001);
2160
+ cameraField.setFloat(0.001);
2161
+ specularField.setFloat(0.001);
2162
+ fakedepthField.setFloat(0.001);
2163
+ opacityField.setFloat(0.6);
2164
+
2165
+ materialtouched = true;
2166
+ applySelf();
2167
+ }
2168
+ });
2169
+ presetpanel.add(shadowShader);
2170
+
2171
+ cGridBag panel = new cGridBag().setVertical(true);
2172
+
2173
+ presetpanel.preferredWidth = 1;
2174
+
2175
+ materialpanel.add(presetpanel);
2176
+ materialpanel.add(panel);
2177
+
2178
+ panel.preferredWidth = 8;
2179
+
2180
+ /*
16662181 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16672182 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1668
- */
2183
+ */
16692184
16702185 cGridBag editBar = new cGridBag().setVertical(false);
16712186
....@@ -1699,27 +2214,50 @@
16992214 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17002215
17012216 cGridBag colorSection = new cGridBag().setVertical(true);
2217
+
2218
+ cGridBag huepanel = new cGridBag();
2219
+ cGridBag huelabel = new cGridBag();
2220
+ skin = GetLabel("icons/hue.png", false);
2221
+ skin.fit = true;
2222
+ huelabel.add(skin);
2223
+ huelabel.preferredWidth = 20;
2224
+ huepanel.add(new cGridBag()); // Label
2225
+ huepanel.add(huelabel); // Field/slider
2226
+
2227
+ huepanel.preferredHeight = 7;
2228
+
2229
+ colorSection.add(huepanel);
17022230
17032231 cGridBag color = new cGridBag();
1704
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1705
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1706
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2232
+
2233
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2234
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2235
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2236
+
17072237 //colorField.preferredWidth = 200;
17082238 colorSection.add(color);
17092239
17102240 cGridBag modulation = new cGridBag();
17112241 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17122242 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1713
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2243
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17142244 colorSection.add(modulation);
17152245
2246
+ cGridBag opacity = new cGridBag();
2247
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2248
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2249
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2250
+ colorSection.add(opacity);
2251
+
2252
+ colorSection.add(GetSeparator());
2253
+
17162254 cGridBag texture = new cGridBag();
17172255 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17182256 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17192257 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17202258 colorSection.add(texture);
17212259
1722
- panel.add(new JSeparator());
2260
+ panel.add(GetSeparator());
17232261
17242262 panel.add(colorSection);
17252263
....@@ -1775,7 +2313,7 @@
17752313 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17762314 diffuseSection.add(shadowbias);
17772315
1778
- panel.add(new JSeparator());
2316
+ panel.add(GetSeparator());
17792317
17802318 panel.add(diffuseSection);
17812319
....@@ -1838,7 +2376,7 @@
18382376 specularSection.add(anisoV);
18392377
18402378
1841
- panel.add(new JSeparator());
2379
+ panel.add(GetSeparator());
18422380
18432381 panel.add(specularSection);
18442382
....@@ -1863,12 +2401,6 @@
18632401 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18642402 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18652403 colorSection.add(backlit);
1866
-
1867
- cGridBag opacity = new cGridBag();
1868
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1869
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1871
- colorSection.add(opacity);
18722404
18732405 //panel.add(new JSeparator());
18742406
....@@ -1914,7 +2446,7 @@
19142446 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19152447 textureSection.add(opacityPower);
19162448
1917
- panel.add(new JSeparator());
2449
+ panel.add(GetSeparator());
19182450
19192451 panel.add(textureSection);
19202452
....@@ -1979,8 +2511,9 @@
19792511 // 3D models
19802512 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19812513 {
1982
- lastConverter = new com.jmex.model.converters.MaxToJme();
1983
- LoadFile(filename, lastConverter);
2514
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2515
+ //LoadFile(filename, lastConverter);
2516
+ LoadObjFile(filename); // New 3ds loader
19842517 continue;
19852518 }
19862519 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2706,6 +3239,7 @@
27063239 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
27073240 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
27083241 }
3242
+
27093243 //cJME.count++;
27103244 //cJME.count %= 12;
27113245 if (gc)
....@@ -2889,6 +3423,7 @@
28893423 }
28903424 }
28913425 }
3426
+
28923427 cFileSystemPane FSPane;
28933428
28943429 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2898,7 +3433,7 @@
28983433
28993434 freezematerial = true;
29003435 colorField.setFloat(mat.color);
2901
- modulationField.setFloat(mat.modulation);
3436
+ saturationField.setFloat(mat.modulation);
29023437 metalnessField.setFloat(mat.metalness);
29033438 diffuseField.setFloat(mat.diffuse);
29043439 specularField.setFloat(mat.specular);
....@@ -2942,6 +3477,7 @@
29423477 }
29433478 }
29443479 }
3480
+
29453481 freezematerial = false;
29463482 }
29473483
....@@ -3104,6 +3640,17 @@
31043640 public void itemStateChanged(ItemEvent event)
31053641 {
31063642 // System.out.println("Propagate = " + propagate);
3643
+ if (event.getSource() == pinButton)
3644
+ {
3645
+ copy.pinned ^= true;
3646
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3647
+ {
3648
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3649
+ copy.CloseUI();
3650
+ //copy.editWindow.refreshContents();
3651
+ }
3652
+ }
3653
+ else
31073654 if (event.getSource() == propagateToggle)
31083655 {
31093656 propagate ^= true;
....@@ -3208,8 +3755,9 @@
32083755 } else if (event.getSource() == liveCB)
32093756 {
32103757 copy.live ^= true;
3758
+ objEditor.refreshContents(true); // To show item colors
32113759 return;
3212
- } else if (event.getSource() == selectCB)
3760
+ } else if (event.getSource() == selectableCB)
32133761 {
32143762 copy.dontselect ^= true;
32153763 return;
....@@ -3217,7 +3765,7 @@
32173765 {
32183766 copy.hide ^= true;
32193767 copy.Touch(); // display list issue
3220
- objEditor.refreshContents();
3768
+ objEditor.refreshContents(true); // To show item colors
32213769 return;
32223770 } else if (event.getSource() == link2masterCB)
32233771 {
....@@ -3473,11 +4021,12 @@
34734021
34744022 static public byte[] Compress(Object3D o)
34754023 {
4024
+ // Slower to actually compress.
34764025 try
34774026 {
34784027 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3479
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3480
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4028
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4029
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34814030
34824031 Object3D parent = o.parent;
34834032 o.parent = null;
....@@ -3488,10 +4037,14 @@
34884037
34894038 out.flush();
34904039
3491
- zstream.close();
4040
+ baos //zstream
4041
+ .close();
34924042 out.close();
34934043
3494
- return baos.toByteArray();
4044
+ byte[] bytes = baos.toByteArray();
4045
+
4046
+ System.out.println("save #bytes = " + bytes.length);
4047
+ return bytes;
34954048 } catch (Exception e)
34964049 {
34974050 System.err.println(e);
....@@ -3501,13 +4054,16 @@
35014054
35024055 static public Object Uncompress(byte[] bytes)
35034056 {
3504
- System.out.println("#bytes = " + bytes.length);
4057
+ System.out.println("restore #bytes = " + bytes.length);
35054058 try
35064059 {
35074060 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3508
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3509
- ObjectInputStream in = new ObjectInputStream(istream);
4061
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4062
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
35104063 Object obj = in.readObject();
4064
+
4065
+ bais //istream
4066
+ .close();
35114067 in.close();
35124068
35134069 return obj;
....@@ -3562,34 +4118,86 @@
35624118 return null;
35634119 }
35644120
3565
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35664121
35674122 public void Save()
35684123 {
4124
+ //Save(true);
4125
+ Replace();
4126
+ SetUndoStates();
4127
+ }
4128
+
4129
+ private boolean Equal(byte[] compress, byte[] name)
4130
+ {
4131
+ if (compress.length != name.length)
4132
+ {
4133
+ return false;
4134
+ }
4135
+
4136
+ for (int i=compress.length; --i>=0;)
4137
+ {
4138
+ if (compress[i] != name[i])
4139
+ return false;
4140
+ }
4141
+
4142
+ return true;
4143
+ }
4144
+
4145
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4146
+
4147
+ void DeleteVersion()
4148
+ {
4149
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4150
+ {
4151
+ copy.versionlist[i] = copy.versionlist[i+1];
4152
+ }
4153
+
4154
+ CopyChanged();
4155
+
4156
+ SetUndoStates();
4157
+ }
4158
+
4159
+ public boolean Save(boolean user)
4160
+ {
35694161 System.err.println("Save");
4162
+ Replace();
35704163
35714164 cRadio tab = GetCurrentTab();
35724165
3573
- boolean temp = CameraPane.SWITCH;
3574
- CameraPane.SWITCH = false;
4166
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
35754167
3576
- copy.ExtractBigData(hashtable);
4168
+ boolean thesame = false;
35774169
3578
- byte[] compress = Compress(copy);
4170
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4171
+// {
4172
+// thesame = true;
4173
+// }
35794174
35804175 //EditorFrame.m_MainFrame.requestFocusInWindow();
3581
- tab.graphs[tab.undoindex++] = compress;
4176
+ if (!thesame)
4177
+ {
4178
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4179
+ {
4180
+ copy.versionlist[i] = copy.versionlist[i-1];
4181
+ }
4182
+
4183
+ //tab.user[tab.versionindex] = user;
4184
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4185
+
4186
+ copy.versionlist[++copy.versionindex] = compress;
4187
+
4188
+ // if (increment)
4189
+ // tab.versionindex++;
4190
+ }
35824191
3583
- copy.RestoreBigData(hashtable);
4192
+ //copy.RestoreBigData(versiontable);
35844193
3585
- CameraPane.SWITCH = temp;
3586
-
35874194 //assert(hashtable.isEmpty());
35884195
3589
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3590
- {
3591
- tab.graphs[i] = null;
3592
- }
4196
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4197
+// {
4198
+// //tab.user[i] = false;
4199
+// copy.versionlist[i] = null;
4200
+// }
35934201
35944202 SetUndoStates();
35954203
....@@ -3598,7 +4206,7 @@
35984206 {
35994207 try
36004208 {
3601
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4209
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
36024210 ObjectOutputStream p = new ObjectOutputStream(ostream);
36034211
36044212 p.writeObject(copy);
....@@ -3611,28 +4219,68 @@
36114219 e.printStackTrace();
36124220 }
36134221 }
4222
+
4223
+ return !thesame;
4224
+ }
4225
+
4226
+ boolean flashIt = true;
4227
+
4228
+ void RefreshSelection()
4229
+ {
4230
+ Object3D selection = new Object3D();
4231
+
4232
+ for (int i = 0; i < copy.selection.size(); i++)
4233
+ {
4234
+ Object3D elem = copy.selection.elementAt(i);
4235
+
4236
+ Object3D obj = copy.GetObject(elem.GetUUID());
4237
+
4238
+ if (obj == null)
4239
+ {
4240
+ copy.selection.remove(i--);
4241
+ }
4242
+ else
4243
+ {
4244
+ selection.add(obj);
4245
+ copy.selection.setElementAt(obj, i);
4246
+ }
4247
+ }
4248
+
4249
+ flashIt = false;
4250
+ GetTree().clearSelection();
4251
+ for (int i = 0; i < selection.size(); i++)
4252
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4253
+ flashIt = true;
4254
+
4255
+ //refreshContents(false);
36144256 }
36154257
3616
- void CopyChanged(Object3D obj)
4258
+ void CopyChanged()
36174259 {
4260
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4261
+
36184262 SetUndoStates();
36194263
36204264 boolean temp = CameraPane.SWITCH;
36214265 CameraPane.SWITCH = false;
36224266
3623
- copy.ExtractBigData(hashtable);
4267
+ copy.ExtractBigData(versiontable);
36244268
36254269 copy.clear();
36264270
4271
+ copy.skyboxname = obj.skyboxname;
4272
+ copy.skyboxext = obj.skyboxext;
4273
+
36274274 for (int i=0; i<obj.Size(); i++)
36284275 {
36294276 copy.add(obj.get(i));
36304277 }
36314278
3632
- copy.RestoreBigData(hashtable);
4279
+ copy.RestoreBigData(versiontable);
36334280
36344281 CameraPane.SWITCH = temp;
36354282
4283
+ RefreshSelection();
36364284 //assert(hashtable.isEmpty());
36374285
36384286 copy.Touch();
....@@ -3653,56 +4301,139 @@
36534301 }
36544302 }
36554303
3656
- refreshContents();
4304
+ refreshContents(true);
36574305 }
36584306
3659
- cButton undoButton;
3660
- cButton redoButton;
4307
+ cButton previousVersionButton;
4308
+ cButton restoreButton;
4309
+ cButton replaceButton;
4310
+ cButton nextVersionButton;
4311
+ cButton saveVersionButton;
4312
+ cButton deleteVersionButton;
36614313
4314
+ boolean muteSlider;
4315
+
4316
+ int VersionCount()
4317
+ {
4318
+ int count = 0;
4319
+
4320
+ for (int i = copy.versionlist.length; --i >= 0;)
4321
+ {
4322
+ if (copy.versionlist[i] != null)
4323
+ count++;
4324
+ }
4325
+
4326
+ return count;
4327
+ }
4328
+
36624329 void SetUndoStates()
36634330 {
36644331 cRadio tab = GetCurrentTab();
36654332
3666
- undoButton.setEnabled(tab.undoindex > 0);
3667
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
4333
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
4334
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
4335
+
4336
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4337
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4338
+
4339
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4340
+ copy.versionlist[copy.versionindex + 1] != null);
4341
+
4342
+ muteSlider = true;
4343
+ versionSlider.setMaximum(VersionCount() - 1);
4344
+ versionSlider.setInteger(copy.versionindex);
4345
+ muteSlider = false;
36684346 }
36694347
3670
- public void Undo()
4348
+ public boolean PreviousVersion()
36714349 {
4350
+ // Option?
4351
+ Replace();
4352
+
36724353 System.err.println("Undo");
36734354
36744355 cRadio tab = GetCurrentTab();
36754356
3676
- if (tab.undoindex == 0)
4357
+ if (copy.versionindex == 0)
36774358 {
36784359 java.awt.Toolkit.getDefaultToolkit().beep();
3679
- return;
4360
+ return false;
36804361 }
36814362
3682
- if (tab.graphs[tab.undoindex] == null)
3683
- {
3684
- Save();
3685
- tab.undoindex -= 1;
3686
- }
4363
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4364
+// {
4365
+// if (Save(false))
4366
+// tab.versionindex -= 1;
4367
+// else
4368
+// {
4369
+// if (tab.versionindex <= 0)
4370
+// return false;
4371
+// else
4372
+// tab.versionindex -= 1;
4373
+// }
4374
+// }
36874375
3688
- tab.undoindex -= 1;
4376
+ copy.versionindex -= 1;
36894377
3690
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4378
+ CopyChanged();
4379
+
4380
+ return true;
36914381 }
36924382
3693
- public void Redo()
4383
+ public boolean Restore()
36944384 {
4385
+ System.err.println("Restore");
4386
+
36954387 cRadio tab = GetCurrentTab();
36964388
3697
- if (tab.graphs[tab.undoindex + 1] == null)
4389
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4390
+ {
4391
+ java.awt.Toolkit.getDefaultToolkit().beep();
4392
+ return false;
4393
+ }
4394
+
4395
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4396
+ CopyChanged();
4397
+
4398
+ return true;
4399
+ }
4400
+
4401
+ public boolean Replace()
4402
+ {
4403
+ System.err.println("Replace");
4404
+
4405
+ cRadio tab = GetCurrentTab();
4406
+
4407
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4408
+ {
4409
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4410
+ return false;
4411
+ }
4412
+
4413
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4414
+
4415
+ return true;
4416
+ }
4417
+
4418
+ public void NextVersion()
4419
+ {
4420
+ // Option?
4421
+ Replace();
4422
+
4423
+ cRadio tab = GetCurrentTab();
4424
+
4425
+ if (copy.versionlist[copy.versionindex + 1] == null)
36984426 {
36994427 java.awt.Toolkit.getDefaultToolkit().beep();
37004428 return;
37014429 }
37024430
3703
- tab.undoindex += 1;
4431
+ copy.versionindex += 1;
37044432
3705
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4433
+ CopyChanged();
4434
+
4435
+ //if (!tab.user[tab.versionindex])
4436
+ // tab.graphs[tab.versionindex] = null;
37064437 }
37074438
37084439 void ImportGFD()
....@@ -3913,7 +4644,7 @@
39134644 //copy.material = new cMaterial(copy.GetMaterial());
39144645
39154646 current.color = (float) colorField.getFloat();
3916
- current.modulation = (float) modulationField.getFloat();
4647
+ current.modulation = (float) saturationField.getFloat();
39174648 current.metalness = (float) metalnessField.getFloat();
39184649 current.diffuse = (float) diffuseField.getFloat();
39194650 current.specular = (float) specularField.getFloat();
....@@ -3946,7 +4677,7 @@
39464677 cMaterial mat = copy.material;
39474678
39484679 colorField.SetToolTipValue((mat.color));
3949
- modulationField.SetToolTipValue((mat.modulation));
4680
+ saturationField.SetToolTipValue((mat.modulation));
39504681 metalnessField.SetToolTipValue((mat.metalness));
39514682 diffuseField.SetToolTipValue((mat.diffuse));
39524683 specularField.SetToolTipValue((mat.specular));
....@@ -3998,9 +4729,26 @@
39984729 //copy.Touch();
39994730 }
40004731
4732
+ cNumberSlider versionSlider;
4733
+
40014734 public void stateChanged(ChangeEvent e)
40024735 {
40034736 // assert(false);
4737
+ if (e.getSource() == versionSlider)
4738
+ {
4739
+ if (muteSlider)
4740
+ return;
4741
+
4742
+ int version = versionSlider.getInteger();
4743
+
4744
+ if (copy.versionlist[version] != null)
4745
+ {
4746
+ copy.versionindex = version;
4747
+ CopyChanged();
4748
+ }
4749
+
4750
+ return;
4751
+ }
40044752
40054753 if (freezematerial)
40064754 {
....@@ -4036,6 +4784,12 @@
40364784 {
40374785 //System.out.println("stateChanged = " + this);
40384786 materialtouched = true;
4787
+
4788
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4789
+ {
4790
+ saturationField.setFloat(1);
4791
+ }
4792
+
40394793 applySelf();
40404794 //System.out.println("this = " + this);
40414795 //System.out.println("PARENT = " + parent);
....@@ -4335,6 +5089,7 @@
43355089 {
43365090 if (GetTree() != null)
43375091 {
5092
+ GetTree().revalidate();
43385093 GetTree().repaint();
43395094 }
43405095
....@@ -4343,13 +5098,16 @@
43435098 ctrlPanel.validate(); // ? new
43445099 ctrlPanel.repaint();
43455100 }
5101
+
5102
+ if (previousVersionButton != null && copy.versionlist != null)
5103
+ SetUndoStates();
43465104 }
43475105
43485106 static TweenManager tweenManager = new TweenManager();
43495107
43505108 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43515109 {
4352
- if (Globals.SAVEONMAKE) // && resetmodel)
5110
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43535111 Save();
43545112 //Tween.set(thing, 0).target(1).start(tweenManager);
43555113 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4591,7 +5349,9 @@
45915349 readobj.ResetDisplayList();
45925350 } catch (Exception e)
45935351 {
4594
- //e.printStackTrace();
5352
+ if (!e.toString().contains("GZIP"))
5353
+ e.printStackTrace();
5354
+
45955355 try
45965356 {
45975357 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4665,12 +5425,14 @@
46655425
46665426 if (readobj != null)
46675427 {
4668
- if (Globals.SAVEONMAKE)
4669
- Save();
5428
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5429
+ // Save();
46705430 try
46715431 {
46725432 //readobj.deepCopySelf(copy);
46735433 copy.clear(); // june 2014
5434
+ copy.skyboxname = readobj.skyboxname;
5435
+ copy.skyboxext = readobj.skyboxext;
46745436 for (int i = 0; i < readobj.size(); i++)
46755437 {
46765438 Object3D child = readobj.get(i); // reserve(i);
....@@ -4711,6 +5473,7 @@
47115473 }
47125474 } catch (ClassCastException e)
47135475 {
5476
+ e.printStackTrace();
47145477 assert (false);
47155478 Composite c = (Composite) copy;
47165479 c.children.clear();
....@@ -4721,6 +5484,17 @@
47215484 c.addChild(csg);
47225485 }
47235486
5487
+ copy.versionlist = readobj.versionlist;
5488
+ copy.versionindex = readobj.versionindex;
5489
+
5490
+ if (copy.versionlist == null)
5491
+ {
5492
+ copy.versionlist = new Object3D[100];
5493
+ copy.versionindex = -1;
5494
+ }
5495
+
5496
+ //? SetUndoStates();
5497
+
47245498 ResetModel();
47255499 copy.HardTouch(); // recompile?
47265500 refreshContents();
....@@ -4731,7 +5505,7 @@
47315505 {
47325506 if (Grafreed.standAlone)
47335507 {
4734
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5508
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
47355509 browser.show();
47365510 String filename = browser.getFile();
47375511 if (filename != null && filename.length() > 0)
....@@ -4830,6 +5604,7 @@
48305604 //ps.print(buffer.toString());
48315605 } catch (IOException e)
48325606 {
5607
+ e.printStackTrace();
48335608 }
48345609 }
48355610
....@@ -5049,6 +5824,7 @@
50495824 ButtonGroup buttonGroup;
50505825
50515826 cGridBag toolboxPanel;
5827
+ cGridBag skyboxPanel;
50525828 cGridBag materialPanel;
50535829 cGridBag ctrlPanel;
50545830
....@@ -5122,7 +5898,7 @@
51225898 JLabel colorLabel;
51235899 cNumberSlider colorField;
51245900 JLabel modulationLabel;
5125
- cNumberSlider modulationField;
5901
+ cNumberSlider saturationField;
51265902 JLabel metalnessLabel;
51275903 cNumberSlider metalnessField;
51285904 JLabel diffuseLabel;
....@@ -5153,6 +5929,7 @@
51535929 cNumberSlider anisoField;
51545930 JLabel anisoVLabel;
51555931 cNumberSlider anisoVField;
5932
+
51565933 JLabel cameraLabel;
51575934 cNumberSlider cameraField;
51585935 JLabel selfshadowLabel;
....@@ -5167,6 +5944,7 @@
51675944 cNumberSlider fakedepthField;
51685945 JLabel shadowbiasLabel;
51695946 cNumberSlider shadowbiasField;
5947
+
51705948 JLabel bumpLabel;
51715949 cNumberSlider bumpField;
51725950 JLabel noiseLabel;