Normand Briere
2019-08-01 29d5516687020263d3ae0454ce81879a3a450af0
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 byte[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 byte[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
....@@ -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,30 @@
785847 radio.layout.doClick();
786848 //frame.setVisible(true);
787849 }
850
+ frame.validate();
788851 }
852
+
853
+ private byte[] CompressCopy()
854
+ {
855
+ boolean temp = CameraPane.SWITCH;
856
+ CameraPane.SWITCH = false;
857
+
858
+ copy.ExtractBigData(versiontable);
859
+ // if (copy == client)
860
+
861
+ byte[] versions[] = copy.versions;
862
+ copy.versions = null;
863
+
864
+ byte[] compress = Compress(copy);
865
+
866
+ copy.versions = versions;
867
+
868
+ copy.RestoreBigData(versiontable);
869
+
870
+ CameraPane.SWITCH = temp;
871
+
872
+ return compress;
873
+ }
789874
790875 private JTextPane createTextPane()
791876 {
....@@ -917,7 +1002,7 @@
9171002 // NumberSlider vDivsField;
9181003 // JCheckBox endcaps;
9191004 JCheckBox liveCB;
920
- JCheckBox selectCB;
1005
+ JCheckBox selectableCB;
9211006 JCheckBox hideCB;
9221007 JCheckBox link2masterCB;
9231008 JCheckBox markCB;
....@@ -1117,7 +1202,7 @@
11171202 namePanel = new cGridBag();
11181203
11191204 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1205
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211206 oe.ctrlPanel.add(namePanel);
11221207
11231208 oe.ctrlPanel.Return();
....@@ -1129,26 +1214,30 @@
11291214
11301215 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11311216 liveCB.setToolTipText("Animate object");
1132
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1133
- selectCB.setToolTipText("Make object selectable");
1217
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1218
+ selectableCB.setToolTipText("Make object selectable");
11341219 // Return();
1220
+
11351221 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11361222 hideCB.setToolTipText("Hide object");
11371223 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
11381224 markCB.setToolTipText("As animation target transform");
1225
+
1226
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11391227
11401228 setupPanel2 = new cGridBag().setVertical(false);
11411229
11421230 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431231 rewindCB.setToolTipText("Rewind animation");
11441232
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1233
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461234 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471235
1236
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1237
+ link2masterCB.setToolTipText("Attach to support");
1238
+
11481239 if (Globals.ADVANCED)
11491240 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521241 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531242 speedupCB.setToolTipText("Option motion capture");
11541243 }
....@@ -1422,6 +1511,7 @@
14221511 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14231512 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14241513 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1514
+ //XYZPanel.setName("XYZ");
14251515
14261516 /*
14271517 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1459,13 +1549,29 @@
14591549 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14601550 //tmp.setName("Edit");
14611551 objectPanel.add(materialPanel);
1552
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1553
+ objectPanel.setToolTipTextAt(0, "Material panel");
1554
+
14621555 // JPanel north = new JPanel(new BorderLayout());
14631556 // north.setName("Edit");
14641557 // north.add(ctrlPanel, BorderLayout.NORTH);
14651558 // objectPanel.add(north);
14661559 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1560
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1561
+ objectPanel.setToolTipTextAt(1, "Edit panel");
1562
+
1563
+ //if (Globals.ADVANCED)
1564
+ objectPanel.add(infoPanel);
1565
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1566
+ objectPanel.setToolTipTextAt(2, "Info panel");
1567
+
1568
+ objectPanel.add(XYZPanel);
1569
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1570
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB panel");
1571
+
14681572 objectPanel.add(toolboxPanel);
1573
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1574
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
14691575
14701576 /*
14711577 aConstraints.gridx = 0;
....@@ -1486,7 +1592,7 @@
14861592 scrollpane.addMouseWheelListener(this); // Default not fast enough
14871593
14881594 /*JTabbedPane*/ scenePanel = new cGridBag();
1489
- scenePanel.preferredWidth = 6;
1595
+ scenePanel.preferredWidth = 5;
14901596
14911597 JTabbedPane tabbedPane = new JTabbedPane();
14921598 tabbedPane.add(scrollpane);
....@@ -1564,7 +1670,7 @@
15641670 bigThree = new cGridBag();
15651671 bigThree.addComponent(scenePanel);
15661672 bigThree.addComponent(centralPanel);
1567
- bigThree.addComponent(XYZPanel);
1673
+ //bigThree.addComponent(XYZPanel);
15681674
15691675 // // SIDE EFFECT!!!
15701676 // aConstraints.gridx = 0;
....@@ -1573,9 +1679,9 @@
15731679 // aConstraints.gridheight = 1;
15741680
15751681 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1682
+ framePanel.setContinuousLayout(false);
1683
+ framePanel.setOneTouchExpandable(false);
1684
+ //.setDividerLocation(0.8);
15791685 //framePanel.setDividerSize(15);
15801686 //framePanel.setResizeWeight(0.15);
15811687 framePanel.setName("Frame");
....@@ -1594,17 +1700,17 @@
15941700
15951701 frame.setSize(1280, 860);
15961702
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001703 cameraView.requestFocusInWindow();
16011704
16021705 gridPanel.setDividerLocation(1.0);
1706
+
1707
+ frame.validate();
1708
+
1709
+ frame.setVisible(true);
16031710
16041711 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051712 frame.addWindowListener(new WindowAdapter()
16061713 {
1607
-
16081714 public void windowClosing(WindowEvent e)
16091715 {
16101716 Close();
....@@ -1666,45 +1772,48 @@
16661772 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16671773
16681774 cGridBag colorSection = new cGridBag().setVertical(true);
1775
+
1776
+ cGridBag huepanel = new cGridBag();
1777
+ cGridBag huelabel = new cGridBag();
1778
+ huelabel.add(GetLabel("icons/hue.png", false));
1779
+ huelabel.preferredWidth = 20;
1780
+ huepanel.add(new cGridBag()); // Label
1781
+ huepanel.add(huelabel); // Field/slider
1782
+
1783
+ huepanel.preferredHeight = 7;
1784
+
1785
+ colorSection.add(huepanel);
16691786
16701787 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);
1788
+
1789
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1790
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1791
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1792
+
16741793 //colorField.preferredWidth = 200;
16751794 colorSection.add(color);
16761795
16771796 cGridBag modulation = new cGridBag();
16781797 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16791798 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1680
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1799
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16811800 colorSection.add(modulation);
16821801
1802
+ cGridBag opacity = new cGridBag();
1803
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1804
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1805
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1806
+ colorSection.add(opacity);
1807
+
1808
+ colorSection.add(GetSeparator());
1809
+
16831810 cGridBag texture = new cGridBag();
16841811 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16851812 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16861813 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871814 colorSection.add(texture);
16881815
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());
1816
+ panel.add(GetSeparator());
17081817
17091818 panel.add(colorSection);
17101819
....@@ -1754,7 +1863,13 @@
17541863 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551864 diffuseSection.add(fakedepth);
17561865
1757
- panel.add(new JSeparator());
1866
+ cGridBag shadowbias = new cGridBag();
1867
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1868
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1869
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1870
+ diffuseSection.add(shadowbias);
1871
+
1872
+ panel.add(GetSeparator());
17581873
17591874 panel.add(diffuseSection);
17601875
....@@ -1804,42 +1919,48 @@
18041919 // aConstraints.gridy += 1;
18051920 // aConstraints.gridwidth = 1;
18061921
1922
+ cGridBag anisoU = new cGridBag();
1923
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1924
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1925
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1926
+ specularSection.add(anisoU);
18071927
1808
- panel.add(new JSeparator());
1928
+ cGridBag anisoV = new cGridBag();
1929
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1930
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1931
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1932
+ specularSection.add(anisoV);
1933
+
1934
+
1935
+ panel.add(GetSeparator());
18091936
18101937 panel.add(specularSection);
18111938
18121939 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18131940
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
1941
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18151942
18161943 cGridBag camera = new cGridBag();
18171944 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18181945 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18191946 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
1947
+ colorSection.add(camera);
18211948
18221949 cGridBag ambient = new cGridBag();
18231950 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18241951 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18251952 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
1953
+ colorSection.add(ambient);
18271954
18281955 cGridBag backlit = new cGridBag();
18291956 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18301957 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18311958 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
1959
+ colorSection.add(backlit);
18331960
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());
1961
+ //panel.add(new JSeparator());
18411962
1842
- panel.add(globalSection);
1963
+ //panel.add(globalSection);
18431964
18441965 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18451966
....@@ -1881,7 +2002,7 @@
18812002 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18822003 textureSection.add(opacityPower);
18832004
1884
- panel.add(new JSeparator());
2005
+ panel.add(GetSeparator());
18852006
18862007 panel.add(textureSection);
18872008
....@@ -1946,8 +2067,9 @@
19462067 // 3D models
19472068 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19482069 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
2070
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2071
+ //LoadFile(filename, lastConverter);
2072
+ LoadObjFile(filename); // New 3ds loader
19512073 continue;
19522074 }
19532075 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2795,7 @@
26732795 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752797 }
2798
+
26762799 //cJME.count++;
26772800 //cJME.count %= 12;
26782801 if (gc)
....@@ -2856,6 +2979,7 @@
28562979 }
28572980 }
28582981 }
2982
+
28592983 cFileSystemPane FSPane;
28602984
28612985 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2909,6 +3033,7 @@
29093033 }
29103034 }
29113035 }
3036
+
29123037 freezematerial = false;
29133038 }
29143039
....@@ -3176,7 +3301,7 @@
31763301 {
31773302 copy.live ^= true;
31783303 return;
3179
- } else if (event.getSource() == selectCB)
3304
+ } else if (event.getSource() == selectableCB)
31803305 {
31813306 copy.dontselect ^= true;
31823307 return;
....@@ -3361,9 +3486,9 @@
33613486 {
33623487 Close();
33633488 //return true;
3364
- } else if (source == loadItem)
3489
+ } else if (source == openItem)
33653490 {
3366
- load();
3491
+ Open();
33673492 //return true;
33683493 } else if (source == newItem)
33693494 {
....@@ -3388,6 +3513,10 @@
33883513 {
33893514 generatePOV();
33903515 //return true;
3516
+ } else if (event.getSource() == archiveItem)
3517
+ {
3518
+ cTools.Archive(frame);
3519
+ return;
33913520 } else if (source == zBufferItem)
33923521 {
33933522 try
....@@ -3439,8 +3568,8 @@
34393568 try
34403569 {
34413570 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3571
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3572
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34443573
34453574 Object3D parent = o.parent;
34463575 o.parent = null;
....@@ -3451,10 +3580,14 @@
34513580
34523581 out.flush();
34533582
3454
- zstream.close();
3583
+ baos //zstream
3584
+ .close();
34553585 out.close();
34563586
3457
- return baos.toByteArray();
3587
+ byte[] bytes = baos.toByteArray();
3588
+
3589
+ System.out.println("save #bytes = " + bytes.length);
3590
+ return bytes;
34583591 } catch (Exception e)
34593592 {
34603593 System.err.println(e);
....@@ -3464,13 +3597,16 @@
34643597
34653598 static public Object Uncompress(byte[] bytes)
34663599 {
3467
- System.out.println("#bytes = " + bytes.length);
3600
+ System.out.println("restore #bytes = " + bytes.length);
34683601 try
34693602 {
34703603 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
3604
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3605
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34733606 Object obj = in.readObject();
3607
+
3608
+ bais //istream
3609
+ .close();
34743610 in.close();
34753611
34763612 return obj;
....@@ -3525,31 +3661,67 @@
35253661 return null;
35263662 }
35273663
3528
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35293664
35303665 public void Save()
3666
+ {
3667
+ //Save(true);
3668
+ Replace();
3669
+ }
3670
+
3671
+ private boolean Equal(byte[] compress, byte[] name)
3672
+ {
3673
+ if (compress.length != name.length)
3674
+ {
3675
+ return false;
3676
+ }
3677
+
3678
+ for (int i=compress.length; --i>=0;)
3679
+ {
3680
+ if (compress[i] != name[i])
3681
+ return false;
3682
+ }
3683
+
3684
+ return true;
3685
+ }
3686
+
3687
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3688
+
3689
+ public boolean Save(boolean user)
35313690 {
35323691 System.err.println("Save");
35333692
35343693 cRadio tab = GetCurrentTab();
35353694
3536
- boolean temp = CameraPane.SWITCH;
3537
- CameraPane.SWITCH = false;
3695
+ byte[] compress = CompressCopy(); // Saved version. No need for "Replace".
35383696
3539
- copy.ExtractBigData(hashtable);
3697
+ boolean thesame = false;
3698
+
3699
+ // Quick heuristic using length. Works only when stream is compressed.
3700
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3701
+ {
3702
+ thesame = true;
3703
+ }
35403704
35413705 //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- tab.graphs[tab.undoindex++] = Compress(copy);
3706
+ if (!thesame)
3707
+ {
3708
+ //tab.user[tab.versionindex] = user;
3709
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3710
+
3711
+ copy.versions[++copy.versionindex] = compress;
3712
+
3713
+ // if (increment)
3714
+ // tab.versionindex++;
3715
+ }
35433716
3544
- copy.RestoreBigData(hashtable);
3717
+ //copy.RestoreBigData(versiontable);
35453718
3546
- CameraPane.SWITCH = temp;
3547
-
35483719 //assert(hashtable.isEmpty());
35493720
3550
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3721
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35513722 {
3552
- tab.graphs[i] = null;
3723
+ //tab.user[i] = false;
3724
+ copy.versions[i] = null;
35533725 }
35543726
35553727 SetUndoStates();
....@@ -3559,7 +3731,7 @@
35593731 {
35603732 try
35613733 {
3562
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3734
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35633735 ObjectOutputStream p = new ObjectOutputStream(ostream);
35643736
35653737 p.writeObject(copy);
....@@ -3572,6 +3744,8 @@
35723744 e.printStackTrace();
35733745 }
35743746 }
3747
+
3748
+ return !thesame;
35753749 }
35763750
35773751 void CopyChanged(Object3D obj)
....@@ -3581,16 +3755,19 @@
35813755 boolean temp = CameraPane.SWITCH;
35823756 CameraPane.SWITCH = false;
35833757
3584
- copy.ExtractBigData(hashtable);
3758
+ copy.ExtractBigData(versiontable);
35853759
35863760 copy.clear();
35873761
3762
+ copy.skyboxname = obj.skyboxname;
3763
+ copy.skyboxext = obj.skyboxext;
3764
+
35883765 for (int i=0; i<obj.Size(); i++)
35893766 {
35903767 copy.add(obj.get(i));
35913768 }
35923769
3593
- copy.RestoreBigData(hashtable);
3770
+ copy.RestoreBigData(versiontable);
35943771
35953772 CameraPane.SWITCH = temp;
35963773
....@@ -3618,52 +3795,129 @@
36183795 }
36193796
36203797 cButton undoButton;
3798
+ cButton restoreButton;
3799
+ cButton replaceButton;
36213800 cButton redoButton;
36223801
3802
+ boolean muteSlider;
3803
+
3804
+ int VersionCount()
3805
+ {
3806
+ int count = 0;
3807
+
3808
+ for (int i = copy.versions.length; --i >= 0;)
3809
+ {
3810
+ if (copy.versions[i] != null)
3811
+ count++;
3812
+ }
3813
+
3814
+ return count;
3815
+ }
3816
+
36233817 void SetUndoStates()
36243818 {
36253819 cRadio tab = GetCurrentTab();
36263820
3627
- undoButton.setEnabled(tab.undoindex > 0);
3628
- redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
3821
+ restoreButton.setEnabled(copy.versionindex != -1);
3822
+ replaceButton.setEnabled(copy.versionindex != -1);
3823
+
3824
+ undoButton.setEnabled(copy.versionindex > 0);
3825
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3826
+
3827
+ muteSlider = true;
3828
+ versionSlider.setMaximum(VersionCount() - 1);
3829
+ versionSlider.setInteger(copy.versionindex);
3830
+ muteSlider = false;
36293831 }
36303832
3631
- public void Undo()
3833
+ public boolean Undo()
36323834 {
3835
+ // Option?
3836
+ Replace();
3837
+
36333838 System.err.println("Undo");
36343839
36353840 cRadio tab = GetCurrentTab();
36363841
3637
- if (tab.undoindex == 0)
3842
+ if (copy.versionindex == 0)
36383843 {
36393844 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3845
+ return false;
36413846 }
36423847
3643
- if (tab.graphs[tab.undoindex] == null)
3848
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3849
+// {
3850
+// if (Save(false))
3851
+// tab.versionindex -= 1;
3852
+// else
3853
+// {
3854
+// if (tab.versionindex <= 0)
3855
+// return false;
3856
+// else
3857
+// tab.versionindex -= 1;
3858
+// }
3859
+// }
3860
+
3861
+ copy.versionindex -= 1;
3862
+
3863
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3864
+
3865
+ return true;
3866
+ }
3867
+
3868
+ public boolean Restore()
3869
+ {
3870
+ System.err.println("Restore");
3871
+
3872
+ cRadio tab = GetCurrentTab();
3873
+
3874
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
36443875 {
3645
- Save();
3646
- tab.undoindex -= 1;
3876
+ java.awt.Toolkit.getDefaultToolkit().beep();
3877
+ return false;
36473878 }
36483879
3649
- tab.undoindex -= 1;
3880
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3881
+
3882
+ return true;
3883
+ }
36503884
3651
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3885
+ public boolean Replace()
3886
+ {
3887
+ System.err.println("Replace");
3888
+
3889
+ cRadio tab = GetCurrentTab();
3890
+
3891
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3892
+ {
3893
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3894
+ return false;
3895
+ }
3896
+
3897
+ copy.versions[copy.versionindex] = CompressCopy();
3898
+
3899
+ return true;
36523900 }
36533901
36543902 public void Redo()
36553903 {
3904
+ // Option?
3905
+ Replace();
3906
+
36563907 cRadio tab = GetCurrentTab();
36573908
3658
- if (tab.graphs[tab.undoindex + 1] == null)
3909
+ if (copy.versions[copy.versionindex + 1] == null)
36593910 {
36603911 java.awt.Toolkit.getDefaultToolkit().beep();
36613912 return;
36623913 }
36633914
3664
- tab.undoindex += 1;
3915
+ copy.versionindex += 1;
36653916
3666
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3917
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3918
+
3919
+ //if (!tab.user[tab.versionindex])
3920
+ // tab.graphs[tab.versionindex] = null;
36673921 }
36683922
36693923 void ImportGFD()
....@@ -3959,9 +4213,25 @@
39594213 //copy.Touch();
39604214 }
39614215
4216
+ cNumberSlider versionSlider;
4217
+
39624218 public void stateChanged(ChangeEvent e)
39634219 {
39644220 // assert(false);
4221
+ if (e.getSource() == versionSlider)
4222
+ {
4223
+ if (muteSlider)
4224
+ return;
4225
+
4226
+ int version = versionSlider.getInteger();
4227
+
4228
+ if (copy.versions[version] != null)
4229
+ {
4230
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4231
+ }
4232
+
4233
+ return;
4234
+ }
39654235
39664236 if (freezematerial)
39674237 {
....@@ -4310,7 +4580,7 @@
43104580
43114581 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
43124582 {
4313
- if (Globals.SAVEONMAKE) // && resetmodel)
4583
+ if (Globals.REPLACEONMAKE) // && resetmodel)
43144584 Save();
43154585 //Tween.set(thing, 0).target(1).start(tweenManager);
43164586 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4552,7 +4822,9 @@
45524822 readobj.ResetDisplayList();
45534823 } catch (Exception e)
45544824 {
4555
- //e.printStackTrace();
4825
+ if (!e.toString().contains("GZIP"))
4826
+ e.printStackTrace();
4827
+
45564828 try
45574829 {
45584830 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4626,12 +4898,14 @@
46264898
46274899 if (readobj != null)
46284900 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
4901
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4902
+ // Save();
46314903 try
46324904 {
46334905 //readobj.deepCopySelf(copy);
46344906 copy.clear(); // june 2014
4907
+ copy.skyboxname = readobj.skyboxname;
4908
+ copy.skyboxext = readobj.skyboxext;
46354909 for (int i = 0; i < readobj.size(); i++)
46364910 {
46374911 Object3D child = readobj.get(i); // reserve(i);
....@@ -4672,6 +4946,7 @@
46724946 }
46734947 } catch (ClassCastException e)
46744948 {
4949
+ e.printStackTrace();
46754950 assert (false);
46764951 Composite c = (Composite) copy;
46774952 c.children.clear();
....@@ -4682,13 +4957,24 @@
46824957 c.addChild(csg);
46834958 }
46844959
4960
+ copy.versions = readobj.versions;
4961
+ copy.versionindex = readobj.versionindex;
4962
+
4963
+ if (copy.versions == null)
4964
+ {
4965
+ copy.versions = new byte[100][];
4966
+ copy.versionindex = -1;
4967
+ }
4968
+
4969
+ //? SetUndoStates();
4970
+
46854971 ResetModel();
46864972 copy.HardTouch(); // recompile?
46874973 refreshContents();
46884974 }
46894975 }
46904976
4691
- void load() // throws ClassNotFoundException
4977
+ void Open() // throws ClassNotFoundException
46924978 {
46934979 if (Grafreed.standAlone)
46944980 {
....@@ -4791,6 +5077,7 @@
47915077 //ps.print(buffer.toString());
47925078 } catch (IOException e)
47935079 {
5080
+ e.printStackTrace();
47945081 }
47955082 }
47965083
....@@ -4973,7 +5260,7 @@
49735260 MenuBar menuBar;
49745261 Menu fileMenu;
49755262 MenuItem newItem;
4976
- MenuItem loadItem;
5263
+ MenuItem openItem;
49775264 MenuItem saveItem;
49785265 MenuItem saveAsItem;
49795266 MenuItem exportAsItem;
....@@ -4996,6 +5283,7 @@
49965283 CheckboxMenuItem toggleSwitchItem;
49975284 CheckboxMenuItem toggleRootItem;
49985285 CheckboxMenuItem animationItem;
5286
+ MenuItem archiveItem;
49995287 CheckboxMenuItem toggleHandleItem;
50005288 CheckboxMenuItem togglePaintItem;
50015289 JSplitPane mainPanel;