Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
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.versions == null)
300
+ {
301
+ copy.versions = 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.versions == null)
319
+ {
320
+ copy.versions = 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.versions == 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
437470 materialPanel = new cGridBag().setVertical(true);
438
- materialPanel.setName("Material");
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
....@@ -463,10 +497,11 @@
463497 mainPanel.setResizeWeight(0.5);
464498
465499 //mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
-// BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
-// divider.setDividerSize(15);
468
-// divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
500
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
501
+ divider.setDividerSize(15);
502
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469503
504
+ mainPanel.setUI(new BasicSplitPaneUI());
470505
471506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
472507 //mainPanel.setLayout(new GridBagLayout());
....@@ -698,8 +733,8 @@
698733 }
699734 }
700735
701
-static GraphicsDevice device = GraphicsEnvironment
702
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
703738
704739 Rectangle keeprect;
705740 cRadio radio;
....@@ -720,10 +755,19 @@
720755 void Minimize()
721756 {
722757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
723759 }
724760
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={}
725764 void Maximize()
726765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
727771 if (maximized)
728772 {
729773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -731,22 +775,36 @@
731775 else
732776 {
733777 keeprect = frame.getBounds();
734
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
735
- Dimension rect2 = frame.getToolkit().getScreenSize();
736
- 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);
737781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
738783 }
739784
740785 maximized ^= true;
786
+
787
+ frame.validate();
741788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
742793
743794 void ToggleFullScreen()
744795 {
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
745798 cameraView.ToggleFullScreen();
746799
747800 if (!CameraPane.FULLSCREEN)
748801 {
749802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
750808 //frame.setVisible(false);
751809 // frame.removeNotify();
752810 // frame.setUndecorated(false);
....@@ -756,7 +814,7 @@
756814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
757815 // X framePanel.add(bigThree);
758816 // X frame.getContentPane().add(/*"Center",*/framePanel);
759
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
760818
761819 //frame.setVisible(true);
762820 radio.layout = keepButton;
....@@ -771,7 +829,12 @@
771829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
772830 // frame.getToolkit().getScreenSize().height);
773831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
774835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
775838 // frame.removeNotify();
776839 // frame.setUndecorated(true);
777840 // frame.addNotify();
....@@ -784,7 +847,31 @@
784847 radio.layout.doClick();
785848 //frame.setVisible(true);
786849 }
850
+ frame.validate();
787851 }
852
+
853
+ private Object3D CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ Object3D versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versions = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
788875
789876 private JTextPane createTextPane()
790877 {
....@@ -916,7 +1003,7 @@
9161003 // NumberSlider vDivsField;
9171004 // JCheckBox endcaps;
9181005 JCheckBox liveCB;
919
- JCheckBox selectCB;
1006
+ JCheckBox selectableCB;
9201007 JCheckBox hideCB;
9211008 JCheckBox link2masterCB;
9221009 JCheckBox markCB;
....@@ -1116,7 +1203,7 @@
11161203 namePanel = new cGridBag();
11171204
11181205 nameField = AddText(namePanel, copy.GetName());
1119
- namePanel.add(nameField);
1206
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11201207 oe.ctrlPanel.add(namePanel);
11211208
11221209 oe.ctrlPanel.Return();
....@@ -1128,26 +1215,30 @@
11281215
11291216 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11301217 liveCB.setToolTipText("Animate object");
1131
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1132
- selectCB.setToolTipText("Make object selectable");
1218
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1219
+ selectableCB.setToolTipText("Make object selectable");
11331220 // Return();
1221
+
11341222 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11351223 hideCB.setToolTipText("Hide object");
11361224 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11371225 markCB.setToolTipText("As animation target transform");
1226
+
1227
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11381228
11391229 setupPanel2 = new cGridBag().setVertical(false);
11401230
11411231 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11421232 rewindCB.setToolTipText("Rewind animation");
11431233
1144
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1234
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11451235 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11461236
1237
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1238
+ link2masterCB.setToolTipText("Attach to support");
1239
+
11471240 if (Globals.ADVANCED)
11481241 {
1149
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1150
- link2masterCB.setToolTipText("Attach to support");
11511242 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11521243 speedupCB.setToolTipText("Option motion capture");
11531244 }
....@@ -1421,6 +1512,7 @@
14211512 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14221513 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14231514 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1515
+ //XYZPanel.setName("XYZ");
14241516
14251517 /*
14261518 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1458,13 +1550,29 @@
14581550 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14591551 //tmp.setName("Edit");
14601552 objectPanel.add(materialPanel);
1553
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
+ objectPanel.setToolTipTextAt(0, "Material panel");
1555
+
14611556 // JPanel north = new JPanel(new BorderLayout());
14621557 // north.setName("Edit");
14631558 // north.add(ctrlPanel, BorderLayout.NORTH);
14641559 // objectPanel.add(north);
14651560 objectPanel.add(editPanel);
1466
- objectPanel.add(infoPanel);
1561
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1562
+ objectPanel.setToolTipTextAt(1, "Edit panel");
1563
+
1564
+ //if (Globals.ADVANCED)
1565
+ objectPanel.add(infoPanel);
1566
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1567
+ objectPanel.setToolTipTextAt(2, "Info panel");
1568
+
1569
+ objectPanel.add(XYZPanel);
1570
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1571
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1572
+
14671573 objectPanel.add(toolboxPanel);
1574
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
14681576
14691577 /*
14701578 aConstraints.gridx = 0;
....@@ -1485,7 +1593,7 @@
14851593 scrollpane.addMouseWheelListener(this); // Default not fast enough
14861594
14871595 /*JTabbedPane*/ scenePanel = new cGridBag();
1488
- scenePanel.preferredWidth = 6;
1596
+ scenePanel.preferredWidth = 5;
14891597
14901598 JTabbedPane tabbedPane = new JTabbedPane();
14911599 tabbedPane.add(scrollpane);
....@@ -1563,7 +1671,7 @@
15631671 bigThree = new cGridBag();
15641672 bigThree.addComponent(scenePanel);
15651673 bigThree.addComponent(centralPanel);
1566
- bigThree.addComponent(XYZPanel);
1674
+ //bigThree.addComponent(XYZPanel);
15671675
15681676 // // SIDE EFFECT!!!
15691677 // aConstraints.gridx = 0;
....@@ -1572,9 +1680,9 @@
15721680 // aConstraints.gridheight = 1;
15731681
15741682 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1575
- framePanel.setContinuousLayout(true);
1576
- framePanel.setOneTouchExpandable(true);
1577
- framePanel.setDividerLocation(0.8);
1683
+ framePanel.setContinuousLayout(false);
1684
+ framePanel.setOneTouchExpandable(false);
1685
+ //.setDividerLocation(0.8);
15781686 //framePanel.setDividerSize(15);
15791687 //framePanel.setResizeWeight(0.15);
15801688 framePanel.setName("Frame");
....@@ -1593,17 +1701,17 @@
15931701
15941702 frame.setSize(1280, 860);
15951703
1596
- frame.validate();
1597
- frame.setVisible(true);
1598
-
15991704 cameraView.requestFocusInWindow();
16001705
16011706 gridPanel.setDividerLocation(1.0);
1707
+
1708
+ frame.validate();
1709
+
1710
+ frame.setVisible(true);
16021711
16031712 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16041713 frame.addWindowListener(new WindowAdapter()
16051714 {
1606
-
16071715 public void windowClosing(WindowEvent e)
16081716 {
16091717 Close();
....@@ -1665,45 +1773,48 @@
16651773 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16661774
16671775 cGridBag colorSection = new cGridBag().setVertical(true);
1776
+
1777
+ cGridBag huepanel = new cGridBag();
1778
+ cGridBag huelabel = new cGridBag();
1779
+ huelabel.add(GetLabel("icons/hue.png", false));
1780
+ huelabel.preferredWidth = 20;
1781
+ huepanel.add(new cGridBag()); // Label
1782
+ huepanel.add(huelabel); // Field/slider
1783
+
1784
+ huepanel.preferredHeight = 7;
1785
+
1786
+ colorSection.add(huepanel);
16681787
16691788 cGridBag color = new cGridBag();
1670
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1671
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1672
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1789
+
1790
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1791
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1792
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1793
+
16731794 //colorField.preferredWidth = 200;
16741795 colorSection.add(color);
16751796
16761797 cGridBag modulation = new cGridBag();
16771798 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16781799 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1679
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1800
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16801801 colorSection.add(modulation);
16811802
1803
+ cGridBag opacity = new cGridBag();
1804
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1805
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1806
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1807
+ colorSection.add(opacity);
1808
+
1809
+ colorSection.add(GetSeparator());
1810
+
16821811 cGridBag texture = new cGridBag();
16831812 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16841813 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16851814 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16861815 colorSection.add(texture);
16871816
1688
- cGridBag anisoU = new cGridBag();
1689
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1690
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1692
- colorSection.add(anisoU);
1693
-
1694
- cGridBag anisoV = new cGridBag();
1695
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1696
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1697
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1698
- colorSection.add(anisoV);
1699
-
1700
- cGridBag shadowbias = new cGridBag();
1701
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1702
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1703
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1704
- colorSection.add(shadowbias);
1705
-
1706
- panel.add(new JSeparator());
1817
+ panel.add(GetSeparator());
17071818
17081819 panel.add(colorSection);
17091820
....@@ -1753,7 +1864,13 @@
17531864 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17541865 diffuseSection.add(fakedepth);
17551866
1756
- panel.add(new JSeparator());
1867
+ cGridBag shadowbias = new cGridBag();
1868
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1869
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1871
+ diffuseSection.add(shadowbias);
1872
+
1873
+ panel.add(GetSeparator());
17571874
17581875 panel.add(diffuseSection);
17591876
....@@ -1803,42 +1920,48 @@
18031920 // aConstraints.gridy += 1;
18041921 // aConstraints.gridwidth = 1;
18051922
1923
+ cGridBag anisoU = new cGridBag();
1924
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1925
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1926
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1927
+ specularSection.add(anisoU);
18061928
1807
- panel.add(new JSeparator());
1929
+ cGridBag anisoV = new cGridBag();
1930
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1931
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1932
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1933
+ specularSection.add(anisoV);
1934
+
1935
+
1936
+ panel.add(GetSeparator());
18081937
18091938 panel.add(specularSection);
18101939
18111940 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18121941
1813
- cGridBag globalSection = new cGridBag().setVertical(true);
1942
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18141943
18151944 cGridBag camera = new cGridBag();
18161945 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18171946 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18181947 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1819
- globalSection.add(camera);
1948
+ colorSection.add(camera);
18201949
18211950 cGridBag ambient = new cGridBag();
18221951 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18231952 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18241953 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1825
- globalSection.add(ambient);
1954
+ colorSection.add(ambient);
18261955
18271956 cGridBag backlit = new cGridBag();
18281957 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18291958 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18301959 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1831
- globalSection.add(backlit);
1960
+ colorSection.add(backlit);
18321961
1833
- cGridBag opacity = new cGridBag();
1834
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1835
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1836
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1837
- globalSection.add(opacity);
1838
-
1839
- panel.add(new JSeparator());
1962
+ //panel.add(new JSeparator());
18401963
1841
- panel.add(globalSection);
1964
+ //panel.add(globalSection);
18421965
18431966 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18441967
....@@ -1880,7 +2003,7 @@
18802003 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18812004 textureSection.add(opacityPower);
18822005
1883
- panel.add(new JSeparator());
2006
+ panel.add(GetSeparator());
18842007
18852008 panel.add(textureSection);
18862009
....@@ -1945,8 +2068,9 @@
19452068 // 3D models
19462069 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19472070 {
1948
- lastConverter = new com.jmex.model.converters.MaxToJme();
1949
- LoadFile(filename, lastConverter);
2071
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2072
+ //LoadFile(filename, lastConverter);
2073
+ LoadObjFile(filename); // New 3ds loader
19502074 continue;
19512075 }
19522076 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2672,6 +2796,7 @@
26722796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26732797 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26742798 }
2799
+
26752800 //cJME.count++;
26762801 //cJME.count %= 12;
26772802 if (gc)
....@@ -2855,6 +2980,7 @@
28552980 }
28562981 }
28572982 }
2983
+
28582984 cFileSystemPane FSPane;
28592985
28602986 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2908,6 +3034,7 @@
29083034 }
29093035 }
29103036 }
3037
+
29113038 freezematerial = false;
29123039 }
29133040
....@@ -3175,7 +3302,7 @@
31753302 {
31763303 copy.live ^= true;
31773304 return;
3178
- } else if (event.getSource() == selectCB)
3305
+ } else if (event.getSource() == selectableCB)
31793306 {
31803307 copy.dontselect ^= true;
31813308 return;
....@@ -3360,9 +3487,9 @@
33603487 {
33613488 Close();
33623489 //return true;
3363
- } else if (source == loadItem)
3490
+ } else if (source == openItem)
33643491 {
3365
- load();
3492
+ Open();
33663493 //return true;
33673494 } else if (source == newItem)
33683495 {
....@@ -3387,6 +3514,10 @@
33873514 {
33883515 generatePOV();
33893516 //return true;
3517
+ } else if (event.getSource() == archiveItem)
3518
+ {
3519
+ cTools.Archive(frame);
3520
+ return;
33903521 } else if (source == zBufferItem)
33913522 {
33923523 try
....@@ -3435,11 +3566,12 @@
34353566
34363567 static public byte[] Compress(Object3D o)
34373568 {
3569
+ // Slower to actually compress.
34383570 try
34393571 {
34403572 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3441
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3442
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3573
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3574
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34433575
34443576 Object3D parent = o.parent;
34453577 o.parent = null;
....@@ -3450,10 +3582,14 @@
34503582
34513583 out.flush();
34523584
3453
- zstream.close();
3585
+ baos //zstream
3586
+ .close();
34543587 out.close();
34553588
3456
- return baos.toByteArray();
3589
+ byte[] bytes = baos.toByteArray();
3590
+
3591
+ System.out.println("save #bytes = " + bytes.length);
3592
+ return bytes;
34573593 } catch (Exception e)
34583594 {
34593595 System.err.println(e);
....@@ -3463,13 +3599,16 @@
34633599
34643600 static public Object Uncompress(byte[] bytes)
34653601 {
3466
- System.out.println("#bytes = " + bytes.length);
3602
+ System.out.println("restore #bytes = " + bytes.length);
34673603 try
34683604 {
34693605 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3470
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3471
- ObjectInputStream in = new ObjectInputStream(istream);
3606
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3607
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34723608 Object obj = in.readObject();
3609
+
3610
+ bais //istream
3611
+ .close();
34733612 in.close();
34743613
34753614 return obj;
....@@ -3524,31 +3663,66 @@
35243663 return null;
35253664 }
35263665
3527
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35283666
35293667 public void Save()
3668
+ {
3669
+ //Save(true);
3670
+ Replace();
3671
+ }
3672
+
3673
+ private boolean Equal(byte[] compress, byte[] name)
3674
+ {
3675
+ if (compress.length != name.length)
3676
+ {
3677
+ return false;
3678
+ }
3679
+
3680
+ for (int i=compress.length; --i>=0;)
3681
+ {
3682
+ if (compress[i] != name[i])
3683
+ return false;
3684
+ }
3685
+
3686
+ return true;
3687
+ }
3688
+
3689
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3690
+
3691
+ public boolean Save(boolean user)
35303692 {
35313693 System.err.println("Save");
35323694
35333695 cRadio tab = GetCurrentTab();
35343696
3535
- boolean temp = CameraPane.SWITCH;
3536
- CameraPane.SWITCH = false;
3697
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
35373698
3538
- copy.ExtractBigData(hashtable);
3699
+ boolean thesame = false;
3700
+
3701
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3702
+// {
3703
+// thesame = true;
3704
+// }
35393705
35403706 //EditorFrame.m_MainFrame.requestFocusInWindow();
3541
- tab.graphs[tab.undoindex++] = Compress(copy);
3707
+ if (!thesame)
3708
+ {
3709
+ //tab.user[tab.versionindex] = user;
3710
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3711
+
3712
+ copy.versions[++copy.versionindex] = compress;
3713
+
3714
+ // if (increment)
3715
+ // tab.versionindex++;
3716
+ }
35423717
3543
- copy.RestoreBigData(hashtable);
3718
+ //copy.RestoreBigData(versiontable);
35443719
3545
- CameraPane.SWITCH = temp;
3546
-
35473720 //assert(hashtable.isEmpty());
35483721
3549
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3722
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35503723 {
3551
- tab.graphs[i] = null;
3724
+ //tab.user[i] = false;
3725
+ copy.versions[i] = null;
35523726 }
35533727
35543728 SetUndoStates();
....@@ -3558,7 +3732,7 @@
35583732 {
35593733 try
35603734 {
3561
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3735
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35623736 ObjectOutputStream p = new ObjectOutputStream(ostream);
35633737
35643738 p.writeObject(copy);
....@@ -3571,6 +3745,8 @@
35713745 e.printStackTrace();
35723746 }
35733747 }
3748
+
3749
+ return !thesame;
35743750 }
35753751
35763752 void CopyChanged(Object3D obj)
....@@ -3580,16 +3756,19 @@
35803756 boolean temp = CameraPane.SWITCH;
35813757 CameraPane.SWITCH = false;
35823758
3583
- copy.ExtractBigData(hashtable);
3759
+ copy.ExtractBigData(versiontable);
35843760
35853761 copy.clear();
35863762
3763
+ copy.skyboxname = obj.skyboxname;
3764
+ copy.skyboxext = obj.skyboxext;
3765
+
35873766 for (int i=0; i<obj.Size(); i++)
35883767 {
35893768 copy.add(obj.get(i));
35903769 }
35913770
3592
- copy.RestoreBigData(hashtable);
3771
+ copy.RestoreBigData(versiontable);
35933772
35943773 CameraPane.SWITCH = temp;
35953774
....@@ -3617,52 +3796,130 @@
36173796 }
36183797
36193798 cButton undoButton;
3799
+ cButton restoreButton;
3800
+ cButton replaceButton;
36203801 cButton redoButton;
36213802
3803
+ boolean muteSlider;
3804
+
3805
+ int VersionCount()
3806
+ {
3807
+ int count = 0;
3808
+
3809
+ for (int i = copy.versions.length; --i >= 0;)
3810
+ {
3811
+ if (copy.versions[i] != null)
3812
+ count++;
3813
+ }
3814
+
3815
+ return count;
3816
+ }
3817
+
36223818 void SetUndoStates()
36233819 {
36243820 cRadio tab = GetCurrentTab();
36253821
3626
- undoButton.setEnabled(tab.undoindex > 0);
3627
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3822
+ restoreButton.setEnabled(copy.versionindex != -1);
3823
+ replaceButton.setEnabled(copy.versionindex != -1);
3824
+
3825
+ undoButton.setEnabled(copy.versionindex > 0);
3826
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3827
+
3828
+ muteSlider = true;
3829
+ versionSlider.setMaximum(VersionCount() - 1);
3830
+ versionSlider.setInteger(copy.versionindex);
3831
+ muteSlider = false;
36283832 }
36293833
3630
- public void Undo()
3834
+ public boolean Undo()
36313835 {
3836
+ // Option?
3837
+ Replace();
3838
+
36323839 System.err.println("Undo");
36333840
36343841 cRadio tab = GetCurrentTab();
36353842
3636
- if (tab.undoindex == 0)
3843
+ if (copy.versionindex == 0)
36373844 {
36383845 java.awt.Toolkit.getDefaultToolkit().beep();
3639
- return;
3846
+ return false;
36403847 }
36413848
3642
- if (tab.graphs[tab.undoindex] == null)
3849
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3850
+// {
3851
+// if (Save(false))
3852
+// tab.versionindex -= 1;
3853
+// else
3854
+// {
3855
+// if (tab.versionindex <= 0)
3856
+// return false;
3857
+// else
3858
+// tab.versionindex -= 1;
3859
+// }
3860
+// }
3861
+
3862
+ copy.versionindex -= 1;
3863
+
3864
+ CopyChanged((Object3D)copy.versions[copy.versionindex]);
3865
+
3866
+ return true;
3867
+ }
3868
+
3869
+ public boolean Restore()
3870
+ {
3871
+ System.err.println("Restore");
3872
+
3873
+ cRadio tab = GetCurrentTab();
3874
+
3875
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36433876 {
3644
- Save();
3645
- tab.undoindex -= 1;
3877
+ java.awt.Toolkit.getDefaultToolkit().beep();
3878
+ return false;
36463879 }
36473880
3648
- tab.undoindex -= 1;
3881
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
+ CopyChanged(copy.versions[copy.versionindex]);
3883
+
3884
+ return true;
3885
+ }
36493886
3650
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3887
+ public boolean Replace()
3888
+ {
3889
+ System.err.println("Replace");
3890
+
3891
+ cRadio tab = GetCurrentTab();
3892
+
3893
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3894
+ {
3895
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3896
+ return false;
3897
+ }
3898
+
3899
+ copy.versions[copy.versionindex] = CompressCopy();
3900
+
3901
+ return true;
36513902 }
36523903
36533904 public void Redo()
36543905 {
3906
+ // Option?
3907
+ Replace();
3908
+
36553909 cRadio tab = GetCurrentTab();
36563910
3657
- if (tab.graphs[tab.undoindex + 1] == null)
3911
+ if (copy.versions[copy.versionindex + 1] == null)
36583912 {
36593913 java.awt.Toolkit.getDefaultToolkit().beep();
36603914 return;
36613915 }
36623916
3663
- tab.undoindex += 1;
3917
+ copy.versionindex += 1;
36643918
3665
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3919
+ CopyChanged(copy.versions[copy.versionindex]);
3920
+
3921
+ //if (!tab.user[tab.versionindex])
3922
+ // tab.graphs[tab.versionindex] = null;
36663923 }
36673924
36683925 void ImportGFD()
....@@ -3958,9 +4215,25 @@
39584215 //copy.Touch();
39594216 }
39604217
4218
+ cNumberSlider versionSlider;
4219
+
39614220 public void stateChanged(ChangeEvent e)
39624221 {
39634222 // assert(false);
4223
+ if (e.getSource() == versionSlider)
4224
+ {
4225
+ if (muteSlider)
4226
+ return;
4227
+
4228
+ int version = versionSlider.getInteger();
4229
+
4230
+ if (copy.versions[version] != null)
4231
+ {
4232
+ CopyChanged(copy.versions[copy.versionindex = version]);
4233
+ }
4234
+
4235
+ return;
4236
+ }
39644237
39654238 if (freezematerial)
39664239 {
....@@ -4309,7 +4582,7 @@
43094582
43104583 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43114584 {
4312
- if (Globals.SAVEONMAKE) // && resetmodel)
4585
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43134586 Save();
43144587 //Tween.set(thing, 0).target(1).start(tweenManager);
43154588 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4551,7 +4824,9 @@
45514824 readobj.ResetDisplayList();
45524825 } catch (Exception e)
45534826 {
4554
- //e.printStackTrace();
4827
+ if (!e.toString().contains("GZIP"))
4828
+ e.printStackTrace();
4829
+
45554830 try
45564831 {
45574832 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4625,12 +4900,14 @@
46254900
46264901 if (readobj != null)
46274902 {
4628
- if (Globals.SAVEONMAKE)
4629
- Save();
4903
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4904
+ // Save();
46304905 try
46314906 {
46324907 //readobj.deepCopySelf(copy);
46334908 copy.clear(); // june 2014
4909
+ copy.skyboxname = readobj.skyboxname;
4910
+ copy.skyboxext = readobj.skyboxext;
46344911 for (int i = 0; i < readobj.size(); i++)
46354912 {
46364913 Object3D child = readobj.get(i); // reserve(i);
....@@ -4671,6 +4948,7 @@
46714948 }
46724949 } catch (ClassCastException e)
46734950 {
4951
+ e.printStackTrace();
46744952 assert (false);
46754953 Composite c = (Composite) copy;
46764954 c.children.clear();
....@@ -4681,13 +4959,24 @@
46814959 c.addChild(csg);
46824960 }
46834961
4962
+ copy.versions = readobj.versions;
4963
+ copy.versionindex = readobj.versionindex;
4964
+
4965
+ if (copy.versions == null)
4966
+ {
4967
+ copy.versions = new Object3D[100];
4968
+ copy.versionindex = -1;
4969
+ }
4970
+
4971
+ //? SetUndoStates();
4972
+
46844973 ResetModel();
46854974 copy.HardTouch(); // recompile?
46864975 refreshContents();
46874976 }
46884977 }
46894978
4690
- void load() // throws ClassNotFoundException
4979
+ void Open() // throws ClassNotFoundException
46914980 {
46924981 if (Grafreed.standAlone)
46934982 {
....@@ -4790,6 +5079,7 @@
47905079 //ps.print(buffer.toString());
47915080 } catch (IOException e)
47925081 {
5082
+ e.printStackTrace();
47935083 }
47945084 }
47955085
....@@ -4972,7 +5262,7 @@
49725262 MenuBar menuBar;
49735263 Menu fileMenu;
49745264 MenuItem newItem;
4975
- MenuItem loadItem;
5265
+ MenuItem openItem;
49765266 MenuItem saveItem;
49775267 MenuItem saveAsItem;
49785268 MenuItem exportAsItem;
....@@ -4995,6 +5285,7 @@
49955285 CheckboxMenuItem toggleSwitchItem;
49965286 CheckboxMenuItem toggleRootItem;
49975287 CheckboxMenuItem animationItem;
5288
+ MenuItem archiveItem;
49985289 CheckboxMenuItem toggleHandleItem;
49995290 CheckboxMenuItem togglePaintItem;
50005291 JSplitPane mainPanel;