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);
....@@ -169,7 +248,7 @@
169248
170249 objEditor.ctrlPanel.remove(setupPanel);
171250 objEditor.ctrlPanel.remove(setupPanel2);
172
- objEditor.ctrlPanel.remove(commandsPanel);
251
+ objEditor.ctrlPanel.remove(objectCommandsPanel);
173252 objEditor.ctrlPanel.remove(pushPanel);
174253 //objEditor.ctrlPanel.remove(fillPanel);
175254
....@@ -217,6 +296,12 @@
217296 client = inClient;
218297 copy = client;
219298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
220305 // "this" is not called: SetupUI2(objEditor);
221306 }
222307
....@@ -230,6 +315,12 @@
230315 client = inClient;
231316 copy = client;
232317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
233324 SetupUI2(callee.GetEditor());
234325 }
235326
....@@ -244,6 +335,7 @@
244335 //localCopy.parent = null;
245336
246337 frame = new JFrame();
338
+ frame.setUndecorated(false);
247339 objEditor = this;
248340 this.callee = callee;
249341
....@@ -261,6 +353,12 @@
261353 copy = localCopy;
262354 copy.editWindow = this;
263355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
264362 SetupMenu();
265363
266364 //SetupName(objEditor); // new
....@@ -274,12 +372,17 @@
274372 return frame.action(event, obj);
275373 }
276374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
277380 void SetupMenu()
278381 {
279382 frame.setMenuBar(menuBar = new MenuBar());
280383 menuBar.add(fileMenu = new Menu("File"));
281384 fileMenu.add(newItem = new MenuItem("New"));
282
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
283386
284387 //oe.menuBar.add(menu = new Menu("Include"));
285388 Menu menu = new Menu("Import");
....@@ -311,7 +414,7 @@
311414 }
312415
313416 newItem.addActionListener(this);
314
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
315418 saveItem.addActionListener(this);
316419 saveAsItem.addActionListener(this);
317420 exportAsItem.addActionListener(this);
....@@ -320,28 +423,68 @@
320423 closeItem.addActionListener(this);
321424
322425 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
+
323452 toolbarPanel = new JPanel();
324453 toolbarPanel.setName("Toolbar");
454
+
325455 treePanel = new cGridBag();
326456 treePanel.setName("Tree");
457
+
458
+ editPanel = new cGridBag().setVertical(true);
459
+ //editPanel.setName("Edit");
460
+
327461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
328
- ctrlPanel.setName("Edit");
329
- materialPanel = new cGridBag().setVertical(true);
330
- 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
+
331473 /*JTextPane*/
332474 infoarea = createTextPane();
333475 doc = infoarea.getStyledDocument();
334476
335477 infoarea.setEditable(true);
336478 SetText();
479
+
337480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
338481 // infoarea.setOpaque(false);
339482 // //infoarea.setForeground(textcolor);
340483 // TEXTAREA infoarea.setLineWrap(true);
341484 // TEXTAREA infoarea.setWrapStyleWord(true);
342485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
343
- infoPanel.setPreferredSize(new Dimension(50, 200));
344
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
345488 //infoPanel.setLayout(new BorderLayout());
346489 //infoPanel.add(createTextPane());
347490
....@@ -352,7 +495,14 @@
352495 mainPanel.setDividerSize(9);
353496 mainPanel.setDividerLocation(0.5); //1.0);
354497 mainPanel.setResizeWeight(0.5);
355
-
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
+
356506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
357507 //mainPanel.setLayout(new GridBagLayout());
358508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -583,21 +733,145 @@
583733 }
584734 }
585735
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
+
586794 void ToggleFullScreen()
587795 {
588
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
589801 {
590
- frame.getContentPane().remove(/*"Center",*/bigThree);
591
- framePanel.add(bigThree);
592
- 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
+
593825 } else
594826 {
595
- frame.getContentPane().remove(/*"Center",*/framePanel);
596
- framePanel.remove(bigThree);
597
- 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);
598849 }
599
- cameraView.ToggleFullScreen();
850
+ frame.validate();
600851 }
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
+ }
601875
602876 private JTextPane createTextPane()
603877 {
....@@ -720,6 +994,7 @@
720994 {
721995 SetupMaterial(materialPanel);
722996 }
997
+
723998 //SetupName();
724999 //SetupViews();
7251000 }
....@@ -729,7 +1004,7 @@
7291004 // NumberSlider vDivsField;
7301005 // JCheckBox endcaps;
7311006 JCheckBox liveCB;
732
- JCheckBox selectCB;
1007
+ JCheckBox selectableCB;
7331008 JCheckBox hideCB;
7341009 JCheckBox link2masterCB;
7351010 JCheckBox markCB;
....@@ -737,7 +1012,12 @@
7371012 JCheckBox speedupCB;
7381013 JCheckBox rewindCB;
7391014 JCheckBox flipVCB;
1015
+
1016
+ cCheckBox toggleTextureCB;
1017
+ cCheckBox toggleSwitchCB;
1018
+
7401019 JComboBox texresMenu;
1020
+
7411021 JButton resetButton;
7421022 JButton stepButton;
7431023 JButton stepAllButton;
....@@ -746,10 +1026,13 @@
7461026 JButton fasterButton;
7471027 JButton remarkButton;
7481028
1029
+ cGridBag editPanel;
1030
+ cGridBag editCommandsPanel;
1031
+
7491032 cGridBag namePanel;
7501033 cGridBag setupPanel;
7511034 cGridBag setupPanel2;
752
- cGridBag commandsPanel;
1035
+ cGridBag objectCommandsPanel;
7531036 cGridBag pushPanel;
7541037 cGridBag fillPanel;
7551038
....@@ -921,38 +1204,42 @@
9211204 namePanel = new cGridBag();
9221205
9231206 nameField = AddText(namePanel, copy.GetName());
924
- namePanel.add(nameField);
1207
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
9251208 oe.ctrlPanel.add(namePanel);
9261209
9271210 oe.ctrlPanel.Return();
9281211
929
- if (!GroupEditor.allparams)
1212
+ if (!allparams)
9301213 return;
9311214
9321215 setupPanel = new cGridBag().setVertical(false);
9331216
9341217 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
9351218 liveCB.setToolTipText("Animate object");
936
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
937
- selectCB.setToolTipText("Make object selectable");
1219
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1220
+ selectableCB.setToolTipText("Make object selectable");
9381221 // Return();
1222
+
9391223 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
9401224 hideCB.setToolTipText("Hide object");
9411225 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
942
- markCB.setToolTipText("Set the animation target transform");
1226
+ markCB.setToolTipText("As animation target transform");
1227
+
1228
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
9431229
9441230 setupPanel2 = new cGridBag().setVertical(false);
9451231
9461232 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
9471233 rewindCB.setToolTipText("Rewind animation");
9481234
949
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
950
- randomCB.setToolTipText("Rewind or Go back and forth randomly");
1235
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1236
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
9511237
1238
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1239
+ link2masterCB.setToolTipText("Attach to support");
1240
+
9521241 if (Globals.ADVANCED)
9531242 {
954
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
955
- link2masterCB.setToolTipText("Attach to support");
9561243 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
9571244 speedupCB.setToolTipText("Option motion capture");
9581245 }
....@@ -962,23 +1249,23 @@
9621249 oe.ctrlPanel.add(setupPanel2);
9631250 oe.ctrlPanel.Return();
9641251
965
- commandsPanel = new cGridBag().setVertical(false);
1252
+ objectCommandsPanel = new cGridBag().setVertical(false);
9661253
967
- resetButton = AddButton(commandsPanel, "Reset");
1254
+ resetButton = AddButton(objectCommandsPanel, "Reset");
9681255 resetButton.setToolTipText("Jump to frame zero");
969
- stepButton = AddButton(commandsPanel, "Step");
1256
+ stepButton = AddButton(objectCommandsPanel, "Step");
9701257 stepButton.setToolTipText("Step one frame");
9711258 // resetAllButton = AddButton(oe, "Reset All");
9721259 // stepAllButton = AddButton(oe, "Step All");
9731260 // Return();
974
- slowerButton = AddButton(commandsPanel, "Slow");
1261
+ slowerButton = AddButton(objectCommandsPanel, "Slow");
9751262 slowerButton.setToolTipText("Decrease animation speed");
976
- fasterButton = AddButton(commandsPanel, "Fast");
1263
+ fasterButton = AddButton(objectCommandsPanel, "Fast");
9771264 fasterButton.setToolTipText("Increase animation speed");
978
- remarkButton = AddButton(commandsPanel, "Remark");
1265
+ remarkButton = AddButton(objectCommandsPanel, "Remark");
9791266 remarkButton.setToolTipText("Set the current transform as the target");
9801267
981
- oe.ctrlPanel.add(commandsPanel);
1268
+ oe.ctrlPanel.add(objectCommandsPanel);
9821269 oe.ctrlPanel.Return();
9831270
9841271 pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
....@@ -1184,8 +1471,11 @@
11841471 //worldPanel.setName("World");
11851472 centralPanel = new cGridBag();
11861473 centralPanel.preferredWidth = 20;
1187
- timelinePanel = new JPanel(new BorderLayout());
1188
- 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);
11891479
11901480 cameraPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cameraView, timelinePanel);
11911481 cameraPanel.setContinuousLayout(true);
....@@ -1194,7 +1484,10 @@
11941484 // cameraPanel.setDividerSize(9);
11951485 cameraPanel.setResizeWeight(1.0);
11961486
1487
+ }
1488
+
11971489 centralPanel.add(cameraView);
1490
+ centralPanel.setFocusable(true);
11981491 //frame.setJMenuBar(timelineMenubar);
11991492 //centralPanel.add(timelinePanel);
12001493
....@@ -1220,6 +1513,7 @@
12201513 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
12211514 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
12221515 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1516
+ //XYZPanel.setName("XYZ");
12231517
12241518 /*
12251519 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1257,12 +1551,29 @@
12571551 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
12581552 //tmp.setName("Edit");
12591553 objectPanel.add(materialPanel);
1554
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1555
+ objectPanel.setToolTipTextAt(0, "Material");
1556
+
12601557 // JPanel north = new JPanel(new BorderLayout());
12611558 // north.setName("Edit");
12621559 // north.add(ctrlPanel, BorderLayout.NORTH);
12631560 // objectPanel.add(north);
1264
- objectPanel.add(ctrlPanel);
1265
- 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");
12661577
12671578 /*
12681579 aConstraints.gridx = 0;
....@@ -1271,7 +1582,7 @@
12711582 aConstraints.gridy += 1;
12721583 aConstraints.gridwidth = 1;
12731584 mainPanel.add(objectPanel, aConstraints);
1274
- */
1585
+ */
12751586
12761587 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
12771588 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1283,14 +1594,12 @@
12831594 scrollpane.addMouseWheelListener(this); // Default not fast enough
12841595
12851596 /*JTabbedPane*/ scenePanel = new cGridBag();
1286
- scenePanel.preferredWidth = 6;
1597
+ scenePanel.preferredWidth = 5;
12871598
12881599 JTabbedPane tabbedPane = new JTabbedPane();
12891600 tabbedPane.add(scrollpane);
12901601
1291
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1292
-
1293
- optionsPanel = new cGridBag().setVertical(true);
1602
+ optionsPanel = new cGridBag().setVertical(false);
12941603
12951604 optionsPanel.setName("Options");
12961605
....@@ -1298,6 +1607,8 @@
12981607
12991608 tabbedPane.add(optionsPanel);
13001609
1610
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1611
+
13011612 scenePanel.add(tabbedPane);
13021613
13031614 /*
....@@ -1361,7 +1672,7 @@
13611672 bigThree = new cGridBag();
13621673 bigThree.addComponent(scenePanel);
13631674 bigThree.addComponent(centralPanel);
1364
- bigThree.addComponent(XYZPanel);
1675
+ //bigThree.addComponent(XYZPanel);
13651676
13661677 // // SIDE EFFECT!!!
13671678 // aConstraints.gridx = 0;
....@@ -1370,9 +1681,9 @@
13701681 // aConstraints.gridheight = 1;
13711682
13721683 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1373
- framePanel.setContinuousLayout(true);
1374
- framePanel.setOneTouchExpandable(true);
1375
- framePanel.setDividerLocation(0.8);
1684
+ framePanel.setContinuousLayout(false);
1685
+ framePanel.setOneTouchExpandable(false);
1686
+ //.setDividerLocation(0.8);
13761687 //framePanel.setDividerSize(15);
13771688 //framePanel.setResizeWeight(0.15);
13781689 framePanel.setName("Frame");
....@@ -1390,14 +1701,18 @@
13901701 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
13911702
13921703 frame.setSize(1280, 860);
1393
- frame.setVisible(true);
1394
-
1704
+
1705
+ cameraView.requestFocusInWindow();
1706
+
13951707 gridPanel.setDividerLocation(1.0);
1708
+
1709
+ frame.validate();
1710
+
1711
+ frame.setVisible(true);
13961712
13971713 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
13981714 frame.addWindowListener(new WindowAdapter()
13991715 {
1400
-
14011716 public void windowClosing(WindowEvent e)
14021717 {
14031718 Close();
....@@ -1420,12 +1735,56 @@
14201735 ctrlPanel.removeAll();
14211736 }
14221737
1423
- void SetupMaterial(cGridBag panel)
1738
+ void SetupMaterial(cGridBag materialpanel)
14241739 {
1425
- /*
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
+ /*
14261785 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
14271786 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1428
- */
1787
+ */
14291788
14301789 cGridBag editBar = new cGridBag().setVertical(false);
14311790
....@@ -1459,45 +1818,50 @@
14591818 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
14601819
14611820 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);
14621834
14631835 cGridBag color = new cGridBag();
1464
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1465
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1466
- 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
+
14671841 //colorField.preferredWidth = 200;
14681842 colorSection.add(color);
14691843
14701844 cGridBag modulation = new cGridBag();
14711845 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
14721846 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1473
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1847
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
14741848 colorSection.add(modulation);
14751849
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
+
14761858 cGridBag texture = new cGridBag();
14771859 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
14781860 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
14791861 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
14801862 colorSection.add(texture);
14811863
1482
- cGridBag anisoU = new cGridBag();
1483
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1484
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1485
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1486
- colorSection.add(anisoU);
1487
-
1488
- cGridBag anisoV = new cGridBag();
1489
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1490
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1491
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1492
- colorSection.add(anisoV);
1493
-
1494
- cGridBag shadowbias = new cGridBag();
1495
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1496
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1497
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1498
- colorSection.add(shadowbias);
1499
-
1500
- panel.add(new JSeparator());
1864
+ panel.add(GetSeparator());
15011865
15021866 panel.add(colorSection);
15031867
....@@ -1547,7 +1911,13 @@
15471911 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
15481912 diffuseSection.add(fakedepth);
15491913
1550
- 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());
15511921
15521922 panel.add(diffuseSection);
15531923
....@@ -1597,42 +1967,48 @@
15971967 // aConstraints.gridy += 1;
15981968 // aConstraints.gridwidth = 1;
15991969
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);
16001975
1601
- 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());
16021984
16031985 panel.add(specularSection);
16041986
16051987 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16061988
1607
- cGridBag globalSection = new cGridBag().setVertical(true);
1989
+ //cGridBag globalSection = new cGridBag().setVertical(true);
16081990
16091991 cGridBag camera = new cGridBag();
16101992 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
16111993 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16121994 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1613
- globalSection.add(camera);
1995
+ colorSection.add(camera);
16141996
16151997 cGridBag ambient = new cGridBag();
16161998 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
16171999 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16182000 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1619
- globalSection.add(ambient);
2001
+ colorSection.add(ambient);
16202002
16212003 cGridBag backlit = new cGridBag();
16222004 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
16232005 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16242006 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1625
- globalSection.add(backlit);
2007
+ colorSection.add(backlit);
16262008
1627
- cGridBag opacity = new cGridBag();
1628
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1629
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1630
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1631
- globalSection.add(opacity);
1632
-
1633
- panel.add(new JSeparator());
2009
+ //panel.add(new JSeparator());
16342010
1635
- panel.add(globalSection);
2011
+ //panel.add(globalSection);
16362012
16372013 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16382014
....@@ -1674,7 +2050,7 @@
16742050 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
16752051 textureSection.add(opacityPower);
16762052
1677
- panel.add(new JSeparator());
2053
+ panel.add(GetSeparator());
16782054
16792055 panel.add(textureSection);
16802056
....@@ -1739,8 +2115,9 @@
17392115 // 3D models
17402116 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
17412117 {
1742
- lastConverter = new com.jmex.model.converters.MaxToJme();
1743
- LoadFile(filename, lastConverter);
2118
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2119
+ //LoadFile(filename, lastConverter);
2120
+ LoadObjFile(filename); // New 3ds loader
17442121 continue;
17452122 }
17462123 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2466,6 +2843,7 @@
24662843 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
24672844 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
24682845 }
2846
+
24692847 //cJME.count++;
24702848 //cJME.count %= 12;
24712849 if (gc)
....@@ -2649,6 +3027,7 @@
26493027 }
26503028 }
26513029 }
3030
+
26523031 cFileSystemPane FSPane;
26533032
26543033 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2658,7 +3037,7 @@
26583037
26593038 freezematerial = true;
26603039 colorField.setFloat(mat.color);
2661
- modulationField.setFloat(mat.modulation);
3040
+ saturationField.setFloat(mat.modulation);
26623041 metalnessField.setFloat(mat.metalness);
26633042 diffuseField.setFloat(mat.diffuse);
26643043 specularField.setFloat(mat.specular);
....@@ -2702,11 +3081,14 @@
27023081 }
27033082 }
27043083 }
3084
+
27053085 freezematerial = false;
27063086 }
27073087
27083088 void SetMaterial(Object3D object)
27093089 {
3090
+ latestObject = object;
3091
+
27103092 cMaterial mat = object.material;
27113093
27123094 if (mat == null)
....@@ -2818,12 +3200,17 @@
28183200 // }
28193201
28203202 /**/
2821
- if (deselect)
3203
+ if (deselect || child == null)
28223204 {
28233205 //group.deselectAll();
28243206 //freeze = true;
28253207 GetTree().clearSelection();
28263208 //freeze = false;
3209
+
3210
+ if (child == null)
3211
+ {
3212
+ return;
3213
+ }
28273214 }
28283215
28293216 //group.addSelectee(child);
....@@ -2892,7 +3279,7 @@
28923279 cameraView.ToggleDL();
28933280 cameraView.repaint();
28943281 return;
2895
- } else if (event.getSource() == toggleTextureItem)
3282
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
28963283 {
28973284 cameraView.ToggleTexture();
28983285 // june 2013 copy.HardTouch();
....@@ -2931,7 +3318,7 @@
29313318 frame.validate();
29323319
29333320 return;
2934
- } else if (event.getSource() == toggleSwitchItem)
3321
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
29353322 {
29363323 cameraView.ToggleSwitch();
29373324 cameraView.repaint();
....@@ -2961,8 +3348,9 @@
29613348 } else if (event.getSource() == liveCB)
29623349 {
29633350 copy.live ^= true;
3351
+ objEditor.refreshContents(true); // To show item colors
29643352 return;
2965
- } else if (event.getSource() == selectCB)
3353
+ } else if (event.getSource() == selectableCB)
29663354 {
29673355 copy.dontselect ^= true;
29683356 return;
....@@ -2970,7 +3358,7 @@
29703358 {
29713359 copy.hide ^= true;
29723360 copy.Touch(); // display list issue
2973
- objEditor.refreshContents();
3361
+ objEditor.refreshContents(true); // To show item colors
29743362 return;
29753363 } else if (event.getSource() == link2masterCB)
29763364 {
....@@ -3147,9 +3535,9 @@
31473535 {
31483536 Close();
31493537 //return true;
3150
- } else if (source == loadItem)
3538
+ } else if (source == openItem)
31513539 {
3152
- load();
3540
+ Open();
31533541 //return true;
31543542 } else if (source == newItem)
31553543 {
....@@ -3174,6 +3562,10 @@
31743562 {
31753563 generatePOV();
31763564 //return true;
3565
+ } else if (event.getSource() == archiveItem)
3566
+ {
3567
+ cTools.Archive(frame);
3568
+ return;
31773569 } else if (source == zBufferItem)
31783570 {
31793571 try
....@@ -3222,11 +3614,12 @@
32223614
32233615 static public byte[] Compress(Object3D o)
32243616 {
3617
+ // Slower to actually compress.
32253618 try
32263619 {
32273620 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3228
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3229
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3621
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3622
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
32303623
32313624 Object3D parent = o.parent;
32323625 o.parent = null;
....@@ -3237,10 +3630,14 @@
32373630
32383631 out.flush();
32393632
3240
- zstream.close();
3633
+ baos //zstream
3634
+ .close();
32413635 out.close();
32423636
3243
- return baos.toByteArray();
3637
+ byte[] bytes = baos.toByteArray();
3638
+
3639
+ System.out.println("save #bytes = " + bytes.length);
3640
+ return bytes;
32443641 } catch (Exception e)
32453642 {
32463643 System.err.println(e);
....@@ -3250,13 +3647,16 @@
32503647
32513648 static public Object Uncompress(byte[] bytes)
32523649 {
3253
- System.out.println("#bytes = " + bytes.length);
3650
+ System.out.println("restore #bytes = " + bytes.length);
32543651 try
32553652 {
32563653 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3257
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3258
- ObjectInputStream in = new ObjectInputStream(istream);
3654
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3655
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
32593656 Object obj = in.readObject();
3657
+
3658
+ bais //istream
3659
+ .close();
32603660 in.close();
32613661
32623662 return obj;
....@@ -3311,37 +3711,78 @@
33113711 return null;
33123712 }
33133713
3314
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
33153714
33163715 public void Save()
33173716 {
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
+
33183745 cRadio tab = GetCurrentTab();
33193746
3320
- boolean temp = CameraPane.SWITCH;
3321
- CameraPane.SWITCH = false;
3747
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace".
33223748
3323
- copy.ExtractBigData(hashtable);
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
+// }
33243755
33253756 //EditorFrame.m_MainFrame.requestFocusInWindow();
3326
- tab.graphs[tab.undoindex++] = Compress(copy);
3327
-
3328
- copy.RestoreBigData(hashtable);
3329
-
3330
- CameraPane.SWITCH = temp;
3331
-
3332
- //assert(hashtable.isEmpty());
3333
-
3334
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3757
+ if (!thesame)
33353758 {
3336
- 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++;
33373766 }
33383767
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
+
33393780 // test save
33403781 if (false)
33413782 {
33423783 try
33433784 {
3344
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3785
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
33453786 ObjectOutputStream p = new ObjectOutputStream(ostream);
33463787
33473788 p.writeObject(copy);
....@@ -3354,26 +3795,66 @@
33543795 e.printStackTrace();
33553796 }
33563797 }
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);
33573832 }
33583833
33593834 void CopyChanged(Object3D obj)
33603835 {
3836
+ SetUndoStates();
3837
+
33613838 boolean temp = CameraPane.SWITCH;
33623839 CameraPane.SWITCH = false;
33633840
3364
- copy.ExtractBigData(hashtable);
3841
+ copy.ExtractBigData(versiontable);
33653842
33663843 copy.clear();
33673844
3845
+ copy.skyboxname = obj.skyboxname;
3846
+ copy.skyboxext = obj.skyboxext;
3847
+
33683848 for (int i=0; i<obj.Size(); i++)
33693849 {
33703850 copy.add(obj.get(i));
33713851 }
33723852
3373
- copy.RestoreBigData(hashtable);
3853
+ copy.RestoreBigData(versiontable);
33743854
33753855 CameraPane.SWITCH = temp;
33763856
3857
+ RefreshSelection();
33773858 //assert(hashtable.isEmpty());
33783859
33793860 copy.Touch();
....@@ -3397,40 +3878,131 @@
33973878 refreshContents();
33983879 }
33993880
3400
- 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()
34013902 {
34023903 cRadio tab = GetCurrentTab();
34033904
3404
- 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)
34053927 {
34063928 java.awt.Toolkit.getDefaultToolkit().beep();
3407
- return;
3929
+ return false;
34083930 }
34093931
3410
- 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)
34113959 {
3412
- Save();
3413
- tab.undoindex -= 1;
3960
+ java.awt.Toolkit.getDefaultToolkit().beep();
3961
+ return false;
34143962 }
34153963
3416
- tab.undoindex -= 1;
3964
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3965
+ CopyChanged(copy.versionlist[copy.versionindex]);
3966
+
3967
+ return true;
3968
+ }
34173969
3418
- CopyChanged((Object3D)Uncompress(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;
34193985 }
34203986
34213987 public void Redo()
34223988 {
3989
+ // Option?
3990
+ Replace();
3991
+
34233992 cRadio tab = GetCurrentTab();
34243993
3425
- if (tab.graphs[tab.undoindex + 1] == null)
3994
+ if (copy.versionlist[copy.versionindex + 1] == null)
34263995 {
34273996 java.awt.Toolkit.getDefaultToolkit().beep();
34283997 return;
34293998 }
34303999
3431
- tab.undoindex += 1;
4000
+ copy.versionindex += 1;
34324001
3433
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged(copy.versionlist[copy.versionindex]);
4003
+
4004
+ //if (!tab.user[tab.versionindex])
4005
+ // tab.graphs[tab.versionindex] = null;
34344006 }
34354007
34364008 void ImportGFD()
....@@ -3582,7 +4154,7 @@
35824154 assert false;
35834155 }
35844156
3585
- void EditSelection()
4157
+ void EditSelection(boolean newWindow)
35864158 {
35874159 }
35884160
....@@ -3641,7 +4213,7 @@
36414213 //copy.material = new cMaterial(copy.GetMaterial());
36424214
36434215 current.color = (float) colorField.getFloat();
3644
- current.modulation = (float) modulationField.getFloat();
4216
+ current.modulation = (float) saturationField.getFloat();
36454217 current.metalness = (float) metalnessField.getFloat();
36464218 current.diffuse = (float) diffuseField.getFloat();
36474219 current.specular = (float) specularField.getFloat();
....@@ -3674,7 +4246,7 @@
36744246 cMaterial mat = copy.material;
36754247
36764248 colorField.SetToolTipValue((mat.color));
3677
- modulationField.SetToolTipValue((mat.modulation));
4249
+ saturationField.SetToolTipValue((mat.modulation));
36784250 metalnessField.SetToolTipValue((mat.metalness));
36794251 diffuseField.SetToolTipValue((mat.diffuse));
36804252 specularField.SetToolTipValue((mat.specular));
....@@ -3726,9 +4298,25 @@
37264298 //copy.Touch();
37274299 }
37284300
4301
+ cNumberSlider versionSlider;
4302
+
37294303 public void stateChanged(ChangeEvent e)
37304304 {
37314305 // 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
+ }
37324320
37334321 if (freezematerial)
37344322 {
....@@ -3764,6 +4352,12 @@
37644352 {
37654353 //System.out.println("stateChanged = " + this);
37664354 materialtouched = true;
4355
+
4356
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4357
+ {
4358
+ saturationField.setFloat(1);
4359
+ }
4360
+
37674361 applySelf();
37684362 //System.out.println("this = " + this);
37694363 //System.out.println("PARENT = " + parent);
....@@ -4063,6 +4657,7 @@
40634657 {
40644658 if (GetTree() != null)
40654659 {
4660
+ GetTree().revalidate();
40664661 GetTree().repaint();
40674662 }
40684663
....@@ -4077,7 +4672,8 @@
40774672
40784673 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
40794674 {
4080
- Save();
4675
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4676
+ Save();
40814677 //Tween.set(thing, 0).target(1).start(tweenManager);
40824678 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
40834679 // if (thing instanceof GenericJointDemo)
....@@ -4164,6 +4760,12 @@
41644760 {
41654761 ResetModel();
41664762 Select(thing.GetTreePath(), true, false); // unselect... false);
4763
+
4764
+ if (thing.Size() == 0)
4765
+ {
4766
+ //EditSelection(false);
4767
+ }
4768
+
41674769 refreshContents();
41684770 }
41694771
....@@ -4312,7 +4914,9 @@
43124914 readobj.ResetDisplayList();
43134915 } catch (Exception e)
43144916 {
4315
- //e.printStackTrace();
4917
+ if (!e.toString().contains("GZIP"))
4918
+ e.printStackTrace();
4919
+
43164920 try
43174921 {
43184922 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4386,11 +4990,14 @@
43864990
43874991 if (readobj != null)
43884992 {
4389
- Save();
4993
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4994
+ // Save();
43904995 try
43914996 {
43924997 //readobj.deepCopySelf(copy);
43934998 copy.clear(); // june 2014
4999
+ copy.skyboxname = readobj.skyboxname;
5000
+ copy.skyboxext = readobj.skyboxext;
43945001 for (int i = 0; i < readobj.size(); i++)
43955002 {
43965003 Object3D child = readobj.get(i); // reserve(i);
....@@ -4431,6 +5038,7 @@
44315038 }
44325039 } catch (ClassCastException e)
44335040 {
5041
+ e.printStackTrace();
44345042 assert (false);
44355043 Composite c = (Composite) copy;
44365044 c.children.clear();
....@@ -4441,13 +5049,24 @@
44415049 c.addChild(csg);
44425050 }
44435051
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
+
44445063 ResetModel();
44455064 copy.HardTouch(); // recompile?
44465065 refreshContents();
44475066 }
44485067 }
44495068
4450
- void load() // throws ClassNotFoundException
5069
+ void Open() // throws ClassNotFoundException
44515070 {
44525071 if (Grafreed.standAlone)
44535072 {
....@@ -4550,6 +5169,7 @@
45505169 //ps.print(buffer.toString());
45515170 } catch (IOException e)
45525171 {
5172
+ e.printStackTrace();
45535173 }
45545174 }
45555175
....@@ -4564,6 +5184,8 @@
45645184 String filename = browser.getFile();
45655185 if (filename != null && filename.length() > 0)
45665186 {
5187
+ if (!filename.endsWith(".gfd"))
5188
+ filename += ".gfd";
45675189 lastname = browser.getDirectory() + filename;
45685190 save();
45695191 }
....@@ -4730,7 +5352,7 @@
47305352 MenuBar menuBar;
47315353 Menu fileMenu;
47325354 MenuItem newItem;
4733
- MenuItem loadItem;
5355
+ MenuItem openItem;
47345356 MenuItem saveItem;
47355357 MenuItem saveAsItem;
47365358 MenuItem exportAsItem;
....@@ -4753,22 +5375,36 @@
47535375 CheckboxMenuItem toggleSwitchItem;
47545376 CheckboxMenuItem toggleRootItem;
47555377 CheckboxMenuItem animationItem;
5378
+ MenuItem archiveItem;
47565379 CheckboxMenuItem toggleHandleItem;
47575380 CheckboxMenuItem togglePaintItem;
47585381 JSplitPane mainPanel;
47595382 JScrollPane scrollpane;
5383
+
47605384 JPanel toolbarPanel;
5385
+
47615386 cGridBag treePanel;
5387
+
47625388 JPanel radioPanel;
47635389 ButtonGroup buttonGroup;
4764
- cGridBag ctrlPanel;
5390
+
5391
+ cGridBag toolboxPanel;
47655392 cGridBag materialPanel;
5393
+ cGridBag ctrlPanel;
5394
+
47665395 JScrollPane infoPanel;
5396
+
47675397 cGridBag optionsPanel;
5398
+
47685399 JTabbedPane objectPanel;
5400
+ boolean materialFlushed;
5401
+ Object3D latestObject;
5402
+
47695403 cGridBag XYZPanel;
5404
+
47705405 JSplitPane gridPanel;
47715406 JSplitPane bigPanel;
5407
+
47725408 cGridBag bigThree;
47735409 cGridBag scenePanel;
47745410 cGridBag centralPanel;
....@@ -4826,7 +5462,7 @@
48265462 JLabel colorLabel;
48275463 cNumberSlider colorField;
48285464 JLabel modulationLabel;
4829
- cNumberSlider modulationField;
5465
+ cNumberSlider saturationField;
48305466 JLabel metalnessLabel;
48315467 cNumberSlider metalnessField;
48325468 JLabel diffuseLabel;
....@@ -4883,7 +5519,7 @@
48835519 cNumberSlider fogField;
48845520 JLabel opacityPowerLabel;
48855521 cNumberSlider opacityPowerField;
4886
- JTree jTree;
5522
+ cTree jTree;
48875523 //ObjectUI parent;
48885524
48895525 cNumberSlider normalpushField;