From bed42c663d286d76a32f155049f9efabc2fdb73f Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 28 Apr 2019 20:48:43 -0400
Subject: [PATCH] New UI proto

---
 GroupEditor.java |  948 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 568 insertions(+), 380 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 4fa02b1..a2fec77 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -219,6 +219,8 @@
 		resetsupportItem.addActionListener(this);
 		linkverticesItem = menu.add(new MenuItem("Link to Support"));
 		linkverticesItem.addActionListener(this);
+		relinkverticesItem = menu.add(new MenuItem("Re-link to Support"));
+		relinkverticesItem.addActionListener(this);
 		setMasterItem = menu.add(new MenuItem("Set Master Mesh"));
 		setMasterItem.addActionListener(this);
                 
@@ -231,6 +233,10 @@
 		frontItem.addActionListener(this);
 		compositeItem = menu.add(new MenuItem("Composite"));
 		compositeItem.addActionListener(this);
+		hideItem = menu.add(new MenuItem("Hide"));
+		hideItem.addActionListener(this);
+		ungroupItem = menu.add(new MenuItem("Ungroup"));
+		ungroupItem.addActionListener(this);
 		menu.add("-");
 		randomItem = menu.add(new MenuItem("Random"));
 		randomItem.addActionListener(this);
@@ -252,6 +258,8 @@
 		oe.menuBar.add(menu = new Menu("Object"));
 		textureItem = menu.add(new MenuItem("Texture"));
 		textureItem.addActionListener(this);
+		billboardItem = menu.add(new MenuItem("Billboard"));
+		billboardItem.addActionListener(this);
 		csgItem = menu.add(new MenuItem("CSG"));
 		csgItem.addActionListener(this);
                 shadowXItem = menu.add(new MenuItem("Shadow X"));
@@ -269,14 +277,12 @@
 		pointflowItem = menu.add(new MenuItem("Point Flow"));
 		pointflowItem.addActionListener(this);
 		menu.add("-");
-		transformgeometryItem = menu.add(new MenuItem("Transform Geometry"));
-		transformgeometryItem.addActionListener(this);
 		resetTransformItem = menu.add(new MenuItem("Reset Transform"));
 		resetTransformItem.addActionListener(this);
 		resetCentroidItem = menu.add(new MenuItem("Reset Centroid"));
 		resetCentroidItem.addActionListener(this);
-		ungroupItem = menu.add(new MenuItem("Ungroup"));
-		ungroupItem.addActionListener(this);
+		transformgeometryItem = menu.add(new MenuItem("Transform Geometry"));
+		transformgeometryItem.addActionListener(this);
                 
 		oe.menuBar.add(menu = new Menu("Geometry"));
 		genUVItem = menu.add(new MenuItem("Generate UV"));
@@ -287,6 +293,8 @@
 		genNormalsCADItem.addActionListener(this);
 		genNormalsMESHItem = menu.add(new MenuItem("Mesh Normals"));
 		genNormalsMESHItem.addActionListener(this);
+		genNormalsMINEItem = menu.add(new MenuItem("My Normals"));
+		genNormalsMINEItem.addActionListener(this);
 		stripifyItem = menu.add(new MenuItem("Stripify"));
 		stripifyItem.addActionListener(this);
 		unstripifyItem = menu.add(new MenuItem("Unstripify"));
@@ -426,76 +434,24 @@
         oe.buttonGroup.add(dummyButton);
          */
                 aConstraints.gridy += 1;
+                
+                //this.AddOptions(oe.toolbarPanel, oe.aConstraints);
+                
 		oe.aConstraints.gridwidth = 1;
         	oe.aConstraints.gridx = 0;
                 
-                oe.toolbarPanel.add(liveCB = new cCheckBox("Live", CameraPane.isLIVE()), oe.aConstraints);
+                oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE()), oe.aConstraints);
+                liveCB.setToolTipText("Enabled animation");
                                 liveCB.addItemListener(this);
 
         	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT), oe.aConstraints);
-                                supportCB.addItemListener(this);
-
-        //	oe.aConstraints.gridx += 1;
-        //        oe.toolbarPanel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), oe.aConstraints);
-        //                        localCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(crowdCB = new cCheckBox("Crowd", CameraPane.CROWD), oe.aConstraints);
-                                crowdCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(smoothCB = new cCheckBox("Inertia", CameraPane.INERTIA), oe.aConstraints);
-                                smoothCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST), oe.aConstraints);
-                                fastCB.addItemListener(this);
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE), oe.aConstraints);
-                                slowCB.addItemListener(this);
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(boxCB = new cCheckBox("Box", CameraPane.FAST), oe.aConstraints);
-                                boxCB.addItemListener(this);
-
-//        	oe.aConstraints.gridx += 1;
-//                oe.toolbarPanel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), oe.aConstraints);
-//                                speakerMocapCB.addItemListener(this);
-
-            if (false)
-            {
-                // handled in scripts
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(speakerCameraCB = new cCheckBox("Cam", CameraPane.SPEAKERCAMERA), oe.aConstraints);
-                                speakerCameraCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(speakerFocusCB = new cCheckBox("Focus", CameraPane.SPEAKERFOCUS), oe.aConstraints);
-                                speakerFocusCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS), oe.aConstraints);
-                                smoothfocusCB.addItemListener(this);
-            }
-
-//oe.aConstraints.gridx += 1;
-//oe.toolbarPanel.add(debugCB = new cCheckBox("Debug", CameraPane.DEBUG), oe.aConstraints);
-//                debugCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(oeilCB = new cCheckBox("O", CameraPane.OEIL), oe.aConstraints);
-                                oeilCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(lookAtCB = new cCheckBox("T", CameraPane.LOOKAT), oe.aConstraints);
-                                lookAtCB.addItemListener(this);
-
-        	oe.aConstraints.gridx += 1;
-                oe.toolbarPanel.add(trackCB = new cCheckBox(":", CameraPane.TRACK), oe.aConstraints);
+                oe.toolbarPanel.add(trackCB = new cCheckBox("Track", CameraPane.TRACK), oe.aConstraints);
+                trackCB.setToolTipText("Enable tracking");
                                 trackCB.addItemListener(this);
 
         	oe.aConstraints.gridx += 1;
 		oe.toolbarPanel.add(screenfitButton = new cButton("@ ")); //, oe.aConstraints);
+                screenfitButton.setToolTipText("Screen fit");
 		screenfitButton.addActionListener(this);
 			oe.aConstraints.gridx += 1;
 //		oe.toolbarPanel.add(screenfitpointButton = new cButton(" @+ ")); //, oe.aConstraints);
@@ -503,6 +459,7 @@
 //			oe.aConstraints.gridx += 1;
 		oe.toolbarPanel.add(snapobjectButton = new cButton(" O+ ")); //, oe.aConstraints);
 		snapobjectButton.addActionListener(this);
+                snapobjectButton.setToolTipText("Snap Object");
 			oe.aConstraints.gridx += 1;
 
                 //aConstraints.gridx = 0;
@@ -511,28 +468,39 @@
 		oe.aConstraints.gridwidth = 1;
 		
 		oe.toolbarPanel.add(flashSelectionButton = new cButton(" ? ")); //, oe.aConstraints);
+                flashSelectionButton.setToolTipText("Show selection");
 		flashSelectionButton.addActionListener(this);
+                
+		oe.toolbarPanel.add(new cButton("     ", false));
+                
 		oe.aConstraints.gridx += 1;
 		oe.aConstraints.weighty = 0;
 		oe.aConstraints.gridwidth = 1;
                 
                 //
 		oe.toolbarPanel.add(twoButton = new cButton(" |+| ")); //, oe.aConstraints);
+                twoButton.setToolTipText("Show center view only");
 		twoButton.addActionListener(this);
 		oe.toolbarPanel.add(fourButton = new cButton("+|| ")); //, oe.aConstraints);
 		fourButton.addActionListener(this);
+                fourButton.setToolTipText("Show left panel only");
 		oe.toolbarPanel.add(sixButton = new cButton("+|+| ")); //, oe.aConstraints);
+                sixButton.setToolTipText("2-column layout left");
 		sixButton.addActionListener(this);
 		oe.toolbarPanel.add(threeButton = new cButton(" |+|+")); //, oe.aConstraints);
