Normand Briere
2019-08-13 0cdf3fb57ddea3226f094ba45c836c7e9b123e3a
ObjEditor.java
....@@ -34,6 +34,7 @@
3434 iSendInfo
3535 //KeyListener
3636 {
37
+ public cToggleButton pinButton;
3738 boolean timeline;
3839 boolean wasFullScreen;
3940
....@@ -41,64 +42,78 @@
4142 JFrame frame;
4243
4344 static ObjEditor theFrame;
45
+
46
+ public cGridBag GetSeparator()
47
+ {
48
+ cGridBag separator = new cGridBag();
49
+ separator.add(new JSeparator());
50
+ separator.preferredHeight = 5;
51
+ return separator;
52
+ }
4453
4554 cButton GetButton(String name, boolean border)
4655 {
47
- try
48
- {
49
- ImageIcon icon = GetIcon(name);
50
- return new cButton(icon, border);
51
- }
52
- catch (Exception e)
53
- {
54
- return new cButton(name, border);
55
- }
56
+ ImageIcon icon = GetIcon(name);
57
+ return new cButton(icon, border);
58
+ }
59
+
60
+ cLabel GetLabel(String name, boolean border)
61
+ {
62
+ //ImageIcon icon = GetIcon(name);
63
+ return new cLabel(GetImage(name), border);
5664 }
5765
5866 cToggleButton GetToggleButton(String name, boolean border)
5967 {
60
- try
61
- {
62
- ImageIcon icon = GetIcon(name);
63
- return new cToggleButton(icon, border);
64
- }
65
- catch (Exception e)
66
- {
67
- return new cToggleButton(name, border);
68
- }
68
+ ImageIcon icon = GetIcon(name);
69
+ return new cToggleButton(icon, border);
6970 }
7071
7172 cCheckBox GetCheckBox(String name, boolean border)
7273 {
74
+ ImageIcon icon = GetIcon(name);
75
+ return new cCheckBox(icon, border);
76
+ }
77
+
78
+ ImageIcon GetIcon(String name)
79
+ {
7380 try
7481 {
75
- ImageIcon icon = GetIcon(name);
76
- return new cCheckBox(icon, border);
82
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
83
+
84
+// if (image.getWidth() > 48 && image.getHeight() > 48)
85
+// {
86
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
87
+// Graphics2D g = resized.createGraphics();
88
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
89
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
90
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
91
+// g.dispose();
92
+//
93
+// image = resized;
94
+// }
95
+
96
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
97
+ return icon;
7798 }
7899 catch (Exception e)
79100 {
80
- return new cCheckBox(name, border);
101
+ return null;
81102 }
82103 }
83
-
84
- private ImageIcon GetIcon(String name) throws IOException
104
+
105
+ BufferedImage GetImage(String name)
85106 {
86
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
87
-
88
- if (image.getWidth() != 24 && image.getHeight() != 24)
107
+ try
89108 {
90
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
91
- Graphics2D g = resized.createGraphics();
92
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
93
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
94
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
95
- g.dispose();
96
-
97
- image = resized;
109
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
110
+
111
+ return image;
98112 }
99
-
100
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
101
- return icon;
113
+ catch (Exception e)
114
+ {
115
+ return null;
116
+ }
102117 }
103118
104119 // SCRIPT
....@@ -282,6 +297,14 @@
282297 client = inClient;
283298 copy = client;
284299
300
+// if (copy.versionlist == null)
301
+// {
302
+// copy.versionlist = new Object3D[100];
303
+// copy.versionindex = -1;
304
+//
305
+// callee.Save(true);
306
+// }
307
+
285308 // "this" is not called: SetupUI2(objEditor);
286309 }
287310
....@@ -295,6 +318,14 @@
295318 client = inClient;
296319 copy = client;
297320
321
+ if (copy.versionlist == null)
322
+ {
323
+ copy.versionlist = new Object3D[100];
324
+ copy.versionindex = -1;
325
+
326
+// Save(true);
327
+ }
328
+
298329 SetupUI2(callee.GetEditor());
299330 }
300331
....@@ -309,7 +340,7 @@
309340 //localCopy.parent = null;
310341
311342 frame = new JFrame();
312
- frame.setUndecorated(true);
343
+ frame.setUndecorated(false);
313344 objEditor = this;
314345 this.callee = callee;
315346
....@@ -327,6 +358,14 @@
327358 copy = localCopy;
328359 copy.editWindow = this;
329360
361
+// if (copy.versionlist == null)
362
+// {
363
+// copy.versionlist = new Object3D[100];
364
+// copy.versionindex = -1;
365
+//
366
+// Save(true);
367
+// }
368
+
330369 SetupMenu();
331370
332371 //SetupName(objEditor); // new
....@@ -350,7 +389,7 @@
350389 frame.setMenuBar(menuBar = new MenuBar());
351390 menuBar.add(fileMenu = new Menu("File"));
352391 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
392
+ fileMenu.add(openItem = new MenuItem("Open..."));
354393
355394 //oe.menuBar.add(menu = new Menu("Include"));
356395 Menu menu = new Menu("Import");
....@@ -382,7 +421,7 @@
382421 }
383422
384423 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
424
+ openItem.addActionListener(this);
386425 saveItem.addActionListener(this);
387426 saveAsItem.addActionListener(this);
388427 exportAsItem.addActionListener(this);
....@@ -412,18 +451,19 @@
412451 // EditSelection(false);
413452 // }
414453
415
- refreshContents(false); // To refresh Info tab
454
+// refreshContents(false); // To refresh Info tab
416455 }
417456 };
418457 objectPanel.addChangeListener(changeListener);
419458
420459 toolbarPanel = new JPanel();
421460 toolbarPanel.setName("Toolbar");
461
+
422462 treePanel = new cGridBag();
423463 treePanel.setName("Tree");
424464
425465 editPanel = new cGridBag().setVertical(true);
426
- editPanel.setName("Edit");
466
+ //editPanel.setName("Edit");
427467
428468 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
429469
....@@ -431,11 +471,13 @@
431471 editPanel.add(editCommandsPanel);
432472 editPanel.add(ctrlPanel);
433473
434
- toolboxPanel = new cGridBag().setVertical(false);
435
- toolboxPanel.setName("Toolbox");
474
+ toolboxPanel = new cGridBag().setVertical(true);
475
+ //toolboxPanel.setName("Toolbox");
436476
437
- materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
477
+ skyboxPanel = new cGridBag().setVertical(true);
478
+
479
+ materialPanel = new cGridBag().setVertical(false);
480
+ //materialPanel.setName("Material");
439481
440482 /*JTextPane*/
441483 infoarea = createTextPane();
....@@ -443,14 +485,15 @@
443485
444486 infoarea.setEditable(true);
445487 SetText();
488
+
446489 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
447490 // infoarea.setOpaque(false);
448491 // //infoarea.setForeground(textcolor);
449492 // TEXTAREA infoarea.setLineWrap(true);
450493 // TEXTAREA infoarea.setWrapStyleWord(true);
451494 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");
495
+ infoPanel.setPreferredSize(new Dimension(1, 1));
496
+ //infoPanel.setName("Info");
454497 //infoPanel.setLayout(new BorderLayout());
455498 //infoPanel.add(createTextPane());
456499
....@@ -699,8 +742,8 @@
699742 }
700743 }
701744
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
745
+//static GraphicsDevice device = GraphicsEnvironment
746
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704747
705748 Rectangle keeprect;
706749 cRadio radio;
....@@ -717,6 +760,7 @@
717760 boolean maximized;
718761
719762 cButton fullscreenLayout;
763
+ cButton expandedLayout;
720764
721765 void Minimize()
722766 {
....@@ -741,10 +785,11 @@
741785 else
742786 {
743787 keeprect = frame.getBounds();
744
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
- Dimension rect2 = frame.getToolkit().getScreenSize();
746
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
788
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
789
+// Dimension rect2 = frame.getToolkit().getScreenSize();
790
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
747791 // frame.setState(Frame.MAXIMIZED_BOTH);
792
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
748793 }
749794
750795 maximized ^= true;
....@@ -755,15 +800,22 @@
755800 cButton minButton;
756801 cButton maxButton;
757802 cButton fullButton;
803
+ cButton collapseButton;
804
+ cButton maximize3DButton;
758805
759806 void ToggleFullScreen()
760807 {
808
+ GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
809
+
761810 cameraView.ToggleFullScreen();
762811
763812 if (!CameraPane.FULLSCREEN)
764813 {
765814 device.setFullScreenWindow(null);
815
+ frame.dispose();
816
+ frame.setUndecorated(false);
766817 frame.validate();
818
+ frame.setVisible(true);
767819
768820 //frame.setVisible(false);
769821 // frame.removeNotify();
....@@ -774,13 +826,13 @@
774826 // X frame.getContentPane().remove(/*"Center",*/bigThree);
775827 // X framePanel.add(bigThree);
776828 // X frame.getContentPane().add(/*"Center",*/framePanel);
777
- framePanel.setDividerLocation(1);
829
+// framePanel.setDividerLocation(46); // icons are 24x24
778830
779831 //frame.setVisible(true);
780
- radio.layout = keepButton;
832
+// radio.layout = keepButton;
781833 //theFrame = null;
782834 keepButton = null;
783
- radio.layout.doClick();
835
+// radio.layout.doClick();
784836
785837 } else
786838 {
....@@ -789,22 +841,59 @@
789841 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
790842 // frame.getToolkit().getScreenSize().height);
791843 //frame.setVisible(false);
844
+
845
+ frame.dispose();
846
+ frame.setUndecorated(true);
792847 device.setFullScreenWindow(frame);
793848 frame.validate();
849
+ frame.setVisible(true);
794850 // frame.removeNotify();
795851 // frame.setUndecorated(true);
796852 // frame.addNotify();
797853 // X frame.getContentPane().remove(/*"Center",*/framePanel);
798854 // X framePanel.remove(bigThree);
799855 // X frame.getContentPane().add(/*"Center",*/bigThree);
800
- framePanel.setDividerLocation(0);
856
+// framePanel.setDividerLocation(0);
801857
802
- radio.layout = fullscreenLayout;
803
- radio.layout.doClick();
858
+// radio.layout = fullscreenLayout;
859
+// radio.layout.doClick();
804860 //frame.setVisible(true);
805861 }
806862 frame.validate();
863
+
864
+ cameraView.requestFocusInWindow();
807865 }
866
+
867
+ void CollapseToolbar()
868
+ {
869
+ framePanel.setDividerLocation(0);
870
+ //frame.validate();
871
+
872
+ cameraView.requestFocusInWindow();
873
+ }
874
+
875
+ private Object3D Duplicate(Object3D object)
876
+ {
877
+ boolean temp = CameraPane.SWITCH;
878
+ CameraPane.SWITCH = false;
879
+
880
+ object.ExtractBigData(versiontable);
881
+ // if (copy == client)
882
+
883
+ Object3D versions[] = object.versionlist;
884
+ object.versionlist = null;
885
+
886
+ //byte[] compress = Compress(copy);
887
+ Object3D compress = (Object3D)Grafreed.clone(object);
888
+
889
+ object.versionlist = versions;
890
+
891
+ object.RestoreBigData(versiontable);
892
+
893
+ CameraPane.SWITCH = temp;
894
+
895
+ return compress;
896
+ }
808897
809898 private JTextPane createTextPane()
810899 {
....@@ -927,6 +1016,7 @@
9271016 {
9281017 SetupMaterial(materialPanel);
9291018 }
1019
+
9301020 //SetupName();
9311021 //SetupViews();
9321022 }
....@@ -936,7 +1026,7 @@
9361026 // NumberSlider vDivsField;
9371027 // JCheckBox endcaps;
9381028 JCheckBox liveCB;
939
- JCheckBox selectCB;
1029
+ JCheckBox selectableCB;
9401030 JCheckBox hideCB;
9411031 JCheckBox link2masterCB;
9421032 JCheckBox markCB;
....@@ -1135,6 +1225,18 @@
11351225
11361226 namePanel = new cGridBag();
11371227
1228
+ //if (copy.pinned)
1229
+ {
1230
+ pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
1231
+ pinButton.setSelected(copy.pinned);
1232
+ cGridBag t = new cGridBag();
1233
+ t.preferredWidth = 2;
1234
+ t.add(pinButton);
1235
+ namePanel.add(t);
1236
+
1237
+ pinButton.addItemListener(this);
1238
+ }
1239
+
11381240 nameField = AddText(namePanel, copy.GetName());
11391241 namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11401242 oe.ctrlPanel.add(namePanel);
....@@ -1148,13 +1250,16 @@
11481250
11491251 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11501252 liveCB.setToolTipText("Animate object");
1151
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1152
- selectCB.setToolTipText("Make object selectable");
1253
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1254
+ selectableCB.setToolTipText("Make object selectable");
11531255 // Return();
1256
+
11541257 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11551258 hideCB.setToolTipText("Hide object");
11561259 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11571260 markCB.setToolTipText("As animation target transform");
1261
+
1262
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11581263
11591264 setupPanel2 = new cGridBag().setVertical(false);
11601265
....@@ -1164,10 +1269,11 @@
11641269 randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11651270 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11661271
1272
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1273
+ link2masterCB.setToolTipText("Attach to support");
1274
+
11671275 if (Globals.ADVANCED)
11681276 {
1169
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1170
- link2masterCB.setToolTipText("Attach to support");
11711277 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11721278 speedupCB.setToolTipText("Option motion capture");
11731279 }
....@@ -1441,6 +1547,7 @@
14411547 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14421548 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14431549 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1550
+ //XYZPanel.setName("XYZ");
14441551
14451552 /*
14461553 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1478,14 +1585,29 @@
14781585 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14791586 //tmp.setName("Edit");
14801587 objectPanel.add(materialPanel);
1588
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1589
+ objectPanel.setToolTipTextAt(0, "Material");
1590
+
1591
+ objectPanel.add(toolboxPanel);
1592
+ objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
1593
+ objectPanel.setToolTipTextAt(1, "Objects & textures");
1594
+
1595
+ objectPanel.add(skyboxPanel);
1596
+ objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
1597
+ objectPanel.setToolTipTextAt(2, "Backgrounds");
1598
+
14811599 // JPanel north = new JPanel(new BorderLayout());
14821600 // north.setName("Edit");
14831601 // north.add(ctrlPanel, BorderLayout.NORTH);
14841602 // objectPanel.add(north);
14851603 objectPanel.add(editPanel);
1486
- objectPanel.add(infoPanel);
1487
- objectPanel.add(toolboxPanel);
1488
-
1604
+ objectPanel.setIconAt(3, GetIcon("icons/write.png"));
1605
+ objectPanel.setToolTipTextAt(3, "Edit controls");
1606
+
1607
+ objectPanel.add(XYZPanel);
1608
+ objectPanel.setIconAt(4, GetIcon("icons/XYZ.png"));
1609
+ objectPanel.setToolTipTextAt(4, "XYZ/RGB transform");
1610
+
14891611 /*
14901612 aConstraints.gridx = 0;
14911613 aConstraints.gridwidth = 1;
....@@ -1505,7 +1627,7 @@
15051627 scrollpane.addMouseWheelListener(this); // Default not fast enough
15061628
15071629 /*JTabbedPane*/ scenePanel = new cGridBag();
1508
- scenePanel.preferredWidth = 6;
1630
+ scenePanel.preferredWidth = 5;
15091631
15101632 JTabbedPane tabbedPane = new JTabbedPane();
15111633 tabbedPane.add(scrollpane);
....@@ -1522,6 +1644,11 @@
15221644
15231645 scenePanel.add(tabbedPane);
15241646
1647
+ //if (Globals.ADVANCED)
1648
+ tabbedPane.add(infoPanel);
1649
+ tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1650
+ tabbedPane.setToolTipTextAt(3, "Information");
1651
+
15251652 /*
15261653 cTree jTree = new cTree(null);
15271654 ToolTipManager.sharedInstance().registerComponent(jTree);
....@@ -1583,7 +1710,7 @@
15831710 bigThree = new cGridBag();
15841711 bigThree.addComponent(scenePanel);
15851712 bigThree.addComponent(centralPanel);
1586
- bigThree.addComponent(XYZPanel);
1713
+ //bigThree.addComponent(XYZPanel);
15871714
15881715 // // SIDE EFFECT!!!
15891716 // aConstraints.gridx = 0;
....@@ -1592,9 +1719,26 @@
15921719 // aConstraints.gridheight = 1;
15931720
15941721 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1595
- framePanel.setContinuousLayout(true);
1596
- framePanel.setOneTouchExpandable(true);
1597
- framePanel.setDividerLocation(0.8);
1722
+
1723
+ framePanel.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY,
1724
+ new java.beans.PropertyChangeListener()
1725
+ {
1726
+ public void propertyChange(java.beans.PropertyChangeEvent pce)
1727
+ {
1728
+ if ((Integer)pce.getOldValue() == 1)
1729
+ {
1730
+ if (radio.layout != expandedLayout)
1731
+ {
1732
+ radio.layout = expandedLayout;
1733
+ radio.layout.doClick();
1734
+ }
1735
+ }
1736
+ }
1737
+ });
1738
+
1739
+ framePanel.setContinuousLayout(false);
1740
+ framePanel.setOneTouchExpandable(false);
1741
+ //.setDividerLocation(0.8);
15981742 //framePanel.setDividerSize(15);
15991743 //framePanel.setResizeWeight(0.15);
16001744 framePanel.setName("Frame");
....@@ -1613,17 +1757,17 @@
16131757
16141758 frame.setSize(1280, 860);
16151759
1616
- frame.validate();
1617
- frame.setVisible(true);
1618
-
16191760 cameraView.requestFocusInWindow();
16201761
16211762 gridPanel.setDividerLocation(1.0);
1763
+
1764
+ frame.validate();
1765
+
1766
+ frame.setVisible(true);
16221767
16231768 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16241769 frame.addWindowListener(new WindowAdapter()
16251770 {
1626
-
16271771 public void windowClosing(WindowEvent e)
16281772 {
16291773 Close();
....@@ -1646,12 +1790,403 @@
16461790 ctrlPanel.removeAll();
16471791 }
16481792
1649
- void SetupMaterial(cGridBag panel)
1793
+ void SetupMaterial(cGridBag materialpanel)
16501794 {
1651
- /*
1795
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1796
+
1797
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1798
+ skin.setToolTipText("Skin");
1799
+ skin.addMouseListener(new MouseAdapter()
1800
+ {
1801
+ public void mouseClicked(MouseEvent e)
1802
+ {
1803
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1804
+ cMaterial material = object.material;
1805
+
1806
+ // Skin
1807
+ colorField.setFloat(material.color);
1808
+ saturationField.setFloat(material.modulation);
1809
+ subsurfaceField.setFloat(material.subsurface);
1810
+ selfshadowField.setFloat(material.diffuseness);
1811
+ diffusenessField.setFloat(material.factor);
1812
+ shininessField.setFloat(material.shininess);
1813
+ shadowbiasField.setFloat(material.shadowbias);
1814
+ diffuseField.setFloat(material.diffuse);
1815
+ specularField.setFloat(material.specular);
1816
+
1817
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1818
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1819
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1820
+
1821
+ materialtouched = true;
1822
+ applySelf();
1823
+ }
1824
+ });
1825
+ presetpanel.add(skin);
1826
+
1827
+ cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
1828
+ lambert.setToolTipText("Diffuse");
1829
+ lambert.addMouseListener(new MouseAdapter()
1830
+ {
1831
+ public void mouseClicked(MouseEvent e)
1832
+ {
1833
+ Object3D object = Grafreed.materials.versionlist[2].get(0);
1834
+ cMaterial material = object.material;
1835
+
1836
+ diffusenessField.setFloat(material.factor);
1837
+ selfshadowField.setFloat(material.diffuseness);
1838
+
1839
+ materialtouched = true;
1840
+ applySelf();
1841
+ }
1842
+ });
1843
+ presetpanel.add(lambert);
1844
+
1845
+ cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
1846
+ diffuse2.setToolTipText("Diffuse2");
1847
+ diffuse2.addMouseListener(new MouseAdapter()
1848
+ {
1849
+ public void mouseClicked(MouseEvent e)
1850
+ {
1851
+ Object3D object = Grafreed.materials.versionlist[3].get(0);
1852
+ cMaterial material = object.material;
1853
+
1854
+ diffusenessField.setFloat(material.factor);
1855
+ selfshadowField.setFloat(material.diffuseness);
1856
+
1857
+ materialtouched = true;
1858
+ applySelf();
1859
+ }
1860
+ });
1861
+ presetpanel.add(diffuse2);
1862
+
1863
+ cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
1864
+ diffusemoon.setToolTipText("Moon");
1865
+ diffusemoon.addMouseListener(new MouseAdapter()
1866
+ {
1867
+ public void mouseClicked(MouseEvent e)
1868
+ {
1869
+ Object3D object = Grafreed.materials.versionlist[4].get(0);
1870
+ cMaterial material = object.material;
1871
+
1872
+ diffusenessField.setFloat(material.factor);
1873
+ selfshadowField.setFloat(material.diffuseness);
1874
+
1875
+ materialtouched = true;
1876
+ applySelf();
1877
+ }
1878
+ });
1879
+ presetpanel.add(diffusemoon);
1880
+
1881
+ cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
1882
+ diffusemoon2.setToolTipText("Moon2");
1883
+ diffusemoon2.addMouseListener(new MouseAdapter()
1884
+ {
1885
+ public void mouseClicked(MouseEvent e)
1886
+ {
1887
+ Object3D object = Grafreed.materials.versionlist[5].get(0);
1888
+ cMaterial material = object.material;
1889
+
1890
+ diffusenessField.setFloat(material.factor);
1891
+ selfshadowField.setFloat(material.diffuseness);
1892
+
1893
+ materialtouched = true;
1894
+ applySelf();
1895
+ }
1896
+ });
1897
+ presetpanel.add(diffusemoon2);
1898
+
1899
+ cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
1900
+ diffusemoon3.setToolTipText("Moon3");
1901
+ diffusemoon3.addMouseListener(new MouseAdapter()
1902
+ {
1903
+ public void mouseClicked(MouseEvent e)
1904
+ {
1905
+ Object3D object = Grafreed.materials.versionlist[6].get(0);
1906
+ cMaterial material = object.material;
1907
+
1908
+ diffusenessField.setFloat(material.factor);
1909
+ selfshadowField.setFloat(material.diffuseness);
1910
+
1911
+ materialtouched = true;
1912
+ applySelf();
1913
+ }
1914
+ });
1915
+ presetpanel.add(diffusemoon3);
1916
+
1917
+ cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
1918
+ diffusesheen.setToolTipText("Sheen");
1919
+ diffusesheen.addMouseListener(new MouseAdapter()
1920
+ {
1921
+ public void mouseClicked(MouseEvent e)
1922
+ {
1923
+ Object3D object = Grafreed.materials.versionlist[7].get(0);
1924
+ cMaterial material = object.material;
1925
+
1926
+ sheenField.setFloat(material.sheen);
1927
+
1928
+ materialtouched = true;
1929
+ applySelf();
1930
+ }
1931
+ });
1932
+ presetpanel.add(diffusesheen);
1933
+
1934
+ cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1935
+ rough.setToolTipText("Rough metal");
1936
+ rough.addMouseListener(new MouseAdapter()
1937
+ {
1938
+ public void mouseClicked(MouseEvent e)
1939
+ {
1940
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1941
+ cMaterial material = object.material;
1942
+
1943
+ shininessField.setFloat(material.shininess);
1944
+ velvetField.setFloat(material.velvet);
1945
+
1946
+ materialtouched = true;
1947
+ applySelf();
1948
+ }
1949
+ });
1950
+ presetpanel.add(rough);
1951
+
1952
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
1953
+ rough2.setToolTipText("Medium metal");
1954
+ rough2.addMouseListener(new MouseAdapter()
1955
+ {
1956
+ public void mouseClicked(MouseEvent e)
1957
+ {
1958
+ Object3D object = Grafreed.materials.versionlist[13].get(0);
1959
+ cMaterial material = object.material;
1960
+
1961
+ shininessField.setFloat(material.shininess);
1962
+ lightareaField.setFloat(material.lightarea);
1963
+
1964
+ materialtouched = true;
1965
+ applySelf();
1966
+ }
1967
+ });
1968
+ presetpanel.add(rough2);
1969
+
1970
+ cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
1971
+ shini0.setToolTipText("Shiny");
1972
+ shini0.addMouseListener(new MouseAdapter()
1973
+ {
1974
+ public void mouseClicked(MouseEvent e)
1975
+ {
1976
+ Object3D object = Grafreed.materials.versionlist[14].get(0);
1977
+ cMaterial material = object.material;
1978
+
1979
+ shininessField.setFloat(material.shininess);
1980
+ lightareaField.setFloat(material.lightarea);
1981
+
1982
+ materialtouched = true;
1983
+ applySelf();
1984
+ }
1985
+ });
1986
+ presetpanel.add(shini0);
1987
+
1988
+ cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
1989
+ shini1.setToolTipText("Shiny2");
1990
+ shini1.addMouseListener(new MouseAdapter()
1991
+ {
1992
+ public void mouseClicked(MouseEvent e)
1993
+ {
1994
+ Object3D object = Grafreed.materials.versionlist[11].get(0);
1995
+ cMaterial material = object.material;
1996
+
1997
+ shininessField.setFloat(material.shininess);
1998
+ lightareaField.setFloat(material.lightarea);
1999
+
2000
+ materialtouched = true;
2001
+ applySelf();
2002
+ }
2003
+ });
2004
+ presetpanel.add(shini1);
2005
+
2006
+ cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
2007
+ shini2.setToolTipText("Shiny3");
2008
+ shini2.addMouseListener(new MouseAdapter()
2009
+ {
2010
+ public void mouseClicked(MouseEvent e)
2011
+ {
2012
+ Object3D object = Grafreed.materials.versionlist[12].get(0);
2013
+ cMaterial material = object.material;
2014
+
2015
+ shininessField.setFloat(material.shininess);
2016
+ lightareaField.setFloat(material.lightarea);
2017
+
2018
+ materialtouched = true;
2019
+ applySelf();
2020
+ }
2021
+ });
2022
+ presetpanel.add(shini2);
2023
+
2024
+ cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
2025
+ aniso.setToolTipText("AnisoU");
2026
+ aniso.addMouseListener(new MouseAdapter()
2027
+ {
2028
+ public void mouseClicked(MouseEvent e)
2029
+ {
2030
+ Object3D object = Grafreed.materials.versionlist[8].get(0);
2031
+ cMaterial material = object.material;
2032
+
2033
+ anisoField.setFloat(material.aniso);
2034
+ anisoVField.setFloat(material.anisoV);
2035
+
2036
+ materialtouched = true;
2037
+ applySelf();
2038
+ }
2039
+ });
2040
+ presetpanel.add(aniso);
2041
+
2042
+ cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
2043
+ aniso2.setToolTipText("AnisoV");
2044
+ aniso2.addMouseListener(new MouseAdapter()
2045
+ {
2046
+ public void mouseClicked(MouseEvent e)
2047
+ {
2048
+ Object3D object = Grafreed.materials.versionlist[9].get(0);
2049
+ cMaterial material = object.material;
2050
+
2051
+ anisoField.setFloat(material.aniso);
2052
+ anisoVField.setFloat(material.anisoV);
2053
+
2054
+ materialtouched = true;
2055
+ applySelf();
2056
+ }
2057
+ });
2058
+ presetpanel.add(aniso2);
2059
+
2060
+ cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
2061
+ aniso3.setToolTipText("AnisoUV");
2062
+ aniso3.addMouseListener(new MouseAdapter()
2063
+ {
2064
+ public void mouseClicked(MouseEvent e)
2065
+ {
2066
+ Object3D object = Grafreed.materials.versionlist[10].get(0);
2067
+ cMaterial material = object.material;
2068
+
2069
+ anisoField.setFloat(material.aniso);
2070
+ anisoVField.setFloat(material.anisoV);
2071
+
2072
+ materialtouched = true;
2073
+ applySelf();
2074
+ }
2075
+ });
2076
+ presetpanel.add(aniso3);
2077
+
2078
+ cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
2079
+ velvet0.setToolTipText("Velvet");
2080
+ velvet0.addMouseListener(new MouseAdapter()
2081
+ {
2082
+ public void mouseClicked(MouseEvent e)
2083
+ {
2084
+ Object3D object = Grafreed.materials.versionlist[15].get(0);
2085
+ cMaterial material = object.material;
2086
+
2087
+ diffusenessField.setFloat(material.factor);
2088
+ selfshadowField.setFloat(material.diffuseness);
2089
+ sheenField.setFloat(material.sheen);
2090
+ shininessField.setFloat(material.shininess);
2091
+ velvetField.setFloat(material.velvet);
2092
+ shiftField.setFloat(material.shift);
2093
+
2094
+ materialtouched = true;
2095
+ applySelf();
2096
+ }
2097
+ });
2098
+ presetpanel.add(velvet0);
2099
+
2100
+ cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
2101
+ bump0.setToolTipText("Bump texture");
2102
+ bump0.addMouseListener(new MouseAdapter()
2103
+ {
2104
+ public void mouseClicked(MouseEvent e)
2105
+ {
2106
+ Object3D object = Grafreed.materials.versionlist[16].get(0);
2107
+ cMaterial material = object.material;
2108
+
2109
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
2110
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
2111
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
2112
+
2113
+ materialtouched = true;
2114
+ applySelf();
2115
+ }
2116
+ });
2117
+ presetpanel.add(bump0);
2118
+
2119
+ cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
2120
+ halo.setToolTipText("Halo");
2121
+ halo.addMouseListener(new MouseAdapter()
2122
+ {
2123
+ public void mouseClicked(MouseEvent e)
2124
+ {
2125
+ Object3D object = Grafreed.materials.versionlist[17].get(0);
2126
+ cMaterial material = object.material;
2127
+
2128
+ opacityPowerField.setFloat(object.projectedVertices[2].y / 1000.0);
2129
+
2130
+ materialtouched = true;
2131
+ applySelf();
2132
+ }
2133
+ });
2134
+ presetpanel.add(halo);
2135
+
2136
+ cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
2137
+ candle.setToolTipText("Candle");
2138
+ candle.addMouseListener(new MouseAdapter()
2139
+ {
2140
+ public void mouseClicked(MouseEvent e)
2141
+ {
2142
+ Object3D object = Grafreed.materials.versionlist[18].get(0);
2143
+ cMaterial material = object.material;
2144
+
2145
+ subsurfaceField.setFloat(material.subsurface);
2146
+ shadowbiasField.setFloat(material.shadowbias);
2147
+ ambientField.setFloat(material.ambient);
2148
+ specularField.setFloat(material.specular);
2149
+ lightareaField.setFloat(material.lightarea);
2150
+ shininessField.setFloat(material.shininess);
2151
+
2152
+ materialtouched = true;
2153
+ applySelf();
2154
+ }
2155
+ });
2156
+ presetpanel.add(candle);
2157
+
2158
+ cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
2159
+ shadowShader.setToolTipText("Shadow");
2160
+ shadowShader.addMouseListener(new MouseAdapter()
2161
+ {
2162
+ public void mouseClicked(MouseEvent e)
2163
+ {
2164
+ diffuseField.setFloat(0.001);
2165
+ ambientField.setFloat(0.001);
2166
+ cameraField.setFloat(0.001);
2167
+ specularField.setFloat(0.001);
2168
+ fakedepthField.setFloat(0.001);
2169
+ opacityField.setFloat(0.6);
2170
+
2171
+ materialtouched = true;
2172
+ applySelf();
2173
+ }
2174
+ });
2175
+ presetpanel.add(shadowShader);
2176
+
2177
+ cGridBag panel = new cGridBag().setVertical(true);
2178
+
2179
+ presetpanel.preferredWidth = 1;
2180
+
2181
+ materialpanel.add(presetpanel);
2182
+ materialpanel.add(panel);
2183
+
2184
+ panel.preferredWidth = 8;
2185
+
2186
+ /*
16522187 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16532188 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1654
- */
2189
+ */
16552190
16562191 cGridBag editBar = new cGridBag().setVertical(false);
16572192
....@@ -1685,27 +2220,50 @@
16852220 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16862221
16872222 cGridBag colorSection = new cGridBag().setVertical(true);
2223
+
2224
+ cGridBag huepanel = new cGridBag();
2225
+ cGridBag huelabel = new cGridBag();
2226
+ skin = GetLabel("icons/hue.png", false);
2227
+ skin.fit = true;
2228
+ huelabel.add(skin);
2229
+ huelabel.preferredWidth = 20;
2230
+ huepanel.add(new cGridBag()); // Label
2231
+ huepanel.add(huelabel); // Field/slider
2232
+
2233
+ huepanel.preferredHeight = 7;
2234
+
2235
+ colorSection.add(huepanel);
16882236
16892237 cGridBag color = new cGridBag();
1690
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1691
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2238
+
2239
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
2240
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2241
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2242
+
16932243 //colorField.preferredWidth = 200;
16942244 colorSection.add(color);
16952245
16962246 cGridBag modulation = new cGridBag();
16972247 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16982248 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1699
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2249
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
17002250 colorSection.add(modulation);
17012251
2252
+ cGridBag opacity = new cGridBag();
2253
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
2254
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2255
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
2256
+ colorSection.add(opacity);
2257
+
2258
+ colorSection.add(GetSeparator());
2259
+
17022260 cGridBag texture = new cGridBag();
17032261 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
17042262 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17052263 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
17062264 colorSection.add(texture);
17072265
1708
- panel.add(new JSeparator());
2266
+ panel.add(GetSeparator());
17092267
17102268 panel.add(colorSection);
17112269
....@@ -1761,7 +2319,7 @@
17612319 shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17622320 diffuseSection.add(shadowbias);
17632321
1764
- panel.add(new JSeparator());
2322
+ panel.add(GetSeparator());
17652323
17662324 panel.add(diffuseSection);
17672325
....@@ -1824,7 +2382,7 @@
18242382 specularSection.add(anisoV);
18252383
18262384
1827
- panel.add(new JSeparator());
2385
+ panel.add(GetSeparator());
18282386
18292387 panel.add(specularSection);
18302388
....@@ -1849,12 +2407,6 @@
18492407 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18502408 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
18512409 colorSection.add(backlit);
1852
-
1853
- cGridBag opacity = new cGridBag();
1854
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1855
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1856
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1857
- colorSection.add(opacity);
18582410
18592411 //panel.add(new JSeparator());
18602412
....@@ -1900,7 +2452,7 @@
19002452 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
19012453 textureSection.add(opacityPower);
19022454
1903
- panel.add(new JSeparator());
2455
+ panel.add(GetSeparator());
19042456
19052457 panel.add(textureSection);
19062458
....@@ -1965,8 +2517,9 @@
19652517 // 3D models
19662518 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19672519 {
1968
- lastConverter = new com.jmex.model.converters.MaxToJme();
1969
- LoadFile(filename, lastConverter);
2520
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2521
+ //LoadFile(filename, lastConverter);
2522
+ LoadObjFile(filename); // New 3ds loader
19702523 continue;
19712524 }
19722525 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2692,6 +3245,7 @@
26923245 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26933246 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26943247 }
3248
+
26953249 //cJME.count++;
26963250 //cJME.count %= 12;
26973251 if (gc)
....@@ -2875,6 +3429,7 @@
28753429 }
28763430 }
28773431 }
3432
+
28783433 cFileSystemPane FSPane;
28793434
28803435 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2884,7 +3439,7 @@
28843439
28853440 freezematerial = true;
28863441 colorField.setFloat(mat.color);
2887
- modulationField.setFloat(mat.modulation);
3442
+ saturationField.setFloat(mat.modulation);
28883443 metalnessField.setFloat(mat.metalness);
28893444 diffuseField.setFloat(mat.diffuse);
28903445 specularField.setFloat(mat.specular);
....@@ -2928,6 +3483,7 @@
29283483 }
29293484 }
29303485 }
3486
+
29313487 freezematerial = false;
29323488 }
29333489
....@@ -3090,6 +3646,17 @@
30903646 public void itemStateChanged(ItemEvent event)
30913647 {
30923648 // System.out.println("Propagate = " + propagate);
3649
+ if (event.getSource() == pinButton)
3650
+ {
3651
+ copy.pinned ^= true;
3652
+ if (!copy.pinned && !copy.editWindow.copy.selection.contains(copy))
3653
+ {
3654
+ ((GroupEditor)copy.editWindow).listUI.remove(copy);
3655
+ copy.CloseUI();
3656
+ //copy.editWindow.refreshContents();
3657
+ }
3658
+ }
3659
+ else
30933660 if (event.getSource() == propagateToggle)
30943661 {
30953662 propagate ^= true;
....@@ -3194,8 +3761,9 @@
31943761 } else if (event.getSource() == liveCB)
31953762 {
31963763 copy.live ^= true;
3764
+ objEditor.refreshContents(true); // To show item colors
31973765 return;
3198
- } else if (event.getSource() == selectCB)
3766
+ } else if (event.getSource() == selectableCB)
31993767 {
32003768 copy.dontselect ^= true;
32013769 return;
....@@ -3203,7 +3771,7 @@
32033771 {
32043772 copy.hide ^= true;
32053773 copy.Touch(); // display list issue
3206
- objEditor.refreshContents();
3774
+ objEditor.refreshContents(true); // To show item colors
32073775 return;
32083776 } else if (event.getSource() == link2masterCB)
32093777 {
....@@ -3380,9 +3948,9 @@
33803948 {
33813949 Close();
33823950 //return true;
3383
- } else if (source == loadItem)
3951
+ } else if (source == openItem)
33843952 {
3385
- load();
3953
+ Open();
33863954 //return true;
33873955 } else if (source == newItem)
33883956 {
....@@ -3407,6 +3975,10 @@
34073975 {
34083976 generatePOV();
34093977 //return true;
3978
+ } else if (event.getSource() == archiveItem)
3979
+ {
3980
+ cTools.Archive(frame);
3981
+ return;
34103982 } else if (source == zBufferItem)
34113983 {
34123984 try
....@@ -3455,11 +4027,12 @@
34554027
34564028 static public byte[] Compress(Object3D o)
34574029 {
4030
+ // Slower to actually compress.
34584031 try
34594032 {
34604033 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3461
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3462
- ObjectOutputStream out = new ObjectOutputStream(zstream);
4034
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
4035
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34634036
34644037 Object3D parent = o.parent;
34654038 o.parent = null;
....@@ -3470,10 +4043,14 @@
34704043
34714044 out.flush();
34724045
3473
- zstream.close();
4046
+ baos //zstream
4047
+ .close();
34744048 out.close();
34754049
3476
- return baos.toByteArray();
4050
+ byte[] bytes = baos.toByteArray();
4051
+
4052
+ System.out.println("save #bytes = " + bytes.length);
4053
+ return bytes;
34774054 } catch (Exception e)
34784055 {
34794056 System.err.println(e);
....@@ -3483,13 +4060,16 @@
34834060
34844061 static public Object Uncompress(byte[] bytes)
34854062 {
3486
- System.out.println("#bytes = " + bytes.length);
4063
+ System.out.println("restore #bytes = " + bytes.length);
34874064 try
34884065 {
34894066 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3490
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3491
- ObjectInputStream in = new ObjectInputStream(istream);
4067
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
4068
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34924069 Object obj = in.readObject();
4070
+
4071
+ bais //istream
4072
+ .close();
34934073 in.close();
34944074
34954075 return obj;
....@@ -3544,43 +4124,95 @@
35444124 return null;
35454125 }
35464126
3547
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35484127
35494128 public void Save()
35504129 {
4130
+ //Save(true);
4131
+ Replace();
4132
+ SetVersionStates();
4133
+ }
4134
+
4135
+ private boolean Equal(byte[] compress, byte[] name)
4136
+ {
4137
+ if (compress.length != name.length)
4138
+ {
4139
+ return false;
4140
+ }
4141
+
4142
+ for (int i=compress.length; --i>=0;)
4143
+ {
4144
+ if (compress[i] != name[i])
4145
+ return false;
4146
+ }
4147
+
4148
+ return true;
4149
+ }
4150
+
4151
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
4152
+
4153
+ void DeleteVersion()
4154
+ {
4155
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
4156
+ {
4157
+ copy.versionlist[i] = copy.versionlist[i+1];
4158
+ }
4159
+
4160
+ CopyChanged();
4161
+
4162
+ SetVersionStates();
4163
+ }
4164
+
4165
+ public boolean Save(boolean user)
4166
+ {
35514167 System.err.println("Save");
4168
+ Replace();
35524169
3553
- cRadio tab = GetCurrentTab();
4170
+ //cRadio tab = GetCurrentTab();
35544171
3555
- boolean temp = CameraPane.SWITCH;
3556
- CameraPane.SWITCH = false;
4172
+ Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
35574173
3558
- copy.ExtractBigData(hashtable);
4174
+ boolean thesame = false;
35594175
3560
- byte[] compress = Compress(copy);
4176
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
4177
+// {
4178
+// thesame = true;
4179
+// }
35614180
35624181 //EditorFrame.m_MainFrame.requestFocusInWindow();
3563
- tab.graphs[tab.undoindex++] = compress;
3564
-
3565
- copy.RestoreBigData(hashtable);
3566
-
3567
- CameraPane.SWITCH = temp;
3568
-
3569
- //assert(hashtable.isEmpty());
3570
-
3571
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
4182
+ if (!thesame)
35724183 {
3573
- tab.graphs[i] = null;
4184
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
4185
+ {
4186
+ copy.versionlist[i] = copy.versionlist[i-1];
4187
+ }
4188
+
4189
+ //tab.user[tab.versionindex] = user;
4190
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
4191
+
4192
+ copy.versionlist[++copy.versionindex] = compress;
4193
+
4194
+ // if (increment)
4195
+ // tab.versionindex++;
35744196 }
35754197
3576
- SetUndoStates();
4198
+ //copy.RestoreBigData(versiontable);
4199
+
4200
+ //assert(hashtable.isEmpty());
4201
+
4202
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
4203
+// {
4204
+// //tab.user[i] = false;
4205
+// copy.versionlist[i] = null;
4206
+// }
4207
+
4208
+ SetVersionStates();
35774209
35784210 // test save
35794211 if (false)
35804212 {
35814213 try
35824214 {
3583
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
4215
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35844216 ObjectOutputStream p = new ObjectOutputStream(ostream);
35854217
35864218 p.writeObject(copy);
....@@ -3593,28 +4225,68 @@
35934225 e.printStackTrace();
35944226 }
35954227 }
4228
+
4229
+ return !thesame;
4230
+ }
4231
+
4232
+ boolean flashIt = true;
4233
+
4234
+ void RefreshSelection()
4235
+ {
4236
+ Object3D selection = new Object3D();
4237
+
4238
+ for (int i = 0; i < copy.selection.size(); i++)
4239
+ {
4240
+ Object3D elem = copy.selection.elementAt(i);
4241
+
4242
+ Object3D obj = copy.GetObject(elem.GetUUID());
4243
+
4244
+ if (obj == null)
4245
+ {
4246
+ copy.selection.remove(i--);
4247
+ }
4248
+ else
4249
+ {
4250
+ selection.add(obj);
4251
+ copy.selection.setElementAt(obj, i);
4252
+ }
4253
+ }
4254
+
4255
+ flashIt = false;
4256
+ GetTree().clearSelection();
4257
+ for (int i = 0; i < selection.size(); i++)
4258
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
4259
+ flashIt = true;
4260
+
4261
+ //refreshContents(false);
35964262 }
35974263
3598
- void CopyChanged(Object3D obj)
4264
+ void CopyChanged()
35994265 {
3600
- SetUndoStates();
4266
+ Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
4267
+
4268
+ SetVersionStates();
36014269
36024270 boolean temp = CameraPane.SWITCH;
36034271 CameraPane.SWITCH = false;
36044272
3605
- copy.ExtractBigData(hashtable);
4273
+ copy.ExtractBigData(versiontable);
36064274
36074275 copy.clear();
36084276
4277
+ copy.skyboxname = obj.skyboxname;
4278
+ copy.skyboxext = obj.skyboxext;
4279
+
36094280 for (int i=0; i<obj.Size(); i++)
36104281 {
36114282 copy.add(obj.get(i));
36124283 }
36134284
3614
- copy.RestoreBigData(hashtable);
4285
+ copy.RestoreBigData(versiontable);
36154286
36164287 CameraPane.SWITCH = temp;
36174288
4289
+ RefreshSelection();
36184290 //assert(hashtable.isEmpty());
36194291
36204292 copy.Touch();
....@@ -3635,56 +4307,144 @@
36354307 }
36364308 }
36374309
3638
- refreshContents();
4310
+ refreshContents(true);
36394311 }
36404312
3641
- cButton undoButton;
3642
- cButton redoButton;
4313
+ cButton previousVersionButton;
4314
+ cButton restoreButton;
4315
+ cButton replaceButton;
4316
+ cButton nextVersionButton;
4317
+ cButton saveVersionButton;
4318
+ cButton deleteVersionButton;
36434319
3644
- void SetUndoStates()
4320
+ boolean muteSlider;
4321
+
4322
+ int VersionCount()
36454323 {
3646
- cRadio tab = GetCurrentTab();
4324
+ int count = 0;
36474325
3648
- undoButton.setEnabled(tab.undoindex > 0);
3649
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
4326
+ for (int i = copy.versionlist.length; --i >= 0;)
4327
+ {
4328
+ if (copy.versionlist[i] != null)
4329
+ count++;
4330
+ }
4331
+
4332
+ return count;
36504333 }
36514334
3652
- public void Undo()
4335
+ void SetVersionStates()
36534336 {
4337
+ //if (true)
4338
+ // return;
4339
+
4340
+ //cRadio tab = GetCurrentTab();
4341
+
4342
+ restoreButton.setEnabled(copy.versionindex != -1);
4343
+ replaceButton.setEnabled(copy.versionindex != -1);
4344
+
4345
+ previousVersionButton.setEnabled(copy.versionindex > 0);
4346
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
4347
+
4348
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
4349
+ copy.versionlist[copy.versionindex + 1] != null);
4350
+
4351
+ muteSlider = true;
4352
+ versionSlider.setMinimum(0);
4353
+ versionSlider.setMaximum(VersionCount() - 1);
4354
+ versionSlider.setInteger(copy.versionindex);
4355
+ versionSlider.setEnabled(copy.versionindex != -1);
4356
+ muteSlider = false;
4357
+ }
4358
+
4359
+ public boolean PreviousVersion()
4360
+ {
4361
+ // Option?
4362
+ Replace();
4363
+
36544364 System.err.println("Undo");
36554365
3656
- cRadio tab = GetCurrentTab();
4366
+ //cRadio tab = GetCurrentTab();
36574367
3658
- if (tab.undoindex == 0)
4368
+ if (copy.versionindex == 0)
36594369 {
36604370 java.awt.Toolkit.getDefaultToolkit().beep();
3661
- return;
4371
+ return false;
36624372 }
36634373
3664
- if (tab.graphs[tab.undoindex] == null)
3665
- {
3666
- Save();
3667
- tab.undoindex -= 1;
3668
- }
4374
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
4375
+// {
4376
+// if (Save(false))
4377
+// tab.versionindex -= 1;
4378
+// else
4379
+// {
4380
+// if (tab.versionindex <= 0)
4381
+// return false;
4382
+// else
4383
+// tab.versionindex -= 1;
4384
+// }
4385
+// }
36694386
3670
- tab.undoindex -= 1;
4387
+ copy.versionindex -= 1;
36714388
3672
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4389
+ CopyChanged();
4390
+
4391
+ return true;
36734392 }
36744393
3675
- public void Redo()
4394
+ public boolean Restore()
36764395 {
3677
- cRadio tab = GetCurrentTab();
4396
+ System.err.println("Restore");
36784397
3679
- if (tab.graphs[tab.undoindex + 1] == null)
4398
+ //cRadio tab = GetCurrentTab();
4399
+
4400
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4401
+ {
4402
+ java.awt.Toolkit.getDefaultToolkit().beep();
4403
+ return false;
4404
+ }
4405
+
4406
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4407
+ CopyChanged();
4408
+
4409
+ return true;
4410
+ }
4411
+
4412
+ public boolean Replace()
4413
+ {
4414
+ System.err.println("Replace");
4415
+
4416
+ //cRadio tab = GetCurrentTab();
4417
+
4418
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4419
+ {
4420
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4421
+ return false;
4422
+ }
4423
+
4424
+ copy.versionlist[copy.versionindex] = Duplicate(copy);
4425
+
4426
+ return true;
4427
+ }
4428
+
4429
+ public void NextVersion()
4430
+ {
4431
+ // Option?
4432
+ Replace();
4433
+
4434
+ //cRadio tab = GetCurrentTab();
4435
+
4436
+ if (copy.versionlist[copy.versionindex + 1] == null)
36804437 {
36814438 java.awt.Toolkit.getDefaultToolkit().beep();
36824439 return;
36834440 }
36844441
3685
- tab.undoindex += 1;
4442
+ copy.versionindex += 1;
36864443
3687
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4444
+ CopyChanged();
4445
+
4446
+ //if (!tab.user[tab.versionindex])
4447
+ // tab.graphs[tab.versionindex] = null;
36884448 }
36894449
36904450 void ImportGFD()
....@@ -3895,7 +4655,7 @@
38954655 //copy.material = new cMaterial(copy.GetMaterial());
38964656
38974657 current.color = (float) colorField.getFloat();
3898
- current.modulation = (float) modulationField.getFloat();
4658
+ current.modulation = (float) saturationField.getFloat();
38994659 current.metalness = (float) metalnessField.getFloat();
39004660 current.diffuse = (float) diffuseField.getFloat();
39014661 current.specular = (float) specularField.getFloat();
....@@ -3928,7 +4688,7 @@
39284688 cMaterial mat = copy.material;
39294689
39304690 colorField.SetToolTipValue((mat.color));
3931
- modulationField.SetToolTipValue((mat.modulation));
4691
+ saturationField.SetToolTipValue((mat.modulation));
39324692 metalnessField.SetToolTipValue((mat.metalness));
39334693 diffuseField.SetToolTipValue((mat.diffuse));
39344694 specularField.SetToolTipValue((mat.specular));
....@@ -3980,9 +4740,26 @@
39804740 //copy.Touch();
39814741 }
39824742
4743
+ cNumberSlider versionSlider;
4744
+
39834745 public void stateChanged(ChangeEvent e)
39844746 {
39854747 // assert(false);
4748
+ if (e.getSource() == versionSlider)
4749
+ {
4750
+ if (muteSlider)
4751
+ return;
4752
+
4753
+ int version = versionSlider.getInteger();
4754
+
4755
+ if (version != -1 && copy.versionlist[version] != null)
4756
+ {
4757
+ copy.versionindex = version;
4758
+ CopyChanged();
4759
+ }
4760
+
4761
+ return;
4762
+ }
39864763
39874764 if (freezematerial)
39884765 {
....@@ -4018,6 +4795,12 @@
40184795 {
40194796 //System.out.println("stateChanged = " + this);
40204797 materialtouched = true;
4798
+
4799
+ if (Globals.AUTOSATURATE && e.getSource() == colorField && saturationField.getFloat() == 0.001)
4800
+ {
4801
+ saturationField.setFloat(1);
4802
+ }
4803
+
40214804 applySelf();
40224805 //System.out.println("this = " + this);
40234806 //System.out.println("PARENT = " + parent);
....@@ -4317,6 +5100,7 @@
43175100 {
43185101 if (GetTree() != null)
43195102 {
5103
+ GetTree().revalidate();
43205104 GetTree().repaint();
43215105 }
43225106
....@@ -4325,13 +5109,16 @@
43255109 ctrlPanel.validate(); // ? new
43265110 ctrlPanel.repaint();
43275111 }
5112
+
5113
+ if (previousVersionButton != null && copy.versionlist != null)
5114
+ SetVersionStates();
43285115 }
43295116
43305117 static TweenManager tweenManager = new TweenManager();
43315118
43325119 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43335120 {
4334
- if (Globals.SAVEONMAKE) // && resetmodel)
5121
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43355122 Save();
43365123 //Tween.set(thing, 0).target(1).start(tweenManager);
43375124 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4573,7 +5360,9 @@
45735360 readobj.ResetDisplayList();
45745361 } catch (Exception e)
45755362 {
4576
- //e.printStackTrace();
5363
+ if (!e.toString().contains("GZIP"))
5364
+ e.printStackTrace();
5365
+
45775366 try
45785367 {
45795368 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4647,12 +5436,14 @@
46475436
46485437 if (readobj != null)
46495438 {
4650
- if (Globals.SAVEONMAKE)
4651
- Save();
5439
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5440
+ // Save();
46525441 try
46535442 {
46545443 //readobj.deepCopySelf(copy);
46555444 copy.clear(); // june 2014
5445
+ copy.skyboxname = readobj.skyboxname;
5446
+ copy.skyboxext = readobj.skyboxext;
46565447 for (int i = 0; i < readobj.size(); i++)
46575448 {
46585449 Object3D child = readobj.get(i); // reserve(i);
....@@ -4693,6 +5484,7 @@
46935484 }
46945485 } catch (ClassCastException e)
46955486 {
5487
+ e.printStackTrace();
46965488 assert (false);
46975489 Composite c = (Composite) copy;
46985490 c.children.clear();
....@@ -4703,17 +5495,31 @@
47035495 c.addChild(csg);
47045496 }
47055497
5498
+ copy.versionlist = readobj.versionlist;
5499
+ copy.versionindex = readobj.versionindex;
5500
+
5501
+ if (copy.versionlist == null)
5502
+ {
5503
+ // Backward compatibility
5504
+ copy.versionlist = new Object3D[100];
5505
+ copy.versionindex = -1;
5506
+
5507
+ Save(true);
5508
+ }
5509
+
5510
+ //? SetUndoStates();
5511
+
47065512 ResetModel();
47075513 copy.HardTouch(); // recompile?
47085514 refreshContents();
47095515 }
47105516 }
47115517
4712
- void load() // throws ClassNotFoundException
5518
+ void Open() // throws ClassNotFoundException
47135519 {
47145520 if (Grafreed.standAlone)
47155521 {
4716
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5522
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
47175523 browser.show();
47185524 String filename = browser.getFile();
47195525 if (filename != null && filename.length() > 0)
....@@ -4790,6 +5596,8 @@
47905596
47915597 void save()
47925598 {
5599
+ Replace();
5600
+
47935601 if (lastname == null)
47945602 {
47955603 return;
....@@ -4812,6 +5620,7 @@
48125620 //ps.print(buffer.toString());
48135621 } catch (IOException e)
48145622 {
5623
+ e.printStackTrace();
48155624 }
48165625 }
48175626
....@@ -4994,7 +5803,7 @@
49945803 MenuBar menuBar;
49955804 Menu fileMenu;
49965805 MenuItem newItem;
4997
- MenuItem loadItem;
5806
+ MenuItem openItem;
49985807 MenuItem saveItem;
49995808 MenuItem saveAsItem;
50005809 MenuItem exportAsItem;
....@@ -5017,6 +5826,7 @@
50175826 CheckboxMenuItem toggleSwitchItem;
50185827 CheckboxMenuItem toggleRootItem;
50195828 CheckboxMenuItem animationItem;
5829
+ MenuItem archiveItem;
50205830 CheckboxMenuItem toggleHandleItem;
50215831 CheckboxMenuItem togglePaintItem;
50225832 JSplitPane mainPanel;
....@@ -5030,6 +5840,7 @@
50305840 ButtonGroup buttonGroup;
50315841
50325842 cGridBag toolboxPanel;
5843
+ cGridBag skyboxPanel;
50335844 cGridBag materialPanel;
50345845 cGridBag ctrlPanel;
50355846
....@@ -5103,7 +5914,7 @@
51035914 JLabel colorLabel;
51045915 cNumberSlider colorField;
51055916 JLabel modulationLabel;
5106
- cNumberSlider modulationField;
5917
+ cNumberSlider saturationField;
51075918 JLabel metalnessLabel;
51085919 cNumberSlider metalnessField;
51095920 JLabel diffuseLabel;
....@@ -5134,6 +5945,7 @@
51345945 cNumberSlider anisoField;
51355946 JLabel anisoVLabel;
51365947 cNumberSlider anisoVField;
5948
+
51375949 JLabel cameraLabel;
51385950 cNumberSlider cameraField;
51395951 JLabel selfshadowLabel;
....@@ -5148,6 +5960,7 @@
51485960 cNumberSlider fakedepthField;
51495961 JLabel shadowbiasLabel;
51505962 cNumberSlider shadowbiasField;
5963
+
51515964 JLabel bumpLabel;
51525965 cNumberSlider bumpField;
51535966 JLabel noiseLabel;