Normand Briere
2019-08-04 0c85af6e46f48b7425d59fc776b193c06a4a1f52
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
....@@ -35,6 +39,81 @@
3539
3640 GroupEditor callee;
3741 JFrame frame;
42
+
43
+ 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
+ }
38117
39118 // SCRIPT
40119
....@@ -145,7 +224,7 @@
145224
146225 objEditor.ctrlPanel.remove(namePanel);
147226
148
- if (!GroupEditor.allparams)
227
+ if (!allparams)
149228 return;
150229
151230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -168,7 +247,8 @@
168247 // objEditor.ctrlPanel.remove(remarkButton);
169248
170249 objEditor.ctrlPanel.remove(setupPanel);
171
- objEditor.ctrlPanel.remove(commandsPanel);
250
+ objEditor.ctrlPanel.remove(setupPanel2);
251
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
172252 objEditor.ctrlPanel.remove(pushPanel);
173253 //objEditor.ctrlPanel.remove(fillPanel);
174254
....@@ -216,6 +296,12 @@
216296 client = inClient;
217297 copy = client;
218298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
219305 // "this" is not called: SetupUI2(objEditor);
220306 }
221307
....@@ -229,6 +315,12 @@
229315 client = inClient;
230316 copy = client;
231317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
232324 SetupUI2(callee.GetEditor());
233325 }
234326
....@@ -243,6 +335,7 @@
243335 //localCopy.parent = null;
244336
245337 frame = new JFrame();
338
+ frame.setUndecorated(false);
246339 objEditor = this;
247340 this.callee = callee;
248341
....@@ -260,6 +353,12 @@
260353 copy = localCopy;
261354 copy.editWindow = this;
262355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
263362 SetupMenu();
264363
265364 //SetupName(objEditor); // new
....@@ -273,12 +372,17 @@
273372 return frame.action(event, obj);
274373 }
275374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
276380 void SetupMenu()
277381 {
278382 frame.setMenuBar(menuBar = new MenuBar());
279383 menuBar.add(fileMenu = new Menu("File"));
280384 fileMenu.add(newItem = new MenuItem("New"));
281
- fileMenu.add(loadItem = new MenuItem("Load..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
282386
283387 //oe.menuBar.add(menu = new Menu("Include"));
284388 Menu menu = new Menu("Import");
....@@ -310,7 +414,7 @@
310414 }
311415
312416 newItem.addActionListener(this);
313
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
314418 saveItem.addActionListener(this);
315419 saveAsItem.addActionListener(this);
316420 exportAsItem.addActionListener(this);
....@@ -319,28 +423,68 @@
319423 closeItem.addActionListener(this);
320424
321425 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
+
322452 toolbarPanel = new JPanel();
323453 toolbarPanel.setName("Toolbar");
454
+
324455 treePanel = new cGridBag();
325456 treePanel.setName("Tree");
457
+
458
+ editPanel = new cGridBag().setVertical(true);
459
+ //editPanel.setName("Edit");
460
+
326461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
327
- ctrlPanel.setName("Edit");
328
- materialPanel = new cGridBag().setVertical(true);
329
- materialPanel.setName("Material");
462
+
463
+ editCommandsPanel = new cGridBag();
464
+ editPanel.add(editCommandsPanel);
465
+ editPanel.add(ctrlPanel);
466
+
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
469
+
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
472
+
330473 /*JTextPane*/
331474 infoarea = createTextPane();
332475 doc = infoarea.getStyledDocument();
333476
334477 infoarea.setEditable(true);
335478 SetText();
479
+
336480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
337481 // infoarea.setOpaque(false);
338482 // //infoarea.setForeground(textcolor);
339483 // TEXTAREA infoarea.setLineWrap(true);
340484 // TEXTAREA infoarea.setWrapStyleWord(true);
341485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
342
- infoPanel.setPreferredSize(new Dimension(50, 200));
343
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
344488 //infoPanel.setLayout(new BorderLayout());
345489 //infoPanel.add(createTextPane());
346490
....@@ -351,7 +495,14 @@
351495 mainPanel.setDividerSize(9);
352496 mainPanel.setDividerLocation(0.5); //1.0);
353497 mainPanel.setResizeWeight(0.5);
354
-
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
+
355506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
356507 //mainPanel.setLayout(new GridBagLayout());
357508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -419,10 +570,10 @@
419570 e.printStackTrace();
420571 }
421572
422
- String selection = infoarea.getText();
423
- java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
424
- java.awt.datatransfer.Clipboard clipboard =
425
- Toolkit.getDefaultToolkit().getSystemClipboard();
573
+// String selection = infoarea.getText();
574
+// java.awt.datatransfer.StringSelection data = new java.awt.datatransfer.StringSelection(selection);
575
+// java.awt.datatransfer.Clipboard clipboard =
576
+// Toolkit.getDefaultToolkit().getSystemClipboard();
426577 //clipboard.setContents(data, data);
427578 }
428579
....@@ -582,21 +733,145 @@
582733 }
583734 }
584735
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
738
+
739
+ Rectangle keeprect;
740
+ cRadio radio;
741
+
742
+cButton keepButton;
743
+ cButton twoButton; // Full 3D
744
+ cButton sixButton;
745
+ cButton threeButton;
746
+ cButton sevenButton;
747
+ cButton fourButton; // full panel
748
+ cButton oneButton; // full XYZ
749
+ //cButton currentLayout;
750
+
751
+ boolean maximized;
752
+
753
+ cButton fullscreenLayout;
754
+
755
+ void Minimize()
756
+ {
757
+ frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
759
+ }
760
+
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={}
764
+ void Maximize()
765
+ {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
771
+ if (maximized)
772
+ {
773
+ frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
774
+ }
775
+ else
776
+ {
777
+ keeprect = frame.getBounds();
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
781
+// frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
783
+ }
784
+
785
+ maximized ^= true;
786
+
787
+ frame.validate();
788
+ }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
793
+
585794 void ToggleFullScreen()
586795 {
587
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
588801 {
589
- frame.getContentPane().remove(/*"Center",*/bigThree);
590
- framePanel.add(bigThree);
591
- frame.getContentPane().add(/*"Center",*/framePanel);
802
+ device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
808
+ //frame.setVisible(false);
809
+// frame.removeNotify();
810
+// frame.setUndecorated(false);
811
+// frame.addNotify();
812
+ //frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
813
+
814
+// X frame.getContentPane().remove(/*"Center",*/bigThree);
815
+// X framePanel.add(bigThree);
816
+// X frame.getContentPane().add(/*"Center",*/framePanel);
817
+ framePanel.setDividerLocation(46);
818
+
819
+ //frame.setVisible(true);
820
+ radio.layout = keepButton;
821
+ //theFrame = null;
822
+ keepButton = null;
823
+ radio.layout.doClick();
824
+
592825 } else
593826 {
594
- frame.getContentPane().remove(/*"Center",*/framePanel);
595
- framePanel.remove(bigThree);
596
- frame.getContentPane().add(/*"Center",*/bigThree);
827
+ keepButton = radio.layout;
828
+ //keeprect = frame.getBounds();
829
+// frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
830
+// frame.getToolkit().getScreenSize().height);
831
+ //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
835
+ device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
838
+// frame.removeNotify();
839
+// frame.setUndecorated(true);
840
+// frame.addNotify();
841
+// X frame.getContentPane().remove(/*"Center",*/framePanel);
842
+// X framePanel.remove(bigThree);
843
+// X frame.getContentPane().add(/*"Center",*/bigThree);
844
+ framePanel.setDividerLocation(0);
845
+
846
+ radio.layout = fullscreenLayout;
847
+ radio.layout.doClick();
848
+ //frame.setVisible(true);
597849 }
598
- cameraView.ToggleFullScreen();
850
+ frame.validate();
599851 }
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.versionlist;
862
+ copy.versionlist = null;
863
+
864
+ //byte[] compress = Compress(copy);
865
+ Object3D compress = (Object3D)Grafreed.clone(copy);
866
+
867
+ copy.versionlist = versions;
868
+
869
+ copy.RestoreBigData(versiontable);
870
+
871
+ CameraPane.SWITCH = temp;
872
+
873
+ return compress;
874
+ }
600875
601876 private JTextPane createTextPane()
602877 {
....@@ -719,6 +994,7 @@
719994 {
720995 SetupMaterial(materialPanel);
721996 }
997
+
722998 //SetupName();
723999 //SetupViews();
7241000 }
....@@ -728,7 +1004,7 @@
7281004 // NumberSlider vDivsField;
7291005 // JCheckBox endcaps;
7301006 JCheckBox liveCB;
731
- JCheckBox selectCB;
1007
+ JCheckBox selectableCB;
7321008 JCheckBox hideCB;
7331009 JCheckBox link2masterCB;
7341010 JCheckBox markCB;
....@@ -736,7 +1012,12 @@
7361012 JCheckBox speedupCB;
7371013 JCheckBox rewindCB;
7381014 JCheckBox flipVCB;
1015
+
1016
+ cCheckBox toggleTextureCB;
1017
+ cCheckBox toggleSwitchCB;
1018
+
7391019 JComboBox texresMenu;
1020
+
7401021 JButton resetButton;
7411022 JButton stepButton;
7421023 JButton stepAllButton;
....@@ -745,9 +1026,13 @@
7451026 JButton fasterButton;
7461027 JButton remarkButton;
7471028
1029
+ cGridBag editPanel;
1030
+ cGridBag editCommandsPanel;
1031
+
7481032 cGridBag namePanel;
7491033 cGridBag setupPanel;
750
- cGridBag commandsPanel;
1034
+ cGridBag setupPanel2;
1035
+ cGridBag objectCommandsPanel;
7511036 cGridBag pushPanel;
7521037 cGridBag fillPanel;
7531038
....@@ -919,60 +1204,68 @@
9191204 namePanel = new cGridBag();
9201205
9211206 nameField = AddText(namePanel, copy.GetName());
922
- namePanel.add(nameField);
1207
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9231208 oe.ctrlPanel.add(namePanel);
9241209
9251210 oe.ctrlPanel.Return();
9261211
927
- if (!GroupEditor.allparams)
1212
+ if (!allparams)
9281213 return;
9291214
9301215 setupPanel = new cGridBag().setVertical(false);
9311216
9321217 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9331218 liveCB.setToolTipText("Animate object");
934
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
935
- selectCB.setToolTipText("Make object selectable");
1219
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1220
+ selectableCB.setToolTipText("Make object selectable");
9361221 // Return();
1222
+
9371223 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9381224 hideCB.setToolTipText("Hide object");
9391225 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
940
- markCB.setToolTipText("Set the animation target transform");
1226
+ markCB.setToolTipText("As animation target transform");
9411227
942
- rewindCB = AddCheckBox(setupPanel, "Rewind", copy.rewind);
1228
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
1229
+
1230
+ setupPanel2 = new cGridBag().setVertical(false);
1231
+
1232
+ rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9431233 rewindCB.setToolTipText("Rewind animation");
9441234
945
- randomCB = AddCheckBox(setupPanel, "Random", copy.random);
946
- randomCB.setToolTipText("Option for switch node");
1235
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1236
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9471237
1238
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1239
+ link2masterCB.setToolTipText("Attach to support");
1240
+
9481241 if (Globals.ADVANCED)
9491242 {
950
- link2masterCB = AddCheckBox(setupPanel, "Support", copy.link2master);
951
- link2masterCB.setToolTipText("Attach to support");
952
- speedupCB = AddCheckBox(setupPanel, "Speed", copy.speedup);
1243
+ speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9531244 speedupCB.setToolTipText("Option motion capture");
9541245 }
9551246
9561247 oe.ctrlPanel.add(setupPanel);
9571248 oe.ctrlPanel.Return();
1249
+ oe.ctrlPanel.add(setupPanel2);
1250
+ oe.ctrlPanel.Return();
9581251
959
- commandsPanel = new cGridBag().setVertical(false);
1252
+ objectCommandsPanel = new cGridBag().setVertical(false);
9601253
961
- resetButton = AddButton(commandsPanel, "Reset");
1254
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9621255 resetButton.setToolTipText("Jump to frame zero");
963
- stepButton = AddButton(commandsPanel, "Step");
1256
+ stepButton = AddButton(objectCommandsPanel, "Step");
9641257 stepButton.setToolTipText("Step one frame");
9651258 // resetAllButton = AddButton(oe, "Reset All");
9661259 // stepAllButton = AddButton(oe, "Step All");
9671260 // Return();
968
- slowerButton = AddButton(commandsPanel, "Slow");
1261
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9691262 slowerButton.setToolTipText("Decrease animation speed");
970
- fasterButton = AddButton(commandsPanel, "Fast");
1263
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9711264 fasterButton.setToolTipText("Increase animation speed");
972
- remarkButton = AddButton(commandsPanel, "Remark");
1265
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9731266 remarkButton.setToolTipText("Set the current transform as the target");
9741267
975
- oe.ctrlPanel.add(commandsPanel);
1268
+ oe.ctrlPanel.add(objectCommandsPanel);
9761269 oe.ctrlPanel.Return();
9771270
9781271 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1178,8 +1471,11 @@
11781471 //worldPanel.setName("World");
11791472 centralPanel = new cGridBag();
11801473 centralPanel.preferredWidth = 20;
1181
- timelinePanel = new JPanel(new BorderLayout());
1182
- timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
1474
+
1475
+ if (Globals.ADVANCED)
1476
+ {
1477
+ timelinePanel = new JPanel(new BorderLayout());
1478
+ timelineMenubar = new timeflow.app.TimeflowApp().TimeFlowWindow(timelinePanel);
11831479
11841480 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11851481 cameraPanel.setContinuousLayout(true);
....@@ -1188,7 +1484,10 @@
11881484 // cameraPanel.setDividerSize(9);
11891485 cameraPanel.setResizeWeight(1.0);
11901486
1487
+ }
1488
+
11911489 centralPanel.add(cameraView);
1490
+ centralPanel.setFocusable(true);
11921491 //frame.setJMenuBar(timelineMenubar);
11931492 //centralPanel.add(timelinePanel);
11941493
....@@ -1214,6 +1513,7 @@
12141513 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12151514 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12161515 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1516
+ //XYZPanel.setName("XYZ");
12171517
12181518 /*
12191519 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1251,12 +1551,29 @@
12511551 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12521552 //tmp.setName("Edit");
12531553 objectPanel.add(materialPanel);
1554
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
+ objectPanel.setToolTipTextAt(0, "Material");
1556
+
12541557 // JPanel north = new JPanel(new BorderLayout());
12551558 // north.setName("Edit");
12561559 // north.add(ctrlPanel, BorderLayout.NORTH);
12571560 // objectPanel.add(north);
1258
- objectPanel.add(ctrlPanel);
1259
- objectPanel.add(infoPanel);
1561
+ objectPanel.add(editPanel);
1562
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1563
+ objectPanel.setToolTipTextAt(1, "Edit controls");
1564
+
1565
+ //if (Globals.ADVANCED)
1566
+ objectPanel.add(infoPanel);
1567
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1568
+ objectPanel.setToolTipTextAt(2, "Information");
1569
+
1570
+ objectPanel.add(XYZPanel);
1571
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1572
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1573
+
1574
+ objectPanel.add(toolboxPanel);
1575
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1576
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
12601577
12611578 /*
12621579 aConstraints.gridx = 0;
....@@ -1265,7 +1582,7 @@
12651582 aConstraints.gridy += 1;
12661583 aConstraints.gridwidth = 1;
12671584 mainPanel.add(objectPanel, aConstraints);
1268
- */
1585
+ */
12691586
12701587 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12711588 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1277,14 +1594,12 @@
12771594 scrollpane.addMouseWheelListener(this); // Default not fast enough
12781595
12791596 /*JTabbedPane*/ scenePanel = new cGridBag();
1280
- scenePanel.preferredWidth = 6;
1597
+ scenePanel.preferredWidth = 5;
12811598
12821599 JTabbedPane tabbedPane = new JTabbedPane();
12831600 tabbedPane.add(scrollpane);
12841601
1285
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1286
-
1287
- optionsPanel = new cGridBag().setVertical(true);
1602
+ optionsPanel = new cGridBag().setVertical(false);
12881603
12891604 optionsPanel.setName("Options");
12901605
....@@ -1292,6 +1607,8 @@
12921607
12931608 tabbedPane.add(optionsPanel);
12941609
1610
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1611
+
12951612 scenePanel.add(tabbedPane);
12961613
12971614 /*
....@@ -1355,7 +1672,7 @@
13551672 bigThree = new cGridBag();
13561673 bigThree.addComponent(scenePanel);
13571674 bigThree.addComponent(centralPanel);
1358
- bigThree.addComponent(XYZPanel);
1675
+ //bigThree.addComponent(XYZPanel);
13591676
13601677 // // SIDE EFFECT!!!
13611678 // aConstraints.gridx = 0;
....@@ -1364,9 +1681,9 @@
13641681 // aConstraints.gridheight = 1;
13651682
13661683 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1367
- framePanel.setContinuousLayout(true);
1368
- framePanel.setOneTouchExpandable(true);
1369
- framePanel.setDividerLocation(0.8);
1684
+ framePanel.setContinuousLayout(false);
1685
+ framePanel.setOneTouchExpandable(false);
1686
+ //.setDividerLocation(0.8);
13701687 //framePanel.setDividerSize(15);
13711688 //framePanel.setResizeWeight(0.15);
13721689 framePanel.setName("Frame");
....@@ -1384,14 +1701,18 @@
13841701 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13851702
13861703 frame.setSize(1280, 860);
1387
- frame.setVisible(true);
1388
-
1704
+
1705
+ cameraView.requestFocusInWindow();
1706
+
13891707 gridPanel.setDividerLocation(1.0);
1708
+
1709
+ frame.validate();
1710
+
1711
+ frame.setVisible(true);
13901712
13911713 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13921714 frame.addWindowListener(new WindowAdapter()
13931715 {
1394
-
13951716 public void windowClosing(WindowEvent e)
13961717 {
13971718 Close();
....@@ -1414,12 +1735,56 @@
14141735 ctrlPanel.removeAll();
14151736 }
14161737
1417
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
14181739 {
1419
- /*
1740
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1741
+ cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1742
+ label.addMouseListener(new MouseAdapter()
1743
+ {
1744
+ public void mouseClicked(MouseEvent e)
1745
+ {
1746
+ colorField.setFloat(0);
1747
+ saturationField.setFloat(1);
1748
+ materialtouched = true;
1749
+ applySelf();
1750
+ }
1751
+ });
1752
+ presetpanel.add(label);
1753
+
1754
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));
1755
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1756
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1757
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1758
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1759
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1760
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1761
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1762
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1763
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1764
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1765
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1766
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1767
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1768
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1769
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1770
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1771
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));
1772
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));
1773
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));
1774
+
1775
+ cGridBag panel = new cGridBag().setVertical(true);
1776
+
1777
+ presetpanel.preferredWidth = 1;
1778
+
1779
+ materialpanel.add(panel);
1780
+ materialpanel.add(presetpanel);
1781
+
1782
+ panel.preferredWidth = 8;
1783
+
1784
+ /*
14201785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14211786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1422
- */
1787
+ */
14231788
14241789 cGridBag editBar = new cGridBag().setVertical(false);
14251790
....@@ -1453,45 +1818,50 @@
14531818 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14541819
14551820 cGridBag colorSection = new cGridBag().setVertical(true);
1821
+
1822
+ cGridBag huepanel = new cGridBag();
1823
+ cGridBag huelabel = new cGridBag();
1824
+ label = GetLabel("icons/hue.png", false);
1825
+ label.fit = true;
1826
+ huelabel.add(label);
1827
+ huelabel.preferredWidth = 20;
1828
+ huepanel.add(new cGridBag()); // Label
1829
+ huepanel.add(huelabel); // Field/slider
1830
+
1831
+ huepanel.preferredHeight = 7;
1832
+
1833
+ colorSection.add(huepanel);
14561834
14571835 cGridBag color = new cGridBag();
1458
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1459
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1460
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1836
+
1837
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1838
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1839
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1840
+
14611841 //colorField.preferredWidth = 200;
14621842 colorSection.add(color);
14631843
14641844 cGridBag modulation = new cGridBag();
14651845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14661846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1467
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14681848 colorSection.add(modulation);
14691849
1850
+ cGridBag opacity = new cGridBag();
1851
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1852
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1853
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1854
+ colorSection.add(opacity);
1855
+
1856
+ colorSection.add(GetSeparator());
1857
+
14701858 cGridBag texture = new cGridBag();
14711859 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14721860 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14731861 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14741862 colorSection.add(texture);
14751863
1476
- cGridBag anisoU = new cGridBag();
1477
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1478
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1479
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1480
- colorSection.add(anisoU);
1481
-
1482
- cGridBag anisoV = new cGridBag();
1483
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1484
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1486
- colorSection.add(anisoV);
1487
-
1488
- cGridBag shadowbias = new cGridBag();
1489
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1490
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1492
- colorSection.add(shadowbias);
1493
-
1494
- panel.add(new JSeparator());
1864
+ panel.add(GetSeparator());
14951865
14961866 panel.add(colorSection);
14971867
....@@ -1541,7 +1911,13 @@
15411911 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15421912 diffuseSection.add(fakedepth);
15431913
1544
- panel.add(new JSeparator());
1914
+ cGridBag shadowbias = new cGridBag();
1915
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1916
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1917
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1918
+ diffuseSection.add(shadowbias);
1919
+
1920
+ panel.add(GetSeparator());
15451921
15461922 panel.add(diffuseSection);
15471923
....@@ -1591,42 +1967,48 @@
15911967 // aConstraints.gridy += 1;
15921968 // aConstraints.gridwidth = 1;
15931969
1970
+ cGridBag anisoU = new cGridBag();
1971
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1972
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1973
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1974
+ specularSection.add(anisoU);
15941975
1595
- panel.add(new JSeparator());
1976
+ cGridBag anisoV = new cGridBag();
1977
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1978
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1979
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1980
+ specularSection.add(anisoV);
1981
+
1982
+
1983
+ panel.add(GetSeparator());
15961984
15971985 panel.add(specularSection);
15981986
15991987 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16001988
1601
- cGridBag globalSection = new cGridBag().setVertical(true);
1989
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16021990
16031991 cGridBag camera = new cGridBag();
16041992 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16051993 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16061994 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1607
- globalSection.add(camera);
1995
+ colorSection.add(camera);
16081996
16091997 cGridBag ambient = new cGridBag();
16101998 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16111999 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16122000 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(ambient);
2001
+ colorSection.add(ambient);
16142002
16152003 cGridBag backlit = new cGridBag();
16162004 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16172005 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16182006 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(backlit);
2007
+ colorSection.add(backlit);
16202008
1621
- cGridBag opacity = new cGridBag();
1622
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1623
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1624
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1625
- globalSection.add(opacity);
1626
-
1627
- panel.add(new JSeparator());
2009
+ //panel.add(new JSeparator());
16282010
1629
- panel.add(globalSection);
2011
+ //panel.add(globalSection);
16302012
16312013 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16322014
....@@ -1668,7 +2050,7 @@
16682050 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16692051 textureSection.add(opacityPower);
16702052
1671
- panel.add(new JSeparator());
2053
+ panel.add(GetSeparator());
16722054
16732055 panel.add(textureSection);
16742056
....@@ -1733,8 +2115,9 @@
17332115 // 3D models
17342116 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17352117 {
1736
- lastConverter = new com.jmex.model.converters.MaxToJme();
1737
- LoadFile(filename, lastConverter);
2118
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2119
+ //LoadFile(filename, lastConverter);
2120
+ LoadObjFile(filename); // New 3ds loader
17382121 continue;
17392122 }
17402123 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2072,19 +2455,19 @@
20722455
20732456 void LoadObjFile(String fullname)
20742457 {
2075
- /*
2458
+ System.out.println("Loading " + fullname);
2459
+ /**/
20762460 //lastFilename = fullname;
20772461 if(loadObjThread == null)
20782462 {
2079
- loadObjThread = new LoadOBJThread();
2080
- loadObjThread.start();
2463
+ loadObjThread = new LoadOBJThread();
2464
+ loadObjThread.start();
20812465 }
20822466
20832467 loadObjThread.add(fullname);
2084
- */
2468
+ /**/
20852469
2086
- System.out.println("Loading " + fullname);
2087
- makeSomething(new FileObject(fullname, true), true);
2470
+ //makeSomething(new FileObject(fullname, true), true);
20882471 }
20892472
20902473 void LoadGFDFile(String fullname)
....@@ -2460,6 +2843,7 @@
24602843 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24612844 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24622845 }
2846
+
24632847 //cJME.count++;
24642848 //cJME.count %= 12;
24652849 if (gc)
....@@ -2643,6 +3027,7 @@
26433027 }
26443028 }
26453029 }
3030
+
26463031 cFileSystemPane FSPane;
26473032
26483033 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2652,7 +3037,7 @@
26523037
26533038 freezematerial = true;
26543039 colorField.setFloat(mat.color);
2655
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
26563041 metalnessField.setFloat(mat.metalness);
26573042 diffuseField.setFloat(mat.diffuse);
26583043 specularField.setFloat(mat.specular);
....@@ -2696,11 +3081,14 @@
26963081 }
26973082 }
26983083 }
3084
+
26993085 freezematerial = false;
27003086 }
27013087
27023088 void SetMaterial(Object3D object)
27033089 {
3090
+ latestObject = object;
3091
+
27043092 cMaterial mat = object.material;
27053093
27063094 if (mat == null)
....@@ -2812,12 +3200,17 @@
28123200 // }
28133201
28143202 /**/
2815
- if (deselect)
3203
+ if (deselect || child == null)
28163204 {
28173205 //group.deselectAll();
28183206 //freeze = true;
28193207 GetTree().clearSelection();
28203208 //freeze = false;
3209
+
3210
+ if (child == null)
3211
+ {
3212
+ return;
3213
+ }
28213214 }
28223215
28233216 //group.addSelectee(child);
....@@ -2886,7 +3279,7 @@
28863279 cameraView.ToggleDL();
28873280 cameraView.repaint();
28883281 return;
2889
- } else if (event.getSource() == toggleTextureItem)
3282
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28903283 {
28913284 cameraView.ToggleTexture();
28923285 // june 2013 copy.HardTouch();
....@@ -2925,9 +3318,9 @@
29253318 frame.validate();
29263319
29273320 return;
2928
- } else if (event.getSource() == toggleSwitchItem)
3321
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29293322 {
2930
- cameraView.ToggleRandom();
3323
+ cameraView.ToggleSwitch();
29313324 cameraView.repaint();
29323325 return;
29333326 } else if (event.getSource() == toggleHandleItem)
....@@ -2955,8 +3348,9 @@
29553348 } else if (event.getSource() == liveCB)
29563349 {
29573350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
29583352 return;
2959
- } else if (event.getSource() == selectCB)
3353
+ } else if (event.getSource() == selectableCB)
29603354 {
29613355 copy.dontselect ^= true;
29623356 return;
....@@ -2964,7 +3358,7 @@
29643358 {
29653359 copy.hide ^= true;
29663360 copy.Touch(); // display list issue
2967
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
29683362 return;
29693363 } else if (event.getSource() == link2masterCB)
29703364 {
....@@ -3141,9 +3535,9 @@
31413535 {
31423536 Close();
31433537 //return true;
3144
- } else if (source == loadItem)
3538
+ } else if (source == openItem)
31453539 {
3146
- load();
3540
+ Open();
31473541 //return true;
31483542 } else if (source == newItem)
31493543 {
....@@ -3168,6 +3562,10 @@
31683562 {
31693563 generatePOV();
31703564 //return true;
3565
+ } else if (event.getSource() == archiveItem)
3566
+ {
3567
+ cTools.Archive(frame);
3568
+ return;
31713569 } else if (source == zBufferItem)
31723570 {
31733571 try
....@@ -3214,22 +3612,32 @@
32143612 objEditor.refreshContents();
32153613 }
32163614
3217
- static public byte[] Compress(Object o)
3615
+ static public byte[] Compress(Object3D o)
32183616 {
3617
+ // Slower to actually compress.
32193618 try
32203619 {
32213620 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3222
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3223
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3621
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3622
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32243623
3624
+ Object3D parent = o.parent;
3625
+ o.parent = null;
3626
+
32253627 out.writeObject(o);
32263628
3629
+ o.parent = parent;
3630
+
32273631 out.flush();
32283632
3229
- zstream.close();
3633
+ baos //zstream
3634
+ .close();
32303635 out.close();
32313636
3232
- return baos.toByteArray();
3637
+ byte[] bytes = baos.toByteArray();
3638
+
3639
+ System.out.println("save #bytes = " + bytes.length);
3640
+ return bytes;
32333641 } catch (Exception e)
32343642 {
32353643 System.err.println(e);
....@@ -3239,12 +3647,16 @@
32393647
32403648 static public Object Uncompress(byte[] bytes)
32413649 {
3650
+ System.out.println("restore #bytes = " + bytes.length);
32423651 try
32433652 {
32443653 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3245
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3246
- ObjectInputStream in = new ObjectInputStream(istream);
3654
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3655
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
32473656 Object obj = in.readObject();
3657
+
3658
+ bais //istream
3659
+ .close();
32483660 in.close();
32493661
32503662 return obj;
....@@ -3299,32 +3711,78 @@
32993711 return null;
33003712 }
33013713
3302
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
33033714
33043715 public void Save()
33053716 {
3717
+ //Save(true);
3718
+ Replace();
3719
+ SetUndoStates();
3720
+ }
3721
+
3722
+ private boolean Equal(byte[] compress, byte[] name)
3723
+ {
3724
+ if (compress.length != name.length)
3725
+ {
3726
+ return false;
3727
+ }
3728
+
3729
+ for (int i=compress.length; --i>=0;)
3730
+ {
3731
+ if (compress[i] != name[i])
3732
+ return false;
3733
+ }
3734
+
3735
+ return true;
3736
+ }
3737
+
3738
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3739
+
3740
+ public boolean Save(boolean user)
3741
+ {
3742
+ System.err.println("Save");
3743
+ Replace();
3744
+
33063745 cRadio tab = GetCurrentTab();
33073746
3308
- copy.ExtractBigData(hashtable);
3747
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
3748
+
3749
+ boolean thesame = false;
3750
+
3751
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3752
+// {
3753
+// thesame = true;
3754
+// }
33093755
33103756 //EditorFrame.m_MainFrame.requestFocusInWindow();
3311
- tab.graphs[tab.undoindex++] = (Object3D)clone(copy);
3312
-
3313
- copy.RestoreBigData(hashtable);
3314
-
3315
- //assert(hashtable.isEmpty());
3316
-
3317
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3757
+ if (!thesame)
33183758 {
3319
- tab.graphs[i] = null;
3759
+ //tab.user[tab.versionindex] = user;
3760
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3761
+
3762
+ copy.versionlist[++copy.versionindex] = compress;
3763
+
3764
+ // if (increment)
3765
+ // tab.versionindex++;
33203766 }
33213767
3768
+ //copy.RestoreBigData(versiontable);
3769
+
3770
+ //assert(hashtable.isEmpty());
3771
+
3772
+ for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3773
+ {
3774
+ //tab.user[i] = false;
3775
+ copy.versionlist[i] = null;
3776
+ }
3777
+
3778
+ SetUndoStates();
3779
+
33223780 // test save
33233781 if (false)
33243782 {
33253783 try
33263784 {
3327
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3785
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
33283786 ObjectOutputStream p = new ObjectOutputStream(ostream);
33293787
33303788 p.writeObject(copy);
....@@ -3337,21 +3795,66 @@
33373795 e.printStackTrace();
33383796 }
33393797 }
3798
+
3799
+ return !thesame;
3800
+ }
3801
+
3802
+ boolean flashIt = true;
3803
+
3804
+ void RefreshSelection()
3805
+ {
3806
+ Object3D selection = new Object3D();
3807
+
3808
+ for (int i = 0; i < copy.selection.size(); i++)
3809
+ {
3810
+ Object3D elem = copy.selection.elementAt(i);
3811
+
3812
+ Object3D obj = copy.GetObject(elem.GetUUID());
3813
+
3814
+ if (obj == null)
3815
+ {
3816
+ copy.selection.remove(i--);
3817
+ }
3818
+ else
3819
+ {
3820
+ selection.add(obj);
3821
+ copy.selection.setElementAt(obj, i);
3822
+ }
3823
+ }
3824
+
3825
+ flashIt = false;
3826
+ GetTree().clearSelection();
3827
+ for (int i = 0; i < selection.size(); i++)
3828
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3829
+ flashIt = true;
3830
+
3831
+ refreshContents(false);
33403832 }
33413833
33423834 void CopyChanged(Object3D obj)
33433835 {
3344
- copy.ExtractBigData(hashtable);
3836
+ SetUndoStates();
3837
+
3838
+ boolean temp = CameraPane.SWITCH;
3839
+ CameraPane.SWITCH = false;
3840
+
3841
+ copy.ExtractBigData(versiontable);
33453842
33463843 copy.clear();
33473844
3845
+ copy.skyboxname = obj.skyboxname;
3846
+ copy.skyboxext = obj.skyboxext;
3847
+
33483848 for (int i=0; i<obj.Size(); i++)
33493849 {
33503850 copy.add(obj.get(i));
33513851 }
33523852
3353
- copy.RestoreBigData(hashtable);
3853
+ copy.RestoreBigData(versiontable);
33543854
3855
+ CameraPane.SWITCH = temp;
3856
+
3857
+ RefreshSelection();
33553858 //assert(hashtable.isEmpty());
33563859
33573860 copy.Touch();
....@@ -3375,40 +3878,131 @@
33753878 refreshContents();
33763879 }
33773880
3378
- public void Undo()
3881
+ cButton undoButton;
3882
+ cButton restoreButton;
3883
+ cButton replaceButton;
3884
+ cButton redoButton;
3885
+
3886
+ boolean muteSlider;
3887
+
3888
+ int VersionCount()
3889
+ {
3890
+ int count = 0;
3891
+
3892
+ for (int i = copy.versionlist.length; --i >= 0;)
3893
+ {
3894
+ if (copy.versionlist[i] != null)
3895
+ count++;
3896
+ }
3897
+
3898
+ return count;
3899
+ }
3900
+
3901
+ void SetUndoStates()
33793902 {
33803903 cRadio tab = GetCurrentTab();
33813904
3382
- if (tab.undoindex == 0)
3905
+ restoreButton.setEnabled(copy.versionindex != -1);
3906
+ replaceButton.setEnabled(copy.versionindex != -1);
3907
+
3908
+ undoButton.setEnabled(copy.versionindex > 0);
3909
+ redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3910
+
3911
+ muteSlider = true;
3912
+ versionSlider.setMaximum(VersionCount() - 1);
3913
+ versionSlider.setInteger(copy.versionindex);
3914
+ muteSlider = false;
3915
+ }
3916
+
3917
+ public boolean Undo()
3918
+ {
3919
+ // Option?
3920
+ Replace();
3921
+
3922
+ System.err.println("Undo");
3923
+
3924
+ cRadio tab = GetCurrentTab();
3925
+
3926
+ if (copy.versionindex == 0)
33833927 {
33843928 java.awt.Toolkit.getDefaultToolkit().beep();
3385
- return;
3929
+ return false;
33863930 }
33873931
3388
- if (tab.graphs[tab.undoindex] == null)
3932
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3933
+// {
3934
+// if (Save(false))
3935
+// tab.versionindex -= 1;
3936
+// else
3937
+// {
3938
+// if (tab.versionindex <= 0)
3939
+// return false;
3940
+// else
3941
+// tab.versionindex -= 1;
3942
+// }
3943
+// }
3944
+
3945
+ copy.versionindex -= 1;
3946
+
3947
+ CopyChanged((Object3D)copy.versionlist[copy.versionindex]);
3948
+
3949
+ return true;
3950
+ }
3951
+
3952
+ public boolean Restore()
3953
+ {
3954
+ System.err.println("Restore");
3955
+
3956
+ cRadio tab = GetCurrentTab();
3957
+
3958
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
33893959 {
3390
- Save();
3391
- tab.undoindex -= 1;
3960
+ java.awt.Toolkit.getDefaultToolkit().beep();
3961
+ return false;
33923962 }
33933963
3394
- tab.undoindex -= 1;
3964
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
3966
+
3967
+ return true;
3968
+ }
33953969
3396
- CopyChanged(tab.graphs[tab.undoindex]);
3970
+ public boolean Replace()
3971
+ {
3972
+ System.err.println("Replace");
3973
+
3974
+ cRadio tab = GetCurrentTab();
3975
+
3976
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
3977
+ {
3978
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3979
+ return false;
3980
+ }
3981
+
3982
+ copy.versionlist[copy.versionindex] = CompressCopy();
3983
+
3984
+ return true;
33973985 }
33983986
33993987 public void Redo()
34003988 {
3989
+ // Option?
3990
+ Replace();
3991
+
34013992 cRadio tab = GetCurrentTab();
34023993
3403
- if (tab.graphs[tab.undoindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
34043995 {
34053996 java.awt.Toolkit.getDefaultToolkit().beep();
34063997 return;
34073998 }
34083999
3409
- tab.undoindex += 1;
4000
+ copy.versionindex += 1;
34104001
3411
- CopyChanged(tab.graphs[tab.undoindex]);
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
4003
+
4004
+ //if (!tab.user[tab.versionindex])
4005
+ // tab.graphs[tab.versionindex] = null;
34124006 }
34134007
34144008 void ImportGFD()
....@@ -3560,7 +4154,7 @@
35604154 assert false;
35614155 }
35624156
3563
- void EditSelection()
4157
+ void EditSelection(boolean newWindow)
35644158 {
35654159 }
35664160
....@@ -3619,7 +4213,7 @@
36194213 //copy.material = new cMaterial(copy.GetMaterial());
36204214
36214215 current.color = (float) colorField.getFloat();
3622
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
36234217 current.metalness = (float) metalnessField.getFloat();
36244218 current.diffuse = (float) diffuseField.getFloat();
36254219 current.specular = (float) specularField.getFloat();
....@@ -3652,7 +4246,7 @@
36524246 cMaterial mat = copy.material;
36534247
36544248 colorField.SetToolTipValue((mat.color));
3655
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
36564250 metalnessField.SetToolTipValue((mat.metalness));
36574251 diffuseField.SetToolTipValue((mat.diffuse));
36584252 specularField.SetToolTipValue((mat.specular));
....@@ -3704,9 +4298,25 @@
37044298 //copy.Touch();
37054299 }
37064300
4301
+ cNumberSlider versionSlider;
4302
+
37074303 public void stateChanged(ChangeEvent e)
37084304 {
37094305 // assert(false);
4306
+ if (e.getSource() == versionSlider)
4307
+ {
4308
+ if (muteSlider)
4309
+ return;
4310
+
4311
+ int version = versionSlider.getInteger();
4312
+
4313
+ if (copy.versionlist[version] != null)
4314
+ {
4315
+ CopyChanged(copy.versionlist[copy.versionindex = version]);
4316
+ }
4317
+
4318
+ return;
4319
+ }
37104320
37114321 if (freezematerial)
37124322 {
....@@ -3742,6 +4352,12 @@
37424352 {
37434353 //System.out.println("stateChanged = " + this);
37444354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
37454361 applySelf();
37464362 //System.out.println("this = " + this);
37474363 //System.out.println("PARENT = " + parent);
....@@ -4041,6 +4657,7 @@
40414657 {
40424658 if (GetTree() != null)
40434659 {
4660
+ GetTree().revalidate();
40444661 GetTree().repaint();
40454662 }
40464663
....@@ -4055,7 +4672,8 @@
40554672
40564673 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40574674 {
4058
- Save();
4675
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4676
+ Save();
40594677 //Tween.set(thing, 0).target(1).start(tweenManager);
40604678 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40614679 // if (thing instanceof GenericJointDemo)
....@@ -4142,6 +4760,12 @@
41424760 {
41434761 ResetModel();
41444762 Select(thing.GetTreePath(), true, false); // unselect... false);
4763
+
4764
+ if (thing.Size() == 0)
4765
+ {
4766
+ //EditSelection(false);
4767
+ }
4768
+
41454769 refreshContents();
41464770 }
41474771
....@@ -4279,6 +4903,7 @@
42794903
42804904 try
42814905 {
4906
+ // Try compressed version first.
42824907 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
42834908 java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);
42844909 java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);
....@@ -4289,7 +4914,9 @@
42894914 readobj.ResetDisplayList();
42904915 } catch (Exception e)
42914916 {
4292
- //e.printStackTrace();
4917
+ if (!e.toString().contains("GZIP"))
4918
+ e.printStackTrace();
4919
+
42934920 try
42944921 {
42954922 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4348,6 +4975,12 @@
43484975
43494976 void LoadIt(Object obj)
43504977 {
4978
+ if (obj == null)
4979
+ {
4980
+ // Invalid file
4981
+ return;
4982
+ }
4983
+
43514984 System.out.println("Loaded " + obj);
43524985 //new Exception().printStackTrace();
43534986 Object3D readobj = (Object3D) obj;
....@@ -4357,11 +4990,14 @@
43574990
43584991 if (readobj != null)
43594992 {
4360
- Save();
4993
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4994
+ // Save();
43614995 try
43624996 {
43634997 //readobj.deepCopySelf(copy);
43644998 copy.clear(); // june 2014
4999
+ copy.skyboxname = readobj.skyboxname;
5000
+ copy.skyboxext = readobj.skyboxext;
43655001 for (int i = 0; i < readobj.size(); i++)
43665002 {
43675003 Object3D child = readobj.get(i); // reserve(i);
....@@ -4402,6 +5038,7 @@
44025038 }
44035039 } catch (ClassCastException e)
44045040 {
5041
+ e.printStackTrace();
44055042 assert (false);
44065043 Composite c = (Composite) copy;
44075044 c.children.clear();
....@@ -4412,13 +5049,24 @@
44125049 c.addChild(csg);
44135050 }
44145051
5052
+ copy.versionlist = readobj.versionlist;
5053
+ copy.versionindex = readobj.versionindex;
5054
+
5055
+ if (copy.versionlist == null)
5056
+ {
5057
+ copy.versionlist = new Object3D[100];
5058
+ copy.versionindex = -1;
5059
+ }
5060
+
5061
+ //? SetUndoStates();
5062
+
44155063 ResetModel();
44165064 copy.HardTouch(); // recompile?
44175065 refreshContents();
44185066 }
44195067 }
44205068
4421
- void load() // throws ClassNotFoundException
5069
+ void Open() // throws ClassNotFoundException
44225070 {
44235071 if (Grafreed.standAlone)
44245072 {
....@@ -4521,6 +5169,7 @@
45215169 //ps.print(buffer.toString());
45225170 } catch (IOException e)
45235171 {
5172
+ e.printStackTrace();
45245173 }
45255174 }
45265175
....@@ -4535,6 +5184,8 @@
45355184 String filename = browser.getFile();
45365185 if (filename != null && filename.length() > 0)
45375186 {
5187
+ if (!filename.endsWith(".gfd"))
5188
+ filename += ".gfd";
45385189 lastname = browser.getDirectory() + filename;
45395190 save();
45405191 }
....@@ -4701,7 +5352,7 @@
47015352 MenuBar menuBar;
47025353 Menu fileMenu;
47035354 MenuItem newItem;
4704
- MenuItem loadItem;
5355
+ MenuItem openItem;
47055356 MenuItem saveItem;
47065357 MenuItem saveAsItem;
47075358 MenuItem exportAsItem;
....@@ -4724,22 +5375,36 @@
47245375 CheckboxMenuItem toggleSwitchItem;
47255376 CheckboxMenuItem toggleRootItem;
47265377 CheckboxMenuItem animationItem;
5378
+ MenuItem archiveItem;
47275379 CheckboxMenuItem toggleHandleItem;
47285380 CheckboxMenuItem togglePaintItem;
47295381 JSplitPane mainPanel;
47305382 JScrollPane scrollpane;
5383
+
47315384 JPanel toolbarPanel;
5385
+
47325386 cGridBag treePanel;
5387
+
47335388 JPanel radioPanel;
47345389 ButtonGroup buttonGroup;
4735
- cGridBag ctrlPanel;
5390
+
5391
+ cGridBag toolboxPanel;
47365392 cGridBag materialPanel;
5393
+ cGridBag ctrlPanel;
5394
+
47375395 JScrollPane infoPanel;
5396
+
47385397 cGridBag optionsPanel;
5398
+
47395399 JTabbedPane objectPanel;
5400
+ boolean materialFlushed;
5401
+ Object3D latestObject;
5402
+
47405403 cGridBag XYZPanel;
5404
+
47415405 JSplitPane gridPanel;
47425406 JSplitPane bigPanel;
5407
+
47435408 cGridBag bigThree;
47445409 cGridBag scenePanel;
47455410 cGridBag centralPanel;
....@@ -4797,7 +5462,7 @@
47975462 JLabel colorLabel;
47985463 cNumberSlider colorField;
47995464 JLabel modulationLabel;
4800
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
48015466 JLabel metalnessLabel;
48025467 cNumberSlider metalnessField;
48035468 JLabel diffuseLabel;
....@@ -4854,7 +5519,7 @@
48545519 cNumberSlider fogField;
48555520 JLabel opacityPowerLabel;
48565521 cNumberSlider opacityPowerField;
4857
- JTree jTree;
5522
+ cTree jTree;
48585523 //ObjectUI parent;
48595524
48605525 cNumberSlider normalpushField;