+                threeButton.setToolTipText("2-column layout right");
 		threeButton.addActionListener(this);
 		oe.toolbarPanel.add(sevenButton = new cButton("+|+|+")); //, oe.aConstraints);
+                sevenButton.setToolTipText("3-column layout");
 		sevenButton.addActionListener(this);
                 //
 
-		oe.toolbarPanel.add(rootButton = new cButton(" o o o  E  ")); //, oe.aConstraints);
+		oe.toolbarPanel.add(rootButton = new cButton(" o o o ")); //, oe.aConstraints);
+                rootButton.setToolTipText("Edit object in new tab");
 		rootButton.addActionListener(this);
 			oe.aConstraints.gridx += 1;
 		oe.toolbarPanel.add(closeButton = new cButton("  X  ")); //, oe.aConstraints);
+                closeButton.setToolTipText("Close tab");
 		closeButton.addActionListener(this);
 		//oe.treePanel.add(clearButton = new cButton("X"), oe.aConstraints);
 		//clearButton.addActionListener(this);
@@ -635,17 +603,91 @@
         radio.layout = sevenButton;
         oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
 	}
+        
+        void AddOptions(JPanel panel, GridBagConstraints constraints)
+        {
+        	constraints.gridx = 0;
+        	constraints.gridy = 0;
+                panel.add(fastCB = new cCheckBox("Fast", CameraPane.FAST), constraints);
+                fastCB.setToolTipText("Fast mode");
+                                fastCB.addItemListener(this);
+        	constraints.gridy += 1;
+                panel.add(supportCB = new cCheckBox("Support", CameraPane.SUPPORT), constraints);
+                supportCB.setToolTipText("Enabled rigging");
+                                supportCB.addItemListener(this);
+
+        //	constraints.gridy += 1;
+        //        panel.add(localCB = new cCheckBox("Local", CameraPane.LOCALTRANSFORM), constraints);
+        //                        localCB.addItemListener(this);
+
+        	constraints.gridy += 1;
+                panel.add(crowdCB = new cCheckBox("Crowd", Globals.CROWD), constraints);
+                crowdCB.setToolTipText("Used for crowds");
+                                crowdCB.addItemListener(this);
+
+        	constraints.gridy += 1;
+                panel.add(smoothCB = new cCheckBox("Inertia", CameraPane.INERTIA), constraints);
+                smoothCB.setToolTipText("Snapping delay");
+                                smoothCB.addItemListener(this);
+
+        	constraints.gridy += 1;
+                panel.add(slowCB = new cCheckBox("Slow", CameraPane.SLOWPOSE), constraints);
+                slowCB.setToolTipText("Smooth interpolation");
+                                slowCB.addItemListener(this);
+        	constraints.gridy += 1;
+                panel.add(boxCB = new cCheckBox("Box", CameraPane.BOXMODE), constraints);
+                boxCB.setToolTipText("Display bounding boxes");
+                                boxCB.addItemListener(this);
+        	constraints.gridy += 1;
+                panel.add(zoomBoxCB = new cCheckBox("Zoom", CameraPane.ZOOMBOXMODE), constraints);
+                zoomBoxCB.setToolTipText("Display bounding boxes when moving the wheel");
+                                zoomBoxCB.addItemListener(this);
+
+//        	constraints.gridy += 1;
+//                panel.add(speakerMocapCB = new cCheckBox("Mocap", CameraPane.SPEAKERMOCAP), constraints);
+//                                speakerMocapCB.addItemListener(this);
+
+            if (false)
+            {
+                // handled in scripts
+        	constraints.gridy += 1;
+                panel.add(speakerCameraCB = new cCheckBox("Cam", CameraPane.SPEAKERCAMERA), constraints);
+                                speakerCameraCB.addItemListener(this);
+
+        	constraints.gridy += 1;
+                panel.add(speakerFocusCB = new cCheckBox("Focus", CameraPane.SPEAKERFOCUS), constraints);
+                                speakerFocusCB.addItemListener(this);
+
+        	constraints.gridy += 1;
+                panel.add(smoothfocusCB = new cCheckBox("Smooth", CameraPane.SMOOTHFOCUS), constraints);
+                                smoothfocusCB.addItemListener(this);
+            }
+
+//constraints.gridx += 1;
+//panel.add(debugCB = new cCheckBox("Debug", CameraPane.DEBUG), constraints);
+//                debugCB.addItemListener(this);
+
+        	constraints.gridy += 1;
+                panel.add(oeilCB = new cCheckBox("Eye", CameraPane.OEIL), constraints);
+                                oeilCB.addItemListener(this);
+
+        	constraints.gridy += 1;
+                panel.add(lookAtCB = new cCheckBox("Target", CameraPane.LOOKAT), constraints);
+                lookAtCB.setToolTipText("Look-at target");
+                                lookAtCB.addItemListener(this);
+
+        }
 	
         void EditObject(Object3D obj)
         {
-            cRadio dummyButton = new cRadio(obj.name);
-            dummyButton.SetObject(obj);
-            dummyButton.layout = sevenButton;
-            dummyButton.SetCamera(cameraView.renderCamera, false);
-            dummyButton.addActionListener(this);
-            radioPanel.add(dummyButton);
-            buttonGroup.add(dummyButton);
-            dummyButton.doClick();
+            cRadio radioButton = new cRadio(obj.name);
+            radioButton.SetObject(obj);
+            radioButton.layout = sevenButton;
+            radioButton.SetCamera(cameraView.renderCamera, false);
+            radioButton.addActionListener(this);
+            radioPanel.add(radioButton);
+            buttonGroup.add(radioButton);
+            radioButton.doClick();
         }
         void SetupViews(ObjEditor oe)
         {
@@ -665,6 +707,7 @@
         JCheckBox fastCB;
         JCheckBox slowCB;
         JCheckBox boxCB;
+        JCheckBox zoomBoxCB;
         JCheckBox trackCB;
         JCheckBox smoothfocusCB;
 //        JCheckBox speakerMocapCB;
@@ -707,8 +750,7 @@
                     dropAttributes |= Object3D.TEXTURE;
                 else
                     dropAttributes &= ~Object3D.TEXTURE;
-            }
-            else if(e.getSource() == liveCB)
+            } else if(e.getSource() == liveCB)
             {
                 cameraView.ToggleLive();
             }
@@ -745,6 +787,10 @@
                 Recompile();
         cameraView.repaint();
 //                refreshContents();
