From 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 25 Aug 2019 20:58:10 -0400
Subject: [PATCH] Proto version slider.

---
 ObjEditor.java |  433 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 308 insertions(+), 125 deletions(-)

diff --git a/ObjEditor.java b/ObjEditor.java
index 4b47343..fd5504d 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -72,6 +72,21 @@
         }
     }
 
+    public Composite CreateCameras()
+    {
+        Composite cams = new cTemplate();
+        cams.name = "Cameras";
+        copy.insertElementAt(cams, 0);
+
+        cams.addChild(new Camera());
+        cams.addChild(new Camera(1));
+        cams.addChild(new Camera(2));
+        cams.addChild(new Camera(3));
+        cams.addChild(new Camera(4));
+        
+        return cams;
+    }
+
     public cGridBag GetSeparator()
     {
         cGridBag separator = new cGridBag();
@@ -83,7 +98,7 @@
     cButton GetButton(String name, boolean border)
     {
         ImageIcon icon = GetIcon(name);
-        if (icon != null)
+        if (icon != null || name.contains("/"))
             return new cButton(icon, border);
         else
             return new cButton(name, border);
@@ -119,8 +134,14 @@
         
         try
         {
-            BufferedImage image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
-
+            BufferedImage image;
+            
+            if (name.endsWith("jpg"))
+                // Much faster!
+                image = new sun.awt.image.codec.JPEGImageDecoderImpl(ObjEditor.class.getClassLoader().getResourceAsStream(name)).decodeAsBufferedImage();
+            else
+                image = javax.imageio.ImageIO.read(ObjEditor.class.getClassLoader().getResourceAsStream(name));
+  
 //            if (image.getWidth() > 48 && image.getHeight() > 48)
 //            {
 //                BufferedImage resized = new BufferedImage(48, 48, image.getType());
@@ -295,6 +316,8 @@
         objEditor.ctrlPanel.remove(setupPanel2);
         objEditor.ctrlPanel.remove(objectCommandsPanel);
         objEditor.ctrlPanel.remove(pushPanel);
+        if (versionPanel != null)
+            objEditor.ctrlPanel.remove(versionPanel);
         //objEditor.ctrlPanel.remove(fillPanel);
         
         //Remove(normalpushField);
@@ -362,14 +385,6 @@
         client = inClient;
         copy = client;
 
-        if (copy.versionlist == null)
-        {
-            copy.versionlist = new Object3D[100];
-            copy.versionindex = -1;
-            
-//            Save(true);
-        }
-        
         SetupUI2(callee.GetEditor());
     }
 
@@ -445,8 +460,11 @@
 		importOBJItem.addActionListener(this);
 		import3DSItem = menu.add(new MenuItem("3DS file..."));
 		import3DSItem.addActionListener(this);
+                if (Globals.ADVANCED)
+                {
 		importVRMLX3DItem = menu.add(new MenuItem("VRML/X3D file..."));
 		importVRMLX3DItem.addActionListener(this);
+                }
 		menu.add("-");
 		importGFDItem = menu.add(new MenuItem("Grafreed file..."));
 		importGFDItem.addActionListener(this);
@@ -1147,6 +1165,7 @@
     cGridBag setupPanel2;
     cGridBag objectCommandsPanel;
     cGridBag pushPanel;
+    cGridBag versionPanel;
     cGridBag fillPanel;
 
     JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
@@ -1318,7 +1337,7 @@
             
         //if (copy.pinned)
         {
-            pinButton = GetToggleButton("icons/pin.png", !Grafreed.NIMBUSLAF);
+            pinButton = GetToggleButton("icons/pin.png", !Globals.NIMBUSLAF);
             pinButton.setSelected(copy.pinned);
             cGridBag t = new cGridBag();
             t.preferredWidth = 2;
@@ -1393,9 +1412,14 @@
         oe.ctrlPanel.add(objectCommandsPanel);
         oe.ctrlPanel.Return();
 
-    pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
+    pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH * 100, 1.1); // To have the buttons
     normalpushField = (cNumberSlider)pushPanel.getComponent(1);
-    //Return();
+    if (false && copy.versionlist != null && copy.versionindex != -1)
+    {
+        oe.ctrlPanel.Return();
+        versionPanel = AddSlider(oe.ctrlPanel, "Version", 0, copy.VersionCount() - 1, copy.versionindex);
+        versionField = (cNumberSlider)versionPanel.getComponent(1);
+    }
 
         oe.ctrlPanel.Return();
             
@@ -1550,23 +1574,9 @@
 
         if (cam == null || !(copy.get(0) instanceof cGroup))
         {
-        if (Globals.DEBUG)
-            System.out.println("CREATE CAMERAS");
-            cams = new cTemplate();
-            cams.name = "Cameras";
-            copy.insertElementAt(cams, 0);
-            //cams.parent = copy;
-
-            cam = new Camera(); // LA.newVector(3, 2, 1));
-            cams.addChild(cam);
-            cam = new Camera(1);
-            cams.addChild(cam);
-            cam = new Camera(2);
-            cams.addChild(cam);
-            cam = new Camera(3);
-            cams.addChild(cam);
-            cam = new Camera(4); // Light
-            cams.addChild(cam);
+            if (Globals.DEBUG)
+                System.out.println("CREATE CAMERAS");
+            cams = CreateCameras();
         } else
         {
             cams = (cGroup) copy.get(0);
@@ -1638,7 +1648,8 @@
         
         resetTransformPanel.preferredHeight = 2;
         
-        cButton resetTransform = GetButton("Reset all", !Grafreed.NIMBUSLAF);
+        cButton resetTransform = GetButton("Reset all", !Globals.NIMBUSLAF);
+        resetTransform.setToolTipText("Reset Translation, Rotation and Scale");
         resetTransform.addMouseListener(new MouseAdapter()
         {
             public void mouseClicked(MouseEvent e)
@@ -1648,7 +1659,8 @@
         });
         resetTransformPanel.add(resetTransform);
         
-        resetTransform = GetButton("T only", !Grafreed.NIMBUSLAF);
+        resetTransform = GetButton("T only", !Globals.NIMBUSLAF);
+        resetTransform.setToolTipText("Reset Translation only");
         resetTransform.addMouseListener(new MouseAdapter()
         {
             public void mouseClicked(MouseEvent e)
@@ -1658,7 +1670,8 @@
         });
         resetTransformPanel.add(resetTransform);
         
-        resetTransform = GetButton("RS only", !Grafreed.NIMBUSLAF);
+        resetTransform = GetButton("RS only", !Globals.NIMBUSLAF);
+        resetTransform.setToolTipText("Reset Rotation and Scale only");
         resetTransform.addMouseListener(new MouseAdapter()
         {
             public void mouseClicked(MouseEvent e)
@@ -1715,24 +1728,24 @@
 
         //JScrollPane tmp = new JScrollPane(ctrlPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
         //tmp.setName("Edit");
+        objectPanel.add(skyboxPanel);
+        objectPanel.setIconAt(0, GetIcon("icons/skybox.jpg"));
+        objectPanel.setToolTipTextAt(0, "Backgrounds");
+        
         objectPanel.add(toolboxPanel);
-        objectPanel.setIconAt(0, GetIcon("icons/primitives.png"));
-        objectPanel.setToolTipTextAt(0, "Objects & textures");
+        objectPanel.setIconAt(1, GetIcon("icons/primitives.png"));
+        objectPanel.setToolTipTextAt(1, "Objects & textures");
 
         objectPanel.add(materialPanel);
-        objectPanel.setIconAt(1, GetIcon("icons/material.png"));
-        objectPanel.setToolTipTextAt(1, "Material");
+        objectPanel.setIconAt(2, GetIcon("icons/material.png"));
+        objectPanel.setToolTipTextAt(2, "Material");
     
-        objectPanel.add(skyboxPanel);
-        objectPanel.setIconAt(2, GetIcon("icons/skybox.jpg"));
-        objectPanel.setToolTipTextAt(2, "Backgrounds");
-        
 //        JPanel north = new JPanel(new BorderLayout());
 //        north.setName("Edit");
 //        north.add(ctrlPanel, BorderLayout.NORTH);
 //        objectPanel.add(north);
         objectPanel.add(editPanel);
-        objectPanel.setIconAt(3, GetIcon("icons/write.png"));
+        objectPanel.setIconAt(3, GetIcon("icons/writewhite.png"));
         objectPanel.setToolTipTextAt(3, "Edit controls");
         
         objectPanel.add(transformPanel);
@@ -1741,7 +1754,7 @@
         
         patchMaterial = true;
         cameraView.patchMaterial = this;
-        objectPanel.setSelectedIndex(1);
+        objectPanel.setSelectedIndex(2);
                 
         /*
         aConstraints.gridx = 0;
@@ -1762,7 +1775,7 @@
         scrollpane.addMouseWheelListener(this); // Default not fast enough
 
         /*JTabbedPane*/ scenePanel = new cGridBag();
-        scenePanel.preferredWidth = 6;
+        scenePanel.preferredWidth = 5;
         
         JTabbedPane tabbedPane = new JTabbedPane();
         tabbedPane.add(scrollpane);
@@ -1773,17 +1786,109 @@
         
         AddOptions(optionsPanel); //, aConstraints);
         
-        tabbedPane.add(optionsPanel);
-        
         tabbedPane.add(FSPane = new cFileSystemPane(this));
 
+        tabbedPane.add(optionsPanel);
+        
         scenePanel.add(tabbedPane);
 
-        //if (Globals.ADVANCED)
-//            tabbedPane.add(infoPanel);
-//        tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
-//        tabbedPane.setToolTipTextAt(3, "Information");
+        cGridBag creditsPanel = new cGridBag().setVertical(true);
+        creditsPanel.setName("Credits");
         
+        cLabel ogaLabel = new cLabel(" Skyboxes courtesy of OpenGameArt!", !Globals.NIMBUSLAF);
+	creditsPanel.add(ogaLabel);
+        
+        cButton creditButton;
+	creditsPanel.add(creditButton = GetButton("icons/sara-logo.png", !Globals.NIMBUSLAF));
+        creditButton.setToolTipText("https://opengameart.org");
+        
+        creditButton.addMouseListener(new MouseAdapter()
+        {
+            public void mouseClicked(MouseEvent e)
+            {
+                try
+                {
+                    Desktop.getDesktop().browse(new java.net.URI("https://opengameart.org/"));
+                } catch (Exception e1)
+//                } catch (java.io.IOException | java.net.URISyntaxException e1)
+                {
+                    e1.printStackTrace();
+                }
+            }
+        });
+        
+        ogaLabel = new cLabel(" Download 3D models! (.3ds and .obj only)", !Globals.NIMBUSLAF);
+	creditsPanel.add(ogaLabel);
+        
+	creditsPanel.add(creditButton = GetButton("icons/3delicious.png", !Globals.NIMBUSLAF));
+        creditButton.setToolTipText("https://3delicious.net");
+        
+        creditButton.addMouseListener(new MouseAdapter()
+        {
+            public void mouseClicked(MouseEvent e)
+            {
+                try
+                {
+                    Desktop.getDesktop().browse(new java.net.URI("https://3delicious.net"));
+                } catch (Exception e1)
+//                } catch (java.io.IOException | java.net.URISyntaxException e1)
+                {
+                    e1.printStackTrace();
+                }
+            }
+        });
+        
+	creditsPanel.add(creditButton = GetButton("icons/archive3d.png", !Globals.NIMBUSLAF));
+        creditButton.setToolTipText("https://archive3d.net");
+        
+        creditButton.addMouseListener(new MouseAdapter()
+        {
+            public void mouseClicked(MouseEvent e)
+            {
+                try
+                {
+                    Desktop.getDesktop().browse(new java.net.URI("https://archive3d.net"));
+                } catch (Exception e1)
+//                } catch (java.io.IOException | java.net.URISyntaxException e1)
+                {
+                    e1.printStackTrace();
+                }
+            }
+        });
+        
+	creditsPanel.add(creditButton = GetButton("icons/turbosquid.png", !Globals.NIMBUSLAF));
+        creditButton.setToolTipText("https://turbosquid.com");
+        
+        creditButton.addMouseListener(new MouseAdapter()
+        {
+            public void mouseClicked(MouseEvent e)
+            {
+                try
+                {
+                    Desktop.getDesktop().browse(new java.net.URI("https://www.turbosquid.com/Search/3D-Models/free"));
+                } catch (Exception e1)
+//                } catch (java.io.IOException | java.net.URISyntaxException e1)
+                {
+                    e1.printStackTrace();
+                }
+            }
+        });
+        
+        for (int i=6; --i>=0;)
+        {
+            creditsPanel.add(new cGridBag());
+        }
+        
+        tabbedPane.add(creditsPanel);
+        tabbedPane.setToolTipTextAt(3, "Credits");
+        
+        if (Globals.ADVANCED)
+        {
+            objectPanel.add(infoPanel);
+            objectPanel.setIconAt(5, GetIcon("icons/info.png"));
+            objectPanel.setToolTipTextAt(4, "Information");
+        }
+
         /*
         cTree jTree = new cTree(null);
         ToolTipManager.sharedInstance().registerComponent(jTree);
@@ -1929,7 +2034,7 @@
     {
         cGridBag presetpanel = new cGridBag().setVertical(true);
         
-        cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF);
+        cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Globals.NIMBUSLAF);
         skin.setToolTipText("Skin");
         skin.addMouseListener(new MouseAdapter()
         {
@@ -1967,7 +2072,7 @@
         });
         presetpanel.add(skin);
         
-        cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF);
+        cLabel lambert = GetLabel("icons/shadericons/shadericon00002.png", !Globals.NIMBUSLAF);
         lambert.setToolTipText("Diffuse");
         lambert.addMouseListener(new MouseAdapter()
         {
@@ -1985,7 +2090,7 @@
         });
         presetpanel.add(lambert);
         
-        cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF);
+        cLabel diffuse2 = GetLabel("icons/shadericons/shadericon00003.png", !Globals.NIMBUSLAF);
         diffuse2.setToolTipText("Diffuse2");
         diffuse2.addMouseListener(new MouseAdapter()
         {
@@ -2003,7 +2108,7 @@
         });
         presetpanel.add(diffuse2);
         
-        cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF);
+        cLabel diffusemoon = GetLabel("icons/shadericons/shadericon00004.png", !Globals.NIMBUSLAF);
         diffusemoon.setToolTipText("Moon");
         diffusemoon.addMouseListener(new MouseAdapter()
         {
@@ -2021,7 +2126,7 @@
         });
         presetpanel.add(diffusemoon);
         
-        cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Grafreed.NIMBUSLAF);
+        cLabel diffusemoon2 = GetLabel("icons/shadericons/shadericon00005.png", !Globals.NIMBUSLAF);
         diffusemoon2.setToolTipText("Moon2");
         diffusemoon2.addMouseListener(new MouseAdapter()
         {
@@ -2039,7 +2144,7 @@
         });
         presetpanel.add(diffusemoon2);
         
-        cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Grafreed.NIMBUSLAF);
+        cLabel diffusemoon3 = GetLabel("icons/shadericons/shadericon00006.png", !Globals.NIMBUSLAF);
         diffusemoon3.setToolTipText("Moon3");
         diffusemoon3.addMouseListener(new MouseAdapter()
         {
@@ -2057,7 +2162,7 @@
         });
         presetpanel.add(diffusemoon3);
         
-        cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Grafreed.NIMBUSLAF);
+        cLabel diffusesheen = GetLabel("icons/shadericons/shadericon00007.png", !Globals.NIMBUSLAF);
         diffusesheen.setToolTipText("Sheen");
         diffusesheen.addMouseListener(new MouseAdapter()
         {
@@ -2074,7 +2179,7 @@
         });
         presetpanel.add(diffusesheen);
         
-        cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF);
+        cLabel rough = GetLabel("icons/shadericons/shadericon00001.png", !Globals.NIMBUSLAF);
         rough.setToolTipText("Rough metal");
         rough.addMouseListener(new MouseAdapter()
         {
@@ -2092,7 +2197,7 @@
         });
         presetpanel.add(rough);
         
-        cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Grafreed.NIMBUSLAF);
+        cLabel rough2 = GetLabel("icons/shadericons/shadericon00013.png", !Globals.NIMBUSLAF);
         rough2.setToolTipText("Medium metal");
         rough2.addMouseListener(new MouseAdapter()
         {
@@ -2110,7 +2215,7 @@
         });
         presetpanel.add(rough2);
         
-        cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Grafreed.NIMBUSLAF);
+        cLabel shini0 = GetLabel("icons/shadericons/shadericon00014.png", !Globals.NIMBUSLAF);
         shini0.setToolTipText("Shiny");
         shini0.addMouseListener(new MouseAdapter()
         {
@@ -2128,7 +2233,7 @@
         });
         presetpanel.add(shini0);
         
-        cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Grafreed.NIMBUSLAF);
+        cLabel shini1 = GetLabel("icons/shadericons/shadericon00011.png", !Globals.NIMBUSLAF);
         shini1.setToolTipText("Shiny2");
         shini1.addMouseListener(new MouseAdapter()
         {
@@ -2146,7 +2251,7 @@
         });
         presetpanel.add(shini1);
         
-        cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Grafreed.NIMBUSLAF);
+        cLabel shini2 = GetLabel("icons/shadericons/shadericon00012.png", !Globals.NIMBUSLAF);
         shini2.setToolTipText("Shiny3");
         shini2.addMouseListener(new MouseAdapter()
         {
@@ -2164,7 +2269,7 @@
         });
         presetpanel.add(shini2);
         
-        cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Grafreed.NIMBUSLAF);
+        cLabel aniso = GetLabel("icons/shadericons/shadericon00008.png", !Globals.NIMBUSLAF);
         aniso.setToolTipText("AnisoU");
         aniso.addMouseListener(new MouseAdapter()
         {
@@ -2182,7 +2287,7 @@
         });
         presetpanel.add(aniso);
         
-        cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Grafreed.NIMBUSLAF);
+        cLabel aniso2 = GetLabel("icons/shadericons/shadericon00009.png", !Globals.NIMBUSLAF);
         aniso2.setToolTipText("AnisoV");
         aniso2.addMouseListener(new MouseAdapter()
         {
@@ -2200,7 +2305,7 @@
         });
         presetpanel.add(aniso2);
         
-        cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Grafreed.NIMBUSLAF);
+        cLabel aniso3 = GetLabel("icons/shadericons/shadericon00010.png", !Globals.NIMBUSLAF);
         aniso3.setToolTipText("AnisoUV");
         aniso3.addMouseListener(new MouseAdapter()
         {
@@ -2218,7 +2323,7 @@
         });
         presetpanel.add(aniso3);
         
-        cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF);
+        cLabel velvet0 = GetLabel("icons/shadericons/shadericon00015.png", !Globals.NIMBUSLAF);
         velvet0.setToolTipText("Velvet");
         velvet0.addMouseListener(new MouseAdapter()
         {
@@ -2240,7 +2345,7 @@
         });
         presetpanel.add(velvet0);
         
-        cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF);
+        cLabel bump0 = GetLabel("icons/shadericons/shadericon00016.png", !Globals.NIMBUSLAF);
         bump0.setToolTipText("Bump texture");
         bump0.addMouseListener(new MouseAdapter()
         {
@@ -2259,13 +2364,13 @@
         });
         presetpanel.add(bump0);
         
-        cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Grafreed.NIMBUSLAF);
+        cLabel borderShader = GetLabel("icons/shadericons/borderfade.jpg", !Globals.NIMBUSLAF);
         borderShader.setToolTipText("Border fade");
         borderShader.addMouseListener(new MouseAdapter()
         {
             public void mouseClicked(MouseEvent e)
             {
-                borderfadeField.setFloat(0.5);
+                borderfadeField.setFloat(0.4);
                 opacityField.setFloat(0.75);
 
                 materialtouched = true;
@@ -2274,7 +2379,7 @@
         });
         presetpanel.add(borderShader);
         
-        cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF);
+        cLabel halo = GetLabel("icons/shadericons/shadericon00017.png", !Globals.NIMBUSLAF);
         halo.setToolTipText("Halo");
         halo.addMouseListener(new MouseAdapter()
         {
@@ -2291,7 +2396,7 @@
         });
         presetpanel.add(halo);
         
-        cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF);
+        cLabel candle = GetLabel("icons/shadericons/shadericon00018.png", !Globals.NIMBUSLAF);
         candle.setToolTipText("Candle");
         candle.addMouseListener(new MouseAdapter()
         {
@@ -2313,7 +2418,7 @@
         });
         presetpanel.add(candle);
         
-        cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Grafreed.NIMBUSLAF);
+        cLabel shadowShader = GetLabel("icons/shadericons/shadow.png", !Globals.NIMBUSLAF);
         shadowShader.setToolTipText("Shadow");
         shadowShader.addMouseListener(new MouseAdapter()
         {
@@ -2324,13 +2429,55 @@
                 cameraField.setFloat(0.001);
                 specularField.setFloat(0.001);
                 fakedepthField.setFloat(0.001);
-                opacityField.setFloat(0.6);
+                opacityField.setFloat(0.4);
 
                 materialtouched = true;
                 applySelf();
             }
         });
         presetpanel.add(shadowShader);
+        
+        cLabel para0 = GetLabel("icons/shadericons/parallax0.png", !Globals.NIMBUSLAF);
+        para0.setToolTipText("No parallax");
+        para0.addMouseListener(new MouseAdapter()
+        {
+            public void mouseClicked(MouseEvent e)
+            {
+                parallaxField.setFloat(0.125);
+
+                materialtouched = true;
+                applySelf();
+            }
+        });
+        presetpanel.add(para0);
+        
+        cLabel para1 = GetLabel("icons/shadericons/parallax1.png", !Globals.NIMBUSLAF);
+        para1.setToolTipText("With parallax");
+        para1.addMouseListener(new MouseAdapter()
+        {
+            public void mouseClicked(MouseEvent e)
+            {
+                parallaxField.setFloat(0.13);
+
+                materialtouched = true;
+                applySelf();
+            }
+        });
+        presetpanel.add(para1);
+        
+        cLabel para2 = GetLabel("icons/shadericons/parallax2.png", !Globals.NIMBUSLAF);
+        para2.setToolTipText("Reset parallax");
+        para2.addMouseListener(new MouseAdapter()
+        {
+            public void mouseClicked(MouseEvent e)
+            {
+                parallaxField.setFloat(0.14);
+
+                materialtouched = true;
+                applySelf();
+            }
+        });
+        presetpanel.add(para2);
         
         cGridBag panel = new cGridBag().setVertical(true);
         
@@ -2348,19 +2495,19 @@
 
         cGridBag editBar = new cGridBag().setVertical(false);
             
-        editBar.add(createMaterialButton = new cButton("Create", !Grafreed.NIMBUSLAF)); // , aConstraints);
+        editBar.add(createMaterialButton = new cButton("Create", !Globals.NIMBUSLAF)); // , aConstraints);
                 createMaterialButton.setToolTipText("Create material");
 
         /*
         ctrlPanel.add(resetSlidersButton = new cButton("Reset All"), aConstraints);
          */
 
-        editBar.add(clearMaterialButton = new cButton("Clear", !Grafreed.NIMBUSLAF)); // , aConstraints);
+        editBar.add(clearMaterialButton = new cButton("Clear", !Globals.NIMBUSLAF)); // , aConstraints);
                 clearMaterialButton.setToolTipText("Clear material");
         
         if (Globals.ADVANCED)
         {
-                editBar.add(resetSlidersButton = new cButton("Reset", !Grafreed.NIMBUSLAF)); // , aConstraints);
+                editBar.add(resetSlidersButton = new cButton("Reset", !Globals.NIMBUSLAF)); // , aConstraints);
                 editBar.add(propagateToggle = new cCheckBox("Prop", propagate)); // , aConstraints);
                 editBar.add(multiplyToggle = new cCheckBox("Mult", false)); // , aConstraints);
         }
@@ -2577,6 +2724,12 @@
                 backlit.add(backlitField = new cNumberSlider(this, 0.001, 50, -1)); // , aConstraints);
         colorSection.add(backlit);
 
+        cGridBag parallax = new cGridBag();
+                parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints);
+                parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING);
+                parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.25, -0.125)); // , aConstraints);
+        colorSection.add(parallax);
+        
         //panel.add(new JSeparator());
         
         //panel.add(globalSection);
@@ -3628,6 +3781,7 @@
         shadowField.setFloat(mat.shadow);
         textureField.setFloat(mat.texture);
         opacityField.setFloat(mat.opacity);
+        parallaxField.setFloat(mat.parallax + 0.125f);
         fakedepthField.setFloat(mat.fakedepth);
         shadowbiasField.setFloat(mat.shadowbias);
         bumpField.setInteger(1); // dec 2013
@@ -3921,6 +4075,7 @@
         } else if (event.getSource() == link2masterCB)
         {
             copy.link2master ^= true;
+            objEditor.refreshContents();
             return;
         }
         if (event.getSource() == randomCB)
