From 3c4c16e0a4ca3949a7a37a24607df7f89abfe7ea Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 22 Apr 2019 16:52:58 -0400
Subject: [PATCH] Refactoring phase 3

---
 ObjEditor.java      |   10 
 CameraScroller.java |    6 
 Merge.java          |    4 
 PointFlow.java      |  201 --------------
 CSG.java            |    4 
 Mocap.java          |    2 
 Composite.java      |    6 
 iCameraPane.java    |   11 
 BoundaryRep.java    |   88 -----
 cLinker.java        |    2 
 CameraPane.java     |  319 ++++++++++++++++++++++
 Globals.java        |   18 
 Object3D.java       |  159 +++++-----
 13 files changed, 438 insertions(+), 392 deletions(-)

diff --git a/BoundaryRep.java b/BoundaryRep.java
index 655d595..729177a 100644
--- a/BoundaryRep.java
+++ b/BoundaryRep.java
@@ -15,7 +15,7 @@
     {
         this(0, 0);
     }
-    
+
     void SaveSupports()
     {
         transientsupport = support;
@@ -4893,7 +4893,7 @@
         return verticesCopy;
     }
 
-    void PreprocessOcclusion(CameraPane cp, double[][] transform)
+    void PreprocessOcclusion(iCameraPane cp, double[][] transform)
     {
         if (//!trimmed ||
                 AOdone)
@@ -4902,80 +4902,7 @@
             return;
         }
 
-        Camera keep = cp.renderCamera;
-        cp.renderCamera = localcamera;
-
-        if (trimmed)
-        {
-            float[] colors = new float[positions.length / 3];
-
-            int i3 = 0;
-            for (int i = 0; i < positions.length / 3; i++, i3 += 3)
-            {
-                if (normals[i3] == 0 && normals[i3+1] == 0 && normals[i3+2] == 0)
-                    continue;
-
-                from.set(positions[i3], positions[i3 + 1], positions[i3 + 2]);
-                to.set(positions[i3] + normals[i3],
-                        positions[i3 + 1] + normals[i3 + 1],
-                        positions[i3 + 2] + normals[i3 + 2]);
-                LA.xformPos(from, transform, from);
-                LA.xformPos(to, transform, to); // RIGID ONLY
-                localcamera.setAim(from, to);
-
-                CameraPane.occlusionbuffer.display();
-
-                if (CameraPane.DEBUG_OCCLUSION)
-                    cp.display(); // debug
-
-                colors[i] = cp.vertexOcclusion.r;
-                //colors[i3 + 1] = cp.vertexOcclusion.g;
-                //colors[i3 + 2] = cp.vertexOcclusion.b;
-
-                if ((i % 100) == 0 && i != 0)
-                {
-            CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
-                    //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
-                        System.out.println((int) (100.0 * i / (positions.length / 3)) + "% (" + i + " of " + (positions.length / 3) + ")");
-                }
-            }
-
-            this.colors = colors;
-        }
-        else
-        {
-            for (int i = 0; i < VertexCount(); i++)
-            {
-                Vertex v = GetVertex(i);
-                
-                if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
-                    continue;
-
-                from.set(v.x, v.y, v.z);
-                to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
-                LA.xformPos(from, transform, from);
-                LA.xformPos(to, transform, to); // RIGID ONLY
-                localcamera.setAim(from, to);
-
-                CameraPane.occlusionbuffer.display();
-
-                if (CameraPane.DEBUG_OCCLUSION)
-                    cp.display(); // debug
-
-                v.AO = cp.vertexOcclusion.r;
-
-                if ((i % 100) == 0 && i != 0)
-                {
-            CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
-                    //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
-                        System.out.println((int) (100.0 * i / VertexCount()) + "% (" + i + " of " + VertexCount() + ")");
-                }
-            }
-        }
-
-        //System.out.println("done.");
-
-        cp.renderCamera = keep;
+                cp.PrepOcclusion(this, transform);
         
         AOdone = true;
     }
@@ -8354,9 +8281,6 @@
         return "trim = " + trimmed + "; stripped = " + stripified + "; colors = " + colors + "; faces = " + (faces!=null?faces.size():null) + "; triangles = " + (triangles!=null?triangles.length:null) + "; indices = " + indices;
     }
     
-    static Camera localcamera = new Camera();
-    static cVector from = new cVector();
-    static cVector to = new cVector();
     boolean trimmed = false;
     boolean stripified = false;
     transient boolean AOdone = false;
@@ -8364,8 +8288,10 @@
     /*transient*/ int maxIndexV = 0;
     /*transient*/ int bufV, bufF;
     // Raw version
-    private float[] positions;
-    private float[] normals;
+    //private
+            float[] positions;
+    //private
+            float[] normals;
     float[] colors;
     private float[] uvmap;
     private int[] triangles;
