Normand Briere
2019-08-05 de0d8d87447fea5faea469ccf8072a7aead35b6d
ObjEditor.java
....@@ -15,6 +15,9 @@
1515 //import javax.swing.plaf.ColorUIResource;
1616 //import javax.swing.plaf.metal.DefaultMetalTheme;
1717
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
20
+
1821 //import javax.media.opengl.GLCanvas;
1922
2023 import //weka.core.
....@@ -38,64 +41,78 @@
3841 JFrame frame;
3942
4043 static ObjEditor theFrame;
44
+
45
+ public cGridBag GetSeparator()
46
+ {
47
+ cGridBag separator = new cGridBag();
48
+ separator.add(new JSeparator());
49
+ separator.preferredHeight = 5;
50
+ return separator;
51
+ }
4152
4253 cButton GetButton(String name, boolean border)
4354 {
44
- try
45
- {
46
- ImageIcon icon = GetIcon(name);
47
- return new cButton(icon, border);
48
- }
49
- catch (Exception e)
50
- {
51
- return new cButton(name, border);
52
- }
55
+ ImageIcon icon = GetIcon(name);
56
+ return new cButton(icon, border);
57
+ }
58
+
59
+ cLabel GetLabel(String name, boolean border)
60
+ {
61
+ //ImageIcon icon = GetIcon(name);
62
+ return new cLabel(GetImage(name), border);
5363 }
5464
5565 cToggleButton GetToggleButton(String name, boolean border)
5666 {
57
- try
58
- {
59
- ImageIcon icon = GetIcon(name);
60
- return new cToggleButton(icon, border);
61
- }
62
- catch (Exception e)
63
- {
64
- return new cToggleButton(name, border);
65
- }
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
6669 }
6770
6871 cCheckBox GetCheckBox(String name, boolean border)
6972 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
7079 try
7180 {
72
- ImageIcon icon = GetIcon(name);
73
- return new cCheckBox(icon, border);
81
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
82
+
83
+// if (image.getWidth() > 48 && image.getHeight() > 48)
84
+// {
85
+// BufferedImage resized = new BufferedImage(48, 48, image.getType());
86
+// Graphics2D g = resized.createGraphics();
87
+// g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
88
+// //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
89
+// g.drawImage(image, 0, 0, 48, 48, 0, 0, image.getWidth(), image.getHeight(), null);
90
+// g.dispose();
91
+//
92
+// image = resized;
93
+// }
94
+
95
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
96
+ return icon;
7497 }
7598 catch (Exception e)
7699 {
77
- return new cCheckBox(name, border);
100
+ return null;
78101 }
79102 }
80
-
81
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
82105 {
83
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
84
-
85
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
86107 {
87
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
88
- Graphics2D g = resized.createGraphics();
89
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
90
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
91
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
92
- g.dispose();
93
-
94
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
95111 }
96
-
97
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
98
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
99116 }
100117
101118 // SCRIPT
....@@ -207,7 +224,7 @@
207224
208225 objEditor.ctrlPanel.remove(namePanel);
209226
210
- if (!GroupEditor.allparams)
227
+ if (!allparams)
211228 return;
212229
213230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -279,6 +296,12 @@
279296 client = inClient;
280297 copy = client;
281298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
282305 // "this" is not called: SetupUI2(objEditor);
283306 }
284307
....@@ -292,6 +315,12 @@
292315 client = inClient;
293316 copy = client;
294317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
295324 SetupUI2(callee.GetEditor());
296325 }
297326
....@@ -306,7 +335,7 @@
306335 //localCopy.parent = null;
307336
308337 frame = new JFrame();
309
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
310339 objEditor = this;
311340 this.callee = callee;
312341
....@@ -324,6 +353,12 @@
324353 copy = localCopy;
325354 copy.editWindow = this;
326355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
327362 SetupMenu();
328363
329364 //SetupName(objEditor); // new
....@@ -337,12 +372,17 @@
337372 return frame.action(event, obj);
338373 }
339374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
340380 void SetupMenu()
341381 {
342382 frame.setMenuBar(menuBar = new MenuBar());
343383 menuBar.add(fileMenu = new Menu("File"));
344384 fileMenu.add(newItem = new MenuItem("New"));
345
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
346386
347387 //oe.menuBar.add(menu = new Menu("Include"));
348388 Menu menu = new Menu("Import");
....@@ -374,7 +414,7 @@
374414 }
375415
376416 newItem.addActionListener(this);
377
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
378418 saveItem.addActionListener(this);
379419 saveAsItem.addActionListener(this);
380420 exportAsItem.addActionListener(this);
....@@ -398,6 +438,11 @@
398438 //
399439 // materialFlushed = true;
400440 // }
441
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
442
+// {
443
+// if (listUI.size() == 0)
444
+// EditSelection(false);
445
+// }
401446
402447 refreshContents(false); // To refresh Info tab
403448 }
....@@ -406,11 +451,12 @@
406451
407452 toolbarPanel = new JPanel();
408453 toolbarPanel.setName("Toolbar");
454
+
409455 treePanel = new cGridBag();
410456 treePanel.setName("Tree");
411457
412458 editPanel = new cGridBag().setVertical(true);
413
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
414460
415461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
416462
....@@ -418,11 +464,11 @@
418464 editPanel.add(editCommandsPanel);
419465 editPanel.add(ctrlPanel);
420466
421
- toolboxPanel = new cGridBag().setVertical(false);
422
- toolboxPanel.setName("Toolbox");
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
423469
424
- materialPanel = new cGridBag().setVertical(true);
425
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
426472
427473 /*JTextPane*/
428474 infoarea = createTextPane();
....@@ -430,14 +476,15 @@
430476
431477 infoarea.setEditable(true);
432478 SetText();
479
+
433480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
434481 // infoarea.setOpaque(false);
435482 // //infoarea.setForeground(textcolor);
436483 // TEXTAREA infoarea.setLineWrap(true);
437484 // TEXTAREA infoarea.setWrapStyleWord(true);
438485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
439
- infoPanel.setPreferredSize(new Dimension(50, 200));
440
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
441488 //infoPanel.setLayout(new BorderLayout());
442489 //infoPanel.add(createTextPane());
443490
....@@ -448,7 +495,14 @@
448495 mainPanel.setDividerSize(9);
449496 mainPanel.setDividerLocation(0.5); //1.0);
450497 mainPanel.setResizeWeight(0.5);
451
-
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
+
452506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
453507 //mainPanel.setLayout(new GridBagLayout());
454508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -679,8 +733,8 @@
679733 }
680734 }
681735
682
-static GraphicsDevice device = GraphicsEnvironment
683
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
684738
685739 Rectangle keeprect;
686740 cRadio radio;
....@@ -701,10 +755,19 @@
701755 void Minimize()
702756 {
703757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
704759 }
705760
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={}
706764 void Maximize()
707765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
708771 if (maximized)
709772 {
710773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -712,22 +775,36 @@
712775 else
713776 {
714777 keeprect = frame.getBounds();
715
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
716
- Dimension rect2 = frame.getToolkit().getScreenSize();
717
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
778
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
779
+// Dimension rect2 = frame.getToolkit().getScreenSize();
780
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
718781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
719783 }
720784
721785 maximized ^= true;
786
+
787
+ frame.validate();
722788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
723793
724794 void ToggleFullScreen()
725795 {
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
726798 cameraView.ToggleFullScreen();
727799
728800 if (!CameraPane.FULLSCREEN)
729801 {
730802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
731808 //frame.setVisible(false);
732809 // frame.removeNotify();
733810 // frame.setUndecorated(false);
....@@ -737,7 +814,7 @@
737814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
738815 // X framePanel.add(bigThree);
739816 // X frame.getContentPane().add(/*"Center",*/framePanel);
740
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
741818
742819 //frame.setVisible(true);
743820 radio.layout = keepButton;
....@@ -752,7 +829,12 @@
752829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
753830 // frame.getToolkit().getScreenSize().height);
754831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
755835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
756838 // frame.removeNotify();
757839 // frame.setUndecorated(true);
758840 // frame.addNotify();
....@@ -765,7 +847,33 @@
765847 radio.layout.doClick();
766848 //frame.setVisible(true);
767849 }
850
+ frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
768853 }
854
+
855
+ private Object3D CompressCopy()
856
+ {
857
+ boolean temp = CameraPane.SWITCH;
858
+ CameraPane.SWITCH = false;
859
+
860
+ copy.ExtractBigData(versiontable);
861
+ // if (copy == client)
862
+
863
+ Object3D versions[] = copy.versionlist;
864
+ copy.versionlist = null;
865
+
866
+ //byte[] compress = Compress(copy);
867
+ Object3D compress = (Object3D)Grafreed.clone(copy);
868
+
869
+ copy.versionlist = versions;
870
+
871
+ copy.RestoreBigData(versiontable);
872
+
873
+ CameraPane.SWITCH = temp;
874
+
875
+ return compress;
876
+ }
769877
770878 private JTextPane createTextPane()
771879 {
....@@ -888,6 +996,7 @@
888996 {
889997 SetupMaterial(materialPanel);
890998 }
999
+
8911000 //SetupName();
8921001 //SetupViews();
8931002 }
....@@ -897,7 +1006,7 @@
8971006 // NumberSlider vDivsField;
8981007 // JCheckBox endcaps;
8991008 JCheckBox liveCB;
900
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
9011010 JCheckBox hideCB;
9021011 JCheckBox link2masterCB;
9031012 JCheckBox markCB;
....@@ -1097,38 +1206,42 @@
10971206 namePanel = new cGridBag();
10981207
10991208 nameField = AddText(namePanel, copy.GetName());
1100
- namePanel.add(nameField);
1209
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11011210 oe.ctrlPanel.add(namePanel);
11021211
11031212 oe.ctrlPanel.Return();
11041213
1105
- if (!GroupEditor.allparams)
1214
+ if (!allparams)
11061215 return;
11071216
11081217 setupPanel = new cGridBag().setVertical(false);
11091218
11101219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
11111220 liveCB.setToolTipText("Animate object");
1112
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1113
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
11141223 // Return();
1224
+
11151225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
11161226 hideCB.setToolTipText("Hide object");
11171227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1118
- markCB.setToolTipText("Set the animation target transform");
1228
+ markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
11191231
11201232 setupPanel2 = new cGridBag().setVertical(false);
11211233
11221234 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11231235 rewindCB.setToolTipText("Rewind animation");
11241236
1125
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1126
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1237
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1238
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11271239
1240
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1241
+ link2masterCB.setToolTipText("Attach to support");
1242
+
11281243 if (Globals.ADVANCED)
11291244 {
1130
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1131
- link2masterCB.setToolTipText("Attach to support");
11321245 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11331246 speedupCB.setToolTipText("Option motion capture");
11341247 }
....@@ -1402,6 +1515,7 @@
14021515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
14031516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
14041517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
14051519
14061520 /*
14071521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1439,13 +1553,29 @@
14391553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
14401554 //tmp.setName("Edit");
14411555 objectPanel.add(materialPanel);
1442
- objectPanel.add(toolboxPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
14431559 // JPanel north = new JPanel(new BorderLayout());
14441560 // north.setName("Edit");
14451561 // north.add(ctrlPanel, BorderLayout.NORTH);
14461562 // objectPanel.add(north);
14471563 objectPanel.add(editPanel);
1448
- objectPanel.add(infoPanel);
1564
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1565
+ objectPanel.setToolTipTextAt(1, "Edit controls");
1566
+
1567
+ //if (Globals.ADVANCED)
1568
+ objectPanel.add(infoPanel);
1569
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1570
+ objectPanel.setToolTipTextAt(2, "Information");
1571
+
1572
+ objectPanel.add(XYZPanel);
1573
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1574
+ objectPanel.setToolTipTextAt(3, "XYZ/RGB transform");
1575
+
1576
+ objectPanel.add(toolboxPanel);
1577
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
1578
+ objectPanel.setToolTipTextAt(4, "Objects & backgrounds");
14491579
14501580 /*
14511581 aConstraints.gridx = 0;
....@@ -1454,7 +1584,7 @@
14541584 aConstraints.gridy += 1;
14551585 aConstraints.gridwidth = 1;
14561586 mainPanel.add(objectPanel, aConstraints);
1457
- */
1587
+ */
14581588
14591589 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14601590 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1466,7 +1596,7 @@
14661596 scrollpane.addMouseWheelListener(this); // Default not fast enough
14671597
14681598 /*JTabbedPane*/ scenePanel = new cGridBag();
1469
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
14701600
14711601 JTabbedPane tabbedPane = new JTabbedPane();
14721602 tabbedPane.add(scrollpane);
....@@ -1544,7 +1674,7 @@
15441674 bigThree = new cGridBag();
15451675 bigThree.addComponent(scenePanel);
15461676 bigThree.addComponent(centralPanel);
1547
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
15481678
15491679 // // SIDE EFFECT!!!
15501680 // aConstraints.gridx = 0;
....@@ -1553,9 +1683,9 @@
15531683 // aConstraints.gridheight = 1;
15541684
15551685 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1556
- framePanel.setContinuousLayout(true);
1557
- framePanel.setOneTouchExpandable(true);
1558
- framePanel.setDividerLocation(0.8);
1686
+ framePanel.setContinuousLayout(false);
1687
+ framePanel.setOneTouchExpandable(false);
1688
+ //.setDividerLocation(0.8);
15591689 //framePanel.setDividerSize(15);
15601690 //framePanel.setResizeWeight(0.15);
15611691 framePanel.setName("Frame");
....@@ -1574,17 +1704,17 @@
15741704
15751705 frame.setSize(1280, 860);
15761706
1577
- frame.validate();
1578
- frame.setVisible(true);
1579
-
15801707 cameraView.requestFocusInWindow();
15811708
15821709 gridPanel.setDividerLocation(1.0);
1710
+
1711
+ frame.validate();
1712
+
1713
+ frame.setVisible(true);
15831714
15841715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15851716 frame.addWindowListener(new WindowAdapter()
15861717 {
1587
-
15881718 public void windowClosing(WindowEvent e)
15891719 {
15901720 Close();
....@@ -1607,12 +1737,85 @@
16071737 ctrlPanel.removeAll();
16081738 }
16091739
1610
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
16111741 {
1612
- /*
1742
+ cGridBag presetpanel = new cGridBag().setVertical(true);
1743
+ cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
1744
+ skin.addMouseListener(new MouseAdapter()
1745
+ {
1746
+ public void mouseClicked(MouseEvent e)
1747
+ {
1748
+ Object3D object = Grafreed.materials.versionlist[0].get(0);
1749
+ cMaterial material = object.material;
1750
+
1751
+ // Skin
1752
+ colorField.setFloat(material.color);
1753
+ saturationField.setFloat(material.modulation);
1754
+ subsurfaceField.setFloat(material.subsurface);
1755
+ selfshadowField.setFloat(material.diffuseness);
1756
+ diffusenessField.setFloat(material.factor);
1757
+ shininessField.setFloat(material.shininess);
1758
+ shadowbiasField.setFloat(material.shadowbias);
1759
+ diffuseField.setFloat(material.diffuse);
1760
+ specularField.setFloat(material.specular);
1761
+
1762
+ bumpField.setFloat(object.projectedVertices[0].x / 1000.0);
1763
+ noiseField.setFloat(object.projectedVertices[0].y / 1000.0);
1764
+ powerField.setFloat(object.projectedVertices[2].x / 1000.0);
1765
+
1766
+ materialtouched = true;
1767
+ applySelf();
1768
+ }
1769
+ });
1770
+ presetpanel.add(skin);
1771
+
1772
+ cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
1773
+ rough2.addMouseListener(new MouseAdapter()
1774
+ {
1775
+ public void mouseClicked(MouseEvent e)
1776
+ {
1777
+ Object3D object = Grafreed.materials.versionlist[1].get(0);
1778
+ cMaterial material = object.material;
1779
+
1780
+ shininessField.setFloat(material.shininess);
1781
+ velvetField.setFloat(material.velvet);
1782
+
1783
+ materialtouched = true;
1784
+ applySelf();
1785
+ }
1786
+ });
1787
+ presetpanel.add(rough2);
1788
+
1789
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF));
1790
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF));
1791
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF));
1792
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF));
1793
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF));
1794
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF));
1795
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF));
1796
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF));
1797
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF));
1798
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF));
1799
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF));
1800
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF));
1801
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF));
1802
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF));
1803
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF));
1804
+ presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF));
1805
+
1806
+ cGridBag panel = new cGridBag().setVertical(true);
1807
+
1808
+ presetpanel.preferredWidth = 1;
1809
+
1810
+ materialpanel.add(panel);
1811
+ materialpanel.add(presetpanel);
1812
+
1813
+ panel.preferredWidth = 8;
1814
+
1815
+ /*
16131816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
16141817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1615
- */
1818
+ */
16161819
16171820 cGridBag editBar = new cGridBag().setVertical(false);
16181821
....@@ -1646,45 +1849,50 @@
16461849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16471850
16481851 cGridBag colorSection = new cGridBag().setVertical(true);
1852
+
1853
+ cGridBag huepanel = new cGridBag();
1854
+ cGridBag huelabel = new cGridBag();
1855
+ skin = GetLabel("icons/hue.png", false);
1856
+ skin.fit = true;
1857
+ huelabel.add(skin);
1858
+ huelabel.preferredWidth = 20;
1859
+ huepanel.add(new cGridBag()); // Label
1860
+ huepanel.add(huelabel); // Field/slider
1861
+
1862
+ huepanel.preferredHeight = 7;
1863
+
1864
+ colorSection.add(huepanel);
16491865
16501866 cGridBag color = new cGridBag();
1651
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1652
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1653
- color.add(colorField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1867
+
1868
+ color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1869
+ colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1870
+ color.add(colorField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1871
+
16541872 //colorField.preferredWidth = 200;
16551873 colorSection.add(color);
16561874
16571875 cGridBag modulation = new cGridBag();
16581876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16591877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1660
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16611879 colorSection.add(modulation);
16621880
1881
+ cGridBag opacity = new cGridBag();
1882
+ opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1883
+ opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1884
+ opacity.add(opacityField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
1885
+ colorSection.add(opacity);
1886
+
1887
+ colorSection.add(GetSeparator());
1888
+
16631889 cGridBag texture = new cGridBag();
16641890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16651891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16661892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16671893 colorSection.add(texture);
16681894
1669
- cGridBag anisoU = new cGridBag();
1670
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1671
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1672
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1673
- colorSection.add(anisoU);
1674
-
1675
- cGridBag anisoV = new cGridBag();
1676
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1677
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1678
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1679
- colorSection.add(anisoV);
1680
-
1681
- cGridBag shadowbias = new cGridBag();
1682
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1683
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1684
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1685
- colorSection.add(shadowbias);
1686
-
1687
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
16881896
16891897 panel.add(colorSection);
16901898
....@@ -1734,7 +1942,13 @@
17341942 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17351943 diffuseSection.add(fakedepth);
17361944
1737
- panel.add(new JSeparator());
1945
+ cGridBag shadowbias = new cGridBag();
1946
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1947
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1948
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1949
+ diffuseSection.add(shadowbias);
1950
+
1951
+ panel.add(GetSeparator());
17381952
17391953 panel.add(diffuseSection);
17401954
....@@ -1784,42 +1998,48 @@
17841998 // aConstraints.gridy += 1;
17851999 // aConstraints.gridwidth = 1;
17862000
2001
+ cGridBag anisoU = new cGridBag();
2002
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
2003
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2004
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2005
+ specularSection.add(anisoU);
17872006
1788
- panel.add(new JSeparator());
2007
+ cGridBag anisoV = new cGridBag();
2008
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
2009
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
2010
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
2011
+ specularSection.add(anisoV);
2012
+
2013
+
2014
+ panel.add(GetSeparator());
17892015
17902016 panel.add(specularSection);
17912017
17922018 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17932019
1794
- cGridBag globalSection = new cGridBag().setVertical(true);
2020
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17952021
17962022 cGridBag camera = new cGridBag();
17972023 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17982024 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17992025 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1800
- globalSection.add(camera);
2026
+ colorSection.add(camera);
18012027
18022028 cGridBag ambient = new cGridBag();
18032029 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18042030 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18052031 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1806
- globalSection.add(ambient);
2032
+ colorSection.add(ambient);
18072033
18082034 cGridBag backlit = new cGridBag();
18092035 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18102036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18112037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1812
- globalSection.add(backlit);
2038
+ colorSection.add(backlit);
18132039
1814
- cGridBag opacity = new cGridBag();
1815
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1816
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1817
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1818
- globalSection.add(opacity);
1819
-
1820
- panel.add(new JSeparator());
2040
+ //panel.add(new JSeparator());
18212041
1822
- panel.add(globalSection);
2042
+ //panel.add(globalSection);
18232043
18242044 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18252045
....@@ -1861,7 +2081,7 @@
18612081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18622082 textureSection.add(opacityPower);
18632083
1864
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
18652085
18662086 panel.add(textureSection);
18672087
....@@ -1926,8 +2146,9 @@
19262146 // 3D models
19272147 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19282148 {
1929
- lastConverter = new com.jmex.model.converters.MaxToJme();
1930
- LoadFile(filename, lastConverter);
2149
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2150
+ //LoadFile(filename, lastConverter);
2151
+ LoadObjFile(filename); // New 3ds loader
19312152 continue;
19322153 }
19332154 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2653,6 +2874,7 @@
26532874 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26542875 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26552876 }
2877
+
26562878 //cJME.count++;
26572879 //cJME.count %= 12;
26582880 if (gc)
....@@ -2836,6 +3058,7 @@
28363058 }
28373059 }
28383060 }
3061
+
28393062 cFileSystemPane FSPane;
28403063
28413064 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2845,7 +3068,7 @@
28453068
28463069 freezematerial = true;
28473070 colorField.setFloat(mat.color);
2848
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
28493072 metalnessField.setFloat(mat.metalness);
28503073 diffuseField.setFloat(mat.diffuse);
28513074 specularField.setFloat(mat.specular);
....@@ -2889,6 +3112,7 @@
28893112 }
28903113 }
28913114 }
3115
+
28923116 freezematerial = false;
28933117 }
28943118
....@@ -3007,12 +3231,17 @@
30073231 // }
30083232
30093233 /**/
3010
- if (deselect)
3234
+ if (deselect || child == null)
30113235 {
30123236 //group.deselectAll();
30133237 //freeze = true;
30143238 GetTree().clearSelection();
30153239 //freeze = false;
3240
+
3241
+ if (child == null)
3242
+ {
3243
+ return;
3244
+ }
30163245 }
30173246
30183247 //group.addSelectee(child);
....@@ -3150,8 +3379,9 @@
31503379 } else if (event.getSource() == liveCB)
31513380 {
31523381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
31533383 return;
3154
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
31553385 {
31563386 copy.dontselect ^= true;
31573387 return;
....@@ -3159,7 +3389,7 @@
31593389 {
31603390 copy.hide ^= true;
31613391 copy.Touch(); // display list issue
3162
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
31633393 return;
31643394 } else if (event.getSource() == link2masterCB)
31653395 {
....@@ -3336,9 +3566,9 @@
33363566 {
33373567 Close();
33383568 //return true;
3339
- } else if (source == loadItem)
3569
+ } else if (source == openItem)
33403570 {
3341
- load();
3571
+ Open();
33423572 //return true;
33433573 } else if (source == newItem)
33443574 {
....@@ -3363,6 +3593,10 @@
33633593 {
33643594 generatePOV();
33653595 //return true;
3596
+ } else if (event.getSource() == archiveItem)
3597
+ {
3598
+ cTools.Archive(frame);
3599
+ return;
33663600 } else if (source == zBufferItem)
33673601 {
33683602 try
....@@ -3411,11 +3645,12 @@
34113645
34123646 static public byte[] Compress(Object3D o)
34133647 {
3648
+ // Slower to actually compress.
34143649 try
34153650 {
34163651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3417
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3418
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3652
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3653
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34193654
34203655 Object3D parent = o.parent;
34213656 o.parent = null;
....@@ -3426,10 +3661,14 @@
34263661
34273662 out.flush();
34283663
3429
- zstream.close();
3664
+ baos //zstream
3665
+ .close();
34303666 out.close();
34313667
3432
- return baos.toByteArray();
3668
+ byte[] bytes = baos.toByteArray();
3669
+
3670
+ System.out.println("save #bytes = " + bytes.length);
3671
+ return bytes;
34333672 } catch (Exception e)
34343673 {
34353674 System.err.println(e);
....@@ -3439,13 +3678,16 @@
34393678
34403679 static public Object Uncompress(byte[] bytes)
34413680 {
3442
- System.out.println("#bytes = " + bytes.length);
3681
+ System.out.println("restore #bytes = " + bytes.length);
34433682 try
34443683 {
34453684 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3446
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3447
- ObjectInputStream in = new ObjectInputStream(istream);
3685
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3686
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34483687 Object obj = in.readObject();
3688
+
3689
+ bais //istream
3690
+ .close();
34493691 in.close();
34503692
34513693 return obj;
....@@ -3500,39 +3742,95 @@
35003742 return null;
35013743 }
35023744
3503
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
35043745
35053746 public void Save()
35063747 {
3748
+ //Save(true);
3749
+ Replace();
3750
+ SetUndoStates();
3751
+ }
3752
+
3753
+ private boolean Equal(byte[] compress, byte[] name)
3754
+ {
3755
+ if (compress.length != name.length)
3756
+ {
3757
+ return false;
3758
+ }
3759
+
3760
+ for (int i=compress.length; --i>=0;)
3761
+ {
3762
+ if (compress[i] != name[i])
3763
+ return false;
3764
+ }
3765
+
3766
+ return true;
3767
+ }
3768
+
3769
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3770
+
3771
+ void DeleteVersion()
3772
+ {
3773
+ for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)
3774
+ {
3775
+ copy.versionlist[i] = copy.versionlist[i+1];
3776
+ }
3777
+
3778
+ CopyChanged();
3779
+
3780
+ SetUndoStates();
3781
+ }
3782
+
3783
+ public boolean Save(boolean user)
3784
+ {
35073785 System.err.println("Save");
3786
+ //Replace();
35083787
35093788 cRadio tab = GetCurrentTab();
35103789
3511
- boolean temp = CameraPane.SWITCH;
3512
- CameraPane.SWITCH = false;
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
35133791
3514
- copy.ExtractBigData(hashtable);
3792
+ boolean thesame = false;
3793
+
3794
+// if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3795
+// {
3796
+// thesame = true;
3797
+// }
35153798
35163799 //EditorFrame.m_MainFrame.requestFocusInWindow();
3517
- tab.graphs[tab.undoindex++] = Compress(copy);
3518
-
3519
- copy.RestoreBigData(hashtable);
3520
-
3521
- CameraPane.SWITCH = temp;
3522
-
3523
- //assert(hashtable.isEmpty());
3524
-
3525
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3800
+ if (!thesame)
35263801 {
3527
- tab.graphs[i] = null;
3802
+ for (int i = copy.versionlist.length; --i > copy.versionindex+1;)
3803
+ {
3804
+ copy.versionlist[i] = copy.versionlist[i-1];
3805
+ }
3806
+
3807
+ //tab.user[tab.versionindex] = user;
3808
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3809
+
3810
+ copy.versionlist[++copy.versionindex] = compress;
3811
+
3812
+ // if (increment)
3813
+ // tab.versionindex++;
35283814 }
35293815
3816
+ //copy.RestoreBigData(versiontable);
3817
+
3818
+ //assert(hashtable.isEmpty());
3819
+
3820
+// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)
3821
+// {
3822
+// //tab.user[i] = false;
3823
+// copy.versionlist[i] = null;
3824
+// }
3825
+
3826
+ SetUndoStates();
3827
+
35303828 // test save
35313829 if (false)
35323830 {
35333831 try
35343832 {
3535
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3833
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
35363834 ObjectOutputStream p = new ObjectOutputStream(ostream);
35373835
35383836 p.writeObject(copy);
....@@ -3545,26 +3843,68 @@
35453843 e.printStackTrace();
35463844 }
35473845 }
3846
+
3847
+ return !thesame;
3848
+ }
3849
+
3850
+ boolean flashIt = true;
3851
+
3852
+ void RefreshSelection()
3853
+ {
3854
+ Object3D selection = new Object3D();
3855
+
3856
+ for (int i = 0; i < copy.selection.size(); i++)
3857
+ {
3858
+ Object3D elem = copy.selection.elementAt(i);
3859
+
3860
+ Object3D obj = copy.GetObject(elem.GetUUID());
3861
+
3862
+ if (obj == null)
3863
+ {
3864
+ copy.selection.remove(i--);
3865
+ }
3866
+ else
3867
+ {
3868
+ selection.add(obj);
3869
+ copy.selection.setElementAt(obj, i);
3870
+ }
3871
+ }
3872
+
3873
+ flashIt = false;
3874
+ GetTree().clearSelection();
3875
+ for (int i = 0; i < selection.size(); i++)
3876
+ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath());
3877
+ flashIt = true;
3878
+
3879
+ //refreshContents(false);
35483880 }
35493881
3550
- void CopyChanged(Object3D obj)
3882
+ void CopyChanged()
35513883 {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
3886
+ SetUndoStates();
3887
+
35523888 boolean temp = CameraPane.SWITCH;
35533889 CameraPane.SWITCH = false;
35543890
3555
- copy.ExtractBigData(hashtable);
3891
+ copy.ExtractBigData(versiontable);
35563892
35573893 copy.clear();
35583894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
35593898 for (int i=0; i<obj.Size(); i++)
35603899 {
35613900 copy.add(obj.get(i));
35623901 }
35633902
3564
- copy.RestoreBigData(hashtable);
3903
+ copy.RestoreBigData(versiontable);
35653904
35663905 CameraPane.SWITCH = temp;
35673906
3907
+ RefreshSelection();
35683908 //assert(hashtable.isEmpty());
35693909
35703910 copy.Touch();
....@@ -3585,45 +3925,139 @@
35853925 }
35863926 }
35873927
3588
- refreshContents();
3928
+ refreshContents(true);
35893929 }
35903930
3591
- public void Undo()
3931
+ cButton previousVersionButton;
3932
+ cButton restoreButton;
3933
+ cButton replaceButton;
3934
+ cButton nextVersionButton;
3935
+ cButton saveVersionButton;
3936
+ cButton deleteVersionButton;
3937
+
3938
+ boolean muteSlider;
3939
+
3940
+ int VersionCount()
35923941 {
3942
+ int count = 0;
3943
+
3944
+ for (int i = copy.versionlist.length; --i >= 0;)
3945
+ {
3946
+ if (copy.versionlist[i] != null)
3947
+ count++;
3948
+ }
3949
+
3950
+ return count;
3951
+ }
3952
+
3953
+ void SetUndoStates()
3954
+ {
3955
+ cRadio tab = GetCurrentTab();
3956
+
3957
+ restoreButton.setEnabled(true); // copy.versionindex != -1);
3958
+ replaceButton.setEnabled(true); // copy.versionindex != -1);
3959
+
3960
+ previousVersionButton.setEnabled(copy.versionindex > 0);
3961
+ nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
3962
+
3963
+ deleteVersionButton.setEnabled(//copy.versionindex > 0 &&
3964
+ copy.versionlist[copy.versionindex + 1] != null);
3965
+
3966
+ muteSlider = true;
3967
+ versionSlider.setMaximum(VersionCount() - 1);
3968
+ versionSlider.setInteger(copy.versionindex);
3969
+ muteSlider = false;
3970
+ }
3971
+
3972
+ public boolean PreviousVersion()
3973
+ {
3974
+ // Option?
3975
+ Replace();
3976
+
35933977 System.err.println("Undo");
35943978
35953979 cRadio tab = GetCurrentTab();
35963980
3597
- if (tab.undoindex == 0)
3981
+ if (copy.versionindex == 0)
35983982 {
35993983 java.awt.Toolkit.getDefaultToolkit().beep();
3600
- return;
3984
+ return false;
36013985 }
36023986
3603
- if (tab.graphs[tab.undoindex] == null)
3604
- {
3605
- Save();
3606
- tab.undoindex -= 1;
3607
- }
3987
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3988
+// {
3989
+// if (Save(false))
3990
+// tab.versionindex -= 1;
3991
+// else
3992
+// {
3993
+// if (tab.versionindex <= 0)
3994
+// return false;
3995
+// else
3996
+// tab.versionindex -= 1;
3997
+// }
3998
+// }
36083999
3609
- tab.undoindex -= 1;
4000
+ copy.versionindex -= 1;
36104001
3611
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged();
4003
+
4004
+ return true;
36124005 }
36134006
3614
- public void Redo()
4007
+ public boolean Restore()
36154008 {
4009
+ System.err.println("Restore");
4010
+
36164011 cRadio tab = GetCurrentTab();
36174012
3618
- if (tab.graphs[tab.undoindex + 1] == null)
4013
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4014
+ {
4015
+ java.awt.Toolkit.getDefaultToolkit().beep();
4016
+ return false;
4017
+ }
4018
+
4019
+ //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
4020
+ CopyChanged();
4021
+
4022
+ return true;
4023
+ }
4024
+
4025
+ public boolean Replace()
4026
+ {
4027
+ System.err.println("Replace");
4028
+
4029
+ cRadio tab = GetCurrentTab();
4030
+
4031
+ if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
4032
+ {
4033
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
4034
+ return false;
4035
+ }
4036
+
4037
+ copy.versionlist[copy.versionindex] = CompressCopy();
4038
+
4039
+ return true;
4040
+ }
4041
+
4042
+ public void NextVersion()
4043
+ {
4044
+ // Option?
4045
+ Replace();
4046
+
4047
+ cRadio tab = GetCurrentTab();
4048
+
4049
+ if (copy.versionlist[copy.versionindex + 1] == null)
36194050 {
36204051 java.awt.Toolkit.getDefaultToolkit().beep();
36214052 return;
36224053 }
36234054
3624
- tab.undoindex += 1;
4055
+ copy.versionindex += 1;
36254056
3626
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4057
+ CopyChanged();
4058
+
4059
+ //if (!tab.user[tab.versionindex])
4060
+ // tab.graphs[tab.versionindex] = null;
36274061 }
36284062
36294063 void ImportGFD()
....@@ -3834,7 +4268,7 @@
38344268 //copy.material = new cMaterial(copy.GetMaterial());
38354269
38364270 current.color = (float) colorField.getFloat();
3837
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
38384272 current.metalness = (float) metalnessField.getFloat();
38394273 current.diffuse = (float) diffuseField.getFloat();
38404274 current.specular = (float) specularField.getFloat();
....@@ -3867,7 +4301,7 @@
38674301 cMaterial mat = copy.material;
38684302
38694303 colorField.SetToolTipValue((mat.color));
3870
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
38714305 metalnessField.SetToolTipValue((mat.metalness));
38724306 diffuseField.SetToolTipValue((mat.diffuse));
38734307 specularField.SetToolTipValue((mat.specular));
....@@ -3919,9 +4353,26 @@
39194353 //copy.Touch();
39204354 }
39214355
4356
+ cNumberSlider versionSlider;
4357
+
39224358 public void stateChanged(ChangeEvent e)
39234359 {
39244360 // assert(false);
4361
+ if (e.getSource() == versionSlider)
4362
+ {
4363
+ if (muteSlider)
4364
+ return;
4365
+
4366
+ int version = versionSlider.getInteger();
4367
+
4368
+ if (copy.versionlist[version] != null)
4369
+ {
4370
+ copy.versionindex = version;
4371
+ CopyChanged();
4372
+ }
4373
+
4374
+ return;
4375
+ }
39254376
39264377 if (freezematerial)
39274378 {
....@@ -3957,6 +4408,12 @@
39574408 {
39584409 //System.out.println("stateChanged = " + this);
39594410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
39604417 applySelf();
39614418 //System.out.println("this = " + this);
39624419 //System.out.println("PARENT = " + parent);
....@@ -4256,6 +4713,7 @@
42564713 {
42574714 if (GetTree() != null)
42584715 {
4716
+ GetTree().revalidate();
42594717 GetTree().repaint();
42604718 }
42614719
....@@ -4264,13 +4722,16 @@
42644722 ctrlPanel.validate(); // ? new
42654723 ctrlPanel.repaint();
42664724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
42674728 }
42684729
42694730 static TweenManager tweenManager = new TweenManager();
42704731
42714732 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42724733 {
4273
- if (Globals.SAVEONMAKE) // && resetmodel)
4734
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42744735 Save();
42754736 //Tween.set(thing, 0).target(1).start(tweenManager);
42764737 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4512,7 +4973,9 @@
45124973 readobj.ResetDisplayList();
45134974 } catch (Exception e)
45144975 {
4515
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
45164979 try
45174980 {
45184981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4586,12 +5049,14 @@
45865049
45875050 if (readobj != null)
45885051 {
4589
- if (Globals.SAVEONMAKE)
4590
- Save();
5052
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5053
+ // Save();
45915054 try
45925055 {
45935056 //readobj.deepCopySelf(copy);
45945057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
45955060 for (int i = 0; i < readobj.size(); i++)
45965061 {
45975062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4632,6 +5097,7 @@
46325097 }
46335098 } catch (ClassCastException e)
46345099 {
5100
+ e.printStackTrace();
46355101 assert (false);
46365102 Composite c = (Composite) copy;
46375103 c.children.clear();
....@@ -4642,17 +5108,28 @@
46425108 c.addChild(csg);
46435109 }
46445110
5111
+ copy.versionlist = readobj.versionlist;
5112
+ copy.versionindex = readobj.versionindex;
5113
+
5114
+ if (copy.versionlist == null)
5115
+ {
5116
+ copy.versionlist = new Object3D[100];
5117
+ copy.versionindex = -1;
5118
+ }
5119
+
5120
+ //? SetUndoStates();
5121
+
46455122 ResetModel();
46465123 copy.HardTouch(); // recompile?
46475124 refreshContents();
46485125 }
46495126 }
46505127
4651
- void load() // throws ClassNotFoundException
5128
+ void Open() // throws ClassNotFoundException
46525129 {
46535130 if (Grafreed.standAlone)
46545131 {
4655
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46565133 browser.show();
46575134 String filename = browser.getFile();
46585135 if (filename != null && filename.length() > 0)
....@@ -4751,6 +5228,7 @@
47515228 //ps.print(buffer.toString());
47525229 } catch (IOException e)
47535230 {
5231
+ e.printStackTrace();
47545232 }
47555233 }
47565234
....@@ -4765,6 +5243,8 @@
47655243 String filename = browser.getFile();
47665244 if (filename != null && filename.length() > 0)
47675245 {
5246
+ if (!filename.endsWith(".gfd"))
5247
+ filename += ".gfd";
47685248 lastname = browser.getDirectory() + filename;
47695249 save();
47705250 }
....@@ -4931,7 +5411,7 @@
49315411 MenuBar menuBar;
49325412 Menu fileMenu;
49335413 MenuItem newItem;
4934
- MenuItem loadItem;
5414
+ MenuItem openItem;
49355415 MenuItem saveItem;
49365416 MenuItem saveAsItem;
49375417 MenuItem exportAsItem;
....@@ -4954,6 +5434,7 @@
49545434 CheckboxMenuItem toggleSwitchItem;
49555435 CheckboxMenuItem toggleRootItem;
49565436 CheckboxMenuItem animationItem;
5437
+ MenuItem archiveItem;
49575438 CheckboxMenuItem toggleHandleItem;
49585439 CheckboxMenuItem togglePaintItem;
49595440 JSplitPane mainPanel;
....@@ -5040,7 +5521,7 @@
50405521 JLabel colorLabel;
50415522 cNumberSlider colorField;
50425523 JLabel modulationLabel;
5043
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
50445525 JLabel metalnessLabel;
50455526 cNumberSlider metalnessField;
50465527 JLabel diffuseLabel;