Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
ObjEditor.java
....@@ -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());
....@@ -1174,10 +1174,11 @@
11741174 randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
11751175 randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
11761176
1177
+ link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master);
1178
+ link2masterCB.setToolTipText("Attach to support");
1179
+
11771180 if (Globals.ADVANCED)
11781181 {
1179
- link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master);
1180
- link2masterCB.setToolTipText("Attach to support");
11811182 speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup);
11821183 speedupCB.setToolTipText("Option motion capture");
11831184 }
....@@ -1494,7 +1495,7 @@
14941495 // objectPanel.add(north);
14951496 objectPanel.add(editPanel);
14961497
1497
- if (Globals.ADVANCED)
1498
+ //if (Globals.ADVANCED)
14981499 objectPanel.add(infoPanel);
14991500
15001501 objectPanel.add(toolboxPanel);
....@@ -1979,8 +1980,9 @@
19791980 // 3D models
19801981 if (filename.endsWith(".3ds") || filename.endsWith(".3DS"))
19811982 {
1982
- lastConverter = new com.jmex.model.converters.MaxToJme();
1983
- LoadFile(filename, lastConverter);
1983
+ //lastConverter = new com.jmex.model.converters.MaxToJme();
1984
+ //LoadFile(filename, lastConverter);
1985
+ LoadObjFile(filename); // New 3ds loader
19841986 continue;
19851987 }
19861988 if (filename.endsWith(".dae") || filename.endsWith(".DAE"))
....@@ -2706,6 +2708,7 @@
27062708 LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2);
27072709 LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2);
27082710 }
2711
+
27092712 //cJME.count++;
27102713 //cJME.count %= 12;
27112714 if (gc)
....@@ -2889,6 +2892,7 @@
28892892 }
28902893 }
28912894 }
2895
+
28922896 cFileSystemPane FSPane;
28932897
28942898 void SetMaterial(cMaterial mat, Object3D.cVector2[] others)
....@@ -2942,6 +2946,7 @@
29422946 }
29432947 }
29442948 }
2949
+
29452950 freezematerial = false;
29462951 }
29472952
....@@ -3201,10 +3206,6 @@
32013206 {
32023207 ToggleAnimation();
32033208 return;
3204
- } else if (event.getSource() == archiveItem)
3205
- {
3206
- cTools.Archive(frame);
3207
- return;
32083209 } else if (event.getSource() == flipVCB)
32093210 {
32103211 copy.flipV ^= true;
....@@ -3425,6 +3426,10 @@
34253426 {
34263427 generatePOV();
34273428 //return true;
3429
+ } else if (event.getSource() == archiveItem)
3430
+ {
3431
+ cTools.Archive(frame);
3432
+ return;
34283433 } else if (source == zBufferItem)
34293434 {
34303435 try
....@@ -3476,8 +3481,8 @@
34763481 try
34773482 {
34783483 ByteArrayOutputStream baos = new ByteArrayOutputStream();
3479
- java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3480
- ObjectOutputStream out = new ObjectOutputStream(zstream);
3484
+// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos);
3485
+ ObjectOutputStream out = new ObjectOutputStream(baos); //zstream);
34813486
34823487 Object3D parent = o.parent;
34833488 o.parent = null;
....@@ -3488,10 +3493,14 @@
34883493
34893494 out.flush();
34903495
3491
- zstream.close();
3496
+ baos //zstream
3497
+ .close();
34923498 out.close();
34933499
3494
- return baos.toByteArray();
3500
+ byte[] bytes = baos.toByteArray();
3501
+
3502
+ System.out.println("save #bytes = " + bytes.length);
3503
+ return bytes;
34953504 } catch (Exception e)
34963505 {
34973506 System.err.println(e);
....@@ -3501,13 +3510,16 @@
35013510
35023511 static public Object Uncompress(byte[] bytes)
35033512 {
3504
- System.out.println("#bytes = " + bytes.length);
3513
+ System.out.println("restore #bytes = " + bytes.length);
35053514 try
35063515 {
35073516 ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
3508
- java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3509
- ObjectInputStream in = new ObjectInputStream(istream);
3517
+ //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais);
3518
+ ObjectInputStream in = new ObjectInputStream(bais); // istream);
35103519 Object obj = in.readObject();
3520
+
3521
+ bais //istream
3522
+ .close();
35113523 in.close();
35123524
35133525 return obj;
....@@ -3566,6 +3578,27 @@
35663578
35673579 public void Save()
35683580 {
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
+ {
35693602 System.err.println("Save");
35703603
35713604 cRadio tab = GetCurrentTab();
....@@ -3576,19 +3609,37 @@
35763609 copy.ExtractBigData(hashtable);
35773610
35783611 byte[] compress = Compress(copy);
3579
-
3580
- //EditorFrame.m_MainFrame.requestFocusInWindow();
3581
- tab.graphs[tab.undoindex++] = compress;
3582
-
3583
- copy.RestoreBigData(hashtable);
35843612
35853613 CameraPane.SWITCH = temp;
35863614
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
+
35873637 //assert(hashtable.isEmpty());
35883638
35893639 for (int i = tab.undoindex; i < tab.graphs.length; i++)
35903640 {
3591
- tab.graphs[i] = null;
3641
+ //tab.user[i] = false;
3642
+ // tab.graphs[i] = null;
35923643 }
35933644
35943645 SetUndoStates();
....@@ -3611,6 +3662,8 @@
36113662 e.printStackTrace();
36123663 }
36133664 }
3665
+
3666
+ return !thesame;
36143667 }
36153668
36163669 void CopyChanged(Object3D obj)
....@@ -3667,7 +3720,7 @@
36673720 redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null);
36683721 }
36693722
3670
- public void Undo()
3723
+ public boolean Undo()
36713724 {
36723725 System.err.println("Undo");
36733726
....@@ -3676,18 +3729,27 @@
36763729 if (tab.undoindex == 0)
36773730 {
36783731 java.awt.Toolkit.getDefaultToolkit().beep();
3679
- return;
3732
+ return false;
36803733 }
36813734
3682
- if (tab.graphs[tab.undoindex] == null)
3735
+ if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex])
36833736 {
3684
- Save();
3685
- 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
+ }
36863746 }
36873747
36883748 tab.undoindex -= 1;
36893749
36903750 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3751
+
3752
+ return true;
36913753 }
36923754
36933755 public void Redo()
....@@ -3703,6 +3765,9 @@
37033765 tab.undoindex += 1;
37043766
37053767 CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex]));
3768
+
3769
+ //if (!tab.user[tab.undoindex])
3770
+ // tab.graphs[tab.undoindex] = null;
37063771 }
37073772
37083773 void ImportGFD()
....@@ -4665,8 +4730,8 @@
46654730
46664731 if (readobj != null)
46674732 {
4668
- if (Globals.SAVEONMAKE)
4669
- Save();
4733
+ //if (Globals.SAVEONMAKE) // A new object cannot share meshes
4734
+ // Save();
46704735 try
46714736 {
46724737 //readobj.deepCopySelf(copy);
....@@ -5035,7 +5100,7 @@
50355100 CheckboxMenuItem toggleSwitchItem;
50365101 CheckboxMenuItem toggleRootItem;
50375102 CheckboxMenuItem animationItem;
5038
- CheckboxMenuItem archiveItem;
5103
+ MenuItem archiveItem;
50395104 CheckboxMenuItem toggleHandleItem;
50405105 CheckboxMenuItem togglePaintItem;
50415106 JSplitPane mainPanel;