diff --git a/CSG.java b/CSG.java
index 44c5995..cefd400 100644
--- a/CSG.java
+++ b/CSG.java
@@ -132,7 +132,7 @@
     }
 
     /**/
-    void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
+    void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
     {
         if (csgType == UNION || !link2master) // || csgType == MERGE)
         {
@@ -154,7 +154,7 @@
     }
     /**/
 
-    void PreprocessOcclusion(CameraPane cp)
+    void PreprocessOcclusion(iCameraPane cp)
     {
         if (csgType == UNION) // || csgType == MERGE)
         {
diff --git a/CameraPane.java b/CameraPane.java
index c4bdcc2..fc57173 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -149,8 +149,9 @@
         defaultcaps.setAccumBlueBits(16);
         defaultcaps.setAccumAlphaBits(16);
     }
+    
     static CameraPane theRenderer;
-
+    
     void SetAsGLRenderer(boolean b)
     {
         isRenderer = b;
@@ -236,9 +237,14 @@
             return this.ambientOcclusion;
     }
     
+    public boolean IsDebugSelection()
+    {
+            return DEBUG_SELECTION;
+    }
+    
     public boolean IsFrozen()
     {
-        boolean selectmode = this.DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
+        boolean selectmode = this.DrawMode() == SELECTION || this.IsDebugSelection();
         
         return !selectmode && cameracount == 0; // != 0;
     }
@@ -259,9 +265,19 @@
             return lightCamera;
     }
     
+    public Camera ManipCamera()
+    {
+            return manipCamera;
+    }
+    
     public Camera RenderCamera()
     {
             return renderCamera;
+    }
+    
+    public Camera[] Cameras()
+    {
+            return cameras;
     }
     
     public void PushMaterial(Object3D obj, boolean selected)
@@ -408,7 +424,7 @@
         
         javax.media.opengl.GL gl = display.GetGL();
         
-        boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
+        boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
         
         //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
         if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
@@ -760,6 +776,291 @@
 ////        tris.postdraw(this);
     }
 