@@ -4161,11 +4316,18 @@
 
     void New()
     {
-        while (copy.Size() > 1)
+        while (copy.Size() > 0)
         {
-            copy.remove(1);
+            copy.remove(0);
         }
         
+        copy.selection.clear();
+        
+        if (copy == Grafreed.grafreed.universe)
+        {
+            CreateCameras();
+            cameraView.SetCamera(GetCamera(copy, 0));
+        }
         ResetModel();
         objEditor.refreshContents();
     }
@@ -4304,7 +4466,7 @@
             copy.versionindex -= 1;
         
         if (copy.versionindex != -1)
-            CopyChanged();
+            CopyChanged(copy);
         
         SetVersionStates();
     }
@@ -4314,7 +4476,11 @@
         System.err.println("Save");
         Replace();
         
-        //cRadio tab = GetCurrentTab();
+        if (copy.versionlist == null)
+        {
+            copy.versionlist = new Object3D[100];
+            copy.versionindex = -1;
+        }
         
         Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
         
@@ -4382,20 +4548,20 @@
     {
         Object3D selection = new Object3D();
         
-        for (int i = 0; i < copy.selection.size(); i++)
+        for (int i = 0; i < objEditor.copy.selection.size(); i++)
         {
-            Object3D elem = copy.selection.elementAt(i);
+            Object3D elem = objEditor.copy.selection.elementAt(i);
             
-            Object3D obj = copy.GetObject(elem.GetUUID());
+            Object3D obj = objEditor.copy.GetObject(elem.GetUUID());
             
             if (obj == null)
             {
-                copy.selection.remove(i--);
+                objEditor.copy.selection.remove(i--);
             }
             else
             {
                 selection.add(obj);
-                copy.selection.setElementAt(obj, i);
+                objEditor.copy.selection.setElementAt(obj, i);
             }
         }
         
@@ -4408,44 +4574,43 @@
         //refreshContents(false);
     }
 
