Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
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
....@@ -309,7 +335,7 @@
309335 //localCopy.parent = null;
310336
311337 frame = new JFrame();
312
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
313339 objEditor = this;
314340 this.callee = callee;
315341
....@@ -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
....@@ -699,8 +733,8 @@
699733 }
700734 }
701735
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704738
705739 Rectangle keeprect;
706740 cRadio radio;
....@@ -721,10 +755,19 @@
721755 void Minimize()
722756 {
723757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
724759 }
725760
761
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
762
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
763
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
726764 void Maximize()
727765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
728771 if (maximized)
729772 {
730773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -732,22 +775,36 @@
732775 else
733776 {
734777 keeprect = frame.getBounds();
735
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
736
- Dimension rect2 = frame.getToolkit().getScreenSize();
737
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
738781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
739783 }
740784
741785 maximized ^= true;
786
+
787
+ frame.validate();
742788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
743793
744794 void ToggleFullScreen()
745795 {
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
746798 cameraView.ToggleFullScreen();
747799
748800 if (!CameraPane.FULLSCREEN)
749801 {
750802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
751808 //frame.setVisible(false);
752809 // frame.removeNotify();
753810 // frame.setUndecorated(false);
....@@ -757,7 +814,7 @@
757814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
758815 // X framePanel.add(bigThree);
759816 // X frame.getContentPane().add(/*"Center",*/framePanel);
760
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
761818
762819 //frame.setVisible(true);
763820 radio.layout = keepButton;
....@@ -772,7 +829,12 @@
772829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773830 // frame.getToolkit().getScreenSize().height);
774831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
775835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
776838 // frame.removeNotify();
777839 // frame.setUndecorated(true);
778840 // frame.addNotify();
....@@ -785,7 +847,33 @@
785847 radio.layout.doClick();
786848 //frame.setVisible(true);
787849 }
850
+ frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
788853 }
854
+
855
+ private Object3D CompressCopy()
856
+ {
857
+ boolean temp = CameraPane.SWITCH;
858
+ CameraPane.SWITCH = false;
859
+
860
+ copy.ExtractBigData(versiontable);
861
+ // if (copy == client)
862
+
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
865
+
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
868
+
869
+ copy.versionlist = versions;
870
+
871
+ copy.RestoreBigData(versiontable);
872
+
873
+ CameraPane.SWITCH = temp;
874
+
875
+ return compress;
876
+ }
789877
790878 private JTextPane createTextPane()
791879 {
....@@ -908,6 +996,7 @@
908996 {
909997 SetupMaterial(materialPanel);
910998 }
999
+
9111000 //SetupName();
9121001 //SetupViews();
9131002 }
....@@ -917,7 +1006,7 @@
9171006 // NumberSlider vDivsField;
9181007 // JCheckBox endcaps;
9191008 JCheckBox liveCB;
920
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
9211010 JCheckBox hideCB;
9221011 JCheckBox link2masterCB;
9231012 JCheckBox markCB;
....@@ -1117,7 +1206,7 @@
11171206 namePanel = new cGridBag();
11181207
11191208 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1209
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211210 oe.ctrlPanel.add(namePanel);
11221211
11231212 oe.ctrlPanel.Return();
....@@ -1129,26 +1218,30 @@
11291218
11301219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11311220 liveCB.setToolTipText("Animate object");
1132
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1133
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
11341223 // Return();
1224
+
11351225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11361226 hideCB.setToolTipText("Hide object");
11371227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11381228 markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11391231
11401232 setupPanel2 = new cGridBag().setVertical(false);
11411233
11421234 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431235 rewindCB.setToolTipText("Rewind animation");
11441236
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1237
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461238 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471239
1240
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1241
+ link2masterCB.setToolTipText("Attach to support");
1242
+
11481243 if (Globals.ADVANCED)
11491244 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521245 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531246 speedupCB.setToolTipText("Option motion capture");
11541247 }
....@@ -1422,6 +1515,7 @@
14221515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14231516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14241517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
14251519
14261520 /*
14271521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1459,13 +1553,29 @@
14591553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14601554 //tmp.setName("Edit");
14611555 objectPanel.add(materialPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
14621559 // JPanel north = new JPanel(new BorderLayout());
14631560 // north.setName("Edit");
14641561 // north.add(ctrlPanel, BorderLayout.NORTH);
14651562 // objectPanel.add(north);
14661563 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1564
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
1566
+
1567
+ //if (Globals.ADVANCED)
1568
+ objectPanel.add(infoPanel);
1569
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
1571
+
1572
+ objectPanel.add(XYZPanel);
1573
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1575
+
14681576 objectPanel.add(toolboxPanel);
1577
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
14691579
14701580 /*
14711581 aConstraints.gridx = 0;
....@@ -1486,7 +1596,7 @@
14861596 scrollpane.addMouseWheelListener(this); // Default not fast enough
14871597
14881598 /*JTabbedPane*/ scenePanel = new cGridBag();
1489
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
14901600
14911601 JTabbedPane tabbedPane = new JTabbedPane();
14921602 tabbedPane.add(scrollpane);
....@@ -1564,7 +1674,7 @@
15641674 bigThree = new cGridBag();
15651675 bigThree.addComponent(scenePanel);
15661676 bigThree.addComponent(centralPanel);
1567
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
15681678
15691679 // // SIDE EFFECT!!!
15701680 // aConstraints.gridx = 0;
....@@ -1573,9 +1683,9 @@
15731683 // aConstraints.gridheight = 1;
15741684
15751685 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1686
+ framePanel.setContinuousLayout(false);
1687
+ framePanel.setOneTouchExpandable(false);
1688
+ //.setDividerLocation(0.8);
15791689 //framePanel.setDividerSize(15);
15801690 //framePanel.setResizeWeight(0.15);
15811691 framePanel.setName("Frame");
....@@ -1594,17 +1704,17 @@
15941704
15951705 frame.setSize(1280, 860);
15961706
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001707 cameraView.requestFocusInWindow();
16011708
16021709 gridPanel.setDividerLocation(1.0);
1710
+
1711
+ frame.validate();
1712
+
1713
+ frame.setVisible(true);
16031714
16041715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051716 frame.addWindowListener(new WindowAdapter()
16061717 {
1607
-
16081718 public void windowClosing(WindowEvent e)
16091719 {
16101720 Close();
....@@ -1627,12 +1737,85 @@
16271737 ctrlPanel.removeAll();
16281738 }
16291739
1630
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
16311741 {
1632
- /*
1742
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1743
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1744
+ skin.addMouseListener(new MouseAdapter()
1745
+ {
1746
+ public void mouseClicked(MouseEvent e)
1747
+ {
1748
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1749
+ cMaterial material = object.material;
1750
+
1751
+ // Skin
1752
+ colorField.setFloat(material.color);
1753
+ saturationField.setFloat(material.modulation);
1754
+ subsurfaceField.setFloat(material.subsurface);
1755
+ selfshadowField.setFloat(material.diffuseness);
1756
+ diffusenessField.setFloat(material.factor);
1757
+ shininessField.setFloat(material.shininess);
1758
+ shadowbiasField.setFloat(material.shadowbias);
1759
+ diffuseField.setFloat(material.diffuse);
1760
+ specularField.setFloat(material.specular);
1761
+
1762
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1763
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1764
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1765
+
1766
+ materialtouched = true;
1767
+ applySelf();
1768
+ }
1769
+ });
1770
+ presetpanel.add(skin);
1771
+
1772
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1773
+ rough2.addMouseListener(new MouseAdapter()
1774
+ {
1775
+ public void mouseClicked(MouseEvent e)
1776
+ {
1777
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1778
+ cMaterial material = object.material;
1779
+
1780
+ shininessField.setFloat(material.shininess);
1781
+ velvetField.setFloat(material.velvet);
1782
+
1783
+ materialtouched = true;
1784
+ applySelf();
1785
+ }
1786
+ });
1787
+ presetpanel.add(rough2);
1788
+
1789
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1790
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1791
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1792
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1793
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1794
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1795
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1796
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1797
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1798
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1799
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1800
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1801
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1802
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1803
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1804
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1805
+
1806
+ cGridBag panel = new cGridBag().setVertical(true);
1807
+
1808
+ presetpanel.preferredWidth = 1;
1809
+
1810
+ materialpanel.add(panel);
1811
+ materialpanel.add(presetpanel);
1812
+
1813
+ panel.preferredWidth = 8;
1814
+
1815
+ /*
16331816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16341817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1635
- */
1818
+ */
16361819
16371820 cGridBag editBar = new cGridBag().setVertical(false);
16381821
....@@ -1666,45 +1849,50 @@
16661849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16671850
16681851 cGridBag colorSection = new cGridBag().setVertical(true);
1852
+
1853
+ cGridBag huepanel = new cGridBag();
1854
+ cGridBag huelabel = new cGridBag();
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
1858
+ huelabel.preferredWidth = 20;
1859
+ huepanel.add(new cGridBag()); // Label
1860
+ huepanel.add(huelabel); // Field/slider
1861
+
1862
+ huepanel.preferredHeight = 7;
1863
+
1864
+ colorSection.add(huepanel);
16691865
16701866 cGridBag color = new cGridBag();
1671
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1672
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1673
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1867
+
1868
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1869
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1871
+
16741872 //colorField.preferredWidth = 200;
16751873 colorSection.add(color);
16761874
16771875 cGridBag modulation = new cGridBag();
16781876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16791877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1680
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16811879 colorSection.add(modulation);
16821880
1881
+ cGridBag opacity = new cGridBag();
1882
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1883
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1884
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1885
+ colorSection.add(opacity);
1886
+
1887
+ colorSection.add(GetSeparator());
1888
+
16831889 cGridBag texture = new cGridBag();
16841890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16851891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16861892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871893 colorSection.add(texture);
16881894
1689
- cGridBag anisoU = new cGridBag();
1690
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1691
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1693
- colorSection.add(anisoU);
1694
-
1695
- cGridBag anisoV = new cGridBag();
1696
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1697
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1698
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1699
- colorSection.add(anisoV);
1700
-
1701
- cGridBag shadowbias = new cGridBag();
1702
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1703
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1704
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1705
- colorSection.add(shadowbias);
1706
-
1707
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
17081896
17091897 panel.add(colorSection);
17101898
....@@ -1754,7 +1942,13 @@
17541942 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551943 diffuseSection.add(fakedepth);
17561944
1757
- panel.add(new JSeparator());
1945
+ cGridBag shadowbias = new cGridBag();
1946
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1947
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1948
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1949
+ diffuseSection.add(shadowbias);
1950
+
1951
+ panel.add(GetSeparator());
17581952
17591953 panel.add(diffuseSection);
17601954
....@@ -1804,42 +1998,48 @@
18041998 // aConstraints.gridy += 1;
18051999 // aConstraints.gridwidth = 1;
18062000
2001
+ cGridBag anisoU = new cGridBag();
2002
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2003
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2004
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2005
+ specularSection.add(anisoU);
18072006
1808
- panel.add(new JSeparator());
2007
+ cGridBag anisoV = new cGridBag();
2008
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2009
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2010
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2011
+ specularSection.add(anisoV);
2012
+
2013
+
2014
+ panel.add(GetSeparator());
18092015
18102016 panel.add(specularSection);
18112017
18122018 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18132019
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
2020
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18152021
18162022 cGridBag camera = new cGridBag();
18172023 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18182024 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18192025 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
2026
+ colorSection.add(camera);
18212027
18222028 cGridBag ambient = new cGridBag();
18232029 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18242030 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18252031 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
2032
+ colorSection.add(ambient);
18272033
18282034 cGridBag backlit = new cGridBag();
18292035 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18302036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18312037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
2038
+ colorSection.add(backlit);
18332039
1834
- cGridBag opacity = new cGridBag();
1835
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1836
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1839
-
1840
- panel.add(new JSeparator());
2040
+ //panel.add(new JSeparator());
18412041
1842
- panel.add(globalSection);
2042
+ //panel.add(globalSection);
18432043
18442044 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18452045
....@@ -1881,7 +2081,7 @@
18812081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18822082 textureSection.add(opacityPower);
18832083
1884
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
18852085
18862086 panel.add(textureSection);
18872087
....@@ -1946,8 +2146,9 @@
19462146 // 3D models
19472147 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482148 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2149
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2150
+ //LoadFile(filename, lastConverter);
2151
+ LoadObjFile(filename); // New 3ds loader
19512152 continue;
19522153 }
19532154 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2874,7 @@
26732874 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742875 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752876 }
2877
+
26762878 //cJME.count++;
26772879 //cJME.count %= 12;
26782880 if (gc)
....@@ -2856,6 +3058,7 @@
28563058 }
28573059 }
28583060 }
3061
+
28593062 cFileSystemPane FSPane;
28603063
28613064 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2865,7 +3068,7 @@
28653068
28663069 freezematerial = true;
28673070 colorField.setFloat(mat.color);
2868
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
28693072 metalnessField.setFloat(mat.metalness);
28703073 diffuseField.setFloat(mat.diffuse);
28713074 specularField.setFloat(mat.specular);
....@@ -2909,6 +3112,7 @@
29093112 }
29103113 }
29113114 }
3115
+
29123116 freezematerial = false;
29133117 }
29143118
....@@ -3175,8 +3379,9 @@
31753379 } else if (event.getSource() == liveCB)
31763380 {
31773381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
31783383 return;
3179
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
31803385 {
31813386 copy.dontselect ^= true;
31823387 return;
....@@ -3184,7 +3389,7 @@
31843389 {
31853390 copy.hide ^= true;
31863391 copy.Touch(); // display list issue
3187
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
31883393 return;
31893394 } else if (event.getSource() == link2masterCB)
31903395 {
....@@ -3361,9 +3566,9 @@
33613566 {
33623567 Close();
33633568 //return true;
3364
- } else if (source == loadItem)
3569
+ } else if (source == openItem)
33653570 {
3366
- load();
3571
+ Open();
33673572 //return true;
33683573 } else if (source == newItem)
33693574 {
....@@ -3388,6 +3593,10 @@
33883593 {
33893594 generatePOV();
33903595 //return true;
3596
+ } else if (event.getSource() == archiveItem)
3597
+ {
3598
+ cTools.Archive(frame);
3599
+ return;
33913600 } else if (source == zBufferItem)
33923601 {
33933602 try
....@@ -3436,11 +3645,12 @@
34363645
34373646 static public byte[] Compress(Object3D o)
34383647 {
3648
+ // Slower to actually compress.
34393649 try
34403650 {
34413651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3652
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3653
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34443654
34453655 Object3D parent = o.parent;
34463656 o.parent = null;
....@@ -3451,10 +3661,14 @@
34513661
34523662 out.flush();
34533663
3454
- zstream.close();
3664
+ baos //zstream
3665
+ .close();
34553666 out.close();
34563667
3457
- return baos.toByteArray();
3668
+ byte[] bytes = baos.toByteArray();
3669
+
3670
+ System.out.println("save #bytes = " + bytes.length);
3671
+ return bytes;
34583672 } catch (Exception e)
34593673 {
34603674 System.err.println(e);
....@@ -3464,13 +3678,16 @@
34643678
34653679 static public Object Uncompress(byte[] bytes)
34663680 {
3467
- System.out.println("#bytes = " + bytes.length);
3681
+ System.out.println("restore #bytes = " + bytes.length);
34683682 try
34693683 {
34703684 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
3685
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3686
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34733687 Object obj = in.readObject();
3688
+
3689
+ bais //istream
3690
+ .close();
34743691 in.close();
34753692
34763693 return obj;
....@@ -3525,32 +3742,86 @@
35253742 return null;
35263743 }
35273744
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35293745
35303746 public void Save()
35313747 {
3748
+ //Save(true);
3749
+ Replace();
3750
+ SetUndoStates();
3751
+ }
3752
+
3753
+ private boolean Equal(byte[] compress, byte[] name)
3754
+ {
3755
+ if (compress.length != name.length)
3756
+ {
3757
+ return false;
3758
+ }
3759
+
3760
+ for (int i=compress.length; --i>=0;)
3761
+ {
3762
+ if (compress[i] != name[i])
3763
+ return false;
3764
+ }
3765
+
3766
+ return true;
3767
+ }
3768
+
3769
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3770
+
3771
+ void DeleteVersion()
3772
+ {
3773
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
3774
+ {
3775
+ copy.versionlist[i] = copy.versionlist[i+1];
3776
+ }
3777
+
3778
+ CopyChanged();
3779
+
3780
+ SetUndoStates();
3781
+ }
3782
+
3783
+ public boolean Save(boolean user)
3784
+ {
35323785 System.err.println("Save");
3786
+ //Replace();
35333787
35343788 cRadio tab = GetCurrentTab();
35353789
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
35383791
3539
- copy.ExtractBigData(hashtable);
3792
+ boolean thesame = false;
3793
+
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
35403798
35413799 //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- tab.graphs[tab.undoindex++] = Compress(copy);
3800
+ if (!thesame)
3801
+ {
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
3807
+ //tab.user[tab.versionindex] = user;
3808
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3809
+
3810
+ copy.versionlist[++copy.versionindex] = compress;
3811
+
3812
+ // if (increment)
3813
+ // tab.versionindex++;
3814
+ }
35433815
3544
- copy.RestoreBigData(hashtable);
3816
+ //copy.RestoreBigData(versiontable);
35453817
3546
- CameraPane.SWITCH = temp;
3547
-
35483818 //assert(hashtable.isEmpty());
35493819
3550
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3551
- {
3552
- tab.graphs[i] = null;
3553
- }
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
35543825
35553826 SetUndoStates();
35563827
....@@ -3559,7 +3830,7 @@
35593830 {
35603831 try
35613832 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3833
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35633834 ObjectOutputStream p = new ObjectOutputStream(ostream);
35643835
35653836 p.writeObject(copy);
....@@ -3572,28 +3843,68 @@
35723843 e.printStackTrace();
35733844 }
35743845 }
3846
+
3847
+ return !thesame;
3848
+ }
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
3853
+ {
3854
+ Object3D selection = new Object3D();
3855
+
3856
+ for (int i = 0; i < copy.selection.size(); i++)
3857
+ {
3858
+ Object3D elem = copy.selection.elementAt(i);
3859
+
3860
+ Object3D obj = copy.GetObject(elem.GetUUID());
3861
+
3862
+ if (obj == null)
3863
+ {
3864
+ copy.selection.remove(i--);
3865
+ }
3866
+ else
3867
+ {
3868
+ selection.add(obj);
3869
+ copy.selection.setElementAt(obj, i);
3870
+ }
3871
+ }
3872
+
3873
+ flashIt = false;
3874
+ GetTree().clearSelection();
3875
+ for (int i = 0; i < selection.size(); i++)
3876
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3877
+ flashIt = true;
3878
+
3879
+ //refreshContents(false);
35753880 }
35763881
3577
- void CopyChanged(Object3D obj)
3882
+ void CopyChanged()
35783883 {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
35793886 SetUndoStates();
35803887
35813888 boolean temp = CameraPane.SWITCH;
35823889 CameraPane.SWITCH = false;
35833890
3584
- copy.ExtractBigData(hashtable);
3891
+ copy.ExtractBigData(versiontable);
35853892
35863893 copy.clear();
35873894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
35883898 for (int i=0; i<obj.Size(); i++)
35893899 {
35903900 copy.add(obj.get(i));
35913901 }
35923902
3593
- copy.RestoreBigData(hashtable);
3903
+ copy.RestoreBigData(versiontable);
35943904
35953905 CameraPane.SWITCH = temp;
35963906
3907
+ RefreshSelection();
35973908 //assert(hashtable.isEmpty());
35983909
35993910 copy.Touch();
....@@ -3614,56 +3925,139 @@
36143925 }
36153926 }
36163927
3617
- refreshContents();
3928
+ refreshContents(true);
36183929 }
36193930
3620
- cButton undoButton;
3621
- cButton redoButton;
3931
+ cButton previousVersionButton;
3932
+ cButton restoreButton;
3933
+ cButton replaceButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
36223937
3938
+ boolean muteSlider;
3939
+
3940
+ int VersionCount()
3941
+ {
3942
+ int count = 0;
3943
+
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
3945
+ {
3946
+ if (copy.versionlist[i] != null)
3947
+ count++;
3948
+ }
3949
+
3950
+ return count;
3951
+ }
3952
+
36233953 void SetUndoStates()
36243954 {
36253955 cRadio tab = GetCurrentTab();
36263956
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
3959
+
3960
+ previousVersionButton.setEnabled(copy.versionindex > 0);
3961
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3962
+
3963
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
3964
+ copy.versionlist[copy.versionindex + 1] != null);
3965
+
3966
+ muteSlider = true;
3967
+ versionSlider.setMaximum(VersionCount() - 1);
3968
+ versionSlider.setInteger(copy.versionindex);
3969
+ muteSlider = false;
36293970 }
36303971
3631
- public void Undo()
3972
+ public boolean PreviousVersion()
36323973 {
3974
+ // Option?
3975
+ Replace();
3976
+
36333977 System.err.println("Undo");
36343978
36353979 cRadio tab = GetCurrentTab();
36363980
3637
- if (tab.undoindex == 0)
3981
+ if (copy.versionindex == 0)
36383982 {
36393983 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3984
+ return false;
36413985 }
36423986
3643
- if (tab.graphs[tab.undoindex] == null)
3644
- {
3645
- Save();
3646
- tab.undoindex -= 1;
3647
- }
3987
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3988
+// {
3989
+// if (Save(false))
3990
+// tab.versionindex -= 1;
3991
+// else
3992
+// {
3993
+// if (tab.versionindex <= 0)
3994
+// return false;
3995
+// else
3996
+// tab.versionindex -= 1;
3997
+// }
3998
+// }
36483999
3649
- tab.undoindex -= 1;
4000
+ copy.versionindex -= 1;
36504001
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged();
4003
+
4004
+ return true;
36524005 }
36534006
3654
- public void Redo()
4007
+ public boolean Restore()
36554008 {
4009
+ System.err.println("Restore");
4010
+
36564011 cRadio tab = GetCurrentTab();
36574012
3658
- if (tab.graphs[tab.undoindex + 1] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4014
+ {
4015
+ java.awt.Toolkit.getDefaultToolkit().beep();
4016
+ return false;
4017
+ }
4018
+
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
4021
+
4022
+ return true;
4023
+ }
4024
+
4025
+ public boolean Replace()
4026
+ {
4027
+ System.err.println("Replace");
4028
+
4029
+ cRadio tab = GetCurrentTab();
4030
+
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4032
+ {
4033
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4034
+ return false;
4035
+ }
4036
+
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
4038
+
4039
+ return true;
4040
+ }
4041
+
4042
+ public void NextVersion()
4043
+ {
4044
+ // Option?
4045
+ Replace();
4046
+
4047
+ cRadio tab = GetCurrentTab();
4048
+
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
36594050 {
36604051 java.awt.Toolkit.getDefaultToolkit().beep();
36614052 return;
36624053 }
36634054
3664
- tab.undoindex += 1;
4055
+ copy.versionindex += 1;
36654056
3666
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4057
+ CopyChanged();
4058
+
4059
+ //if (!tab.user[tab.versionindex])
4060
+ // tab.graphs[tab.versionindex] = null;
36674061 }
36684062
36694063 void ImportGFD()
....@@ -3874,7 +4268,7 @@
38744268 //copy.material = new cMaterial(copy.GetMaterial());
38754269
38764270 current.color = (float) colorField.getFloat();
3877
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
38784272 current.metalness = (float) metalnessField.getFloat();
38794273 current.diffuse = (float) diffuseField.getFloat();
38804274 current.specular = (float) specularField.getFloat();
....@@ -3907,7 +4301,7 @@
39074301 cMaterial mat = copy.material;
39084302
39094303 colorField.SetToolTipValue((mat.color));
3910
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
39114305 metalnessField.SetToolTipValue((mat.metalness));
39124306 diffuseField.SetToolTipValue((mat.diffuse));
39134307 specularField.SetToolTipValue((mat.specular));
....@@ -3959,9 +4353,26 @@
39594353 //copy.Touch();
39604354 }
39614355
4356
+ cNumberSlider versionSlider;
4357
+
39624358 public void stateChanged(ChangeEvent e)
39634359 {
39644360 // assert(false);
4361
+ if (e.getSource() == versionSlider)
4362
+ {
4363
+ if (muteSlider)
4364
+ return;
4365
+
4366
+ int version = versionSlider.getInteger();
4367
+
4368
+ if (copy.versionlist[version] != null)
4369
+ {
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
4372
+ }
4373
+
4374
+ return;
4375
+ }
39654376
39664377 if (freezematerial)
39674378 {
....@@ -3997,6 +4408,12 @@
39974408 {
39984409 //System.out.println("stateChanged = " + this);
39994410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
40004417 applySelf();
40014418 //System.out.println("this = " + this);
40024419 //System.out.println("PARENT = " + parent);
....@@ -4296,6 +4713,7 @@
42964713 {
42974714 if (GetTree() != null)
42984715 {
4716
+ GetTree().revalidate();
42994717 GetTree().repaint();
43004718 }
43014719
....@@ -4304,13 +4722,16 @@
43044722 ctrlPanel.validate(); // ? new
43054723 ctrlPanel.repaint();
43064724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
43074728 }
43084729
43094730 static TweenManager tweenManager = new TweenManager();
43104731
43114732 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43124733 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
4734
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43144735 Save();
43154736 //Tween.set(thing, 0).target(1).start(tweenManager);
43164737 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4552,7 +4973,9 @@
45524973 readobj.ResetDisplayList();
45534974 } catch (Exception e)
45544975 {
4555
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
45564979 try
45574980 {
45584981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4626,12 +5049,14 @@
46265049
46275050 if (readobj != null)
46285051 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
5052
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5053
+ // Save();
46315054 try
46325055 {
46335056 //readobj.deepCopySelf(copy);
46345057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
46355060 for (int i = 0; i < readobj.size(); i++)
46365061 {
46375062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4672,6 +5097,7 @@
46725097 }
46735098 } catch (ClassCastException e)
46745099 {
5100
+ e.printStackTrace();
46755101 assert (false);
46765102 Composite c = (Composite) copy;
46775103 c.children.clear();
....@@ -4682,17 +5108,28 @@
46825108 c.addChild(csg);
46835109 }
46845110
5111
+ copy.versionlist = readobj.versionlist;
5112
+ copy.versionindex = readobj.versionindex;
5113
+
5114
+ if (copy.versionlist == null)
5115
+ {
5116
+ copy.versionlist = new Object3D[100];
5117
+ copy.versionindex = -1;
5118
+ }
5119
+
5120
+ //? SetUndoStates();
5121
+
46855122 ResetModel();
46865123 copy.HardTouch(); // recompile?
46875124 refreshContents();
46885125 }
46895126 }
46905127
4691
- void load() // throws ClassNotFoundException
5128
+ void Open() // throws ClassNotFoundException
46925129 {
46935130 if (Grafreed.standAlone)
46945131 {
4695
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46965133 browser.show();
46975134 String filename = browser.getFile();
46985135 if (filename != null && filename.length() > 0)
....@@ -4791,6 +5228,7 @@
47915228 //ps.print(buffer.toString());
47925229 } catch (IOException e)
47935230 {
5231
+ e.printStackTrace();
47945232 }
47955233 }
47965234
....@@ -4973,7 +5411,7 @@
49735411 MenuBar menuBar;
49745412 Menu fileMenu;
49755413 MenuItem newItem;
4976
- MenuItem loadItem;
5414
+ MenuItem openItem;
49775415 MenuItem saveItem;
49785416 MenuItem saveAsItem;
49795417 MenuItem exportAsItem;
....@@ -4996,6 +5434,7 @@
49965434 CheckboxMenuItem toggleSwitchItem;
49975435 CheckboxMenuItem toggleRootItem;
49985436 CheckboxMenuItem animationItem;
5437
+ MenuItem archiveItem;
49995438 CheckboxMenuItem toggleHandleItem;
50005439 CheckboxMenuItem togglePaintItem;
50015440 JSplitPane mainPanel;
....@@ -5082,7 +5521,7 @@
50825521 JLabel colorLabel;
50835522 cNumberSlider colorField;
50845523 JLabel modulationLabel;
5085
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
50865525 JLabel metalnessLabel;
50875526 cNumberSlider metalnessField;
50885527 JLabel diffuseLabel;