+            }
+            else if(e.getSource() == zoomBoxCB)
+            {
+                cameraView.ToggleZoomBoxMode();
             }
             else if(e.getSource() == smoothfocusCB)
             {
@@ -1035,6 +1081,8 @@
 		torusItem.addActionListener(this);
 		superItem = menu.add(new MenuItem("Superellipsoid"));
 		superItem.addActionListener(this);
+		kleinItem = menu.add(new MenuItem("Klein Bottle"));
+		kleinItem.addActionListener(this);
 		particleItem = menu.add(new MenuItem("Particle system"));
 		particleItem.addActionListener(this);
 		ragdollItem = menu.add(new MenuItem("Rag Walk"));
@@ -1108,6 +1156,8 @@
 		resetParentItem.addActionListener(this);
 		repairParentItem = menu.add(new MenuItem("Repair Parent"));
 		repairParentItem.addActionListener(this);
+		repairShadowItem = menu.add(new MenuItem("Repair Shadow"));
+		repairShadowItem.addActionListener(this);
 		menu.add(invariantsItem = new MenuItem("Invariants"));
 		invariantsItem.addActionListener(this);
 		menu.add(recompileItem = new MenuItem("Recompile"));
@@ -1468,6 +1518,7 @@
 //
         public void actionPerformed(ActionEvent event) // , Object arg)
 	{
+                Object source = event.getSource();
             /*
 		if (event.getSource() == nameField)
 		{
@@ -1479,11 +1530,11 @@
 		}
                 else
              */
-		if (event.getSource() == lookAtItem || event.getSource() == lookFromItem)
+		if (source == lookAtItem || source == lookFromItem)
 		{
                     ScreenFit();
                 } else
-		if (event.getSource() == switchItem)
+		if (source == switchItem)
 		{
 			cVector v1 = new cVector();
 			cVector v2 = new cVector();
@@ -1492,11 +1543,11 @@
 			objEditor.cameraView.renderCamera.setAim(v2, v1);
 			objEditor.cameraView.repaint();
 		} else
-		if (event.getSource() == rectoidItem)
+		if (source == rectoidItem)
 		{
 			makeSomething(new Box());
 		} else
-		if (event.getSource() == particleItem)
+		if (source == particleItem)
 		{
         ParticleNode particleGeom = new ParticleNode("Particles", 1000); //, particleType);
         ParticleController particleController = new ParticleController(particleGeom);
@@ -1517,9 +1568,9 @@
         applyExample(particleGeom, "SMOKE");
 			makeSomething(particleGeom);
 		} else
-		if (event.getSource() == ragdollItem || event.getSource() == ragdoll2Item)
+		if (source == ragdollItem || source == ragdoll2Item)
 		{
-                    GenericJoint ragdoll = new GenericJoint(event.getSource() == ragdollItem);
+                    GenericJoint ragdoll = new GenericJoint(source == ragdollItem);
                     
                     ragdoll.toParent = LA.newMatrix();
                     ragdoll.fromParent = LA.newMatrix();
@@ -1537,7 +1588,7 @@
 		} else
                     /*
                      */
-		if (event.getSource() == heightFieldItem)
+		if (source == heightFieldItem)
 		{
                     Object3D obj = new Object3D();
                     
@@ -1575,27 +1626,31 @@
                     
                     makeSomething(obj);
 		} else
-		if (event.getSource() == gridItem)
+		if (source == gridItem)
 		{
 			makeSomething(new Grid());
 		} else
-		if (event.getSource() == ellipsoidItem)
+		if (source == ellipsoidItem)
 		{
 			makeSomething(new Sphere());
 		} else
-		if (event.getSource() == coneItem)
+		if (source == coneItem)
 		{
 			makeSomething(new Cone());
 		} else
-		if (event.getSource() == torusItem)
+		if (source == torusItem)
 		{
 			makeSomething(new Torus());
 		} else
-		if (event.getSource() == superItem)
+		if (source == superItem)
 		{
 			makeSomething(new Superellipsoid());
 		} else
-		if (event.getSource() == blobItem)
+		if (source == kleinItem)
+		{
+			makeSomething(new Klein());
+		} else
+		if (source == blobItem)
 		{
 			Blob blob = new Blob();
 			BlobComponent comp = new BlobComponent();
@@ -1603,15 +1658,15 @@
 			//blob.retile();
 			makeSomething(blob);
 		} else
-		if (event.getSource() == latheItem)
+		if (source == latheItem)
 		{
 			makeSomething(new Lathe());
 		} else
-		if (event.getSource() == bezierItem)
+		if (source == bezierItem)
 		{
 			makeSomething(new BezierSurface());
 		} else
-		if (event.getSource() == checkerItem)
+		if (source == checkerItem)
 		{
                     /*
 			Object3D obj = new BezierSurface(5,8);
@@ -1626,7 +1681,7 @@
                      */
 			makeSomething(new Checker());
 		} else
-		if (event.getSource() == meshItem)
+		if (source == meshItem)
 		{
                     Object3D itemtomake = new Object3D();
                     Object3D child;
@@ -1647,35 +1702,35 @@
                         makeSomething(child);
                     }
 		} else
-		if (event.getSource() == springItem)
+		if (source == springItem)
 		{
 			cSpring s = new cSpring();
                         s.setup();
 			makeSomething(s);
 		} else
-		if (event.getSource() == flagItem)
+		if (source == flagItem)
 		{
 			cSpring s = new cFlag();
                         s.setup();
 			makeSomething(s);
 		} else
-		if (event.getSource() == lightItem)
+		if (source == lightItem)
 		{
 			makeSomething(new Light());
 		} else
-		if (event.getSource() == csgItem)
+		if (source == csgItem)
 		{
 			group(new CSG());
 		} else
-		if (event.getSource() == templateItem)
+		if (source == templateItem)
 		{
 			group(new cTemplate());
 		} else
-		if (event.getSource() == attributeItem)
+		if (source == attributeItem)
 		{
 			makeSomething(new Attribute());
 		} else
-		if (event.getSource() == pointflowItem)
+		if (source == pointflowItem)
 		{
 			makeSomething(new PointFlow());
 		} else
@@ -1687,7 +1742,7 @@
 		} else
                      */
                     
-		if (event.getSource() == superLoopItem)
+		if (source == superLoopItem)
 		{
                         Composite g = new cGroup();
                         for (int i=0; i<15; i++)
@@ -1709,7 +1764,7 @@
                             
 			group(g);
 		} else
-		if (event.getSource() == loopItem)
+		if (source == loopItem)
 		{
                         Composite csg = new GroupLeaf();
                         csg.count = 5;
@@ -1718,7 +1773,7 @@
                         csg.addChild(child);
                         child.addChild(csg);
 		} else
-		if (event.getSource() == doubleItem)
+		if (source == doubleItem)
 		{
                         Composite csg = new GroupLeaf();
                         csg.count = 5;
@@ -1730,7 +1785,7 @@
                         csg.addChild(child);
                         child.addChild(csg);
 		} else
-		if (event.getSource() == tripleItem)
+		if (source == tripleItem)
 		{
                         Composite csg = new GroupLeaf();
                         csg.count = 4;
@@ -1746,70 +1801,70 @@
                         child.addChild(csg);
 		} else
                     
-		if (event.getSource() == importGFDItem)
+		if (source == importGFDItem)
 		{
 			ImportGFD();
 		} else
-		if (event.getSource() == importVRMLX3DItem)
+		if (source == importVRMLX3DItem)
 		{
 			ImportVRMLX3D();
 		} else
-		if (event.getSource() == import3DSItem)
+		if (source == import3DSItem)
 		{
 			objEditor.ImportJME(new com.jmex.model.converters.MaxToJme(), "3ds", "Import 3DS");
 		} else
-		if (event.getSource() == importOBJItem)
+		if (source == importOBJItem)
 		{
 			objEditor.ImportJME(new com.jmex.model.converters.ObjToJme(), "obj", "Import OBJ");
 		} else
-		if (event.getSource() == computeAOItem)
+		if (source == computeAOItem)
 		{
-                    CameraPane.drawMode = CameraPane.OCCLUSION;
-                    CameraPane.theRenderer.repaint();
+                    Globals.drawMode = CameraPane.OCCLUSION;
+                    Globals.theRenderer.repaint();
 		} else
-		if (event.getSource() == recompileItem)
+		if (source == recompileItem)
 		{
                     Recompile();
                     refreshContents();
 		} else
-		if (event.getSource() == editScriptItem)
+		if (source == editScriptItem)
 		{
                     OpenDialog();
                     refreshContents();
 		} else
-		if (event.getSource() == invariantsItem)
+		if (source == invariantsItem)
 		{
                     System.out.println("Invariants:");
-                    GrafreeD.theApplet3D.universe.invariants();
+                    GrafreeD.grafreeD.universe.invariants();
 		} else
-		if (event.getSource() == memoryItem)
+		if (source == memoryItem)
 		{
                     //System.out.println("Invariants:");
                     PrintMemory();
 		} else
-		if (event.getSource() == pathItem)
+		if (source == pathItem)
 		{
                     PrintPath();
 		} else
-		if (event.getSource() == analyzeItem)
+		if (source == analyzeItem)
 		{
                     AnalyzeObject();
 		} else
-		if (event.getSource() == dumpItem)
+		if (source == dumpItem)
 		{
                     DumpObject();
 		} else
-		if (event.getSource() == screenfitButton)
+		if (source == screenfitButton)
 		{
 			//Reload(lastConverter, lastFilename, true);
                     ScreenFit();
 		} else
-		if (event.getSource() == screenfitpointButton)
+		if (source == screenfitpointButton)
 		{
 			//Reload(lastConverter, lastFilename, true);
                     ScreenFitPoint();
 		} else