+    static Camera localcamera = new Camera();
+    static cVector from = new cVector();
+    static cVector to = new cVector();
+    
+        public void PrepOcclusion(BoundaryRep br, double[][] transform)
+        {
+                CameraPane cp = this;
+
+                Camera keep = cp.RenderCamera();
+                cp.renderCamera = localcamera;
+
+                if (br.trimmed)
+                {
+                    float[] colors = new float[br.positions.length / 3];
+
+                    int i3 = 0;
+                    for (int i = 0; i < br.positions.length / 3; i++, i3 += 3)
+                    {
+                        if (br.normals[i3] == 0 && br.normals[i3+1] == 0 && br.normals[i3+2] == 0)
+                            continue;
+
+                        from.set(br.positions[i3], br.positions[i3 + 1], br.positions[i3 + 2]);
+                        to.set(br.positions[i3] + br.normals[i3],
+                                br.positions[i3 + 1] + br.normals[i3 + 1],
+                                br.positions[i3 + 2] + br.normals[i3 + 2]);
+                        LA.xformPos(from, transform, from);
+                        LA.xformPos(to, transform, to); // RIGID ONLY
+                        localcamera.setAim(from, to);
+
+                        CameraPane.occlusionbuffer.display();
+
+                        if (CameraPane.DEBUG_OCCLUSION)
+                            cp.display(); // debug
+
+                        colors[i] = cp.vertexOcclusion.r;
+                        //colors[i3 + 1] = cp.vertexOcclusion.g;
+                        //colors[i3 + 2] = cp.vertexOcclusion.b;
+
+                        if ((i % 100) == 0 && i != 0)
+                        {
+                    CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
+                            //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
+                                System.out.println((int) (100.0 * i / (br.positions.length / 3)) + "% (" + i + " of " + (br.positions.length / 3) + ")");
+                        }
+                    }
+
+                    br.colors = colors;
+                }
+                else
+                {
+                    for (int i = 0; i < br.VertexCount(); i++)
+                    {
+                        Vertex v = br.GetVertex(i);
+
+                        if (v.norm == null || v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0)
+                            continue;
+
+                        from.set(v.x, v.y, v.z);
+                        to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z);
+                        LA.xformPos(from, transform, from);
+                        LA.xformPos(to, transform, to); // RIGID ONLY
+                        localcamera.setAim(from, to);
+
+                        CameraPane.occlusionbuffer.display();
+
+                        if (CameraPane.DEBUG_OCCLUSION)
+                            cp.display(); // debug
+
+                        v.AO = cp.vertexOcclusion.r;
+
+                        if ((i % 100) == 0 && i != 0)
+                        {
+                    CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
+                            //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done");
+                                System.out.println((int) (100.0 * i / br.VertexCount()) + "% (" + i + " of " + br.VertexCount() + ")");
+                        }
+                    }
+                }
+
+                //System.out.println("done.");
+
+                cp.renderCamera = keep;
+        }
+        
+    void DrawPointFLow(PointFlow pointFlow, Object3D /*Composite*/ root, boolean selected, boolean blocked)
+    {
+            CameraPane display = this;
+        pointFlow.CreateHT();
+        
+        float r = display.modelParams0[0];
+        float g = display.modelParams0[1];
+        float b = display.modelParams0[2];
+        float opacity = display.modelParams5[1];        
+        
+        //final GL gl = GLU.getCurrentGL();
+        GL gl = display.GetGL(); // getGL();
+
+        int s = pointFlow.points.size();
+
+        boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
+        gl.glEnable(gl.GL_CULL_FACE);
+        
+        for (int i=s; --i>=0;)
+        //for (int i=0; i<s; i++)
+        {
+            cVector v = pointFlow.points.get(i);
+            
+            double mindist = Double.MAX_VALUE;
+            
+            double size = pointFlow.minimumSize;
+            
+            double distancenext = 0;
+            
+            if (i > 0)
+            {
+                cVector w = pointFlow.points.get(i-1);
+                
+                double dist = w.distance(v);
+                
+                distancenext = dist;
+        
+                if (mindist > dist)
+                {
+                    mindist = dist;
+                    size = mindist*pointFlow.resizefactor;
+                }
+            }
+            
+            if (i < s-1)
+            {
+                cVector w = pointFlow.points.get(i+1);
+                
+                double dist = w.distance(v);
+                
+                if (mindist > dist)
+                {
+                    mindist = dist;
+                    size = mindist*pointFlow.resizefactor;
+                }
+            }
+            
+            if (size < pointFlow.minimumSize)
+                size = pointFlow.minimumSize;
+            if (size > pointFlow.maximumSize)
+                size = pointFlow.maximumSize;
+            
+            double tx = v.x;
+            double ty = v.y;
+            double tz = v.z;
+            
+        //    if (tx == 0 && ty == 0 && tz == 0)
+        //        continue;
+            
+        gl.glMatrixMode(gl.GL_TEXTURE);
+        gl.glPushMatrix();
+        pointFlow.texmat[12] = pointFlow.texmat[13] = pointFlow.texmat[14] = i;
+        
+        gl.glMultMatrixf(pointFlow.texmat, 0);
+        
+            gl.glMatrixMode(gl.GL_MODELVIEW);
+            gl.glPushMatrix();
+            
+            gl.glTranslated(tx,ty,tz);
+
+            gl.glScaled(size,size,size);
+            
+//            float cr = colorBuf.get(index4);
+//            float cg = colorBuf.get(index4+1);
+//            float cb = colorBuf.get(index4+2);
+//            float ca = colorBuf.get(index4+3);
+//            
+//            display.modelParams0[0] = r * cr;
+//            display.modelParams0[1] = g * cg;
+//            display.modelParams0[2] = b * cb;
+//            
+//            display.modelParams5[1] = opacity * ca;
+//            
+//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
+//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
+//        
+//        RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
+//        RandomNode.globalseed2 = RandomNode.globalseed;
+//        
+////            gl.glColor4f(cr,cg,cb,ca);
+//   //         gl.glScalef(1024/16,1024/16,1024/16);
+            pointFlow.geo.Draw/*Node*/(display,null,selected, blocked);
+            
+            gl.glPopMatrix();
+
+            double step = size/4; //
+            
+            if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
+                continue;
+            
+            int nbsteps = (int)(distancenext/step);
+            
+            step = distancenext/nbsteps;
+            
+            cVector next = pointFlow.points.get(i-1);
+            
+            tmp.set(next);
+            tmp.sub(v);
+            tmp.normalize();
+            tmp.mul(step);
+            
+            // calculate next size
+            mindist = Double.MAX_VALUE;
+            
+            double nextsize = pointFlow.minimumSize;
+            
+            if (i > 1)
+            {
+                cVector w = pointFlow.points.get(i-2);
+                
+                double dist = w.distance(next);
+                
+                if (mindist > dist)
+                {
+                    mindist = dist;
+                    nextsize = mindist*pointFlow.resizefactor;
+                }
+            }
+            
+            double dist = v.distance(next);
+
+            if (mindist > dist)
+            {
+                mindist = dist;
+                nextsize = mindist*pointFlow.resizefactor;
+            }
+            
+            if (nextsize < pointFlow.minimumSize)
+                nextsize = pointFlow.minimumSize;
+            if (nextsize > pointFlow.maximumSize)
+                nextsize = pointFlow.maximumSize;
+            //
+            
+            double count = 0;
+            
+            while (distancenext > 0.000000001) // step
+            {
+                gl.glPushMatrix();
+
+                gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
+
+                double K = count/nbsteps;
+                
+                double intersize = K*nextsize + (1-K)*size;
+                
+                gl.glScaled(intersize,intersize,intersize);
+
+                pointFlow.geo.Draw/*Node*/(display,null,selected,blocked);
+            
+                count++;
+                
+                distancenext -= step;
+                
+                gl.glPopMatrix();
+            }
+            
+            if (count != nbsteps)
+                assert(count == nbsteps);
+            
+   //         gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
+            //gl.glTranslatef(-tx,-ty,-tz);
+            
+        gl.glMatrixMode(gl.GL_TEXTURE);
+        gl.glPopMatrix();
+        }
+
+        if (!cf)
+            gl.glDisable(gl.GL_CULL_FACE);
+        
+//        display.modelParams0[0] = r;
+//        display.modelParams0[1] = g;
+//        display.modelParams0[2] = b;
+//            
+//        display.modelParams5[1] = opacity;
+//            
+//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
+//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
+        
+        gl.glMatrixMode(gl.GL_MODELVIEW);
+    }
+    
     /// INTERFACE
     
     void SetColor(Object3D obj, Vertex p0)
