Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
ObjEditor.java
....@@ -41,64 +41,78 @@
4141 JFrame frame;
4242
4343 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4452
4553 cButton GetButton(String name, boolean border)
4654 {
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
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5663 }
5764
5865 cToggleButton GetToggleButton(String name, boolean border)
5966 {
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
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6969 }
7070
7171 cCheckBox GetCheckBox(String name, boolean border)
7272 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7379 try
7480 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7797 }
7898 catch (Exception e)
7999 {
80
- return new cCheckBox(name, border);
100
+ return null;
81101 }
82102 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
85105 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
89107 {
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;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
98111 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
102116 }
103117
104118 // SCRIPT
....@@ -282,6 +296,12 @@
282296 client = inClient;
283297 copy = client;
284298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
285305 // "this" is not called: SetupUI2(objEditor);
286306 }
287307
....@@ -295,6 +315,12 @@
295315 client = inClient;
296316 copy = client;
297317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
298324 SetupUI2(callee.GetEditor());
299325 }
300326
....@@ -327,6 +353,12 @@
327353 copy = localCopy;
328354 copy.editWindow = this;
329355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
330362 SetupMenu();
331363
332364 //SetupName(objEditor); // new
....@@ -350,7 +382,7 @@
350382 frame.setMenuBar(menuBar = new MenuBar());
351383 menuBar.add(fileMenu = new Menu("File"));
352384 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
354386
355387 //oe.menuBar.add(menu = new Menu("Include"));
356388 Menu menu = new Menu("Import");
....@@ -382,7 +414,7 @@
382414 }
383415
384416 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
386418 saveItem.addActionListener(this);
387419 saveAsItem.addActionListener(this);
388420 exportAsItem.addActionListener(this);
....@@ -419,11 +451,12 @@
419451
420452 toolbarPanel = new JPanel();
421453 toolbarPanel.setName("Toolbar");
454
+
422455 treePanel = new cGridBag();
423456 treePanel.setName("Tree");
424457
425458 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
427460
428461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429462
....@@ -431,11 +464,11 @@
431464 editPanel.add(editCommandsPanel);
432465 editPanel.add(ctrlPanel);
433466
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
436469
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
439472
440473 /*JTextPane*/
441474 infoarea = createTextPane();
....@@ -443,14 +476,15 @@
443476
444477 infoarea.setEditable(true);
445478 SetText();
479
+
446480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447481 // infoarea.setOpaque(false);
448482 // //infoarea.setForeground(textcolor);
449483 // TEXTAREA infoarea.setLineWrap(true);
450484 // TEXTAREA infoarea.setWrapStyleWord(true);
451485 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");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
454488 //infoPanel.setLayout(new BorderLayout());
455489 //infoPanel.add(createTextPane());
456490
....@@ -780,7 +814,7 @@
780814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
781815 // X framePanel.add(bigThree);
782816 // X frame.getContentPane().add(/*"Center",*/framePanel);
783
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
784818
785819 //frame.setVisible(true);
786820 radio.layout = keepButton;
....@@ -815,6 +849,29 @@
815849 }
816850 frame.validate();
817851 }
852
+
853
+ private Object3D CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ Object3D versions[] = copy.versionlist;
862
+ copy.versionlist = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versionlist = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
818875
819876 private JTextPane createTextPane()
820877 {
....@@ -937,6 +994,7 @@
937994 {
938995 SetupMaterial(materialPanel);
939996 }
997
+
940998 //SetupName();
941999 //SetupViews();
9421000 }
....@@ -946,7 +1004,7 @@
9461004 // NumberSlider vDivsField;
9471005 // JCheckBox endcaps;
9481006 JCheckBox liveCB;
949
- JCheckBox selectCB;
1007
+ JCheckBox selectableCB;
9501008 JCheckBox hideCB;
9511009 JCheckBox link2masterCB;
9521010 JCheckBox markCB;
....@@ -1158,13 +1216,16 @@
11581216
11591217 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11601218 liveCB.setToolTipText("Animate object");
1161
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1162
- selectCB.setToolTipText("Make object selectable");
1219
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1220
+ selectableCB.setToolTipText("Make object selectable");
11631221 // Return();
1222
+
11641223 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11651224 hideCB.setToolTipText("Hide object");
11661225 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11671226 markCB.setToolTipText("As animation target transform");
1227
+
1228
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11681229
11691230 setupPanel2 = new cGridBag().setVertical(false);
11701231
....@@ -1174,10 +1235,11 @@
11741235 randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11751236 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11761237
1238
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1239
+ link2masterCB.setToolTipText("Attach to support");
1240
+
11771241 if (Globals.ADVANCED)
11781242 {
1179
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1180
- link2masterCB.setToolTipText("Attach to support");
11811243 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11821244 speedupCB.setToolTipText("Option motion capture");
11831245 }
....@@ -1451,6 +1513,7 @@
14511513 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14521514 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14531515 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1516
+ //XYZPanel.setName("XYZ");
14541517
14551518 /*
14561519 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1488,13 +1551,29 @@
14881551 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14891552 //tmp.setName("Edit");
14901553 objectPanel.add(materialPanel);
1554
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
+ objectPanel.setToolTipTextAt(0, "Material");
1556
+
14911557 // JPanel north = new JPanel(new BorderLayout());
14921558 // north.setName("Edit");
14931559 // north.add(ctrlPanel, BorderLayout.NORTH);
14941560 // objectPanel.add(north);
14951561 objectPanel.add(editPanel);
1496
- objectPanel.add(infoPanel);
1562
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1563
+ objectPanel.setToolTipTextAt(1, "Edit controls");
1564
+
1565
+ //if (Globals.ADVANCED)
1566
+ objectPanel.add(infoPanel);
1567
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1568
+ objectPanel.setToolTipTextAt(2, "Information");
1569
+
1570
+ objectPanel.add(XYZPanel);
1571
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1572
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1573
+
14971574 objectPanel.add(toolboxPanel);
1575
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1576
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
14981577
14991578 /*
15001579 aConstraints.gridx = 0;
....@@ -1515,7 +1594,7 @@
15151594 scrollpane.addMouseWheelListener(this); // Default not fast enough
15161595
15171596 /*JTabbedPane*/ scenePanel = new cGridBag();
1518
- scenePanel.preferredWidth = 6;
1597
+ scenePanel.preferredWidth = 5;
15191598
15201599 JTabbedPane tabbedPane = new JTabbedPane();
15211600 tabbedPane.add(scrollpane);
....@@ -1593,7 +1672,7 @@
15931672 bigThree = new cGridBag();
15941673 bigThree.addComponent(scenePanel);
15951674 bigThree.addComponent(centralPanel);
1596
- bigThree.addComponent(XYZPanel);
1675
+ //bigThree.addComponent(XYZPanel);
15971676
15981677 // // SIDE EFFECT!!!
15991678 // aConstraints.gridx = 0;
....@@ -1602,9 +1681,9 @@
16021681 // aConstraints.gridheight = 1;
16031682
16041683 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1605
- framePanel.setContinuousLayout(true);
1606
- framePanel.setOneTouchExpandable(true);
1607
- framePanel.setDividerLocation(0.8);
1684
+ framePanel.setContinuousLayout(false);
1685
+ framePanel.setOneTouchExpandable(false);
1686
+ //.setDividerLocation(0.8);
16081687 //framePanel.setDividerSize(15);
16091688 //framePanel.setResizeWeight(0.15);
16101689 framePanel.setName("Frame");
....@@ -1634,7 +1713,6 @@
16341713 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16351714 frame.addWindowListener(new WindowAdapter()
16361715 {
1637
-
16381716 public void windowClosing(WindowEvent e)
16391717 {
16401718 Close();
....@@ -1657,12 +1735,56 @@
16571735 ctrlPanel.removeAll();
16581736 }
16591737
1660
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
16611739 {
1662
- /*
1740
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1741
+ cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
+ label.addMouseListener(new MouseAdapter()
1743
+ {
1744
+ public void mouseClicked(MouseEvent e)
1745
+ {
1746
+ colorField.setFloat(0);
1747
+ saturationField.setFloat(1);
1748
+ materialtouched = true;
1749
+ applySelf();
1750
+ }
1751
+ });
1752
+ presetpanel.add(label);
1753
+
1754
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
1755
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1756
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1757
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1758
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1759
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1760
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1761
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1762
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1763
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1764
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1765
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1766
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1767
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1768
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1769
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1770
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1771
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));
1772
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));
1773
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));
1774
+
1775
+ cGridBag panel = new cGridBag().setVertical(true);
1776
+
1777
+ presetpanel.preferredWidth = 1;
1778
+
1779
+ materialpanel.add(panel);
1780
+ materialpanel.add(presetpanel);
1781
+
1782
+ panel.preferredWidth = 8;
1783
+
1784
+ /*
16631785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16641786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1665
- */
1787
+ */
16661788
16671789 cGridBag editBar = new cGridBag().setVertical(false);
16681790
....@@ -1696,27 +1818,50 @@
16961818 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16971819
16981820 cGridBag colorSection = new cGridBag().setVertical(true);
1821
+
1822
+ cGridBag huepanel = new cGridBag();
1823
+ cGridBag huelabel = new cGridBag();
1824
+ label = GetLabel("icons/hue.png", false);
1825
+ label.fit = true;
1826
+ huelabel.add(label);
1827
+ huelabel.preferredWidth = 20;
1828
+ huepanel.add(new cGridBag()); // Label
1829
+ huepanel.add(huelabel); // Field/slider
1830
+
1831
+ huepanel.preferredHeight = 7;
1832
+
1833
+ colorSection.add(huepanel);
16991834
17001835 cGridBag color = new cGridBag();
1701
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1702
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1703
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1836
+
1837
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1838
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1839
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1840
+
17041841 //colorField.preferredWidth = 200;
17051842 colorSection.add(color);
17061843
17071844 cGridBag modulation = new cGridBag();
17081845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
17091846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1710
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17111848 colorSection.add(modulation);
17121849
1850
+ cGridBag opacity = new cGridBag();
1851
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1852
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1853
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1854
+ colorSection.add(opacity);
1855
+
1856
+ colorSection.add(GetSeparator());
1857
+
17131858 cGridBag texture = new cGridBag();
17141859 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17151860 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17161861 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17171862 colorSection.add(texture);
17181863
1719
- panel.add(new JSeparator());
1864
+ panel.add(GetSeparator());
17201865
17211866 panel.add(colorSection);
17221867
....@@ -1772,7 +1917,7 @@
17721917 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17731918 diffuseSection.add(shadowbias);
17741919
1775
- panel.add(new JSeparator());
1920
+ panel.add(GetSeparator());
17761921
17771922 panel.add(diffuseSection);
17781923
....@@ -1835,7 +1980,7 @@
18351980 specularSection.add(anisoV);
18361981
18371982
1838
- panel.add(new JSeparator());
1983
+ panel.add(GetSeparator());
18391984
18401985 panel.add(specularSection);
18411986
....@@ -1860,12 +2005,6 @@
18602005 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18612006 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18622007 colorSection.add(backlit);
1863
-
1864
- cGridBag opacity = new cGridBag();
1865
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1866
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1867
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1868
- colorSection.add(opacity);
18692008
18702009 //panel.add(new JSeparator());
18712010
....@@ -1911,7 +2050,7 @@
19112050 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19122051 textureSection.add(opacityPower);
19132052
1914
- panel.add(new JSeparator());
2053
+ panel.add(GetSeparator());
19152054
19162055 panel.add(textureSection);
19172056
....@@ -1976,8 +2115,9 @@
19762115 // 3D models
19772116 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19782117 {
1979
- lastConverter = new com.jmex.model.converters.MaxToJme();
1980
- LoadFile(filename, lastConverter);
2118
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2119
+ //LoadFile(filename, lastConverter);
2120
+ LoadObjFile(filename); // New 3ds loader
19812121 continue;
19822122 }
19832123 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2703,6 +2843,7 @@
27032843 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
27042844 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
27052845 }
2846
+
27062847 //cJME.count++;
27072848 //cJME.count %= 12;
27082849 if (gc)
....@@ -2886,6 +3027,7 @@
28863027 }
28873028 }
28883029 }
3030
+
28893031 cFileSystemPane FSPane;
28903032
28913033 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2895,7 +3037,7 @@
28953037
28963038 freezematerial = true;
28973039 colorField.setFloat(mat.color);
2898
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
28993041 metalnessField.setFloat(mat.metalness);
29003042 diffuseField.setFloat(mat.diffuse);
29013043 specularField.setFloat(mat.specular);
....@@ -2939,6 +3081,7 @@
29393081 }
29403082 }
29413083 }
3084
+
29423085 freezematerial = false;
29433086 }
29443087
....@@ -3205,8 +3348,9 @@
32053348 } else if (event.getSource() == liveCB)
32063349 {
32073350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
32083352 return;
3209
- } else if (event.getSource() == selectCB)
3353
+ } else if (event.getSource() == selectableCB)
32103354 {
32113355 copy.dontselect ^= true;
32123356 return;
....@@ -3214,7 +3358,7 @@
32143358 {
32153359 copy.hide ^= true;
32163360 copy.Touch(); // display list issue
3217
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
32183362 return;
32193363 } else if (event.getSource() == link2masterCB)
32203364 {
....@@ -3391,9 +3535,9 @@
33913535 {
33923536 Close();
33933537 //return true;
3394
- } else if (source == loadItem)
3538
+ } else if (source == openItem)
33953539 {
3396
- load();
3540
+ Open();
33973541 //return true;
33983542 } else if (source == newItem)
33993543 {
....@@ -3418,6 +3562,10 @@
34183562 {
34193563 generatePOV();
34203564 //return true;
3565
+ } else if (event.getSource() == archiveItem)
3566
+ {
3567
+ cTools.Archive(frame);
3568
+ return;
34213569 } else if (source == zBufferItem)
34223570 {
34233571 try
....@@ -3466,11 +3614,12 @@
34663614
34673615 static public byte[] Compress(Object3D o)
34683616 {
3617
+ // Slower to actually compress.
34693618 try
34703619 {
34713620 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3472
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3473
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3621
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3622
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34743623
34753624 Object3D parent = o.parent;
34763625 o.parent = null;
....@@ -3481,10 +3630,14 @@
34813630
34823631 out.flush();
34833632
3484
- zstream.close();
3633
+ baos //zstream
3634
+ .close();
34853635 out.close();
34863636
3487
- return baos.toByteArray();
3637
+ byte[] bytes = baos.toByteArray();
3638
+
3639
+ System.out.println("save #bytes = " + bytes.length);
3640
+ return bytes;
34883641 } catch (Exception e)
34893642 {
34903643 System.err.println(e);
....@@ -3494,13 +3647,16 @@
34943647
34953648 static public Object Uncompress(byte[] bytes)
34963649 {
3497
- System.out.println("#bytes = " + bytes.length);
3650
+ System.out.println("restore #bytes = " + bytes.length);
34983651 try
34993652 {
35003653 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3501
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3502
- ObjectInputStream in = new ObjectInputStream(istream);
3654
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3655
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
35033656 Object obj = in.readObject();
3657
+
3658
+ bais //istream
3659
+ .close();
35043660 in.close();
35053661
35063662 return obj;
....@@ -3555,33 +3711,68 @@
35553711 return null;
35563712 }
35573713
3558
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35593714
35603715 public void Save()
35613716 {
3717
+ //Save(true);
3718
+ Replace();
3719
+ SetUndoStates();
3720
+ }
3721
+
3722
+ private boolean Equal(byte[] compress, byte[] name)
3723
+ {
3724
+ if (compress.length != name.length)
3725
+ {
3726
+ return false;
3727
+ }
3728
+
3729
+ for (int i=compress.length; --i>=0;)
3730
+ {
3731
+ if (compress[i] != name[i])
3732
+ return false;
3733
+ }
3734
+
3735
+ return true;
3736
+ }
3737
+
3738
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3739
+
3740
+ public boolean Save(boolean user)
3741
+ {
35623742 System.err.println("Save");
3743
+ Replace();
35633744
35643745 cRadio tab = GetCurrentTab();
35653746
3566
- boolean temp = CameraPane.SWITCH;
3567
- CameraPane.SWITCH = false;
3747
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
35683748
3569
- copy.ExtractBigData(hashtable);
3749
+ boolean thesame = false;
35703750
3571
- byte[] compress = Compress(copy);
3751
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3752
+// {
3753
+// thesame = true;
3754
+// }
35723755
35733756 //EditorFrame.m_MainFrame.requestFocusInWindow();
3574
- tab.graphs[tab.undoindex++] = compress;
3757
+ if (!thesame)
3758
+ {
3759
+ //tab.user[tab.versionindex] = user;
3760
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3761
+
3762
+ copy.versionlist[++copy.versionindex] = compress;
3763
+
3764
+ // if (increment)
3765
+ // tab.versionindex++;
3766
+ }
35753767
3576
- copy.RestoreBigData(hashtable);
3768
+ //copy.RestoreBigData(versiontable);
35773769
3578
- CameraPane.SWITCH = temp;
3579
-
35803770 //assert(hashtable.isEmpty());
35813771
3582
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3772
+ for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
35833773 {
3584
- tab.graphs[i] = null;
3774
+ //tab.user[i] = false;
3775
+ copy.versionlist[i] = null;
35853776 }
35863777
35873778 SetUndoStates();
....@@ -3591,7 +3782,7 @@
35913782 {
35923783 try
35933784 {
3594
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3785
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35953786 ObjectOutputStream p = new ObjectOutputStream(ostream);
35963787
35973788 p.writeObject(copy);
....@@ -3604,6 +3795,40 @@
36043795 e.printStackTrace();
36053796 }
36063797 }
3798
+
3799
+ return !thesame;
3800
+ }
3801
+
3802
+ boolean flashIt = true;
3803
+
3804
+ void RefreshSelection()
3805
+ {
3806
+ Object3D selection = new Object3D();
3807
+
3808
+ for (int i = 0; i < copy.selection.size(); i++)
3809
+ {
3810
+ Object3D elem = copy.selection.elementAt(i);
3811
+
3812
+ Object3D obj = copy.GetObject(elem.GetUUID());
3813
+
3814
+ if (obj == null)
3815
+ {
3816
+ copy.selection.remove(i--);
3817
+ }
3818
+ else
3819
+ {
3820
+ selection.add(obj);
3821
+ copy.selection.setElementAt(obj, i);
3822
+ }
3823
+ }
3824
+
3825
+ flashIt = false;
3826
+ GetTree().clearSelection();
3827
+ for (int i = 0; i < selection.size(); i++)
3828
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3829
+ flashIt = true;
3830
+
3831
+ refreshContents(false);
36073832 }
36083833
36093834 void CopyChanged(Object3D obj)
....@@ -3613,19 +3838,23 @@
36133838 boolean temp = CameraPane.SWITCH;
36143839 CameraPane.SWITCH = false;
36153840
3616
- copy.ExtractBigData(hashtable);
3841
+ copy.ExtractBigData(versiontable);
36173842
36183843 copy.clear();
36193844
3845
+ copy.skyboxname = obj.skyboxname;
3846
+ copy.skyboxext = obj.skyboxext;
3847
+
36203848 for (int i=0; i<obj.Size(); i++)
36213849 {
36223850 copy.add(obj.get(i));
36233851 }
36243852
3625
- copy.RestoreBigData(hashtable);
3853
+ copy.RestoreBigData(versiontable);
36263854
36273855 CameraPane.SWITCH = temp;
36283856
3857
+ RefreshSelection();
36293858 //assert(hashtable.isEmpty());
36303859
36313860 copy.Touch();
....@@ -3650,52 +3879,130 @@
36503879 }
36513880
36523881 cButton undoButton;
3882
+ cButton restoreButton;
3883
+ cButton replaceButton;
36533884 cButton redoButton;
36543885
3886
+ boolean muteSlider;
3887
+
3888
+ int VersionCount()
3889
+ {
3890
+ int count = 0;
3891
+
3892
+ for (int i = copy.versionlist.length; --i >= 0;)
3893
+ {
3894
+ if (copy.versionlist[i] != null)
3895
+ count++;
3896
+ }
3897
+
3898
+ return count;
3899
+ }
3900
+
36553901 void SetUndoStates()
36563902 {
36573903 cRadio tab = GetCurrentTab();
36583904
3659
- undoButton.setEnabled(tab.undoindex > 0);
3660
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3905
+ restoreButton.setEnabled(copy.versionindex != -1);
3906
+ replaceButton.setEnabled(copy.versionindex != -1);
3907
+
3908
+ undoButton.setEnabled(copy.versionindex > 0);
3909
+ redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3910
+
3911
+ muteSlider = true;
3912
+ versionSlider.setMaximum(VersionCount() - 1);
3913
+ versionSlider.setInteger(copy.versionindex);
3914
+ muteSlider = false;
36613915 }
36623916
3663
- public void Undo()
3917
+ public boolean Undo()
36643918 {
3919
+ // Option?
3920
+ Replace();
3921
+
36653922 System.err.println("Undo");
36663923
36673924 cRadio tab = GetCurrentTab();
36683925
3669
- if (tab.undoindex == 0)
3926
+ if (copy.versionindex == 0)
36703927 {
36713928 java.awt.Toolkit.getDefaultToolkit().beep();
3672
- return;
3929
+ return false;
36733930 }
36743931
3675
- if (tab.graphs[tab.undoindex] == null)
3932
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3933
+// {
3934
+// if (Save(false))
3935
+// tab.versionindex -= 1;
3936
+// else
3937
+// {
3938
+// if (tab.versionindex <= 0)
3939
+// return false;
3940
+// else
3941
+// tab.versionindex -= 1;
3942
+// }
3943
+// }
3944
+
3945
+ copy.versionindex -= 1;
3946
+
3947
+ CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
3948
+
3949
+ return true;
3950
+ }
3951
+
3952
+ public boolean Restore()
3953
+ {
3954
+ System.err.println("Restore");
3955
+
3956
+ cRadio tab = GetCurrentTab();
3957
+
3958
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
36763959 {
3677
- Save();
3678
- tab.undoindex -= 1;
3960
+ java.awt.Toolkit.getDefaultToolkit().beep();
3961
+ return false;
36793962 }
36803963
3681
- tab.undoindex -= 1;
3964
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
3966
+
3967
+ return true;
3968
+ }
36823969
3683
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3970
+ public boolean Replace()
3971
+ {
3972
+ System.err.println("Replace");
3973
+
3974
+ cRadio tab = GetCurrentTab();
3975
+
3976
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
3977
+ {
3978
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3979
+ return false;
3980
+ }
3981
+
3982
+ copy.versionlist[copy.versionindex] = CompressCopy();
3983
+
3984
+ return true;
36843985 }
36853986
36863987 public void Redo()
36873988 {
3989
+ // Option?
3990
+ Replace();
3991
+
36883992 cRadio tab = GetCurrentTab();
36893993
3690
- if (tab.graphs[tab.undoindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
36913995 {
36923996 java.awt.Toolkit.getDefaultToolkit().beep();
36933997 return;
36943998 }
36953999
3696
- tab.undoindex += 1;
4000
+ copy.versionindex += 1;
36974001
3698
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
4003
+
4004
+ //if (!tab.user[tab.versionindex])
4005
+ // tab.graphs[tab.versionindex] = null;
36994006 }
37004007
37014008 void ImportGFD()
....@@ -3906,7 +4213,7 @@
39064213 //copy.material = new cMaterial(copy.GetMaterial());
39074214
39084215 current.color = (float) colorField.getFloat();
3909
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
39104217 current.metalness = (float) metalnessField.getFloat();
39114218 current.diffuse = (float) diffuseField.getFloat();
39124219 current.specular = (float) specularField.getFloat();
....@@ -3939,7 +4246,7 @@
39394246 cMaterial mat = copy.material;
39404247
39414248 colorField.SetToolTipValue((mat.color));
3942
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
39434250 metalnessField.SetToolTipValue((mat.metalness));
39444251 diffuseField.SetToolTipValue((mat.diffuse));
39454252 specularField.SetToolTipValue((mat.specular));
....@@ -3991,9 +4298,25 @@
39914298 //copy.Touch();
39924299 }
39934300
4301
+ cNumberSlider versionSlider;
4302
+
39944303 public void stateChanged(ChangeEvent e)
39954304 {
39964305 // assert(false);
4306
+ if (e.getSource() == versionSlider)
4307
+ {
4308
+ if (muteSlider)
4309
+ return;
4310
+
4311
+ int version = versionSlider.getInteger();
4312
+
4313
+ if (copy.versionlist[version] != null)
4314
+ {
4315
+ CopyChanged(copy.versionlist[copy.versionindex = version]);
4316
+ }
4317
+
4318
+ return;
4319
+ }
39974320
39984321 if (freezematerial)
39994322 {
....@@ -4029,6 +4352,12 @@
40294352 {
40304353 //System.out.println("stateChanged = " + this);
40314354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
40324361 applySelf();
40334362 //System.out.println("this = " + this);
40344363 //System.out.println("PARENT = " + parent);
....@@ -4328,6 +4657,7 @@
43284657 {
43294658 if (GetTree() != null)
43304659 {
4660
+ GetTree().revalidate();
43314661 GetTree().repaint();
43324662 }
43334663
....@@ -4342,7 +4672,7 @@
43424672
43434673 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43444674 {
4345
- if (Globals.SAVEONMAKE) // && resetmodel)
4675
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43464676 Save();
43474677 //Tween.set(thing, 0).target(1).start(tweenManager);
43484678 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4584,7 +4914,9 @@
45844914 readobj.ResetDisplayList();
45854915 } catch (Exception e)
45864916 {
4587
- //e.printStackTrace();
4917
+ if (!e.toString().contains("GZIP"))
4918
+ e.printStackTrace();
4919
+
45884920 try
45894921 {
45904922 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4658,12 +4990,14 @@
46584990
46594991 if (readobj != null)
46604992 {
4661
- if (Globals.SAVEONMAKE)
4662
- Save();
4993
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4994
+ // Save();
46634995 try
46644996 {
46654997 //readobj.deepCopySelf(copy);
46664998 copy.clear(); // june 2014
4999
+ copy.skyboxname = readobj.skyboxname;
5000
+ copy.skyboxext = readobj.skyboxext;
46675001 for (int i = 0; i < readobj.size(); i++)
46685002 {
46695003 Object3D child = readobj.get(i); // reserve(i);
....@@ -4704,6 +5038,7 @@
47045038 }
47055039 } catch (ClassCastException e)
47065040 {
5041
+ e.printStackTrace();
47075042 assert (false);
47085043 Composite c = (Composite) copy;
47095044 c.children.clear();
....@@ -4714,13 +5049,24 @@
47145049 c.addChild(csg);
47155050 }
47165051
5052
+ copy.versionlist = readobj.versionlist;
5053
+ copy.versionindex = readobj.versionindex;
5054
+
5055
+ if (copy.versionlist == null)
5056
+ {
5057
+ copy.versionlist = new Object3D[100];
5058
+ copy.versionindex = -1;
5059
+ }
5060
+
5061
+ //? SetUndoStates();
5062
+
47175063 ResetModel();
47185064 copy.HardTouch(); // recompile?
47195065 refreshContents();
47205066 }
47215067 }
47225068
4723
- void load() // throws ClassNotFoundException
5069
+ void Open() // throws ClassNotFoundException
47245070 {
47255071 if (Grafreed.standAlone)
47265072 {
....@@ -4823,6 +5169,7 @@
48235169 //ps.print(buffer.toString());
48245170 } catch (IOException e)
48255171 {
5172
+ e.printStackTrace();
48265173 }
48275174 }
48285175
....@@ -5005,7 +5352,7 @@
50055352 MenuBar menuBar;
50065353 Menu fileMenu;
50075354 MenuItem newItem;
5008
- MenuItem loadItem;
5355
+ MenuItem openItem;
50095356 MenuItem saveItem;
50105357 MenuItem saveAsItem;
50115358 MenuItem exportAsItem;
....@@ -5028,6 +5375,7 @@
50285375 CheckboxMenuItem toggleSwitchItem;
50295376 CheckboxMenuItem toggleRootItem;
50305377 CheckboxMenuItem animationItem;
5378
+ MenuItem archiveItem;
50315379 CheckboxMenuItem toggleHandleItem;
50325380 CheckboxMenuItem togglePaintItem;
50335381 JSplitPane mainPanel;
....@@ -5114,7 +5462,7 @@
51145462 JLabel colorLabel;
51155463 cNumberSlider colorField;
51165464 JLabel modulationLabel;
5117
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
51185466 JLabel metalnessLabel;
51195467 cNumberSlider metalnessField;
51205468 JLabel diffuseLabel;