-    void CopyChanged()
+    void CopyChanged(Object3D changed)
     {
-        Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
-        
-        SetVersionStates();
+        Object3D obj = (Object3D)Grafreed.clone(changed.versionlist[copy.versionindex]);
         
         boolean temp = CameraPane.SWITCH;
         CameraPane.SWITCH = false;
         
-        copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
+        changed.ExtractBigData(Grafreed.grafreed.universe.versiontable);
         
-        copy.clear();
+        changed.clear();
         
-        copy.skyboxname = obj.skyboxname;
-        copy.skyboxext = obj.skyboxext;
+        changed.skyboxname = obj.skyboxname;
+        changed.skyboxext = obj.skyboxext;
                 
         for (int i=0; i<obj.Size(); i++)
         {
-            copy.add(obj.get(i));
+            changed.add(obj.get(i));
         }
         
-        copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
+        changed.RestoreBigData(Grafreed.grafreed.universe.versiontable);
         
         CameraPane.SWITCH = temp;
         
-        RefreshSelection();
+        if (objEditor == this)
+            RefreshSelection();
         //assert(hashtable.isEmpty());
         
-        copy.Touch();
+        objEditor.copy.Touch();
         
         ResetModel();
-        copy.HardTouch(); // recompile?
+        objEditor.copy.HardTouch(); // recompile?
         
         cRadio ab;
-        for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
+        for (java.util.Enumeration e = objEditor.buttonGroup.getElements(); e.hasMoreElements();)
         {
             ab = (cRadio)e.nextElement();
-            Object3D test = copy.GetObject(ab.object.GetUUID());
+            Object3D test = objEditor.copy.GetObject(ab.object.GetUUID());
             //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
             if (test != null)
             {
@@ -4454,7 +4619,7 @@
             }
         }
         
-        refreshContents(true);
+        objEditor.refreshContents(true);
     }
     
     cButton previousVersionButton;