-		if (event.getSource() == snapobjectButton)
+		if (source == snapobjectButton)
 		{
 			//Reload(lastConverter, lastFilename, true);
                     SnapObject();
@@ -1820,13 +1875,13 @@
 //                    Recompile();
 //                    refreshContents();
 //		} else
-		if (event.getSource() == gcButton)
+		if (source == gcButton)
 		{
                     System.out.println("Memory (F/T/M) : " + Runtime.getRuntime().freeMemory() + "/" + Runtime.getRuntime().totalMemory() + "/" + Runtime.getRuntime().maxMemory());
                     System.gc();
                     System.out.println("GC Memory (F/T/M) : " + Runtime.getRuntime().freeMemory() + "/" + Runtime.getRuntime().totalMemory() + "/" + Runtime.getRuntime().maxMemory());
 		} else
-		if (event.getSource() == editLeafItem)
+		if (source == editLeafItem)
 		{
                     Object3D obj;
                     for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -1840,62 +1895,62 @@
                     }
                     refreshContents(true);
 		} else
-		if (event.getSource() == openWindowItem)
+		if (source == openWindowItem)
 		{
 			EditSelection(true);
 		} else
-		if (event.getSource() == cutItem || event.getSource() == clearButton)
+		if (source == cutItem || source == clearButton)
 		{
 			loadClipboard(true);
 		} else
-		if (event.getSource() == duplicateItem)
+		if (source == duplicateItem)
 		{
                     Object3D keep = GrafreeD.clipboard;
 			loadClipboard(false);
 			paste(false);
                     GrafreeD.clipboard = keep;
 		} else
-		if (event.getSource() == cloneItem)
+		if (source == cloneItem)
 		{
                     CloneSelection(false);
 		} else
-		if (event.getSource() == cloneSupportItem)
+		if (source == cloneSupportItem)
 		{
                     CloneSelection(true);
 		} else
-		if (event.getSource() == copyItem)
+		if (source == copyItem)
 		{
 			loadClipboard(false);
 		} else
-		if (event.getSource() == pasteItem)
+		if (source == pasteItem)
 		{
 			paste(false);
 		} else
-		if (event.getSource() == pasteLinkItem)
+		if (source == pasteLinkItem)
 		{
 			pasteInto(false);
 		} else
-		if (event.getSource() == pasteCloneItem)
+		if (source == pasteCloneItem)
 		{
 			pasteInto(true);
 		} else
-		if (event.getSource() == pasteExpandItem)
+		if (source == pasteExpandItem)
 		{
 			paste(true);
 		} else
-		if (event.getSource() == synchronizeItem)
+		if (source == synchronizeItem)
 		{
                     Overwrite(Object3D.TRANSFORM);
                 } else
-		if (event.getSource() == overwriteNameItem)
+		if (source == overwriteNameItem)
 		{
                     Overwrite(Object3D.NAME);
                 } else
-		if (event.getSource() == overwriteUVItem)
+		if (source == overwriteUVItem)
 		{
                     Overwrite(Object3D.UV);
                 } else
-		if (event.getSource() == overwriteMatItem)
+		if (source == overwriteMatItem)
 		{
                     /* july 2015
                     if ((dropAttributes & Object3D.TEXTURE) == 0)
@@ -1915,7 +1970,7 @@
                     
                     Overwrite(dropAttributes);
                 }
-		if (event.getSource() == overwriteGeoItem)
+		if (source == overwriteGeoItem)
 		{
                     Overwrite(Object3D.GEOMETRY);
 //                    if (/*group.selection.size() == 1 &&*/ GrafreeD.clipboard.size() == 1)
@@ -1932,7 +1987,7 @@
 //		refreshContents();
 //                    }
 		} else
-		if (event.getSource() == generateMeshItem)
+		if (source == generateMeshItem)
 		{
                     //if (group.selection.size() == 1)
 //                    for (int i=0; i<group.selection.size(); i++)
@@ -1943,7 +1998,7 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == extractGeometriesItem)
+		if (source == extractGeometriesItem)
 		{
                     boolean one = false;
                     
@@ -1970,7 +2025,7 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == cloneGeometriesItem)
+		if (source == cloneGeometriesItem)
 		{
                     boolean one = false;
                     
@@ -1996,32 +2051,37 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == shareGeometriesItem)
+		if (source == shareGeometriesItem)
 		{
                     boolean one = false;
                     
                     if (group.selection.size() == 1)
                         one = true;
 
+                    Object3D merge = null;
+                    
                     Object3D content = new cGroup();
                     
                     for (int i=0; i<group.selection.size(); i++)
                     {
-                        Object3D sel = new Merge(group.selection.get(i));
+                        merge = new Merge(group.selection.get(i));
                         
                         if (one)
-                            makeSomething(sel, false);
+                            makeSomething(merge, false);
                         else
-                            content.addChild(sel);
+                            content.addChild(merge);
                     }
                     
                     if (!one)
-                        makeSomething(content, false);
-                    
-                    ResetModel();
-                    refreshContents();
+                        makeSomething(content, true);
+                    else
+                    {
+                        ResetModel();
+                        Select(merge.GetTreePath(), true, false); // unselect... false);
+                        refreshContents();
+                    }
 		} else
-		if (event.getSource() == mergeGeometriesItem)
+		if (source == mergeGeometriesItem)
 		{
                     boolean one = false;
                     
@@ -2051,7 +2111,7 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == linkverticesItem)
+		if (source == linkverticesItem)
 		{
 //                    if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1)
 //                    {
@@ -2071,7 +2131,7 @@
                         if (content instanceof cGroup && ((cGroup)content).transientlink )
                             content = ((cGroup)content).get(0);
 
-            CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
+            Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR));
                         for (int i=0; i<group.selection.size(); i++)
                         {
                             boolean random = CameraPane.RANDOM;
@@ -2080,11 +2140,11 @@
                       //      group.selection.get(i).setMasterThis(content); // should be identity
                             CameraPane.RANDOM = random;
                         }
-            CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
+            Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
 		refreshContents();
                     }
 		} else