@@ -10340,7 +10641,7 @@
         fragmentMode |= (lightslot - 64) << 2; // 1; // first bit is available for aniso
         //System.out.println("fragmentMode = " + fragmentMode);
 
-        if (DrawMode() == DEFAULT || DrawMode() == SELECTION || DEBUG_SELECTION)
+        if (DrawMode() == DEFAULT || DrawMode() == SELECTION || IsDebugSelection())
         {
             /*
             if (CULLFACE || (ambientOcclusion && OCCLUSION_CULLING))
@@ -10641,7 +10942,7 @@
             callist = gl.glGenLists(1);
         }
 
-        boolean selectmode = DrawMode() == SELECTION || CameraPane.DEBUG_SELECTION;
+        boolean selectmode = DrawMode() == SELECTION || IsDebugSelection();
         
         boolean active = !selectmode; // DrawMode() != SELECTION; // mouseDown;
         
@@ -13115,6 +13416,11 @@
     cVector tmp = new cVector();
     cVector tmp2 = new cVector();
     boolean isMoving;
+
+    public cVector TargetLookAt()
+    {
+            return targetLookAt;
+    }
 
     class PingThread extends Thread
     {
@@ -15966,7 +16272,6 @@
 
     class AntialiasBuffer implements GLEventListener
     {
-
         CameraPane parent = null;
 
         AntialiasBuffer(CameraPane p)
@@ -16359,7 +16664,7 @@
         }
     }
     
-    static void DrawPoints(CameraPane cpane)
+    static void DrawPoints(iCameraPane cpane)
     {
         for (int i=0; i<8; i++) // first and last are red
         {
diff --git a/CameraScroller.java b/CameraScroller.java
index 0a11119..e210980 100644
--- a/CameraScroller.java
+++ b/CameraScroller.java
@@ -15,10 +15,10 @@
         //horizCenter = imageWidth / 2;
         //vertCenter = imageHeight / 2;
         setLayout(new BorderLayout());
-        cameraPane = new CameraPane(null, null, false);
+// TODO        cameraPane = new CameraPane(null, null, false);
 	//JScrollPane pain = new JScrollPane(cameraPane);
         /*add("North", (*/ caption = new Label("", 0); //);
-        add("Center", cameraPane);
+// TODO        add("Center", cameraPane);
         //add("East", vScroll = new Scrollbar(1));
         //add("South", hScroll = new Scrollbar(0));
         //add("Center", cameraPane = new CameraPane());
@@ -124,7 +124,7 @@
     }
     */
 
-    CameraPane cameraPane;
+// TODO    CameraPane cameraPane;
     //Scrollbar vScroll;
     //Scrollbar hScroll;
     Label caption;
diff --git a/Composite.java b/Composite.java
index 6156d60..210413e 100644
--- a/Composite.java
+++ b/Composite.java
@@ -837,7 +837,7 @@
         }
 
         if ((//display.drawMode == CameraPane.SHADOW ||
-                display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) &&
+                display.DrawMode() == CameraPane.SELECTION || display.IsDebugSelection()) &&
                 //HasTransparency())
         // SERIAL PATCH
 //        if (viewCode == -1)
@@ -855,7 +855,7 @@
 
     cTexture tex = null;
 
