Normand Briere
2019-08-16 64e20f390e4b8e58bd0006dde8fa10fba1dac1d5
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,119 @@
4142 JFrame frame;
4243
4344 static ObjEditor theFrame;
45
+
46
+ public void AllocProjectedVertices(Object3D object)
47
+ {
48
+ assert (object.projectedVertices != null);
49
+
50
+ if (object.projectedVertices.length <= 2)
51
+ {
52
+ // Side effect...
53
+ Object3D.cVector2[] keep = object.projectedVertices;
54
+ object.projectedVertices = new Object3D.cVector2[3];
55
+ for (int i = 0; i < 3; i++)
56
+ {
57
+ if (i < keep.length)
58
+ {
59
+ object.projectedVertices[i] = keep[i];
60
+ } else
61
+ {
62
+ object.projectedVertices[i] = new Object3D.cVector2();
63
+ }
64
+ /*
65
+ if(keep.length == 0)
66
+ object.projectedVertices[0] = new Object3D.cVector2();
67
+ else
68
+ object.projectedVertices[0] = keep[0];
69
+ object.projectedVertices[1] = new Object3D.cVector2();
70
+ */
71
+ }
72
+ }
73
+ }
74
+
75
+ public cGridBag GetSeparator()
76
+ {
77
+ cGridBag separator = new cGridBag();
78
+ separator.add(new JSeparator());
79
+ separator.preferredHeight = 5;
80
+ return separator;
81
+ }
4482
4583 cButton GetButton(String name, boolean border)
4684 {
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
- }
85
+ ImageIcon icon = GetIcon(name);
86
+ return new cButton(icon, border);
87
+ }
88
+
89
+ cLabel GetLabel(String name, boolean border)
90
+ {
91
+ //ImageIcon icon = GetIcon(name);
92
+ return new cLabel(GetImage(name), border);
5693 }
5794
5895 cToggleButton GetToggleButton(String name, boolean border)
5996 {
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
- }
97
+ ImageIcon icon = GetIcon(name);
98
+ return new cToggleButton(icon, border);
6999 }
70100
71101 cCheckBox GetCheckBox(String name, boolean border)
72102 {
103
+ ImageIcon icon = GetIcon(name);
104
+ return new cCheckBox(icon, border);
105
+ }
106
+
107
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
108
+
109
+ ImageIcon GetIcon(String name)
110
+ {
111
+ javax.swing.ImageIcon iconCache = icons.get(name);
112
+ if (iconCache != null)
113
+ {
114
+ return iconCache;
115
+ }
116
+
73117 try
74118 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
119
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
120
+
121
+// if (image.getWidth() > 48 && image.getHeight() > 48)
122
+// {
123
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
124
+// Graphics2D g = resized.createGraphics();
125
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
126
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
127
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
128
+// g.dispose();
129
+//
130
+// image = resized;
131
+// }
132
+
133
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
134
+
135
+ icons.put(name, icon);
136
+
137
+ return icon;
77138 }
78139 catch (Exception e)
79140 {
80
- return new cCheckBox(name, border);
141
+ //icons.put(name, null);
142
+ return null;
81143 }
82144 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
145
+
146
+ BufferedImage GetImage(String name)
85147 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
148
+ try
89149 {
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;
150
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
151
+
152
+ return image;
98153 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
154
+ catch (Exception e)
155
+ {
156
+ return null;
157
+ }
102158 }
103159
104160 // SCRIPT
....@@ -282,11 +338,13 @@
282338 client = inClient;
283339 copy = client;
284340
285
- if (copy.versions == null)
286
- {
287
- copy.versions = new byte[100][];
288
- copy.versionindex = -1;
289
- }
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
290348
291349 // "this" is not called: SetupUI2(objEditor);
292350 }
....@@ -301,10 +359,12 @@
301359 client = inClient;
302360 copy = client;
303361
304
- if (copy.versions == null)
362
+ if (copy.versionlist == null)
305363 {
306
- copy.versions = new byte[100][];
364
+ copy.versionlist = new Object3D[100];
307365 copy.versionindex = -1;
366
+
367
+// Save(true);
308368 }
309369
310370 SetupUI2(callee.GetEditor());
....@@ -328,7 +388,8 @@
328388 //parent = p;
329389
330390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
331
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
332393 //gd.setFullScreenWindow(this);
333394 //setResizable(false);
334395 //if (!isDisplayable())
....@@ -339,11 +400,13 @@
339400 copy = localCopy;
340401 copy.editWindow = this;
341402
342
- if (copy.versions == null)
343
- {
344
- copy.versions = new byte[100][];
345
- copy.versionindex = -1;
346
- }
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
347410
348411 SetupMenu();
349412
....@@ -412,6 +475,8 @@
412475
413476 ChangeListener changeListener = new ChangeListener()
414477 {
478
+ //String name;
479
+
415480 public void stateChanged(ChangeEvent changeEvent)
416481 {
417482 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -430,18 +495,49 @@
430495 // EditSelection(false);
431496 // }
432497
433
- refreshContents(false); // To refresh Info tab
498
+// if (objectPanel.getSelectedIndex() == 4)
499
+// {
500
+// name = copy.skyboxname;
501
+//
502
+// if (name == null)
503
+// {
504
+// name = "";
505
+// }
506
+//
507
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
508
+// copy.skyboxext = "jpg";
509
+// }
510
+// else
511
+// {
512
+// if (name != null)
513
+// {
514
+// if (name.equals(""))
515
+// {
516
+// copy.skyboxname = null;
517
+// copy.skyboxext = null;
518
+// }
519
+// else
520
+// {
521
+// copy.skyboxname = name;
522
+// }
523
+// }
524
+// }
525
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
526
+
527
+// refreshContents(false); // To refresh Info tab
528
+ cameraView.repaint();
434529 }
435530 };
436531 objectPanel.addChangeListener(changeListener);
437532
438533 toolbarPanel = new JPanel();
439534 toolbarPanel.setName("Toolbar");
535
+
440536 treePanel = new cGridBag();
441537 treePanel.setName("Tree");
442538
443539 editPanel = new cGridBag().setVertical(true);
444
- editPanel.setName("Edit");
540
+ //editPanel.setName("Edit");
445541
446542 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
447543
....@@ -449,11 +545,13 @@
449545 editPanel.add(editCommandsPanel);
450546 editPanel.add(ctrlPanel);
451547
452
- toolboxPanel = new cGridBag().setVertical(false);
453
- toolboxPanel.setName("Toolbox");
548
+ toolboxPanel = new cGridBag().setVertical(true);
549
+ //toolboxPanel.setName("Toolbox");
454550
455
- materialPanel = new cGridBag().setVertical(true);
456
- materialPanel.setName("Material");
551
+ skyboxPanel = new cGridBag().setVertical(true);
552
+
553
+ materialPanel = new cGridBag().setVertical(false);
554
+ //materialPanel.setName("Material");
457555
458556 /*JTextPane*/
459557 infoarea = createTextPane();
....@@ -461,6 +559,7 @@
461559
462560 infoarea.setEditable(true);
463561 SetText();
562
+
464563 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
465564 // infoarea.setOpaque(false);
466565 // //infoarea.setForeground(textcolor);
....@@ -468,7 +567,7 @@
468567 // TEXTAREA infoarea.setWrapStyleWord(true);
469568 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
470569 infoPanel.setPreferredSize(new Dimension(1, 1));
471
- infoPanel.setName("Info");
570
+ //infoPanel.setName("Info");
472571 //infoPanel.setLayout(new BorderLayout());
473572 //infoPanel.add(createTextPane());
474573
....@@ -735,6 +834,7 @@
735834 boolean maximized;
736835
737836 cButton fullscreenLayout;
837
+ cButton expandedLayout;
738838
739839 void Minimize()
740840 {
....@@ -774,10 +874,12 @@
774874 cButton minButton;
775875 cButton maxButton;
776876 cButton fullButton;
877
+ cButton collapseButton;
878
+ cButton maximize3DButton;
777879
778880 void ToggleFullScreen()
779881 {
780
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
882
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
781883
782884 cameraView.ToggleFullScreen();
783885
....@@ -798,13 +900,13 @@
798900 // X frame.getContentPane().remove(/*"Center",*/bigThree);
799901 // X framePanel.add(bigThree);
800902 // X frame.getContentPane().add(/*"Center",*/framePanel);
801
- framePanel.setDividerLocation(46);
903
+// framePanel.setDividerLocation(46); // icons are 24x24
802904
803905 //frame.setVisible(true);
804
- radio.layout = keepButton;
906
+// radio.layout = keepButton;
805907 //theFrame = null;
806908 keepButton = null;
807
- radio.layout.doClick();
909
+// radio.layout.doClick();
808910
809911 } else
810912 {
....@@ -825,31 +927,42 @@
825927 // X frame.getContentPane().remove(/*"Center",*/framePanel);
826928 // X framePanel.remove(bigThree);
827929 // X frame.getContentPane().add(/*"Center",*/bigThree);
828
- framePanel.setDividerLocation(0);
930
+// framePanel.setDividerLocation(0);
829931
830
- radio.layout = fullscreenLayout;
831
- radio.layout.doClick();
932
+// radio.layout = fullscreenLayout;
933
+// radio.layout.doClick();
832934 //frame.setVisible(true);
833935 }
834936 frame.validate();
937
+
938
+ cameraView.requestFocusInWindow();
835939 }
836940
837
- private byte[] CompressCopy()
941
+ void CollapseToolbar()
942
+ {
943
+ framePanel.setDividerLocation(0);
944
+ //frame.validate();
945
+
946
+ cameraView.requestFocusInWindow();
947
+ }
948
+
949
+ private Object3D Duplicate(Object3D object)
838950 {
839951 boolean temp = CameraPane.SWITCH;
840952 CameraPane.SWITCH = false;
841953
842
- copy.ExtractBigData(versiontable);
954
+ object.ExtractBigData(versiontable);
843955 // if (copy == client)
844956
845
- byte[] versions[] = copy.versions;
846
- copy.versions = null;
957
+ Object3D versions[] = object.versionlist;
958
+ object.versionlist = null;
847959
848
- byte[] compress = Compress(copy);
960
+ //byte[] compress = Compress(copy);
961
+ Object3D compress = (Object3D)Grafreed.clone(object);
849962
850
- copy.versions = versions;
963
+ object.versionlist = versions;
851964
852
- copy.RestoreBigData(versiontable);
965
+ object.RestoreBigData(versiontable);
853966
854967 CameraPane.SWITCH = temp;
855968
....@@ -977,6 +1090,7 @@
9771090 {
9781091 SetupMaterial(materialPanel);
9791092 }
1093
+
9801094 //SetupName();
9811095 //SetupViews();
9821096 }
....@@ -986,7 +1100,7 @@
9861100 // NumberSlider vDivsField;
9871101 // JCheckBox endcaps;
9881102 JCheckBox liveCB;
989
- JCheckBox selectCB;
1103
+ JCheckBox selectableCB;
9901104 JCheckBox hideCB;
9911105 JCheckBox link2masterCB;
9921106 JCheckBox markCB;
....@@ -1185,6 +1299,18 @@
11851299
11861300 namePanel = new cGridBag();
11871301
1302
+ //if (copy.pinned)
1303
+ {
1304
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1305
+ pinButton.setSelected(copy.pinned);
1306
+ cGridBag t = new cGridBag();
1307
+ t.preferredWidth = 2;
1308
+ t.add(pinButton);
1309
+ namePanel.add(t);
1310
+
1311
+ pinButton.addItemListener(this);
1312
+ }
1313
+
11881314 nameField = AddText(namePanel, copy.GetName());
11891315 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11901316 oe.ctrlPanel.add(namePanel);
....@@ -1198,13 +1324,16 @@
11981324
11991325 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
12001326 liveCB.setToolTipText("Animate object");
1201
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1202
- selectCB.setToolTipText("Make object selectable");
1327
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1328
+ markCB.setToolTipText("Set target transform");
1329
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1330
+ selectableCB.setToolTipText("Make object selectable");
12031331 // Return();
1332
+
12041333 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
12051334 hideCB.setToolTipText("Hide object");
1206
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1207
- markCB.setToolTipText("As animation target transform");
1335
+
1336
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
12081337
12091338 setupPanel2 = new cGridBag().setVertical(false);
12101339
....@@ -1404,6 +1533,7 @@
14041533
14051534 if (cam == null || !(copy.get(0) instanceof cGroup))
14061535 {
1536
+ if (Globals.DEBUG)
14071537 System.out.println("CREATE CAMERAS");
14081538 cams = new cTemplate();
14091539 cams.name = "Cameras";
....@@ -1492,6 +1622,7 @@
14921622 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14931623 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14941624 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1625
+ //XYZPanel.setName("XYZ");
14951626
14961627 /*
14971628 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1529,17 +1660,29 @@
15291660 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15301661 //tmp.setName("Edit");
15311662 objectPanel.add(materialPanel);
1663
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1664
+ objectPanel.setToolTipTextAt(0, "Material");
1665
+
1666
+ objectPanel.add(toolboxPanel);
1667
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1668
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1669
+
1670
+ objectPanel.add(skyboxPanel);
1671
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1672
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1673
+
15321674 // JPanel north = new JPanel(new BorderLayout());
15331675 // north.setName("Edit");
15341676 // north.add(ctrlPanel, BorderLayout.NORTH);
15351677 // objectPanel.add(north);
15361678 objectPanel.add(editPanel);
1679
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1680
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15371681
1538
- //if (Globals.ADVANCED)
1539
- objectPanel.add(infoPanel);
1682
+ objectPanel.add(XYZPanel);
1683
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1684
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15401685
1541
- objectPanel.add(toolboxPanel);
1542
-
15431686 /*
15441687 aConstraints.gridx = 0;
15451688 aConstraints.gridwidth = 1;
....@@ -1559,7 +1702,7 @@
15591702 scrollpane.addMouseWheelListener(this); // Default not fast enough
15601703
15611704 /*JTabbedPane*/ scenePanel = new cGridBag();
1562
- scenePanel.preferredWidth = 6;
1705
+ scenePanel.preferredWidth = 5;
15631706
15641707 JTabbedPane tabbedPane = new JTabbedPane();
15651708 tabbedPane.add(scrollpane);
....@@ -1576,6 +1719,11 @@
15761719
15771720 scenePanel.add(tabbedPane);
15781721
1722
+ //if (Globals.ADVANCED)
1723
+// tabbedPane.add(infoPanel);
1724
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1725
+// tabbedPane.setToolTipTextAt(3, "Information");
1726
+
15791727 /*
15801728 cTree jTree = new cTree(null);
15811729 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1637,7 +1785,7 @@
16371785 bigThree = new cGridBag();
16381786 bigThree.addComponent(scenePanel);
16391787 bigThree.addComponent(centralPanel);
1640
- bigThree.addComponent(XYZPanel);
1788
+ //bigThree.addComponent(XYZPanel);
16411789
16421790 // // SIDE EFFECT!!!
16431791 // aConstraints.gridx = 0;
....@@ -1646,6 +1794,23 @@
16461794 // aConstraints.gridheight = 1;
16471795
16481796 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1797
+
1798
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1799
+ new java.beans.PropertyChangeListener()
1800
+ {
1801
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1802
+ {
1803
+ if ((Integer)pce.getOldValue() == 1)
1804
+ {
1805
+ if (radio.layout != expandedLayout)
1806
+ {
1807
+ radio.layout = expandedLayout;
1808
+ radio.layout.doClick();
1809
+ }
1810
+ }
1811
+ }
1812
+ });
1813
+
16491814 framePanel.setContinuousLayout(false);
16501815 framePanel.setOneTouchExpandable(false);
16511816 //.setDividerLocation(0.8);
....@@ -1655,7 +1820,7 @@
16551820
16561821 frame.getContentPane().setLayout(new BorderLayout());
16571822 /**/
1658
- JTabbedPane worldPane = new JTabbedPane();
1823
+ //JTabbedPane worldPane = new JTabbedPane();
16591824 //worldPane.add(bigPanel);
16601825 //worldPane.add(worldPanel);
16611826 /**/
....@@ -1678,7 +1843,6 @@
16781843 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16791844 frame.addWindowListener(new WindowAdapter()
16801845 {
1681
-
16821846 public void windowClosing(WindowEvent e)
16831847 {
16841848 Close();
....@@ -1701,12 +1865,418 @@
17011865 ctrlPanel.removeAll();
17021866 }
17031867
1704
- void SetupMaterial(cGridBag panel)
1868
+ void SetupMaterial(cGridBag materialpanel)
17051869 {
1706
- /*
1870
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1871
+
1872
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1873
+ skin.setToolTipText("Skin");
1874
+ skin.addMouseListener(new MouseAdapter()
1875
+ {
1876
+ public void mouseClicked(MouseEvent e)
1877
+ {
1878
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1879
+ cMaterial material = object.material;
1880
+
1881
+ // Skin
1882
+ colorField.setFloat(material.color);
1883
+ saturationField.setFloat(material.modulation);
1884
+ subsurfaceField.setFloat(material.subsurface);
1885
+ selfshadowField.setFloat(material.diffuseness);
1886
+ diffusenessField.setFloat(material.factor);
1887
+ shininessField.setFloat(material.shininess);
1888
+ shadowbiasField.setFloat(material.shadowbias);
1889
+ diffuseField.setFloat(material.diffuse);
1890
+ specularField.setFloat(material.specular);
1891
+
1892
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1893
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1894
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1895
+
1896
+ materialtouched = true;
1897
+ applySelf();
1898
+ }
1899
+ });
1900
+ presetpanel.add(skin);
1901
+
1902
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1903
+ lambert.setToolTipText("Diffuse");
1904
+ lambert.addMouseListener(new MouseAdapter()
1905
+ {
1906
+ public void mouseClicked(MouseEvent e)
1907
+ {
1908
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1909
+ cMaterial material = object.material;
1910
+
1911
+ diffusenessField.setFloat(material.factor);
1912
+ selfshadowField.setFloat(material.diffuseness);
1913
+
1914
+ materialtouched = true;
1915
+ applySelf();
1916
+ }
1917
+ });
1918
+ presetpanel.add(lambert);
1919
+
1920
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1921
+ diffuse2.setToolTipText("Diffuse2");
1922
+ diffuse2.addMouseListener(new MouseAdapter()
1923
+ {
1924
+ public void mouseClicked(MouseEvent e)
1925
+ {
1926
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1927
+ cMaterial material = object.material;
1928
+
1929
+ diffusenessField.setFloat(material.factor);
1930
+ selfshadowField.setFloat(material.diffuseness);
1931
+
1932
+ materialtouched = true;
1933
+ applySelf();
1934
+ }
1935
+ });
1936
+ presetpanel.add(diffuse2);
1937
+
1938
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1939
+ diffusemoon.setToolTipText("Moon");
1940
+ diffusemoon.addMouseListener(new MouseAdapter()
1941
+ {
1942
+ public void mouseClicked(MouseEvent e)
1943
+ {
1944
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1945
+ cMaterial material = object.material;
1946
+
1947
+ diffusenessField.setFloat(material.factor);
1948
+ selfshadowField.setFloat(material.diffuseness);
1949
+
1950
+ materialtouched = true;
1951
+ applySelf();
1952
+ }
1953
+ });
1954
+ presetpanel.add(diffusemoon);
1955
+
1956
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1957
+ diffusemoon2.setToolTipText("Moon2");
1958
+ diffusemoon2.addMouseListener(new MouseAdapter()
1959
+ {
1960
+ public void mouseClicked(MouseEvent e)
1961
+ {
1962
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1963
+ cMaterial material = object.material;
1964
+
1965
+ diffusenessField.setFloat(material.factor);
1966
+ selfshadowField.setFloat(material.diffuseness);
1967
+
1968
+ materialtouched = true;
1969
+ applySelf();
1970
+ }
1971
+ });
1972
+ presetpanel.add(diffusemoon2);
1973
+
1974
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1975
+ diffusemoon3.setToolTipText("Moon3");
1976
+ diffusemoon3.addMouseListener(new MouseAdapter()
1977
+ {
1978
+ public void mouseClicked(MouseEvent e)
1979
+ {
1980
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1981
+ cMaterial material = object.material;
1982
+
1983
+ diffusenessField.setFloat(material.factor);
1984
+ selfshadowField.setFloat(material.diffuseness);
1985
+
1986
+ materialtouched = true;
1987
+ applySelf();
1988
+ }
1989
+ });
1990
+ presetpanel.add(diffusemoon3);
1991
+
1992
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1993
+ diffusesheen.setToolTipText("Sheen");
1994
+ diffusesheen.addMouseListener(new MouseAdapter()
1995
+ {
1996
+ public void mouseClicked(MouseEvent e)
1997
+ {
1998
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1999
+ cMaterial material = object.material;
2000
+
2001
+ sheenField.setFloat(material.sheen);
2002
+
2003
+ materialtouched = true;
2004
+ applySelf();
2005
+ }
2006
+ });
2007
+ presetpanel.add(diffusesheen);
2008
+
2009
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2010
+ rough.setToolTipText("Rough metal");
2011
+ rough.addMouseListener(new MouseAdapter()
2012
+ {
2013
+ public void mouseClicked(MouseEvent e)
2014
+ {
2015
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2016
+ cMaterial material = object.material;
2017
+
2018
+ shininessField.setFloat(material.shininess);
2019
+ velvetField.setFloat(material.velvet);
2020
+
2021
+ materialtouched = true;
2022
+ applySelf();
2023
+ }
2024
+ });
2025
+ presetpanel.add(rough);
2026
+
2027
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2028
+ rough2.setToolTipText("Medium metal");
2029
+ rough2.addMouseListener(new MouseAdapter()
2030
+ {
2031
+ public void mouseClicked(MouseEvent e)
2032
+ {
2033
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2034
+ cMaterial material = object.material;
2035
+
2036
+ shininessField.setFloat(material.shininess);
2037
+ lightareaField.setFloat(material.lightarea);
2038
+
2039
+ materialtouched = true;
2040
+ applySelf();
2041
+ }
2042
+ });
2043
+ presetpanel.add(rough2);
2044
+
2045
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2046
+ shini0.setToolTipText("Shiny");
2047
+ shini0.addMouseListener(new MouseAdapter()
2048
+ {
2049
+ public void mouseClicked(MouseEvent e)
2050
+ {
2051
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2052
+ cMaterial material = object.material;
2053
+
2054
+ shininessField.setFloat(material.shininess);
2055
+ lightareaField.setFloat(material.lightarea);
2056
+
2057
+ materialtouched = true;
2058
+ applySelf();
2059
+ }
2060
+ });
2061
+ presetpanel.add(shini0);
2062
+
2063
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2064
+ shini1.setToolTipText("Shiny2");
2065
+ shini1.addMouseListener(new MouseAdapter()
2066
+ {
2067
+ public void mouseClicked(MouseEvent e)
2068
+ {
2069
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2070
+ cMaterial material = object.material;
2071
+
2072
+ shininessField.setFloat(material.shininess);
2073
+ lightareaField.setFloat(material.lightarea);
2074
+
2075
+ materialtouched = true;
2076
+ applySelf();
2077
+ }
2078
+ });
2079
+ presetpanel.add(shini1);
2080
+
2081
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2082
+ shini2.setToolTipText("Shiny3");
2083
+ shini2.addMouseListener(new MouseAdapter()
2084
+ {
2085
+ public void mouseClicked(MouseEvent e)
2086
+ {
2087
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2088
+ cMaterial material = object.material;
2089
+
2090
+ shininessField.setFloat(material.shininess);
2091
+ lightareaField.setFloat(material.lightarea);
2092
+
2093
+ materialtouched = true;
2094
+ applySelf();
2095
+ }
2096
+ });
2097
+ presetpanel.add(shini2);
2098
+
2099
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2100
+ aniso.setToolTipText("AnisoU");
2101
+ aniso.addMouseListener(new MouseAdapter()
2102
+ {
2103
+ public void mouseClicked(MouseEvent e)
2104
+ {
2105
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2106
+ cMaterial material = object.material;
2107
+
2108
+ anisoField.setFloat(material.aniso);
2109
+ anisoVField.setFloat(material.anisoV);
2110
+
2111
+ materialtouched = true;
2112
+ applySelf();
2113
+ }
2114
+ });
2115
+ presetpanel.add(aniso);
2116
+
2117
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2118
+ aniso2.setToolTipText("AnisoV");
2119
+ aniso2.addMouseListener(new MouseAdapter()
2120
+ {
2121
+ public void mouseClicked(MouseEvent e)
2122
+ {
2123
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2124
+ cMaterial material = object.material;
2125
+
2126
+ anisoField.setFloat(material.aniso);
2127
+ anisoVField.setFloat(material.anisoV);
2128
+
2129
+ materialtouched = true;
2130
+ applySelf();
2131
+ }
2132
+ });
2133
+ presetpanel.add(aniso2);
2134
+
2135
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2136
+ aniso3.setToolTipText("AnisoUV");
2137
+ aniso3.addMouseListener(new MouseAdapter()
2138
+ {
2139
+ public void mouseClicked(MouseEvent e)
2140
+ {
2141
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2142
+ cMaterial material = object.material;
2143
+
2144
+ anisoField.setFloat(material.aniso);
2145
+ anisoVField.setFloat(material.anisoV);
2146
+
2147
+ materialtouched = true;
2148
+ applySelf();
2149
+ }
2150
+ });
2151
+ presetpanel.add(aniso3);
2152
+
2153
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2154
+ velvet0.setToolTipText("Velvet");
2155
+ velvet0.addMouseListener(new MouseAdapter()
2156
+ {
2157
+ public void mouseClicked(MouseEvent e)
2158
+ {
2159
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2160
+ cMaterial material = object.material;
2161
+
2162
+ diffusenessField.setFloat(material.factor);
2163
+ selfshadowField.setFloat(material.diffuseness);
2164
+ sheenField.setFloat(material.sheen);
2165
+ shininessField.setFloat(material.shininess);
2166
+ velvetField.setFloat(material.velvet);
2167
+ shiftField.setFloat(material.shift);
2168
+
2169
+ materialtouched = true;
2170
+ applySelf();
2171
+ }
2172
+ });
2173
+ presetpanel.add(velvet0);
2174
+
2175
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2176
+ bump0.setToolTipText("Bump texture");
2177
+ bump0.addMouseListener(new MouseAdapter()
2178
+ {
2179
+ public void mouseClicked(MouseEvent e)
2180
+ {
2181
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2182
+ cMaterial material = object.material;
2183
+
2184
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2185
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2186
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2187
+
2188
+ materialtouched = true;
2189
+ applySelf();
2190
+ }
2191
+ });
2192
+ presetpanel.add(bump0);
2193
+
2194
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2195
+ borderShader.setToolTipText("Border fade");
2196
+ borderShader.addMouseListener(new MouseAdapter()
2197
+ {
2198
+ public void mouseClicked(MouseEvent e)
2199
+ {
2200
+ borderfadeField.setFloat(0.5);
2201
+ opacityField.setFloat(0.75);
2202
+
2203
+ materialtouched = true;
2204
+ applySelf();
2205
+ }
2206
+ });
2207
+ presetpanel.add(borderShader);
2208
+
2209
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2210
+ halo.setToolTipText("Halo");
2211
+ halo.addMouseListener(new MouseAdapter()
2212
+ {
2213
+ public void mouseClicked(MouseEvent e)
2214
+ {
2215
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2216
+ cMaterial material = object.material;
2217
+
2218
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2219
+
2220
+ materialtouched = true;
2221
+ applySelf();
2222
+ }
2223
+ });
2224
+ presetpanel.add(halo);
2225
+
2226
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2227
+ candle.setToolTipText("Candle");
2228
+ candle.addMouseListener(new MouseAdapter()
2229
+ {
2230
+ public void mouseClicked(MouseEvent e)
2231
+ {
2232
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2233
+ cMaterial material = object.material;
2234
+
2235
+ subsurfaceField.setFloat(material.subsurface);
2236
+ shadowbiasField.setFloat(material.shadowbias);
2237
+ ambientField.setFloat(material.ambient);
2238
+ specularField.setFloat(material.specular);
2239
+ lightareaField.setFloat(material.lightarea);
2240
+ shininessField.setFloat(material.shininess);
2241
+
2242
+ materialtouched = true;
2243
+ applySelf();
2244
+ }
2245
+ });
2246
+ presetpanel.add(candle);
2247
+
2248
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2249
+ shadowShader.setToolTipText("Shadow");
2250
+ shadowShader.addMouseListener(new MouseAdapter()
2251
+ {
2252
+ public void mouseClicked(MouseEvent e)
2253
+ {
2254
+ diffuseField.setFloat(0.001);
2255
+ ambientField.setFloat(0.001);
2256
+ cameraField.setFloat(0.001);
2257
+ specularField.setFloat(0.001);
2258
+ fakedepthField.setFloat(0.001);
2259
+ opacityField.setFloat(0.6);
2260
+
2261
+ materialtouched = true;
2262
+ applySelf();
2263
+ }
2264
+ });
2265
+ presetpanel.add(shadowShader);
2266
+
2267
+ cGridBag panel = new cGridBag().setVertical(true);
2268
+
2269
+ presetpanel.preferredWidth = 1;
2270
+
2271
+ materialpanel.add(presetpanel);
2272
+ materialpanel.add(panel);
2273
+
2274
+ panel.preferredWidth = 8;
2275
+
2276
+ /*
17072277 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
17082278 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1709
- */
2279
+ */
17102280
17112281 cGridBag editBar = new cGridBag().setVertical(false);
17122282
....@@ -1740,27 +2310,61 @@
17402310 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17412311
17422312 cGridBag colorSection = new cGridBag().setVertical(true);
2313
+
2314
+ cGridBag huepanel = new cGridBag();
2315
+ cGridBag huelabel = new cGridBag();
2316
+ cLabel hue = GetLabel("icons/hue.png", false);
2317
+ hue.fit = true;
2318
+
2319
+ hue.addMouseListener(new MouseAdapter()
2320
+ {
2321
+ public void mousePressed(MouseEvent e)
2322
+ {
2323
+ int x = e.getX();
2324
+
2325
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2326
+ }
2327
+ });
2328
+
2329
+ huelabel.add(hue);
2330
+ huelabel.preferredWidth = 20;
2331
+ huepanel.add(new cGridBag()); // Label
2332
+ huepanel.add(huelabel); // Field/slider
2333
+
2334
+ huepanel.preferredHeight = 7;
2335
+
2336
+ colorSection.add(huepanel);
17432337
17442338 cGridBag color = new cGridBag();
1745
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1746
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1747
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2339
+
2340
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2341
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2342
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2343
+
17482344 //colorField.preferredWidth = 200;
17492345 colorSection.add(color);
17502346
17512347 cGridBag modulation = new cGridBag();
17522348 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17532349 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1754
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2350
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17552351 colorSection.add(modulation);
17562352
2353
+ cGridBag opacity = new cGridBag();
2354
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2355
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2356
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2357
+ colorSection.add(opacity);
2358
+
2359
+ colorSection.add(GetSeparator());
2360
+
17572361 cGridBag texture = new cGridBag();
17582362 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17592363 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17602364 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17612365 colorSection.add(texture);
17622366
1763
- panel.add(new JSeparator());
2367
+ panel.add(GetSeparator());
17642368
17652369 panel.add(colorSection);
17662370
....@@ -1816,7 +2420,7 @@
18162420 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18172421 diffuseSection.add(shadowbias);
18182422
1819
- panel.add(new JSeparator());
2423
+ panel.add(GetSeparator());
18202424
18212425 panel.add(diffuseSection);
18222426
....@@ -1879,7 +2483,7 @@
18792483 specularSection.add(anisoV);
18802484
18812485
1882
- panel.add(new JSeparator());
2486
+ panel.add(GetSeparator());
18832487
18842488 panel.add(specularSection);
18852489
....@@ -1904,12 +2508,6 @@
19042508 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
19052509 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
19062510 colorSection.add(backlit);
1907
-
1908
- cGridBag opacity = new cGridBag();
1909
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1910
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1911
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1912
- colorSection.add(opacity);
19132511
19142512 //panel.add(new JSeparator());
19152513
....@@ -1955,7 +2553,7 @@
19552553 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19562554 textureSection.add(opacityPower);
19572555
1958
- panel.add(new JSeparator());
2556
+ panel.add(GetSeparator());
19592557
19602558 panel.add(textureSection);
19612559
....@@ -2942,7 +3540,7 @@
29423540
29433541 freezematerial = true;
29443542 colorField.setFloat(mat.color);
2945
- modulationField.setFloat(mat.modulation);
3543
+ saturationField.setFloat(mat.modulation);
29463544 metalnessField.setFloat(mat.metalness);
29473545 diffuseField.setFloat(mat.diffuse);
29483546 specularField.setFloat(mat.specular);
....@@ -3004,32 +3602,8 @@
30043602
30053603 if (multiplyToggle != null)
30063604 multiplyToggle.setSelected(mat.multiply);
3007
-
3008
- assert (object.projectedVertices != null);
3009
-
3010
- if (object.projectedVertices.length <= 2)
3011
- {
3012
- // Side effect...
3013
- Object3D.cVector2[] keep = object.projectedVertices;
3014
- object.projectedVertices = new Object3D.cVector2[3];
3015
- for (int i = 0; i < 3; i++)
3016
- {
3017
- if (i < keep.length)
3018
- {
3019
- object.projectedVertices[i] = keep[i];
3020
- } else
3021
- {
3022
- object.projectedVertices[i] = new Object3D.cVector2();
3023
- }
3024
- /*
3025
- if(keep.length == 0)
3026
- object.projectedVertices[0] = new Object3D.cVector2();
3027
- else
3028
- object.projectedVertices[0] = keep[0];
3029
- object.projectedVertices[1] = new Object3D.cVector2();
3030
- */
3031
- }
3032
- }
3605
+
3606
+ AllocProjectedVertices(object);
30333607
30343608 SetMaterial(mat, object.projectedVertices);
30353609 }
....@@ -3149,6 +3723,17 @@
31493723 public void itemStateChanged(ItemEvent event)
31503724 {
31513725 // System.out.println("Propagate = " + propagate);
3726
+ if (event.getSource() == pinButton)
3727
+ {
3728
+ copy.pinned ^= true;
3729
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3730
+ {
3731
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3732
+ copy.CloseUI();
3733
+ //copy.editWindow.refreshContents();
3734
+ }
3735
+ }
3736
+ else
31523737 if (event.getSource() == propagateToggle)
31533738 {
31543739 propagate ^= true;
....@@ -3253,8 +3838,9 @@
32533838 } else if (event.getSource() == liveCB)
32543839 {
32553840 copy.live ^= true;
3841
+ objEditor.refreshContents(true); // To show item colors
32563842 return;
3257
- } else if (event.getSource() == selectCB)
3843
+ } else if (event.getSource() == selectableCB)
32583844 {
32593845 copy.dontselect ^= true;
32603846 return;
....@@ -3262,7 +3848,7 @@
32623848 {
32633849 copy.hide ^= true;
32643850 copy.Touch(); // display list issue
3265
- objEditor.refreshContents();
3851
+ objEditor.refreshContents(true); // To show item colors
32663852 return;
32673853 } else if (event.getSource() == link2masterCB)
32683854 {
....@@ -3518,6 +4104,7 @@
35184104
35194105 static public byte[] Compress(Object3D o)
35204106 {
4107
+ // Slower to actually compress.
35214108 try
35224109 {
35234110 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3619,6 +4206,7 @@
36194206 {
36204207 //Save(true);
36214208 Replace();
4209
+ SetVersionStates();
36224210 }
36234211
36244212 private boolean Equal(byte[] compress, byte[] name)
....@@ -3639,29 +4227,46 @@
36394227
36404228 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
36414229
4230
+ void DeleteVersion()
4231
+ {
4232
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4233
+ {
4234
+ copy.versionlist[i] = copy.versionlist[i+1];
4235
+ }
4236
+
4237
+ CopyChanged();
4238
+
4239
+ SetVersionStates();
4240
+ }
4241
+
36424242 public boolean Save(boolean user)
36434243 {
36444244 System.err.println("Save");
4245
+ Replace();
36454246
3646
- cRadio tab = GetCurrentTab();
4247
+ //cRadio tab = GetCurrentTab();
36474248
3648
- byte[] compress = CompressCopy();
4249
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36494250
36504251 boolean thesame = false;
36514252
3652
- // Quick heuristic using length. Works only when stream is compressed.
3653
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3654
- {
3655
- thesame = true;
3656
- }
4253
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4254
+// {
4255
+// thesame = true;
4256
+// }
36574257
36584258 //EditorFrame.m_MainFrame.requestFocusInWindow();
36594259 if (!thesame)
36604260 {
4261
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4262
+ {
4263
+ copy.versionlist[i] = copy.versionlist[i-1];
4264
+ }
4265
+
36614266 //tab.user[tab.versionindex] = user;
36624267 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36634268
3664
- copy.versions[++copy.versionindex] = compress;
4269
+ copy.versionlist[++copy.versionindex] = compress;
36654270
36664271 // if (increment)
36674272 // tab.versionindex++;
....@@ -3671,13 +4276,13 @@
36714276
36724277 //assert(hashtable.isEmpty());
36734278
3674
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3675
- {
3676
- //tab.user[i] = false;
3677
- copy.versions[i] = null;
3678
- }
4279
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4280
+// {
4281
+// //tab.user[i] = false;
4282
+// copy.versionlist[i] = null;
4283
+// }
36794284
3680
- SetUndoStates();
4285
+ SetVersionStates();
36814286
36824287 // test save
36834288 if (false)
....@@ -3700,10 +4305,44 @@
37004305
37014306 return !thesame;
37024307 }
3703
-
3704
- void CopyChanged(Object3D obj)
4308
+
4309
+ boolean flashIt = true;
4310
+
4311
+ void RefreshSelection()
37054312 {
3706
- SetUndoStates();
4313
+ Object3D selection = new Object3D();
4314
+
4315
+ for (int i = 0; i < copy.selection.size(); i++)
4316
+ {
4317
+ Object3D elem = copy.selection.elementAt(i);
4318
+
4319
+ Object3D obj = copy.GetObject(elem.GetUUID());
4320
+
4321
+ if (obj == null)
4322
+ {
4323
+ copy.selection.remove(i--);
4324
+ }
4325
+ else
4326
+ {
4327
+ selection.add(obj);
4328
+ copy.selection.setElementAt(obj, i);
4329
+ }
4330
+ }
4331
+
4332
+ flashIt = false;
4333
+ GetTree().clearSelection();
4334
+ for (int i = 0; i < selection.size(); i++)
4335
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4336
+ flashIt = true;
4337
+
4338
+ //refreshContents(false);
4339
+ }
4340
+
4341
+ void CopyChanged()
4342
+ {
4343
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4344
+
4345
+ SetVersionStates();
37074346
37084347 boolean temp = CameraPane.SWITCH;
37094348 CameraPane.SWITCH = false;
....@@ -3712,6 +4351,9 @@
37124351
37134352 copy.clear();
37144353
4354
+ copy.skyboxname = obj.skyboxname;
4355
+ copy.skyboxext = obj.skyboxext;
4356
+
37154357 for (int i=0; i<obj.Size(); i++)
37164358 {
37174359 copy.add(obj.get(i));
....@@ -3721,6 +4363,7 @@
37214363
37224364 CameraPane.SWITCH = temp;
37234365
4366
+ RefreshSelection();
37244367 //assert(hashtable.isEmpty());
37254368
37264369 copy.Touch();
....@@ -3741,13 +4384,15 @@
37414384 }
37424385 }
37434386
3744
- refreshContents();
4387
+ refreshContents(true);
37454388 }
37464389
3747
- cButton undoButton;
4390
+ cButton previousVersionButton;
37484391 cButton restoreButton;
37494392 cButton replaceButton;
3750
- cButton redoButton;
4393
+ cButton nextVersionButton;
4394
+ cButton saveVersionButton;
4395
+ cButton deleteVersionButton;
37514396
37524397 boolean muteSlider;
37534398
....@@ -3755,39 +4400,47 @@
37554400 {
37564401 int count = 0;
37574402
3758
- for (int i = copy.versions.length; --i >= 0;)
4403
+ for (int i = copy.versionlist.length; --i >= 0;)
37594404 {
3760
- if (copy.versions[i] != null)
4405
+ if (copy.versionlist[i] != null)
37614406 count++;
37624407 }
37634408
37644409 return count;
37654410 }
37664411
3767
- void SetUndoStates()
4412
+ void SetVersionStates()
37684413 {
3769
- cRadio tab = GetCurrentTab();
4414
+ //if (true)
4415
+ // return;
4416
+
4417
+ //cRadio tab = GetCurrentTab();
37704418
37714419 restoreButton.setEnabled(copy.versionindex != -1);
37724420 replaceButton.setEnabled(copy.versionindex != -1);
37734421
3774
- undoButton.setEnabled(copy.versionindex > 0);
3775
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4422
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4423
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4424
+
4425
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4426
+ copy.versionlist[copy.versionindex + 1] != null);
37764427
37774428 muteSlider = true;
4429
+ versionSlider.setMinimum(0);
37784430 versionSlider.setMaximum(VersionCount() - 1);
37794431 versionSlider.setInteger(copy.versionindex);
4432
+ versionSlider.setEnabled(copy.versionindex != -1);
37804433 muteSlider = false;
37814434 }
37824435
3783
- public boolean Undo()
4436
+ public boolean PreviousVersion()
37844437 {
37854438 // Option?
37864439 Replace();
37874440
37884441 System.err.println("Undo");
37894442
3790
- cRadio tab = GetCurrentTab();
4443
+ //cRadio tab = GetCurrentTab();
37914444
37924445 if (copy.versionindex == 0)
37934446 {
....@@ -3810,7 +4463,7 @@
38104463
38114464 copy.versionindex -= 1;
38124465
3813
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4466
+ CopyChanged();
38144467
38154468 return true;
38164469 }
....@@ -3819,15 +4472,16 @@
38194472 {
38204473 System.err.println("Restore");
38214474
3822
- cRadio tab = GetCurrentTab();
4475
+ //cRadio tab = GetCurrentTab();
38234476
3824
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4477
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38254478 {
38264479 java.awt.Toolkit.getDefaultToolkit().beep();
38274480 return false;
38284481 }
38294482
3830
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4483
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4484
+ CopyChanged();
38314485
38324486 return true;
38334487 }
....@@ -3836,27 +4490,27 @@
38364490 {
38374491 System.err.println("Replace");
38384492
3839
- cRadio tab = GetCurrentTab();
4493
+ //cRadio tab = GetCurrentTab();
38404494
3841
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4495
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38424496 {
38434497 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38444498 return false;
38454499 }
38464500
3847
- copy.versions[copy.versionindex] = CompressCopy();
4501
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38484502
38494503 return true;
38504504 }
38514505
3852
- public void Redo()
4506
+ public void NextVersion()
38534507 {
38544508 // Option?
38554509 Replace();
38564510
3857
- cRadio tab = GetCurrentTab();
4511
+ //cRadio tab = GetCurrentTab();
38584512
3859
- if (copy.versions[copy.versionindex + 1] == null)
4513
+ if (copy.versionlist[copy.versionindex + 1] == null)
38604514 {
38614515 java.awt.Toolkit.getDefaultToolkit().beep();
38624516 return;
....@@ -3864,7 +4518,7 @@
38644518
38654519 copy.versionindex += 1;
38664520
3867
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4521
+ CopyChanged();
38684522
38694523 //if (!tab.user[tab.versionindex])
38704524 // tab.graphs[tab.versionindex] = null;
....@@ -4078,7 +4732,7 @@
40784732 //copy.material = new cMaterial(copy.GetMaterial());
40794733
40804734 current.color = (float) colorField.getFloat();
4081
- current.modulation = (float) modulationField.getFloat();
4735
+ current.modulation = (float) saturationField.getFloat();
40824736 current.metalness = (float) metalnessField.getFloat();
40834737 current.diffuse = (float) diffuseField.getFloat();
40844738 current.specular = (float) specularField.getFloat();
....@@ -4111,7 +4765,7 @@
41114765 cMaterial mat = copy.material;
41124766
41134767 colorField.SetToolTipValue((mat.color));
4114
- modulationField.SetToolTipValue((mat.modulation));
4768
+ saturationField.SetToolTipValue((mat.modulation));
41154769 metalnessField.SetToolTipValue((mat.metalness));
41164770 diffuseField.SetToolTipValue((mat.diffuse));
41174771 specularField.SetToolTipValue((mat.specular));
....@@ -4173,11 +4827,14 @@
41734827 if (muteSlider)
41744828 return;
41754829
4830
+ Replace();
4831
+
41764832 int version = versionSlider.getInteger();
41774833
4178
- if (copy.versions[version] != null)
4834
+ if (version != -1 && copy.versionlist[version] != null)
41794835 {
4180
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4836
+ copy.versionindex = version;
4837
+ CopyChanged();
41814838 }
41824839
41834840 return;
....@@ -4217,6 +4874,12 @@
42174874 {
42184875 //System.out.println("stateChanged = " + this);
42194876 materialtouched = true;
4877
+
4878
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4879
+ {
4880
+ saturationField.setFloat(1);
4881
+ }
4882
+
42204883 applySelf();
42214884 //System.out.println("this = " + this);
42224885 //System.out.println("PARENT = " + parent);
....@@ -4516,6 +5179,7 @@
45165179 {
45175180 if (GetTree() != null)
45185181 {
5182
+ GetTree().revalidate();
45195183 GetTree().repaint();
45205184 }
45215185
....@@ -4524,6 +5188,11 @@
45245188 ctrlPanel.validate(); // ? new
45255189 ctrlPanel.repaint();
45265190 }
5191
+
5192
+ if (previousVersionButton != null && copy.versionlist != null)
5193
+ SetVersionStates();
5194
+
5195
+ cameraView.requestFocusInWindow();
45275196 }
45285197
45295198 static TweenManager tweenManager = new TweenManager();
....@@ -4555,7 +5224,7 @@
45555224 // group = (Composite) group.get(0);
45565225 // }
45575226
4558
- System.out.println("makeSomething of " + thing);
5227
+ //System.out.println("makeSomething of " + thing);
45595228
45605229 /*
45615230 if (deselect && jList != null)
....@@ -4772,7 +5441,9 @@
47725441 readobj.ResetDisplayList();
47735442 } catch (Exception e)
47745443 {
4775
- //e.printStackTrace();
5444
+ if (!e.toString().contains("GZIP"))
5445
+ e.printStackTrace();
5446
+
47765447 try
47775448 {
47785449 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4852,6 +5523,8 @@
48525523 {
48535524 //readobj.deepCopySelf(copy);
48545525 copy.clear(); // june 2014
5526
+ copy.skyboxname = readobj.skyboxname;
5527
+ copy.skyboxext = readobj.skyboxext;
48555528 for (int i = 0; i < readobj.size(); i++)
48565529 {
48575530 Object3D child = readobj.get(i); // reserve(i);
....@@ -4892,6 +5565,7 @@
48925565 }
48935566 } catch (ClassCastException e)
48945567 {
5568
+ e.printStackTrace();
48955569 assert (false);
48965570 Composite c = (Composite) copy;
48975571 c.children.clear();
....@@ -4902,13 +5576,16 @@
49025576 c.addChild(csg);
49035577 }
49045578
4905
- copy.versions = readobj.versions;
5579
+ copy.versionlist = readobj.versionlist;
49065580 copy.versionindex = readobj.versionindex;
49075581
4908
- if (copy.versions == null)
5582
+ if (copy.versionlist == null)
49095583 {
4910
- copy.versions = new byte[100][];
5584
+ // Backward compatibility
5585
+ copy.versionlist = new Object3D[100];
49115586 copy.versionindex = -1;
5587
+
5588
+ //Save(true);
49125589 }
49135590
49145591 //? SetUndoStates();
....@@ -4923,7 +5600,7 @@
49235600 {
49245601 if (Grafreed.standAlone)
49255602 {
4926
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5603
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
49275604 browser.show();
49285605 String filename = browser.getFile();
49295606 if (filename != null && filename.length() > 0)
....@@ -5000,6 +5677,8 @@
50005677
50015678 void save()
50025679 {
5680
+ Replace();
5681
+
50035682 if (lastname == null)
50045683 {
50055684 return;
....@@ -5022,6 +5701,7 @@
50225701 //ps.print(buffer.toString());
50235702 } catch (IOException e)
50245703 {
5704
+ e.printStackTrace();
50255705 }
50265706 }
50275707
....@@ -5241,6 +5921,7 @@
52415921 ButtonGroup buttonGroup;
52425922
52435923 cGridBag toolboxPanel;
5924
+ cGridBag skyboxPanel;
52445925 cGridBag materialPanel;
52455926 cGridBag ctrlPanel;
52465927
....@@ -5314,7 +5995,7 @@
53145995 JLabel colorLabel;
53155996 cNumberSlider colorField;
53165997 JLabel modulationLabel;
5317
- cNumberSlider modulationField;
5998
+ cNumberSlider saturationField;
53185999 JLabel metalnessLabel;
53196000 cNumberSlider metalnessField;
53206001 JLabel diffuseLabel;
....@@ -5345,6 +6026,7 @@
53456026 cNumberSlider anisoField;
53466027 JLabel anisoVLabel;
53476028 cNumberSlider anisoVField;
6029
+
53486030 JLabel cameraLabel;
53496031 cNumberSlider cameraField;
53506032 JLabel selfshadowLabel;
....@@ -5359,6 +6041,7 @@
53596041 cNumberSlider fakedepthField;
53606042 JLabel shadowbiasLabel;
53616043 cNumberSlider shadowbiasField;
6044
+
53626045 JLabel bumpLabel;
53636046 cNumberSlider bumpField;
53646047 JLabel noiseLabel;