Normand Briere
2019-08-15 33504fc9a180903aace77613264550754fba5706
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,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
....@@ -327,6 +399,14 @@
327399 copy = localCopy;
328400 copy.editWindow = this;
329401
402
+// if (copy.versionlist == null)
403
+// {
404
+// copy.versionlist = new Object3D[100];
405
+// copy.versionindex = -1;
406
+//
407
+// Save(true);
408
+// }
409
+
330410 SetupMenu();
331411
332412 //SetupName(objEditor); // new
....@@ -394,6 +474,8 @@
394474
395475 ChangeListener changeListener = new ChangeListener()
396476 {
477
+ //String name;
478
+
397479 public void stateChanged(ChangeEvent changeEvent)
398480 {
399481 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -412,18 +494,49 @@
412494 // EditSelection(false);
413495 // }
414496
415
- refreshContents(false); // To refresh Info tab
497
+// if (objectPanel.getSelectedIndex() == 4)
498
+// {
499
+// name = copy.skyboxname;
500
+//
501
+// if (name == null)
502
+// {
503
+// name = "";
504
+// }
505
+//
506
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
507
+// copy.skyboxext = "jpg";
508
+// }
509
+// else
510
+// {
511
+// if (name != null)
512
+// {
513
+// if (name.equals(""))
514
+// {
515
+// copy.skyboxname = null;
516
+// copy.skyboxext = null;
517
+// }
518
+// else
519
+// {
520
+// copy.skyboxname = name;
521
+// }
522
+// }
523
+// }
524
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
525
+
526
+// refreshContents(false); // To refresh Info tab
527
+ cameraView.repaint();
416528 }
417529 };
418530 objectPanel.addChangeListener(changeListener);
419531
420532 toolbarPanel = new JPanel();
421533 toolbarPanel.setName("Toolbar");
534
+
422535 treePanel = new cGridBag();
423536 treePanel.setName("Tree");
424537
425538 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
539
+ //editPanel.setName("Edit");
427540
428541 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429542
....@@ -431,11 +544,13 @@
431544 editPanel.add(editCommandsPanel);
432545 editPanel.add(ctrlPanel);
433546
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
547
+ toolboxPanel = new cGridBag().setVertical(true);
548
+ //toolboxPanel.setName("Toolbox");
436549
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
550
+ skyboxPanel = new cGridBag().setVertical(true);
551
+
552
+ materialPanel = new cGridBag().setVertical(false);
553
+ //materialPanel.setName("Material");
439554
440555 /*JTextPane*/
441556 infoarea = createTextPane();
....@@ -443,14 +558,15 @@
443558
444559 infoarea.setEditable(true);
445560 SetText();
561
+
446562 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447563 // infoarea.setOpaque(false);
448564 // //infoarea.setForeground(textcolor);
449565 // TEXTAREA infoarea.setLineWrap(true);
450566 // TEXTAREA infoarea.setWrapStyleWord(true);
451567 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452
- //infoPanel.setPreferredSize(new Dimension(50, 200));
453
- infoPanel.setName("Info");
568
+ infoPanel.setPreferredSize(new Dimension(1, 1));
569
+ //infoPanel.setName("Info");
454570 //infoPanel.setLayout(new BorderLayout());
455571 //infoPanel.add(createTextPane());
456572
....@@ -717,6 +833,7 @@
717833 boolean maximized;
718834
719835 cButton fullscreenLayout;
836
+ cButton expandedLayout;
720837
721838 void Minimize()
722839 {
....@@ -756,10 +873,12 @@
756873 cButton minButton;
757874 cButton maxButton;
758875 cButton fullButton;
876
+ cButton collapseButton;
877
+ cButton maximize3DButton;
759878
760879 void ToggleFullScreen()
761880 {
762
-GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
881
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763882
764883 cameraView.ToggleFullScreen();
765884
....@@ -780,13 +899,13 @@
780899 // X frame.getContentPane().remove(/*"Center",*/bigThree);
781900 // X framePanel.add(bigThree);
782901 // X frame.getContentPane().add(/*"Center",*/framePanel);
783
- framePanel.setDividerLocation(46);
902
+// framePanel.setDividerLocation(46); // icons are 24x24
784903
785904 //frame.setVisible(true);
786
- radio.layout = keepButton;
905
+// radio.layout = keepButton;
787906 //theFrame = null;
788907 keepButton = null;
789
- radio.layout.doClick();
908
+// radio.layout.doClick();
790909
791910 } else
792911 {
....@@ -807,14 +926,47 @@
807926 // X frame.getContentPane().remove(/*"Center",*/framePanel);
808927 // X framePanel.remove(bigThree);
809928 // X frame.getContentPane().add(/*"Center",*/bigThree);
810
- framePanel.setDividerLocation(0);
929
+// framePanel.setDividerLocation(0);
811930
812
- radio.layout = fullscreenLayout;
813
- radio.layout.doClick();
931
+// radio.layout = fullscreenLayout;
932
+// radio.layout.doClick();
814933 //frame.setVisible(true);
815934 }
816935 frame.validate();
936
+
937
+ cameraView.requestFocusInWindow();
817938 }
939
+
940
+ void CollapseToolbar()
941
+ {
942
+ framePanel.setDividerLocation(0);
943
+ //frame.validate();
944
+
945
+ cameraView.requestFocusInWindow();
946
+ }
947
+
948
+ private Object3D Duplicate(Object3D object)
949
+ {
950
+ boolean temp = CameraPane.SWITCH;
951
+ CameraPane.SWITCH = false;
952
+
953
+ object.ExtractBigData(versiontable);
954
+ // if (copy == client)
955
+
956
+ Object3D versions[] = object.versionlist;
957
+ object.versionlist = null;
958
+
959
+ //byte[] compress = Compress(copy);
960
+ Object3D compress = (Object3D)Grafreed.clone(object);
961
+
962
+ object.versionlist = versions;
963
+
964
+ object.RestoreBigData(versiontable);
965
+
966
+ CameraPane.SWITCH = temp;
967
+
968
+ return compress;
969
+ }
818970
819971 private JTextPane createTextPane()
820972 {
....@@ -937,6 +1089,7 @@
9371089 {
9381090 SetupMaterial(materialPanel);
9391091 }
1092
+
9401093 //SetupName();
9411094 //SetupViews();
9421095 }
....@@ -946,7 +1099,7 @@
9461099 // NumberSlider vDivsField;
9471100 // JCheckBox endcaps;
9481101 JCheckBox liveCB;
949
- JCheckBox selectCB;
1102
+ JCheckBox selectableCB;
9501103 JCheckBox hideCB;
9511104 JCheckBox link2masterCB;
9521105 JCheckBox markCB;
....@@ -1145,6 +1298,18 @@
11451298
11461299 namePanel = new cGridBag();
11471300
1301
+ //if (copy.pinned)
1302
+ {
1303
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1304
+ pinButton.setSelected(copy.pinned);
1305
+ cGridBag t = new cGridBag();
1306
+ t.preferredWidth = 2;
1307
+ t.add(pinButton);
1308
+ namePanel.add(t);
1309
+
1310
+ pinButton.addItemListener(this);
1311
+ }
1312
+
11481313 nameField = AddText(namePanel, copy.GetName());
11491314 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11501315 oe.ctrlPanel.add(namePanel);
....@@ -1158,13 +1323,16 @@
11581323
11591324 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11601325 liveCB.setToolTipText("Animate object");
1161
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
- selectCB.setToolTipText("Make object selectable");
1326
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1327
+ selectableCB.setToolTipText("Make object selectable");
11631328 // Return();
1329
+
11641330 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11651331 hideCB.setToolTipText("Hide object");
11661332 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11671333 markCB.setToolTipText("As animation target transform");
1334
+
1335
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11681336
11691337 setupPanel2 = new cGridBag().setVertical(false);
11701338
....@@ -1174,10 +1342,11 @@
11741342 randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11751343 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11761344
1345
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1346
+ link2masterCB.setToolTipText("Attach to support");
1347
+
11771348 if (Globals.ADVANCED)
11781349 {
1179
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1180
- link2masterCB.setToolTipText("Attach to support");
11811350 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11821351 speedupCB.setToolTipText("Option motion capture");
11831352 }
....@@ -1451,6 +1620,7 @@
14511620 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14521621 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14531622 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1623
+ //XYZPanel.setName("XYZ");
14541624
14551625 /*
14561626 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1488,17 +1658,29 @@
14881658 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14891659 //tmp.setName("Edit");
14901660 objectPanel.add(materialPanel);
1661
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1662
+ objectPanel.setToolTipTextAt(0, "Material");
1663
+
1664
+ objectPanel.add(toolboxPanel);
1665
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1666
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1667
+
1668
+ objectPanel.add(skyboxPanel);
1669
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1670
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1671
+
14911672 // JPanel north = new JPanel(new BorderLayout());
14921673 // north.setName("Edit");
14931674 // north.add(ctrlPanel, BorderLayout.NORTH);
14941675 // objectPanel.add(north);
14951676 objectPanel.add(editPanel);
1677
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1678
+ objectPanel.setToolTipTextAt(3, "Edit controls");
14961679
1497
- if (Globals.ADVANCED)
1498
- objectPanel.add(infoPanel);
1680
+ objectPanel.add(XYZPanel);
1681
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1682
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
14991683
1500
- objectPanel.add(toolboxPanel);
1501
-
15021684 /*
15031685 aConstraints.gridx = 0;
15041686 aConstraints.gridwidth = 1;
....@@ -1518,7 +1700,7 @@
15181700 scrollpane.addMouseWheelListener(this); // Default not fast enough
15191701
15201702 /*JTabbedPane*/ scenePanel = new cGridBag();
1521
- scenePanel.preferredWidth = 6;
1703
+ scenePanel.preferredWidth = 5;
15221704
15231705 JTabbedPane tabbedPane = new JTabbedPane();
15241706 tabbedPane.add(scrollpane);
....@@ -1535,6 +1717,11 @@
15351717
15361718 scenePanel.add(tabbedPane);
15371719
1720
+ //if (Globals.ADVANCED)
1721
+// tabbedPane.add(infoPanel);
1722
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1723
+// tabbedPane.setToolTipTextAt(3, "Information");
1724
+
15381725 /*
15391726 cTree jTree = new cTree(null);
15401727 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1596,7 +1783,7 @@
15961783 bigThree = new cGridBag();
15971784 bigThree.addComponent(scenePanel);
15981785 bigThree.addComponent(centralPanel);
1599
- bigThree.addComponent(XYZPanel);
1786
+ //bigThree.addComponent(XYZPanel);
16001787
16011788 // // SIDE EFFECT!!!
16021789 // aConstraints.gridx = 0;
....@@ -1605,6 +1792,23 @@
16051792 // aConstraints.gridheight = 1;
16061793
16071794 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1795
+
1796
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1797
+ new java.beans.PropertyChangeListener()
1798
+ {
1799
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1800
+ {
1801
+ if ((Integer)pce.getOldValue() == 1)
1802
+ {
1803
+ if (radio.layout != expandedLayout)
1804
+ {
1805
+ radio.layout = expandedLayout;
1806
+ radio.layout.doClick();
1807
+ }
1808
+ }
1809
+ }
1810
+ });
1811
+
16081812 framePanel.setContinuousLayout(false);
16091813 framePanel.setOneTouchExpandable(false);
16101814 //.setDividerLocation(0.8);
....@@ -1614,7 +1818,7 @@
16141818
16151819 frame.getContentPane().setLayout(new BorderLayout());
16161820 /**/
1617
- JTabbedPane worldPane = new JTabbedPane();
1821
+ //JTabbedPane worldPane = new JTabbedPane();
16181822 //worldPane.add(bigPanel);
16191823 //worldPane.add(worldPanel);
16201824 /**/
....@@ -1637,7 +1841,6 @@
16371841 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16381842 frame.addWindowListener(new WindowAdapter()
16391843 {
1640
-
16411844 public void windowClosing(WindowEvent e)
16421845 {
16431846 Close();
....@@ -1660,12 +1863,418 @@
16601863 ctrlPanel.removeAll();
16611864 }
16621865
1663
- void SetupMaterial(cGridBag panel)
1866
+ void SetupMaterial(cGridBag materialpanel)
16641867 {
1665
- /*
1868
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1869
+
1870
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1871
+ skin.setToolTipText("Skin");
1872
+ skin.addMouseListener(new MouseAdapter()
1873
+ {
1874
+ public void mouseClicked(MouseEvent e)
1875
+ {
1876
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1877
+ cMaterial material = object.material;
1878
+
1879
+ // Skin
1880
+ colorField.setFloat(material.color);
1881
+ saturationField.setFloat(material.modulation);
1882
+ subsurfaceField.setFloat(material.subsurface);
1883
+ selfshadowField.setFloat(material.diffuseness);
1884
+ diffusenessField.setFloat(material.factor);
1885
+ shininessField.setFloat(material.shininess);
1886
+ shadowbiasField.setFloat(material.shadowbias);
1887
+ diffuseField.setFloat(material.diffuse);
1888
+ specularField.setFloat(material.specular);
1889
+
1890
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1891
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1892
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1893
+
1894
+ materialtouched = true;
1895
+ applySelf();
1896
+ }
1897
+ });
1898
+ presetpanel.add(skin);
1899
+
1900
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1901
+ lambert.setToolTipText("Diffuse");
1902
+ lambert.addMouseListener(new MouseAdapter()
1903
+ {
1904
+ public void mouseClicked(MouseEvent e)
1905
+ {
1906
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1907
+ cMaterial material = object.material;
1908
+
1909
+ diffusenessField.setFloat(material.factor);
1910
+ selfshadowField.setFloat(material.diffuseness);
1911
+
1912
+ materialtouched = true;
1913
+ applySelf();
1914
+ }
1915
+ });
1916
+ presetpanel.add(lambert);
1917
+
1918
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1919
+ diffuse2.setToolTipText("Diffuse2");
1920
+ diffuse2.addMouseListener(new MouseAdapter()
1921
+ {
1922
+ public void mouseClicked(MouseEvent e)
1923
+ {
1924
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1925
+ cMaterial material = object.material;
1926
+
1927
+ diffusenessField.setFloat(material.factor);
1928
+ selfshadowField.setFloat(material.diffuseness);
1929
+
1930
+ materialtouched = true;
1931
+ applySelf();
1932
+ }
1933
+ });
1934
+ presetpanel.add(diffuse2);
1935
+
1936
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1937
+ diffusemoon.setToolTipText("Moon");
1938
+ diffusemoon.addMouseListener(new MouseAdapter()
1939
+ {
1940
+ public void mouseClicked(MouseEvent e)
1941
+ {
1942
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1943
+ cMaterial material = object.material;
1944
+
1945
+ diffusenessField.setFloat(material.factor);
1946
+ selfshadowField.setFloat(material.diffuseness);
1947
+
1948
+ materialtouched = true;
1949
+ applySelf();
1950
+ }
1951
+ });
1952
+ presetpanel.add(diffusemoon);
1953
+
1954
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1955
+ diffusemoon2.setToolTipText("Moon2");
1956
+ diffusemoon2.addMouseListener(new MouseAdapter()
1957
+ {
1958
+ public void mouseClicked(MouseEvent e)
1959
+ {
1960
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1961
+ cMaterial material = object.material;
1962
+
1963
+ diffusenessField.setFloat(material.factor);
1964
+ selfshadowField.setFloat(material.diffuseness);
1965
+
1966
+ materialtouched = true;
1967
+ applySelf();
1968
+ }
1969
+ });
1970
+ presetpanel.add(diffusemoon2);
1971
+
1972
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1973
+ diffusemoon3.setToolTipText("Moon3");
1974
+ diffusemoon3.addMouseListener(new MouseAdapter()
1975
+ {
1976
+ public void mouseClicked(MouseEvent e)
1977
+ {
1978
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1979
+ cMaterial material = object.material;
1980
+
1981
+ diffusenessField.setFloat(material.factor);
1982
+ selfshadowField.setFloat(material.diffuseness);
1983
+
1984
+ materialtouched = true;
1985
+ applySelf();
1986
+ }
1987
+ });
1988
+ presetpanel.add(diffusemoon3);
1989
+
1990
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1991
+ diffusesheen.setToolTipText("Sheen");
1992
+ diffusesheen.addMouseListener(new MouseAdapter()
1993
+ {
1994
+ public void mouseClicked(MouseEvent e)
1995
+ {
1996
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1997
+ cMaterial material = object.material;
1998
+
1999
+ sheenField.setFloat(material.sheen);
2000
+
2001
+ materialtouched = true;
2002
+ applySelf();
2003
+ }
2004
+ });
2005
+ presetpanel.add(diffusesheen);
2006
+
2007
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
2008
+ rough.setToolTipText("Rough metal");
2009
+ rough.addMouseListener(new MouseAdapter()
2010
+ {
2011
+ public void mouseClicked(MouseEvent e)
2012
+ {
2013
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
2014
+ cMaterial material = object.material;
2015
+
2016
+ shininessField.setFloat(material.shininess);
2017
+ velvetField.setFloat(material.velvet);
2018
+
2019
+ materialtouched = true;
2020
+ applySelf();
2021
+ }
2022
+ });
2023
+ presetpanel.add(rough);
2024
+
2025
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
2026
+ rough2.setToolTipText("Medium metal");
2027
+ rough2.addMouseListener(new MouseAdapter()
2028
+ {
2029
+ public void mouseClicked(MouseEvent e)
2030
+ {
2031
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
2032
+ cMaterial material = object.material;
2033
+
2034
+ shininessField.setFloat(material.shininess);
2035
+ lightareaField.setFloat(material.lightarea);
2036
+
2037
+ materialtouched = true;
2038
+ applySelf();
2039
+ }
2040
+ });
2041
+ presetpanel.add(rough2);
2042
+
2043
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
2044
+ shini0.setToolTipText("Shiny");
2045
+ shini0.addMouseListener(new MouseAdapter()
2046
+ {
2047
+ public void mouseClicked(MouseEvent e)
2048
+ {
2049
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
2050
+ cMaterial material = object.material;
2051
+
2052
+ shininessField.setFloat(material.shininess);
2053
+ lightareaField.setFloat(material.lightarea);
2054
+
2055
+ materialtouched = true;
2056
+ applySelf();
2057
+ }
2058
+ });
2059
+ presetpanel.add(shini0);
2060
+
2061
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
2062
+ shini1.setToolTipText("Shiny2");
2063
+ shini1.addMouseListener(new MouseAdapter()
2064
+ {
2065
+ public void mouseClicked(MouseEvent e)
2066
+ {
2067
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
2068
+ cMaterial material = object.material;
2069
+
2070
+ shininessField.setFloat(material.shininess);
2071
+ lightareaField.setFloat(material.lightarea);
2072
+
2073
+ materialtouched = true;
2074
+ applySelf();
2075
+ }
2076
+ });
2077
+ presetpanel.add(shini1);
2078
+
2079
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2080
+ shini2.setToolTipText("Shiny3");
2081
+ shini2.addMouseListener(new MouseAdapter()
2082
+ {
2083
+ public void mouseClicked(MouseEvent e)
2084
+ {
2085
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2086
+ cMaterial material = object.material;
2087
+
2088
+ shininessField.setFloat(material.shininess);
2089
+ lightareaField.setFloat(material.lightarea);
2090
+
2091
+ materialtouched = true;
2092
+ applySelf();
2093
+ }
2094
+ });
2095
+ presetpanel.add(shini2);
2096
+
2097
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2098
+ aniso.setToolTipText("AnisoU");
2099
+ aniso.addMouseListener(new MouseAdapter()
2100
+ {
2101
+ public void mouseClicked(MouseEvent e)
2102
+ {
2103
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2104
+ cMaterial material = object.material;
2105
+
2106
+ anisoField.setFloat(material.aniso);
2107
+ anisoVField.setFloat(material.anisoV);
2108
+
2109
+ materialtouched = true;
2110
+ applySelf();
2111
+ }
2112
+ });
2113
+ presetpanel.add(aniso);
2114
+
2115
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2116
+ aniso2.setToolTipText("AnisoV");
2117
+ aniso2.addMouseListener(new MouseAdapter()
2118
+ {
2119
+ public void mouseClicked(MouseEvent e)
2120
+ {
2121
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2122
+ cMaterial material = object.material;
2123
+
2124
+ anisoField.setFloat(material.aniso);
2125
+ anisoVField.setFloat(material.anisoV);
2126
+
2127
+ materialtouched = true;
2128
+ applySelf();
2129
+ }
2130
+ });
2131
+ presetpanel.add(aniso2);
2132
+
2133
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2134
+ aniso3.setToolTipText("AnisoUV");
2135
+ aniso3.addMouseListener(new MouseAdapter()
2136
+ {
2137
+ public void mouseClicked(MouseEvent e)
2138
+ {
2139
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2140
+ cMaterial material = object.material;
2141
+
2142
+ anisoField.setFloat(material.aniso);
2143
+ anisoVField.setFloat(material.anisoV);
2144
+
2145
+ materialtouched = true;
2146
+ applySelf();
2147
+ }
2148
+ });
2149
+ presetpanel.add(aniso3);
2150
+
2151
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2152
+ velvet0.setToolTipText("Velvet");
2153
+ velvet0.addMouseListener(new MouseAdapter()
2154
+ {
2155
+ public void mouseClicked(MouseEvent e)
2156
+ {
2157
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2158
+ cMaterial material = object.material;
2159
+
2160
+ diffusenessField.setFloat(material.factor);
2161
+ selfshadowField.setFloat(material.diffuseness);
2162
+ sheenField.setFloat(material.sheen);
2163
+ shininessField.setFloat(material.shininess);
2164
+ velvetField.setFloat(material.velvet);
2165
+ shiftField.setFloat(material.shift);
2166
+
2167
+ materialtouched = true;
2168
+ applySelf();
2169
+ }
2170
+ });
2171
+ presetpanel.add(velvet0);
2172
+
2173
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2174
+ bump0.setToolTipText("Bump texture");
2175
+ bump0.addMouseListener(new MouseAdapter()
2176
+ {
2177
+ public void mouseClicked(MouseEvent e)
2178
+ {
2179
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2180
+ cMaterial material = object.material;
2181
+
2182
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2183
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2184
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2185
+
2186
+ materialtouched = true;
2187
+ applySelf();
2188
+ }
2189
+ });
2190
+ presetpanel.add(bump0);
2191
+
2192
+ cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
2193
+ borderShader.setToolTipText("Border fade");
2194
+ borderShader.addMouseListener(new MouseAdapter()
2195
+ {
2196
+ public void mouseClicked(MouseEvent e)
2197
+ {
2198
+ borderfadeField.setFloat(0.5);
2199
+ opacityField.setFloat(0.6);
2200
+
2201
+ materialtouched = true;
2202
+ applySelf();
2203
+ }
2204
+ });
2205
+ presetpanel.add(borderShader);
2206
+
2207
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2208
+ halo.setToolTipText("Halo");
2209
+ halo.addMouseListener(new MouseAdapter()
2210
+ {
2211
+ public void mouseClicked(MouseEvent e)
2212
+ {
2213
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2214
+ cMaterial material = object.material;
2215
+
2216
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2217
+
2218
+ materialtouched = true;
2219
+ applySelf();
2220
+ }
2221
+ });
2222
+ presetpanel.add(halo);
2223
+
2224
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2225
+ candle.setToolTipText("Candle");
2226
+ candle.addMouseListener(new MouseAdapter()
2227
+ {
2228
+ public void mouseClicked(MouseEvent e)
2229
+ {
2230
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2231
+ cMaterial material = object.material;
2232
+
2233
+ subsurfaceField.setFloat(material.subsurface);
2234
+ shadowbiasField.setFloat(material.shadowbias);
2235
+ ambientField.setFloat(material.ambient);
2236
+ specularField.setFloat(material.specular);
2237
+ lightareaField.setFloat(material.lightarea);
2238
+ shininessField.setFloat(material.shininess);
2239
+
2240
+ materialtouched = true;
2241
+ applySelf();
2242
+ }
2243
+ });
2244
+ presetpanel.add(candle);
2245
+
2246
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2247
+ shadowShader.setToolTipText("Shadow");
2248
+ shadowShader.addMouseListener(new MouseAdapter()
2249
+ {
2250
+ public void mouseClicked(MouseEvent e)
2251
+ {
2252
+ diffuseField.setFloat(0.001);
2253
+ ambientField.setFloat(0.001);
2254
+ cameraField.setFloat(0.001);
2255
+ specularField.setFloat(0.001);
2256
+ fakedepthField.setFloat(0.001);
2257
+ opacityField.setFloat(0.6);
2258
+
2259
+ materialtouched = true;
2260
+ applySelf();
2261
+ }
2262
+ });
2263
+ presetpanel.add(shadowShader);
2264
+
2265
+ cGridBag panel = new cGridBag().setVertical(true);
2266
+
2267
+ presetpanel.preferredWidth = 1;
2268
+
2269
+ materialpanel.add(presetpanel);
2270
+ materialpanel.add(panel);
2271
+
2272
+ panel.preferredWidth = 8;
2273
+
2274
+ /*
16662275 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16672276 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1668
- */
2277
+ */
16692278
16702279 cGridBag editBar = new cGridBag().setVertical(false);
16712280
....@@ -1699,27 +2308,50 @@
16992308 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17002309
17012310 cGridBag colorSection = new cGridBag().setVertical(true);
2311
+
2312
+ cGridBag huepanel = new cGridBag();
2313
+ cGridBag huelabel = new cGridBag();
2314
+ skin = GetLabel("icons/hue.png", false);
2315
+ skin.fit = true;
2316
+ huelabel.add(skin);
2317
+ huelabel.preferredWidth = 20;
2318
+ huepanel.add(new cGridBag()); // Label
2319
+ huepanel.add(huelabel); // Field/slider
2320
+
2321
+ huepanel.preferredHeight = 7;
2322
+
2323
+ colorSection.add(huepanel);
17022324
17032325 cGridBag color = new cGridBag();
1704
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1705
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1706
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2326
+
2327
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2328
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2329
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2330
+
17072331 //colorField.preferredWidth = 200;
17082332 colorSection.add(color);
17092333
17102334 cGridBag modulation = new cGridBag();
17112335 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17122336 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1713
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2337
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17142338 colorSection.add(modulation);
17152339
2340
+ cGridBag opacity = new cGridBag();
2341
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2342
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2343
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2344
+ colorSection.add(opacity);
2345
+
2346
+ colorSection.add(GetSeparator());
2347
+
17162348 cGridBag texture = new cGridBag();
17172349 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17182350 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17192351 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17202352 colorSection.add(texture);
17212353
1722
- panel.add(new JSeparator());
2354
+ panel.add(GetSeparator());
17232355
17242356 panel.add(colorSection);
17252357
....@@ -1775,7 +2407,7 @@
17752407 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17762408 diffuseSection.add(shadowbias);
17772409
1778
- panel.add(new JSeparator());
2410
+ panel.add(GetSeparator());
17792411
17802412 panel.add(diffuseSection);
17812413
....@@ -1838,7 +2470,7 @@
18382470 specularSection.add(anisoV);
18392471
18402472
1841
- panel.add(new JSeparator());
2473
+ panel.add(GetSeparator());
18422474
18432475 panel.add(specularSection);
18442476
....@@ -1863,12 +2495,6 @@
18632495 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18642496 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18652497 colorSection.add(backlit);
1866
-
1867
- cGridBag opacity = new cGridBag();
1868
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1869
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1871
- colorSection.add(opacity);
18722498
18732499 //panel.add(new JSeparator());
18742500
....@@ -1914,7 +2540,7 @@
19142540 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19152541 textureSection.add(opacityPower);
19162542
1917
- panel.add(new JSeparator());
2543
+ panel.add(GetSeparator());
19182544
19192545 panel.add(textureSection);
19202546
....@@ -1979,8 +2605,9 @@
19792605 // 3D models
19802606 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19812607 {
1982
- lastConverter = new com.jmex.model.converters.MaxToJme();
1983
- LoadFile(filename, lastConverter);
2608
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2609
+ //LoadFile(filename, lastConverter);
2610
+ LoadObjFile(filename); // New 3ds loader
19842611 continue;
19852612 }
19862613 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2706,6 +3333,7 @@
27063333 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
27073334 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
27083335 }
3336
+
27093337 //cJME.count++;
27103338 //cJME.count %= 12;
27113339 if (gc)
....@@ -2889,6 +3517,7 @@
28893517 }
28903518 }
28913519 }
3520
+
28923521 cFileSystemPane FSPane;
28933522
28943523 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2898,7 +3527,7 @@
28983527
28993528 freezematerial = true;
29003529 colorField.setFloat(mat.color);
2901
- modulationField.setFloat(mat.modulation);
3530
+ saturationField.setFloat(mat.modulation);
29023531 metalnessField.setFloat(mat.metalness);
29033532 diffuseField.setFloat(mat.diffuse);
29043533 specularField.setFloat(mat.specular);
....@@ -2942,6 +3571,7 @@
29423571 }
29433572 }
29443573 }
3574
+
29453575 freezematerial = false;
29463576 }
29473577
....@@ -2959,32 +3589,8 @@
29593589
29603590 if (multiplyToggle != null)
29613591 multiplyToggle.setSelected(mat.multiply);
2962
-
2963
- assert (object.projectedVertices != null);
2964
-
2965
- if (object.projectedVertices.length <= 2)
2966
- {
2967
- // Side effect...
2968
- Object3D.cVector2[] keep = object.projectedVertices;
2969
- object.projectedVertices = new Object3D.cVector2[3];
2970
- for (int i = 0; i < 3; i++)
2971
- {
2972
- if (i < keep.length)
2973
- {
2974
- object.projectedVertices[i] = keep[i];
2975
- } else
2976
- {
2977
- object.projectedVertices[i] = new Object3D.cVector2();
2978
- }
2979
- /*
2980
- if(keep.length == 0)
2981
- object.projectedVertices[0] = new Object3D.cVector2();
2982
- else
2983
- object.projectedVertices[0] = keep[0];
2984
- object.projectedVertices[1] = new Object3D.cVector2();
2985
- */
2986
- }
2987
- }
3592
+
3593
+ AllocProjectedVertices(object);
29883594
29893595 SetMaterial(mat, object.projectedVertices);
29903596 }
....@@ -3104,6 +3710,17 @@
31043710 public void itemStateChanged(ItemEvent event)
31053711 {
31063712 // System.out.println("Propagate = " + propagate);
3713
+ if (event.getSource() == pinButton)
3714
+ {
3715
+ copy.pinned ^= true;
3716
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3717
+ {
3718
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3719
+ copy.CloseUI();
3720
+ //copy.editWindow.refreshContents();
3721
+ }
3722
+ }
3723
+ else
31073724 if (event.getSource() == propagateToggle)
31083725 {
31093726 propagate ^= true;
....@@ -3201,10 +3818,6 @@
32013818 {
32023819 ToggleAnimation();
32033820 return;
3204
- } else if (event.getSource() == archiveItem)
3205
- {
3206
- cTools.Archive(frame);
3207
- return;
32083821 } else if (event.getSource() == flipVCB)
32093822 {
32103823 copy.flipV ^= true;
....@@ -3212,8 +3825,9 @@
32123825 } else if (event.getSource() == liveCB)
32133826 {
32143827 copy.live ^= true;
3828
+ objEditor.refreshContents(true); // To show item colors
32153829 return;
3216
- } else if (event.getSource() == selectCB)
3830
+ } else if (event.getSource() == selectableCB)
32173831 {
32183832 copy.dontselect ^= true;
32193833 return;
....@@ -3221,7 +3835,7 @@
32213835 {
32223836 copy.hide ^= true;
32233837 copy.Touch(); // display list issue
3224
- objEditor.refreshContents();
3838
+ objEditor.refreshContents(true); // To show item colors
32253839 return;
32263840 } else if (event.getSource() == link2masterCB)
32273841 {
....@@ -3425,6 +4039,10 @@
34254039 {
34264040 generatePOV();
34274041 //return true;
4042
+ } else if (event.getSource() == archiveItem)
4043
+ {
4044
+ cTools.Archive(frame);
4045
+ return;
34284046 } else if (source == zBufferItem)
34294047 {
34304048 try
....@@ -3473,11 +4091,12 @@
34734091
34744092 static public byte[] Compress(Object3D o)
34754093 {
4094
+ // Slower to actually compress.
34764095 try
34774096 {
34784097 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3479
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3480
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4098
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4099
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34814100
34824101 Object3D parent = o.parent;
34834102 o.parent = null;
....@@ -3488,10 +4107,14 @@
34884107
34894108 out.flush();
34904109
3491
- zstream.close();
4110
+ baos //zstream
4111
+ .close();
34924112 out.close();
34934113
3494
- return baos.toByteArray();
4114
+ byte[] bytes = baos.toByteArray();
4115
+
4116
+ System.out.println("save #bytes = " + bytes.length);
4117
+ return bytes;
34954118 } catch (Exception e)
34964119 {
34974120 System.err.println(e);
....@@ -3501,13 +4124,16 @@
35014124
35024125 static public Object Uncompress(byte[] bytes)
35034126 {
3504
- System.out.println("#bytes = " + bytes.length);
4127
+ System.out.println("restore #bytes = " + bytes.length);
35054128 try
35064129 {
35074130 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3508
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3509
- ObjectInputStream in = new ObjectInputStream(istream);
4131
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4132
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
35104133 Object obj = in.readObject();
4134
+
4135
+ bais //istream
4136
+ .close();
35114137 in.close();
35124138
35134139 return obj;
....@@ -3562,43 +4188,95 @@
35624188 return null;
35634189 }
35644190
3565
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35664191
35674192 public void Save()
35684193 {
4194
+ //Save(true);
4195
+ Replace();
4196
+ SetVersionStates();
4197
+ }
4198
+
4199
+ private boolean Equal(byte[] compress, byte[] name)
4200
+ {
4201
+ if (compress.length != name.length)
4202
+ {
4203
+ return false;
4204
+ }
4205
+
4206
+ for (int i=compress.length; --i>=0;)
4207
+ {
4208
+ if (compress[i] != name[i])
4209
+ return false;
4210
+ }
4211
+
4212
+ return true;
4213
+ }
4214
+
4215
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4216
+
4217
+ void DeleteVersion()
4218
+ {
4219
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4220
+ {
4221
+ copy.versionlist[i] = copy.versionlist[i+1];
4222
+ }
4223
+
4224
+ CopyChanged();
4225
+
4226
+ SetVersionStates();
4227
+ }
4228
+
4229
+ public boolean Save(boolean user)
4230
+ {
35694231 System.err.println("Save");
4232
+ Replace();
35704233
3571
- cRadio tab = GetCurrentTab();
4234
+ //cRadio tab = GetCurrentTab();
35724235
3573
- boolean temp = CameraPane.SWITCH;
3574
- CameraPane.SWITCH = false;
4236
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
35754237
3576
- copy.ExtractBigData(hashtable);
4238
+ boolean thesame = false;
35774239
3578
- byte[] compress = Compress(copy);
4240
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4241
+// {
4242
+// thesame = true;
4243
+// }
35794244
35804245 //EditorFrame.m_MainFrame.requestFocusInWindow();
3581
- tab.graphs[tab.undoindex++] = compress;
3582
-
3583
- copy.RestoreBigData(hashtable);
3584
-
3585
- CameraPane.SWITCH = temp;
3586
-
3587
- //assert(hashtable.isEmpty());
3588
-
3589
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4246
+ if (!thesame)
35904247 {
3591
- tab.graphs[i] = null;
4248
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4249
+ {
4250
+ copy.versionlist[i] = copy.versionlist[i-1];
4251
+ }
4252
+
4253
+ //tab.user[tab.versionindex] = user;
4254
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4255
+
4256
+ copy.versionlist[++copy.versionindex] = compress;
4257
+
4258
+ // if (increment)
4259
+ // tab.versionindex++;
35924260 }
35934261
3594
- SetUndoStates();
4262
+ //copy.RestoreBigData(versiontable);
4263
+
4264
+ //assert(hashtable.isEmpty());
4265
+
4266
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4267
+// {
4268
+// //tab.user[i] = false;
4269
+// copy.versionlist[i] = null;
4270
+// }
4271
+
4272
+ SetVersionStates();
35954273
35964274 // test save
35974275 if (false)
35984276 {
35994277 try
36004278 {
3601
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4279
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
36024280 ObjectOutputStream p = new ObjectOutputStream(ostream);
36034281
36044282 p.writeObject(copy);
....@@ -3611,28 +4289,68 @@
36114289 e.printStackTrace();
36124290 }
36134291 }
4292
+
4293
+ return !thesame;
4294
+ }
4295
+
4296
+ boolean flashIt = true;
4297
+
4298
+ void RefreshSelection()
4299
+ {
4300
+ Object3D selection = new Object3D();
4301
+
4302
+ for (int i = 0; i < copy.selection.size(); i++)
4303
+ {
4304
+ Object3D elem = copy.selection.elementAt(i);
4305
+
4306
+ Object3D obj = copy.GetObject(elem.GetUUID());
4307
+
4308
+ if (obj == null)
4309
+ {
4310
+ copy.selection.remove(i--);
4311
+ }
4312
+ else
4313
+ {
4314
+ selection.add(obj);
4315
+ copy.selection.setElementAt(obj, i);
4316
+ }
4317
+ }
4318
+
4319
+ flashIt = false;
4320
+ GetTree().clearSelection();
4321
+ for (int i = 0; i < selection.size(); i++)
4322
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4323
+ flashIt = true;
4324
+
4325
+ //refreshContents(false);
36144326 }
36154327
3616
- void CopyChanged(Object3D obj)
4328
+ void CopyChanged()
36174329 {
3618
- SetUndoStates();
4330
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4331
+
4332
+ SetVersionStates();
36194333
36204334 boolean temp = CameraPane.SWITCH;
36214335 CameraPane.SWITCH = false;
36224336
3623
- copy.ExtractBigData(hashtable);
4337
+ copy.ExtractBigData(versiontable);
36244338
36254339 copy.clear();
36264340
4341
+ copy.skyboxname = obj.skyboxname;
4342
+ copy.skyboxext = obj.skyboxext;
4343
+
36274344 for (int i=0; i<obj.Size(); i++)
36284345 {
36294346 copy.add(obj.get(i));
36304347 }
36314348
3632
- copy.RestoreBigData(hashtable);
4349
+ copy.RestoreBigData(versiontable);
36334350
36344351 CameraPane.SWITCH = temp;
36354352
4353
+ RefreshSelection();
36364354 //assert(hashtable.isEmpty());
36374355
36384356 copy.Touch();
....@@ -3653,56 +4371,144 @@
36534371 }
36544372 }
36554373
3656
- refreshContents();
4374
+ refreshContents(true);
36574375 }
36584376
3659
- cButton undoButton;
3660
- cButton redoButton;
4377
+ cButton previousVersionButton;
4378
+ cButton restoreButton;
4379
+ cButton replaceButton;
4380
+ cButton nextVersionButton;
4381
+ cButton saveVersionButton;
4382
+ cButton deleteVersionButton;
36614383
3662
- void SetUndoStates()
4384
+ boolean muteSlider;
4385
+
4386
+ int VersionCount()
36634387 {
3664
- cRadio tab = GetCurrentTab();
4388
+ int count = 0;
36654389
3666
- undoButton.setEnabled(tab.undoindex > 0);
3667
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
4390
+ for (int i = copy.versionlist.length; --i >= 0;)
4391
+ {
4392
+ if (copy.versionlist[i] != null)
4393
+ count++;
4394
+ }
4395
+
4396
+ return count;
36684397 }
36694398
3670
- public void Undo()
4399
+ void SetVersionStates()
36714400 {
4401
+ //if (true)
4402
+ // return;
4403
+
4404
+ //cRadio tab = GetCurrentTab();
4405
+
4406
+ restoreButton.setEnabled(copy.versionindex != -1);
4407
+ replaceButton.setEnabled(copy.versionindex != -1);
4408
+
4409
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4410
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4411
+
4412
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4413
+ copy.versionlist[copy.versionindex + 1] != null);
4414
+
4415
+ muteSlider = true;
4416
+ versionSlider.setMinimum(0);
4417
+ versionSlider.setMaximum(VersionCount() - 1);
4418
+ versionSlider.setInteger(copy.versionindex);
4419
+ versionSlider.setEnabled(copy.versionindex != -1);
4420
+ muteSlider = false;
4421
+ }
4422
+
4423
+ public boolean PreviousVersion()
4424
+ {
4425
+ // Option?
4426
+ Replace();
4427
+
36724428 System.err.println("Undo");
36734429
3674
- cRadio tab = GetCurrentTab();
4430
+ //cRadio tab = GetCurrentTab();
36754431
3676
- if (tab.undoindex == 0)
4432
+ if (copy.versionindex == 0)
36774433 {
36784434 java.awt.Toolkit.getDefaultToolkit().beep();
3679
- return;
4435
+ return false;
36804436 }
36814437
3682
- if (tab.graphs[tab.undoindex] == null)
3683
- {
3684
- Save();
3685
- tab.undoindex -= 1;
3686
- }
4438
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4439
+// {
4440
+// if (Save(false))
4441
+// tab.versionindex -= 1;
4442
+// else
4443
+// {
4444
+// if (tab.versionindex <= 0)
4445
+// return false;
4446
+// else
4447
+// tab.versionindex -= 1;
4448
+// }
4449
+// }
36874450
3688
- tab.undoindex -= 1;
4451
+ copy.versionindex -= 1;
36894452
3690
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4453
+ CopyChanged();
4454
+
4455
+ return true;
36914456 }
36924457
3693
- public void Redo()
4458
+ public boolean Restore()
36944459 {
3695
- cRadio tab = GetCurrentTab();
4460
+ System.err.println("Restore");
36964461
3697
- if (tab.graphs[tab.undoindex + 1] == null)
4462
+ //cRadio tab = GetCurrentTab();
4463
+
4464
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4465
+ {
4466
+ java.awt.Toolkit.getDefaultToolkit().beep();
4467
+ return false;
4468
+ }
4469
+
4470
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4471
+ CopyChanged();
4472
+
4473
+ return true;
4474
+ }
4475
+
4476
+ public boolean Replace()
4477
+ {
4478
+ System.err.println("Replace");
4479
+
4480
+ //cRadio tab = GetCurrentTab();
4481
+
4482
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4483
+ {
4484
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4485
+ return false;
4486
+ }
4487
+
4488
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4489
+
4490
+ return true;
4491
+ }
4492
+
4493
+ public void NextVersion()
4494
+ {
4495
+ // Option?
4496
+ Replace();
4497
+
4498
+ //cRadio tab = GetCurrentTab();
4499
+
4500
+ if (copy.versionlist[copy.versionindex + 1] == null)
36984501 {
36994502 java.awt.Toolkit.getDefaultToolkit().beep();
37004503 return;
37014504 }
37024505
3703
- tab.undoindex += 1;
4506
+ copy.versionindex += 1;
37044507
3705
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4508
+ CopyChanged();
4509
+
4510
+ //if (!tab.user[tab.versionindex])
4511
+ // tab.graphs[tab.versionindex] = null;
37064512 }
37074513
37084514 void ImportGFD()
....@@ -3913,7 +4719,7 @@
39134719 //copy.material = new cMaterial(copy.GetMaterial());
39144720
39154721 current.color = (float) colorField.getFloat();
3916
- current.modulation = (float) modulationField.getFloat();
4722
+ current.modulation = (float) saturationField.getFloat();
39174723 current.metalness = (float) metalnessField.getFloat();
39184724 current.diffuse = (float) diffuseField.getFloat();
39194725 current.specular = (float) specularField.getFloat();
....@@ -3946,7 +4752,7 @@
39464752 cMaterial mat = copy.material;
39474753
39484754 colorField.SetToolTipValue((mat.color));
3949
- modulationField.SetToolTipValue((mat.modulation));
4755
+ saturationField.SetToolTipValue((mat.modulation));
39504756 metalnessField.SetToolTipValue((mat.metalness));
39514757 diffuseField.SetToolTipValue((mat.diffuse));
39524758 specularField.SetToolTipValue((mat.specular));
....@@ -3998,9 +4804,28 @@
39984804 //copy.Touch();
39994805 }
40004806
4807
+ cNumberSlider versionSlider;
4808
+
40014809 public void stateChanged(ChangeEvent e)
40024810 {
40034811 // assert(false);
4812
+ if (e.getSource() == versionSlider)
4813
+ {
4814
+ if (muteSlider)
4815
+ return;
4816
+
4817
+ Replace();
4818
+
4819
+ int version = versionSlider.getInteger();
4820
+
4821
+ if (version != -1 && copy.versionlist[version] != null)
4822
+ {
4823
+ copy.versionindex = version;
4824
+ CopyChanged();
4825
+ }
4826
+
4827
+ return;
4828
+ }
40044829
40054830 if (freezematerial)
40064831 {
....@@ -4036,6 +4861,12 @@
40364861 {
40374862 //System.out.println("stateChanged = " + this);
40384863 materialtouched = true;
4864
+
4865
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4866
+ {
4867
+ saturationField.setFloat(1);
4868
+ }
4869
+
40394870 applySelf();
40404871 //System.out.println("this = " + this);
40414872 //System.out.println("PARENT = " + parent);
....@@ -4335,6 +5166,7 @@
43355166 {
43365167 if (GetTree() != null)
43375168 {
5169
+ GetTree().revalidate();
43385170 GetTree().repaint();
43395171 }
43405172
....@@ -4343,13 +5175,16 @@
43435175 ctrlPanel.validate(); // ? new
43445176 ctrlPanel.repaint();
43455177 }
5178
+
5179
+ if (previousVersionButton != null && copy.versionlist != null)
5180
+ SetVersionStates();
43465181 }
43475182
43485183 static TweenManager tweenManager = new TweenManager();
43495184
43505185 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43515186 {
4352
- if (Globals.SAVEONMAKE) // && resetmodel)
5187
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43535188 Save();
43545189 //Tween.set(thing, 0).target(1).start(tweenManager);
43555190 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4591,7 +5426,9 @@
45915426 readobj.ResetDisplayList();
45925427 } catch (Exception e)
45935428 {
4594
- //e.printStackTrace();
5429
+ if (!e.toString().contains("GZIP"))
5430
+ e.printStackTrace();
5431
+
45955432 try
45965433 {
45975434 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4665,12 +5502,14 @@
46655502
46665503 if (readobj != null)
46675504 {
4668
- if (Globals.SAVEONMAKE)
4669
- Save();
5505
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5506
+ // Save();
46705507 try
46715508 {
46725509 //readobj.deepCopySelf(copy);
46735510 copy.clear(); // june 2014
5511
+ copy.skyboxname = readobj.skyboxname;
5512
+ copy.skyboxext = readobj.skyboxext;
46745513 for (int i = 0; i < readobj.size(); i++)
46755514 {
46765515 Object3D child = readobj.get(i); // reserve(i);
....@@ -4711,6 +5550,7 @@
47115550 }
47125551 } catch (ClassCastException e)
47135552 {
5553
+ e.printStackTrace();
47145554 assert (false);
47155555 Composite c = (Composite) copy;
47165556 c.children.clear();
....@@ -4721,6 +5561,20 @@
47215561 c.addChild(csg);
47225562 }
47235563
5564
+ copy.versionlist = readobj.versionlist;
5565
+ copy.versionindex = readobj.versionindex;
5566
+
5567
+ if (copy.versionlist == null)
5568
+ {
5569
+ // Backward compatibility
5570
+ copy.versionlist = new Object3D[100];
5571
+ copy.versionindex = -1;
5572
+
5573
+ //Save(true);
5574
+ }
5575
+
5576
+ //? SetUndoStates();
5577
+
47245578 ResetModel();
47255579 copy.HardTouch(); // recompile?
47265580 refreshContents();
....@@ -4731,7 +5585,7 @@
47315585 {
47325586 if (Grafreed.standAlone)
47335587 {
4734
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5588
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
47355589 browser.show();
47365590 String filename = browser.getFile();
47375591 if (filename != null && filename.length() > 0)
....@@ -4808,6 +5662,8 @@
48085662
48095663 void save()
48105664 {
5665
+ Replace();
5666
+
48115667 if (lastname == null)
48125668 {
48135669 return;
....@@ -4830,6 +5686,7 @@
48305686 //ps.print(buffer.toString());
48315687 } catch (IOException e)
48325688 {
5689
+ e.printStackTrace();
48335690 }
48345691 }
48355692
....@@ -5035,7 +5892,7 @@
50355892 CheckboxMenuItem toggleSwitchItem;
50365893 CheckboxMenuItem toggleRootItem;
50375894 CheckboxMenuItem animationItem;
5038
- CheckboxMenuItem archiveItem;
5895
+ MenuItem archiveItem;
50395896 CheckboxMenuItem toggleHandleItem;
50405897 CheckboxMenuItem togglePaintItem;
50415898 JSplitPane mainPanel;
....@@ -5049,6 +5906,7 @@
50495906 ButtonGroup buttonGroup;
50505907
50515908 cGridBag toolboxPanel;
5909
+ cGridBag skyboxPanel;
50525910 cGridBag materialPanel;
50535911 cGridBag ctrlPanel;
50545912
....@@ -5122,7 +5980,7 @@
51225980 JLabel colorLabel;
51235981 cNumberSlider colorField;
51245982 JLabel modulationLabel;
5125
- cNumberSlider modulationField;
5983
+ cNumberSlider saturationField;
51265984 JLabel metalnessLabel;
51275985 cNumberSlider metalnessField;
51285986 JLabel diffuseLabel;
....@@ -5153,6 +6011,7 @@
51536011 cNumberSlider anisoField;
51546012 JLabel anisoVLabel;
51556013 cNumberSlider anisoVField;
6014
+
51566015 JLabel cameraLabel;
51576016 cNumberSlider cameraField;
51586017 JLabel selfshadowLabel;
....@@ -5167,6 +6026,7 @@
51676026 cNumberSlider fakedepthField;
51686027 JLabel shadowbiasLabel;
51696028 cNumberSlider shadowbiasField;
6029
+
51706030 JLabel bumpLabel;
51716031 cNumberSlider bumpField;
51726032 JLabel noiseLabel;