Normand Briere
2019-08-01 c49ad213b600f844e9070cb09390c3e6d3d13db4
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -38,64 +41,78 @@
3841 JFrame frame;
3942
4043 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
+ }
4152
4253 cButton GetButton(String name, boolean border)
4354 {
44
- try
45
- {
46
- ImageIcon icon = GetIcon(name);
47
- return new cButton(icon, border);
48
- }
49
- catch (Exception e)
50
- {
51
- return new cButton(name, border);
52
- }
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);
5363 }
5464
5565 cToggleButton GetToggleButton(String name, boolean border)
5666 {
57
- try
58
- {
59
- ImageIcon icon = GetIcon(name);
60
- return new cToggleButton(icon, border);
61
- }
62
- catch (Exception e)
63
- {
64
- return new cToggleButton(name, border);
65
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6669 }
6770
6871 cCheckBox GetCheckBox(String name, boolean border)
6972 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7079 try
7180 {
72
- ImageIcon icon = GetIcon(name);
73
- 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;
7497 }
7598 catch (Exception e)
7699 {
77
- return new cCheckBox(name, border);
100
+ return null;
78101 }
79102 }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
82105 {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
86107 {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
95111 }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
99116 }
100117
101118 // SCRIPT
....@@ -279,6 +296,12 @@
279296 client = inClient;
280297 copy = client;
281298
299
+ if (copy.versions == null)
300
+ {
301
+ copy.versions = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
282305 // "this" is not called: SetupUI2(objEditor);
283306 }
284307
....@@ -292,6 +315,12 @@
292315 client = inClient;
293316 copy = client;
294317
318
+ if (copy.versions == null)
319
+ {
320
+ copy.versions = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
295324 SetupUI2(callee.GetEditor());
296325 }
297326
....@@ -306,7 +335,7 @@
306335 //localCopy.parent = null;
307336
308337 frame = new JFrame();
309
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
310339 objEditor = this;
311340 this.callee = callee;
312341
....@@ -324,6 +353,12 @@
324353 copy = localCopy;
325354 copy.editWindow = this;
326355
356
+ if (copy.versions == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
327362 SetupMenu();
328363
329364 //SetupName(objEditor); // new
....@@ -347,7 +382,7 @@
347382 frame.setMenuBar(menuBar = new MenuBar());
348383 menuBar.add(fileMenu = new Menu("File"));
349384 fileMenu.add(newItem = new MenuItem("New"));
350
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
351386
352387 //oe.menuBar.add(menu = new Menu("Include"));
353388 Menu menu = new Menu("Import");
....@@ -379,7 +414,7 @@
379414 }
380415
381416 newItem.addActionListener(this);
382
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
383418 saveItem.addActionListener(this);
384419 saveAsItem.addActionListener(this);
385420 exportAsItem.addActionListener(this);
....@@ -416,11 +451,12 @@
416451
417452 toolbarPanel = new JPanel();
418453 toolbarPanel.setName("Toolbar");
454
+
419455 treePanel = new cGridBag();
420456 treePanel.setName("Tree");
421457
422458 editPanel = new cGridBag().setVertical(true);
423
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
424460
425461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
426462
....@@ -428,11 +464,11 @@
428464 editPanel.add(editCommandsPanel);
429465 editPanel.add(ctrlPanel);
430466
431
- toolboxPanel = new cGridBag().setVertical(false);
432
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
433469
434470 materialPanel = new cGridBag().setVertical(true);
435
- materialPanel.setName("Material");
471
+ //materialPanel.setName("Material");
436472
437473 /*JTextPane*/
438474 infoarea = createTextPane();
....@@ -440,14 +476,15 @@
440476
441477 infoarea.setEditable(true);
442478 SetText();
479
+
443480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
444481 // infoarea.setOpaque(false);
445482 // //infoarea.setForeground(textcolor);
446483 // TEXTAREA infoarea.setLineWrap(true);
447484 // TEXTAREA infoarea.setWrapStyleWord(true);
448485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
449
- infoPanel.setPreferredSize(new Dimension(50, 200));
450
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
451488 //infoPanel.setLayout(new BorderLayout());
452489 //infoPanel.add(createTextPane());
453490
....@@ -458,7 +495,14 @@
458495 mainPanel.setDividerSize(9);
459496 mainPanel.setDividerLocation(0.5); //1.0);
460497 mainPanel.setResizeWeight(0.5);
461
-
498
+
499
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
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!"));
503
+
504
+ mainPanel.setUI(new BasicSplitPaneUI());
505
+
462506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
463507 //mainPanel.setLayout(new GridBagLayout());
464508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -689,8 +733,8 @@
689733 }
690734 }
691735
692
-static GraphicsDevice device = GraphicsEnvironment
693
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
694738
695739 Rectangle keeprect;
696740 cRadio radio;
....@@ -711,10 +755,19 @@
711755 void Minimize()
712756 {
713757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
714759 }
715760
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={}
716764 void Maximize()
717765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
718771 if (maximized)
719772 {
720773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -722,22 +775,36 @@
722775 else
723776 {
724777 keeprect = frame.getBounds();
725
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
726
- Dimension rect2 = frame.getToolkit().getScreenSize();
727
- 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);
728781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
729783 }
730784
731785 maximized ^= true;
786
+
787
+ frame.validate();
732788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
733793
734794 void ToggleFullScreen()
735795 {
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
736798 cameraView.ToggleFullScreen();
737799
738800 if (!CameraPane.FULLSCREEN)
739801 {
740802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
741808 //frame.setVisible(false);
742809 // frame.removeNotify();
743810 // frame.setUndecorated(false);
....@@ -747,7 +814,7 @@
747814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
748815 // X framePanel.add(bigThree);
749816 // X frame.getContentPane().add(/*"Center",*/framePanel);
750
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
751818
752819 //frame.setVisible(true);
753820 radio.layout = keepButton;
....@@ -762,7 +829,12 @@
762829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
763830 // frame.getToolkit().getScreenSize().height);
764831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
765835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
766838 // frame.removeNotify();
767839 // frame.setUndecorated(true);
768840 // frame.addNotify();
....@@ -775,7 +847,31 @@
775847 radio.layout.doClick();
776848 //frame.setVisible(true);
777849 }
850
+ frame.validate();
778851 }
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
+ }
779875
780876 private JTextPane createTextPane()
781877 {
....@@ -907,7 +1003,7 @@
9071003 // NumberSlider vDivsField;
9081004 // JCheckBox endcaps;
9091005 JCheckBox liveCB;
910
- JCheckBox selectCB;
1006
+ JCheckBox selectableCB;
9111007 JCheckBox hideCB;
9121008 JCheckBox link2masterCB;
9131009 JCheckBox markCB;
....@@ -1107,7 +1203,7 @@
11071203 namePanel = new cGridBag();
11081204
11091205 nameField = AddText(namePanel, copy.GetName());
1110
- namePanel.add(nameField);
1206
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11111207 oe.ctrlPanel.add(namePanel);
11121208
11131209 oe.ctrlPanel.Return();
....@@ -1119,26 +1215,30 @@
11191215
11201216 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11211217 liveCB.setToolTipText("Animate object");
1122
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1123
- selectCB.setToolTipText("Make object selectable");
1218
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1219
+ selectableCB.setToolTipText("Make object selectable");
11241220 // Return();
1221
+
11251222 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11261223 hideCB.setToolTipText("Hide object");
11271224 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1128
- markCB.setToolTipText("Set the animation target transform");
1225
+ markCB.setToolTipText("As animation target transform");
1226
+
1227
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11291228
11301229 setupPanel2 = new cGridBag().setVertical(false);
11311230
11321231 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11331232 rewindCB.setToolTipText("Rewind animation");
11341233
1135
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1136
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1234
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1235
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11371236
1237
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1238
+ link2masterCB.setToolTipText("Attach to support");
1239
+
11381240 if (Globals.ADVANCED)
11391241 {
1140
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1141
- link2masterCB.setToolTipText("Attach to support");
11421242 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11431243 speedupCB.setToolTipText("Option motion capture");
11441244 }
....@@ -1412,6 +1512,7 @@
14121512 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14131513 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14141514 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1515
+ //XYZPanel.setName("XYZ");
14151516
14161517 /*
14171518 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1449,13 +1550,29 @@
14491550 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14501551 //tmp.setName("Edit");
14511552 objectPanel.add(materialPanel);
1553
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1554
+ objectPanel.setToolTipTextAt(0, "Material panel");
1555
+
14521556 // JPanel north = new JPanel(new BorderLayout());
14531557 // north.setName("Edit");
14541558 // north.add(ctrlPanel, BorderLayout.NORTH);
14551559 // objectPanel.add(north);
14561560 objectPanel.add(editPanel);
1457
- 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
+
14581573 objectPanel.add(toolboxPanel);
1574
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1575
+ objectPanel.setToolTipTextAt(4, "Objects/backgrounds panel");
14591576
14601577 /*
14611578 aConstraints.gridx = 0;
....@@ -1476,7 +1593,7 @@
14761593 scrollpane.addMouseWheelListener(this); // Default not fast enough
14771594
14781595 /*JTabbedPane*/ scenePanel = new cGridBag();
1479
- scenePanel.preferredWidth = 6;
1596
+ scenePanel.preferredWidth = 5;
14801597
14811598 JTabbedPane tabbedPane = new JTabbedPane();
14821599 tabbedPane.add(scrollpane);
....@@ -1554,7 +1671,7 @@
15541671 bigThree = new cGridBag();
15551672 bigThree.addComponent(scenePanel);
15561673 bigThree.addComponent(centralPanel);
1557
- bigThree.addComponent(XYZPanel);
1674
+ //bigThree.addComponent(XYZPanel);
15581675
15591676 // // SIDE EFFECT!!!
15601677 // aConstraints.gridx = 0;
....@@ -1563,9 +1680,9 @@
15631680 // aConstraints.gridheight = 1;
15641681
15651682 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1566
- framePanel.setContinuousLayout(true);
1567
- framePanel.setOneTouchExpandable(true);
1568
- framePanel.setDividerLocation(0.8);
1683
+ framePanel.setContinuousLayout(false);
1684
+ framePanel.setOneTouchExpandable(false);
1685
+ //.setDividerLocation(0.8);
15691686 //framePanel.setDividerSize(15);
15701687 //framePanel.setResizeWeight(0.15);
15711688 framePanel.setName("Frame");
....@@ -1584,17 +1701,17 @@
15841701
15851702 frame.setSize(1280, 860);
15861703
1587
- frame.validate();
1588
- frame.setVisible(true);
1589
-
15901704 cameraView.requestFocusInWindow();
15911705
15921706 gridPanel.setDividerLocation(1.0);
1707
+
1708
+ frame.validate();
1709
+
1710
+ frame.setVisible(true);
15931711
15941712 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15951713 frame.addWindowListener(new WindowAdapter()
15961714 {
1597
-
15981715 public void windowClosing(WindowEvent e)
15991716 {
16001717 Close();
....@@ -1656,45 +1773,48 @@
16561773 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16571774
16581775 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);
16591787
16601788 cGridBag color = new cGridBag();
1661
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1662
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1663
- 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
+
16641794 //colorField.preferredWidth = 200;
16651795 colorSection.add(color);
16661796
16671797 cGridBag modulation = new cGridBag();
16681798 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16691799 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1670
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1800
+ modulation.add(modulationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16711801 colorSection.add(modulation);
16721802
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
+
16731811 cGridBag texture = new cGridBag();
16741812 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16751813 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16761814 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16771815 colorSection.add(texture);
16781816
1679
- cGridBag anisoU = new cGridBag();
1680
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1681
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1682
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1683
- colorSection.add(anisoU);
1684
-
1685
- cGridBag anisoV = new cGridBag();
1686
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1687
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1688
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1689
- colorSection.add(anisoV);
1690
-
1691
- cGridBag shadowbias = new cGridBag();
1692
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1693
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1694
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1695
- colorSection.add(shadowbias);
1696
-
1697
- panel.add(new JSeparator());
1817
+ panel.add(GetSeparator());
16981818
16991819 panel.add(colorSection);
17001820
....@@ -1744,7 +1864,13 @@
17441864 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17451865 diffuseSection.add(fakedepth);
17461866
1747
- 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());
17481874
17491875 panel.add(diffuseSection);
17501876
....@@ -1794,42 +1920,48 @@
17941920 // aConstraints.gridy += 1;
17951921 // aConstraints.gridwidth = 1;
17961922
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);
17971928
1798
- 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());
17991937
18001938 panel.add(specularSection);
18011939
18021940 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18031941
1804
- cGridBag globalSection = new cGridBag().setVertical(true);
1942
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18051943
18061944 cGridBag camera = new cGridBag();
18071945 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18081946 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18091947 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1810
- globalSection.add(camera);
1948
+ colorSection.add(camera);
18111949
18121950 cGridBag ambient = new cGridBag();
18131951 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18141952 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18151953 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1816
- globalSection.add(ambient);
1954
+ colorSection.add(ambient);
18171955
18181956 cGridBag backlit = new cGridBag();
18191957 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18201958 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18211959 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1822
- globalSection.add(backlit);
1960
+ colorSection.add(backlit);
18231961
1824
- cGridBag opacity = new cGridBag();
1825
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1826
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1827
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1828
- globalSection.add(opacity);
1829
-
1830
- panel.add(new JSeparator());
1962
+ //panel.add(new JSeparator());
18311963
1832
- panel.add(globalSection);
1964
+ //panel.add(globalSection);
18331965
18341966 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18351967
....@@ -1871,7 +2003,7 @@
18712003 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18722004 textureSection.add(opacityPower);
18732005
1874
- panel.add(new JSeparator());
2006
+ panel.add(GetSeparator());
18752007
18762008 panel.add(textureSection);
18772009
....@@ -1936,8 +2068,9 @@
19362068 // 3D models
19372069 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19382070 {
1939
- lastConverter = new com.jmex.model.converters.MaxToJme();
1940
- LoadFile(filename, lastConverter);
2071
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2072
+ //LoadFile(filename, lastConverter);
2073
+ LoadObjFile(filename); // New 3ds loader
19412074 continue;
19422075 }
19432076 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2663,6 +2796,7 @@
26632796 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26642797 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26652798 }
2799
+
26662800 //cJME.count++;
26672801 //cJME.count %= 12;
26682802 if (gc)
....@@ -2846,6 +2980,7 @@
28462980 }
28472981 }
28482982 }
2983
+
28492984 cFileSystemPane FSPane;
28502985
28512986 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2899,6 +3034,7 @@
28993034 }
29003035 }
29013036 }
3037
+
29023038 freezematerial = false;
29033039 }
29043040
....@@ -3017,12 +3153,17 @@
30173153 // }
30183154
30193155 /**/
3020
- if (deselect)
3156
+ if (deselect || child == null)
30213157 {
30223158 //group.deselectAll();
30233159 //freeze = true;
30243160 GetTree().clearSelection();
30253161 //freeze = false;
3162
+
3163
+ if (child == null)
3164
+ {
3165
+ return;
3166
+ }
30263167 }
30273168
30283169 //group.addSelectee(child);
....@@ -3161,7 +3302,7 @@
31613302 {
31623303 copy.live ^= true;
31633304 return;
3164
- } else if (event.getSource() == selectCB)
3305
+ } else if (event.getSource() == selectableCB)
31653306 {
31663307 copy.dontselect ^= true;
31673308 return;
....@@ -3346,9 +3487,9 @@
33463487 {
33473488 Close();
33483489 //return true;
3349
- } else if (source == loadItem)
3490
+ } else if (source == openItem)
33503491 {
3351
- load();
3492
+ Open();
33523493 //return true;
33533494 } else if (source == newItem)
33543495 {
....@@ -3373,6 +3514,10 @@
33733514 {
33743515 generatePOV();
33753516 //return true;
3517
+ } else if (event.getSource() == archiveItem)
3518
+ {
3519
+ cTools.Archive(frame);
3520
+ return;
33763521 } else if (source == zBufferItem)
33773522 {
33783523 try
....@@ -3421,11 +3566,12 @@
34213566
34223567 static public byte[] Compress(Object3D o)
34233568 {
3569
+ // Slower to actually compress.
34243570 try
34253571 {
34263572 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3427
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3428
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3573
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3574
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34293575
34303576 Object3D parent = o.parent;
34313577 o.parent = null;
....@@ -3436,10 +3582,14 @@
34363582
34373583 out.flush();
34383584
3439
- zstream.close();
3585
+ baos //zstream
3586
+ .close();
34403587 out.close();
34413588
3442
- return baos.toByteArray();
3589
+ byte[] bytes = baos.toByteArray();
3590
+
3591
+ System.out.println("save #bytes = " + bytes.length);
3592
+ return bytes;
34433593 } catch (Exception e)
34443594 {
34453595 System.err.println(e);
....@@ -3449,13 +3599,16 @@
34493599
34503600 static public Object Uncompress(byte[] bytes)
34513601 {
3452
- System.out.println("#bytes = " + bytes.length);
3602
+ System.out.println("restore #bytes = " + bytes.length);
34533603 try
34543604 {
34553605 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3456
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3457
- ObjectInputStream in = new ObjectInputStream(istream);
3606
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3607
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34583608 Object obj = in.readObject();
3609
+
3610
+ bais //istream
3611
+ .close();
34593612 in.close();
34603613
34613614 return obj;
....@@ -3510,31 +3663,66 @@
35103663 return null;
35113664 }
35123665
3513
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35143666
35153667 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)
35163692 {
35173693 System.err.println("Save");
35183694
35193695 cRadio tab = GetCurrentTab();
35203696
3521
- boolean temp = CameraPane.SWITCH;
3522
- CameraPane.SWITCH = false;
3697
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
35233698
3524
- 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
+// }
35253705
35263706 //EditorFrame.m_MainFrame.requestFocusInWindow();
3527
- 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
+ }
35283717
3529
- copy.RestoreBigData(hashtable);
3718
+ //copy.RestoreBigData(versiontable);
35303719
3531
- CameraPane.SWITCH = temp;
3532
-
35333720 //assert(hashtable.isEmpty());
35343721
3535
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3722
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
35363723 {
3537
- tab.graphs[i] = null;
3724
+ //tab.user[i] = false;
3725
+ copy.versions[i] = null;
35383726 }
35393727
35403728 SetUndoStates();
....@@ -3544,7 +3732,7 @@
35443732 {
35453733 try
35463734 {
3547
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3735
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35483736 ObjectOutputStream p = new ObjectOutputStream(ostream);
35493737
35503738 p.writeObject(copy);
....@@ -3557,6 +3745,8 @@
35573745 e.printStackTrace();
35583746 }
35593747 }
3748
+
3749
+ return !thesame;
35603750 }
35613751
35623752 void CopyChanged(Object3D obj)
....@@ -3566,16 +3756,19 @@
35663756 boolean temp = CameraPane.SWITCH;
35673757 CameraPane.SWITCH = false;
35683758
3569
- copy.ExtractBigData(hashtable);
3759
+ copy.ExtractBigData(versiontable);
35703760
35713761 copy.clear();
35723762
3763
+ copy.skyboxname = obj.skyboxname;
3764
+ copy.skyboxext = obj.skyboxext;
3765
+
35733766 for (int i=0; i<obj.Size(); i++)
35743767 {
35753768 copy.add(obj.get(i));
35763769 }
35773770
3578
- copy.RestoreBigData(hashtable);
3771
+ copy.RestoreBigData(versiontable);
35793772
35803773 CameraPane.SWITCH = temp;
35813774
....@@ -3603,52 +3796,130 @@
36033796 }
36043797
36053798 cButton undoButton;
3799
+ cButton restoreButton;
3800
+ cButton replaceButton;
36063801 cButton redoButton;
36073802
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
+
36083818 void SetUndoStates()
36093819 {
36103820 cRadio tab = GetCurrentTab();
36113821
3612
- undoButton.setEnabled(tab.undoindex > 0);
3613
- 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;
36143832 }
36153833
3616
- public void Undo()
3834
+ public boolean Undo()
36173835 {
3836
+ // Option?
3837
+ Replace();
3838
+
36183839 System.err.println("Undo");
36193840
36203841 cRadio tab = GetCurrentTab();
36213842
3622
- if (tab.undoindex == 0)
3843
+ if (copy.versionindex == 0)
36233844 {
36243845 java.awt.Toolkit.getDefaultToolkit().beep();
3625
- return;
3846
+ return false;
36263847 }
36273848
3628
- 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)
36293876 {
3630
- Save();
3631
- tab.undoindex -= 1;
3877
+ java.awt.Toolkit.getDefaultToolkit().beep();
3878
+ return false;
36323879 }
36333880
3634
- tab.undoindex -= 1;
3881
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3882
+ CopyChanged(copy.versions[copy.versionindex]);
3883
+
3884
+ return true;
3885
+ }
36353886
3636
- 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;
36373902 }
36383903
36393904 public void Redo()
36403905 {
3906
+ // Option?
3907
+ Replace();
3908
+
36413909 cRadio tab = GetCurrentTab();
36423910
3643
- if (tab.graphs[tab.undoindex + 1] == null)
3911
+ if (copy.versions[copy.versionindex + 1] == null)
36443912 {
36453913 java.awt.Toolkit.getDefaultToolkit().beep();
36463914 return;
36473915 }
36483916
3649
- tab.undoindex += 1;
3917
+ copy.versionindex += 1;
36503918
3651
- 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;
36523923 }
36533924
36543925 void ImportGFD()
....@@ -3944,9 +4215,25 @@
39444215 //copy.Touch();
39454216 }
39464217
4218
+ cNumberSlider versionSlider;
4219
+
39474220 public void stateChanged(ChangeEvent e)
39484221 {
39494222 // 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
+ }
39504237
39514238 if (freezematerial)
39524239 {
....@@ -4295,7 +4582,7 @@
42954582
42964583 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42974584 {
4298
- if (Globals.SAVEONMAKE) // && resetmodel)
4585
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42994586 Save();
43004587 //Tween.set(thing, 0).target(1).start(tweenManager);
43014588 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4537,7 +4824,9 @@
45374824 readobj.ResetDisplayList();
45384825 } catch (Exception e)
45394826 {
4540
- //e.printStackTrace();
4827
+ if (!e.toString().contains("GZIP"))
4828
+ e.printStackTrace();
4829
+
45414830 try
45424831 {
45434832 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4611,12 +4900,14 @@
46114900
46124901 if (readobj != null)
46134902 {
4614
- if (Globals.SAVEONMAKE)
4615
- Save();
4903
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4904
+ // Save();
46164905 try
46174906 {
46184907 //readobj.deepCopySelf(copy);
46194908 copy.clear(); // june 2014
4909
+ copy.skyboxname = readobj.skyboxname;
4910
+ copy.skyboxext = readobj.skyboxext;
46204911 for (int i = 0; i < readobj.size(); i++)
46214912 {
46224913 Object3D child = readobj.get(i); // reserve(i);
....@@ -4657,6 +4948,7 @@
46574948 }
46584949 } catch (ClassCastException e)
46594950 {
4951
+ e.printStackTrace();
46604952 assert (false);
46614953 Composite c = (Composite) copy;
46624954 c.children.clear();
....@@ -4667,13 +4959,24 @@
46674959 c.addChild(csg);
46684960 }
46694961
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
+
46704973 ResetModel();
46714974 copy.HardTouch(); // recompile?
46724975 refreshContents();
46734976 }
46744977 }
46754978
4676
- void load() // throws ClassNotFoundException
4979
+ void Open() // throws ClassNotFoundException
46774980 {
46784981 if (Grafreed.standAlone)
46794982 {
....@@ -4776,6 +5079,7 @@
47765079 //ps.print(buffer.toString());
47775080 } catch (IOException e)
47785081 {
5082
+ e.printStackTrace();
47795083 }
47805084 }
47815085
....@@ -4958,7 +5262,7 @@
49585262 MenuBar menuBar;
49595263 Menu fileMenu;
49605264 MenuItem newItem;
4961
- MenuItem loadItem;
5265
+ MenuItem openItem;
49625266 MenuItem saveItem;
49635267 MenuItem saveAsItem;
49645268 MenuItem exportAsItem;
....@@ -4981,6 +5285,7 @@
49815285 CheckboxMenuItem toggleSwitchItem;
49825286 CheckboxMenuItem toggleRootItem;
49835287 CheckboxMenuItem animationItem;
5288
+ MenuItem archiveItem;
49845289 CheckboxMenuItem toggleHandleItem;
49855290 CheckboxMenuItem togglePaintItem;
49865291 JSplitPane mainPanel;