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,51 +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);
63
+ }
64
+
65
+ cToggleButton GetToggleButton(String name, boolean border)
66
+ {
67
+ ImageIcon icon = GetIcon(name);
68
+ return new cToggleButton(icon, border);
5369 }
5470
5571 cCheckBox GetCheckBox(String name, boolean border)
5672 {
73
+ ImageIcon icon = GetIcon(name);
74
+ return new cCheckBox(icon, border);
75
+ }
76
+
77
+ ImageIcon GetIcon(String name)
78
+ {
5779 try
5880 {
59
- ImageIcon icon = GetIcon(name);
60
- 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;
6197 }
6298 catch (Exception e)
6399 {
64
- return new cCheckBox(name, border);
100
+ return null;
65101 }
66102 }
67
-
68
- private ImageIcon GetIcon(String name) throws IOException
103
+
104
+ BufferedImage GetImage(String name)
69105 {
70
- BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
71
-
72
- if (image.getWidth() != 24 && image.getHeight() != 24)
106
+ try
73107 {
74
- BufferedImage resized = new BufferedImage(24, 24, image.getType());
75
- Graphics2D g = resized.createGraphics();
76
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
77
- //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
78
- g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
79
- g.dispose();
80
-
81
- image = resized;
108
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
109
+
110
+ return image;
82111 }
83
-
84
- javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
85
- return icon;
112
+ catch (Exception e)
113
+ {
114
+ return null;
115
+ }
86116 }
87117
88118 // SCRIPT
....@@ -194,7 +224,7 @@
194224
195225 objEditor.ctrlPanel.remove(namePanel);
196226
197
- if (!GroupEditor.allparams)
227
+ if (!allparams)
198228 return;
199229
200230 // objEditor.ctrlPanel.remove(liveCB);
....@@ -266,6 +296,12 @@
266296 client = inClient;
267297 copy = client;
268298
299
+ if (copy.versionlist == null)
300
+ {
301
+ copy.versionlist = new Object3D[100];
302
+ copy.versionindex = -1;
303
+ }
304
+
269305 // "this" is not called: SetupUI2(objEditor);
270306 }
271307
....@@ -279,6 +315,12 @@
279315 client = inClient;
280316 copy = client;
281317
318
+ if (copy.versionlist == null)
319
+ {
320
+ copy.versionlist = new Object3D[100];
321
+ copy.versionindex = -1;
322
+ }
323
+
282324 SetupUI2(callee.GetEditor());
283325 }
284326
....@@ -293,7 +335,7 @@
293335 //localCopy.parent = null;
294336
295337 frame = new JFrame();
296
- frame.setUndecorated(true);
338
+ frame.setUndecorated(false);
297339 objEditor = this;
298340 this.callee = callee;
299341
....@@ -311,6 +353,12 @@
311353 copy = localCopy;
312354 copy.editWindow = this;
313355
356
+ if (copy.versionlist == null)
357
+ {
358
+// copy.versions = new byte[100][];
359
+// copy.versionindex = -1;
360
+ }
361
+
314362 SetupMenu();
315363
316364 //SetupName(objEditor); // new
....@@ -324,12 +372,17 @@
324372 return frame.action(event, obj);
325373 }
326374
375
+ // Cannot work without static
376
+ static boolean allparams = true;
377
+
378
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
379
+
327380 void SetupMenu()
328381 {
329382 frame.setMenuBar(menuBar = new MenuBar());
330383 menuBar.add(fileMenu = new Menu("File"));
331384 fileMenu.add(newItem = new MenuItem("New"));
332
- fileMenu.add(loadItem = new MenuItem("Open..."));
385
+ fileMenu.add(openItem = new MenuItem("Open..."));
333386
334387 //oe.menuBar.add(menu = new Menu("Include"));
335388 Menu menu = new Menu("Import");
....@@ -361,7 +414,7 @@
361414 }
362415
363416 newItem.addActionListener(this);
364
- loadItem.addActionListener(this);
417
+ openItem.addActionListener(this);
365418 saveItem.addActionListener(this);
366419 saveAsItem.addActionListener(this);
367420 exportAsItem.addActionListener(this);
....@@ -370,13 +423,40 @@
370423 closeItem.addActionListener(this);
371424
372425 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
+
373452 toolbarPanel = new JPanel();
374453 toolbarPanel.setName("Toolbar");
454
+
375455 treePanel = new cGridBag();
376456 treePanel.setName("Tree");
377457
378458 editPanel = new cGridBag().setVertical(true);
379
- editPanel.setName("Edit");
459
+ //editPanel.setName("Edit");
380460
381461 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
382462
....@@ -384,23 +464,27 @@
384464 editPanel.add(editCommandsPanel);
385465 editPanel.add(ctrlPanel);
386466
387
- materialPanel = new cGridBag().setVertical(true);
467
+ toolboxPanel = new cGridBag().setVertical(true);
468
+ //toolboxPanel.setName("Toolbox");
388469
389
- materialPanel.setName("Material");
470
+ materialPanel = new cGridBag().setVertical(false);
471
+ //materialPanel.setName("Material");
472
+
390473 /*JTextPane*/
391474 infoarea = createTextPane();
392475 doc = infoarea.getStyledDocument();
393476
394477 infoarea.setEditable(true);
395478 SetText();
479
+
396480 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
397481 // infoarea.setOpaque(false);
398482 // //infoarea.setForeground(textcolor);
399483 // TEXTAREA infoarea.setLineWrap(true);
400484 // TEXTAREA infoarea.setWrapStyleWord(true);
401485 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
402
- infoPanel.setPreferredSize(new Dimension(50, 200));
403
- infoPanel.setName("Info");
486
+ infoPanel.setPreferredSize(new Dimension(1, 1));
487
+ //infoPanel.setName("Info");
404488 //infoPanel.setLayout(new BorderLayout());
405489 //infoPanel.add(createTextPane());
406490
....@@ -411,7 +495,14 @@
411495 mainPanel.setDividerSize(9);
412496 mainPanel.setDividerLocation(0.5); //1.0);
413497 mainPanel.setResizeWeight(0.5);
414
-
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
+
415506 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
416507 //mainPanel.setLayout(new GridBagLayout());
417508 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -642,8 +733,8 @@
642733 }
643734 }
644735
645
-static GraphicsDevice device = GraphicsEnvironment
646
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
736
+//static GraphicsDevice device = GraphicsEnvironment
737
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
647738
648739 Rectangle keeprect;
649740 cRadio radio;
....@@ -659,13 +750,24 @@
659750
660751 boolean maximized;
661752
753
+ cButton fullscreenLayout;
754
+
662755 void Minimize()
663756 {
664757 frame.setState(Frame.ICONIFIED);
758
+ frame.validate();
665759 }
666760
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={}
667764 void Maximize()
668765 {
766
+ if (CameraPane.FULLSCREEN)
767
+ {
768
+ ToggleFullScreen();
769
+ }
770
+
669771 if (maximized)
670772 {
671773 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -673,20 +775,36 @@
673775 else
674776 {
675777 keeprect = frame.getBounds();
676
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
677
- Dimension rect2 = frame.getToolkit().getScreenSize();
678
- 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);
679781 // frame.setState(Frame.MAXIMIZED_BOTH);
782
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
680783 }
681784
682785 maximized ^= true;
786
+
787
+ frame.validate();
683788 }
789
+
790
+ cButton minButton;
791
+ cButton maxButton;
792
+ cButton fullButton;
684793
685794 void ToggleFullScreen()
686795 {
687
- if (CameraPane.FULLSCREEN)
796
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
797
+
798
+ cameraView.ToggleFullScreen();
799
+
800
+ if (!CameraPane.FULLSCREEN)
688801 {
689802 device.setFullScreenWindow(null);
803
+ frame.dispose();
804
+ frame.setUndecorated(false);
805
+ frame.validate();
806
+ frame.setVisible(true);
807
+
690808 //frame.setVisible(false);
691809 // frame.removeNotify();
692810 // frame.setUndecorated(false);
....@@ -696,7 +814,7 @@
696814 // X frame.getContentPane().remove(/*"Center",*/bigThree);
697815 // X framePanel.add(bigThree);
698816 // X frame.getContentPane().add(/*"Center",*/framePanel);
699
- framePanel.setDividerLocation(1);
817
+ framePanel.setDividerLocation(46);
700818
701819 //frame.setVisible(true);
702820 radio.layout = keepButton;
....@@ -711,7 +829,12 @@
711829 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
712830 // frame.getToolkit().getScreenSize().height);
713831 //frame.setVisible(false);
832
+
833
+ frame.dispose();
834
+ frame.setUndecorated(true);
714835 device.setFullScreenWindow(frame);
836
+ frame.validate();
837
+ frame.setVisible(true);
715838 // frame.removeNotify();
716839 // frame.setUndecorated(true);
717840 // frame.addNotify();
....@@ -720,13 +843,37 @@
720843 // X frame.getContentPane().add(/*"Center",*/bigThree);
721844 framePanel.setDividerLocation(0);
722845
723
- radio.layout = twoButton;
846
+ radio.layout = fullscreenLayout;
724847 radio.layout.doClick();
725848 //frame.setVisible(true);
726849 }
727
-
728
- cameraView.ToggleFullScreen();
850
+ frame.validate();
851
+
852
+ cameraView.requestFocusInWindow();
729853 }
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
+ }
730877
731878 private JTextPane createTextPane()
732879 {
....@@ -849,6 +996,7 @@
849996 {
850997 SetupMaterial(materialPanel);
851998 }
999
+
8521000 //SetupName();
8531001 //SetupViews();
8541002 }
....@@ -858,7 +1006,7 @@
8581006 // NumberSlider vDivsField;
8591007 // JCheckBox endcaps;
8601008 JCheckBox liveCB;
861
- JCheckBox selectCB;
1009
+ JCheckBox selectableCB;
8621010 JCheckBox hideCB;
8631011 JCheckBox link2masterCB;
8641012 JCheckBox markCB;
....@@ -866,7 +1014,12 @@
8661014 JCheckBox speedupCB;
8671015 JCheckBox rewindCB;
8681016 JCheckBox flipVCB;
1017
+
1018
+ cCheckBox toggleTextureCB;
1019
+ cCheckBox toggleSwitchCB;
1020
+
8691021 JComboBox texresMenu;
1022
+
8701023 JButton resetButton;
8711024 JButton stepButton;
8721025 JButton stepAllButton;
....@@ -1053,38 +1206,42 @@
10531206 namePanel = new cGridBag();
10541207
10551208 nameField = AddText(namePanel, copy.GetName());
1056
- namePanel.add(nameField);
1209
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10571210 oe.ctrlPanel.add(namePanel);
10581211
10591212 oe.ctrlPanel.Return();
10601213
1061
- if (!GroupEditor.allparams)
1214
+ if (!allparams)
10621215 return;
10631216
10641217 setupPanel = new cGridBag().setVertical(false);
10651218
10661219 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10671220 liveCB.setToolTipText("Animate object");
1068
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1069
- selectCB.setToolTipText("Make object selectable");
1221
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1222
+ selectableCB.setToolTipText("Make object selectable");
10701223 // Return();
1224
+
10711225 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10721226 hideCB.setToolTipText("Hide object");
10731227 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1074
- markCB.setToolTipText("Set the animation target transform");
1228
+ markCB.setToolTipText("As animation target transform");
1229
+
1230
+ ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
10751231
10761232 setupPanel2 = new cGridBag().setVertical(false);
10771233
10781234 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10791235 rewindCB.setToolTipText("Rewind animation");
10801236
1081
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1082
- 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)");
10831239
1240
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1241
+ link2masterCB.setToolTipText("Attach to support");
1242
+
10841243 if (Globals.ADVANCED)
10851244 {
1086
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1087
- link2masterCB.setToolTipText("Attach to support");
10881245 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10891246 speedupCB.setToolTipText("Option motion capture");
10901247 }
....@@ -1358,6 +1515,7 @@
13581515 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13591516 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13601517 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1518
+ //XYZPanel.setName("XYZ");
13611519
13621520 /*
13631521 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1395,12 +1553,29 @@
13951553 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13961554 //tmp.setName("Edit");
13971555 objectPanel.add(materialPanel);
1556
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
1557
+ objectPanel.setToolTipTextAt(0, "Material");
1558
+
13981559 // JPanel north = new JPanel(new BorderLayout());
13991560 // north.setName("Edit");
14001561 // north.add(ctrlPanel, BorderLayout.NORTH);
14011562 // objectPanel.add(north);
14021563 objectPanel.add(editPanel);
1403
- 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");
14041579
14051580 /*
14061581 aConstraints.gridx = 0;
....@@ -1409,7 +1584,7 @@
14091584 aConstraints.gridy += 1;
14101585 aConstraints.gridwidth = 1;
14111586 mainPanel.add(objectPanel, aConstraints);
1412
- */
1587
+ */
14131588
14141589 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
14151590 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1421,14 +1596,12 @@
14211596 scrollpane.addMouseWheelListener(this); // Default not fast enough
14221597
14231598 /*JTabbedPane*/ scenePanel = new cGridBag();
1424
- scenePanel.preferredWidth = 6;
1599
+ scenePanel.preferredWidth = 5;
14251600
14261601 JTabbedPane tabbedPane = new JTabbedPane();
14271602 tabbedPane.add(scrollpane);
14281603
1429
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1430
-
1431
- optionsPanel = new cGridBag().setVertical(true);
1604
+ optionsPanel = new cGridBag().setVertical(false);
14321605
14331606 optionsPanel.setName("Options");
14341607
....@@ -1436,6 +1609,8 @@
14361609
14371610 tabbedPane.add(optionsPanel);
14381611
1612
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1613
+
14391614 scenePanel.add(tabbedPane);
14401615
14411616 /*
....@@ -1499,7 +1674,7 @@
14991674 bigThree = new cGridBag();
15001675 bigThree.addComponent(scenePanel);
15011676 bigThree.addComponent(centralPanel);
1502
- bigThree.addComponent(XYZPanel);
1677
+ //bigThree.addComponent(XYZPanel);
15031678
15041679 // // SIDE EFFECT!!!
15051680 // aConstraints.gridx = 0;
....@@ -1508,9 +1683,9 @@
15081683 // aConstraints.gridheight = 1;
15091684
15101685 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1511
- framePanel.setContinuousLayout(true);
1512
- framePanel.setOneTouchExpandable(true);
1513
- framePanel.setDividerLocation(0.8);
1686
+ framePanel.setContinuousLayout(false);
1687
+ framePanel.setOneTouchExpandable(false);
1688
+ //.setDividerLocation(0.8);
15141689 //framePanel.setDividerSize(15);
15151690 //framePanel.setResizeWeight(0.15);
15161691 framePanel.setName("Frame");
....@@ -1528,16 +1703,18 @@
15281703 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
15291704
15301705 frame.setSize(1280, 860);
1531
- frame.setVisible(true);
1532
-
1706
+
15331707 cameraView.requestFocusInWindow();
15341708
15351709 gridPanel.setDividerLocation(1.0);
1710
+
1711
+ frame.validate();
1712
+
1713
+ frame.setVisible(true);
15361714
15371715 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
15381716 frame.addWindowListener(new WindowAdapter()
15391717 {
1540
-
15411718 public void windowClosing(WindowEvent e)
15421719 {
15431720 Close();
....@@ -1560,12 +1737,85 @@
15601737 ctrlPanel.removeAll();
15611738 }
15621739
1563
- void SetupMaterial(cGridBag panel)
1740
+ void SetupMaterial(cGridBag materialpanel)
15641741 {
1565
- /*
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
+ /*
15661816 ctrlPanel.add(materialLabel = new JLabel("MATERIAL : "), aConstraints);
15671817 materialLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1568
- */
1818
+ */
15691819
15701820 cGridBag editBar = new cGridBag().setVertical(false);
15711821
....@@ -1599,45 +1849,50 @@
15991849 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16001850
16011851 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);
16021865
16031866 cGridBag color = new cGridBag();
1604
- color.add(colorLabel = new JLabel("Color/hue")); // , aConstraints);
1605
- colorLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1606
- 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
+
16071872 //colorField.preferredWidth = 200;
16081873 colorSection.add(color);
16091874
16101875 cGridBag modulation = new cGridBag();
16111876 modulation.add(modulationLabel = new JLabel("Saturation")); // , aConstraints);
16121877 modulationLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1613
- modulation.add(modulationField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1878
+ modulation.add(saturationField = new cNumberSlider(this, 0.001, 1)); // , aConstraints);
16141879 colorSection.add(modulation);
16151880
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
+
16161889 cGridBag texture = new cGridBag();
16171890 texture.add(textureLabel = new JLabel("Texture")); // , aConstraints);
16181891 textureLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16191892 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16201893 colorSection.add(texture);
16211894
1622
- cGridBag anisoU = new cGridBag();
1623
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1624
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1625
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1626
- colorSection.add(anisoU);
1627
-
1628
- cGridBag anisoV = new cGridBag();
1629
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1630
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1631
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1632
- colorSection.add(anisoV);
1633
-
1634
- cGridBag shadowbias = new cGridBag();
1635
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1636
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1637
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1638
- colorSection.add(shadowbias);
1639
-
1640
- panel.add(new JSeparator());
1895
+ panel.add(GetSeparator());
16411896
16421897 panel.add(colorSection);
16431898
....@@ -1687,7 +1942,13 @@
16871942 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16881943 diffuseSection.add(fakedepth);
16891944
1690
- 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());
16911952
16921953 panel.add(diffuseSection);
16931954
....@@ -1737,42 +1998,48 @@
17371998 // aConstraints.gridy += 1;
17381999 // aConstraints.gridwidth = 1;
17392000
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);
17402006
1741
- 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());
17422015
17432016 panel.add(specularSection);
17442017
17452018 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17462019
1747
- cGridBag globalSection = new cGridBag().setVertical(true);
2020
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17482021
17492022 cGridBag camera = new cGridBag();
17502023 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17512024 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17522025 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1753
- globalSection.add(camera);
2026
+ colorSection.add(camera);
17542027
17552028 cGridBag ambient = new cGridBag();
17562029 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17572030 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17582031 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1759
- globalSection.add(ambient);
2032
+ colorSection.add(ambient);
17602033
17612034 cGridBag backlit = new cGridBag();
17622035 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17632036 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17642037 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1765
- globalSection.add(backlit);
2038
+ colorSection.add(backlit);
17662039
1767
- cGridBag opacity = new cGridBag();
1768
- opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
1769
- opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1770
- opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1771
- globalSection.add(opacity);
1772
-
1773
- panel.add(new JSeparator());
2040
+ //panel.add(new JSeparator());
17742041
1775
- panel.add(globalSection);
2042
+ //panel.add(globalSection);
17762043
17772044 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17782045
....@@ -1814,7 +2081,7 @@
18142081 opacityPower.add(opacityPowerField = new cNumberSlider(this, 0.0, 10 /*10 dec 2013*/)); // , aConstraints);
18152082 textureSection.add(opacityPower);
18162083
1817
- panel.add(new JSeparator());
2084
+ panel.add(GetSeparator());
18182085
18192086 panel.add(textureSection);
18202087
....@@ -1879,8 +2146,9 @@
18792146 // 3D models
18802147 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18812148 {
1882
- lastConverter = new com.jmex.model.converters.MaxToJme();
1883
- LoadFile(filename, lastConverter);
2149
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2150
+ //LoadFile(filename, lastConverter);
2151
+ LoadObjFile(filename); // New 3ds loader
18842152 continue;
18852153 }
18862154 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2606,6 +2874,7 @@
26062874 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26072875 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26082876 }
2877
+
26092878 //cJME.count++;
26102879 //cJME.count %= 12;
26112880 if (gc)
....@@ -2789,6 +3058,7 @@
27893058 }
27903059 }
27913060 }
3061
+
27923062 cFileSystemPane FSPane;
27933063
27943064 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2798,7 +3068,7 @@
27983068
27993069 freezematerial = true;
28003070 colorField.setFloat(mat.color);
2801
- modulationField.setFloat(mat.modulation);
3071
+ saturationField.setFloat(mat.modulation);
28023072 metalnessField.setFloat(mat.metalness);
28033073 diffuseField.setFloat(mat.diffuse);
28043074 specularField.setFloat(mat.specular);
....@@ -2842,11 +3112,14 @@
28423112 }
28433113 }
28443114 }
3115
+
28453116 freezematerial = false;
28463117 }
28473118
28483119 void SetMaterial(Object3D object)
28493120 {
3121
+ latestObject = object;
3122
+
28503123 cMaterial mat = object.material;
28513124
28523125 if (mat == null)
....@@ -2958,12 +3231,17 @@
29583231 // }
29593232
29603233 /**/
2961
- if (deselect)
3234
+ if (deselect || child == null)
29623235 {
29633236 //group.deselectAll();
29643237 //freeze = true;
29653238 GetTree().clearSelection();
29663239 //freeze = false;
3240
+
3241
+ if (child == null)
3242
+ {
3243
+ return;
3244
+ }
29673245 }
29683246
29693247 //group.addSelectee(child);
....@@ -3032,7 +3310,7 @@
30323310 cameraView.ToggleDL();
30333311 cameraView.repaint();
30343312 return;
3035
- } else if (event.getSource() == toggleTextureItem)
3313
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
30363314 {
30373315 cameraView.ToggleTexture();
30383316 // june 2013 copy.HardTouch();
....@@ -3071,7 +3349,7 @@
30713349 frame.validate();
30723350
30733351 return;
3074
- } else if (event.getSource() == toggleSwitchItem)
3352
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30753353 {
30763354 cameraView.ToggleSwitch();
30773355 cameraView.repaint();
....@@ -3101,8 +3379,9 @@
31013379 } else if (event.getSource() == liveCB)
31023380 {
31033381 copy.live ^= true;
3382
+ objEditor.refreshContents(true); // To show item colors
31043383 return;
3105
- } else if (event.getSource() == selectCB)
3384
+ } else if (event.getSource() == selectableCB)
31063385 {
31073386 copy.dontselect ^= true;
31083387 return;
....@@ -3110,7 +3389,7 @@
31103389 {
31113390 copy.hide ^= true;
31123391 copy.Touch(); // display list issue
3113
- objEditor.refreshContents();
3392
+ objEditor.refreshContents(true); // To show item colors
31143393 return;
31153394 } else if (event.getSource() == link2masterCB)
31163395 {
....@@ -3287,9 +3566,9 @@
32873566 {
32883567 Close();
32893568 //return true;
3290
- } else if (source == loadItem)
3569
+ } else if (source == openItem)
32913570 {
3292
- load();
3571
+ Open();
32933572 //return true;
32943573 } else if (source == newItem)
32953574 {
....@@ -3314,6 +3593,10 @@
33143593 {
33153594 generatePOV();
33163595 //return true;
3596
+ } else if (event.getSource() == archiveItem)
3597
+ {
3598
+ cTools.Archive(frame);
3599
+ return;
33173600 } else if (source == zBufferItem)
33183601 {
33193602 try
....@@ -3362,11 +3645,12 @@
33623645
33633646 static public byte[] Compress(Object3D o)
33643647 {
3648
+ // Slower to actually compress.
33653649 try
33663650 {
33673651 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3368
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3369
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3652
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3653
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33703654
33713655 Object3D parent = o.parent;
33723656 o.parent = null;
....@@ -3377,10 +3661,14 @@
33773661
33783662 out.flush();
33793663
3380
- zstream.close();
3664
+ baos //zstream
3665
+ .close();
33813666 out.close();
33823667
3383
- return baos.toByteArray();
3668
+ byte[] bytes = baos.toByteArray();
3669
+
3670
+ System.out.println("save #bytes = " + bytes.length);
3671
+ return bytes;
33843672 } catch (Exception e)
33853673 {
33863674 System.err.println(e);
....@@ -3390,13 +3678,16 @@
33903678
33913679 static public Object Uncompress(byte[] bytes)
33923680 {
3393
- System.out.println("#bytes = " + bytes.length);
3681
+ System.out.println("restore #bytes = " + bytes.length);
33943682 try
33953683 {
33963684 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3397
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3398
- ObjectInputStream in = new ObjectInputStream(istream);
3685
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3686
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33993687 Object obj = in.readObject();
3688
+
3689
+ bais //istream
3690
+ .close();
34003691 in.close();
34013692
34023693 return obj;
....@@ -3451,39 +3742,95 @@
34513742 return null;
34523743 }
34533744
3454
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34553745
34563746 public void Save()
34573747 {
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
+ {
34583785 System.err.println("Save");
3786
+ //Replace();
34593787
34603788 cRadio tab = GetCurrentTab();
34613789
3462
- boolean temp = CameraPane.SWITCH;
3463
- CameraPane.SWITCH = false;
3790
+ Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?
34643791
3465
- 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
+// }
34663798
34673799 //EditorFrame.m_MainFrame.requestFocusInWindow();
3468
- tab.graphs[tab.undoindex++] = Compress(copy);
3469
-
3470
- copy.RestoreBigData(hashtable);
3471
-
3472
- CameraPane.SWITCH = temp;
3473
-
3474
- //assert(hashtable.isEmpty());
3475
-
3476
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3800
+ if (!thesame)
34773801 {
3478
- 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++;
34793814 }
34803815
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
+
34813828 // test save
34823829 if (false)
34833830 {
34843831 try
34853832 {
3486
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3833
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34873834 ObjectOutputStream p = new ObjectOutputStream(ostream);
34883835
34893836 p.writeObject(copy);
....@@ -3496,26 +3843,68 @@
34963843 e.printStackTrace();
34973844 }
34983845 }
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);
34993880 }
35003881
3501
- void CopyChanged(Object3D obj)
3882
+ void CopyChanged()
35023883 {
3884
+ Object3D obj = copy.versionlist[copy.versionindex];
3885
+
3886
+ SetUndoStates();
3887
+
35033888 boolean temp = CameraPane.SWITCH;
35043889 CameraPane.SWITCH = false;
35053890
3506
- copy.ExtractBigData(hashtable);
3891
+ copy.ExtractBigData(versiontable);
35073892
35083893 copy.clear();
35093894
3895
+ copy.skyboxname = obj.skyboxname;
3896
+ copy.skyboxext = obj.skyboxext;
3897
+
35103898 for (int i=0; i<obj.Size(); i++)
35113899 {
35123900 copy.add(obj.get(i));
35133901 }
35143902
3515
- copy.RestoreBigData(hashtable);
3903
+ copy.RestoreBigData(versiontable);
35163904
35173905 CameraPane.SWITCH = temp;
35183906
3907
+ RefreshSelection();
35193908 //assert(hashtable.isEmpty());
35203909
35213910 copy.Touch();
....@@ -3536,45 +3925,139 @@
35363925 }
35373926 }
35383927
3539
- refreshContents();
3928
+ refreshContents(true);
35403929 }
35413930
3542
- 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()
35433941 {
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
+
35443977 System.err.println("Undo");
35453978
35463979 cRadio tab = GetCurrentTab();
35473980
3548
- if (tab.undoindex == 0)
3981
+ if (copy.versionindex == 0)
35493982 {
35503983 java.awt.Toolkit.getDefaultToolkit().beep();
3551
- return;
3984
+ return false;
35523985 }
35533986
3554
- if (tab.graphs[tab.undoindex] == null)
3555
- {
3556
- Save();
3557
- tab.undoindex -= 1;
3558
- }
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
+// }
35593999
3560
- tab.undoindex -= 1;
4000
+ copy.versionindex -= 1;
35614001
3562
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4002
+ CopyChanged();
4003
+
4004
+ return true;
35634005 }
35644006
3565
- public void Redo()
4007
+ public boolean Restore()
35664008 {
4009
+ System.err.println("Restore");
4010
+
35674011 cRadio tab = GetCurrentTab();
35684012
3569
- 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)
35704050 {
35714051 java.awt.Toolkit.getDefaultToolkit().beep();
35724052 return;
35734053 }
35744054
3575
- tab.undoindex += 1;
4055
+ copy.versionindex += 1;
35764056
3577
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
4057
+ CopyChanged();
4058
+
4059
+ //if (!tab.user[tab.versionindex])
4060
+ // tab.graphs[tab.versionindex] = null;
35784061 }
35794062
35804063 void ImportGFD()
....@@ -3726,7 +4209,7 @@
37264209 assert false;
37274210 }
37284211
3729
- void EditSelection()
4212
+ void EditSelection(boolean newWindow)
37304213 {
37314214 }
37324215
....@@ -3785,7 +4268,7 @@
37854268 //copy.material = new cMaterial(copy.GetMaterial());
37864269
37874270 current.color = (float) colorField.getFloat();
3788
- current.modulation = (float) modulationField.getFloat();
4271
+ current.modulation = (float) saturationField.getFloat();
37894272 current.metalness = (float) metalnessField.getFloat();
37904273 current.diffuse = (float) diffuseField.getFloat();
37914274 current.specular = (float) specularField.getFloat();
....@@ -3818,7 +4301,7 @@
38184301 cMaterial mat = copy.material;
38194302
38204303 colorField.SetToolTipValue((mat.color));
3821
- modulationField.SetToolTipValue((mat.modulation));
4304
+ saturationField.SetToolTipValue((mat.modulation));
38224305 metalnessField.SetToolTipValue((mat.metalness));
38234306 diffuseField.SetToolTipValue((mat.diffuse));
38244307 specularField.SetToolTipValue((mat.specular));
....@@ -3870,9 +4353,26 @@
38704353 //copy.Touch();
38714354 }
38724355
4356
+ cNumberSlider versionSlider;
4357
+
38734358 public void stateChanged(ChangeEvent e)
38744359 {
38754360 // 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
+ }
38764376
38774377 if (freezematerial)
38784378 {
....@@ -3908,6 +4408,12 @@
39084408 {
39094409 //System.out.println("stateChanged = " + this);
39104410 materialtouched = true;
4411
+
4412
+ if (e.getSource() == colorField && saturationField.getFloat() == 0.001)
4413
+ {
4414
+ saturationField.setFloat(1);
4415
+ }
4416
+
39114417 applySelf();
39124418 //System.out.println("this = " + this);
39134419 //System.out.println("PARENT = " + parent);
....@@ -4207,6 +4713,7 @@
42074713 {
42084714 if (GetTree() != null)
42094715 {
4716
+ GetTree().revalidate();
42104717 GetTree().repaint();
42114718 }
42124719
....@@ -4215,13 +4722,16 @@
42154722 ctrlPanel.validate(); // ? new
42164723 ctrlPanel.repaint();
42174724 }
4725
+
4726
+ if (previousVersionButton != null && copy.versionlist != null)
4727
+ SetUndoStates();
42184728 }
42194729
42204730 static TweenManager tweenManager = new TweenManager();
42214731
42224732 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
42234733 {
4224
- if (Globals.SAVEONMAKE)
4734
+ if (Globals.REPLACEONMAKE) // && resetmodel)
42254735 Save();
42264736 //Tween.set(thing, 0).target(1).start(tweenManager);
42274737 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
....@@ -4309,6 +4819,12 @@
43094819 {
43104820 ResetModel();
43114821 Select(thing.GetTreePath(), true, false); // unselect... false);
4822
+
4823
+ if (thing.Size() == 0)
4824
+ {
4825
+ //EditSelection(false);
4826
+ }
4827
+
43124828 refreshContents();
43134829 }
43144830
....@@ -4457,7 +4973,9 @@
44574973 readobj.ResetDisplayList();
44584974 } catch (Exception e)
44594975 {
4460
- //e.printStackTrace();
4976
+ if (!e.toString().contains("GZIP"))
4977
+ e.printStackTrace();
4978
+
44614979 try
44624980 {
44634981 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4531,12 +5049,14 @@
45315049
45325050 if (readobj != null)
45335051 {
4534
- if (Globals.SAVEONMAKE)
4535
- Save();
5052
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
5053
+ // Save();
45365054 try
45375055 {
45385056 //readobj.deepCopySelf(copy);
45395057 copy.clear(); // june 2014
5058
+ copy.skyboxname = readobj.skyboxname;
5059
+ copy.skyboxext = readobj.skyboxext;
45405060 for (int i = 0; i < readobj.size(); i++)
45415061 {
45425062 Object3D child = readobj.get(i); // reserve(i);
....@@ -4577,6 +5097,7 @@
45775097 }
45785098 } catch (ClassCastException e)
45795099 {
5100
+ e.printStackTrace();
45805101 assert (false);
45815102 Composite c = (Composite) copy;
45825103 c.children.clear();
....@@ -4587,17 +5108,28 @@
45875108 c.addChild(csg);
45885109 }
45895110
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
+
45905122 ResetModel();
45915123 copy.HardTouch(); // recompile?
45925124 refreshContents();
45935125 }
45945126 }
45955127
4596
- void load() // throws ClassNotFoundException
5128
+ void Open() // throws ClassNotFoundException
45975129 {
45985130 if (Grafreed.standAlone)
45995131 {
4600
- FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);
5132
+ FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);
46015133 browser.show();
46025134 String filename = browser.getFile();
46035135 if (filename != null && filename.length() > 0)
....@@ -4696,6 +5228,7 @@
46965228 //ps.print(buffer.toString());
46975229 } catch (IOException e)
46985230 {
5231
+ e.printStackTrace();
46995232 }
47005233 }
47015234
....@@ -4710,6 +5243,8 @@
47105243 String filename = browser.getFile();
47115244 if (filename != null && filename.length() > 0)
47125245 {
5246
+ if (!filename.endsWith(".gfd"))
5247
+ filename += ".gfd";
47135248 lastname = browser.getDirectory() + filename;
47145249 save();
47155250 }
....@@ -4876,7 +5411,7 @@
48765411 MenuBar menuBar;
48775412 Menu fileMenu;
48785413 MenuItem newItem;
4879
- MenuItem loadItem;
5414
+ MenuItem openItem;
48805415 MenuItem saveItem;
48815416 MenuItem saveAsItem;
48825417 MenuItem exportAsItem;
....@@ -4899,22 +5434,36 @@
48995434 CheckboxMenuItem toggleSwitchItem;
49005435 CheckboxMenuItem toggleRootItem;
49015436 CheckboxMenuItem animationItem;
5437
+ MenuItem archiveItem;
49025438 CheckboxMenuItem toggleHandleItem;
49035439 CheckboxMenuItem togglePaintItem;
49045440 JSplitPane mainPanel;
49055441 JScrollPane scrollpane;
5442
+
49065443 JPanel toolbarPanel;
5444
+
49075445 cGridBag treePanel;
5446
+
49085447 JPanel radioPanel;
49095448 ButtonGroup buttonGroup;
4910
- cGridBag ctrlPanel;
5449
+
5450
+ cGridBag toolboxPanel;
49115451 cGridBag materialPanel;
5452
+ cGridBag ctrlPanel;
5453
+
49125454 JScrollPane infoPanel;
5455
+
49135456 cGridBag optionsPanel;
5457
+
49145458 JTabbedPane objectPanel;
5459
+ boolean materialFlushed;
5460
+ Object3D latestObject;
5461
+
49155462 cGridBag XYZPanel;
5463
+
49165464 JSplitPane gridPanel;
49175465 JSplitPane bigPanel;
5466
+
49185467 cGridBag bigThree;
49195468 cGridBag scenePanel;
49205469 cGridBag centralPanel;
....@@ -4972,7 +5521,7 @@
49725521 JLabel colorLabel;
49735522 cNumberSlider colorField;
49745523 JLabel modulationLabel;
4975
- cNumberSlider modulationField;
5524
+ cNumberSlider saturationField;
49765525 JLabel metalnessLabel;
49775526 cNumberSlider metalnessField;
49785527 JLabel diffuseLabel;
....@@ -5029,7 +5578,7 @@
50295578 cNumberSlider fogField;
50305579 JLabel opacityPowerLabel;
50315580 cNumberSlider opacityPowerField;
5032
- JTree jTree;
5581
+ cTree jTree;
50335582 //ObjectUI parent;
50345583
50355584 cNumberSlider normalpushField;