-    boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
+    boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
         
     if (//display.drawMode != display.SHADOW &&
             !selectmode // display.drawMode != display.SELECTION
@@ -994,7 +994,7 @@
 //        }
 //    }
 
-    void drawSelfOld(CameraPane display, Object3D /*Composite*/ root, boolean selected)
+    void drawSelfOld(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
     {
 //        if (count <= 0) // || display.IsFreezed())
 //        {
diff --git a/Globals.java b/Globals.java
index 0e4465b..070b46b 100644
--- a/Globals.java
+++ b/Globals.java
@@ -1,12 +1,20 @@
 
 public class Globals
 {
-static    boolean CROWD = false;
-    static public int drawMode = iCameraPane.DEFAULT; // WARNING
-    static public boolean lighttouched = false; // WARNING
-    
-        static int framecount = 0; // general-purpose global count
         private static boolean LIVE = false;
+        
+        static boolean CROWD = false;
+        static public int drawMode = iCameraPane.DEFAULT; // WARNING
+        
+        static public boolean lighttouched = false;
+        static public boolean ANIMATION = false;
+        static public int imagecount = 0;
+        static public String filename;
+        
+        static public boolean fromscript = false;
+        static public boolean fullreset = false;
+        
+        static int framecount = 0; // general-purpose global count
         static boolean ONESTEP = false; // do LIVE once
 
         public static boolean isLIVE()
diff --git a/Merge.java b/Merge.java
index aa47522..138d4b1 100644
--- a/Merge.java
+++ b/Merge.java
@@ -396,9 +396,9 @@
 
     }
     
-    public void drawCube(CameraPane display, float extent)
+    public void drawCube(iCameraPane display, float extent)
     {
-        GL gl = display.getGL();
+        GL gl = display.GetGL();
 
         extent = extent * 0.5f;
 
diff --git a/Mocap.java b/Mocap.java
index acb3fd0..9dc8a09 100644
--- a/Mocap.java
+++ b/Mocap.java
@@ -1519,7 +1519,7 @@
 //            mywave = currentwave++;
 //        }
                     // sound
-                    cVector eye = CameraPane.theRenderer.eyeCamera.location;
+                    cVector eye = CameraPane.theRenderer.EyeCamera().location;
 
 //                    if (sourcenode.parent.parent != null)
 //                        sourcenode.parent.parent.TransformToWorld(floor, tmp);
diff --git a/ObjEditor.java b/ObjEditor.java
index 884881a..9076e4e 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -3297,25 +3297,25 @@
 
     void ToggleAnimation()
     {
-        if (!CameraPane.ANIMATION)
+        if (!Globals.ANIMATION)
         {
             FileDialog browser = new FileDialog(frame, "Save Animation As...", FileDialog.SAVE);
             browser.show();
             String filename = browser.getFile();
             if (filename != null && filename.length() > 0)
             {
-                CameraPane.filename = browser.getDirectory() + filename;
+                Globals.filename = browser.getDirectory() + filename;
                 //CameraPane.framecount = 0;
-                CameraPane.imagecount = 0;
+                Globals.imagecount = 0;
 
-                CameraPane.ANIMATION ^= true;
+                Globals.ANIMATION ^= true;
 
                 GrafreeD.wav.cursor = 0;
                 GrafreeD.wav.loop = 0;
             }
         } else
         {
-            CameraPane.ANIMATION ^= true;
+            Globals.ANIMATION ^= true;
         }
     }
 
diff --git a/Object3D.java b/Object3D.java
index 18fd57e..fb14401 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -430,16 +430,16 @@
     {
         Object3D copy = this;
         
-            Camera parentcam = CameraPane.theRenderer.manipCamera;
+            Camera parentcam = CameraPane.theRenderer.ManipCamera();
             
-            if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
+            if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[0])
             {
-                parentcam = CameraPane.theRenderer.cameras[1];
+                parentcam = CameraPane.theRenderer.Cameras()[1];
             }
             
-            if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
+            if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[1])
             {
-                parentcam = CameraPane.theRenderer.cameras[0];
+                parentcam = CameraPane.theRenderer.Cameras()[0];
             }
         
         if (this == parentcam)
@@ -447,7 +447,7 @@
             //assert(this instanceof Camera);
             
             for (int count = parentcam.GetTransformCount(); --count>=0;)
-                LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
+                LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.toParent, CameraPane.theRenderer.TargetLookAt());
         }
         
         copy.marked ^= true;
@@ -467,7 +467,7 @@
             //assert(this instanceof Camera);
             
             for (int count = parentcam.GetTransformCount(); --count>=0;)
-                LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
+                LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.fromParent, CameraPane.theRenderer.TargetLookAt());
         }
 
         copy.Touch(); // display list issue
@@ -602,7 +602,7 @@
             return;
         }
         
