From 02e145cb923d601395acc7f15ae9e13f85ef2fbb Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Mon, 02 Jul 2018 21:38:58 -0400
Subject: [PATCH] Hip orientation.

---
 Object3D.java |  136 +++++++++++++++++++++++++++++++++------------
 1 files changed, 100 insertions(+), 36 deletions(-)

diff --git a/Object3D.java b/Object3D.java
index 1b4f39c..f6cf69b 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -355,7 +355,7 @@
     
     int MemorySize()
     {
-        if (memorysize == 0)
+        if (true) // memorysize == 0)
         {
             try
             {
@@ -935,7 +935,7 @@
 
     public Object clone()
     {
-        return GraphreeD.clone(this);
+        return GrafreeD.clone(this);
     }
 
     Object3D copyExpand()
@@ -1446,7 +1446,16 @@
     //    if (other == null)
     //        return;
         
-        System.out.println("Link support this = " + this + "; other = " + other);
+        if (other != null)
+        {
+            BoundaryRep.SEUIL = other.material.cameralight;
+
+            // Set default to 0.1
+            BoundaryRep.SEUIL /= 2;
+            System.out.println("SEUIL = " + BoundaryRep.SEUIL);
+        }
+        
+        System.out.println("Link this = " + this + "; support = " + other);
         
         //if (bRep != null)
         //    bRep.linkVerticesThis(other.bRep);
@@ -1701,7 +1710,7 @@
             Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
             o.bRep = transientrep;
             if (clone)
-                o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
+                o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
             o.CreateMaterial();
             o.SetAttributes(this, -1);
             //parent
@@ -1714,7 +1723,7 @@
             Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
             o.bRep = bRep;
             if (clone)
-                o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
+                o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
             o.CreateMaterial();
             //o.overwriteThis(this, -1);
             o.SetAttributes(this, -1);
@@ -1756,7 +1765,7 @@
 //        {
 //            assert(bRep == null);
 //            Object3D o = new Object3D("Geometry:" + this.name);
-//            o.bRep = (BoundaryRep) GraphreeD.clone(transientrep);
+//            o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
 //            o.CreateMaterial();
 //            parent.addChild(o);
 //        }
@@ -1765,7 +1774,7 @@
 //        {
 //            assert(transientrep == null);
 //            Object3D o = new Object3D("Geometry:" + this.name);
-//            o.bRep = (BoundaryRep) GraphreeD.clone(bRep);
+//            o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
 //            o.CreateMaterial();
 //            parent.addChild(o);
 //        }
@@ -1816,8 +1825,9 @@
             if (obj.name == null)
                 continue; // can't be a null one
             
-            //if (n.contains(obj.name)) // dec 2013  name.split(":")[0])) // Poser generates a count
-            if (n.startsWith(obj.name))
+            String name = obj.name.split(":")[0]; // Poser generates a count
+            //if (n.startsWith(obj.name))
+            if (n.contains(name))
             {
                 theobj = obj;
                 count++;
@@ -2732,6 +2742,24 @@
         blockloop = false;
     }
 
+    void GenNormalsMINE()
+    {
+        if (blockloop)
+            return;
+        
+        blockloop = true;
+        GenNormalsMINE0();
+        for (int i = 0; i < Children().Size(); i++)
+        {
+            Object3D child = (Object3D) Children().get(i); // reserve(i);
+            if (child == null)
+                continue;
+            child.GenNormalsMINE();
+//            Children().release(i);
+        }
+        blockloop = false;
+    }
+
     void ClearColors()
     {
         if (blockloop)
@@ -2876,6 +2904,15 @@
         if (bRep != null)
         {
             bRep.GenerateNormals(crease);
+            Touch();
+        }
+    }
+
+    void GenNormalsMINE0()
+    {
+        if (bRep != null)
+        {
+            bRep.GenerateNormalsMINE();
             Touch();
         }
     }
@@ -3153,7 +3190,7 @@
         
         BoundaryRep sup = bRep.support;
         bRep.support = null;
-        BoundaryRep temprep = (BoundaryRep) GraphreeD.clone(bRep);
+        BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
 //            bRep.SplitInTwo(onlyone); // thread...
             temprep.SplitInTwo(reduction34, onlyone);
             bRep = temprep;
@@ -3677,7 +3714,7 @@
             if (child == null)
                 continue;
             
-            if (GraphreeD.RENDERME > 0)
+            if (GrafreeD.RENDERME > 0)
             {
                 if (child instanceof Merge)
                     ((Merge)child).renderme();
@@ -3717,7 +3754,7 @@
 
     boolean getCentroid(cVector centroid, boolean xform)
     {
-        assert(false);
+// for speaker        assert(false);
         if (blockloop)
             return false;
         
@@ -3828,7 +3865,7 @@
                 if (child == null)
                     continue;
                 
-                if (GraphreeD.RENDERME > 0)
+                if (GrafreeD.RENDERME > 0)
                 {
                     if (child instanceof Merge)
                         ((Merge)child).renderme();
@@ -4023,7 +4060,7 @@
                 if (child == null)
                     continue;
                 
-                if (GraphreeD.RENDERME > 0)
+                if (GrafreeD.RENDERME > 0)
                 {
                     if (child instanceof Merge)
                         ((Merge)child).renderme();
@@ -4111,7 +4148,7 @@
         if (blockloop)
             return;
         
-        for (int i=0; i<size(); i++)
+        for (int i=0; i<Size(); i++)
         {
             if (get(i).parent != this)
             {
@@ -4515,16 +4552,28 @@
     
     Object3D GetFileRoot()
     {
+        if (overflow)
+            return null;
+        
+        overflow = true;
+            
+        Object3D pfr = null;
+        
         if (parent == null && fileparent == null)
-            return this;
+            pfr = this;
         
         if (parent == null && fileparent != null) // V4.gfd???
-            return fileparent;
+            pfr = fileparent;
         
-        if (parent == null)
-            return this;
+        if (pfr == null && parent == null)
+            pfr = this;
         
-        return parent.GetFileRoot();
+        if (pfr == null)
+            pfr = parent.GetFileRoot();
+        
+        overflow = false;
+        
+        return pfr;
     }
     
     cTreePath GetPath()
@@ -5280,7 +5329,7 @@
         if (name != null && name.contains("sclera"))
             name = name;
         
-        if (this instanceof CheckerIG)
+        if (this instanceof Checker)
             return;
         
         if (display.drawMode == display.SHADOW && PASSTEST)
@@ -5507,7 +5556,9 @@
                     display.options2[2] = material.factor;
 
                     cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
-                    display.options3[3] = material.cameralight/0.2f;
+                    display.options4[0] = material.cameralight/0.2f;
+                    display.options4[1] = material.subsurface;
+                    display.options4[2] = material.sheen;
                     
                  //   if (display.CURRENTANTIALIAS > 0)
                  //       display.options3[3] /= 4;
@@ -5807,12 +5858,12 @@
             if (!child.HasTransparency())
             {
                 sel = root != null && root.selection != null && root.selection.indexOf(child) != -1;
-           //     GraphreeD.tracein("draw ", child);
+           //     GrafreeD.tracein("draw ", child);
                 boolean wasblocked = blockdraw;
                 blockdraw = true;
                 child.draw(display, root, selected || sel, wasblocked || blocked); //  || child.IsSelected());
                 blockdraw = false;
-           // GraphreeD.traceout("draw ", child);
+           // GrafreeD.traceout("draw ", child);
             }
 
             release(i);
@@ -7719,7 +7770,7 @@
         if (parent == null)
         {
             System.out.println("NULL PARENT");
-            new Exception().printStackTrace();
+            //new Exception().printStackTrace();
         } else
         {
             if (parent instanceof BezierPatch)
@@ -7735,8 +7786,15 @@
         info.pane.repaint();
     }
 
+    boolean overflow = false;
+    
     void TransformToWorld(cVector out) // , cVector out)
     {
+        if (overflow)
+            return;
+        
+        overflow = true;
+            
         // june 2013 ???       assert (in == out);
         cVector in = out;
         if (toParent != null && !(this instanceof Texture || this instanceof TextureNode))
@@ -7753,6 +7811,8 @@
         {
             (parent!=null?parent:fileparent).TransformToWorld(out); //, out);
         }
+        
+        overflow = false;
     }
 
     void TransformToLocal(cVector out) //, cVector out)
@@ -7995,19 +8055,22 @@
             max = new cVector();
         }
         
-        Object3D sourcenode = GetFileRoot();
-    
-        if (!sourcenode.name.contains("rclab"))
+        if (false) // Can crawl!!
         {
-            getBounds(min, max, true);
+            Object3D sourcenode = GetFileRoot();
 
-            if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
+            if (sourcenode != null && !sourcenode.name.contains("rclab"))
             {
-//                sourcenode.getBounds(min, max, true);
-                sourcenode.getBounds(v0, v1, true);
-//                sourcenode.toParent = sourcenode.toParent;
-//                get(0).toParent = get(0).toParent;
-//                sourcenode.GlobalTransform();
+                getBounds(min, max, true);
+
+                if (min.y != Double.POSITIVE_INFINITY && min.y > 2)
+                {
+    //                sourcenode.getBounds(min, max, true);
+                    sourcenode.getBounds(v0, v1, true);
+    //                sourcenode.toParent = sourcenode.toParent;
+    //                get(0).toParent = get(0).toParent;
+    //                sourcenode.GlobalTransform();
+                }
             }
         }
         
@@ -8016,7 +8079,8 @@
         if (support != null)
         {
             assert(bRep != null);
-            GraphreeD.Assert(support.bRep == bRep.support);
+            if (!(support instanceof GenericJoint)) // support.bRep != null)
+                GrafreeD.Assert(support.bRep == bRep.support);
         }
         else
         {

--
Gitblit v1.6.2