Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
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,13 +1171,14 @@
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
1177
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1178
+ link2masterCB.setToolTipText("Attach to support");
1179
+
11481180 if (Globals.ADVANCED)
11491181 {
1150
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1151
- link2masterCB.setToolTipText("Attach to support");
11521182 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11531183 speedupCB.setToolTipText("Option motion capture");
11541184 }
....@@ -1464,7 +1494,10 @@
14641494 // north.add(ctrlPanel, BorderLayout.NORTH);
14651495 // objectPanel.add(north);
14661496 objectPanel.add(editPanel);
1467
- objectPanel.add(infoPanel);
1497
+
1498
+ //if (Globals.ADVANCED)
1499
+ objectPanel.add(infoPanel);
1500
+
14681501 objectPanel.add(toolboxPanel);
14691502
14701503 /*
....@@ -1573,9 +1606,9 @@
15731606 // aConstraints.gridheight = 1;
15741607
15751608 framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree);
1576
- framePanel.setContinuousLayout(true);
1577
- framePanel.setOneTouchExpandable(true);
1578
- framePanel.setDividerLocation(0.8);
1609
+ framePanel.setContinuousLayout(false);
1610
+ framePanel.setOneTouchExpandable(false);
1611
+ //.setDividerLocation(0.8);
15791612 //framePanel.setDividerSize(15);
15801613 //framePanel.setResizeWeight(0.15);
15811614 framePanel.setName("Frame");
....@@ -1594,12 +1627,13 @@
15941627
15951628 frame.setSize(1280, 860);
15961629
1597
- frame.validate();
1598
- frame.setVisible(true);
1599
-
16001630 cameraView.requestFocusInWindow();
16011631
16021632 gridPanel.setDividerLocation(1.0);
1633
+
1634
+ frame.validate();
1635
+
1636
+ frame.setVisible(true);
16031637
16041638 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
16051639 frame.addWindowListener(new WindowAdapter()
....@@ -1686,24 +1720,6 @@
16861720 texture.add(textureField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
16871721 colorSection.add(texture);
16881722
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
-
17071723 panel.add(new JSeparator());
17081724
17091725 panel.add(colorSection);
....@@ -1753,6 +1769,12 @@
17531769 fakedepthLabel.setHorizontalAlignment(SwingConstants.TRAILING);
17541770 fakedepth.add(fakedepthField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
17551771 diffuseSection.add(fakedepth);
1772
+
1773
+ cGridBag shadowbias = new cGridBag();
1774
+ shadowbias.add(shadowbiasLabel = new JLabel("Shadowbias")); // , aConstraints);
1775
+ shadowbiasLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1776
+ shadowbias.add(shadowbiasField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1777
+ diffuseSection.add(shadowbias);
17561778
17571779 panel.add(new JSeparator());
17581780
....@@ -1804,6 +1826,18 @@
18041826 // aConstraints.gridy += 1;
18051827 // aConstraints.gridwidth = 1;
18061828
1829
+ cGridBag anisoU = new cGridBag();
1830
+ anisoU.add(anisoLabel = new JLabel("AnisoU")); // , aConstraints);
1831
+ anisoLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1832
+ anisoU.add(anisoField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1833
+ specularSection.add(anisoU);
1834
+
1835
+ cGridBag anisoV = new cGridBag();
1836
+ anisoV.add(anisoVLabel = new JLabel("AnisoV")); // , aConstraints);
1837
+ anisoVLabel.setHorizontalAlignment(SwingConstants.TRAILING);
1838
+ anisoV.add(anisoVField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1839
+ specularSection.add(anisoV);
1840
+
18071841
18081842 panel.add(new JSeparator());
18091843
....@@ -1811,35 +1845,35 @@
18111845
18121846 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18131847
1814
- cGridBag globalSection = new cGridBag().setVertical(true);
1848
+ //cGridBag globalSection = new cGridBag().setVertical(true);
18151849
18161850 cGridBag camera = new cGridBag();
18171851 camera.add(cameraLabel = new JLabel("GlobalLight")); // , aConstraints);
18181852 cameraLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18191853 camera.add(cameraField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1820
- globalSection.add(camera);
1854
+ colorSection.add(camera);
18211855
18221856 cGridBag ambient = new cGridBag();
18231857 ambient.add(ambientLabel = new JLabel("Ambient")); // , aConstraints);
18241858 ambientLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18251859 ambient.add(ambientField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1826
- globalSection.add(ambient);
1860
+ colorSection.add(ambient);
18271861
18281862 cGridBag backlit = new cGridBag();
18291863 backlit.add(backlitLabel = new JLabel("Backlit")); // , aConstraints);
18301864 backlitLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18311865 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
1832
- globalSection.add(backlit);
1866
+ colorSection.add(backlit);
18331867
18341868 cGridBag opacity = new cGridBag();
18351869 opacity.add(opacityLabel = new JLabel("Opacity")); // , aConstraints);
18361870 opacityLabel.setHorizontalAlignment(SwingConstants.TRAILING);
18371871 opacity.add(opacityField = new cNumberSlider(this, 0.001, 1, -0.5)); // , aConstraints);
1838
- globalSection.add(opacity);
1872
+ colorSection.add(opacity);
18391873
1840
- panel.add(new JSeparator());
1874
+ //panel.add(new JSeparator());
18411875
1842
- panel.add(globalSection);
1876
+ //panel.add(globalSection);
18431877
18441878 //ctrlPanel.add(new JLabel("----------------------------------")); // , aConstraints);
18451879
....@@ -1946,8 +1980,9 @@
19461980 // 3D models
19471981 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19481982 {
1949
- lastConverter = new com.jmex.model.converters.MaxToJme();
1950
- LoadFile(filename, lastConverter);
1983
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1984
+ //LoadFile(filename, lastConverter);
1985
+ LoadObjFile(filename); // New 3ds loader
19511986 continue;
19521987 }
19531988 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2673,6 +2708,7 @@
26732708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
26742709 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
26752710 }
2711
+
26762712 //cJME.count++;
26772713 //cJME.count %= 12;
26782714 if (gc)
....@@ -2856,6 +2892,7 @@
28562892 }
28572893 }
28582894 }
2895
+
28592896 cFileSystemPane FSPane;
28602897
28612898 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2909,6 +2946,7 @@
29092946 }
29102947 }
29112948 }
2949
+
29122950 freezematerial = false;
29132951 }
29142952
....@@ -3361,9 +3399,9 @@
33613399 {
33623400 Close();
33633401 //return true;
3364
- } else if (source == loadItem)
3402
+ } else if (source == openItem)
33653403 {
3366
- load();
3404
+ Open();
33673405 //return true;
33683406 } else if (source == newItem)
33693407 {
....@@ -3388,6 +3426,10 @@
33883426 {
33893427 generatePOV();
33903428 //return true;
3429
+ } else if (event.getSource() == archiveItem)
3430
+ {
3431
+ cTools.Archive(frame);
3432
+ return;
33913433 } else if (source == zBufferItem)
33923434 {
33933435 try
....@@ -3439,8 +3481,8 @@
34393481 try
34403482 {
34413483 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3442
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3443
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3484
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3485
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34443486
34453487 Object3D parent = o.parent;
34463488 o.parent = null;
....@@ -3451,10 +3493,14 @@
34513493
34523494 out.flush();
34533495
3454
- zstream.close();
3496
+ baos //zstream
3497
+ .close();
34553498 out.close();
34563499
3457
- return baos.toByteArray();
3500
+ byte[] bytes = baos.toByteArray();
3501
+
3502
+ System.out.println("save #bytes = " + bytes.length);
3503
+ return bytes;
34583504 } catch (Exception e)
34593505 {
34603506 System.err.println(e);
....@@ -3464,13 +3510,16 @@
34643510
34653511 static public Object Uncompress(byte[] bytes)
34663512 {
3467
- System.out.println("#bytes = " + bytes.length);
3513
+ System.out.println("restore #bytes = " + bytes.length);
34683514 try
34693515 {
34703516 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3471
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3472
- ObjectInputStream in = new ObjectInputStream(istream);
3517
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3518
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
34733519 Object obj = in.readObject();
3520
+
3521
+ bais //istream
3522
+ .close();
34743523 in.close();
34753524
34763525 return obj;
....@@ -3529,6 +3578,27 @@
35293578
35303579 public void Save()
35313580 {
3581
+ Save(true);
3582
+ }
3583
+
3584
+ private boolean Equal(byte[] compress, byte[] name)
3585
+ {
3586
+ if (compress.length != name.length)
3587
+ {
3588
+ return false;
3589
+ }
3590
+
3591
+ for (int i=compress.length; --i>=0;)
3592
+ {
3593
+ if (compress[i] != name[i])
3594
+ return false;
3595
+ }
3596
+
3597
+ return true;
3598
+ }
3599
+
3600
+ public boolean Save(boolean user)
3601
+ {
35323602 System.err.println("Save");
35333603
35343604 cRadio tab = GetCurrentTab();
....@@ -3538,18 +3608,38 @@
35383608
35393609 copy.ExtractBigData(hashtable);
35403610
3541
- //EditorFrame.m_MainFrame.requestFocusInWindow();
3542
- tab.graphs[tab.undoindex++] = Compress(copy);
3543
-
3544
- copy.RestoreBigData(hashtable);
3611
+ byte[] compress = Compress(copy);
35453612
35463613 CameraPane.SWITCH = temp;
35473614
3615
+ boolean thesame = false;
3616
+
3617
+ // Quick heuristic using length. Works only when stream is compressed.
3618
+ if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1]))
3619
+ {
3620
+ thesame = true;
3621
+ }
3622
+
3623
+ //EditorFrame.m_MainFrame.requestFocusInWindow();
3624
+ if (!thesame)
3625
+ {
3626
+ //tab.user[tab.undoindex] = user;
3627
+ boolean increment = tab.graphs[tab.undoindex] == null;
3628
+
3629
+ tab.graphs[tab.undoindex] = compress;
3630
+
3631
+ if (increment)
3632
+ tab.undoindex++;
3633
+ }
3634
+
3635
+ copy.RestoreBigData(hashtable);
3636
+
35483637 //assert(hashtable.isEmpty());
35493638
35503639 for (int i = tab.undoindex; i < tab.graphs.length; i++)
35513640 {
3552
- tab.graphs[i] = null;
3641
+ //tab.user[i] = false;
3642
+ // tab.graphs[i] = null;
35533643 }
35543644
35553645 SetUndoStates();
....@@ -3572,6 +3662,8 @@
35723662 e.printStackTrace();
35733663 }
35743664 }
3665
+
3666
+ return !thesame;
35753667 }
35763668
35773669 void CopyChanged(Object3D obj)
....@@ -3628,7 +3720,7 @@
36283720 redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
36293721 }
36303722
3631
- public void Undo()
3723
+ public boolean Undo()
36323724 {
36333725 System.err.println("Undo");
36343726
....@@ -3637,18 +3729,27 @@
36373729 if (tab.undoindex == 0)
36383730 {
36393731 java.awt.Toolkit.getDefaultToolkit().beep();
3640
- return;
3732
+ return false;
36413733 }
36423734
3643
- if (tab.graphs[tab.undoindex] == null)
3735
+ if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
36443736 {
3645
- Save();
3646
- tab.undoindex -= 1;
3737
+ if (Save(false))
3738
+ tab.undoindex -= 1;
3739
+ else
3740
+ {
3741
+ if (tab.undoindex <= 0)
3742
+ return false;
3743
+ else
3744
+ tab.undoindex -= 1;
3745
+ }
36473746 }
36483747
36493748 tab.undoindex -= 1;
36503749
36513750 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3751
+
3752
+ return true;
36523753 }
36533754
36543755 public void Redo()
....@@ -3664,6 +3765,9 @@
36643765 tab.undoindex += 1;
36653766
36663767 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3768
+
3769
+ //if (!tab.user[tab.undoindex])
3770
+ // tab.graphs[tab.undoindex] = null;
36673771 }
36683772
36693773 void ImportGFD()
....@@ -4626,8 +4730,8 @@
46264730
46274731 if (readobj != null)
46284732 {
4629
- if (Globals.SAVEONMAKE)
4630
- Save();
4733
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4734
+ // Save();
46314735 try
46324736 {
46334737 //readobj.deepCopySelf(copy);
....@@ -4688,7 +4792,7 @@
46884792 }
46894793 }
46904794
4691
- void load() // throws ClassNotFoundException
4795
+ void Open() // throws ClassNotFoundException
46924796 {
46934797 if (Grafreed.standAlone)
46944798 {
....@@ -4973,7 +5077,7 @@
49735077 MenuBar menuBar;
49745078 Menu fileMenu;
49755079 MenuItem newItem;
4976
- MenuItem loadItem;
5080
+ MenuItem openItem;
49775081 MenuItem saveItem;
49785082 MenuItem saveAsItem;
49795083 MenuItem exportAsItem;
....@@ -4996,6 +5100,7 @@
49965100 CheckboxMenuItem toggleSwitchItem;
49975101 CheckboxMenuItem toggleRootItem;
49985102 CheckboxMenuItem animationItem;
5103
+ MenuItem archiveItem;
49995104 CheckboxMenuItem toggleHandleItem;
50005105 CheckboxMenuItem togglePaintItem;
50015106 JSplitPane mainPanel;