-        if (CameraPane.fromscript)
+        if (Globals.fromscript)
         {
             transformcount = 0;
             return;
@@ -4854,7 +4854,7 @@
         return globalTransform;
     }
 
-    void PreprocessOcclusion(CameraPane cp)
+    void PreprocessOcclusion(iCameraPane cp)
     {
         /*
         if (AOdone)
@@ -5327,6 +5327,7 @@
                     && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
     }
     
+    static boolean DEBUG_SELECTION = false;
     
     void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
     {
@@ -5365,7 +5366,7 @@
         }
 
         if ((//display.DrawMode() == CameraPane.SHADOW ||
-                display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
+                display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
         {
             return;
         }
@@ -5406,7 +5407,7 @@
 
         boolean compiled = false;
 
-        boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
+        boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
         
         if (!selectmode && //display.DrawMode() != display.SELECTION &&
                 (touched || (bRep != null && bRep.displaylist <= 0)))
@@ -5484,9 +5485,9 @@
         
         // frustum culling
         if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
-                && display.DrawMode() != CameraPane.SELECTION)
+                && display.DrawMode() != iCameraPane.SELECTION)
         {
-            if (display.DrawMode() == CameraPane.SHADOW)
+            if (display.DrawMode() == iCameraPane.SHADOW)
             {
                 if (!link2master // tricky to cull in shadow mode.
                          && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
@@ -5533,7 +5534,7 @@
 
 
         if (!culled)
-        if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
+        if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
         {
             if (GetBRep() != null)
             {
@@ -5973,7 +5974,7 @@
         {
             //throw new Error();
 
-            boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
+            boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
 
             int[] strips = bRep.getRawIndices();
 
@@ -6993,83 +6994,83 @@
             int spotw = spot.x + spot.width;
             int spoth = spot.y + spot.height;
             info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
-            if (CameraPane.Xmin > spot.x)
-            {
-                CameraPane.Xmin = spot.x;
-            }
-            if (CameraPane.Xmax < spotw)
-            {
-                CameraPane.Xmax = spotw;
-            }
-            if (CameraPane.Ymin > spot.y)
-            {
-                CameraPane.Ymin = spot.y;
-            }
-            if (CameraPane.Ymax < spoth)
-            {
-                CameraPane.Ymax = spoth;
-            }
+//            if (CameraPane.Xmin > spot.x)
+//            {
+//                CameraPane.Xmin = spot.x;
+//            }
+//            if (CameraPane.Xmax < spotw)
+//            {
+//                CameraPane.Xmax = spotw;
+//            }
+//            if (CameraPane.Ymin > spot.y)
+//            {
+//                CameraPane.Ymin = spot.y;
+//            }
+//            if (CameraPane.Ymax < spoth)
+//            {
+//                CameraPane.Ymax = spoth;
+//            }
             spot.translate(32, 32);
             spotw = spot.x + spot.width;
             spoth = spot.y + spot.height;
             info.g.setColor(Color.blue);
             info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
-            if (CameraPane.Xmin > spot.x)
-            {
-                CameraPane.Xmin = spot.x;
-            }
-            if (CameraPane.Xmax < spotw)
-            {
-                CameraPane.Xmax = spotw;
-            }
-            if (CameraPane.Ymin > spot.y)
-            {
-                CameraPane.Ymin = spot.y;
-            }
-            if (CameraPane.Ymax < spoth)
-            {
-                CameraPane.Ymax = spoth;
-            }
+//            if (CameraPane.Xmin > spot.x)
+//            {
+//                CameraPane.Xmin = spot.x;
+//            }
+//            if (CameraPane.Xmax < spotw)
+//            {
+//                CameraPane.Xmax = spotw;
+//            }
+//            if (CameraPane.Ymin > spot.y)
+//            {
+//                CameraPane.Ymin = spot.y;
+//            }
+//            if (CameraPane.Ymax < spoth)
+//            {
+//                CameraPane.Ymax = spoth;
+//            }
             info.g.drawLine(spotw, spoth, spotw, spoth - 15);
             info.g.drawLine(spotw, spoth, spotw - 15, spoth);
             spot.translate(0, -32);
             info.g.setColor(Color.green);
             info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
-            if (CameraPane.Xmin > spot.x)
-            {
-                CameraPane.Xmin = spot.x;
-            }
-            if (CameraPane.Xmax < spotw)
-            {
-                CameraPane.Xmax = spotw;
-            }
-            if (CameraPane.Ymin > spot.y)
-            {
-                CameraPane.Ymin = spot.y;
-            }
-            if (CameraPane.Ymax < spoth)
-            {
-                CameraPane.Ymax = spoth;
-            }
+//            if (CameraPane.Xmin > spot.x)
+//            {
+//                CameraPane.Xmin = spot.x;
+//            }
+//            if (CameraPane.Xmax < spotw)
+//            {
+//                CameraPane.Xmax = spotw;
+//            }
+//            if (CameraPane.Ymin > spot.y)
+//            {
+//                CameraPane.Ymin = spot.y;
+//            }
+//            if (CameraPane.Ymax < spoth)
+//            {
+//                CameraPane.Ymax = spoth;
+//            }
             info.g.drawArc(boundary.x, boundary.y,
                     boundary.width, boundary.height, 0, 360);
             //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
-            if (CameraPane.Xmin > boundary.x)
-            {
-                CameraPane.Xmin = boundary.x;
-            }
-            if (CameraPane.Xmax < boundary.x + boundary.width)
-            {
-                CameraPane.Xmax = boundary.x + boundary.width;
-            }
-            if (CameraPane.Ymin > boundary.y)
-            {
-                CameraPane.Ymin = boundary.y;
-            }
-            if (CameraPane.Ymax < boundary.y + boundary.height)
-            {
-                CameraPane.Ymax = boundary.y + boundary.height;
-            }
+//            if (CameraPane.Xmin > boundary.x)
+//            {
+//                CameraPane.Xmin = boundary.x;
+//            }
+//            if (CameraPane.Xmax < boundary.x + boundary.width)
+//            {
+//                CameraPane.Xmax = boundary.x + boundary.width;
+//            }
+//            if (CameraPane.Ymin > boundary.y)
+//            {
+//                CameraPane.Ymin = boundary.y;
+//            }
+//            if (CameraPane.Ymax < boundary.y + boundary.height)
+//            {
+//                CameraPane.Ymax = boundary.y + boundary.height;
+//            }
             return;
         }
     }
diff --git a/PointFlow.java b/PointFlow.java
index f1f806b..ab8baa4 100644
--- a/PointFlow.java
+++ b/PointFlow.java
@@ -102,208 +102,7 @@
     double resizefactor = 1;
     
     static cVector tmp = new cVector();
-    
-    void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
-    {
-        CreateHT();
         
-        float r = display.modelParams0[0];
-        float g = display.modelParams0[1];
-        float b = display.modelParams0[2];
-        float opacity = display.modelParams5[1];        
-        
-        //final GL gl = GLU.getCurrentGL();
-        GL gl = display.GetGL(); // getGL();
-
-        int s = points.size();
-
-        boolean cf = gl.glIsEnabled(gl.GL_CULL_FACE);
-        gl.glEnable(gl.GL_CULL_FACE);
-        
-        for (int i=s; --i>=0;)
-        //for (int i=0; i<s; i++)
-        {
-            cVector v = points.get(i);
-            
-            double mindist = Double.MAX_VALUE;
-            
-            double size = minimumSize;
-            
-            double distancenext = 0;
-            
-            if (i > 0)
-            {
-                cVector w = points.get(i-1);
-                
-                double dist = w.distance(v);
-                
-                distancenext = dist;
-        
-                if (mindist > dist)
-                {
-                    mindist = dist;
-                    size = mindist*resizefactor;
-                }
-            }
-            
-            if (i < s-1)
-            {
-                cVector w = points.get(i+1);
-                
-                double dist = w.distance(v);
-                
-                if (mindist > dist)
-                {
-                    mindist = dist;
-                    size = mindist*resizefactor;
-                }
-            }
-            
-            if (size < minimumSize)
-                size = minimumSize;
-            if (size > maximumSize)
-                size = maximumSize;
-            
-            double tx = v.x;
-            double ty = v.y;
-            double tz = v.z;
-            
-        //    if (tx == 0 && ty == 0 && tz == 0)
-        //        continue;
-            
-        gl.glMatrixMode(gl.GL_TEXTURE);
-        gl.glPushMatrix();
-        texmat[12] = texmat[13] = texmat[14] = i;
-        
-        gl.glMultMatrixf(texmat, 0);
-        
-            gl.glMatrixMode(gl.GL_MODELVIEW);
-            gl.glPushMatrix();
-            
-            gl.glTranslated(tx,ty,tz);
-
-            gl.glScaled(size,size,size);
-            
-//            float cr = colorBuf.get(index4);
-//            float cg = colorBuf.get(index4+1);
-//            float cb = colorBuf.get(index4+2);
-//            float ca = colorBuf.get(index4+3);
-//            
-//            display.modelParams0[0] = r * cr;
-//            display.modelParams0[1] = g * cg;
-//            display.modelParams0[2] = b * cb;
-//            
-//            display.modelParams5[1] = opacity * ca;
-//            
-//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
-//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
-//        
-//        RandomNode.globalseed = (int)sizeBuf.get(index3+2); // i;
-//        RandomNode.globalseed2 = RandomNode.globalseed;
-//        
-////            gl.glColor4f(cr,cg,cb,ca);
-//   //         gl.glScalef(1024/16,1024/16,1024/16);
-            geo.Draw/*Node*/(display,null,selected, blocked);
-            
-            gl.glPopMatrix();
-
-            double step = size/4; //
-            
-            if (i == 0 || size == 0 || distancenext > 8*size || distancenext < step)
-                continue;
-            
-            int nbsteps = (int)(distancenext/step);
-            
-            step = distancenext/nbsteps;
-            
-            cVector next = points.get(i-1);
-            
-            tmp.set(next);
-            tmp.sub(v);
-            tmp.normalize();
-            tmp.mul(step);
-            
-            // calculate next size
-            mindist = Double.MAX_VALUE;
-            
-            double nextsize = minimumSize;
-            
-            if (i > 1)
-            {
-                cVector w = points.get(i-2);
-                
-                double dist = w.distance(next);
-                
-                if (mindist > dist)
-                {
-                    mindist = dist;
-                    nextsize = mindist*resizefactor;
-                }
-            }
-            
-            double dist = v.distance(next);
-
-            if (mindist > dist)
-            {
-                mindist = dist;
-                nextsize = mindist*resizefactor;
-            }
-            
-            if (nextsize < minimumSize)
-                nextsize = minimumSize;
-            if (nextsize > maximumSize)
-                nextsize = maximumSize;
-            //
-            
-            double count = 0;
-            
-            while (distancenext > 0.000000001) // step
-            {
-                gl.glPushMatrix();
-
-                gl.glTranslated(tx + tmp.x*count, ty + tmp.y*count, tz + tmp.z*count);
-
-                double K = count/nbsteps;
-                
-                double intersize = K*nextsize + (1-K)*size;
-                
-                gl.glScaled(intersize,intersize,intersize);
-
-                geo.Draw/*Node*/(display,null,selected,blocked);
-            
-                count++;
-                
-                distancenext -= step;
-                
-                gl.glPopMatrix();
-            }
-            
-            if (count != nbsteps)
-                assert(count == nbsteps);
-            
-   //         gl.glScalef(16.0f/1024,16.0f/1024,16.0f/1024);
-            //gl.glTranslatef(-tx,-ty,-tz);
-            
-        gl.glMatrixMode(gl.GL_TEXTURE);
-        gl.glPopMatrix();
-        }
-
-        if (!cf)
-            gl.glDisable(gl.GL_CULL_FACE);
-        
-//        display.modelParams0[0] = r;
-//        display.modelParams0[1] = g;
-//        display.modelParams0[2] = b;
-//            
-//        display.modelParams5[1] = opacity;
-//            
-//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 0, display.modelParams0, 0);
-//        gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 5, display.modelParams5, 0);
-        
-        gl.glMatrixMode(gl.GL_MODELVIEW);
-    }
-    
-    
     void createEditWindow(GroupEditor callee, boolean newWindow)
     {
         //editWindow = (new SphereEditor(this, deepCopy(), callee)).GetEditor();
diff --git a/cLinker.java b/cLinker.java
index 5441199..0e3467c 100644
--- a/cLinker.java
+++ b/cLinker.java
@@ -34,7 +34,7 @@
         //if(count <= 0)
           //  return;
         
-        if(display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
+        if(display.DrawMode() == display.SELECTION || display.IsDebugSelection())
         {
             super.draw(display, root, selected, blocked);
             return;
diff --git a/iCameraPane.java b/iCameraPane.java
index 9d55774..0ecb003 100644
--- a/iCameraPane.java
+++ b/iCameraPane.java
@@ -6,6 +6,8 @@
     static final public int SHADOW = 2;
     static final public int OCCLUSION = 3;
 
+    boolean IsDebugSelection();
+    
     boolean IsBoxMode();
 
     void ClearDepth();
@@ -33,12 +35,15 @@
     void PushTextureMatrix(double[][] matrix, int count);
     void PopTextureMatrix(double[][] matrix);
     
+    Camera[] Cameras();
+    
     Camera EyeCamera();
-    
     Camera LightCamera();
-    
+    Camera ManipCamera();
     Camera RenderCamera();
     
+    cVector TargetLookAt();
+
     // Should be cMaterial
     void PushMaterial(Object3D obj, boolean selected);
     void PushMaterial2(Object3D obj, boolean selected);
@@ -54,4 +59,6 @@
     void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face);
     
     void DrawParticles(TriMesh geo, Object3D shape, boolean selected, boolean rotate);
+    
+    void PrepOcclusion(BoundaryRep br, double[][] transform);
 }

--
Gitblit v1.6.2