@@ -4468,15 +4633,7 @@
     
     int VersionCount()
     {
-        int count = 0;
-        
-        for (int i = copy.versionlist.length; --i >= 0;)
-        {
-            if (copy.versionlist[i] != null)
-                count++;
-        }
-        
-        return count;
+        return copy.VersionCount();
     }
     
     public cGridBag versionSliderPane;
@@ -4488,7 +4645,7 @@
                     
         //cRadio tab = GetCurrentTab();
         
-        if (copy.versionlist == null)
+        if (copy.versionindex == -2)
         {
             saveVersionButton.setEnabled(false);
             restoreButton.setEnabled(false);
@@ -4550,7 +4707,9 @@
 
         copy.versionindex -= 1;
 
-        CopyChanged();
+        CopyChanged(copy);
+        
+        SetVersionStates();
         
         return true;
     }
@@ -4568,7 +4727,9 @@
         }
 
         //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
-        CopyChanged();
+        CopyChanged(copy);
+        
+        SetVersionStates();
         
         return true;
     }
@@ -4605,10 +4766,12 @@
 
         copy.versionindex += 1;
 
-        CopyChanged();
+        CopyChanged(copy);
         
         //if (!tab.user[tab.versionindex])
         //    tab.graphs[tab.versionindex] = null;
