Normand Briere
2019-07-27 1af7d3700724834e40ad8636bc9a56cdc3b19b15
ObjEditor.java
....@@ -4,6 +4,7 @@
44
55 import java.awt.*;
66 import java.awt.event.*;
7
+import java.awt.image.BufferedImage;
78 import javax.swing.*;
89 import javax.swing.event.*;
910 import javax.swing.text.*;
....@@ -13,6 +14,9 @@
1314 import javax.swing.plaf.metal.MetalLookAndFeel;
1415 //import javax.swing.plaf.ColorUIResource;
1516 //import javax.swing.plaf.metal.DefaultMetalTheme;
17
+
18
+import javax.swing.plaf.basic.BasicSplitPaneDivider;
19
+import javax.swing.plaf.basic.BasicSplitPaneUI;
1620
1721 //import javax.media.opengl.GLCanvas;
1822
....@@ -37,6 +41,51 @@
3741 JFrame frame;
3842
3943 static ObjEditor theFrame;
44
+
45
+ cButton GetButton(String name, boolean border)
46
+ {
47
+ ImageIcon icon = GetIcon(name);
48
+ return new cButton(icon, border);
49
+ }
50
+
51
+ cToggleButton GetToggleButton(String name, boolean border)
52
+ {
53
+ ImageIcon icon = GetIcon(name);
54
+ return new cToggleButton(icon, border);
55
+ }
56
+
57
+ cCheckBox GetCheckBox(String name, boolean border)
58
+ {
59
+ ImageIcon icon = GetIcon(name);
60
+ return new cCheckBox(icon, border);
61
+ }
62
+
63
+ private ImageIcon GetIcon(String name)
64
+ {
65
+ try
66
+ {
67
+ BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
68
+
69
+ if (image.getWidth() != 24 && image.getHeight() != 24)
70
+ {
71
+ BufferedImage resized = new BufferedImage(24, 24, image.getType());
72
+ Graphics2D g = resized.createGraphics();
73
+ g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
74
+ //g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
75
+ g.drawImage(image, 0, 0, 24, 24, 0, 0, image.getWidth(), image.getHeight(), null);
76
+ g.dispose();
77
+
78
+ image = resized;
79
+ }
80
+
81
+ javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
82
+ return icon;
83
+ }
84
+ catch (Exception e)
85
+ {
86
+ return null;
87
+ }
88
+ }
4089
4190 // SCRIPT
4291
....@@ -147,7 +196,7 @@
147196
148197 objEditor.ctrlPanel.remove(namePanel);
149198
150
- if (!GroupEditor.allparams)
199
+ if (!allparams)
151200 return;
152201
153202 // objEditor.ctrlPanel.remove(liveCB);
....@@ -219,6 +268,12 @@
219268 client = inClient;
220269 copy = client;
221270
271
+ if (copy.versions == null)
272
+ {
273
+ copy.versions = new byte[100][];
274
+ copy.versionindex = -1;
275
+ }
276
+
222277 // "this" is not called: SetupUI2(objEditor);
223278 }
224279
....@@ -232,6 +287,12 @@
232287 client = inClient;
233288 copy = client;
234289
290
+ if (copy.versions == null)
291
+ {
292
+ copy.versions = new byte[100][];
293
+ copy.versionindex = -1;
294
+ }
295
+
235296 SetupUI2(callee.GetEditor());
236297 }
237298
....@@ -246,7 +307,7 @@
246307 //localCopy.parent = null;
247308
248309 frame = new JFrame();
249
- frame.setUndecorated(true);
310
+ frame.setUndecorated(false);
250311 objEditor = this;
251312 this.callee = callee;
252313
....@@ -264,6 +325,12 @@
264325 copy = localCopy;
265326 copy.editWindow = this;
266327
328
+ if (copy.versions == null)
329
+ {
330
+// copy.versions = new byte[100][];
331
+// copy.versionindex = -1;
332
+ }
333
+
267334 SetupMenu();
268335
269336 //SetupName(objEditor); // new
....@@ -277,12 +344,17 @@
277344 return frame.action(event, obj);
278345 }
279346
347
+ // Cannot work without static
348
+ static boolean allparams = true;
349
+
350
+ static java.util.Vector<Object3D> listUI = new java.util.Vector<Object3D>();
351
+
280352 void SetupMenu()
281353 {
282354 frame.setMenuBar(menuBar = new MenuBar());
283355 menuBar.add(fileMenu = new Menu("File"));
284356 fileMenu.add(newItem = new MenuItem("New"));
285
- fileMenu.add(loadItem = new MenuItem("Open..."));
357
+ fileMenu.add(openItem = new MenuItem("Open..."));
286358
287359 //oe.menuBar.add(menu = new Menu("Include"));
288360 Menu menu = new Menu("Import");
....@@ -314,7 +386,7 @@
314386 }
315387
316388 newItem.addActionListener(this);
317
- loadItem.addActionListener(this);
389
+ openItem.addActionListener(this);
318390 saveItem.addActionListener(this);
319391 saveAsItem.addActionListener(this);
320392 exportAsItem.addActionListener(this);
....@@ -323,13 +395,40 @@
323395 closeItem.addActionListener(this);
324396
325397 objectPanel = new JTabbedPane();
398
+
399
+ ChangeListener changeListener = new ChangeListener()
400
+ {
401
+ public void stateChanged(ChangeEvent changeEvent)
402
+ {
403
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
404
+// {
405
+// if (latestObject != null)
406
+// {
407
+// refreshContents(true);
408
+// SetMaterial(latestObject);
409
+// }
410
+//
411
+// materialFlushed = true;
412
+// }
413
+// if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Edit"))
414
+// {
415
+// if (listUI.size() == 0)
416
+// EditSelection(false);
417
+// }
418
+
419
+ refreshContents(false); // To refresh Info tab
420
+ }
421
+ };
422
+ objectPanel.addChangeListener(changeListener);
423
+
326424 toolbarPanel = new JPanel();
327425 toolbarPanel.setName("Toolbar");
426
+
328427 treePanel = new cGridBag();
329428 treePanel.setName("Tree");
330429
331430 editPanel = new cGridBag().setVertical(true);
332
- editPanel.setName("Edit");
431
+ //editPanel.setName("Edit");
333432
334433 ctrlPanel = new cGridBag().setVertical(false); // new GridBagLayout());
335434
....@@ -337,23 +436,27 @@
337436 editPanel.add(editCommandsPanel);
338437 editPanel.add(ctrlPanel);
339438
340
- materialPanel = new cGridBag().setVertical(true);
439
+ toolboxPanel = new cGridBag().setVertical(false);
440
+ //toolboxPanel.setName("Toolbox");
341441
342
- materialPanel.setName("Material");
442
+ materialPanel = new cGridBag().setVertical(true);
443
+ //materialPanel.setName("Material");
444
+
343445 /*JTextPane*/
344446 infoarea = createTextPane();
345447 doc = infoarea.getStyledDocument();
346448
347449 infoarea.setEditable(true);
348450 SetText();
451
+
349452 // infoarea.setFont(infoarea.getFont().deriveFont(10, 14f));
350453 // infoarea.setOpaque(false);
351454 // //infoarea.setForeground(textcolor);
352455 // TEXTAREA infoarea.setLineWrap(true);
353456 // TEXTAREA infoarea.setWrapStyleWord(true);
354457 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
355
- infoPanel.setPreferredSize(new Dimension(50, 200));
356
- infoPanel.setName("Info");
458
+ infoPanel.setPreferredSize(new Dimension(1, 1));
459
+ //infoPanel.setName("Info");
357460 //infoPanel.setLayout(new BorderLayout());
358461 //infoPanel.add(createTextPane());
359462
....@@ -364,7 +467,14 @@
364467 mainPanel.setDividerSize(9);
365468 mainPanel.setDividerLocation(0.5); //1.0);
366469 mainPanel.setResizeWeight(0.5);
367
-
470
+
471
+//mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
472
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
473
+ divider.setDividerSize(15);
474
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
475
+
476
+ mainPanel.setUI(new BasicSplitPaneUI());
477
+
368478 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
369479 //mainPanel.setLayout(new GridBagLayout());
370480 toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
....@@ -595,8 +705,8 @@
595705 }
596706 }
597707
598
-static GraphicsDevice device = GraphicsEnvironment
599
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
708
+//static GraphicsDevice device = GraphicsEnvironment
709
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
600710
601711 Rectangle keeprect;
602712 cRadio radio;
....@@ -612,13 +722,24 @@
612722
613723 boolean maximized;
614724
725
+ cButton fullscreenLayout;
726
+
615727 void Minimize()
616728 {
617729 frame.setState(Frame.ICONIFIED);
730
+ frame.validate();
618731 }
619732
733
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
734
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
735
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
620736 void Maximize()
621737 {
738
+ if (CameraPane.FULLSCREEN)
739
+ {
740
+ ToggleFullScreen();
741
+ }
742
+
622743 if (maximized)
623744 {
624745 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -626,20 +747,36 @@
626747 else
627748 {
628749 keeprect = frame.getBounds();
629
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
630
- Dimension rect2 = frame.getToolkit().getScreenSize();
631
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
750
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
751
+// Dimension rect2 = frame.getToolkit().getScreenSize();
752
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
632753 // frame.setState(Frame.MAXIMIZED_BOTH);
754
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
633755 }
634756
635757 maximized ^= true;
758
+
759
+ frame.validate();
636760 }
761
+
762
+ cButton minButton;
763
+ cButton maxButton;
764
+ cButton fullButton;
637765
638766 void ToggleFullScreen()
639767 {
640
- if (CameraPane.FULLSCREEN)
768
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
769
+
770
+ cameraView.ToggleFullScreen();
771
+
772
+ if (!CameraPane.FULLSCREEN)
641773 {
642774 device.setFullScreenWindow(null);
775
+ frame.dispose();
776
+ frame.setUndecorated(false);
777
+ frame.validate();
778
+ frame.setVisible(true);
779
+
643780 //frame.setVisible(false);
644781 // frame.removeNotify();
645782 // frame.setUndecorated(false);
....@@ -649,7 +786,7 @@
649786 // X frame.getContentPane().remove(/*"Center",*/bigThree);
650787 // X framePanel.add(bigThree);
651788 // X frame.getContentPane().add(/*"Center",*/framePanel);
652
- framePanel.setDividerLocation(1);
789
+ framePanel.setDividerLocation(46);
653790
654791 //frame.setVisible(true);
655792 radio.layout = keepButton;
....@@ -664,7 +801,12 @@
664801 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
665802 // frame.getToolkit().getScreenSize().height);
666803 //frame.setVisible(false);
804
+
805
+ frame.dispose();
806
+ frame.setUndecorated(true);
667807 device.setFullScreenWindow(frame);
808
+ frame.validate();
809
+ frame.setVisible(true);
668810 // frame.removeNotify();
669811 // frame.setUndecorated(true);
670812 // frame.addNotify();
....@@ -673,13 +815,34 @@
673815 // X frame.getContentPane().add(/*"Center",*/bigThree);
674816 framePanel.setDividerLocation(0);
675817
676
- radio.layout = twoButton;
818
+ radio.layout = fullscreenLayout;
677819 radio.layout.doClick();
678820 //frame.setVisible(true);
679821 }
680
-
681
- cameraView.ToggleFullScreen();
822
+ frame.validate();
682823 }
824
+
825
+ private byte[] CompressCopy()
826
+ {
827
+ boolean temp = CameraPane.SWITCH;
828
+ CameraPane.SWITCH = false;
829
+
830
+ copy.ExtractBigData(versiontable);
831
+ // if (copy == client)
832
+
833
+ byte[] versions[] = copy.versions;
834
+ copy.versions = null;
835
+
836
+ byte[] compress = Compress(copy);
837
+
838
+ copy.versions = versions;
839
+
840
+ copy.RestoreBigData(versiontable);
841
+
842
+ CameraPane.SWITCH = temp;
843
+
844
+ return compress;
845
+ }
683846
684847 private JTextPane createTextPane()
685848 {
....@@ -811,7 +974,7 @@
811974 // NumberSlider vDivsField;
812975 // JCheckBox endcaps;
813976 JCheckBox liveCB;
814
- JCheckBox selectCB;
977
+ JCheckBox selectableCB;
815978 JCheckBox hideCB;
816979 JCheckBox link2masterCB;
817980 JCheckBox markCB;
....@@ -819,7 +982,12 @@
819982 JCheckBox speedupCB;
820983 JCheckBox rewindCB;
821984 JCheckBox flipVCB;
985
+
986
+ cCheckBox toggleTextureCB;
987
+ cCheckBox toggleSwitchCB;
988
+
822989 JComboBox texresMenu;
990
+
823991 JButton resetButton;
824992 JButton stepButton;
825993 JButton stepAllButton;
....@@ -1006,38 +1174,40 @@
10061174 namePanel = new cGridBag();
10071175
10081176 nameField = AddText(namePanel, copy.GetName());
1009
- namePanel.add(nameField);
1177
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
10101178 oe.ctrlPanel.add(namePanel);
10111179
10121180 oe.ctrlPanel.Return();
10131181
1014
- if (!GroupEditor.allparams)
1182
+ if (!allparams)
10151183 return;
10161184
10171185 setupPanel = new cGridBag().setVertical(false);
10181186
10191187 liveCB = AddCheckBox(setupPanel, "Live", copy.live);
10201188 liveCB.setToolTipText("Animate object");
1021
- selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1022
- selectCB.setToolTipText("Make object selectable");
1189
+ selectableCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);
1190
+ selectableCB.setToolTipText("Make object selectable");
10231191 // Return();
1192
+
10241193 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide);
10251194 hideCB.setToolTipText("Hide object");
10261195 markCB = AddCheckBox(setupPanel, "Mark", copy.marked);
1027
- markCB.setToolTipText("Set the animation target transform");
1196
+ markCB.setToolTipText("As animation target transform");
10281197
10291198 setupPanel2 = new cGridBag().setVertical(false);
10301199
10311200 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
10321201 rewindCB.setToolTipText("Rewind animation");
10331202
1034
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1035
- randomCB.setToolTipText("Randomly Rewind or Go back and forth");
1203
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
1204
+ randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
10361205
1206
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1207
+ link2masterCB.setToolTipText("Attach to support");
1208
+
10371209 if (Globals.ADVANCED)
10381210 {
1039
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1040
- link2masterCB.setToolTipText("Attach to support");
10411211 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
10421212 speedupCB.setToolTipText("Option motion capture");
10431213 }
....@@ -1311,6 +1481,7 @@
13111481 XYZPanel.addComponent(/*BorderLayout.SOUTH,*/sideView); // Scroll);
13121482 XYZPanel.addComponent(/*BorderLayout.CENTER,*/frontView); // Scroll);
13131483 XYZPanel.addComponent(/*BorderLayout.NORTH,*/topView); // Scroll);
1484
+ //XYZPanel.setName("XYZ");
13141485
13151486 /*
13161487 gridPanel = new JPanel(); //new BorderLayout());
....@@ -1348,12 +1519,23 @@
13481519 //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
13491520 //tmp.setName("Edit");
13501521 objectPanel.add(materialPanel);
1522
+ objectPanel.setIconAt(0, GetIcon("icons/material.png"));
13511523 // JPanel north = new JPanel(new BorderLayout());
13521524 // north.setName("Edit");
13531525 // north.add(ctrlPanel, BorderLayout.NORTH);
13541526 // objectPanel.add(north);
13551527 objectPanel.add(editPanel);
1356
- objectPanel.add(infoPanel);
1528
+ objectPanel.setIconAt(1, GetIcon("icons/write.png"));
1529
+
1530
+ //if (Globals.ADVANCED)
1531
+ objectPanel.add(infoPanel);
1532
+ objectPanel.setIconAt(2, GetIcon("icons/info.png"));
1533
+
1534
+ objectPanel.add(XYZPanel);
1535
+ objectPanel.setIconAt(3, GetIcon("icons/XYZ.png"));
1536
+
1537
+ objectPanel.add(toolboxPanel);
1538
+ objectPanel.setIconAt(4, GetIcon("icons/primitives.png"));
13571539
13581540 /*
13591541 aConstraints.gridx = 0;
....@@ -1362,7 +1544,7 @@
13621544 aConstraints.gridy += 1;
13631545 aConstraints.gridwidth = 1;
13641546 mainPanel.add(objectPanel, aConstraints);
1365
- */
1547
+ */
13661548
13671549 scrollpane = new JScrollPane(mainPanel, ScrollPaneConstants.// VERTICAL_SCROLLBAR_ALWAYS,
13681550 VERTICAL_SCROLLBAR_AS_NEEDED,
....@@ -1374,14 +1556,12 @@
13741556 scrollpane.addMouseWheelListener(this); // Default not fast enough
13751557
13761558 /*JTabbedPane*/ scenePanel = new cGridBag();
1377
- scenePanel.preferredWidth = 6;
1559
+ scenePanel.preferredWidth = 5;
13781560
13791561 JTabbedPane tabbedPane = new JTabbedPane();
13801562 tabbedPane.add(scrollpane);
13811563
1382
- tabbedPane.add(FSPane = new cFileSystemPane(this));
1383
-
1384
- optionsPanel = new cGridBag().setVertical(true);
1564
+ optionsPanel = new cGridBag().setVertical(false);
13851565
13861566 optionsPanel.setName("Options");
13871567
....@@ -1389,6 +1569,8 @@
13891569
13901570 tabbedPane.add(optionsPanel);
13911571
1572
+ tabbedPane.add(FSPane = new cFileSystemPane(this));
1573
+
13921574 scenePanel.add(tabbedPane);
13931575
13941576 /*
....@@ -1450,9 +1632,9 @@
14501632 /**/
14511633
14521634 bigThree = new cGridBag();
1453
- bigThree.addComponent(scenePanel);
14541635 bigThree.addComponent(centralPanel);
1455
- bigThree.addComponent(XYZPanel);
1636
+ bigThree.addComponent(scenePanel);
1637
+ //bigThree.addComponent(XYZPanel);
14561638
14571639 // // SIDE EFFECT!!!
14581640 // aConstraints.gridx = 0;
....@@ -1461,9 +1643,9 @@
14611643 // aConstraints.gridheight = 1;
14621644
14631645 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1464
- framePanel.setContinuousLayout(true);
1465
- framePanel.setOneTouchExpandable(true);
1466
- framePanel.setDividerLocation(0.8);
1646
+ framePanel.setContinuousLayout(false);
1647
+ framePanel.setOneTouchExpandable(false);
1648
+ //.setDividerLocation(0.8);
14671649 //framePanel.setDividerSize(15);
14681650 //framePanel.setResizeWeight(0.15);
14691651 framePanel.setName("Frame");
....@@ -1481,11 +1663,14 @@
14811663 // aConstraints = gbc; // (GridBagConstraints) GrafreeD.clone(gbc);
14821664
14831665 frame.setSize(1280, 860);
1484
- frame.setVisible(true);
1485
-
1666
+
14861667 cameraView.requestFocusInWindow();
14871668
14881669 gridPanel.setDividerLocation(1.0);
1670
+
1671
+ frame.validate();
1672
+
1673
+ frame.setVisible(true);
14891674
14901675 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
14911676 frame.addWindowListener(new WindowAdapter()
....@@ -1572,24 +1757,6 @@
15721757 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
15731758 colorSection.add(texture);
15741759
1575
- cGridBag anisoU = new cGridBag();
1576
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1577
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1578
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1579
- colorSection.add(anisoU);
1580
-
1581
- cGridBag anisoV = new cGridBag();
1582
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1583
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1584
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1585
- colorSection.add(anisoV);
1586
-
1587
- cGridBag shadowbias = new cGridBag();
1588
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1589
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1590
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1591
- colorSection.add(shadowbias);
1592
-
15931760 panel.add(new JSeparator());
15941761
15951762 panel.add(colorSection);
....@@ -1639,6 +1806,12 @@
16391806 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
16401807 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
16411808 diffuseSection.add(fakedepth);
1809
+
1810
+ cGridBag shadowbias = new cGridBag();
1811
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1812
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1813
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1814
+ diffuseSection.add(shadowbias);
16421815
16431816 panel.add(new JSeparator());
16441817
....@@ -1690,6 +1863,18 @@
16901863 // aConstraints.gridy += 1;
16911864 // aConstraints.gridwidth = 1;
16921865
1866
+ cGridBag anisoU = new cGridBag();
1867
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1868
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1869
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1870
+ specularSection.add(anisoU);
1871
+
1872
+ cGridBag anisoV = new cGridBag();
1873
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1874
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1875
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1876
+ specularSection.add(anisoV);
1877
+
16931878
16941879 panel.add(new JSeparator());
16951880
....@@ -1697,35 +1882,35 @@
16971882
16981883 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
16991884
1700
- cGridBag globalSection = new cGridBag().setVertical(true);
1885
+ //cGridBag globalSection = new cGridBag().setVertical(true);
17011886
17021887 cGridBag camera = new cGridBag();
17031888 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
17041889 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17051890 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1706
- globalSection.add(camera);
1891
+ colorSection.add(camera);
17071892
17081893 cGridBag ambient = new cGridBag();
17091894 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
17101895 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17111896 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1712
- globalSection.add(ambient);
1897
+ colorSection.add(ambient);
17131898
17141899 cGridBag backlit = new cGridBag();
17151900 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
17161901 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17171902 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1718
- globalSection.add(backlit);
1903
+ colorSection.add(backlit);
17191904
17201905 cGridBag opacity = new cGridBag();
17211906 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
17221907 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17231908 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1724
- globalSection.add(opacity);
1909
+ colorSection.add(opacity);
17251910
1726
- panel.add(new JSeparator());
1911
+ //panel.add(new JSeparator());
17271912
1728
- panel.add(globalSection);
1913
+ //panel.add(globalSection);
17291914
17301915 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
17311916
....@@ -1832,8 +2017,9 @@
18322017 // 3D models
18332018 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
18342019 {
1835
- lastConverter = new com.jmex.model.converters.MaxToJme();
1836
- LoadFile(filename, lastConverter);
2020
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
2021
+ //LoadFile(filename, lastConverter);
2022
+ LoadObjFile(filename); // New 3ds loader
18372023 continue;
18382024 }
18392025 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2559,6 +2745,7 @@
25592745 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
25602746 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
25612747 }
2748
+
25622749 //cJME.count++;
25632750 //cJME.count %= 12;
25642751 if (gc)
....@@ -2742,6 +2929,7 @@
27422929 }
27432930 }
27442931 }
2932
+
27452933 cFileSystemPane FSPane;
27462934
27472935 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2795,11 +2983,14 @@
27952983 }
27962984 }
27972985 }
2986
+
27982987 freezematerial = false;
27992988 }
28002989
28012990 void SetMaterial(Object3D object)
28022991 {
2992
+ latestObject = object;
2993
+
28032994 cMaterial mat = object.material;
28042995
28052996 if (mat == null)
....@@ -2911,12 +3102,17 @@
29113102 // }
29123103
29133104 /**/
2914
- if (deselect)
3105
+ if (deselect || child == null)
29153106 {
29163107 //group.deselectAll();
29173108 //freeze = true;
29183109 GetTree().clearSelection();
29193110 //freeze = false;
3111
+
3112
+ if (child == null)
3113
+ {
3114
+ return;
3115
+ }
29203116 }
29213117
29223118 //group.addSelectee(child);
....@@ -2985,7 +3181,7 @@
29853181 cameraView.ToggleDL();
29863182 cameraView.repaint();
29873183 return;
2988
- } else if (event.getSource() == toggleTextureItem)
3184
+ } else if (event.getSource() == toggleTextureItem || event.getSource() == toggleTextureCB)
29893185 {
29903186 cameraView.ToggleTexture();
29913187 // june 2013 copy.HardTouch();
....@@ -3024,7 +3220,7 @@
30243220 frame.validate();
30253221
30263222 return;
3027
- } else if (event.getSource() == toggleSwitchItem)
3223
+ } else if (event.getSource() == toggleSwitchItem || event.getSource() == toggleSwitchCB)
30283224 {
30293225 cameraView.ToggleSwitch();
30303226 cameraView.repaint();
....@@ -3055,7 +3251,7 @@
30553251 {
30563252 copy.live ^= true;
30573253 return;
3058
- } else if (event.getSource() == selectCB)
3254
+ } else if (event.getSource() == selectableCB)
30593255 {
30603256 copy.dontselect ^= true;
30613257 return;
....@@ -3240,9 +3436,9 @@
32403436 {
32413437 Close();
32423438 //return true;
3243
- } else if (source == loadItem)
3439
+ } else if (source == openItem)
32443440 {
3245
- load();
3441
+ Open();
32463442 //return true;
32473443 } else if (source == newItem)
32483444 {
....@@ -3267,6 +3463,10 @@
32673463 {
32683464 generatePOV();
32693465 //return true;
3466
+ } else if (event.getSource() == archiveItem)
3467
+ {
3468
+ cTools.Archive(frame);
3469
+ return;
32703470 } else if (source == zBufferItem)
32713471 {
32723472 try
....@@ -3318,8 +3518,8 @@
33183518 try
33193519 {
33203520 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3321
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3322
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3521
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3522
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
33233523
33243524 Object3D parent = o.parent;
33253525 o.parent = null;
....@@ -3330,10 +3530,14 @@
33303530
33313531 out.flush();
33323532
3333
- zstream.close();
3533
+ baos //zstream
3534
+ .close();
33343535 out.close();
33353536
3336
- return baos.toByteArray();
3537
+ byte[] bytes = baos.toByteArray();
3538
+
3539
+ System.out.println("save #bytes = " + bytes.length);
3540
+ return bytes;
33373541 } catch (Exception e)
33383542 {
33393543 System.err.println(e);
....@@ -3343,13 +3547,16 @@
33433547
33443548 static public Object Uncompress(byte[] bytes)
33453549 {
3346
- System.out.println("#bytes = " + bytes.length);
3550
+ System.out.println("restore #bytes = " + bytes.length);
33473551 try
33483552 {
33493553 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3350
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3351
- ObjectInputStream in = new ObjectInputStream(istream);
3554
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3555
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
33523556 Object obj = in.readObject();
3557
+
3558
+ bais //istream
3559
+ .close();
33533560 in.close();
33543561
33553562 return obj;
....@@ -3404,37 +3611,77 @@
34043611 return null;
34053612 }
34063613
3407
- java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>();
34083614
34093615 public void Save()
34103616 {
3617
+ //Save(true);
3618
+ Replace();
3619
+ }
3620
+
3621
+ private boolean Equal(byte[] compress, byte[] name)
3622
+ {
3623
+ if (compress.length != name.length)
3624
+ {
3625
+ return false;
3626
+ }
3627
+
3628
+ for (int i=compress.length; --i>=0;)
3629
+ {
3630
+ if (compress[i] != name[i])
3631
+ return false;
3632
+ }
3633
+
3634
+ return true;
3635
+ }
3636
+
3637
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>();
3638
+
3639
+ public boolean Save(boolean user)
3640
+ {
3641
+ System.err.println("Save");
3642
+
34113643 cRadio tab = GetCurrentTab();
34123644
3413
- boolean temp = CameraPane.SWITCH;
3414
- CameraPane.SWITCH = false;
3645
+ byte[] compress = CompressCopy();
34153646
3416
- copy.ExtractBigData(hashtable);
3647
+ boolean thesame = false;
3648
+
3649
+ // Quick heuristic using length. Works only when stream is compressed.
3650
+ if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1]))
3651
+ {
3652
+ thesame = true;
3653
+ }
34173654
34183655 //EditorFrame.m_MainFrame.requestFocusInWindow();
3419
- tab.graphs[tab.undoindex++] = Compress(copy);
3420
-
3421
- copy.RestoreBigData(hashtable);
3422
-
3423
- CameraPane.SWITCH = temp;
3424
-
3425
- //assert(hashtable.isEmpty());
3426
-
3427
- for (int i = tab.undoindex; i < tab.graphs.length; i++)
3656
+ if (!thesame)
34283657 {
3429
- tab.graphs[i] = null;
3658
+ //tab.user[tab.versionindex] = user;
3659
+ //boolean increment = true; // tab.graphs[tab.versionindex] == null;
3660
+
3661
+ copy.versions[++copy.versionindex] = compress;
3662
+
3663
+ // if (increment)
3664
+ // tab.versionindex++;
34303665 }
34313666
3667
+ //copy.RestoreBigData(versiontable);
3668
+
3669
+ //assert(hashtable.isEmpty());
3670
+
3671
+ for (int i = copy.versionindex+1; i < copy.versions.length; i++)
3672
+ {
3673
+ //tab.user[i] = false;
3674
+ copy.versions[i] = null;
3675
+ }
3676
+
3677
+ SetUndoStates();
3678
+
34323679 // test save
34333680 if (false)
34343681 {
34353682 try
34363683 {
3437
- FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex);
3684
+ FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex);
34383685 ObjectOutputStream p = new ObjectOutputStream(ostream);
34393686
34403687 p.writeObject(copy);
....@@ -3447,14 +3694,18 @@
34473694 e.printStackTrace();
34483695 }
34493696 }
3697
+
3698
+ return !thesame;
34503699 }
34513700
34523701 void CopyChanged(Object3D obj)
34533702 {
3703
+ SetUndoStates();
3704
+
34543705 boolean temp = CameraPane.SWITCH;
34553706 CameraPane.SWITCH = false;
34563707
3457
- copy.ExtractBigData(hashtable);
3708
+ copy.ExtractBigData(versiontable);
34583709
34593710 copy.clear();
34603711
....@@ -3463,7 +3714,7 @@
34633714 copy.add(obj.get(i));
34643715 }
34653716
3466
- copy.RestoreBigData(hashtable);
3717
+ copy.RestoreBigData(versiontable);
34673718
34683719 CameraPane.SWITCH = temp;
34693720
....@@ -3490,40 +3741,130 @@
34903741 refreshContents();
34913742 }
34923743
3493
- public void Undo()
3744
+ cButton undoButton;
3745
+ cButton restoreButton;
3746
+ cButton replaceButton;
3747
+ cButton redoButton;
3748
+
3749
+ boolean muteSlider;
3750
+
3751
+ int VersionCount()
3752
+ {
3753
+ int count = 0;
3754
+
3755
+ for (int i = copy.versions.length; --i >= 0;)
3756
+ {
3757
+ if (copy.versions[i] != null)
3758
+ count++;
3759
+ }
3760
+
3761
+ return count;
3762
+ }
3763
+
3764
+ void SetUndoStates()
34943765 {
34953766 cRadio tab = GetCurrentTab();
34963767
3497
- if (tab.undoindex == 0)
3768
+ restoreButton.setEnabled(copy.versionindex != -1);
3769
+ replaceButton.setEnabled(copy.versionindex != -1);
3770
+
3771
+ undoButton.setEnabled(copy.versionindex > 0);
3772
+ redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null);
3773
+
3774
+ muteSlider = true;
3775
+ versionSlider.setMaximum(VersionCount() - 1);
3776
+ versionSlider.setInteger(copy.versionindex);
3777
+ muteSlider = false;
3778
+ }
3779
+
3780
+ public boolean Undo()
3781
+ {
3782
+ // Option?
3783
+ Replace();
3784
+
3785
+ System.err.println("Undo");
3786
+
3787
+ cRadio tab = GetCurrentTab();
3788
+
3789
+ if (copy.versionindex == 0)
34983790 {
34993791 java.awt.Toolkit.getDefaultToolkit().beep();
3500
- return;
3792
+ return false;
35013793 }
35023794
3503
- if (tab.graphs[tab.undoindex] == null)
3795
+// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex])
3796
+// {
3797
+// if (Save(false))
3798
+// tab.versionindex -= 1;
3799
+// else
3800
+// {
3801
+// if (tab.versionindex <= 0)
3802
+// return false;
3803
+// else
3804
+// tab.versionindex -= 1;
3805
+// }
3806
+// }
3807
+
3808
+ copy.versionindex -= 1;
3809
+
3810
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3811
+
3812
+ return true;
3813
+ }
3814
+
3815
+ public boolean Restore()
3816
+ {
3817
+ System.err.println("Restore");
3818
+
3819
+ cRadio tab = GetCurrentTab();
3820
+
3821
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
35043822 {
3505
- Save();
3506
- tab.undoindex -= 1;
3823
+ java.awt.Toolkit.getDefaultToolkit().beep();
3824
+ return false;
35073825 }
35083826
3509
- tab.undoindex -= 1;
3827
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3828
+
3829
+ return true;
3830
+ }
35103831
3511
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3832
+ public boolean Replace()
3833
+ {
3834
+ System.err.println("Replace");
3835
+
3836
+ cRadio tab = GetCurrentTab();
3837
+
3838
+ if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null)
3839
+ {
3840
+ // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep();
3841
+ return false;
3842
+ }
3843
+
3844
+ copy.versions[copy.versionindex] = CompressCopy();
3845
+
3846
+ return true;
35123847 }
35133848
35143849 public void Redo()
35153850 {
3851
+ // Option?
3852
+ Replace();
3853
+
35163854 cRadio tab = GetCurrentTab();
35173855
3518
- if (tab.graphs[tab.undoindex + 1] == null)
3856
+ if (copy.versions[copy.versionindex + 1] == null)
35193857 {
35203858 java.awt.Toolkit.getDefaultToolkit().beep();
35213859 return;
35223860 }
35233861
3524
- tab.undoindex += 1;
3862
+ copy.versionindex += 1;
35253863
3526
- CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3864
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
3865
+
3866
+ //if (!tab.user[tab.versionindex])
3867
+ // tab.graphs[tab.versionindex] = null;
35273868 }
35283869
35293870 void ImportGFD()
....@@ -3675,7 +4016,7 @@
36754016 assert false;
36764017 }
36774018
3678
- void EditSelection()
4019
+ void EditSelection(boolean newWindow)
36794020 {
36804021 }
36814022
....@@ -3819,9 +4160,25 @@
38194160 //copy.Touch();
38204161 }
38214162
4163
+ cNumberSlider versionSlider;
4164
+
38224165 public void stateChanged(ChangeEvent e)
38234166 {
38244167 // assert(false);
4168
+ if (e.getSource() == versionSlider)
4169
+ {
4170
+ if (muteSlider)
4171
+ return;
4172
+
4173
+ int version = versionSlider.getInteger();
4174
+
4175
+ if (copy.versions[version] != null)
4176
+ {
4177
+ CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version]));
4178
+ }
4179
+
4180
+ return;
4181
+ }
38254182
38264183 if (freezematerial)
38274184 {
....@@ -4170,7 +4527,8 @@
41704527
41714528 void makeSomething(Object3D thing, boolean resetmodel) // deselect)
41724529 {
4173
- Save();
4530
+ if (Globals.REPLACEONMAKE) // && resetmodel)
4531
+ Save();
41744532 //Tween.set(thing, 0).target(1).start(tweenManager);
41754533 //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager);
41764534 // if (thing instanceof GenericJointDemo)
....@@ -4257,6 +4615,12 @@
42574615 {
42584616 ResetModel();
42594617 Select(thing.GetTreePath(), true, false); // unselect... false);
4618
+
4619
+ if (thing.Size() == 0)
4620
+ {
4621
+ //EditSelection(false);
4622
+ }
4623
+
42604624 refreshContents();
42614625 }
42624626
....@@ -4405,7 +4769,9 @@
44054769 readobj.ResetDisplayList();
44064770 } catch (Exception e)
44074771 {
4408
- //e.printStackTrace();
4772
+ if (!e.toString().contains("GZIP"))
4773
+ e.printStackTrace();
4774
+
44094775 try
44104776 {
44114777 java.io.FileInputStream istream = new java.io.FileInputStream(fullname);
....@@ -4479,7 +4845,8 @@
44794845
44804846 if (readobj != null)
44814847 {
4482
- Save();
4848
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4849
+ // Save();
44834850 try
44844851 {
44854852 //readobj.deepCopySelf(copy);
....@@ -4524,6 +4891,7 @@
45244891 }
45254892 } catch (ClassCastException e)
45264893 {
4894
+ e.printStackTrace();
45274895 assert (false);
45284896 Composite c = (Composite) copy;
45294897 c.children.clear();
....@@ -4534,13 +4902,24 @@
45344902 c.addChild(csg);
45354903 }
45364904
4905
+ copy.versions = readobj.versions;
4906
+ copy.versionindex = readobj.versionindex;
4907
+
4908
+ if (copy.versions == null)
4909
+ {
4910
+ copy.versions = new byte[100][];
4911
+ copy.versionindex = -1;
4912
+ }
4913
+
4914
+ //? SetUndoStates();
4915
+
45374916 ResetModel();
45384917 copy.HardTouch(); // recompile?
45394918 refreshContents();
45404919 }
45414920 }
45424921
4543
- void load() // throws ClassNotFoundException
4922
+ void Open() // throws ClassNotFoundException
45444923 {
45454924 if (Grafreed.standAlone)
45464925 {
....@@ -4643,6 +5022,7 @@
46435022 //ps.print(buffer.toString());
46445023 } catch (IOException e)
46455024 {
5025
+ e.printStackTrace();
46465026 }
46475027 }
46485028
....@@ -4657,6 +5037,8 @@
46575037 String filename = browser.getFile();
46585038 if (filename != null && filename.length() > 0)
46595039 {
5040
+ if (!filename.endsWith(".gfd"))
5041
+ filename += ".gfd";
46605042 lastname = browser.getDirectory() + filename;
46615043 save();
46625044 }
....@@ -4823,7 +5205,7 @@
48235205 MenuBar menuBar;
48245206 Menu fileMenu;
48255207 MenuItem newItem;
4826
- MenuItem loadItem;
5208
+ MenuItem openItem;
48275209 MenuItem saveItem;
48285210 MenuItem saveAsItem;
48295211 MenuItem exportAsItem;
....@@ -4846,22 +5228,36 @@
48465228 CheckboxMenuItem toggleSwitchItem;
48475229 CheckboxMenuItem toggleRootItem;
48485230 CheckboxMenuItem animationItem;
5231
+ MenuItem archiveItem;
48495232 CheckboxMenuItem toggleHandleItem;
48505233 CheckboxMenuItem togglePaintItem;
48515234 JSplitPane mainPanel;
48525235 JScrollPane scrollpane;
5236
+
48535237 JPanel toolbarPanel;
5238
+
48545239 cGridBag treePanel;
5240
+
48555241 JPanel radioPanel;
48565242 ButtonGroup buttonGroup;
4857
- cGridBag ctrlPanel;
5243
+
5244
+ cGridBag toolboxPanel;
48585245 cGridBag materialPanel;
5246
+ cGridBag ctrlPanel;
5247
+
48595248 JScrollPane infoPanel;
5249
+
48605250 cGridBag optionsPanel;
5251
+
48615252 JTabbedPane objectPanel;
5253
+ boolean materialFlushed;
5254
+ Object3D latestObject;
5255
+
48625256 cGridBag XYZPanel;
5257
+
48635258 JSplitPane gridPanel;
48645259 JSplitPane bigPanel;
5260
+
48655261 cGridBag bigThree;
48665262 cGridBag scenePanel;
48675263 cGridBag centralPanel;
....@@ -4976,7 +5372,7 @@
49765372 cNumberSlider fogField;
49775373 JLabel opacityPowerLabel;
49785374 cNumberSlider opacityPowerField;
4979
- JTree jTree;
5375
+ cTree jTree;
49805376 //ObjectUI parent;
49815377
49825378 cNumberSlider normalpushField;