Normand Briere
2019-07-07 46dbce888e7c3eff8969f1ddbe22e144410b67f4
ObjEditor.java
....@@ -309,7 +309,7 @@
309309 //localCopy.parent = null;
310310
311311 frame = new JFrame();
312
- frame.setUndecorated(true);
312
+ frame.setUndecorated(false);
313313 objEditor = this;
314314 this.callee = callee;
315315
....@@ -350,7 +350,7 @@
350350 frame.setMenuBar(menuBar = new MenuBar());
351351 menuBar.add(fileMenu = new Menu("File"));
352352 fileMenu.add(newItem = new MenuItem("New"));
353
- fileMenu.add(loadItem = new MenuItem("Open..."));
353
+ fileMenu.add(openItem = new MenuItem("Open..."));
354354
355355 //oe.menuBar.add(menu = new Menu("Include"));
356356 Menu menu = new Menu("Import");
....@@ -382,7 +382,7 @@
382382 }
383383
384384 newItem.addActionListener(this);
385
- loadItem.addActionListener(this);
385
+ openItem.addActionListener(this);
386386 saveItem.addActionListener(this);
387387 saveAsItem.addActionListener(this);
388388 exportAsItem.addActionListener(this);
....@@ -449,7 +449,7 @@
449449 // TEXTAREA infoarea.setLineWrap(true);
450450 // TEXTAREA infoarea.setWrapStyleWord(true);
451451 infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED);
452
- infoPanel.setPreferredSize(new Dimension(50, 200));
452
+ infoPanel.setPreferredSize(new Dimension(1, 1));
453453 infoPanel.setName("Info");
454454 //infoPanel.setLayout(new BorderLayout());
455455 //infoPanel.add(createTextPane());
....@@ -463,10 +463,11 @@
463463 mainPanel.setResizeWeight(0.5);
464464
465465 //mainPanel.setDividerSize((int) (mainPanel.getDividerSize() * 1.5));
466
-// BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
-// divider.setDividerSize(15);
468
-// divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
466
+ BasicSplitPaneDivider divider = ( (BasicSplitPaneUI) mainPanel.getUI()).getDivider();
467
+ divider.setDividerSize(15);
468
+ divider.setBorder(BorderFactory.createTitledBorder(divider.getBorder(), "Custom border title -- gets rid of the one-touch arrows!"));
469469
470
+ mainPanel.setUI(new BasicSplitPaneUI());
470471
471472 //ctrlPanel.setLayout(new GridLayout(4, 1, 5, 5));
472473 //mainPanel.setLayout(new GridBagLayout());
....@@ -698,8 +699,8 @@
698699 }
699700 }
700701
701
-static GraphicsDevice device = GraphicsEnvironment
702
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
703704
704705 Rectangle keeprect;
705706 cRadio radio;
....@@ -720,10 +721,19 @@
720721 void Minimize()
721722 {
722723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
723725 }
724726
727
+// artifactURI=null, type=0, property=${file.reference.jfxrt.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@6767876f, broken=false, additional={}
728
+// artifactURI=null, type=0, property=${file.reference.mac-ui.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@16bdc817, broken=false, additional={}
729
+// artifactURI=null, type=0, property=${file.reference.classes.jar}, object=org.netbeans.modules.java.api.common.classpath.ClassPathSupport$RelativePath@9daa9c17, broken=false, additional={}
725730 void Maximize()
726731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
727737 if (maximized)
728738 {
729739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -731,22 +741,36 @@
731741 else
732742 {
733743 keeprect = frame.getBounds();
734
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
735
- Dimension rect2 = frame.getToolkit().getScreenSize();
736
- frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
744
+// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
745
+// Dimension rect2 = frame.getToolkit().getScreenSize();
746
+// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height);
737747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
738749 }
739750
740751 maximized ^= true;
752
+
753
+ frame.validate();
741754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
742759
743760 void ToggleFullScreen()
744761 {
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
745764 cameraView.ToggleFullScreen();
746765
747766 if (!CameraPane.FULLSCREEN)
748767 {
749768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
750774 //frame.setVisible(false);
751775 // frame.removeNotify();
752776 // frame.setUndecorated(false);
....@@ -756,7 +780,7 @@
756780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
757781 // X framePanel.add(bigThree);
758782 // X frame.getContentPane().add(/*"Center",*/framePanel);
759
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
760784
761785 //frame.setVisible(true);
762786 radio.layout = keepButton;
....@@ -771,7 +795,12 @@
771795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
772796 // frame.getToolkit().getScreenSize().height);
773797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
774801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
775804 // frame.removeNotify();
776805 // frame.setUndecorated(true);
777806 // frame.addNotify();
....@@ -784,6 +813,7 @@
784813 radio.layout.doClick();
785814 //frame.setVisible(true);
786815 }
816
+ frame.validate();
787817 }
788818
789819 private JTextPane createTextPane()
....@@ -1116,7 +1146,7 @@
11161146 namePanel = new cGridBag();
11171147
11181148 nameField = AddText(namePanel, copy.GetName());
1119
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11201150 oe.ctrlPanel.add(namePanel);
11211151
11221152 oe.ctrlPanel.Return();
....@@ -1141,7 +1171,7 @@
11411171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11421172 rewindCB.setToolTipText("Rewind animation");
11431173
1144
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11451175 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11461176
11471177 if (Globals.ADVANCED)
....@@ -1463,7 +1493,10 @@
14631493 // north.add(ctrlPanel, BorderLayout.NORTH);
14641494 // objectPanel.add(north);
14651495 objectPanel.add(editPanel);
1466
- objectPanel.add(infoPanel);
1496
+
1497
+ //if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
14671500 objectPanel.add(toolboxPanel);
14681501
14691502 /*
....@@ -1572,9 +1605,9 @@
15721605 // aConstraints.gridheight = 1;
15731606
15741607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1575
- framePanel.setContinuousLayout(true);
1576
- framePanel.setOneTouchExpandable(true);
1577
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
15781611 //framePanel.setDividerSize(15);
15791612 //framePanel.setResizeWeight(0.15);
15801613 framePanel.setName("Frame");
....@@ -1593,12 +1626,13 @@
15931626
15941627 frame.setSize(1280, 860);
15951628
1596
- frame.validate();
1597
- frame.setVisible(true);
1598
-
15991629 cameraView.requestFocusInWindow();
16001630
16011631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
16021636
16031637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16041638 frame.addWindowListener(new WindowAdapter()
....@@ -1685,24 +1719,6 @@
16851719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16861720 colorSection.add(texture);
16871721
1688
- cGridBag anisoU = new cGridBag();
1689
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1690
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1691
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1692
- colorSection.add(anisoU);
1693
-
1694
- cGridBag anisoV = new cGridBag();
1695
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1696
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1697
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1698
- colorSection.add(anisoV);
1699
-
1700
- cGridBag shadowbias = new cGridBag();
1701
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1702
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1703
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1704
- colorSection.add(shadowbias);
1705
-
17061722 panel.add(new JSeparator());
17071723
17081724 panel.add(colorSection);
....@@ -1752,6 +1768,12 @@
17521768 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17531769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17541770 diffuseSection.add(fakedepth);
1771
+
1772
+ cGridBag shadowbias = new cGridBag();
1773
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1774
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1775
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1776
+ diffuseSection.add(shadowbias);
17551777
17561778 panel.add(new JSeparator());
17571779
....@@ -1803,6 +1825,18 @@
18031825 // aConstraints.gridy += 1;
18041826 // aConstraints.gridwidth = 1;
18051827
1828
+ cGridBag anisoU = new cGridBag();
1829
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1830
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1831
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1832
+ specularSection.add(anisoU);
1833
+
1834
+ cGridBag anisoV = new cGridBag();
1835
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1836
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1837
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
+ specularSection.add(anisoV);
1839
+
18061840
18071841 panel.add(new JSeparator());
18081842
....@@ -1810,35 +1844,35 @@
18101844
18111845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18121846
1813
- cGridBag globalSection = new cGridBag().setVertical(true);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18141848
18151849 cGridBag camera = new cGridBag();
18161850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18171851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18181852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1819
- globalSection.add(camera);
1853
+ colorSection.add(camera);
18201854
18211855 cGridBag ambient = new cGridBag();
18221856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18231857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18241858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1825
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
18261860
18271861 cGridBag backlit = new cGridBag();
18281862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18291863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18301864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1831
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
18321866
18331867 cGridBag opacity = new cGridBag();
18341868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18351869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18361870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1837
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
18381872
1839
- panel.add(new JSeparator());
1873
+ //panel.add(new JSeparator());
18401874
1841
- panel.add(globalSection);
1875
+ //panel.add(globalSection);
18421876
18431877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18441878
....@@ -1945,8 +1979,9 @@
19451979 // 3D models
19461980 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19471981 {
1948
- lastConverter = new com.jmex.model.converters.MaxToJme();
1949
- LoadFile(filename, lastConverter);
1982
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1983
+ //LoadFile(filename, lastConverter);
1984
+ LoadObjFile(filename); // New 3ds loader
19501985 continue;
19511986 }
19521987 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2672,6 +2707,7 @@
26722707 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26732708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26742709 }
2710
+
26752711 //cJME.count++;
26762712 //cJME.count %= 12;
26772713 if (gc)
....@@ -2855,6 +2891,7 @@
28552891 }
28562892 }
28572893 }
2894
+
28582895 cFileSystemPane FSPane;
28592896
28602897 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2908,6 +2945,7 @@
29082945 }
29092946 }
29102947 }
2948
+
29112949 freezematerial = false;
29122950 }
29132951
....@@ -3360,9 +3398,9 @@
33603398 {
33613399 Close();
33623400 //return true;
3363
- } else if (source == loadItem)
3401
+ } else if (source == openItem)
33643402 {
3365
- load();
3403
+ Open();
33663404 //return true;
33673405 } else if (source == newItem)
33683406 {
....@@ -3387,6 +3425,10 @@
33873425 {
33883426 generatePOV();
33893427 //return true;
3428
+ } else if (event.getSource() == archiveItem)
3429
+ {
3430
+ cTools.Archive(frame);
3431
+ return;
33903432 } else if (source == zBufferItem)
33913433 {
33923434 try
....@@ -3528,6 +3570,28 @@
35283570
35293571 public void Save()
35303572 {
3573
+ // Default reduces the probability of heuristics errors.
3574
+ Save(true);
3575
+ }
3576
+
3577
+ private boolean Equal(byte[] compress, byte[] name)
3578
+ {
3579
+ if (compress.length != name.length)
3580
+ {
3581
+ return false;
3582
+ }
3583
+
3584
+ for (int i=compress.length; --i>=0;)
3585
+ {
3586
+ if (compress[i] != name[i])
3587
+ return false;
3588
+ }
3589
+
3590
+ return true;
3591
+ }
3592
+
3593
+ public boolean Save(boolean user)
3594
+ {
35313595 System.err.println("Save");
35323596
35333597 cRadio tab = GetCurrentTab();
....@@ -3537,17 +3601,32 @@
35373601
35383602 copy.ExtractBigData(hashtable);
35393603
3540
- //EditorFrame.m_MainFrame.requestFocusInWindow();
3541
- tab.graphs[tab.undoindex++] = Compress(copy);
3542
-
3543
- copy.RestoreBigData(hashtable);
3604
+ byte[] compress = Compress(copy);
35443605
35453606 CameraPane.SWITCH = temp;
35463607
3608
+ boolean thesame = false;
3609
+
3610
+ // Quick heuristic using length. Works only when stream is compressed.
3611
+ if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3612
+ {
3613
+ thesame = true;
3614
+ }
3615
+
3616
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3617
+ if (!thesame)
3618
+ {
3619
+ tab.user[tab.undoindex] = user;
3620
+ tab.graphs[tab.undoindex++] = compress;
3621
+ }
3622
+
3623
+ copy.RestoreBigData(hashtable);
3624
+
35473625 //assert(hashtable.isEmpty());
35483626
35493627 for (int i = tab.undoindex; i < tab.graphs.length; i++)
35503628 {
3629
+ tab.user[i] = false;
35513630 tab.graphs[i] = null;
35523631 }
35533632
....@@ -3571,6 +3650,8 @@
35713650 e.printStackTrace();
35723651 }
35733652 }
3653
+
3654
+ return !thesame;
35743655 }
35753656
35763657 void CopyChanged(Object3D obj)
....@@ -3627,7 +3708,7 @@
36273708 redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
36283709 }
36293710
3630
- public void Undo()
3711
+ public boolean Undo()
36313712 {
36323713 System.err.println("Undo");
36333714
....@@ -3636,18 +3717,27 @@
36363717 if (tab.undoindex == 0)
36373718 {
36383719 java.awt.Toolkit.getDefaultToolkit().beep();
3639
- return;
3720
+ return false;
36403721 }
36413722
3642
- if (tab.graphs[tab.undoindex] == null)
3723
+ if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex])
36433724 {
3644
- Save();
3645
- tab.undoindex -= 1;
3725
+ if (Save(false))
3726
+ tab.undoindex -= 1;
3727
+ else
3728
+ {
3729
+ if (tab.undoindex <= 0)
3730
+ return false;
3731
+ else
3732
+ tab.undoindex -= 1;
3733
+ }
36463734 }
36473735
36483736 tab.undoindex -= 1;
36493737
36503738 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3739
+
3740
+ return true;
36513741 }
36523742
36533743 public void Redo()
....@@ -3663,6 +3753,9 @@
36633753 tab.undoindex += 1;
36643754
36653755 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3756
+
3757
+ if (!tab.user[tab.undoindex])
3758
+ tab.graphs[tab.undoindex] = null;
36663759 }
36673760
36683761 void ImportGFD()
....@@ -4687,7 +4780,7 @@
46874780 }
46884781 }
46894782
4690
- void load() // throws ClassNotFoundException
4783
+ void Open() // throws ClassNotFoundException
46914784 {
46924785 if (Grafreed.standAlone)
46934786 {
....@@ -4972,7 +5065,7 @@
49725065 MenuBar menuBar;
49735066 Menu fileMenu;
49745067 MenuItem newItem;
4975
- MenuItem loadItem;
5068
+ MenuItem openItem;
49765069 MenuItem saveItem;
49775070 MenuItem saveAsItem;
49785071 MenuItem exportAsItem;
....@@ -4995,6 +5088,7 @@
49955088 CheckboxMenuItem toggleSwitchItem;
49965089 CheckboxMenuItem toggleRootItem;
49975090 CheckboxMenuItem animationItem;
5091
+ MenuItem archiveItem;
49985092 CheckboxMenuItem toggleHandleItem;
49995093 CheckboxMenuItem togglePaintItem;
50005094 JSplitPane mainPanel;