+        
+        SetVersionStates();        
     }
 
         void ImportGFD()
@@ -4845,6 +5008,7 @@
             current.shadow = (float) shadowField.getFloat();
             current.texture = (float) textureField.getFloat();
             current.opacity = (float) opacityField.getFloat();
+            current.parallax = (float) parallaxField.getFloat() - 0.125f;
             current.fakedepth = (float) fakedepthField.getFloat();
             current.shadowbias = (float) shadowbiasField.getFloat();
 
@@ -4899,6 +5063,8 @@
                         textureField.SetToolTipValue((mat.texture));
                     if (!Equal(opacityField.getFloat(), mat.opacity))
                         opacityField.SetToolTipValue((mat.opacity));
+                    //if (!Equal(parallaxField.getFloat(), mat.parallax))
+                        parallaxField.SetToolTipValue((mat.parallax));
                     if (!Equal(fakedepthField.getFloat(), mat.fakedepth))
                         fakedepthField.SetToolTipValue((mat.fakedepth));
                     if (!Equal(shadowbiasField.getFloat(), mat.shadowbias))
@@ -4934,6 +5100,7 @@
     }
 
     cNumberSlider versionSlider;
+    cNumberSlider versionField;
     
     public void stateChanged(ChangeEvent e)
     {
@@ -4950,12 +5117,26 @@
             if (version != -1 && copy.versionlist[version] != null)
             {
                 copy.versionindex = version;
-                CopyChanged();
+                CopyChanged(copy);
+                SetVersionStates();
             }
             
             return;
         }
 
