.. | .. |
---|
449 | 449 | // TEXTAREA infoarea.setLineWrap(true); |
---|
450 | 450 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 451 | 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)); |
---|
453 | 453 | infoPanel.setName("Info"); |
---|
454 | 454 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 455 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
1174 | 1174 | randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1175 | 1175 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1176 | 1176 | |
---|
| 1177 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1178 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1179 | + |
---|
1177 | 1180 | if (Globals.ADVANCED) |
---|
1178 | 1181 | { |
---|
1179 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1180 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1181 | 1182 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1182 | 1183 | speedupCB.setToolTipText("Option motion capture"); |
---|
1183 | 1184 | } |
---|
.. | .. |
---|
1494 | 1495 | // objectPanel.add(north); |
---|
1495 | 1496 | objectPanel.add(editPanel); |
---|
1496 | 1497 | |
---|
1497 | | - if (Globals.ADVANCED) |
---|
| 1498 | + //if (Globals.ADVANCED) |
---|
1498 | 1499 | objectPanel.add(infoPanel); |
---|
1499 | 1500 | |
---|
1500 | 1501 | objectPanel.add(toolboxPanel); |
---|
.. | .. |
---|
1979 | 1980 | // 3D models |
---|
1980 | 1981 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1981 | 1982 | { |
---|
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 |
---|
1984 | 1986 | continue; |
---|
1985 | 1987 | } |
---|
1986 | 1988 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2706 | 2708 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2707 | 2709 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2708 | 2710 | } |
---|
| 2711 | + |
---|
2709 | 2712 | //cJME.count++; |
---|
2710 | 2713 | //cJME.count %= 12; |
---|
2711 | 2714 | if (gc) |
---|
.. | .. |
---|
2889 | 2892 | } |
---|
2890 | 2893 | } |
---|
2891 | 2894 | } |
---|
| 2895 | + |
---|
2892 | 2896 | cFileSystemPane FSPane; |
---|
2893 | 2897 | |
---|
2894 | 2898 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2942 | 2946 | } |
---|
2943 | 2947 | } |
---|
2944 | 2948 | } |
---|
| 2949 | + |
---|
2945 | 2950 | freezematerial = false; |
---|
2946 | 2951 | } |
---|
2947 | 2952 | |
---|
.. | .. |
---|
3201 | 3206 | { |
---|
3202 | 3207 | ToggleAnimation(); |
---|
3203 | 3208 | return; |
---|
3204 | | - } else if (event.getSource() == archiveItem) |
---|
3205 | | - { |
---|
3206 | | - cTools.Archive(frame); |
---|
3207 | | - return; |
---|
3208 | 3209 | } else if (event.getSource() == flipVCB) |
---|
3209 | 3210 | { |
---|
3210 | 3211 | copy.flipV ^= true; |
---|
.. | .. |
---|
3425 | 3426 | { |
---|
3426 | 3427 | generatePOV(); |
---|
3427 | 3428 | //return true; |
---|
| 3429 | + } else if (event.getSource() == archiveItem) |
---|
| 3430 | + { |
---|
| 3431 | + cTools.Archive(frame); |
---|
| 3432 | + return; |
---|
3428 | 3433 | } else if (source == zBufferItem) |
---|
3429 | 3434 | { |
---|
3430 | 3435 | try |
---|
.. | .. |
---|
3476 | 3481 | try |
---|
3477 | 3482 | { |
---|
3478 | 3483 | 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); |
---|
3481 | 3486 | |
---|
3482 | 3487 | Object3D parent = o.parent; |
---|
3483 | 3488 | o.parent = null; |
---|
.. | .. |
---|
3488 | 3493 | |
---|
3489 | 3494 | out.flush(); |
---|
3490 | 3495 | |
---|
3491 | | - zstream.close(); |
---|
| 3496 | + baos //zstream |
---|
| 3497 | + .close(); |
---|
3492 | 3498 | out.close(); |
---|
3493 | 3499 | |
---|
3494 | | - return baos.toByteArray(); |
---|
| 3500 | + byte[] bytes = baos.toByteArray(); |
---|
| 3501 | + |
---|
| 3502 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3503 | + return bytes; |
---|
3495 | 3504 | } catch (Exception e) |
---|
3496 | 3505 | { |
---|
3497 | 3506 | System.err.println(e); |
---|
.. | .. |
---|
3501 | 3510 | |
---|
3502 | 3511 | static public Object Uncompress(byte[] bytes) |
---|
3503 | 3512 | { |
---|
3504 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3513 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3505 | 3514 | try |
---|
3506 | 3515 | { |
---|
3507 | 3516 | 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); |
---|
3510 | 3519 | Object obj = in.readObject(); |
---|
| 3520 | + |
---|
| 3521 | + bais //istream |
---|
| 3522 | + .close(); |
---|
3511 | 3523 | in.close(); |
---|
3512 | 3524 | |
---|
3513 | 3525 | return obj; |
---|
.. | .. |
---|
3566 | 3578 | |
---|
3567 | 3579 | public void Save() |
---|
3568 | 3580 | { |
---|
| 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 | + { |
---|
3569 | 3602 | System.err.println("Save"); |
---|
3570 | 3603 | |
---|
3571 | 3604 | cRadio tab = GetCurrentTab(); |
---|
.. | .. |
---|
3576 | 3609 | copy.ExtractBigData(hashtable); |
---|
3577 | 3610 | |
---|
3578 | 3611 | byte[] compress = Compress(copy); |
---|
3579 | | - |
---|
3580 | | - //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3581 | | - tab.graphs[tab.undoindex++] = compress; |
---|
3582 | | - |
---|
3583 | | - copy.RestoreBigData(hashtable); |
---|
3584 | 3612 | |
---|
3585 | 3613 | CameraPane.SWITCH = temp; |
---|
3586 | 3614 | |
---|
| 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 | + |
---|
3587 | 3637 | //assert(hashtable.isEmpty()); |
---|
3588 | 3638 | |
---|
3589 | 3639 | for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
3590 | 3640 | { |
---|
3591 | | - tab.graphs[i] = null; |
---|
| 3641 | + //tab.user[i] = false; |
---|
| 3642 | + // tab.graphs[i] = null; |
---|
3592 | 3643 | } |
---|
3593 | 3644 | |
---|
3594 | 3645 | SetUndoStates(); |
---|
.. | .. |
---|
3611 | 3662 | e.printStackTrace(); |
---|
3612 | 3663 | } |
---|
3613 | 3664 | } |
---|
| 3665 | + |
---|
| 3666 | + return !thesame; |
---|
3614 | 3667 | } |
---|
3615 | 3668 | |
---|
3616 | 3669 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3667 | 3720 | redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
3668 | 3721 | } |
---|
3669 | 3722 | |
---|
3670 | | - public void Undo() |
---|
| 3723 | + public boolean Undo() |
---|
3671 | 3724 | { |
---|
3672 | 3725 | System.err.println("Undo"); |
---|
3673 | 3726 | |
---|
.. | .. |
---|
3676 | 3729 | if (tab.undoindex == 0) |
---|
3677 | 3730 | { |
---|
3678 | 3731 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3679 | | - return; |
---|
| 3732 | + return false; |
---|
3680 | 3733 | } |
---|
3681 | 3734 | |
---|
3682 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3735 | + if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
3683 | 3736 | { |
---|
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 | + } |
---|
3686 | 3746 | } |
---|
3687 | 3747 | |
---|
3688 | 3748 | tab.undoindex -= 1; |
---|
3689 | 3749 | |
---|
3690 | 3750 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3751 | + |
---|
| 3752 | + return true; |
---|
3691 | 3753 | } |
---|
3692 | 3754 | |
---|
3693 | 3755 | public void Redo() |
---|
.. | .. |
---|
3703 | 3765 | tab.undoindex += 1; |
---|
3704 | 3766 | |
---|
3705 | 3767 | CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3768 | + |
---|
| 3769 | + //if (!tab.user[tab.undoindex]) |
---|
| 3770 | + // tab.graphs[tab.undoindex] = null; |
---|
3706 | 3771 | } |
---|
3707 | 3772 | |
---|
3708 | 3773 | void ImportGFD() |
---|
.. | .. |
---|
4665 | 4730 | |
---|
4666 | 4731 | if (readobj != null) |
---|
4667 | 4732 | { |
---|
4668 | | - if (Globals.SAVEONMAKE) |
---|
4669 | | - Save(); |
---|
| 4733 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4734 | + // Save(); |
---|
4670 | 4735 | try |
---|
4671 | 4736 | { |
---|
4672 | 4737 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
5035 | 5100 | CheckboxMenuItem toggleSwitchItem; |
---|
5036 | 5101 | CheckboxMenuItem toggleRootItem; |
---|
5037 | 5102 | CheckboxMenuItem animationItem; |
---|
5038 | | - CheckboxMenuItem archiveItem; |
---|
| 5103 | + MenuItem archiveItem; |
---|
5039 | 5104 | CheckboxMenuItem toggleHandleItem; |
---|
5040 | 5105 | CheckboxMenuItem togglePaintItem; |
---|
5041 | 5106 | JSplitPane mainPanel; |
---|