From e36047725ce3217618d4e5807ac7c8769b9e3598 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 17 Jun 2019 19:45:55 -0400
Subject: [PATCH] Split pigment bump.

---
 CameraPane.java |  160 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 147 insertions(+), 13 deletions(-)

diff --git a/CameraPane.java b/CameraPane.java
index b4be4fc..99e2648 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -1890,7 +1890,7 @@
     void PushMatrix(double[][] matrix)
     {
     //    GrafreeD.tracein(matrix);
-        PushMatrix(matrix,1);
+        PushMatrix(matrix, 1);
     }
     
     void PushMatrix()
@@ -7921,6 +7921,64 @@
         ReleaseTexture(pigment, false);
     }
     
+    public void ReleasePigmentTexture(cTexture tex) // INTERFACE
+    {
+        if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
+        {
+            return;
+        }
+
+        if (tex == null)
+        {
+            ReleaseTexture(null, false);
+            return;
+        }
+        
+        String pigment = Object3D.GetPigment(tex);
+
+        if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
+        {
+        //    System.out.print("RELEASE  +++++++++++++++  pigment = " + pigment);
+        //    System.out.println("; bump = " + bump);
+        }
+        
+        if (pigment.equals(""))
+        {
+            pigment = null;
+        }
+        
+        ReleaseTexture(pigment, false);
+    }
+    
+    public void ReleaseBumpTexture(cTexture tex) // INTERFACE
+    {
+        if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
+        {
+            return;
+        }
+
+        if (tex == null)
+        {
+            ReleaseTexture(null, true);
+            return;
+        }
+        
+        String bump = Object3D.GetBump(tex);
+
+        if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
+        {
+        //    System.out.print("RELEASE  +++++++++++++++  pigment = " + pigment);
+        //    System.out.println("; bump = " + bump);
+        }
+        
+        if (bump.equals(""))
+        {
+            bump = null;
+        }
+        
+        ReleaseTexture(bump, true);
+    }
+    
     void ReleaseTexture(String tex, boolean bump)
     {
         if (// DrawMode() != 0 || /*tex == null ||*/
@@ -8067,6 +8125,73 @@
         GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
             
         return; // true;
+    }
+    
+    /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
+    {
+        if (// DrawMode() != 0 || /*tex == null ||*/
+                ambientOcclusion ) // || !textureon)
+        {
+            return; // false;
+        }
+
+        if (tex == null)
+        {
+            BindTexture(null,false,resolution);
+            return;
+        }
+        
+        String pigment = Object3D.GetPigment(tex);
+
+        usedtextures.put(pigment, pigment);
+        
+        if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
+        {
+        //    System.out.print("BIND  +++++++++++++++  pigment = " + pigment);
+        //    System.out.println("; bump = " + bump);
+        }
+        
+        if (pigment.equals(""))
+        {
+            pigment = null;
+        }
+        
+        GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
+        BindTexture(pigment, false, resolution);
+    }
+    
+    /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
+    {
+        if (// DrawMode() != 0 || /*tex == null ||*/
+                ambientOcclusion ) // || !textureon)
+        {
+            return; // false;
+        }
+
+        if (tex == null)
+        {
+            BindTexture(null,true,resolution);
+            return;
+        }
+        
+        String bump = Object3D.GetBump(tex);
+
+        usedtextures.put(bump, bump);
+        
+        if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
+        {
+        //    System.out.print("BIND  +++++++++++++++  pigment = " + pigment);
+        //    System.out.println("; bump = " + bump);
+        }
+        
+        if (bump.equals(""))
+        {
+            bump = null;
+        }
+        
+        GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
+        BindTexture(bump, true, resolution);
+        GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
     }
     
     java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
@@ -9335,7 +9460,7 @@
         
         if (renderCamera != lightCamera)
         //for (int count = parentcam.GetTransformCount(); --count>=0;)
-            LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
+            LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
         
 //            LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
             
@@ -9351,7 +9476,7 @@
             
         if (renderCamera != lightCamera)
         //for (int count = parentcam.GetTransformCount(); --count>=0;)
-            LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
+            LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
 
 //            LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
             
@@ -10550,7 +10675,7 @@
 //        if (parentcam != renderCamera) // not a light
         if (cam != lightCamera)
             //for (int count = parentcam.GetTransformCount(); --count>=0;)
-                LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
+                LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
             
             for (int j = 0; j < 4; j++)
             {
@@ -10565,7 +10690,7 @@
 //        if (parentcam != renderCamera) // not a light
         if (cam != lightCamera)
             //for (int count = parentcam.GetTransformCount(); --count>=0;)
-                LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
+                LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
         
             //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
             
@@ -10959,7 +11084,7 @@
 
 //            if (cam != lightCamera)
             //for (int count = parentcam.GetTransformCount(); --count>=0;)
-                LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
+                LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
         }
         
         LA.xformDir(lightposition, cam.toScreen, lightposition);
@@ -10981,7 +11106,7 @@
             {
                 if (cam != lightCamera)
                 //for (int count = parentcam.GetTransformCount(); --count>=0;)
-                   LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013
+                   LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
             }
             
             LA.xformPos(light0, cam.toScreen, light0);
@@ -11894,7 +12019,7 @@
             for (int i = tp.size(); --i >= 0;)
             {
                 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
-                    LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
+                    LA.xformPos(light, tp.get(i).GlobalTransform(), light);
             }
 
 
@@ -11912,7 +12037,7 @@
             }
             
         //for (int count = parentcam.GetTransformCount(); --count>=0;)
-            LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013
+            LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
 
             LA.xformPos(light, renderCamera.toScreen, light);
             
@@ -13833,6 +13958,8 @@
     
     public void mouseDragged(MouseEvent e)
     {
+        Globals.MOUSEDRAGGED = true;
+        
         //System.out.println("mouseDragged: " + e);
         if (isRenderer)
             movingcamera = true;
@@ -14398,6 +14525,8 @@
 
     public void mouseReleased(MouseEvent e)
     {
+        Globals.MOUSEDRAGGED = false;
+        
         movingcamera = false;
         X = Y = 0;
         //System.out.println("mouseReleased: " + e);
@@ -15513,12 +15642,17 @@
                 {
                     switch (object.selection.get(0).hitSomething)
                     {
-                        case Object3D.hitCenter: gr.setColor(Color.pink); break;
-                        case Object3D.hitRotate: gr.setColor(Color.green); break;
-                        case Object3D.hitScale: gr.setColor(Color.cyan); break;
+                        case Object3D.hitCenter: gr.setColor(Color.pink);
+                            gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
+                            break;
+                        case Object3D.hitRotate: gr.setColor(Color.yellow);
+                            gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
+                        break;
+                        case Object3D.hitScale: gr.setColor(Color.cyan);
+                            gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
+                        break;
                     }
                     
-                    gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
                 }
             }
         }

--
Gitblit v1.6.2