+        if (e.getSource() == versionField)
+        {
+            int version = versionField.getInteger();
+            
+            if (version != -1 && copy.versionindex != version && copy.versionlist[version] != null)
+            {
+                copy.versionindex = version;
+                CopyChanged(copy);
+            }
+            
+            return;
+        }
+        
         if (freezematerial)
         {
             return;
@@ -5045,7 +5226,7 @@
         }
         
         if (normalpushField != null)
-                copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
+                copy.NORMALPUSH = (float)normalpushField.getFloat() / 100;
     }
 
         void SnapObject()
@@ -5419,7 +5600,7 @@
     void ResetModel()
     {
         //assert(copy instanceof Composite);
-        Object3D /*Composite*/ group = (Object3D /*Composite*/) copy;
+        Object3D /*Composite*/ group = (Object3D /*Composite*/) objEditor.copy;
 
 // necessary?		group.selection = new Object3D(); // java.util.Vector();
 
@@ -5430,14 +5611,14 @@
         //group.refreshEditWindow();
         //refreshContents();
 
-        if (copy.selection == null)
+        if (objEditor.copy.selection == null)
         {
-            copy.selection = new Object3D();
+            objEditor.copy.selection = new Object3D();
         }
 
-        for (int j = 0; j < copy.selection.size(); j++)
+        for (int j = 0; j < objEditor.copy.selection.size(); j++)
         {
-            Object3D item = copy.selection.get(j);
+            Object3D item = objEditor.copy.selection.get(j);
 
             if (item instanceof cGroup && ((cGroup) item).transientlink)
             {
@@ -5446,15 +5627,15 @@
 
             if (item.count <= 1) // ??? == 0)
             {
-                copy.selection.remove(item);
+                objEditor.copy.selection.remove(item);
             }
         }
 
         boolean first = true;
 
-        for (int i = copy.selection.size(); --i >= 0;)
+        for (int i = objEditor.copy.selection.size(); --i >= 0;)
         {
-            Object3D item = copy.selection.get(i);
+            Object3D item = objEditor.copy.selection.get(i);
 
             if (item instanceof cGroup && ((cGroup) item).transientlink)
             {
@@ -6155,6 +6336,8 @@
     cNumberSlider textureField;
     JLabel opacityLabel;
     cNumberSlider opacityField;
+    JLabel parallaxLabel;
+    cNumberSlider parallaxField;
     JLabel fakedepthLabel;
     cNumberSlider fakedepthField;
     JLabel shadowbiasLabel;

--
Gitblit v1.6.2