-		if (event.getSource() == resetsupportItem)
+		if (source == resetsupportItem)
 		{
                     for (int i=0; i<group.selection.size(); i++)
                     {
@@ -2096,7 +2156,16 @@
 
                     refreshContents();
 		} else
-		if (event.getSource() == resetreferencesItem)
+		if (source == relinkverticesItem)
+		{
+                    boolean random = CameraPane.RANDOM;
+                    CameraPane.RANDOM = false; // parse all random nodes
+                    group.selection.RelinkToSupport();
+                    CameraPane.RANDOM = random;
+
+                    refreshContents();
+		} else
+		if (source == resetreferencesItem)
 		{
                     for (int i=0; i<group.selection.size(); i++)
                     {
@@ -2105,7 +2174,7 @@
 
                     refreshContents();
 		} else
-		if (event.getSource() == setMasterItem)
+		if (source == setMasterItem)
 		{
                     if (group.selection.size() == 1 && GrafreeD.clipboard.size() == 1)
                     {
@@ -2118,7 +2187,7 @@
 		refreshContents();
                     }
 		} else
-		if (event.getSource() == poseMeshItem)
+		if (source == poseMeshItem)
 		{
                     if (group.selection.size() == 1)
                     {
@@ -2137,19 +2206,19 @@
                     }
                         
 		} else
-		if (event.getSource() == revertMeshItem)
+		if (source == revertMeshItem)
 		{
 			RevertMeshes();
 		} else
-		if (event.getSource() == resetMeshItem)
+		if (source == resetMeshItem)
 		{
 			ResetAll();
 		} else
-		if (event.getSource() == stepAllItem)
+		if (source == stepAllItem)
 		{
 			StepAll();
 		} else
-		if (event.getSource() == clearItem) // || event.getSource() == clearButton)
+		if (source == clearItem) // || event.getSource() == clearButton)
 		{
 			//int indices[] = jList.getSelectedIndices();
 			//for (int i = indices.length - 1; i >= 0; i--)
@@ -2157,42 +2226,46 @@
 
 			ClearSelection(false);
 		} else
-		if (event.getSource() == clearAllItem)
+		if (source == clearAllItem)
 		{
 			ClearSelection(true);
 		} else
-		if (event.getSource() == grabItem)
+		if (source == grabItem)
 		{
 			group(new cGroup(), true);
 		} else
-		if (event.getSource() == frontItem)
+		if (source == hideItem)
+		{
+			group(new HiddenObject());
+		} else
+		if (source == frontItem)
 		{
                     front();
 		} else
-		if (event.getSource() == backItem)
+		if (source == backItem)
 		{
                     back();
 		} else
-		if (event.getSource() == cameraItem)
+		if (source == cameraItem)
 		{
 			makeSomething(new Camera());
 		} else
-		if (event.getSource() == compositeItem)
+		if (source == compositeItem)
 		{
 			group(new Composite());
 		} else
-		if (event.getSource() == randomItem)
+		if (source == randomItem)
 		{
                         RandomNode random = new RandomNode();
 			group(random);
                         if (random.size() > 0)
                             random.name = random.get(0).name + "Rnd";
 		} else
-		if (event.getSource() == physicsItem)
+		if (source == physicsItem)
                 {
                     group(new PhysicsNode());
 		} else
-		if (event.getSource() == frameselectorItem)
+		if (source == frameselectorItem)
 		{
                     for (int i=0; i<group.selection.size(); i++)
                     {
@@ -2204,7 +2277,7 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == switchGeoItem)
+		if (source == switchGeoItem)
 		{
                     for (int i=0; i<group.selection.size(); i++)
                     {
@@ -2216,7 +2289,7 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == switchTransfoItem)
+		if (source == switchTransfoItem)
 		{
                     for (int i=0; i<group.selection.size(); i++)
                     {
@@ -2228,7 +2301,7 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == morphItem)
+		if (source == morphItem)
 		{
                     for (int i=0; i<group.selection.size(); i++)
                     {
@@ -2240,7 +2313,7 @@
                     ResetModel();
                     refreshContents();
 		} else
-		if (event.getSource() == scriptNodeItem)
+		if (source == scriptNodeItem)
 		{
                     boolean atleastone = false;
                     
@@ -2279,199 +2352,215 @@
                         }
                     }
 		} else
-		if (event.getSource() == linkerItem)
+		if (source == linkerItem)
 		{
 			group(new cLinker());
 		} else
-		if (event.getSource() == textureItem)
+		if (source == textureItem)
 		{
 			group(new TextureNode());
 		} else
-		if (event.getSource() == shadowXItem)
+		if (source == billboardItem)
+		{
+			group(new BillboardNode());
+		} else
+		if (source == shadowXItem)
 		{
 			CastShadow(0);
 		} else
-		if (event.getSource() == shadowYItem)
+		if (source == shadowYItem)
 		{
 			CastShadow(1);
 		} else
-		if (event.getSource() == shadowZItem)
+		if (source == shadowZItem)
 		{
 			CastShadow(2);
 		} else
-		if (event.getSource() == ungroupItem)
+		if (source == ungroupItem)
 		{
-			ungroup();
+			//ungroup();
+                    for (int i=0; i<group.selection.size(); i++)
+                    {
+                        Ungroup(group.selection.get(i));
+                    }
+
+                    ClearSelection(false);
+                    
+                    refreshContents();
 		} else
-		if (event.getSource() == genUVItem)
+		if (source == genUVItem)
                 {
 			GenUV();
 		} else
-		if (event.getSource() == genNormalsCADItem)
+		if (source == genNormalsCADItem)
                 {
 			GenNormals(true);
 		} else
-		if (event.getSource() == genNormalsMESHItem)
+		if (source == genNormalsMESHItem)
                 {
 			GenNormals(true); // TODO
 		} else
-		if (event.getSource() == genNormalsORGANItem)
+		if (source == genNormalsORGANItem)
                 {
 			GenNormals(false);
 		} else
-		if (event.getSource() == stripifyItem)
+		if (source == genNormalsMINEItem)
+                {
+			GenNormalsMINE();
+		} else
+		if (source == stripifyItem)
                 {
 			Stripify();
 		} else
-		if (event.getSource() == unstripifyItem)
+		if (source == unstripifyItem)
                 {
 			Unstripify();
 		} else
-		if (event.getSource() == trimItem)
+		if (source == trimItem)
                 {
 			Trim();
 		} else
-		if (event.getSource() == untrimItem)
+		if (source == untrimItem)
                 {
 			Untrim();
 		} else
-		if (event.getSource() == clearColorsItem)
+		if (source == clearColorsItem)
                 {
 			ClearColors();
 		} else
-		if (event.getSource() == clearMaterialsItem)
+		if (source == clearMaterialsItem)
                 {
 			ClearMaterials();
 		} else
-		if (event.getSource() == liveleavesItem)
+		if (source == liveleavesItem)
                 {
 			LiveLeaves(true);
 		} else
-		if (event.getSource() == unliveleavesItem)
+		if (source == unliveleavesItem)
                 {
 			LiveLeaves(false);
 		} else
-		if (event.getSource() == supportleavesItem)
+		if (source == supportleavesItem)
                 {
 			SupportLeaves(true);
 		} else
-		if (event.getSource() == unsupportleavesItem)
+		if (source == unsupportleavesItem)
                 {
 			SupportLeaves(false);
 		} else
-		if (event.getSource() == hideleavesItem)
+		if (source == hideleavesItem)
                 {
 			HideLeaves(true);
 		} else
-		if (event.getSource() == showleavesItem)
+		if (source == showleavesItem)
                 {
 			HideLeaves(false);
 		} else
-		if (event.getSource() == markleavesItem)
+		if (source == markleavesItem)
                 {
 			MarkLeaves(true);
 		} else
-		if (event.getSource() == unmarkleavesItem)
+		if (source == unmarkleavesItem)
                 {
 			MarkLeaves(false);
 		} else
-		if (event.getSource() == flipVItem)
+		if (source == flipVItem)
                 {
 			FlipV(true);
 		} else
-		if (event.getSource() == unflipVItem)
+		if (source == unflipVItem)
                 {
 			FlipV(false);
 		} else
-		if (event.getSource() == lowTexturesItem)
+		if (source == lowTexturesItem)
                 {
 			SetTexRes(0);
 		} else
-		if (event.getSource() == normalTexturesItem)
+		if (source == normalTexturesItem)
                 {
 			SetTexRes(1);
 		} else
-		if (event.getSource() == highTexturesItem)
+		if (source == highTexturesItem)
                 {
 			SetTexRes(2);
 		} else
-		if (event.getSource() == veryhighTexturesItem)
+		if (source == veryhighTexturesItem)
                 {
 			SetTexRes(3);
 		} else
-		if (event.getSource() == maxTexturesItem)
+		if (source == maxTexturesItem)
                 {
 			SetTexRes(4);
 		} else
-		if (event.getSource() == panoTexturesItem)
+		if (source == panoTexturesItem)
                 {
 			SetTexRes(5);
 		} else
-		if (event.getSource() == reverseNormalsItem)
+		if (source == reverseNormalsItem)
                 {
 			ReverseNormals();
 		} else
-		if (event.getSource() == parseverticesItem)
+		if (source == parseverticesItem)
                 {
 			ParseVertices();
 		} else
-		if (event.getSource() == textureFieldItem)
+		if (source == textureFieldItem)
                 {
 			TextureVertices();
 		} else
-		if (event.getSource() == alignItem)
+		if (source == alignItem)
                 {
 			Align();
 		} else
-		if (event.getSource() == mirrorItem)
+		if (source == mirrorItem)
                 {
 			MirrorPoses();
 		} else
-		if (event.getSource() == reduceMorphItem)
+		if (source == reduceMorphItem)
                 {
 			MeshReduction(false);
 		} else
-		if (event.getSource() == reduce34MorphItem)
+		if (source == reduce34MorphItem)
                 {
 			MeshReduction(true);
 		} else
-		if (event.getSource() == reverseTrianglesItem)
+		if (source == reverseTrianglesItem)
                 {
 			ReverseTriangles();
 		} else
-		if (event.getSource() == reduceMeshItem)
+		if (source == reduceMeshItem)
                 {
 			ReduceMesh(false);
 		} else
-		if (event.getSource() == reduce34MeshItem)
+		if (source == reduce34MeshItem)
                 {
 			ReduceMesh(true);
 		} else
-		if (event.getSource() == increaseMeshItem)
+		if (source == increaseMeshItem)
                 {
 			IncreaseMesh();
 		} else
-		if (event.getSource() == clipMeshItem)
+		if (source == clipMeshItem)
                 {
 			ClipMesh();
 		} else
-		if (event.getSource() == smoothMeshItem)
+		if (source == smoothMeshItem)
                 {
 			SmoothMesh();
 		} else
-		if (event.getSource() == transformgeometryItem)
+		if (source == transformgeometryItem)
 		{
                         TransformGeometry();
 		} else
-		if (event.getSource() == resetTransformItem)
+		if (source == resetTransformItem)
 		{
                         ResetTransform();
 		} else
-		if (event.getSource() == resetCentroidItem)
+		if (source == resetCentroidItem)
 		{
                         ResetCentroid();
 		} else
-		if (event.getSource() == resetParentItem)
+		if (source == resetParentItem)
 		{
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
 			{
@@ -2481,7 +2570,7 @@
 			
 			refreshContents();
 		} else
-		if (event.getSource() == repairParentItem)
+		if (source == repairParentItem)
 		{
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
 			{
@@ -2495,7 +2584,21 @@
 			
 			refreshContents();
 		} else
-		if (event.getSource() == sortbysizeItem)
+		if (source == repairShadowItem)
+		{
+			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
+			{
+				Object3D obj = (Object3D)e.nextElement();
+                                obj.RepairShadow();
+//                                for (int i=0; i<obj.size(); i++)
+//                                {
+//                                    obj.get(i).parent = obj;
+//                                }
+			}
+			
+			refreshContents();
+		} else
+		if (source == sortbysizeItem)
 		{
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
 			{
@@ -2507,7 +2610,7 @@
                         ResetModel();
 			refreshContents();
 		} else
-		if (event.getSource() == sortbynameItem)
+		if (source == sortbynameItem)
 		{
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
 			{
@@ -2519,7 +2622,7 @@
         		ResetModel();
 			refreshContents();
 		} else
-		if (event.getSource() == attachPigmentItem)
+		if (source == attachPigmentItem)
 		{
                     String texture = GetFile("Attach pigment");
 			Object3D obj;
@@ -2531,7 +2634,7 @@
 			
 			refreshContents();
 		} else
-		if (event.getSource() == detachPigmentItem)
+		if (source == detachPigmentItem)
 		{
 			Object3D obj;
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -2542,7 +2645,7 @@
 			
 			refreshContents();
 		} else
-		if (event.getSource() == attachBumpItem)
+		if (source == attachBumpItem)
 		{
                     String texture = GetFile("Attach bump");
 			Object3D obj;
@@ -2554,7 +2657,7 @@
 			
 			refreshContents();
 		} else
-		if (event.getSource() == detachBumpItem)
+		if (source == detachBumpItem)
 		{
 			Object3D obj;
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -2565,7 +2668,7 @@
 			
 			refreshContents();
 		} else
-		if (event.getSource() == pigmentBumpItem)
+		if (source == pigmentBumpItem)
 		{
 			Object3D obj;
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -2576,158 +2679,195 @@
 			
 			refreshContents();
 		} else
-		if (event.getSource() == flashSelectionButton)
+		if (source == flashSelectionButton)
 		{
 			CameraPane.flash = true;
 			refreshContents();
 		} else
-		if (event.getSource() == oneButton)
+		if (source == oneButton)
 		{
                 } else
-		if (event.getSource() == twoButton)
+		if (source == twoButton)
 		{
                     radio.layout = twoButton;
                     // bug
                     //gridPanel.setDividerLocation(1.0);
                     //bigPanel.setDividerLocation(0.0);
-                    bigThree.remove(jtp);
-                    bigThree.remove(cameraPanel);
-                    bigThree.remove(XYZPanel);
-                    aWindowConstraints.gridx = 0;
-                    aWindowConstraints.gridy = 0;
-                    aWindowConstraints.gridwidth = 1;
-            //        aConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.weighty = 1;
-                    //bigThree.add(jtp, aWindowConstraints);
-                    aWindowConstraints.weightx = 1;
-                    aWindowConstraints.gridwidth = 3;
-            //        aConstraints.gridheight = 3;
-                    aWindowConstraints.gridx = 1;
-                    aWindowConstraints.fill = GridBagConstraints.BOTH;
-                    bigThree.add(cameraPanel, aWindowConstraints);
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.gridx = 4;
-                    aWindowConstraints.gridwidth = 1;
-            //        aConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    //bigThree.add(XYZPanel, aWindowConstraints);
-                    bigThree.revalidate();
+//                    bigThree.remove(scenePanel);
+//                    bigThree.remove(centralPanel);
+//                    bigThree.remove(XYZPanel);
+//                    aWindowConstraints.gridx = 0;
+//                    aWindowConstraints.gridy = 0;
+//                    aWindowConstraints.gridwidth = 1;
+//            //        aConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.weighty = 1;
+//                    //bigThree.add(jtp, aWindowConstraints);
+//                    aWindowConstraints.weightx = 1;
+//                    aWindowConstraints.gridwidth = 3;
+//            //        aConstraints.gridheight = 3;
+//                    aWindowConstraints.gridx = 1;
+//                    aWindowConstraints.fill = GridBagConstraints.BOTH;
+//                    bigThree.add(centralPanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.gridx = 4;
+//                    aWindowConstraints.gridwidth = 1;
+//            //        aConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    //bigThree.add(XYZPanel, aWindowConstraints);
+//                    scenePanel.setVisible(false);
+//                    centralPanel.setVisible(true);
+//                    XYZPanel.setVisible(false);
+                    bigThree.ClearUI();
+                    bigThree.addComponent(centralPanel);
+                    bigThree.FlushUI();
                 } else
-		if (event.getSource() == threeButton)
+		if (source == threeButton)
 		{
                     radio.layout = threeButton;
-                    bigThree.remove(jtp);
-                    bigThree.remove(cameraPanel);
-                    bigThree.remove(XYZPanel);
-                    aWindowConstraints.gridx = 0;
-                    aWindowConstraints.gridy = 0;
-                    aWindowConstraints.gridwidth = 1;
-            //        aConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.weighty = 1;
-                    //bigThree.add(jtp, aWindowConstraints);
-                    aWindowConstraints.weightx = 1;
-                    aWindowConstraints.gridwidth = 3;
-            //        aConstraints.gridheight = 3;
-                    aWindowConstraints.gridx = 1;
-                    aWindowConstraints.fill = GridBagConstraints.BOTH;
-                    bigThree.add(cameraPanel, aWindowConstraints);
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.gridx = 4;
-                    aWindowConstraints.gridwidth = 1;
-            //        aConstraints.gridheight = 3;
-                    aConstraints.fill = GridBagConstraints.VERTICAL;
-                    bigThree.add(XYZPanel, aWindowConstraints);
-                    bigThree.revalidate();
+                    
+//                    bigThree.remove(scenePanel);
+//                    bigThree.remove(centralPanel);
+//                    bigThree.remove(XYZPanel);
+//                    aWindowConstraints.gridx = 0;
+//                    aWindowConstraints.gridy = 0;
+//                    aWindowConstraints.gridwidth = 1;
+//            //        aConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.weighty = 1;
+//                    //bigThree.add(jtp, aWindowConstraints);
+//                    aWindowConstraints.weightx = 1;
+//                    aWindowConstraints.gridwidth = 3;
+//            //        aConstraints.gridheight = 3;
+//                    aWindowConstraints.gridx = 1;
+//                    aWindowConstraints.fill = GridBagConstraints.BOTH;
+//                    bigThree.add(centralPanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.gridx = 4;
+//                    aWindowConstraints.gridwidth = 1;
+//            //        aConstraints.gridheight = 3;
+//                    aConstraints.fill = GridBagConstraints.VERTICAL;
+//                    bigThree.add(XYZPanel, aWindowConstraints);
+//                    bigThree.validate();
+//                    scenePanel.setVisible(false);
+//                    centralPanel.setVisible(true);
+//                    XYZPanel.setVisible(true);
+                    bigThree.ClearUI();
+                    bigThree.addComponent(centralPanel);
+                    bigThree.addComponent(XYZPanel);
+                    bigThree.FlushUI();
                 } else
-		if (event.getSource() == fourButton)
+		if (source == fourButton)
 		{
                     radio.layout = fourButton;
-                    bigThree.remove(jtp);
-                    bigThree.remove(cameraPanel);
-                    bigThree.remove(XYZPanel);
-                    aWindowConstraints.gridx = 0;
-                    aWindowConstraints.gridy = 0;
-                    aWindowConstraints.gridwidth = 1;
-              //      aWindowConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.BOTH;
-                    aWindowConstraints.weightx = 1;
-                    aWindowConstraints.weighty = 1;
-                    bigThree.add(jtp, aWindowConstraints);
-                    aWindowConstraints.weightx = 1;
-                    aWindowConstraints.gridwidth = 3;
-              //      aConstraints.gridheight = 3;
-                    aWindowConstraints.gridx = 1;
-                    aWindowConstraints.fill = GridBagConstraints.BOTH;
-                    //bigThree.add(cameraPanel, aWindowConstraints);
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.gridx = 4;
-                    aWindowConstraints.gridwidth = 1;
-              //      aWindowConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    //bigThree.add(XYZPanel, aWindowConstraints);
-                    bigThree.revalidate();
+                    
+//                    bigThree.remove(scenePanel);
+//                    bigThree.remove(centralPanel);
+//                    bigThree.remove(XYZPanel);
+//                    aWindowConstraints.gridx = 0;
+//                    aWindowConstraints.gridy = 0;
+//                    aWindowConstraints.gridwidth = 1;
+//              //      aWindowConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.BOTH;
+//                    aWindowConstraints.weightx = 1;
+//                    aWindowConstraints.weighty = 1;
+//                    bigThree.add(scenePanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 1;
+//                    aWindowConstraints.gridwidth = 3;
+//              //      aConstraints.gridheight = 3;
+//                    aWindowConstraints.gridx = 1;
+//                    aWindowConstraints.fill = GridBagConstraints.BOTH;
+//                    //bigThree.add(cameraPanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.gridx = 4;
+//                    aWindowConstraints.gridwidth = 1;
+//              //      aWindowConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    //bigThree.add(XYZPanel, aWindowConstraints);
+//                    bigThree.validate();
+//                    scenePanel.setVisible(true);
+//                    centralPanel.setVisible(false);
+//                    XYZPanel.setVisible(false);
+                    bigThree.ClearUI();
+                    bigThree.addComponent(scenePanel);
+                    bigThree.FlushUI();
                 } else
-		if (event.getSource() == sixButton)
+		if (source == sixButton)
 		{
                     radio.layout = sixButton;
-                    bigThree.remove(jtp);
-                    bigThree.remove(cameraPanel);
-                    bigThree.remove(XYZPanel);
-                    aWindowConstraints.gridx = 0;
-                    aWindowConstraints.gridy = 0;
-                    aWindowConstraints.gridwidth = 1;
-              //      aConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.weighty = 1;
-                    bigThree.add(jtp, aWindowConstraints);
-                    aWindowConstraints.weightx = 1;
-                    aWindowConstraints.gridwidth = 3;
-              //      aWindowConstraints.gridheight = 3;
-                    aWindowConstraints.gridx = 1;
-                    aWindowConstraints.fill = GridBagConstraints.BOTH;
-                    bigThree.add(cameraPanel, aWindowConstraints);
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.gridx = 4;
-                    aWindowConstraints.gridwidth = 1;
-              //      aWindowConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    //bigThree.add(XYZPanel, aConstraints);
-                    bigThree.revalidate();
+                    
+//                    bigThree.remove(scenePanel);
+//                    bigThree.remove(centralPanel);
+//                    bigThree.remove(XYZPanel);
+//                    aWindowConstraints.gridx = 0;
+//                    aWindowConstraints.gridy = 0;
+//                    aWindowConstraints.gridwidth = 1;
+//              //      aConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.weighty = 1;
+//                    bigThree.add(scenePanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 1;
+//                    aWindowConstraints.gridwidth = 3;
+//              //      aWindowConstraints.gridheight = 3;
+//                    aWindowConstraints.gridx = 1;
+//                    aWindowConstraints.fill = GridBagConstraints.BOTH;
+//                    bigThree.add(centralPanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.gridx = 4;
+//                    aWindowConstraints.gridwidth = 1;
+//              //      aWindowConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    //bigThree.add(XYZPanel, aConstraints);
+//                    bigThree.validate();
+//                    scenePanel.setVisible(true);
+//                    centralPanel.setVisible(true);
+//                    XYZPanel.setVisible(false);
+                    bigThree.ClearUI();
+                    bigThree.addComponent(scenePanel);
+                    bigThree.addComponent(centralPanel);
+                    bigThree.FlushUI();
                 } else
-		if (event.getSource() == sevenButton)
+		if (source == sevenButton)
 		{
                     radio.layout = sevenButton;
-                    bigThree.remove(jtp);
-                    bigThree.remove(cameraPanel);
-                    bigThree.remove(XYZPanel);
-                    aWindowConstraints.gridx = 0;
-                    aWindowConstraints.gridy = 0;
-                    aWindowConstraints.gridwidth = 1;
-               //     aWindowConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.weighty = 1;
-                    bigThree.add(jtp, aWindowConstraints);
-                    aWindowConstraints.weightx = 1;
-                    aWindowConstraints.gridwidth = 3;
-               //     aWindowConstraints.gridheight = 3;
-                    aWindowConstraints.gridx = 1;
-                    aWindowConstraints.fill = GridBagConstraints.BOTH;
-                    bigThree.add(cameraPanel, aWindowConstraints);
-                    aWindowConstraints.weightx = 0;
-                    aWindowConstraints.gridx = 4;
-                    aWindowConstraints.gridwidth = 1;
-               //     aConstraints.gridheight = 3;
-                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
-                    bigThree.add(XYZPanel, aWindowConstraints);
-                    bigThree.revalidate();
+                    
+//                    bigThree.remove(scenePanel);
+//                    bigThree.remove(centralPanel);
+//                    bigThree.remove(XYZPanel);
+//                    aWindowConstraints.gridx = 0;
+//                    aWindowConstraints.gridy = 0;
+//                    aWindowConstraints.gridwidth = 1;
+//               //     aWindowConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.weighty = 1;
+//                    bigThree.add(scenePanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 1;
+//                    aWindowConstraints.gridwidth = 3;
+//               //     aWindowConstraints.gridheight = 3;
+//                    aWindowConstraints.gridx = 1;
+//                    aWindowConstraints.fill = GridBagConstraints.BOTH;
+//                    bigThree.add(centralPanel, aWindowConstraints);
+//                    aWindowConstraints.weightx = 0;
+//                    aWindowConstraints.gridx = 4;
+//                    aWindowConstraints.gridwidth = 1;
+//               //     aConstraints.gridheight = 3;
+//                    aWindowConstraints.fill = GridBagConstraints.VERTICAL;
+//                    bigThree.add(XYZPanel, aWindowConstraints);
+//                    bigThree.validate();
+//                    scenePanel.setVisible(true);
+//                    centralPanel.setVisible(true);
+//                    XYZPanel.setVisible(true);
+                    bigThree.ClearUI();
+                    bigThree.addComponent(scenePanel);
+                    bigThree.addComponent(centralPanel);
+                    bigThree.addComponent(XYZPanel);
+                    bigThree.FlushUI();
                 } else
-		if (event.getSource() == rootButton)
+		if (source == rootButton)
 		{
                     Object3D obj;
                     for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
@@ -2739,7 +2879,7 @@
 
                     refreshContents(true);
 		} else
-		if (event.getSource() == closeButton)
+		if (source == closeButton)
 		{
 //System.out.println("CLOSE: " + buttonGroup.getSelection());
                     cRadio ab;
@@ -2760,11 +2900,11 @@
                     }
                     refreshContents(true);
 		} else
-		if (event.getSource() == editItem || event.getSource() == editButton)
+		if (source == editItem || source == editButton)
 		{
 			EditSelection(false);
 		} else
-		if (event.getSource() == uneditButton)
+		if (source == uneditButton)
 		{
 			for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
 			{
@@ -2781,7 +2921,7 @@
 			//objEditor.ResetSliders();
                     refreshContents(true);
 		} else
-		if (event.getSource() == clearPanelButton)
+		if (source == clearPanelButton)
 		{
                     assert(copy == group);
                     //copy.ClearUI();
@@ -2792,7 +2932,7 @@
                     listUI.clear();
                     refreshContents(true);
 		} else
-		if (event.getSource() == allParamsButton)
+		if (source == allParamsButton)
 		{
                     assert(copy == group);
                     
@@ -2813,19 +2953,19 @@
                         
                     refreshContents(true);
 		} else
-		if (event.getSource() == unselectButton)
+		if (source == unselectButton)
 		{
 			objEditor.jTree.clearSelection();
              // ?? oct 2012           GrafreeD.clipboard.clear();
 			objEditor.ResetSliders();
                     refreshContents(true);
 		} else
-                if(event.getSource() instanceof cRadio)
+                if(source instanceof cRadio)
 		{
                     group.parent = keepparent;
                         group.attributes = 0;
                     //group.editWindow = null;
-                    /*cRadio*/ radio = (cRadio)event.getSource();
+                    /*cRadio*/ radio = (cRadio)source;
                     Object3D obj = radio.GetObject();
                     System.out.println("Edit " + obj);
                     if (true) // obj instanceof Composite) // obj.parent == null) // obj instanceof Composite)
@@ -2845,7 +2985,7 @@
                     }
                     
                     copy = group;
-                    //CameraPane.theRenderer.object = group;
+                    //Globals.theRenderer.object = group;
                     if(!useclient)
                     {
                         cameraView.renderCamera = radio.camera;
@@ -2854,7 +2994,8 @@
                         cameraView.cameras[cameraView.cameracount] = radio.camera;
                         cameraView.targetLookAt.set(radio.camera.lookAt);
                         cameraView.object = group;
-                        cameraView.lighttouched = true;
+                        //cameraView.lighttouched = true;
+                        Globals.lighttouched = true;
                         topView.object = group;
                         frontView.object = group;
                         sideView.object = group;
@@ -2890,7 +3031,7 @@
             if (useclient)
             {
                 cameraView.object = client;
-                cameraView.lighttouched = true;
+                Globals.lighttouched = true;
                 //topView.object = client;
                 //frontView.object = client;
                 //sideView.object = client;
@@ -2898,7 +3039,7 @@
             else
             {
                 cameraView.object = group;
-                cameraView.lighttouched = true;
+                Globals.lighttouched = true;
                 //topView.object = group;
                 //frontView.object = group;
                 //sideView.object = group;
@@ -3179,6 +3320,13 @@
 		refreshContents();
 	}
 	
+	void GenNormalsMINE()
+	{
+		group.selection.GenNormalsMINE();
+		
+		refreshContents();
+	}
+	
 	void Stripify()
 	{
 		group.StripifyS();
@@ -3399,7 +3547,7 @@
                             String pigment = Object3D.GetPigment(tex);
                             //String bump = Object3D.GetBump(tex);
                             
-                            com.sun.opengl.util.texture.TextureData texturedata = CameraPane.theRenderer.GetTextureData(pigment, false, node.texres);
+                            com.sun.opengl.util.texture.TextureData texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);
                             
                             double s = v.s;
                             
@@ -3447,12 +3595,26 @@
         
 	void Align()
 	{
+            if (group.selection.size() == 0)
+                return;
+            
+            cVector bbmin = new cVector();
+            cVector bbmax = new cVector();
+            
+            group.selection.get(0).getBounds(bbmin, bbmax, true);
+            
+            double dx = bbmax.x - bbmin.x;
+            double dy = bbmax.y - bbmin.y;
+            double dz = bbmax.z - bbmin.z;
+            
+            double scale = Math.sqrt(dx*dx + dy*dy + dz*dz);
+            
             for (int i=0; i<group.selection.size(); i++)
             {
 		Object3D obj = group.selection.get(i);
                 
-                LA.matTranslate(obj.toParent, i/2f, 0, 0);
-                LA.matTranslateInv(obj.fromParent, -i/2f, 0, 0);
+                LA.matTranslate(obj.toParent, i * scale, 0, 0);
+                LA.matTranslateInv(obj.fromParent, -i * scale, 0, 0);
             }
             
             refreshContents();
@@ -3686,7 +3848,7 @@
             group.selection.RelinkToSupport(); // july 2014
             System.out.println("DONE.");
             refreshContents();
-        CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
+        Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
         }
         
 	void ReduceMesh(boolean reduction34)
@@ -3971,16 +4133,16 @@
 			
                         objEditor.SetText(); // jan 2014
                         
-			if (flashIt && !CameraPane.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera))
+			if (flashIt && !Globals.isLIVE() && tps != null && tps.length > 0 && !(((Object3D) tps[0].getLastPathComponent()) instanceof Camera))
 				CameraPane.flash = true;
                         
 			if (tps != null && tps.length > 0 && ((Object3D) tps[0].getLastPathComponent()) instanceof Camera)
                             // a camera
                         {
                             CameraPane.camerachangeframe = 0; // don't refuse it
-                            CameraPane.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
-                         //   CameraPane.theRenderer.renderCamera = CameraPane.theRenderer.manipCamera;
-                         //   CameraPane.theRenderer.eyeCamera = CameraPane.theRenderer.manipCamera;
+                            Globals.theRenderer.SetCamera((Camera) tps[0].getLastPathComponent());
+                         //   Globals.theRenderer.renderCamera = Globals.theRenderer.manipCamera;
+                         //   Globals.theRenderer.eyeCamera = Globals.theRenderer.manipCamera;
                         }
                             
 			refreshContents();
@@ -4474,6 +4636,26 @@
 		makeSomething(csg);
 	}
 	
+        void Ungroup(Object3D g)
+        {
+            if (g instanceof HiddenObject)
+            {
+                HiddenObject h = (HiddenObject) g;
+                
+                for (int i=0; i<h.ActualSize(); i++)
+                {
+                    objEditor.makeSomething(h.get(i), false);
+                }
+            }
+            else
+            {
+                for (int i=0; i<g.Size(); i++)
+                {
+                    objEditor.makeSomething(g.get(i), false);
+                }
+            }
+        }
+        
 	void ungroup()
 	{
             /*
@@ -4833,6 +5015,7 @@
 	private MenuItem resetsupportItem;
 	private MenuItem resetreferencesItem;
 	private MenuItem linkverticesItem;
+	private MenuItem relinkverticesItem;
 	private MenuItem setMasterItem;
 	private MenuItem resetMeshItem;
 	private MenuItem stepAllItem;
@@ -4854,6 +5037,7 @@
 	private MenuItem genNormalsMESHItem;
 	private MenuItem genNormalsCADItem;
 	private MenuItem genNormalsORGANItem;
+	private MenuItem genNormalsMINEItem;
 	private MenuItem stripifyItem;
 	private MenuItem unstripifyItem;
 	private MenuItem trimItem;
@@ -4895,6 +5079,7 @@
 	private MenuItem resetCentroidItem;
 	private MenuItem transformgeometryItem;
 	private MenuItem resetTransformItem;
+	private MenuItem hideItem;
 	private MenuItem grabItem;
 	private MenuItem backItem;
 	private MenuItem frontItem;
@@ -4915,6 +5100,7 @@
         
 	private MenuItem resetParentItem;
 	private MenuItem repairParentItem;
+	private MenuItem repairShadowItem;
 	private MenuItem sortbysizeItem;
 	private MenuItem sortbynameItem;
         
@@ -4935,6 +5121,7 @@
 	private MenuItem coneItem;
 	private MenuItem torusItem;
 	private MenuItem superItem;
+	private MenuItem kleinItem;
 	private MenuItem blobItem;
 	private MenuItem latheItem;
 	private MenuItem bezierItem;
@@ -4947,6 +5134,7 @@
 	private MenuItem csgItem;
 	private MenuItem templateItem;
 	private MenuItem textureItem;
+	private MenuItem billboardItem;
 	private MenuItem shadowXItem;
 	private MenuItem shadowYItem;
 	private MenuItem shadowZItem;

--
Gitblit v1.6.2