From 564f4d12d93813b5d680fc24d4f118c3886d96ed Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Tue, 20 Aug 2019 19:56:41 -0400
Subject: [PATCH] Parallax mapping!

---
 ObjEditor.java |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/ObjEditor.java b/ObjEditor.java
index 93b4b40..3f3be5b 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -134,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());
@@ -2676,6 +2682,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.5, -0.25)); // , aConstraints);
+        colorSection.add(parallax);
+        
         //panel.add(new JSeparator());
         
         //panel.add(globalSection);
@@ -3727,6 +3739,7 @@
         shadowField.setFloat(mat.shadow);
         textureField.setFloat(mat.texture);
         opacityField.setFloat(mat.opacity);
+        parallaxField.setFloat(mat.parallax + 0.25f);
         fakedepthField.setFloat(mat.fakedepth);
         shadowbiasField.setFloat(mat.shadowbias);
         bumpField.setInteger(1); // dec 2013
@@ -4951,6 +4964,7 @@
             current.shadow = (float) shadowField.getFloat();
             current.texture = (float) textureField.getFloat();
             current.opacity = (float) opacityField.getFloat();
+            current.parallax = (float) parallaxField.getFloat() - 0.25f;
             current.fakedepth = (float) fakedepthField.getFloat();
             current.shadowbias = (float) shadowbiasField.getFloat();
 
@@ -5005,6 +5019,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))
@@ -6261,6 +6277,8 @@
     cNumberSlider textureField;
     JLabel opacityLabel;
     cNumberSlider opacityField;
+    JLabel parallaxLabel;
+    cNumberSlider parallaxField;
     JLabel fakedepthLabel;
     cNumberSlider fakedepthField;
     JLabel shadowbiasLabel;

--
Gitblit v1.6.2