Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -37,6 +41,79 @@
3741 JFrame frame;
3842
3943 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
+ }
52
+
53
+ cButton GetButton(String name, boolean border)
54
+ {
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);
63
+ }
64
+
65
+ cToggleButton GetToggleButton(String name, boolean border)
66
+ {
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
69
+ }
70
+
71
+ cCheckBox GetCheckBox(String name, boolean border)
72
+ {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
79
+ try
80
+ {
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;
97
+ }
98
+ catch (Exception e)
99
+ {
100
+ return null;
101
+ }
102
+ }
103
+
104
+ BufferedImage GetImage(String name)
105
+ {
106
+ try
107
+ {
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
111
+ }
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
116
+ }
40117
41118 // SCRIPT
42119
....@@ -147,7 +224,7 @@
147224
148225 objEditor.ctrlPanel.remove(namePanel);
149226
150
- if (!GroupEditor.allparams)
227
+ if (!allparams)
151228 return;
152229
153230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -219,6 +296,12 @@
219296 client = inClient;
220297 copy = client;
221298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
222305 // "this" is not called: SetupUI2(objEditor);
223306 }
224307
....@@ -232,6 +315,12 @@
232315 client = inClient;
233316 copy = client;
234317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
235324 SetupUI2(callee.GetEditor());
236325 }
237326
....@@ -246,7 +335,7 @@
246335 //localCopy.parent = null;
247336
248337 frame = new JFrame();
249
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
250339 objEditor = this;
251340 this.callee = callee;
252341
....@@ -264,6 +353,12 @@
264353 copy = localCopy;
265354 copy.editWindow = this;
266355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
267362 SetupMenu();
268363
269364 //SetupName(objEditor); // new
....@@ -277,12 +372,17 @@
277372 return frame.action(event, obj);
278373 }
279374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
280380 void SetupMenu()
281381 {
282382 frame.setMenuBar(menuBar = new MenuBar());
283383 menuBar.add(fileMenu = new Menu("File"));
284384 fileMenu.add(newItem = new MenuItem("New"));
285
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
286386
287387 //oe.menuBar.add(menu = new Menu("Include"));
288388 Menu menu = new Menu("Import");
....@@ -314,7 +414,7 @@
314414 }
315415
316416 newItem.addActionListener(this);
317
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
318418 saveItem.addActionListener(this);
319419 saveAsItem.addActionListener(this);
320420 exportAsItem.addActionListener(this);
....@@ -323,13 +423,40 @@
323423 closeItem.addActionListener(this);
324424
325425 objectPanel = new JTabbedPane();
426
+
427
+ ChangeListener changeListener = new ChangeListener()
428
+ {
429
+ public void stateChanged(ChangeEvent changeEvent)
430
+ {
431
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
432
+// {
433
+// if (latestObject != null)
434
+// {
435
+// refreshContents(true);
436
+// SetMaterial(latestObject);
437
+// }
438
+//
439
+// materialFlushed = true;
440
+// }
441
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
442
+// {
443
+// if (listUI.size() == 0)
444
+// EditSelection(false);
445
+// }
446
+
447
+ refreshContents(false); // To refresh Info tab
448
+ }
449
+ };
450
+ objectPanel.addChangeListener(changeListener);
451
+
326452 toolbarPanel = new JPanel();
327453 toolbarPanel.setName("Toolbar");
454
+
328455 treePanel = new cGridBag();
329456 treePanel.setName("Tree");
330457
331458 editPanel = new cGridBag().setVertical(true);
332
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
333460
334461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
335462
....@@ -337,23 +464,27 @@
337464 editPanel.add(editCommandsPanel);
338465 editPanel.add(ctrlPanel);
339466
340
- materialPanel = new cGridBag().setVertical(true);
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
341469
342
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
472
+
343473 /*JTextPane*/
344474 infoarea = createTextPane();
345475 doc = infoarea.getStyledDocument();
346476
347477 infoarea.setEditable(true);
348478 SetText();
479
+
349480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
350481 // infoarea.setOpaque(false);
351482 // //infoarea.setForeground(textcolor);
352483 // TEXTAREA infoarea.setLineWrap(true);
353484 // TEXTAREA infoarea.setWrapStyleWord(true);
354485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
355
- infoPanel.setPreferredSize(new Dimension(50, 200));
356
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
357488 //infoPanel.setLayout(new BorderLayout());
358489 //infoPanel.add(createTextPane());
359490
....@@ -364,7 +495,14 @@
364495 mainPanel.setDividerSize(9);
365496 mainPanel.setDividerLocation(0.5); //1.0);
366497 mainPanel.setResizeWeight(0.5);
367
-
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
+
368506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
369507 //mainPanel.setLayout(new GridBagLayout());
370508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -595,8 +733,8 @@
595733 }
596734 }
597735
598
-static GraphicsDevice device = GraphicsEnvironment
599
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
600738
601739 Rectangle keeprect;
602740 cRadio radio;
....@@ -612,13 +750,24 @@
612750
613751 boolean maximized;
614752
753
+ cButton fullscreenLayout;
754
+
615755 void Minimize()
616756 {
617757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
618759 }
619760
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={}
620764 void Maximize()
621765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
622771 if (maximized)
623772 {
624773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -626,20 +775,36 @@
626775 else
627776 {
628777 keeprect = frame.getBounds();
629
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
630
- Dimension rect2 = frame.getToolkit().getScreenSize();
631
- 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);
632781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
633783 }
634784
635785 maximized ^= true;
786
+
787
+ frame.validate();
636788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
637793
638794 void ToggleFullScreen()
639795 {
640
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
641801 {
642802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
643808 //frame.setVisible(false);
644809 // frame.removeNotify();
645810 // frame.setUndecorated(false);
....@@ -649,7 +814,7 @@
649814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
650815 // X framePanel.add(bigThree);
651816 // X frame.getContentPane().add(/*"Center",*/framePanel);
652
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
653818
654819 //frame.setVisible(true);
655820 radio.layout = keepButton;
....@@ -664,7 +829,12 @@
664829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
665830 // frame.getToolkit().getScreenSize().height);
666831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
667835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
668838 // frame.removeNotify();
669839 // frame.setUndecorated(true);
670840 // frame.addNotify();
....@@ -673,13 +843,37 @@
673843 // X frame.getContentPane().add(/*"Center",*/bigThree);
674844 framePanel.setDividerLocation(0);
675845
676
- radio.layout = twoButton;
846
+ radio.layout = fullscreenLayout;
677847 radio.layout.doClick();
678848 //frame.setVisible(true);
679849 }
680
-
681
- cameraView.ToggleFullScreen();
850
+ frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
682853 }
854
+
855
+ private Object3D CompressCopy()
856
+ {
857
+ boolean temp = CameraPane.SWITCH;
858
+ CameraPane.SWITCH = false;
859
+
860
+ copy.ExtractBigData(versiontable);
861
+ // if (copy == client)
862
+
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
865
+
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
868
+
869
+ copy.versionlist = versions;
870
+
871
+ copy.RestoreBigData(versiontable);
872
+
873
+ CameraPane.SWITCH = temp;
874
+
875
+ return compress;
876
+ }
683877
684878 private JTextPane createTextPane()
685879 {
....@@ -802,6 +996,7 @@
802996 {
803997 SetupMaterial(materialPanel);
804998 }
999
+
8051000 //SetupName();
8061001 //SetupViews();
8071002 }
....@@ -811,7 +1006,7 @@
8111006 // NumberSlider vDivsField;
8121007 // JCheckBox endcaps;
8131008 JCheckBox liveCB;
814
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
8151010 JCheckBox hideCB;
8161011 JCheckBox link2masterCB;
8171012 JCheckBox markCB;
....@@ -819,7 +1014,12 @@
8191014 JCheckBox speedupCB;
8201015 JCheckBox rewindCB;
8211016 JCheckBox flipVCB;
1017
+
1018
+ cCheckBox toggleTextureCB;
1019
+ cCheckBox toggleSwitchCB;
1020
+
8221021 JComboBox texresMenu;
1022
+
8231023 JButton resetButton;
8241024 JButton stepButton;
8251025 JButton stepAllButton;
....@@ -1006,38 +1206,42 @@
10061206 namePanel = new cGridBag();
10071207
10081208 nameField = AddText(namePanel, copy.GetName());
1009
- namePanel.add(nameField);
1209
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10101210 oe.ctrlPanel.add(namePanel);
10111211
10121212 oe.ctrlPanel.Return();
10131213
1014
- if (!GroupEditor.allparams)
1214
+ if (!allparams)
10151215 return;
10161216
10171217 setupPanel = new cGridBag().setVertical(false);
10181218
10191219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10201220 liveCB.setToolTipText("Animate object");
1021
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1022
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
10231223 // Return();
1224
+
10241225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10251226 hideCB.setToolTipText("Hide object");
10261227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1027
- markCB.setToolTipText("Set the animation target transform");
1228
+ markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10281231
10291232 setupPanel2 = new cGridBag().setVertical(false);
10301233
10311234 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10321235 rewindCB.setToolTipText("Rewind animation");
10331236
1034
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1035
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1237
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1238
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10361239
1240
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1241
+ link2masterCB.setToolTipText("Attach to support");
1242
+
10371243 if (Globals.ADVANCED)
10381244 {
1039
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1040
- link2masterCB.setToolTipText("Attach to support");
10411245 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10421246 speedupCB.setToolTipText("Option motion capture");
10431247 }
....@@ -1311,6 +1515,7 @@
13111515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13121516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13131517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
13141519
13151520 /*
13161521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1348,12 +1553,29 @@
13481553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13491554 //tmp.setName("Edit");
13501555 objectPanel.add(materialPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
13511559 // JPanel north = new JPanel(new BorderLayout());
13521560 // north.setName("Edit");
13531561 // north.add(ctrlPanel, BorderLayout.NORTH);
13541562 // objectPanel.add(north);
13551563 objectPanel.add(editPanel);
1356
- objectPanel.add(infoPanel);
1564
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
1566
+
1567
+ //if (Globals.ADVANCED)
1568
+ objectPanel.add(infoPanel);
1569
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
1571
+
1572
+ objectPanel.add(XYZPanel);
1573
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1575
+
1576
+ objectPanel.add(toolboxPanel);
1577
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
13571579
13581580 /*
13591581 aConstraints.gridx = 0;
....@@ -1362,7 +1584,7 @@
13621584 aConstraints.gridy += 1;
13631585 aConstraints.gridwidth = 1;
13641586 mainPanel.add(objectPanel, aConstraints);
1365
- */
1587
+ */
13661588
13671589 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13681590 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1374,14 +1596,12 @@
13741596 scrollpane.addMouseWheelListener(this); // Default not fast enough
13751597
13761598 /*JTabbedPane*/ scenePanel = new cGridBag();
1377
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
13781600
13791601 JTabbedPane tabbedPane = new JTabbedPane();
13801602 tabbedPane.add(scrollpane);
13811603
1382
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1383
-
1384
- optionsPanel = new cGridBag().setVertical(true);
1604
+ optionsPanel = new cGridBag().setVertical(false);
13851605
13861606 optionsPanel.setName("Options");
13871607
....@@ -1389,6 +1609,8 @@
13891609
13901610 tabbedPane.add(optionsPanel);
13911611
1612
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1613
+
13921614 scenePanel.add(tabbedPane);
13931615
13941616 /*
....@@ -1452,7 +1674,7 @@
14521674 bigThree = new cGridBag();
14531675 bigThree.addComponent(scenePanel);
14541676 bigThree.addComponent(centralPanel);
1455
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
14561678
14571679 // // SIDE EFFECT!!!
14581680 // aConstraints.gridx = 0;
....@@ -1461,9 +1683,9 @@
14611683 // aConstraints.gridheight = 1;
14621684
14631685 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1464
- framePanel.setContinuousLayout(true);
1465
- framePanel.setOneTouchExpandable(true);
1466
- framePanel.setDividerLocation(0.8);
1686
+ framePanel.setContinuousLayout(false);
1687
+ framePanel.setOneTouchExpandable(false);
1688
+ //.setDividerLocation(0.8);
14671689 //framePanel.setDividerSize(15);
14681690 //framePanel.setResizeWeight(0.15);
14691691 framePanel.setName("Frame");
....@@ -1481,16 +1703,18 @@
14811703 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14821704
14831705 frame.setSize(1280, 860);
1484
- frame.setVisible(true);
1485
-
1706
+
14861707 cameraView.requestFocusInWindow();
14871708
14881709 gridPanel.setDividerLocation(1.0);
1710
+
1711
+ frame.validate();
1712
+
1713
+ frame.setVisible(true);
14891714
14901715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14911716 frame.addWindowListener(new WindowAdapter()
14921717 {
1493
-
14941718 public void windowClosing(WindowEvent e)
14951719 {
14961720 Close();
....@@ -1513,12 +1737,85 @@
15131737 ctrlPanel.removeAll();
15141738 }
15151739
1516
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
15171741 {
1518
- /*
1742
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1743
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1744
+ skin.addMouseListener(new MouseAdapter()
1745
+ {
1746
+ public void mouseClicked(MouseEvent e)
1747
+ {
1748
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1749
+ cMaterial material = object.material;
1750
+
1751
+ // Skin
1752
+ colorField.setFloat(material.color);
1753
+ saturationField.setFloat(material.modulation);
1754
+ subsurfaceField.setFloat(material.subsurface);
1755
+ selfshadowField.setFloat(material.diffuseness);
1756
+ diffusenessField.setFloat(material.factor);
1757
+ shininessField.setFloat(material.shininess);
1758
+ shadowbiasField.setFloat(material.shadowbias);
1759
+ diffuseField.setFloat(material.diffuse);
1760
+ specularField.setFloat(material.specular);
1761
+
1762
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1763
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1764
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1765
+
1766
+ materialtouched = true;
1767
+ applySelf();
1768
+ }
1769
+ });
1770
+ presetpanel.add(skin);
1771
+
1772
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1773
+ rough2.addMouseListener(new MouseAdapter()
1774
+ {
1775
+ public void mouseClicked(MouseEvent e)
1776
+ {
1777
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1778
+ cMaterial material = object.material;
1779
+
1780
+ shininessField.setFloat(material.shininess);
1781
+ velvetField.setFloat(material.velvet);
1782
+
1783
+ materialtouched = true;
1784
+ applySelf();
1785
+ }
1786
+ });
1787
+ presetpanel.add(rough2);
1788
+
1789
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1790
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1791
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1792
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1793
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1794
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1795
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1796
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1797
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1798
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1799
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1800
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1801
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1802
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1803
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1804
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1805
+
1806
+ cGridBag panel = new cGridBag().setVertical(true);
1807
+
1808
+ presetpanel.preferredWidth = 1;
1809
+
1810
+ materialpanel.add(panel);
1811
+ materialpanel.add(presetpanel);
1812
+
1813
+ panel.preferredWidth = 8;
1814
+
1815
+ /*
15191816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
15201817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1521
- */
1818
+ */
15221819
15231820 cGridBag editBar = new cGridBag().setVertical(false);
15241821
....@@ -1552,45 +1849,50 @@
15521849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
15531850
15541851 cGridBag colorSection = new cGridBag().setVertical(true);
1852
+
1853
+ cGridBag huepanel = new cGridBag();
1854
+ cGridBag huelabel = new cGridBag();
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
1858
+ huelabel.preferredWidth = 20;
1859
+ huepanel.add(new cGridBag()); // Label
1860
+ huepanel.add(huelabel); // Field/slider
1861
+
1862
+ huepanel.preferredHeight = 7;
1863
+
1864
+ colorSection.add(huepanel);
15551865
15561866 cGridBag color = new cGridBag();
1557
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1558
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1559
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1867
+
1868
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1869
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1871
+
15601872 //colorField.preferredWidth = 200;
15611873 colorSection.add(color);
15621874
15631875 cGridBag modulation = new cGridBag();
15641876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
15651877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1566
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
15671879 colorSection.add(modulation);
15681880
1881
+ cGridBag opacity = new cGridBag();
1882
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1883
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1884
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1885
+ colorSection.add(opacity);
1886
+
1887
+ colorSection.add(GetSeparator());
1888
+
15691889 cGridBag texture = new cGridBag();
15701890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
15711891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
15721892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15731893 colorSection.add(texture);
15741894
1575
- cGridBag anisoU = new cGridBag();
1576
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1577
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1578
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1579
- colorSection.add(anisoU);
1580
-
1581
- cGridBag anisoV = new cGridBag();
1582
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1583
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1584
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1585
- colorSection.add(anisoV);
1586
-
1587
- cGridBag shadowbias = new cGridBag();
1588
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1589
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1590
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1591
- colorSection.add(shadowbias);
1592
-
1593
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
15941896
15951897 panel.add(colorSection);
15961898
....@@ -1640,7 +1942,13 @@
16401942 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16411943 diffuseSection.add(fakedepth);
16421944
1643
- panel.add(new JSeparator());
1945
+ cGridBag shadowbias = new cGridBag();
1946
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1947
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1948
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1949
+ diffuseSection.add(shadowbias);
1950
+
1951
+ panel.add(GetSeparator());
16441952
16451953 panel.add(diffuseSection);
16461954
....@@ -1690,42 +1998,48 @@
16901998 // aConstraints.gridy += 1;
16911999 // aConstraints.gridwidth = 1;
16922000
2001
+ cGridBag anisoU = new cGridBag();
2002
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2003
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2004
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2005
+ specularSection.add(anisoU);
16932006
1694
- panel.add(new JSeparator());
2007
+ cGridBag anisoV = new cGridBag();
2008
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2009
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2010
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2011
+ specularSection.add(anisoV);
2012
+
2013
+
2014
+ panel.add(GetSeparator());
16952015
16962016 panel.add(specularSection);
16972017
16982018 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16992019
1700
- cGridBag globalSection = new cGridBag().setVertical(true);
2020
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17012021
17022022 cGridBag camera = new cGridBag();
17032023 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17042024 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17052025 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1706
- globalSection.add(camera);
2026
+ colorSection.add(camera);
17072027
17082028 cGridBag ambient = new cGridBag();
17092029 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17102030 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17112031 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1712
- globalSection.add(ambient);
2032
+ colorSection.add(ambient);
17132033
17142034 cGridBag backlit = new cGridBag();
17152035 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17162036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17172037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1718
- globalSection.add(backlit);
2038
+ colorSection.add(backlit);
17192039
1720
- cGridBag opacity = new cGridBag();
1721
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1722
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1723
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1724
- globalSection.add(opacity);
1725
-
1726
- panel.add(new JSeparator());
2040
+ //panel.add(new JSeparator());
17272041
1728
- panel.add(globalSection);
2042
+ //panel.add(globalSection);
17292043
17302044 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17312045
....@@ -1767,7 +2081,7 @@
17672081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
17682082 textureSection.add(opacityPower);
17692083
1770
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
17712085
17722086 panel.add(textureSection);
17732087
....@@ -1832,8 +2146,9 @@
18322146 // 3D models
18332147 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18342148 {
1835
- lastConverter = new com.jmex.model.converters.MaxToJme();
1836
- LoadFile(filename, lastConverter);
2149
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2150
+ //LoadFile(filename, lastConverter);
2151
+ LoadObjFile(filename); // New 3ds loader
18372152 continue;
18382153 }
18392154 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2559,6 +2874,7 @@
25592874 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25602875 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25612876 }
2877
+
25622878 //cJME.count++;
25632879 //cJME.count %= 12;
25642880 if (gc)
....@@ -2742,6 +3058,7 @@
27423058 }
27433059 }
27443060 }
3061
+
27453062 cFileSystemPane FSPane;
27463063
27473064 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2751,7 +3068,7 @@
27513068
27523069 freezematerial = true;
27533070 colorField.setFloat(mat.color);
2754
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
27553072 metalnessField.setFloat(mat.metalness);
27563073 diffuseField.setFloat(mat.diffuse);
27573074 specularField.setFloat(mat.specular);
....@@ -2795,11 +3112,14 @@
27953112 }
27963113 }
27973114 }
3115
+
27983116 freezematerial = false;
27993117 }
28003118
28013119 void SetMaterial(Object3D object)
28023120 {
3121
+ latestObject = object;
3122
+
28033123 cMaterial mat = object.material;
28043124
28053125 if (mat == null)
....@@ -2911,12 +3231,17 @@
29113231 // }
29123232
29133233 /**/
2914
- if (deselect)
3234
+ if (deselect || child == null)
29153235 {
29163236 //group.deselectAll();
29173237 //freeze = true;
29183238 GetTree().clearSelection();
29193239 //freeze = false;
3240
+
3241
+ if (child == null)
3242
+ {
3243
+ return;
3244
+ }
29203245 }
29213246
29223247 //group.addSelectee(child);
....@@ -2985,7 +3310,7 @@
29853310 cameraView.ToggleDL();
29863311 cameraView.repaint();
29873312 return;
2988
- } else if (event.getSource() == toggleTextureItem)
3313
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29893314 {
29903315 cameraView.ToggleTexture();
29913316 // june 2013 copy.HardTouch();
....@@ -3024,7 +3349,7 @@
30243349 frame.validate();
30253350
30263351 return;
3027
- } else if (event.getSource() == toggleSwitchItem)
3352
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30283353 {
30293354 cameraView.ToggleSwitch();
30303355 cameraView.repaint();
....@@ -3054,8 +3379,9 @@
30543379 } else if (event.getSource() == liveCB)
30553380 {
30563381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
30573383 return;
3058
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
30593385 {
30603386 copy.dontselect ^= true;
30613387 return;
....@@ -3063,7 +3389,7 @@
30633389 {
30643390 copy.hide ^= true;
30653391 copy.Touch(); // display list issue
3066
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
30673393 return;
30683394 } else if (event.getSource() == link2masterCB)
30693395 {
....@@ -3240,9 +3566,9 @@
32403566 {
32413567 Close();
32423568 //return true;
3243
- } else if (source == loadItem)
3569
+ } else if (source == openItem)
32443570 {
3245
- load();
3571
+ Open();
32463572 //return true;
32473573 } else if (source == newItem)
32483574 {
....@@ -3267,6 +3593,10 @@
32673593 {
32683594 generatePOV();
32693595 //return true;
3596
+ } else if (event.getSource() == archiveItem)
3597
+ {
3598
+ cTools.Archive(frame);
3599
+ return;
32703600 } else if (source == zBufferItem)
32713601 {
32723602 try
....@@ -3315,11 +3645,12 @@
33153645
33163646 static public byte[] Compress(Object3D o)
33173647 {
3648
+ // Slower to actually compress.
33183649 try
33193650 {
33203651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3321
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3322
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3652
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3653
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33233654
33243655 Object3D parent = o.parent;
33253656 o.parent = null;
....@@ -3330,10 +3661,14 @@
33303661
33313662 out.flush();
33323663
3333
- zstream.close();
3664
+ baos //zstream
3665
+ .close();
33343666 out.close();
33353667
3336
- return baos.toByteArray();
3668
+ byte[] bytes = baos.toByteArray();
3669
+
3670
+ System.out.println("save #bytes = " + bytes.length);
3671
+ return bytes;
33373672 } catch (Exception e)
33383673 {
33393674 System.err.println(e);
....@@ -3343,13 +3678,16 @@
33433678
33443679 static public Object Uncompress(byte[] bytes)
33453680 {
3346
- System.out.println("#bytes = " + bytes.length);
3681
+ System.out.println("restore #bytes = " + bytes.length);
33473682 try
33483683 {
33493684 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3350
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3351
- ObjectInputStream in = new ObjectInputStream(istream);
3685
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3686
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33523687 Object obj = in.readObject();
3688
+
3689
+ bais //istream
3690
+ .close();
33533691 in.close();
33543692
33553693 return obj;
....@@ -3404,37 +3742,95 @@
34043742 return null;
34053743 }
34063744
3407
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34083745
34093746 public void Save()
34103747 {
3748
+ //Save(true);
3749
+ Replace();
3750
+ SetUndoStates();
3751
+ }
3752
+
3753
+ private boolean Equal(byte[] compress, byte[] name)
3754
+ {
3755
+ if (compress.length != name.length)
3756
+ {
3757
+ return false;
3758
+ }
3759
+
3760
+ for (int i=compress.length; --i>=0;)
3761
+ {
3762
+ if (compress[i] != name[i])
3763
+ return false;
3764
+ }
3765
+
3766
+ return true;
3767
+ }
3768
+
3769
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3770
+
3771
+ void DeleteVersion()
3772
+ {
3773
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
3774
+ {
3775
+ copy.versionlist[i] = copy.versionlist[i+1];
3776
+ }
3777
+
3778
+ CopyChanged();
3779
+
3780
+ SetUndoStates();
3781
+ }
3782
+
3783
+ public boolean Save(boolean user)
3784
+ {
3785
+ System.err.println("Save");
3786
+ //Replace();
3787
+
34113788 cRadio tab = GetCurrentTab();
34123789
3413
- boolean temp = CameraPane.SWITCH;
3414
- CameraPane.SWITCH = false;
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
34153791
3416
- copy.ExtractBigData(hashtable);
3792
+ boolean thesame = false;
3793
+
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
34173798
34183799 //EditorFrame.m_MainFrame.requestFocusInWindow();
3419
- tab.graphs[tab.undoindex++] = Compress(copy);
3420
-
3421
- copy.RestoreBigData(hashtable);
3422
-
3423
- CameraPane.SWITCH = temp;
3424
-
3425
- //assert(hashtable.isEmpty());
3426
-
3427
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3800
+ if (!thesame)
34283801 {
3429
- tab.graphs[i] = null;
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
3807
+ //tab.user[tab.versionindex] = user;
3808
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3809
+
3810
+ copy.versionlist[++copy.versionindex] = compress;
3811
+
3812
+ // if (increment)
3813
+ // tab.versionindex++;
34303814 }
34313815
3816
+ //copy.RestoreBigData(versiontable);
3817
+
3818
+ //assert(hashtable.isEmpty());
3819
+
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
3825
+
3826
+ SetUndoStates();
3827
+
34323828 // test save
34333829 if (false)
34343830 {
34353831 try
34363832 {
3437
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3833
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34383834 ObjectOutputStream p = new ObjectOutputStream(ostream);
34393835
34403836 p.writeObject(copy);
....@@ -3447,26 +3843,68 @@
34473843 e.printStackTrace();
34483844 }
34493845 }
3846
+
3847
+ return !thesame;
3848
+ }
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
3853
+ {
3854
+ Object3D selection = new Object3D();
3855
+
3856
+ for (int i = 0; i < copy.selection.size(); i++)
3857
+ {
3858
+ Object3D elem = copy.selection.elementAt(i);
3859
+
3860
+ Object3D obj = copy.GetObject(elem.GetUUID());
3861
+
3862
+ if (obj == null)
3863
+ {
3864
+ copy.selection.remove(i--);
3865
+ }
3866
+ else
3867
+ {
3868
+ selection.add(obj);
3869
+ copy.selection.setElementAt(obj, i);
3870
+ }
3871
+ }
3872
+
3873
+ flashIt = false;
3874
+ GetTree().clearSelection();
3875
+ for (int i = 0; i < selection.size(); i++)
3876
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3877
+ flashIt = true;
3878
+
3879
+ //refreshContents(false);
34503880 }
34513881
3452
- void CopyChanged(Object3D obj)
3882
+ void CopyChanged()
34533883 {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
3886
+ SetUndoStates();
3887
+
34543888 boolean temp = CameraPane.SWITCH;
34553889 CameraPane.SWITCH = false;
34563890
3457
- copy.ExtractBigData(hashtable);
3891
+ copy.ExtractBigData(versiontable);
34583892
34593893 copy.clear();
34603894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
34613898 for (int i=0; i<obj.Size(); i++)
34623899 {
34633900 copy.add(obj.get(i));
34643901 }
34653902
3466
- copy.RestoreBigData(hashtable);
3903
+ copy.RestoreBigData(versiontable);
34673904
34683905 CameraPane.SWITCH = temp;
34693906
3907
+ RefreshSelection();
34703908 //assert(hashtable.isEmpty());
34713909
34723910 copy.Touch();
....@@ -3487,43 +3925,139 @@
34873925 }
34883926 }
34893927
3490
- refreshContents();
3928
+ refreshContents(true);
34913929 }
34923930
3493
- public void Undo()
3931
+ cButton previousVersionButton;
3932
+ cButton restoreButton;
3933
+ cButton replaceButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
3937
+
3938
+ boolean muteSlider;
3939
+
3940
+ int VersionCount()
3941
+ {
3942
+ int count = 0;
3943
+
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
3945
+ {
3946
+ if (copy.versionlist[i] != null)
3947
+ count++;
3948
+ }
3949
+
3950
+ return count;
3951
+ }
3952
+
3953
+ void SetUndoStates()
34943954 {
34953955 cRadio tab = GetCurrentTab();
34963956
3497
- if (tab.undoindex == 0)
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
3959
+
3960
+ previousVersionButton.setEnabled(copy.versionindex > 0);
3961
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3962
+
3963
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
3964
+ copy.versionlist[copy.versionindex + 1] != null);
3965
+
3966
+ muteSlider = true;
3967
+ versionSlider.setMaximum(VersionCount() - 1);
3968
+ versionSlider.setInteger(copy.versionindex);
3969
+ muteSlider = false;
3970
+ }
3971
+
3972
+ public boolean PreviousVersion()
3973
+ {
3974
+ // Option?
3975
+ Replace();
3976
+
3977
+ System.err.println("Undo");
3978
+
3979
+ cRadio tab = GetCurrentTab();
3980
+
3981
+ if (copy.versionindex == 0)
34983982 {
34993983 java.awt.Toolkit.getDefaultToolkit().beep();
3500
- return;
3984
+ return false;
35013985 }
35023986
3503
- if (tab.graphs[tab.undoindex] == null)
3504
- {
3505
- Save();
3506
- tab.undoindex -= 1;
3507
- }
3987
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3988
+// {
3989
+// if (Save(false))
3990
+// tab.versionindex -= 1;
3991
+// else
3992
+// {
3993
+// if (tab.versionindex <= 0)
3994
+// return false;
3995
+// else
3996
+// tab.versionindex -= 1;
3997
+// }
3998
+// }
35083999
3509
- tab.undoindex -= 1;
4000
+ copy.versionindex -= 1;
35104001
3511
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged();
4003
+
4004
+ return true;
35124005 }
35134006
3514
- public void Redo()
4007
+ public boolean Restore()
35154008 {
4009
+ System.err.println("Restore");
4010
+
35164011 cRadio tab = GetCurrentTab();
35174012
3518
- if (tab.graphs[tab.undoindex + 1] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4014
+ {
4015
+ java.awt.Toolkit.getDefaultToolkit().beep();
4016
+ return false;
4017
+ }
4018
+
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
4021
+
4022
+ return true;
4023
+ }
4024
+
4025
+ public boolean Replace()
4026
+ {
4027
+ System.err.println("Replace");
4028
+
4029
+ cRadio tab = GetCurrentTab();
4030
+
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4032
+ {
4033
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4034
+ return false;
4035
+ }
4036
+
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
4038
+
4039
+ return true;
4040
+ }
4041
+
4042
+ public void NextVersion()
4043
+ {
4044
+ // Option?
4045
+ Replace();
4046
+
4047
+ cRadio tab = GetCurrentTab();
4048
+
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
35194050 {
35204051 java.awt.Toolkit.getDefaultToolkit().beep();
35214052 return;
35224053 }
35234054
3524
- tab.undoindex += 1;
4055
+ copy.versionindex += 1;
35254056
3526
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4057
+ CopyChanged();
4058
+
4059
+ //if (!tab.user[tab.versionindex])
4060
+ // tab.graphs[tab.versionindex] = null;
35274061 }
35284062
35294063 void ImportGFD()
....@@ -3675,7 +4209,7 @@
36754209 assert false;
36764210 }
36774211
3678
- void EditSelection()
4212
+ void EditSelection(boolean newWindow)
36794213 {
36804214 }
36814215
....@@ -3734,7 +4268,7 @@
37344268 //copy.material = new cMaterial(copy.GetMaterial());
37354269
37364270 current.color = (float) colorField.getFloat();
3737
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
37384272 current.metalness = (float) metalnessField.getFloat();
37394273 current.diffuse = (float) diffuseField.getFloat();
37404274 current.specular = (float) specularField.getFloat();
....@@ -3767,7 +4301,7 @@
37674301 cMaterial mat = copy.material;
37684302
37694303 colorField.SetToolTipValue((mat.color));
3770
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
37714305 metalnessField.SetToolTipValue((mat.metalness));
37724306 diffuseField.SetToolTipValue((mat.diffuse));
37734307 specularField.SetToolTipValue((mat.specular));
....@@ -3819,9 +4353,26 @@
38194353 //copy.Touch();
38204354 }
38214355
4356
+ cNumberSlider versionSlider;
4357
+
38224358 public void stateChanged(ChangeEvent e)
38234359 {
38244360 // assert(false);
4361
+ if (e.getSource() == versionSlider)
4362
+ {
4363
+ if (muteSlider)
4364
+ return;
4365
+
4366
+ int version = versionSlider.getInteger();
4367
+
4368
+ if (copy.versionlist[version] != null)
4369
+ {
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
4372
+ }
4373
+
4374
+ return;
4375
+ }
38254376
38264377 if (freezematerial)
38274378 {
....@@ -3857,6 +4408,12 @@
38574408 {
38584409 //System.out.println("stateChanged = " + this);
38594410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
38604417 applySelf();
38614418 //System.out.println("this = " + this);
38624419 //System.out.println("PARENT = " + parent);
....@@ -4156,6 +4713,7 @@
41564713 {
41574714 if (GetTree() != null)
41584715 {
4716
+ GetTree().revalidate();
41594717 GetTree().repaint();
41604718 }
41614719
....@@ -4164,13 +4722,17 @@
41644722 ctrlPanel.validate(); // ? new
41654723 ctrlPanel.repaint();
41664724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
41674728 }
41684729
41694730 static TweenManager tweenManager = new TweenManager();
41704731
41714732 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41724733 {
4173
- Save();
4734
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4735
+ Save();
41744736 //Tween.set(thing, 0).target(1).start(tweenManager);
41754737 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41764738 // if (thing instanceof GenericJointDemo)
....@@ -4257,6 +4819,12 @@
42574819 {
42584820 ResetModel();
42594821 Select(thing.GetTreePath(), true, false); // unselect... false);
4822
+
4823
+ if (thing.Size() == 0)
4824
+ {
4825
+ //EditSelection(false);
4826
+ }
4827
+
42604828 refreshContents();
42614829 }
42624830
....@@ -4405,7 +4973,9 @@
44054973 readobj.ResetDisplayList();
44064974 } catch (Exception e)
44074975 {
4408
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
44094979 try
44104980 {
44114981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4479,11 +5049,14 @@
44795049
44805050 if (readobj != null)
44815051 {
4482
- Save();
5052
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5053
+ // Save();
44835054 try
44845055 {
44855056 //readobj.deepCopySelf(copy);
44865057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
44875060 for (int i = 0; i < readobj.size(); i++)
44885061 {
44895062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4524,6 +5097,7 @@
45245097 }
45255098 } catch (ClassCastException e)
45265099 {
5100
+ e.printStackTrace();
45275101 assert (false);
45285102 Composite c = (Composite) copy;
45295103 c.children.clear();
....@@ -4534,17 +5108,28 @@
45345108 c.addChild(csg);
45355109 }
45365110
5111
+ copy.versionlist = readobj.versionlist;
5112
+ copy.versionindex = readobj.versionindex;
5113
+
5114
+ if (copy.versionlist == null)
5115
+ {
5116
+ copy.versionlist = new Object3D[100];
5117
+ copy.versionindex = -1;
5118
+ }
5119
+
5120
+ //? SetUndoStates();
5121
+
45375122 ResetModel();
45385123 copy.HardTouch(); // recompile?
45395124 refreshContents();
45405125 }
45415126 }
45425127
4543
- void load() // throws ClassNotFoundException
5128
+ void Open() // throws ClassNotFoundException
45445129 {
45455130 if (Grafreed.standAlone)
45465131 {
4547
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
45485133 browser.show();
45495134 String filename = browser.getFile();
45505135 if (filename != null && filename.length() > 0)
....@@ -4643,6 +5228,7 @@
46435228 //ps.print(buffer.toString());
46445229 } catch (IOException e)
46455230 {
5231
+ e.printStackTrace();
46465232 }
46475233 }
46485234
....@@ -4657,6 +5243,8 @@
46575243 String filename = browser.getFile();
46585244 if (filename != null && filename.length() > 0)
46595245 {
5246
+ if (!filename.endsWith(".gfd"))
5247
+ filename += ".gfd";
46605248 lastname = browser.getDirectory() + filename;
46615249 save();
46625250 }
....@@ -4823,7 +5411,7 @@
48235411 MenuBar menuBar;
48245412 Menu fileMenu;
48255413 MenuItem newItem;
4826
- MenuItem loadItem;
5414
+ MenuItem openItem;
48275415 MenuItem saveItem;
48285416 MenuItem saveAsItem;
48295417 MenuItem exportAsItem;
....@@ -4846,22 +5434,36 @@
48465434 CheckboxMenuItem toggleSwitchItem;
48475435 CheckboxMenuItem toggleRootItem;
48485436 CheckboxMenuItem animationItem;
5437
+ MenuItem archiveItem;
48495438 CheckboxMenuItem toggleHandleItem;
48505439 CheckboxMenuItem togglePaintItem;
48515440 JSplitPane mainPanel;
48525441 JScrollPane scrollpane;
5442
+
48535443 JPanel toolbarPanel;
5444
+
48545445 cGridBag treePanel;
5446
+
48555447 JPanel radioPanel;
48565448 ButtonGroup buttonGroup;
4857
- cGridBag ctrlPanel;
5449
+
5450
+ cGridBag toolboxPanel;
48585451 cGridBag materialPanel;
5452
+ cGridBag ctrlPanel;
5453
+
48595454 JScrollPane infoPanel;
5455
+
48605456 cGridBag optionsPanel;
5457
+
48615458 JTabbedPane objectPanel;
5459
+ boolean materialFlushed;
5460
+ Object3D latestObject;
5461
+
48625462 cGridBag XYZPanel;
5463
+
48635464 JSplitPane gridPanel;
48645465 JSplitPane bigPanel;
5466
+
48655467 cGridBag bigThree;
48665468 cGridBag scenePanel;
48675469 cGridBag centralPanel;
....@@ -4919,7 +5521,7 @@
49195521 JLabel colorLabel;
49205522 cNumberSlider colorField;
49215523 JLabel modulationLabel;
4922
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
49235525 JLabel metalnessLabel;
49245526 cNumberSlider metalnessField;
49255527 JLabel diffuseLabel;
....@@ -4976,7 +5578,7 @@
49765578 cNumberSlider fogField;
49775579 JLabel opacityPowerLabel;
49785580 cNumberSlider opacityPowerField;
4979
- JTree jTree;
5581
+ cTree jTree;
49805582 //ObjectUI parent;
49815583
49825584 cNumberSlider normalpushField;