From e24558ddeacfc945b9e9ba0a32b552d04e2ed4dd Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 02 Jun 2019 20:11:20 -0400 Subject: [PATCH] Selectable mode + new mesh reduction. --- Object3D.java | 103 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 83 insertions(+), 20 deletions(-) diff --git a/Object3D.java b/Object3D.java index 76593d2..56b46d5 100644 --- a/Object3D.java +++ b/Object3D.java @@ -300,6 +300,7 @@ } boolean live = false; + boolean dontselect = false; boolean hide = false; boolean link2master = false; // performs reset support/master at each frame boolean marked = false; // animation node @@ -797,7 +798,7 @@ if (marked && Globals.isLIVE() && live && //TEMP21aug2018 - Globals.DrawMode() == iCameraPane.SHADOW && + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && currentframe != Globals.framecount) { currentframe = Globals.framecount; @@ -912,6 +913,11 @@ fromParent = null; // LA.newMatrix(); bRep = null; // new BoundaryRep(); + if (oname != null && oname.equals("LeftHand")) + { + name = oname; + } + /* float hue = (float)Math.random(); Color col; @@ -954,7 +960,7 @@ public Object clone() { - return GrafreeD.clone(this); + return Grafreed.clone(this); } Object3D copyExpand() @@ -1470,7 +1476,7 @@ BoundaryRep.SEUIL = other.material.cameralight; // Set default to 0.1 - BoundaryRep.SEUIL /= 2; + BoundaryRep.SEUIL /= 4; // 2; System.out.println("SEUIL = " + BoundaryRep.SEUIL); } @@ -1729,7 +1735,7 @@ Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); o.bRep = transientrep; if (clone) - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); o.CreateMaterial(); o.SetAttributes(this, -1); //parent @@ -1742,7 +1748,7 @@ Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); o.bRep = bRep; if (clone) - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); + o.bRep = (BoundaryRep) Grafreed.clone(bRep); o.CreateMaterial(); //o.overwriteThis(this, -1); o.SetAttributes(this, -1); @@ -1829,12 +1835,15 @@ if (obj.name == null) continue; // can't be a null one + // Try perfect match first. if (n.equals(obj.name)) { theobj = obj; count++; } } + + // not needed: n = n.split(":")[0]; // Poser generates a count if (count != 1) for (int i=Size(); --i>=0;) @@ -2983,6 +2992,33 @@ blockloop = false; } + void TransformChildren() + { + if (toParent != null) + { + for (int i=Size(); --i>=0;) + { + Object3D v = get(i); + + if (v.toParent == null) + { + v.toParent = LA.newMatrix(); + v.fromParent = LA.newMatrix(); + } + +// LA.matConcat(v.toParent, toParent, v.toParent); +// LA.matConcat(fromParent, v.fromParent, v.fromParent); + LA.matConcat(toParent, v.toParent, v.toParent); + LA.matConcat(v.fromParent, fromParent, v.fromParent); + } + + toParent = null; // LA.matIdentity(toParent); + fromParent = null; // LA.matIdentity(fromParent); + + Touch(); + } + } + void TransformGeometry() { Object3D obj = this; @@ -3204,9 +3240,11 @@ BoundaryRep sup = bRep.support; bRep.support = null; - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); // bRep.SplitInTwo(onlyone); // thread... - temprep.SplitInTwo(reduction34, onlyone); + + while(temprep.SplitInTwo(reduction34, onlyone)); + bRep = temprep; bRep.support = sup; Touch(); @@ -3728,7 +3766,7 @@ if (child == null) continue; - if (GrafreeD.RENDERME > 0) + if (Grafreed.RENDERME > 0) { if (child instanceof Merge) ((Merge)child).renderme(); @@ -3879,7 +3917,7 @@ if (child == null) continue; - if (GrafreeD.RENDERME > 0) + if (Grafreed.RENDERME > 0) { if (child instanceof Merge) ((Merge)child).renderme(); @@ -4074,7 +4112,7 @@ if (child == null) continue; - if (GrafreeD.RENDERME > 0) + if (Grafreed.RENDERME > 0) { if (child instanceof Merge) ((Merge)child).renderme(); @@ -4681,7 +4719,7 @@ cTreePath SelectLeaf(int indexcount, boolean deselect) { - if (hide) + if (hide || dontselect) return null; if (count <= 0) @@ -4707,7 +4745,7 @@ cTreePath Select(int indexcount, boolean deselect) { - if (hide) + if (hide || dontselect) return null; if (count <= 0) @@ -5377,9 +5415,9 @@ boolean NeedSupport() { return - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null // PROBLEM with CROWD!! - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); } static boolean DEBUG_SELECTION = false; @@ -5394,7 +5432,7 @@ } if (display.DrawMode() == iCameraPane.SELECTION && - hide) + (hide || dontselect)) return; if (name != null && name.contains("sclera")) @@ -5636,7 +5674,17 @@ tex = GetTextures(); } - display.BindTextures(tex, texres); + boolean failed = false; + + try + { + display.BindTextures(tex, texres); + } + catch (Exception e) + { + System.err.println("FAILED: " + this); + failed = true; + } if (!compiled) { @@ -5658,7 +5706,8 @@ } } - display.ReleaseTextures(tex); + if (!failed) + display.ReleaseTextures(tex); display.PopMaterial(this, selected); } @@ -5787,6 +5836,9 @@ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) + return; + if (hide) return; // shadow optimisation @@ -5911,6 +5963,9 @@ { if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) return; // no shadow for transparent objects + + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) + return; if (hide) return; @@ -7368,14 +7423,22 @@ //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); + + String objname; + if (false) //parent != null) { - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; } else { - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; } // + super.toString(); //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); + + if (!Globals.ADVANCED) + return objname; + + return objname + " " + System.identityHashCode(this); } public int hashCode() @@ -7567,7 +7630,7 @@ { assert(bRep != null); if (!(support instanceof GenericJoint)) // support.bRep != null) - GrafreeD.Assert(support.bRep == bRep.support); + Grafreed.Assert(support.bRep == bRep.support); } else { -- Gitblit v1.6.2