Normand Briere
2019-08-17 5892f05411c3d4dce2d8a59e0966dc2e1843a971
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
+ static 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(ObjEditor.class.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,6 +338,14 @@
282338 client = inClient;
283339 copy = client;
284340
341
+// if (copy.versionlist == null)
342
+// {
343
+// copy.versionlist = new Object3D[100];
344
+// copy.versionindex = -1;
345
+//
346
+// callee.Save(true);
347
+// }
348
+
285349 // "this" is not called: SetupUI2(objEditor);
286350 }
287351
....@@ -295,6 +359,14 @@
295359 client = inClient;
296360 copy = client;
297361
362
+ if (copy.versionlist == null)
363
+ {
364
+ copy.versionlist = new Object3D[100];
365
+ copy.versionindex = -1;
366
+
367
+// Save(true);
368
+ }
369
+
298370 SetupUI2(callee.GetEditor());
299371 }
300372
....@@ -316,7 +388,8 @@
316388 //parent = p;
317389
318390 GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
319
- System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
391
+ if (Globals.DEBUG)
392
+ System.out.println("getFullScreenWindow? " + gd.getFullScreenWindow());
320393 //gd.setFullScreenWindow(this);
321394 //setResizable(false);
322395 //if (!isDisplayable())
....@@ -327,6 +400,14 @@
327400 copy = localCopy;
328401 copy.editWindow = this;
329402
403
+// if (copy.versionlist == null)
404
+// {
405
+// copy.versionlist = new Object3D[100];
406
+// copy.versionindex = -1;
407
+//
408
+// Save(true);
409
+// }
410
+
330411 SetupMenu();
331412
332413 //SetupName(objEditor); // new
....@@ -345,6 +426,9 @@
345426
346427 static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
347428
429
+ // This is to refresh the UI of the material panel.
430
+ boolean patchMaterial;
431
+
348432 void SetupMenu()
349433 {
350434 frame.setMenuBar(menuBar = new MenuBar());
....@@ -394,6 +478,8 @@
394478
395479 ChangeListener changeListener = new ChangeListener()
396480 {
481
+ //String name;
482
+
397483 public void stateChanged(ChangeEvent changeEvent)
398484 {
399485 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -412,18 +498,49 @@
412498 // EditSelection(false);
413499 // }
414500
415
- refreshContents(false); // To refresh Info tab
501
+// if (objectPanel.getSelectedIndex() == 4)
502
+// {
503
+// name = copy.skyboxname;
504
+//
505
+// if (name == null)
506
+// {
507
+// name = "";
508
+// }
509
+//
510
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
511
+// copy.skyboxext = "jpg";
512
+// }
513
+// else
514
+// {
515
+// if (name != null)
516
+// {
517
+// if (name.equals(""))
518
+// {
519
+// copy.skyboxname = null;
520
+// copy.skyboxext = null;
521
+// }
522
+// else
523
+// {
524
+// copy.skyboxname = name;
525
+// }
526
+// }
527
+// }
528
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
529
+
530
+// refreshContents(false); // To refresh Info tab
531
+ cameraView.repaint();
416532 }
417533 };
418534 objectPanel.addChangeListener(changeListener);
419535
420536 toolbarPanel = new JPanel();
421537 toolbarPanel.setName("Toolbar");
538
+
422539 treePanel = new cGridBag();
423540 treePanel.setName("Tree");
424541
425542 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
543
+ //editPanel.setName("Edit");
427544
428545 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429546
....@@ -431,11 +548,13 @@
431548 editPanel.add(editCommandsPanel);
432549 editPanel.add(ctrlPanel);
433550
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
551
+ toolboxPanel = new cGridBag().setVertical(true);
552
+ //toolboxPanel.setName("Toolbox");
436553
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
554
+ skyboxPanel = new cGridBag().setVertical(true);
555
+
556
+ materialPanel = new cGridBag().setVertical(false);
557
+ //materialPanel.setName("Material");
439558
440559 /*JTextPane*/
441560 infoarea = createTextPane();
....@@ -443,6 +562,7 @@
443562
444563 infoarea.setEditable(true);
445564 SetText();
565
+
446566 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447567 // infoarea.setOpaque(false);
448568 // //infoarea.setForeground(textcolor);
....@@ -450,7 +570,7 @@
450570 // TEXTAREA infoarea.setWrapStyleWord(true);
451571 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452572 infoPanel.setPreferredSize(new Dimension(1, 1));
453
- infoPanel.setName("Info");
573
+ //infoPanel.setName("Info");
454574 //infoPanel.setLayout(new BorderLayout());
455575 //infoPanel.add(createTextPane());
456576
....@@ -717,6 +837,7 @@
717837 boolean maximized;
718838
719839 cButton fullscreenLayout;
840
+ cButton expandedLayout;
720841
721842 void Minimize()
722843 {
....@@ -756,10 +877,12 @@
756877 cButton minButton;
757878 cButton maxButton;
758879 cButton fullButton;
880
+ cButton collapseButton;
881
+ cButton maximize3DButton;
759882
760883 void ToggleFullScreen()
761884 {
762
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
885
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763886
764887 cameraView.ToggleFullScreen();
765888
....@@ -780,13 +903,13 @@
780903 // X frame.getContentPane().remove(/*"Center",*/bigThree);
781904 // X framePanel.add(bigThree);
782905 // X frame.getContentPane().add(/*"Center",*/framePanel);
783
- framePanel.setDividerLocation(46);
906
+// framePanel.setDividerLocation(46); // icons are 24x24
784907
785908 //frame.setVisible(true);
786
- radio.layout = keepButton;
909
+// radio.layout = keepButton;
787910 //theFrame = null;
788911 keepButton = null;
789
- radio.layout.doClick();
912
+// radio.layout.doClick();
790913
791914 } else
792915 {
....@@ -807,31 +930,48 @@
807930 // X frame.getContentPane().remove(/*"Center",*/framePanel);
808931 // X framePanel.remove(bigThree);
809932 // X frame.getContentPane().add(/*"Center",*/bigThree);
810
- framePanel.setDividerLocation(0);
933
+// framePanel.setDividerLocation(0);
811934
812
- radio.layout = fullscreenLayout;
813
- radio.layout.doClick();
935
+// radio.layout = fullscreenLayout;
936
+// radio.layout.doClick();
814937 //frame.setVisible(true);
815938 }
816939 frame.validate();
940
+
941
+ cameraView.requestFocusInWindow();
817942 }
818943
819
- private byte[] CompressCopy()
944
+ void CollapseToolbar()
945
+ {
946
+ framePanel.setDividerLocation(0);
947
+ //frame.validate();
948
+
949
+ cameraView.requestFocusInWindow();
950
+ }
951
+
952
+ private Object3D Duplicate(Object3D object)
820953 {
821954 boolean temp = CameraPane.SWITCH;
822955 CameraPane.SWITCH = false;
823956
824
- copy.ExtractBigData(versiontable);
957
+ if (Grafreed.grafreed.universe.versiontable == null)
958
+ Grafreed.grafreed.universe.versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
959
+
960
+ object.ExtractBigData(Grafreed.grafreed.universe.versiontable);
825961 // if (copy == client)
826962
827
- byte[] versions[] = copy.versions;
828
- copy.versions = null;
963
+ Object3D versions[] = object.versionlist;
964
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = object.versiontable; // if Grafreed.grafreed.universe
965
+ object.versionlist = null;
966
+ object.versiontable = null;
829967
830
- byte[] compress = Compress(copy);
968
+ //byte[] compress = Compress(copy);
969
+ Object3D compress = (Object3D)Grafreed.clone(object);
831970
832
- copy.versions = versions;
971
+ object.versionlist = versions;
972
+ object.versiontable = versiontable; // if Grafreed.grafreed.universe
833973
834
- copy.RestoreBigData(versiontable);
974
+ object.RestoreBigData(Grafreed.grafreed.universe.versiontable);
835975
836976 CameraPane.SWITCH = temp;
837977
....@@ -959,6 +1099,7 @@
9591099 {
9601100 SetupMaterial(materialPanel);
9611101 }
1102
+
9621103 //SetupName();
9631104 //SetupViews();
9641105 }
....@@ -968,7 +1109,7 @@
9681109 // NumberSlider vDivsField;
9691110 // JCheckBox endcaps;
9701111 JCheckBox liveCB;
971
- JCheckBox selectCB;
1112
+ JCheckBox selectableCB;
9721113 JCheckBox hideCB;
9731114 JCheckBox link2masterCB;
9741115 JCheckBox markCB;
....@@ -1167,6 +1308,18 @@
11671308
11681309 namePanel = new cGridBag();
11691310
1311
+ //if (copy.pinned)
1312
+ {
1313
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1314
+ pinButton.setSelected(copy.pinned);
1315
+ cGridBag t = new cGridBag();
1316
+ t.preferredWidth = 2;
1317
+ t.add(pinButton);
1318
+ namePanel.add(t);
1319
+
1320
+ pinButton.addItemListener(this);
1321
+ }
1322
+
11701323 nameField = AddText(namePanel, copy.GetName());
11711324 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11721325 oe.ctrlPanel.add(namePanel);
....@@ -1180,13 +1333,16 @@
11801333
11811334 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11821335 liveCB.setToolTipText("Animate object");
1183
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1184
- selectCB.setToolTipText("Make object selectable");
1336
+ markCB = AddCheckBox(setupPanel, "Anim", copy.marked);
1337
+ markCB.setToolTipText("Set target transform");
1338
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1339
+ selectableCB.setToolTipText("Make object selectable");
11851340 // Return();
1341
+
11861342 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11871343 hideCB.setToolTipText("Hide object");
1188
- markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1189
- markCB.setToolTipText("As animation target transform");
1344
+
1345
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11901346
11911347 setupPanel2 = new cGridBag().setVertical(false);
11921348
....@@ -1386,6 +1542,7 @@
13861542
13871543 if (cam == null || !(copy.get(0) instanceof cGroup))
13881544 {
1545
+ if (Globals.DEBUG)
13891546 System.out.println("CREATE CAMERAS");
13901547 cams = new cTemplate();
13911548 cams.name = "Cameras";
....@@ -1474,6 +1631,7 @@
14741631 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14751632 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14761633 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1634
+ //XYZPanel.setName("XYZ");
14771635
14781636 /*
14791637 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1510,18 +1668,34 @@
15101668
15111669 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
15121670 //tmp.setName("Edit");
1671
+ objectPanel.add(toolboxPanel);
1672
+ objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
1673
+ objectPanel.setToolTipTextAt(0, "Objects & textures");
1674
+
15131675 objectPanel.add(materialPanel);
1676
+ objectPanel.setIconAt(1, GetIcon("icons/material.png"));
1677
+ objectPanel.setToolTipTextAt(1, "Material");
1678
+
1679
+ objectPanel.add(skyboxPanel);
1680
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1681
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1682
+
15141683 // JPanel north = new JPanel(new BorderLayout());
15151684 // north.setName("Edit");
15161685 // north.add(ctrlPanel, BorderLayout.NORTH);
15171686 // objectPanel.add(north);
15181687 objectPanel.add(editPanel);
1688
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1689
+ objectPanel.setToolTipTextAt(3, "Edit controls");
15191690
1520
- //if (Globals.ADVANCED)
1521
- objectPanel.add(infoPanel);
1691
+ objectPanel.add(XYZPanel);
1692
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1693
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
15221694
1523
- objectPanel.add(toolboxPanel);
1524
-
1695
+ patchMaterial = true;
1696
+ cameraView.patchMaterial = this;
1697
+ objectPanel.setSelectedIndex(1);
1698
+
15251699 /*
15261700 aConstraints.gridx = 0;
15271701 aConstraints.gridwidth = 1;
....@@ -1558,6 +1732,11 @@
15581732
15591733 scenePanel.add(tabbedPane);
15601734
1735
+ //if (Globals.ADVANCED)
1736
+// tabbedPane.add(infoPanel);
1737
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1738
+// tabbedPane.setToolTipTextAt(3, "Information");
1739
+
15611740 /*
15621741 cTree jTree = new cTree(null);
15631742 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1619,7 +1798,7 @@
16191798 bigThree = new cGridBag();
16201799 bigThree.addComponent(scenePanel);
16211800 bigThree.addComponent(centralPanel);
1622
- bigThree.addComponent(XYZPanel);
1801
+ //bigThree.addComponent(XYZPanel);
16231802
16241803 // // SIDE EFFECT!!!
16251804 // aConstraints.gridx = 0;
....@@ -1628,6 +1807,23 @@
16281807 // aConstraints.gridheight = 1;
16291808
16301809 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1810
+
1811
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1812
+ new java.beans.PropertyChangeListener()
1813
+ {
1814
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1815
+ {
1816
+ if ((Integer)pce.getOldValue() == 1)
1817
+ {
1818
+ if (radio.layout != expandedLayout)
1819
+ {
1820
+ radio.layout = expandedLayout;
1821
+ radio.layout.doClick();
1822
+ }
1823
+ }
1824
+ }
1825
+ });
1826
+
16311827 framePanel.setContinuousLayout(false);
16321828 framePanel.setOneTouchExpandable(false);
16331829 //.setDividerLocation(0.8);
....@@ -1637,7 +1833,7 @@
16371833
16381834 frame.getContentPane().setLayout(new BorderLayout());
16391835 /**/
1640
- JTabbedPane worldPane = new JTabbedPane();
1836
+ //JTabbedPane worldPane = new JTabbedPane();
16411837 //worldPane.add(bigPanel);
16421838 //worldPane.add(worldPanel);
16431839 /**/
....@@ -1660,7 +1856,6 @@
16601856 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16611857 frame.addWindowListener(new WindowAdapter()
16621858 {
1663
-
16641859 public void windowClosing(WindowEvent e)
16651860 {
16661861 Close();
....@@ -1683,12 +1878,426 @@
16831878 ctrlPanel.removeAll();
16841879 }
16851880
1686
- void SetupMaterial(cGridBag panel)
1881
+ void SetupMaterial(cGridBag materialpanel)
16871882 {
1688
- /*
1883
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1884
+
1885
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1886
+ skin.setToolTipText("Skin");
1887
+ skin.addMouseListener(new MouseAdapter()
1888
+ {
1889
+ public void mouseClicked(MouseEvent e)
1890
+ {
1891
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1892
+ cMaterial material = object.material;
1893
+
1894
+ // Skin
1895
+ colorField.setFloat(material.color);
1896
+ float saturation = material.modulation;
1897
+
1898
+ if (!cameraView.Skinshader)
1899
+ {
1900
+ saturation /= 1.5;
1901
+ }
1902
+
1903
+ saturationField.setFloat(saturation);
1904
+
1905
+ subsurfaceField.setFloat(material.subsurface);
1906
+ selfshadowField.setFloat(material.diffuseness);
1907
+ diffusenessField.setFloat(material.factor);
1908
+ shininessField.setFloat(material.shininess);
1909
+ shadowbiasField.setFloat(material.shadowbias);
1910
+ diffuseField.setFloat(material.diffuse);
1911
+ specularField.setFloat(material.specular);
1912
+
1913
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1914
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1915
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1916
+
1917
+ materialtouched = true;
1918
+ applySelf();
1919
+ }
1920
+ });
1921
+ presetpanel.add(skin);
1922
+
1923
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1924
+ lambert.setToolTipText("Diffuse");
1925
+ lambert.addMouseListener(new MouseAdapter()
1926
+ {
1927
+ public void mouseClicked(MouseEvent e)
1928
+ {
1929
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1930
+ cMaterial material = object.material;
1931
+
1932
+ diffusenessField.setFloat(material.factor);
1933
+ selfshadowField.setFloat(material.diffuseness);
1934
+
1935
+ materialtouched = true;
1936
+ applySelf();
1937
+ }
1938
+ });
1939
+ presetpanel.add(lambert);
1940
+
1941
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1942
+ diffuse2.setToolTipText("Diffuse2");
1943
+ diffuse2.addMouseListener(new MouseAdapter()
1944
+ {
1945
+ public void mouseClicked(MouseEvent e)
1946
+ {
1947
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1948
+ cMaterial material = object.material;
1949
+
1950
+ diffusenessField.setFloat(material.factor);
1951
+ selfshadowField.setFloat(material.diffuseness);
1952
+
1953
+ materialtouched = true;
1954
+ applySelf();
1955
+ }
1956
+ });
1957
+ presetpanel.add(diffuse2);
1958
+
1959
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1960
+ diffusemoon.setToolTipText("Moon");
1961
+ diffusemoon.addMouseListener(new MouseAdapter()
1962
+ {
1963
+ public void mouseClicked(MouseEvent e)
1964
+ {
1965
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1966
+ cMaterial material = object.material;
1967
+
1968
+ diffusenessField.setFloat(material.factor);
1969
+ selfshadowField.setFloat(material.diffuseness);
1970
+
1971
+ materialtouched = true;
1972
+ applySelf();
1973
+ }
1974
+ });
1975
+ presetpanel.add(diffusemoon);
1976
+
1977
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1978
+ diffusemoon2.setToolTipText("Moon2");
1979
+ diffusemoon2.addMouseListener(new MouseAdapter()
1980
+ {
1981
+ public void mouseClicked(MouseEvent e)
1982
+ {
1983
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1984
+ cMaterial material = object.material;
1985
+
1986
+ diffusenessField.setFloat(material.factor);
1987
+ selfshadowField.setFloat(material.diffuseness);
1988
+
1989
+ materialtouched = true;
1990
+ applySelf();
1991
+ }
1992
+ });
1993
+ presetpanel.add(diffusemoon2);
1994
+
1995
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1996
+ diffusemoon3.setToolTipText("Moon3");
1997
+ diffusemoon3.addMouseListener(new MouseAdapter()
1998
+ {
1999
+ public void mouseClicked(MouseEvent e)
2000
+ {
2001
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
2002
+ cMaterial material = object.material;
2003
+
2004
+ diffusenessField.setFloat(material.factor);
2005
+ selfshadowField.setFloat(material.diffuseness);
2006
+
2007
+ materialtouched = true;
2008
+ applySelf();
2009
+ }
2010
+ });
2011
+ presetpanel.add(diffusemoon3);
2012
+
2013
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
2014
+ diffusesheen.setToolTipText("Sheen");
2015
+ diffusesheen.addMouseListener(new MouseAdapter()
2016
+ {
2017
+ public void mouseClicked(MouseEvent e)
2018
+ {
2019
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
2020
+ cMaterial material = object.material;
2021
+
2022
+ sheenField.setFloat(material.sheen);
2023
+
2024
+ materialtouched = true;
2025
+ applySelf();
2026
+ }
2027
+ });
2028
+ presetpanel.add(diffusesheen);
2029
+
2030
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2031
+ rough.setToolTipText("Rough metal");
2032
+ rough.addMouseListener(new MouseAdapter()
2033
+ {
2034
+ public void mouseClicked(MouseEvent e)
2035
+ {
2036
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2037
+ cMaterial material = object.material;
2038
+
2039
+ shininessField.setFloat(material.shininess);
2040
+ velvetField.setFloat(material.velvet);
2041
+
2042
+ materialtouched = true;
2043
+ applySelf();
2044
+ }
2045
+ });
2046
+ presetpanel.add(rough);
2047
+
2048
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2049
+ rough2.setToolTipText("Medium metal");
2050
+ rough2.addMouseListener(new MouseAdapter()
2051
+ {
2052
+ public void mouseClicked(MouseEvent e)
2053
+ {
2054
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2055
+ cMaterial material = object.material;
2056
+
2057
+ shininessField.setFloat(material.shininess);
2058
+ lightareaField.setFloat(material.lightarea);
2059
+
2060
+ materialtouched = true;
2061
+ applySelf();
2062
+ }
2063
+ });
2064
+ presetpanel.add(rough2);
2065
+
2066
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2067
+ shini0.setToolTipText("Shiny");
2068
+ shini0.addMouseListener(new MouseAdapter()
2069
+ {
2070
+ public void mouseClicked(MouseEvent e)
2071
+ {
2072
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2073
+ cMaterial material = object.material;
2074
+
2075
+ shininessField.setFloat(material.shininess);
2076
+ lightareaField.setFloat(material.lightarea);
2077
+
2078
+ materialtouched = true;
2079
+ applySelf();
2080
+ }
2081
+ });
2082
+ presetpanel.add(shini0);
2083
+
2084
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2085
+ shini1.setToolTipText("Shiny2");
2086
+ shini1.addMouseListener(new MouseAdapter()
2087
+ {
2088
+ public void mouseClicked(MouseEvent e)
2089
+ {
2090
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2091
+ cMaterial material = object.material;
2092
+
2093
+ shininessField.setFloat(material.shininess);
2094
+ lightareaField.setFloat(material.lightarea);
2095
+
2096
+ materialtouched = true;
2097
+ applySelf();
2098
+ }
2099
+ });
2100
+ presetpanel.add(shini1);
2101
+
2102
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2103
+ shini2.setToolTipText("Shiny3");
2104
+ shini2.addMouseListener(new MouseAdapter()
2105
+ {
2106
+ public void mouseClicked(MouseEvent e)
2107
+ {
2108
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2109
+ cMaterial material = object.material;
2110
+
2111
+ shininessField.setFloat(material.shininess);
2112
+ lightareaField.setFloat(material.lightarea);
2113
+
2114
+ materialtouched = true;
2115
+ applySelf();
2116
+ }
2117
+ });
2118
+ presetpanel.add(shini2);
2119
+
2120
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2121
+ aniso.setToolTipText("AnisoU");
2122
+ aniso.addMouseListener(new MouseAdapter()
2123
+ {
2124
+ public void mouseClicked(MouseEvent e)
2125
+ {
2126
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2127
+ cMaterial material = object.material;
2128
+
2129
+ anisoField.setFloat(material.aniso);
2130
+ anisoVField.setFloat(material.anisoV);
2131
+
2132
+ materialtouched = true;
2133
+ applySelf();
2134
+ }
2135
+ });
2136
+ presetpanel.add(aniso);
2137
+
2138
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2139
+ aniso2.setToolTipText("AnisoV");
2140
+ aniso2.addMouseListener(new MouseAdapter()
2141
+ {
2142
+ public void mouseClicked(MouseEvent e)
2143
+ {
2144
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2145
+ cMaterial material = object.material;
2146
+
2147
+ anisoField.setFloat(material.aniso);
2148
+ anisoVField.setFloat(material.anisoV);
2149
+
2150
+ materialtouched = true;
2151
+ applySelf();
2152
+ }
2153
+ });
2154
+ presetpanel.add(aniso2);
2155
+
2156
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2157
+ aniso3.setToolTipText("AnisoUV");
2158
+ aniso3.addMouseListener(new MouseAdapter()
2159
+ {
2160
+ public void mouseClicked(MouseEvent e)
2161
+ {
2162
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2163
+ cMaterial material = object.material;
2164
+
2165
+ anisoField.setFloat(material.aniso);
2166
+ anisoVField.setFloat(material.anisoV);
2167
+
2168
+ materialtouched = true;
2169
+ applySelf();
2170
+ }
2171
+ });
2172
+ presetpanel.add(aniso3);
2173
+
2174
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2175
+ velvet0.setToolTipText("Velvet");
2176
+ velvet0.addMouseListener(new MouseAdapter()
2177
+ {
2178
+ public void mouseClicked(MouseEvent e)
2179
+ {
2180
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2181
+ cMaterial material = object.material;
2182
+
2183
+ diffusenessField.setFloat(material.factor);
2184
+ selfshadowField.setFloat(material.diffuseness);
2185
+ sheenField.setFloat(material.sheen);
2186
+ shininessField.setFloat(material.shininess);
2187
+ velvetField.setFloat(material.velvet);
2188
+ shiftField.setFloat(material.shift);
2189
+
2190
+ materialtouched = true;
2191
+ applySelf();
2192
+ }
2193
+ });
2194
+ presetpanel.add(velvet0);
2195
+
2196
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2197
+ bump0.setToolTipText("Bump texture");
2198
+ bump0.addMouseListener(new MouseAdapter()
2199
+ {
2200
+ public void mouseClicked(MouseEvent e)
2201
+ {
2202
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2203
+ cMaterial material = object.material;
2204
+
2205
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2206
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2207
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2208
+
2209
+ materialtouched = true;
2210
+ applySelf();
2211
+ }
2212
+ });
2213
+ presetpanel.add(bump0);
2214
+
2215
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2216
+ borderShader.setToolTipText("Border fade");
2217
+ borderShader.addMouseListener(new MouseAdapter()
2218
+ {
2219
+ public void mouseClicked(MouseEvent e)
2220
+ {
2221
+ borderfadeField.setFloat(0.5);
2222
+ opacityField.setFloat(0.75);
2223
+
2224
+ materialtouched = true;
2225
+ applySelf();
2226
+ }
2227
+ });
2228
+ presetpanel.add(borderShader);
2229
+
2230
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2231
+ halo.setToolTipText("Halo");
2232
+ halo.addMouseListener(new MouseAdapter()
2233
+ {
2234
+ public void mouseClicked(MouseEvent e)
2235
+ {
2236
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2237
+ cMaterial material = object.material;
2238
+
2239
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2240
+
2241
+ materialtouched = true;
2242
+ applySelf();
2243
+ }
2244
+ });
2245
+ presetpanel.add(halo);
2246
+
2247
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2248
+ candle.setToolTipText("Candle");
2249
+ candle.addMouseListener(new MouseAdapter()
2250
+ {
2251
+ public void mouseClicked(MouseEvent e)
2252
+ {
2253
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2254
+ cMaterial material = object.material;
2255
+
2256
+ subsurfaceField.setFloat(material.subsurface);
2257
+ shadowbiasField.setFloat(material.shadowbias);
2258
+ ambientField.setFloat(material.ambient);
2259
+ specularField.setFloat(material.specular);
2260
+ lightareaField.setFloat(material.lightarea);
2261
+ shininessField.setFloat(material.shininess);
2262
+
2263
+ materialtouched = true;
2264
+ applySelf();
2265
+ }
2266
+ });
2267
+ presetpanel.add(candle);
2268
+
2269
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2270
+ shadowShader.setToolTipText("Shadow");
2271
+ shadowShader.addMouseListener(new MouseAdapter()
2272
+ {
2273
+ public void mouseClicked(MouseEvent e)
2274
+ {
2275
+ diffuseField.setFloat(0.001);
2276
+ ambientField.setFloat(0.001);
2277
+ cameraField.setFloat(0.001);
2278
+ specularField.setFloat(0.001);
2279
+ fakedepthField.setFloat(0.001);
2280
+ opacityField.setFloat(0.6);
2281
+
2282
+ materialtouched = true;
2283
+ applySelf();
2284
+ }
2285
+ });
2286
+ presetpanel.add(shadowShader);
2287
+
2288
+ cGridBag panel = new cGridBag().setVertical(true);
2289
+
2290
+ presetpanel.preferredWidth = 1;
2291
+
2292
+ materialpanel.add(presetpanel);
2293
+ materialpanel.add(panel);
2294
+
2295
+ panel.preferredWidth = 8;
2296
+
2297
+ /*
16892298 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16902299 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- */
2300
+ */
16922301
16932302 cGridBag editBar = new cGridBag().setVertical(false);
16942303
....@@ -1722,27 +2331,61 @@
17222331 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17232332
17242333 cGridBag colorSection = new cGridBag().setVertical(true);
2334
+
2335
+ cGridBag huepanel = new cGridBag();
2336
+ cGridBag huelabel = new cGridBag();
2337
+ cLabel hue = GetLabel("icons/hue.png", false);
2338
+ hue.fit = true;
2339
+
2340
+ hue.addMouseListener(new MouseAdapter()
2341
+ {
2342
+ public void mousePressed(MouseEvent e)
2343
+ {
2344
+ int x = e.getX();
2345
+
2346
+ colorField.setFloat((double)x / ((cLabel)e.getSource()).getWidth());
2347
+ }
2348
+ });
2349
+
2350
+ huelabel.add(hue);
2351
+ huelabel.preferredWidth = 20;
2352
+ huepanel.add(new cGridBag()); // Label
2353
+ huepanel.add(huelabel); // Field/slider
2354
+
2355
+ huepanel.preferredHeight = 7;
2356
+
2357
+ colorSection.add(huepanel);
17252358
17262359 cGridBag color = new cGridBag();
1727
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1728
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1729
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2360
+
2361
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2362
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2363
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2364
+
17302365 //colorField.preferredWidth = 200;
17312366 colorSection.add(color);
17322367
17332368 cGridBag modulation = new cGridBag();
17342369 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17352370 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1736
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2371
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17372372 colorSection.add(modulation);
17382373
2374
+ cGridBag opacity = new cGridBag();
2375
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2376
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2377
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2378
+ colorSection.add(opacity);
2379
+
2380
+ colorSection.add(GetSeparator());
2381
+
17392382 cGridBag texture = new cGridBag();
17402383 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17412384 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17422385 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17432386 colorSection.add(texture);
17442387
1745
- panel.add(new JSeparator());
2388
+ panel.add(GetSeparator());
17462389
17472390 panel.add(colorSection);
17482391
....@@ -1798,7 +2441,7 @@
17982441 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17992442 diffuseSection.add(shadowbias);
18002443
1801
- panel.add(new JSeparator());
2444
+ panel.add(GetSeparator());
18022445
18032446 panel.add(diffuseSection);
18042447
....@@ -1861,7 +2504,7 @@
18612504 specularSection.add(anisoV);
18622505
18632506
1864
- panel.add(new JSeparator());
2507
+ panel.add(GetSeparator());
18652508
18662509 panel.add(specularSection);
18672510
....@@ -1886,12 +2529,6 @@
18862529 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18872530 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18882531 colorSection.add(backlit);
1889
-
1890
- cGridBag opacity = new cGridBag();
1891
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1892
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1893
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1894
- colorSection.add(opacity);
18952532
18962533 //panel.add(new JSeparator());
18972534
....@@ -1937,7 +2574,7 @@
19372574 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19382575 textureSection.add(opacityPower);
19392576
1940
- panel.add(new JSeparator());
2577
+ panel.add(GetSeparator());
19412578
19422579 panel.add(textureSection);
19432580
....@@ -2924,7 +3561,7 @@
29243561
29253562 freezematerial = true;
29263563 colorField.setFloat(mat.color);
2927
- modulationField.setFloat(mat.modulation);
3564
+ saturationField.setFloat(mat.modulation);
29283565 metalnessField.setFloat(mat.metalness);
29293566 diffuseField.setFloat(mat.diffuse);
29303567 specularField.setFloat(mat.specular);
....@@ -2986,32 +3623,8 @@
29863623
29873624 if (multiplyToggle != null)
29883625 multiplyToggle.setSelected(mat.multiply);
2989
-
2990
- assert (object.projectedVertices != null);
2991
-
2992
- if (object.projectedVertices.length <= 2)
2993
- {
2994
- // Side effect...
2995
- Object3D.cVector2[] keep = object.projectedVertices;
2996
- object.projectedVertices = new Object3D.cVector2[3];
2997
- for (int i = 0; i < 3; i++)
2998
- {
2999
- if (i < keep.length)
3000
- {
3001
- object.projectedVertices[i] = keep[i];
3002
- } else
3003
- {
3004
- object.projectedVertices[i] = new Object3D.cVector2();
3005
- }
3006
- /*
3007
- if(keep.length == 0)
3008
- object.projectedVertices[0] = new Object3D.cVector2();
3009
- else
3010
- object.projectedVertices[0] = keep[0];
3011
- object.projectedVertices[1] = new Object3D.cVector2();
3012
- */
3013
- }
3014
- }
3626
+
3627
+ AllocProjectedVertices(object);
30153628
30163629 SetMaterial(mat, object.projectedVertices);
30173630 }
....@@ -3131,6 +3744,17 @@
31313744 public void itemStateChanged(ItemEvent event)
31323745 {
31333746 // System.out.println("Propagate = " + propagate);
3747
+ if (event.getSource() == pinButton)
3748
+ {
3749
+ copy.pinned ^= true;
3750
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3751
+ {
3752
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3753
+ copy.CloseUI();
3754
+ //copy.editWindow.refreshContents();
3755
+ }
3756
+ }
3757
+ else
31343758 if (event.getSource() == propagateToggle)
31353759 {
31363760 propagate ^= true;
....@@ -3235,8 +3859,9 @@
32353859 } else if (event.getSource() == liveCB)
32363860 {
32373861 copy.live ^= true;
3862
+ objEditor.refreshContents(true); // To show item colors
32383863 return;
3239
- } else if (event.getSource() == selectCB)
3864
+ } else if (event.getSource() == selectableCB)
32403865 {
32413866 copy.dontselect ^= true;
32423867 return;
....@@ -3244,7 +3869,7 @@
32443869 {
32453870 copy.hide ^= true;
32463871 copy.Touch(); // display list issue
3247
- objEditor.refreshContents();
3872
+ objEditor.refreshContents(true); // To show item colors
32483873 return;
32493874 } else if (event.getSource() == link2masterCB)
32503875 {
....@@ -3309,7 +3934,7 @@
33093934 //System.out.println("ObjEditor " + event);
33103935 applySelf0(true);
33113936 //parent.applySelf();
3312
- objEditor.refreshContents();
3937
+ // conflicts with requestFocus objEditor.refreshContents();
33133938 } else if (source == resetButton)
33143939 {
33153940 CameraPane.fullreset = true;
....@@ -3500,6 +4125,7 @@
35004125
35014126 static public byte[] Compress(Object3D o)
35024127 {
4128
+ // Slower to actually compress.
35034129 try
35044130 {
35054131 ByteArrayOutputStream baos = new ByteArrayOutputStream();
....@@ -3601,6 +4227,7 @@
36014227 {
36024228 //Save(true);
36034229 Replace();
4230
+ SetVersionStates();
36044231 }
36054232
36064233 private boolean Equal(byte[] compress, byte[] name)
....@@ -3619,31 +4246,50 @@
36194246 return true;
36204247 }
36214248
3622
- java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4249
+ void DeleteVersion()
4250
+ {
4251
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4252
+ {
4253
+ copy.versionlist[i] = copy.versionlist[i+1];
4254
+ }
4255
+
4256
+ if (copy.versionlist[copy.versionindex] == null)
4257
+ copy.versionindex -= 1;
4258
+
4259
+ if (copy.versionindex != -1)
4260
+ CopyChanged();
4261
+
4262
+ SetVersionStates();
4263
+ }
36234264
36244265 public boolean Save(boolean user)
36254266 {
36264267 System.err.println("Save");
4268
+ Replace();
36274269
3628
- cRadio tab = GetCurrentTab();
4270
+ //cRadio tab = GetCurrentTab();
36294271
3630
- byte[] compress = CompressCopy();
4272
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
36314273
36324274 boolean thesame = false;
36334275
3634
- // Quick heuristic using length. Works only when stream is compressed.
3635
- if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3636
- {
3637
- thesame = true;
3638
- }
4276
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4277
+// {
4278
+// thesame = true;
4279
+// }
36394280
36404281 //EditorFrame.m_MainFrame.requestFocusInWindow();
36414282 if (!thesame)
36424283 {
4284
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4285
+ {
4286
+ copy.versionlist[i] = copy.versionlist[i-1];
4287
+ }
4288
+
36434289 //tab.user[tab.versionindex] = user;
36444290 //boolean increment = true; // tab.graphs[tab.versionindex] == null;
36454291
3646
- copy.versions[++copy.versionindex] = compress;
4292
+ copy.versionlist[++copy.versionindex] = compress;
36474293
36484294 // if (increment)
36494295 // tab.versionindex++;
....@@ -3653,13 +4299,13 @@
36534299
36544300 //assert(hashtable.isEmpty());
36554301
3656
- for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3657
- {
3658
- //tab.user[i] = false;
3659
- copy.versions[i] = null;
3660
- }
4302
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4303
+// {
4304
+// //tab.user[i] = false;
4305
+// copy.versionlist[i] = null;
4306
+// }
36614307
3662
- SetUndoStates();
4308
+ SetVersionStates();
36634309
36644310 // test save
36654311 if (false)
....@@ -3682,27 +4328,65 @@
36824328
36834329 return !thesame;
36844330 }
3685
-
3686
- void CopyChanged(Object3D obj)
4331
+
4332
+ boolean flashIt = true;
4333
+
4334
+ void RefreshSelection()
36874335 {
3688
- SetUndoStates();
4336
+ Object3D selection = new Object3D();
4337
+
4338
+ for (int i = 0; i < copy.selection.size(); i++)
4339
+ {
4340
+ Object3D elem = copy.selection.elementAt(i);
4341
+
4342
+ Object3D obj = copy.GetObject(elem.GetUUID());
4343
+
4344
+ if (obj == null)
4345
+ {
4346
+ copy.selection.remove(i--);
4347
+ }
4348
+ else
4349
+ {
4350
+ selection.add(obj);
4351
+ copy.selection.setElementAt(obj, i);
4352
+ }
4353
+ }
4354
+
4355
+ flashIt = false;
4356
+ GetTree().clearSelection();
4357
+ for (int i = 0; i < selection.size(); i++)
4358
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4359
+ flashIt = true;
4360
+
4361
+ //refreshContents(false);
4362
+ }
4363
+
4364
+ void CopyChanged()
4365
+ {
4366
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4367
+
4368
+ SetVersionStates();
36894369
36904370 boolean temp = CameraPane.SWITCH;
36914371 CameraPane.SWITCH = false;
36924372
3693
- copy.ExtractBigData(versiontable);
4373
+ copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
36944374
36954375 copy.clear();
36964376
4377
+ copy.skyboxname = obj.skyboxname;
4378
+ copy.skyboxext = obj.skyboxext;
4379
+
36974380 for (int i=0; i<obj.Size(); i++)
36984381 {
36994382 copy.add(obj.get(i));
37004383 }
37014384
3702
- copy.RestoreBigData(versiontable);
4385
+ copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
37034386
37044387 CameraPane.SWITCH = temp;
37054388
4389
+ RefreshSelection();
37064390 //assert(hashtable.isEmpty());
37074391
37084392 copy.Touch();
....@@ -3723,29 +4407,63 @@
37234407 }
37244408 }
37254409
3726
- refreshContents();
4410
+ refreshContents(true);
37274411 }
37284412
3729
- cButton undoButton;
4413
+ cButton previousVersionButton;
37304414 cButton restoreButton;
37314415 cButton replaceButton;
3732
- cButton redoButton;
4416
+ cButton nextVersionButton;
4417
+ cButton saveVersionButton;
4418
+ cButton deleteVersionButton;
37334419
3734
- void SetUndoStates()
4420
+ boolean muteSlider;
4421
+
4422
+ int VersionCount()
37354423 {
3736
- cRadio tab = GetCurrentTab();
4424
+ int count = 0;
4425
+
4426
+ for (int i = copy.versionlist.length; --i >= 0;)
4427
+ {
4428
+ if (copy.versionlist[i] != null)
4429
+ count++;
4430
+ }
4431
+
4432
+ return count;
4433
+ }
4434
+
4435
+ void SetVersionStates()
4436
+ {
4437
+ //if (true)
4438
+ // return;
4439
+
4440
+ //cRadio tab = GetCurrentTab();
37374441
37384442 restoreButton.setEnabled(copy.versionindex != -1);
37394443 replaceButton.setEnabled(copy.versionindex != -1);
3740
- undoButton.setEnabled(copy.versionindex > 0);
3741
- redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
4444
+
4445
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4446
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4447
+
4448
+ deleteVersionButton.setEnabled(copy.versionindex != -1);
4449
+ //copy.versionlist[copy.versionindex + 1] != null);
4450
+
4451
+ muteSlider = true;
4452
+ versionSlider.setMinimum(0);
4453
+ versionSlider.setMaximum(VersionCount() - 1);
4454
+ versionSlider.setInteger(copy.versionindex);
4455
+ versionSlider.setEnabled(copy.versionindex != -1);
4456
+ muteSlider = false;
37424457 }
37434458
3744
- public boolean Undo()
4459
+ public boolean PreviousVersion()
37454460 {
4461
+ // Option?
4462
+ Replace();
4463
+
37464464 System.err.println("Undo");
37474465
3748
- cRadio tab = GetCurrentTab();
4466
+ //cRadio tab = GetCurrentTab();
37494467
37504468 if (copy.versionindex == 0)
37514469 {
....@@ -3768,7 +4486,7 @@
37684486
37694487 copy.versionindex -= 1;
37704488
3771
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4489
+ CopyChanged();
37724490
37734491 return true;
37744492 }
....@@ -3777,41 +4495,45 @@
37774495 {
37784496 System.err.println("Restore");
37794497
3780
- cRadio tab = GetCurrentTab();
4498
+ //cRadio tab = GetCurrentTab();
37814499
3782
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4500
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
37834501 {
37844502 java.awt.Toolkit.getDefaultToolkit().beep();
37854503 return false;
37864504 }
37874505
3788
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4506
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4507
+ CopyChanged();
37894508
37904509 return true;
37914510 }
37924511
37934512 public boolean Replace()
37944513 {
3795
- System.err.println("Replace");
4514
+ //System.err.println("Replace");
37964515
3797
- cRadio tab = GetCurrentTab();
4516
+ //cRadio tab = GetCurrentTab();
37984517
3799
- if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
4518
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
38004519 {
38014520 // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
38024521 return false;
38034522 }
38044523
3805
- copy.versions[copy.versionindex] = CompressCopy();
4524
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
38064525
38074526 return true;
38084527 }
38094528
3810
- public void Redo()
4529
+ public void NextVersion()
38114530 {
3812
- cRadio tab = GetCurrentTab();
4531
+ // Option?
4532
+ Replace();
38134533
3814
- if (copy.versions[copy.versionindex + 1] == null)
4534
+ //cRadio tab = GetCurrentTab();
4535
+
4536
+ if (copy.versionlist[copy.versionindex + 1] == null)
38154537 {
38164538 java.awt.Toolkit.getDefaultToolkit().beep();
38174539 return;
....@@ -3819,7 +4541,7 @@
38194541
38204542 copy.versionindex += 1;
38214543
3822
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4544
+ CopyChanged();
38234545
38244546 //if (!tab.user[tab.versionindex])
38254547 // tab.graphs[tab.versionindex] = null;
....@@ -4016,6 +4738,12 @@
40164738 // else
40174739 // applySelf(true);
40184740 // }
4741
+
4742
+ boolean Equal(double a, double b)
4743
+ {
4744
+ return Math.abs(a - b) < 0.001;
4745
+ }
4746
+
40194747 void applySelf0(boolean name)
40204748 {
40214749 if (name)
....@@ -4033,7 +4761,7 @@
40334761 //copy.material = new cMaterial(copy.GetMaterial());
40344762
40354763 current.color = (float) colorField.getFloat();
4036
- current.modulation = (float) modulationField.getFloat();
4764
+ current.modulation = (float) saturationField.getFloat();
40374765 current.metalness = (float) metalnessField.getFloat();
40384766 current.diffuse = (float) diffuseField.getFloat();
40394767 current.specular = (float) specularField.getFloat();
....@@ -4065,29 +4793,52 @@
40654793 {
40664794 cMaterial mat = copy.material;
40674795
4068
- colorField.SetToolTipValue((mat.color));
4069
- modulationField.SetToolTipValue((mat.modulation));
4070
- metalnessField.SetToolTipValue((mat.metalness));
4071
- diffuseField.SetToolTipValue((mat.diffuse));
4072
- specularField.SetToolTipValue((mat.specular));
4073
- shininessField.SetToolTipValue((mat.shininess));
4074
- shiftField.SetToolTipValue((mat.shift));
4075
- ambientField.SetToolTipValue((mat.ambient));
4076
- lightareaField.SetToolTipValue((mat.lightarea));
4077
- diffusenessField.SetToolTipValue((mat.factor));
4078
- velvetField.SetToolTipValue((mat.velvet));
4079
- sheenField.SetToolTipValue((mat.sheen));
4080
- subsurfaceField.SetToolTipValue((mat.subsurface));
4081
- backlitField.SetToolTipValue((mat.bump));
4082
- anisoField.SetToolTipValue((mat.aniso));
4083
- anisoVField.SetToolTipValue((mat.anisoV));
4084
- cameraField.SetToolTipValue((mat.cameralight));
4085
- selfshadowField.SetToolTipValue((mat.diffuseness));
4086
- shadowField.SetToolTipValue((mat.shadow));
4087
- textureField.SetToolTipValue((mat.texture));
4088
- opacityField.SetToolTipValue((mat.opacity));
4089
- fakedepthField.SetToolTipValue((mat.fakedepth));
4090
- shadowbiasField.SetToolTipValue((mat.shadowbias));
4796
+ if (!Equal(colorField.getFloat(), mat.color))
4797
+ colorField.SetToolTipValue((mat.color));
4798
+ if (!Equal(saturationField.getFloat(), mat.modulation))
4799
+ saturationField.SetToolTipValue((mat.modulation));
4800
+ if (!Equal(metalnessField.getFloat(), mat.metalness))
4801
+ metalnessField.SetToolTipValue((mat.metalness));
4802
+ if (!Equal(diffuseField.getFloat(), mat.diffuse))
4803
+ diffuseField.SetToolTipValue((mat.diffuse));
4804
+ if (!Equal(specularField.getFloat(), mat.specular))
4805
+ specularField.SetToolTipValue((mat.specular));
4806
+ if (!Equal(shininessField.getFloat(), mat.shininess))
4807
+ shininessField.SetToolTipValue((mat.shininess));
4808
+ if (!Equal(shiftField.getFloat(), mat.shift))
4809
+ shiftField.SetToolTipValue((mat.shift));
4810
+ if (!Equal(ambientField.getFloat(), mat.ambient))
4811
+ ambientField.SetToolTipValue((mat.ambient));
4812
+ if (!Equal(lightareaField.getFloat(), mat.lightarea))
4813
+ lightareaField.SetToolTipValue((mat.lightarea));
4814
+ if (!Equal(diffusenessField.getFloat(), mat.factor))
4815
+ diffusenessField.SetToolTipValue((mat.factor));
4816
+ if (!Equal(velvetField.getFloat(), mat.velvet))
4817
+ velvetField.SetToolTipValue((mat.velvet));
4818
+ if (!Equal(sheenField.getFloat(), mat.sheen))
4819
+ sheenField.SetToolTipValue((mat.sheen));
4820
+ if (!Equal(subsurfaceField.getFloat(), mat.subsurface))
4821
+ subsurfaceField.SetToolTipValue((mat.subsurface));
4822
+ if (!Equal(backlitField.getFloat(), mat.bump))
4823
+ backlitField.SetToolTipValue((mat.bump));
4824
+ if (!Equal(anisoField.getFloat(), mat.aniso))
4825
+ anisoField.SetToolTipValue((mat.aniso));
4826
+ if (!Equal(anisoVField.getFloat(), mat.anisoV))
4827
+ anisoVField.SetToolTipValue((mat.anisoV));
4828
+ if (!Equal(cameraField.getFloat(), mat.cameralight))
4829
+ cameraField.SetToolTipValue((mat.cameralight));
4830
+ if (!Equal(selfshadowField.getFloat(), mat.diffuseness))
4831
+ selfshadowField.SetToolTipValue((mat.diffuseness));
4832
+ if (!Equal(shadowField.getFloat(), mat.shadow))
4833
+ shadowField.SetToolTipValue((mat.shadow));
4834
+ if (!Equal(textureField.getFloat(), mat.texture))
4835
+ textureField.SetToolTipValue((mat.texture));
4836
+ if (!Equal(opacityField.getFloat(), mat.opacity))
4837
+ opacityField.SetToolTipValue((mat.opacity));
4838
+ if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
4839
+ fakedepthField.SetToolTipValue((mat.fakedepth));
4840
+ if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
4841
+ shadowbiasField.SetToolTipValue((mat.shadowbias));
40914842 }
40924843
40934844 if (copy.material != null && copy.projectedVertices.length > 0 && copy.projectedVertices[0] != null)
....@@ -4118,18 +4869,24 @@
41184869 //copy.Touch();
41194870 }
41204871
4121
- cNumberSlider versionField;
4872
+ cNumberSlider versionSlider;
41224873
41234874 public void stateChanged(ChangeEvent e)
41244875 {
41254876 // assert(false);
4126
- if (e.getSource() == versionField)
4877
+ if (e.getSource() == versionSlider)
41274878 {
4128
- int version = versionField.getInteger();
4879
+ if (muteSlider)
4880
+ return;
41294881
4130
- if (copy.versions[version] != null)
4882
+ Replace();
4883
+
4884
+ int version = versionSlider.getInteger();
4885
+
4886
+ if (version != -1 && copy.versionlist[version] != null)
41314887 {
4132
- CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4888
+ copy.versionindex = version;
4889
+ CopyChanged();
41334890 }
41344891
41354892 return;
....@@ -4169,6 +4926,12 @@
41694926 {
41704927 //System.out.println("stateChanged = " + this);
41714928 materialtouched = true;
4929
+
4930
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4931
+ {
4932
+ saturationField.setFloat(1);
4933
+ }
4934
+
41724935 applySelf();
41734936 //System.out.println("this = " + this);
41744937 //System.out.println("PARENT = " + parent);
....@@ -4468,6 +5231,7 @@
44685231 {
44695232 if (GetTree() != null)
44705233 {
5234
+ GetTree().revalidate();
44715235 GetTree().repaint();
44725236 }
44735237
....@@ -4476,6 +5240,11 @@
44765240 ctrlPanel.validate(); // ? new
44775241 ctrlPanel.repaint();
44785242 }
5243
+
5244
+ if (previousVersionButton != null && copy.versionlist != null)
5245
+ SetVersionStates();
5246
+
5247
+ cameraView.requestFocusInWindow();
44795248 }
44805249
44815250 static TweenManager tweenManager = new TweenManager();
....@@ -4507,7 +5276,7 @@
45075276 // group = (Composite) group.get(0);
45085277 // }
45095278
4510
- System.out.println("makeSomething of " + thing);
5279
+ //System.out.println("makeSomething of " + thing);
45115280
45125281 /*
45135282 if (deselect && jList != null)
....@@ -4724,7 +5493,9 @@
47245493 readobj.ResetDisplayList();
47255494 } catch (Exception e)
47265495 {
4727
- //e.printStackTrace();
5496
+ if (!e.toString().contains("GZIP"))
5497
+ e.printStackTrace();
5498
+
47285499 try
47295500 {
47305501 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4804,6 +5575,8 @@
48045575 {
48055576 //readobj.deepCopySelf(copy);
48065577 copy.clear(); // june 2014
5578
+ copy.skyboxname = readobj.skyboxname;
5579
+ copy.skyboxext = readobj.skyboxext;
48075580 for (int i = 0; i < readobj.size(); i++)
48085581 {
48095582 Object3D child = readobj.get(i); // reserve(i);
....@@ -4844,6 +5617,7 @@
48445617 }
48455618 } catch (ClassCastException e)
48465619 {
5620
+ e.printStackTrace();
48475621 assert (false);
48485622 Composite c = (Composite) copy;
48495623 c.children.clear();
....@@ -4854,10 +5628,20 @@
48545628 c.addChild(csg);
48555629 }
48565630
4857
- copy.versions = readobj.versions;
5631
+ copy.versionlist = readobj.versionlist;
48585632 copy.versionindex = readobj.versionindex;
5633
+ copy.versiontable = readobj.versiontable;
48595634
4860
- SetUndoStates();
5635
+ if (copy.versionlist == null)
5636
+ {
5637
+ // Backward compatibility
5638
+ copy.versionlist = new Object3D[100];
5639
+ copy.versionindex = -1;
5640
+
5641
+ //Save(true);
5642
+ }
5643
+
5644
+ //? SetUndoStates();
48615645
48625646 ResetModel();
48635647 copy.HardTouch(); // recompile?
....@@ -4869,7 +5653,7 @@
48695653 {
48705654 if (Grafreed.standAlone)
48715655 {
4872
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5656
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
48735657 browser.show();
48745658 String filename = browser.getFile();
48755659 if (filename != null && filename.length() > 0)
....@@ -4946,6 +5730,8 @@
49465730
49475731 void save()
49485732 {
5733
+ Replace();
5734
+
49495735 if (lastname == null)
49505736 {
49515737 return;
....@@ -4968,6 +5754,7 @@
49685754 //ps.print(buffer.toString());
49695755 } catch (IOException e)
49705756 {
5757
+ e.printStackTrace();
49715758 }
49725759 }
49735760
....@@ -5187,6 +5974,7 @@
51875974 ButtonGroup buttonGroup;
51885975
51895976 cGridBag toolboxPanel;
5977
+ cGridBag skyboxPanel;
51905978 cGridBag materialPanel;
51915979 cGridBag ctrlPanel;
51925980
....@@ -5260,7 +6048,7 @@
52606048 JLabel colorLabel;
52616049 cNumberSlider colorField;
52626050 JLabel modulationLabel;
5263
- cNumberSlider modulationField;
6051
+ cNumberSlider saturationField;
52646052 JLabel metalnessLabel;
52656053 cNumberSlider metalnessField;
52666054 JLabel diffuseLabel;
....@@ -5291,6 +6079,7 @@
52916079 cNumberSlider anisoField;
52926080 JLabel anisoVLabel;
52936081 cNumberSlider anisoVField;
6082
+
52946083 JLabel cameraLabel;
52956084 cNumberSlider cameraField;
52966085 JLabel selfshadowLabel;
....@@ -5305,6 +6094,7 @@
53056094 cNumberSlider fakedepthField;
53066095 JLabel shadowbiasLabel;
53076096 cNumberSlider shadowbiasField;
6097
+
53086098 JLabel bumpLabel;
53096099 cNumberSlider bumpField;
53106100 JLabel noiseLabel;