Globals.java
.. .. @@ -12,7 +12,7 @@ 12 12 public static boolean COMPUTESHADOWWHENLIVE = true; 13 13 public static boolean RENDERSHADOW = true; 14 14 15 - public static boolean REPLACEONMAKE = true; // problems when auto-save (works with manual save)15 + public static boolean REPLACEONMAKE = false;16 16 17 17 public static boolean MOUSEDRAGGED = false; 18 18 public static boolean TIMERRUNNING = false; Grafreed.java
.. .. @@ -58,7 +58,7 @@ 58 58 universe.material = new cMaterial(); 59 59 //god.addChild(universe); 60 60 universe.name = "Applet"; 61 - grafreeD = this;61 + grafreed = this;62 62 } 63 63 64 64 /**/ .. .. @@ -849,19 +849,59 @@ 849 849 850 850 //Monitor mon=MonitorFactory.start("myFirstMonitor"); 851 851 standAlone = true; 852 - grafreeD = new Grafreed();853 - grafreeD.universe = new cGroup();854 - grafreeD.universe.name = "Grafreed";855 - grafreeD.universe.material = new cMaterial();852 + grafreed = new Grafreed();853 + grafreed.materials = ReadGFD(grafreed.getClass().getClassLoader().getResourceAsStream("gfd/materials.gfd"));854 +855 + grafreed.universe = new cGroup();856 + grafreed.universe.name = "Grafreed";857 + grafreed.universe.material = new cMaterial();856 858 // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE; 857 859 858 - grafreeD.universe.root = true;859 - grafreeD.universe.openEditWindow(null, true); //, true);860 + grafreed.universe.root = true;861 + grafreed.universe.openEditWindow(null, true); //, true);860 862 //mon.stop(); 861 863 //System.out.println(mon); 862 864 //timeflow.app.TimeflowAppLauncher.GetTimeFlow(); 863 865 } 864 866 867 + static Object3D materials;868 +869 + static Object3D ReadGFD(java.io.InputStream istream)870 + {871 + Object3D readobj = null;872 +873 + try874 + {875 + // Try compressed version first.876 + java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream);877 + java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream);878 +879 + readobj = (Object3D) p.readObject();880 + istream.close();881 +882 + readobj.ResetDisplayList();883 + } catch (Exception e)884 + {885 + if (!e.toString().contains("GZIP"))886 + e.printStackTrace();887 +888 + try889 + {890 + java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream);891 +892 + readobj = (Object3D) p.readObject();893 + istream.close();894 +895 + readobj.ResetDisplayList();896 + } catch (Exception e2)897 + {898 + e2.printStackTrace();899 + }900 + }901 +902 + return readobj;903 + }904 +865 905 // Timer callback 866 906 public void actionPerformed(ActionEvent e) 867 907 { .. .. @@ -1085,7 +1125,7 @@ 1085 1125 } while (avail > 0 && numRead >= 0); 1086 1126 return new String(data, 0, pos, "US-ASCII"); 1087 1127 } 1088 - public static Grafreed grafreeD;1128 + public static Grafreed grafreed;1089 1129 public static boolean standAlone = true; 1090 1130 public Composite universe; 1091 1131 public static Object3D clipboard = new Object3D(); GroupEditor.java
.. .. @@ -931,14 +931,18 @@ 931 931 restoreCameraButton.setToolTipText("Restore viewpoint"); 932 932 restoreCameraButton.addActionListener(this); 933 933 934 - copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);935 - saveButton.setToolTipText("Duplicate current version");936 - saveButton.addActionListener(this);934 + copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);935 + saveVersionButton.setToolTipText("Duplicate current version");936 + saveVersionButton.addActionListener(this);937 937 938 - copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);939 - undoButton.setToolTipText("Previous version");940 - undoButton.addActionListener(this);941 - undoButton.setEnabled(false);938 + copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);939 + deleteVersionButton.setToolTipText("Delete current version");940 + deleteVersionButton.addActionListener(this);941 +942 + copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);943 + previousVersionButton.setToolTipText("Previous version");944 + previousVersionButton.addActionListener(this);945 + previousVersionButton.setEnabled(false);942 946 943 947 cGridBag updown = new cGridBag().setVertical(true); 944 948 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); .. .. @@ -953,10 +957,10 @@ 953 957 954 958 copyOptionsPanel.add(updown); 955 959 956 - copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);957 - redoButton.setToolTipText("Next version");958 - redoButton.addActionListener(this);959 - redoButton.setEnabled(false);960 + copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);961 + nextVersionButton.setToolTipText("Next version");962 + nextVersionButton.addActionListener(this);963 + nextVersionButton.setEnabled(false);960 964 961 965 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); 962 966 liveCB.setToolTipText("Enable animation"); .. .. @@ -2571,7 +2575,7 @@ 2571 2575 if (source == invariantsItem) 2572 2576 { 2573 2577 System.out.println("Invariants:"); 2574 - Grafreed.grafreeD.universe.invariants();2578 + Grafreed.grafreed.universe.invariants();2575 2579 } else 2576 2580 if (source == memoryItem) 2577 2581 { .. .. @@ -2602,12 +2606,12 @@ 2602 2606 { 2603 2607 ToggleFullScreen(); 2604 2608 } else 2605 - if (source == undoButton)2609 + if (source == previousVersionButton)2606 2610 { 2607 2611 // Go to previous version 2608 2612 //if (!Undo()) 2609 2613 //java.awt.Toolkit.getDefaultToolkit().beep(); 2610 - Undo();2614 + PreviousVersion();2611 2615 } else 2612 2616 if (source == restoreButton) 2613 2617 { .. .. @@ -2621,16 +2625,21 @@ 2621 2625 Replace(); 2622 2626 replaceButton.setEnabled(false); 2623 2627 } else 2624 - if (source == redoButton)2628 + if (source == nextVersionButton)2625 2629 { 2626 2630 // Go to next version 2627 - Redo();2631 + NextVersion();2628 2632 } else 2629 - if (source == saveButton)2633 + if (source == saveVersionButton)2630 2634 { 2631 2635 // Save a new version 2632 2636 if (!Save(true)) 2633 2637 java.awt.Toolkit.getDefaultToolkit().beep(); 2638 + } else2639 + if (source == deleteVersionButton)2640 + {2641 + // Delete a new version2642 + DeleteVersion();2634 2643 } else 2635 2644 if (source == oneStepButton) 2636 2645 { .. .. @@ -2685,11 +2694,11 @@ 2685 2694 } else 2686 2695 if (source == undoItem) 2687 2696 { 2688 - Undo();2697 + PreviousVersion();2689 2698 } else 2690 2699 if (source == redoItem) 2691 2700 { 2692 - Redo();2701 + NextVersion();2693 2702 } else 2694 2703 if (source == duplicateItem) 2695 2704 { .. .. @@ -6004,7 +6013,6 @@ 6004 6013 6005 6014 cButton restoreCameraButton; 6006 6015 6007 - cButton saveButton;6008 6016 cButton oneStepButton; 6009 6017 6010 6018 cButton groupButton; ObjEditor.java
.. .. @@ -848,6 +848,8 @@ 848 848 //frame.setVisible(true); 849 849 } 850 850 frame.validate(); 851 +852 + cameraView.requestFocusInWindow();851 853 } 852 854 853 855 private Object3D CompressCopy() .. .. @@ -1738,20 +1740,52 @@ 1738 1740 void SetupMaterial(cGridBag materialpanel) 1739 1741 { 1740 1742 cGridBag presetpanel = new cGridBag().setVertical(true); 1741 - cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);1742 - label.addMouseListener(new MouseAdapter()1743 + cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);1744 + skin.addMouseListener(new MouseAdapter()1743 1745 { 1744 1746 public void mouseClicked(MouseEvent e) 1745 1747 { 1746 - colorField.setFloat(0);1747 - saturationField.setFloat(1);1748 + Object3D object = Grafreed.materials.versionlist[0].get(0);1749 + cMaterial material = object.material;1750 +1751 + // Skin1752 + colorField.setFloat(material.color);1753 + saturationField.setFloat(material.modulation);1754 + subsurfaceField.setFloat(material.subsurface);1755 + selfshadowField.setFloat(material.diffuseness);1756 + diffusenessField.setFloat(material.factor);1757 + shininessField.setFloat(material.shininess);1758 + shadowbiasField.setFloat(material.shadowbias);1759 + diffuseField.setFloat(material.diffuse);1760 + specularField.setFloat(material.specular);1761 +1762 + bumpField.setFloat(object.projectedVertices[0].x / 1000.0);1763 + noiseField.setFloat(object.projectedVertices[0].y / 1000.0);1764 + powerField.setFloat(object.projectedVertices[2].x / 1000.0);1765 +1748 1766 materialtouched = true; 1749 1767 applySelf(); 1750 1768 } 1751 1769 }); 1752 - presetpanel.add(label);1770 + presetpanel.add(skin);1753 1771 1754 - presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF));1772 + cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);1773 + rough2.addMouseListener(new MouseAdapter()1774 + {1775 + public void mouseClicked(MouseEvent e)1776 + {1777 + Object3D object = Grafreed.materials.versionlist[1].get(0);1778 + cMaterial material = object.material;1779 +1780 + shininessField.setFloat(material.shininess);1781 + velvetField.setFloat(material.velvet);1782 +1783 + materialtouched = true;1784 + applySelf();1785 + }1786 + });1787 + presetpanel.add(rough2);1788 +1755 1789 presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF)); 1756 1790 presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF)); 1757 1791 presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF)); .. .. @@ -1768,9 +1802,6 @@ 1768 1802 presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF)); 1769 1803 presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF)); 1770 1804 presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF)); 1771 - presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF));1772 - presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF));1773 - presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF));1774 1805 1775 1806 cGridBag panel = new cGridBag().setVertical(true); 1776 1807 .. .. @@ -1821,9 +1852,9 @@ 1821 1852 1822 1853 cGridBag huepanel = new cGridBag(); 1823 1854 cGridBag huelabel = new cGridBag(); 1824 - label = GetLabel("icons/hue.png", false);1825 - label.fit = true;1826 - huelabel.add(label);1855 + skin = GetLabel("icons/hue.png", false);1856 + skin.fit = true;1857 + huelabel.add(skin);1827 1858 huelabel.preferredWidth = 20; 1828 1859 huepanel.add(new cGridBag()); // Label 1829 1860 huepanel.add(huelabel); // Field/slider .. .. @@ -3737,14 +3768,26 @@ 3737 3768 3738 3769 java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); 3739 3770 3771 + void DeleteVersion()3772 + {3773 + for (int i = copy.versionindex; i < copy.versionlist.length-1; i++)3774 + {3775 + copy.versionlist[i] = copy.versionlist[i+1];3776 + }3777 +3778 + CopyChanged();3779 +3780 + SetUndoStates();3781 + }3782 +3740 3783 public boolean Save(boolean user) 3741 3784 { 3742 3785 System.err.println("Save"); 3743 - Replace();3786 + //Replace();3744 3787 3745 3788 cRadio tab = GetCurrentTab(); 3746 3789 3747 - Object3D compress = CompressCopy(); // Saved version. No need for "Replace".3790 + Object3D compress = CompressCopy(); // Saved version. No need for "Replace"?3748 3791 3749 3792 boolean thesame = false; 3750 3793 .. .. @@ -3756,6 +3799,11 @@ 3756 3799 //EditorFrame.m_MainFrame.requestFocusInWindow(); 3757 3800 if (!thesame) 3758 3801 { 3802 + for (int i = copy.versionlist.length; --i > copy.versionindex+1;)3803 + {3804 + copy.versionlist[i] = copy.versionlist[i-1];3805 + }3806 +3759 3807 //tab.user[tab.versionindex] = user; 3760 3808 //boolean increment = true; // tab.graphs[tab.versionindex] == null; 3761 3809 .. .. @@ -3769,11 +3817,11 @@ 3769 3817 3770 3818 //assert(hashtable.isEmpty()); 3771 3819 3772 - for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)3773 - {3774 - //tab.user[i] = false;3775 - copy.versionlist[i] = null;3776 - }3820 +// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++)3821 +// {3822 +// //tab.user[i] = false;3823 +// copy.versionlist[i] = null;3824 +// }3777 3825 3778 3826 SetUndoStates(); 3779 3827 .. .. @@ -3828,11 +3876,13 @@ 3828 3876 GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath()); 3829 3877 flashIt = true; 3830 3878 3831 - refreshContents(false);3879 + //refreshContents(false);3832 3880 } 3833 3881 3834 - void CopyChanged(Object3D obj)3882 + void CopyChanged()3835 3883 { 3884 + Object3D obj = copy.versionlist[copy.versionindex];3885 +3836 3886 SetUndoStates(); 3837 3887 3838 3888 boolean temp = CameraPane.SWITCH; .. .. @@ -3875,13 +3925,15 @@ 3875 3925 } 3876 3926 } 3877 3927 3878 - refreshContents();3928 + refreshContents(true);3879 3929 } 3880 3930 3881 - cButton undoButton;3931 + cButton previousVersionButton;3882 3932 cButton restoreButton; 3883 3933 cButton replaceButton; 3884 - cButton redoButton;3934 + cButton nextVersionButton;3935 + cButton saveVersionButton;3936 + cButton deleteVersionButton;3885 3937 3886 3938 boolean muteSlider; 3887 3939 .. .. @@ -3902,11 +3954,14 @@ 3902 3954 { 3903 3955 cRadio tab = GetCurrentTab(); 3904 3956 3905 - restoreButton.setEnabled(copy.versionindex != -1);3906 - replaceButton.setEnabled(copy.versionindex != -1);3957 + restoreButton.setEnabled(true); // copy.versionindex != -1);3958 + replaceButton.setEnabled(true); // copy.versionindex != -1);3907 3959 3908 - undoButton.setEnabled(copy.versionindex > 0);3909 - redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);3960 + previousVersionButton.setEnabled(copy.versionindex > 0);3961 + nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);3962 +3963 + deleteVersionButton.setEnabled(//copy.versionindex > 0 &&3964 + copy.versionlist[copy.versionindex + 1] != null);3910 3965 3911 3966 muteSlider = true; 3912 3967 versionSlider.setMaximum(VersionCount() - 1); .. .. @@ -3914,7 +3969,7 @@ 3914 3969 muteSlider = false; 3915 3970 } 3916 3971 3917 - public boolean Undo()3972 + public boolean PreviousVersion()3918 3973 { 3919 3974 // Option? 3920 3975 Replace(); .. .. @@ -3944,7 +3999,7 @@ 3944 3999 3945 4000 copy.versionindex -= 1; 3946 4001 3947 - CopyChanged((Object3D)copy.versionlist[copy.versionindex]);4002 + CopyChanged();3948 4003 3949 4004 return true; 3950 4005 } .. .. @@ -3962,7 +4017,7 @@ 3962 4017 } 3963 4018 3964 4019 //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); 3965 - CopyChanged(copy.versionlist[copy.versionindex]);4020 + CopyChanged();3966 4021 3967 4022 return true; 3968 4023 } .. .. @@ -3984,7 +4039,7 @@ 3984 4039 return true; 3985 4040 } 3986 4041 3987 - public void Redo()4042 + public void NextVersion()3988 4043 { 3989 4044 // Option? 3990 4045 Replace(); .. .. @@ -3999,7 +4054,7 @@ 3999 4054 4000 4055 copy.versionindex += 1; 4001 4056 4002 - CopyChanged(copy.versionlist[copy.versionindex]);4057 + CopyChanged();4003 4058 4004 4059 //if (!tab.user[tab.versionindex]) 4005 4060 // tab.graphs[tab.versionindex] = null; .. .. @@ -4312,7 +4367,8 @@ 4312 4367 4313 4368 if (copy.versionlist[version] != null) 4314 4369 { 4315 - CopyChanged(copy.versionlist[copy.versionindex = version]);4370 + copy.versionindex = version;4371 + CopyChanged();4316 4372 } 4317 4373 4318 4374 return; .. .. @@ -4666,6 +4722,9 @@ 4666 4722 ctrlPanel.validate(); // ? new 4667 4723 ctrlPanel.repaint(); 4668 4724 } 4725 +4726 + if (previousVersionButton != null && copy.versionlist != null)4727 + SetUndoStates();4669 4728 } 4670 4729 4671 4730 static TweenManager tweenManager = new TweenManager(); .. .. @@ -5070,7 +5129,7 @@ 5070 5129 { 5071 5130 if (Grafreed.standAlone) 5072 5131 { 5073 - FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD);5132 + FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD);5074 5133 browser.show(); 5075 5134 String filename = browser.getFile(); 5076 5135 if (filename != null && filename.length() > 0) gfd/materials.gfdBinary files differ
icons/shadericons/shadericon00000.jpgBinary files differ
icons/shadericons/shadericon00000.pngBinary files differ
icons/shadericons/shadericon00001.jpgBinary files differ
icons/shadericons/shadericon00001.pngBinary files differ
icons/shadericons/shadericon00002.jpgBinary files differ
icons/shadericons/shadericon00002.pngBinary files differ
icons/shadericons/shadericon00003.jpgBinary files differ
icons/shadericons/shadericon00003.pngBinary files differ
icons/shadericons/shadericon00004.jpgBinary files differ
icons/shadericons/shadericon00004.pngBinary files differ
icons/shadericons/shadericon00005.jpgBinary files differ
icons/shadericons/shadericon00005.pngBinary files differ
icons/shadericons/shadericon00006.jpgBinary files differ
icons/shadericons/shadericon00006.pngBinary files differ
icons/shadericons/shadericon00007.jpgBinary files differ
icons/shadericons/shadericon00007.pngBinary files differ
icons/shadericons/shadericon00008.jpgBinary files differ
icons/shadericons/shadericon00008.pngBinary files differ
icons/shadericons/shadericon00009.jpgBinary files differ
icons/shadericons/shadericon00009.pngBinary files differ
icons/shadericons/shadericon00010.jpgBinary files differ
icons/shadericons/shadericon00010.pngBinary files differ
icons/shadericons/shadericon00011.jpgBinary files differ
icons/shadericons/shadericon00011.pngBinary files differ
icons/shadericons/shadericon00012.jpgBinary files differ
icons/shadericons/shadericon00012.pngBinary files differ
icons/shadericons/shadericon00013.jpgBinary files differ
icons/shadericons/shadericon00013.pngBinary files differ
icons/shadericons/shadericon00014.jpgBinary files differ
icons/shadericons/shadericon00014.pngBinary files differ
icons/shadericons/shadericon00015.jpgBinary files differ
icons/shadericons/shadericon00015.pngBinary files differ
icons/shadericons/shadericon00016.jpgBinary files differ
icons/shadericons/shadericon00016.pngBinary files differ
icons/shadericons/shadericon00017.jpgBinary files differ
icons/shadericons/shadericon00017.pngBinary files differ
icons/shadericons/shadericon00018.jpgdeleted file mode 100644Binary files differ
icons/shadericons/shadericon00018.pngdeleted file mode 100644Binary files differ
icons/shadericons/shadericon00019.jpgdeleted file mode 100644Binary files differ
icons/shadericons/shadericon00019.pngdeleted file mode 100644Binary files differ
icons/shadericons/shadericon00020.jpgdeleted file mode 100644Binary files differ
icons/shadericons/shadericon00020.pngdeleted file mode 100644Binary files differ
icons/shaderskin.gfdBinary files differ
icons/sphererender2.gfdBinary files differ
icons/sphererender3.gfdBinary files differ
icons/sphererender4.gfdBinary files differ
icons/sphererender5.gfdBinary files differ
icons/sphererender6.gfdBinary files differ
icons/trash.pngBinary files differ