From 255bcc8ac2faaf412e78e231eaa8e4a560621668 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 29 Sep 2019 12:44:37 -0400
Subject: [PATCH] link2master + link2support + UF

---
 ObjEditor.java              |   60 ++++++++++++++++++-
 SwitchNode.java             |    2 
 Merge.java                  |    4 
 CSG.java                    |    2 
 Mocap.java                  |   14 ++--
 GenericJoint.java           |    2 
 fullscenes/urbanfuture3.png |    0 
 FrameSelector.java          |    2 
 CameraPane.java             |   13 +++-
 cTreeModel.java             |    2 
 GroupEditor.java            |    6 +-
 fullscenes/urbanfuture4.png |    0 
 RandomNode.java             |    2 
 CSGEditor.java              |    2 
 Object3D.java               |   24 +++++--
 15 files changed, 100 insertions(+), 35 deletions(-)

diff --git a/CSG.java b/CSG.java
index 5a4e95c..6a6b764 100644
--- a/CSG.java
+++ b/CSG.java
@@ -134,7 +134,7 @@
     /**/
     void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
     {
-        if (csgType == UNION || !link2master) // || csgType == MERGE)
+        if (csgType == UNION || !Link2Support()) // || csgType == MERGE)
         {
             BoundaryRep keep = bRep;
             bRep = null;
diff --git a/CSGEditor.java b/CSGEditor.java
index 01423e2..f06dac2 100644
--- a/CSGEditor.java
+++ b/CSGEditor.java
@@ -256,7 +256,7 @@
 		csg.cellSize2 = size2Slider.getInteger();
 		csg.tolerance = toleranceSlider.getFloat();
                 
-                if (csg.link2master)
+                if (csg.Link2Support())
                     csg.retile();
 	}
 	
diff --git a/CameraPane.java b/CameraPane.java
index 02b265d..33efbcd 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -1530,7 +1530,7 @@
                 }
             }
             float b = 0;
-            if (obj.support != null && obj.link2master)
+            if (obj.support != null && obj.Link2Support())
             {
                 b = 1;
             }
