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());
....@@ -699,8 +699,8 @@
699699 }
700700 }
701701
702
-static GraphicsDevice device = GraphicsEnvironment
703
- .getLocalGraphicsEnvironment().getScreenDevices()[0];
702
+//static GraphicsDevice device = GraphicsEnvironment
703
+// .getLocalGraphicsEnvironment().getScreenDevices()[0];
704704
705705 Rectangle keeprect;
706706 cRadio radio;
....@@ -721,10 +721,19 @@
721721 void Minimize()
722722 {
723723 frame.setState(Frame.ICONIFIED);
724
+ frame.validate();
724725 }
725726
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={}
726730 void Maximize()
727731 {
732
+ if (CameraPane.FULLSCREEN)
733
+ {
734
+ ToggleFullScreen();
735
+ }
736
+
728737 if (maximized)
729738 {
730739 frame.setBounds(keeprect.x, keeprect.y, keeprect.width, keeprect.height);
....@@ -732,22 +741,36 @@
732741 else
733742 {
734743 keeprect = frame.getBounds();
735
- Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
736
- Dimension rect2 = frame.getToolkit().getScreenSize();
737
- 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);
738747 // frame.setState(Frame.MAXIMIZED_BOTH);
748
+ frame.setBounds(frame.getGraphicsConfiguration().getBounds());
739749 }
740750
741751 maximized ^= true;
752
+
753
+ frame.validate();
742754 }
755
+
756
+ cButton minButton;
757
+ cButton maxButton;
758
+ cButton fullButton;
743759
744760 void ToggleFullScreen()
745761 {
762
+GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
763
+
746764 cameraView.ToggleFullScreen();
747765
748766 if (!CameraPane.FULLSCREEN)
749767 {
750768 device.setFullScreenWindow(null);
769
+ frame.dispose();
770
+ frame.setUndecorated(false);
771
+ frame.validate();
772
+ frame.setVisible(true);
773
+
751774 //frame.setVisible(false);
752775 // frame.removeNotify();
753776 // frame.setUndecorated(false);
....@@ -757,7 +780,7 @@
757780 // X frame.getContentPane().remove(/*"Center",*/bigThree);
758781 // X framePanel.add(bigThree);
759782 // X frame.getContentPane().add(/*"Center",*/framePanel);
760
- framePanel.setDividerLocation(1);
783
+ framePanel.setDividerLocation(46);
761784
762785 //frame.setVisible(true);
763786 radio.layout = keepButton;
....@@ -772,7 +795,12 @@
772795 // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width,
773796 // frame.getToolkit().getScreenSize().height);
774797 //frame.setVisible(false);
798
+
799
+ frame.dispose();
800
+ frame.setUndecorated(true);
775801 device.setFullScreenWindow(frame);
802
+ frame.validate();
803
+ frame.setVisible(true);
776804 // frame.removeNotify();
777805 // frame.setUndecorated(true);
778806 // frame.addNotify();
....@@ -785,6 +813,7 @@
785813 radio.layout.doClick();
786814 //frame.setVisible(true);
787815 }
816
+ frame.validate();
788817 }
789818
790819 private JTextPane createTextPane()
....@@ -1117,7 +1146,7 @@
11171146 namePanel = new cGridBag();
11181147
11191148 nameField = AddText(namePanel, copy.GetName());
1120
- namePanel.add(nameField);
1149
+ namePanel.add(new JScrollPane(nameField, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
11211150 oe.ctrlPanel.add(namePanel);
11221151
11231152 oe.ctrlPanel.Return();
....@@ -1142,7 +1171,7 @@
11421171 rewindCB = AddCheckBox(setupPanel2, "Rewind", copy.rewind);
11431172 rewindCB.setToolTipText("Rewind animation");
11441173
1145
- randomCB = AddCheckBox(setupPanel2, "Rand", copy.random);
1174
+ randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11461175 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11471176
11481177 if (Globals.ADVANCED)
....@@ -1464,7 +1493,10 @@
14641493 // north.add(ctrlPanel, BorderLayout.NORTH);
14651494 // objectPanel.add(north);
14661495 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1496
+
1497
+ //if (Globals.ADVANCED)
1498
+ objectPanel.add(infoPanel);
1499
+
14681500 objectPanel.add(toolboxPanel);
14691501
14701502 /*
....@@ -1573,9 +1605,9 @@
15731605 // aConstraints.gridheight = 1;
15741606
15751607 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1608
+ framePanel.setContinuousLayout(false);
1609
+ framePanel.setOneTouchExpandable(false);
1610
+ //.setDividerLocation(0.8);
15791611 //framePanel.setDividerSize(15);
15801612 //framePanel.setResizeWeight(0.15);
15811613 framePanel.setName("Frame");
....@@ -1594,12 +1626,13 @@
15941626
15951627 frame.setSize(1280, 860);
15961628
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001629 cameraView.requestFocusInWindow();
16011630
16021631 gridPanel.setDividerLocation(1.0);
1632
+
1633
+ frame.validate();
1634
+
1635
+ frame.setVisible(true);
16031636
16041637 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051638 frame.addWindowListener(new WindowAdapter()
....@@ -1686,24 +1719,6 @@
16861719 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871720 colorSection.add(texture);
16881721
1689
- cGridBag anisoU = new cGridBag();
1690
- anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1691
- anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1692
- anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1693
- colorSection.add(anisoU);
1694
-
1695
- cGridBag anisoV = new cGridBag();
1696
- anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1697
- anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1698
- anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1699
- colorSection.add(anisoV);
1700
-
1701
- cGridBag shadowbias = new cGridBag();
1702
- shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1703
- shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1704
- shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1705
- colorSection.add(shadowbias);
1706
-
17071722 panel.add(new JSeparator());
17081723
17091724 panel.add(colorSection);
....@@ -1753,6 +1768,12 @@
17531768 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17541769 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551770 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);
17561777
17571778 panel.add(new JSeparator());
17581779
....@@ -1804,6 +1825,18 @@
18041825 // aConstraints.gridy += 1;
18051826 // aConstraints.gridwidth = 1;
18061827
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
+
18071840
18081841 panel.add(new JSeparator());
18091842
....@@ -1811,35 +1844,35 @@
18111844
18121845 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18131846
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
1847
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18151848
18161849 cGridBag camera = new cGridBag();
18171850 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18181851 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18191852 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
1853
+ colorSection.add(camera);
18211854
18221855 cGridBag ambient = new cGridBag();
18231856 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18241857 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18251858 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
1859
+ colorSection.add(ambient);
18271860
18281861 cGridBag backlit = new cGridBag();
18291862 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18301863 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18311864 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
1865
+ colorSection.add(backlit);
18331866
18341867 cGridBag opacity = new cGridBag();
18351868 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18361869 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18371870 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1871
+ colorSection.add(opacity);
18391872
1840
- panel.add(new JSeparator());
1873
+ //panel.add(new JSeparator());
18411874
1842
- panel.add(globalSection);
1875
+ //panel.add(globalSection);
18431876
18441877 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18451878
....@@ -1946,8 +1979,9 @@
19461979 // 3D models
19471980 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19481981 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
1982
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1983
+ //LoadFile(filename, lastConverter);
1984
+ LoadObjFile(filename); // New 3ds loader
19511985 continue;
19521986 }
19531987 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2707,7 @@
26732707 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752709 }
2710
+
26762711 //cJME.count++;
26772712 //cJME.count %= 12;
26782713 if (gc)
....@@ -2856,6 +2891,7 @@
28562891 }
28572892 }
28582893 }
2894
+
28592895 cFileSystemPane FSPane;
28602896
28612897 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2909,6 +2945,7 @@
29092945 }
29102946 }
29112947 }
2948
+
29122949 freezematerial = false;
29132950 }
29142951
....@@ -3361,9 +3398,9 @@
33613398 {
33623399 Close();
33633400 //return true;
3364
- } else if (source == loadItem)
3401
+ } else if (source == openItem)
33653402 {
3366
- load();
3403
+ Open();
33673404 //return true;
33683405 } else if (source == newItem)
33693406 {
....@@ -3388,6 +3425,10 @@
33883425 {
33893426 generatePOV();
33903427 //return true;
3428
+ } else if (event.getSource() == archiveItem)
3429
+ {
3430
+ cTools.Archive(frame);
3431
+ return;
33913432 } else if (source == zBufferItem)
33923433 {
33933434 try
....@@ -3529,6 +3570,28 @@
35293570
35303571 public void Save()
35313572 {
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
+ {
35323595 System.err.println("Save");
35333596
35343597 cRadio tab = GetCurrentTab();
....@@ -3538,17 +3601,32 @@
35383601
35393602 copy.ExtractBigData(hashtable);
35403603
3541
- //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- tab.graphs[tab.undoindex++] = Compress(copy);
3543
-
3544
- copy.RestoreBigData(hashtable);
3604
+ byte[] compress = Compress(copy);
35453605
35463606 CameraPane.SWITCH = temp;
35473607
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
+
35483625 //assert(hashtable.isEmpty());
35493626
35503627 for (int i = tab.undoindex; i < tab.graphs.length; i++)
35513628 {
3629
+ tab.user[i] = false;
35523630 tab.graphs[i] = null;
35533631 }
35543632
....@@ -3572,6 +3650,8 @@
35723650 e.printStackTrace();
35733651 }
35743652 }
3653
+
3654
+ return !thesame;
35753655 }
35763656
35773657 void CopyChanged(Object3D obj)
....@@ -3628,7 +3708,7 @@
36283708 redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
36293709 }
36303710
3631
- public void Undo()
3711
+ public boolean Undo()
36323712 {
36333713 System.err.println("Undo");
36343714
....@@ -3637,18 +3717,27 @@
36373717 if (tab.undoindex == 0)
36383718 {
36393719 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3720
+ return false;
36413721 }
36423722
3643
- if (tab.graphs[tab.undoindex] == null)
3723
+ if (tab.graphs[tab.undoindex] == null || !tab.user[tab.undoindex])
36443724 {
3645
- Save();
3646
- 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
+ }
36473734 }
36483735
36493736 tab.undoindex -= 1;
36503737
36513738 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3739
+
3740
+ return true;
36523741 }
36533742
36543743 public void Redo()
....@@ -3664,6 +3753,9 @@
36643753 tab.undoindex += 1;
36653754
36663755 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3756
+
3757
+ if (!tab.user[tab.undoindex])
3758
+ tab.graphs[tab.undoindex] = null;
36673759 }
36683760
36693761 void ImportGFD()
....@@ -4688,7 +4780,7 @@
46884780 }
46894781 }
46904782
4691
- void load() // throws ClassNotFoundException
4783
+ void Open() // throws ClassNotFoundException
46924784 {
46934785 if (Grafreed.standAlone)
46944786 {
....@@ -4973,7 +5065,7 @@
49735065 MenuBar menuBar;
49745066 Menu fileMenu;
49755067 MenuItem newItem;
4976
- MenuItem loadItem;
5068
+ MenuItem openItem;
49775069 MenuItem saveItem;
49785070 MenuItem saveAsItem;
49795071 MenuItem exportAsItem;
....@@ -4996,6 +5088,7 @@
49965088 CheckboxMenuItem toggleSwitchItem;
49975089 CheckboxMenuItem toggleRootItem;
49985090 CheckboxMenuItem animationItem;
5091
+ MenuItem archiveItem;
49995092 CheckboxMenuItem toggleHandleItem;
50005093 CheckboxMenuItem togglePaintItem;
50015094 JSplitPane mainPanel;