@@ -14676,9 +14676,14 @@
             RigidBody.pos.z = 0;
             if (RigidBody.justclicked)
             {
-                RigidBody.pos.x = (float)manipCamera.lookAt.x;
-                RigidBody.pos.y = (float)manipCamera.lookAt.y;
-                RigidBody.pos.z = (float)manipCamera.lookAt.z;
+//                RigidBody.pos.x = (float)manipCamera.lookAt.x;
+//                RigidBody.pos.y = (float)manipCamera.lookAt.y;
+//                RigidBody.pos.z = (float)manipCamera.lookAt.z;
+                                 //       System.err.println("selected point = " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][1]) + " " + Trunk(selectedpoint.toParent[3][2]));
+                RigidBody.pos.x = (float)selectedpoint.toParent[3][0];
+                RigidBody.pos.y = (float)selectedpoint.toParent[3][1];
+                RigidBody.pos.z = (float)selectedpoint.toParent[3][2];
+
                 RigidBody.wind.set(RigidBody.pos);
                 RigidBody.wind.x -= (float)manipCamera.location.x;
                 RigidBody.wind.y -= (float)manipCamera.location.y;
diff --git a/FrameSelector.java b/FrameSelector.java
index 08538f9..aee02d6 100644
--- a/FrameSelector.java
+++ b/FrameSelector.java
@@ -25,7 +25,7 @@
         
       //  System.err.println("Select Frame # " + frame);
    //     frame %= (getNumFrames() - mocap.offset);
-        if (!link2master) // freeze current value
+        if (!Link2Support()) // freeze current value
             frame = (int)((getNumFrames() - mocap.GetFirstFrame()) * realframe);
       //  System.err.println("Select Frame modulo # " + frame);
         boolean waslive = mocap.live;
diff --git a/GenericJoint.java b/GenericJoint.java
index 3724371..0ea1429 100644
--- a/GenericJoint.java
+++ b/GenericJoint.java
@@ -492,7 +492,7 @@
                 
                 tc.getFrameOffsetB(trans);
                         
-                if (c == 8) // DEBUG
+                if (false) //c == 8) // DEBUG
                 {
                 gl.glDisable(gl.GL_LIGHTING);
                 
diff --git a/GroupEditor.java b/GroupEditor.java
index bed60d6..0ef6314 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -741,8 +741,6 @@
 		morphItem.addActionListener(this);
                 
 		menu.add("-");
-		physicsItem = menu.add(new MenuItem("Physics"));
-		physicsItem.addActionListener(this);
 		frameselectorItem = menu.add(new MenuItem("Frame Selector"));
 		frameselectorItem.addActionListener(this);
 		scriptNodeItem = menu.add(new MenuItem("Script Node"));
@@ -1981,12 +1979,14 @@
                 
 //		particleItem = menu.add(new MenuItem("Particle system"));
 //		particleItem.addActionListener(this);
-        if (Globals.ADVANCED)
+        //if (Globals.ADVANCED)
         {
 		ragdollItem = menu.add(new MenuItem("Rag Walk"));
 		ragdollItem.addActionListener(this);
 		ragdoll2Item = menu.add(new MenuItem("Rag Fall"));
 		ragdoll2Item.addActionListener(this);
+		physicsItem = menu.add(new MenuItem("Physics"));
+		physicsItem.addActionListener(this);
         }
 		menu.add("-");
 		meshItem = menu.add(new MenuItem("Dynamic Mesh"));
diff --git a/Merge.java b/Merge.java
index 0bbe248..4629155 100644
--- a/Merge.java
+++ b/Merge.java
@@ -126,7 +126,7 @@
         
         bRep = null;
         
-        if (link2master)
+        if (Link2Support())
             renderme(); // null);
     }
     
@@ -144,7 +144,7 @@
         if (bRep == null && GetObject() != null)
             renderme(); // display); // only once
         
-        if (/*display.LIVE && live &&*/link2master) // && display.drawMode == display.SHADOW) // SHADOW!!!
+        if (/*display.LIVE && live &&*/Link2Support()) // && display.drawMode == display.SHADOW) // SHADOW!!!
         {
             try
             {
diff --git a/Mocap.java b/Mocap.java
index 32c8f73..cbbed79 100644
--- a/Mocap.java
+++ b/Mocap.java
@@ -998,7 +998,7 @@
         
         get(0).link2master = path.size() > 1; // hip orientation
         
-        if (get(0).link2master)
+        if (get(0).Link2Support())
         {
             rotateonce = 2;
         }
@@ -1427,7 +1427,7 @@
         double w = 0.00015;
 
         //if (!sourcenode.link2master) // strong pin on floor
-        if (parent.link2master) // strong pin on floor
+        if (parent.Link2Support()) // strong pin on floor
         {
             w = 0.005; // .001;
         }
@@ -1641,7 +1641,7 @@
 //            sourcenode.parent.toParent[3][1] = ground - floor.y;
 //            sourcenode.parent.toParent[3][2] += groundz - floor.z;
 //            sourcenode.parent.toParent[3][1] = K * (ground - floor.y) + (1 - K) * oldposy;
-            if (footcontact && (sourcenode.parent != null && !sourcenode.parent.link2master)) // strong pin on floor
+            if (footcontact && (sourcenode.parent != null && !sourcenode.parent.Link2Support())) // strong pin on floor
             {
         v0.x = groundx - floor.x;
         v0.y = 0; // groundx - floor.x;
@@ -2006,7 +2006,7 @@
 //        if (sourcenode.link2master)
 //        if (goalx != 0 || goalz != 0)
 //            K = 0.02; // .0625;
-        if (parent.link2master) // strong pin on floor
+        if (parent.Link2Support()) // strong pin on floor
         {
             K = 0.05; // 0.02;
         }
@@ -2423,9 +2423,9 @@
 //            SetBreakPoint(get(0).toParent[0], 0);
 //        }
         
-        boolean setrotation = get(0).link2master && !firsttimeafterload && frame > 0;
+        boolean setrotation = get(0).Link2Support() && !firsttimeafterload && frame > 0;
         boolean setposition = sourcenode != null && // sourcenode.parent != null && // july 2014
-                              sourcenode./*parent.*/link2master && !firsttimeafterload && frame > 0;
+                              sourcenode./*parent.*/Link2Support() && !firsttimeafterload && frame > 0;
         
 //        cVector centroid = new cVector();
 //        cVector floor = new cVector();
@@ -2858,7 +2858,7 @@
 
                 // set translation
                 // (currently only possible for root bone! see mocapdata.com data)
-                if (bone._isRoot && link2master) // && !GetFileRoot().link2master)
+                if (bone._isRoot && Link2Support()) // && !GetFileRoot().link2master)
                 {
                     if (hasTranslation) // && _translationEnabled)
                     {
diff --git a/ObjEditor.java b/ObjEditor.java
index c8eff94..216b8ba 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -558,7 +558,7 @@
 //                        }
 //                    }
 //                }
-                cameraView.transformMode = objectTabbedPane.getSelectedIndex() == 5;
+                cameraView.transformMode = objectTabbedPane.getSelectedIndex() == transformTabIndex;
                 
 //                refreshContents(false); // To refresh Info tab
                 cameraView.repaint();
@@ -1421,7 +1421,7 @@
         randomCB = AddCheckBox(setupPanel2, "Random", copy.random);
         randomCB.setToolTipText("Randomly Rewind (or Go back and forth)");
 
-        link2masterCB = AddCheckBox(setupPanel2, GetSupportText(), copy.link2master);
+        link2masterCB = AddCheckBox(setupPanel2, GetSupportText(), copy.Link2Support());
         link2masterCB.setToolTipText("Link to support");
         
         if (Globals.ADVANCED)
@@ -1600,6 +1600,8 @@
     }
     
     int objectTabCount;
+    
+    int transformTabIndex;
 
     void SetupViews()
     {
@@ -1792,12 +1794,15 @@
         objectTabbedPane.add(materialPanel);
         objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/material.png"));
         objectTabbedPane.setToolTipTextAt(objectTabCount++, "Material");
-    
+
+        if (Globals.ADVANCED)
+        {
         figurePanel = new cGridBag();
         figurePanel.add(new cButton("FIGURES and POSES coming soon!"));
         objectTabbedPane.add(figurePanel);
         objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/figure.png"));
         objectTabbedPane.setToolTipTextAt(objectTabCount++, "Figures and poses");
+        }
                 
 //        JPanel north = new JPanel(new BorderLayout());
 //        north.setName("Edit");
@@ -1806,7 +1811,8 @@
         objectTabbedPane.add(editPanel);
         objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/writewhite.png"));
         objectTabbedPane.setToolTipTextAt(objectTabCount++, "Edit controls");
-        
+
+        transformTabIndex = objectTabCount;
         objectTabbedPane.add(transformPanel);
         objectTabbedPane.setIconAt(objectTabCount, GetIcon("icons/XYZ.png"));
         objectTabbedPane.setToolTipTextAt(objectTabCount++, "TRS transform");
@@ -2037,6 +2043,52 @@
 
         fullscenePanel.Return();
         
+        fullscenePanel.add(fullsceneButton = GetButton("fullscenes/urbanfuture3.png", !Globals.NIMBUSLAF));
+        fullsceneButton.setToolTipText("Urban Future!");
+        fullsceneButton.addActionListener(new ActionListener()
+        {
+                @Override
+                public void actionPerformed(ActionEvent e)
+                {
+                    ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/uf3.gfd", new iCallBack()
+                    {
+
+                        public void Callback(Object obj)
+                        {
+                            LoadIt(obj);
+                        }
+
+                        public void DragGesture()
+                        {
+                        }
+                    });
+                }
+        });
+
+        fullscenePanel.add(fullsceneButton = GetButton("fullscenes/urbanfuture4.png", !Globals.NIMBUSLAF));
+        fullsceneButton.setToolTipText("Street Level!");
+        fullsceneButton.addActionListener(new ActionListener()
+        {
+                @Override
+                public void actionPerformed(ActionEvent e)
+                {
+                    ReadGFD("https://www.noaofarc.ca/akeeba/categories/Applications/uf4.gfd", new iCallBack()
+                    {
+
+                        public void Callback(Object obj)
+                        {
+                            LoadIt(obj);
+                        }
+
+                        public void DragGesture()
+                        {
+                        }
+                    });
+                }
+        });
+
+        fullscenePanel.Return();
+        
         fullscenePanel.add(new cGridBag());
         fullscenePanel.add(new cGridBag());
         fullscenePanel.Return();
diff --git a/Object3D.java b/Object3D.java
index 10bff2f..0bb1b02 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -100,7 +100,7 @@
         other.softtouched = softtouched;
         
         other.random = random;
-        other.link2master = link2master;
+        other.link2master = Link2Support();
         other.transformcount = transformcount;
         other.marked = marked;
         other.skip = skip;
@@ -220,7 +220,7 @@
             return;
 
         transientsupport = support;
-        transientlink2master = link2master;
+        transientlink2master = Link2Support();
 
         support = null;
         link2master = false;
@@ -633,7 +633,10 @@
     transient boolean keepdontselect;
     boolean dontselect = false;
     boolean hide = false;
+    
     boolean link2master = false; // performs reset support/master at each frame (cannot rename due to serialization)
+    boolean link2support = false; // (cannot rename due to serialization)
+    
     boolean marked = false; // animation node
     boolean skip = false; // centroid issue
     boolean skipmocap = false; // mocap data
@@ -6154,7 +6157,7 @@
     boolean NeedSupport()
     {
         return
-                CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
+                CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && Link2Support() && /*live &&*/ support != null
                  // PROBLEM with CROWD!!
                     && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
     }
@@ -6177,6 +6180,11 @@
         return live && bRep != null;
     }
     
+    boolean Link2Support()
+    {
+        return link2master || link2support;
+    }
+    
     static cVector minima = new cVector();
     static cVector maxima = new cVector();
     static javax.vecmath.Point3d center = new javax.vecmath.Point3d();
@@ -6190,7 +6198,7 @@
         //    System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
         }
         
-        if (live && link2master && support == null && !this.marked) // project on ground
+        if (live && Link2Support() && support == null && !this.marked) // project on ground
         {
             getBounds(minima, maxima, true);
             center.x = (minima.x + maxima.x) / 2;
@@ -6265,7 +6273,7 @@
             support = support;
         
         boolean usecalllists = !IsDynamic() &&
-                                    IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
+                                    IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !Link2Support()); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
         //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
         
         //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
@@ -6373,7 +6381,7 @@
         {
             if (display.DrawMode() == iCameraPane.SHADOW)
             {
-                if (!link2master // tricky to cull in shadow mode.
+                if (!Link2Support() // tricky to cull in shadow mode.
                          && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
                 {
                     //System.out.print("CULLED");
@@ -6846,7 +6854,7 @@
 
         //javax.media.opengl.GL gl = display.GetGL();
 
-        if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
+        if (CameraPane.BOXMODE && !Link2Support()) //selected) // || CameraPane.movingcamera)
         {
             int fc = bRep.FaceCount();
             int vc = bRep.VertexCount();
@@ -8917,7 +8925,7 @@
         
         boolean touch = false;
         
-        if (bRep != null && link2master)
+        if (bRep != null && Link2Support())
         {
             if (bbox == null)
             {
diff --git a/RandomNode.java b/RandomNode.java
index 5551439..dfacf3a 100644
--- a/RandomNode.java
+++ b/RandomNode.java
@@ -36,7 +36,7 @@
     
     boolean IsSwitch()
     {
-        return CameraPane.SWITCH && !this.link2master;
+        return CameraPane.SWITCH && !this.Link2Support();
     }
     
     public int size()
diff --git a/SwitchNode.java b/SwitchNode.java
index edfdfe0..0494a66 100644
--- a/SwitchNode.java
+++ b/SwitchNode.java
@@ -63,7 +63,7 @@
             {
                 countspeed = speed;
                 
-                if (toggleneutral || !link2master)
+                if (toggleneutral || !Link2Support())
                 {
                     do
                     {
diff --git a/cTreeModel.java b/cTreeModel.java
index 85f893d..f8513de 100644
--- a/cTreeModel.java
+++ b/cTreeModel.java
@@ -96,7 +96,7 @@
                 r = 192;
             }
 
-            if (obj.link2master)
+            if (obj.Link2Support())
             {
                 b = 192;
             }
diff --git a/fullscenes/urbanfuture3.png b/fullscenes/urbanfuture3.png
new file mode 100644
index 0000000..7916977
--- /dev/null
+++ b/fullscenes/urbanfuture3.png
Binary files differ
diff --git a/fullscenes/urbanfuture4.png b/fullscenes/urbanfuture4.png
new file mode 100644
index 0000000..a74aa95
--- /dev/null
+++ b/fullscenes/urbanfuture4.png
Binary files differ

--
Gitblit v1.6.2