From e36047725ce3217618d4e5807ac7c8769b9e3598 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 17 Jun 2019 19:45:55 -0400 Subject: [PATCH] Split pigment bump. --- Object3D.java | 375 +++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 259 insertions(+), 116 deletions(-) diff --git a/Object3D.java b/Object3D.java index af581bd..d6e0e59 100644 --- a/Object3D.java +++ b/Object3D.java @@ -24,6 +24,11 @@ private UUID uuid = UUID.randomUUID(); + // TEMPORARY for mocap undo + mocap.reader.BVHReader.BVHResult bvh; + Object3D skeleton; + // + ScriptNode scriptnode; void InitOthers() @@ -104,117 +109,136 @@ // transient boolean reduced; // for morph reduction -transient com.bulletphysics.linearmath.Transform cache; // for fast merge -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge + transient com.bulletphysics.linearmath.Transform cache; // for fast merge + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge -transient Object3D transientsupport; // for cloning -transient boolean transientlink2master; + transient Object3D transientsupport; // for cloning + transient boolean transientlink2master; -void SaveSupports() -{ - if (blockloop) - return; + void SaveSupports() + { + if (blockloop) + return; - transientsupport = support; - transientlink2master = link2master; - - support = null; - link2master = false; - - if (bRep != null) - { - bRep.SaveSupports(); - } - - for (int i = 0; i < Size(); i++) - { - Object3D child = (Object3D) get(i); - if (child == null) - continue; - blockloop = true; - child.SaveSupports(); - blockloop = false; - } -} + transientsupport = support; + transientlink2master = link2master; -void RestoreSupports() -{ - if (blockloop) - return; + support = null; + link2master = false; - support = transientsupport; - link2master = transientlink2master; - transientsupport = null; - transientlink2master = false; - - if (bRep != null) - { - bRep.RestoreSupports(); - } - - for (int i = 0; i < Size(); i++) - { - Object3D child = (Object3D) get(i); - if (child == null) - continue; - blockloop = true; - child.RestoreSupports(); - blockloop = false; - } -} + if (bRep != null) + { + bRep.SaveSupports(); + } -void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) -{ - if (hashtable.containsKey(GetUUID())) - return; - - Object3D o = new Object3D(); - o.bRep = this.bRep; - if (this.bRep != null) - { - o.transientrep = this.bRep.support; - o.bRep.support = null; + for (int i = 0; i < Size(); i++) + { + Object3D child = (Object3D) get(i); + if (child == null) + continue; + blockloop = true; + child.SaveSupports(); + blockloop = false; + } } - -// o.support = this.support; -// o.fileparent = this.fileparent; -// if (this.bRep != null) -// o.bRep = this.bRep.support; - - hashtable.put(GetUUID(), o); - - this.bRep = null; -// if (this.bRep != null) -// this.bRep.support = null; -// this.support = null; -// this.fileparent = null; - - for (int i=0; i<Size(); i++) - { - get(i).ExtractBigData(hashtable); - } -} -void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) -{ - if (!hashtable.containsKey(GetUUID())) - return; - - Object3D o = hashtable.get(GetUUID()); - - this.bRep = o.bRep; - if (this.bRep != null) - this.bRep.support = o.transientrep; -// this.support = o.support; -// this.fileparent = o.fileparent; - - hashtable.remove(GetUUID()); - - for (int i=0; i<Size(); i++) + void RestoreSupports() { - get(i).RestoreBigData(hashtable); + if (blockloop) + return; + + support = transientsupport; + link2master = transientlink2master; + transientsupport = null; + transientlink2master = false; + + if (bRep != null) + { + bRep.RestoreSupports(); + } + + for (int i = 0; i < Size(); i++) + { + Object3D child = (Object3D) get(i); + if (child == null) + continue; + blockloop = true; + child.RestoreSupports(); + blockloop = false; + } } -} + + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) + { + if (hashtable.containsKey(GetUUID())) + { + Object3D o = hashtable.get(GetUUID()); + + Grafreed.Assert(this.bRep == o.bRep); + if (this.bRep != null) + assert(this.bRep.support == o.transientrep); + + return; + } + + Object3D o = new Object3D(); + + hashtable.put(GetUUID(), o); + + for (int i=0; i<Size(); i++) + { + get(i).ExtractBigData(hashtable); + } + + ExtractBigData(o); + } + + void ExtractBigData(Object3D o) + { + o.bRep = this.bRep; + if (this.bRep != null) + { + o.transientrep = this.bRep.support; + o.bRep.support = null; + } + + // o.support = this.support; + // o.fileparent = this.fileparent; + // if (this.bRep != null) + // o.bRep = this.bRep.support; + + this.bRep = null; + // if (this.bRep != null) + // this.bRep.support = null; + // this.support = null; + // this.fileparent = null; + } + + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) + { + if (!hashtable.containsKey(GetUUID())) + return; + + Object3D o = hashtable.get(GetUUID()); + + RestoreBigData(o); + + hashtable.remove(GetUUID()); + + for (int i=0; i<Size(); i++) + { + get(i).RestoreBigData(hashtable); + } + } + + void RestoreBigData(Object3D o) + { + this.bRep = o.bRep; + if (this.bRep != null) + this.bRep.support = o.transientrep; + // this.support = o.support; + // this.fileparent = o.fileparent; + } // MOCAP SUPPORT double tx,ty,tz,rx,ry,rz; @@ -539,12 +563,14 @@ toParent = LA.newMatrix(); fromParent = LA.newMatrix(); } + if (toParentMarked == null) { if (maxcount != 1) { new Exception().printStackTrace(); } + toParentMarked = LA.newMatrix(); fromParentMarked = LA.newMatrix(); } @@ -2685,6 +2711,18 @@ //Touch(); } + void GenNormalsMeshS() + { + selection.GenNormalsMesh(); +// for (int i=0; i<selection.size(); i++) +// { +// Object3D selectee = (Object3D) selection.elementAt(i); +// selectee.GenNormals(crease); +// } + + //Touch(); + } + void ClearColorsS() { selection.ClearColors(); @@ -2816,6 +2854,24 @@ if (child == null) continue; child.GenNormals(crease); +// Children().release(i); + } + blockloop = false; + } + + void GenNormalsMesh() + { + if (blockloop) + return; + + blockloop = true; + GenNormalsMesh0(); + for (int i = 0; i < Children().Size(); i++) + { + Object3D child = (Object3D) Children().get(i); // reserve(i); + if (child == null) + continue; + child.GenNormalsMesh(); // Children().release(i); } blockloop = false; @@ -2984,6 +3040,15 @@ if (bRep != null) { bRep.GenerateNormals(crease); + Touch(); + } + } + + void GenNormalsMesh0() + { + if (bRep != null) + { + bRep.GenerateNormalsMesh(); Touch(); } } @@ -4286,6 +4351,55 @@ } } + void RepairSOV() + { + if (blockloop) + return; + + String texname = this.GetPigmentTexture(); + + if (texname.startsWith("sov")) + { + String[] s = texname.split("/"); + + String[] sname = s[1].split("Color.pn"); + + texname = sname[0]; + + if (sname.length > 1) + { + texname += "Color.jpg"; + } + + this.SetPigmentTexture("sov/" + texname); + } + + texname = this.GetBumpTexture(); + + if (texname.startsWith("sov")) + { + String[] s = texname.split("/"); + + String[] sname = s[1].split("Bump.pn"); + + texname = sname[0]; + + if (sname.length > 1) + { + texname += "Bump.jpg"; + } + + this.SetBumpTexture("sov/" + texname); + } + + for (int i=0; i<Size(); i++) + { + blockloop = true; + get(i).RepairSOV(); + blockloop = false; + } + } + void RepairTexture() { if (this instanceof FileObject || blockloop) @@ -5509,12 +5623,23 @@ boolean NeedSupport() { return - CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null // PROBLEM with CROWD!! && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); } static boolean DEBUG_SELECTION = false; + + boolean IsLive() + { + if (live) + return true; + + if (parent == null) + return false; + + return parent.IsLive(); + } void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) { @@ -5577,7 +5702,7 @@ support = support; //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); + boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); if (!usecalllists && bRep != null && bRep.displaylist > 0) { @@ -5597,10 +5722,12 @@ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); if (!selectmode && //display.DrawMode() != display.SELECTION && - (touched || (bRep != null && bRep.displaylist <= 0))) + //(touched || (bRep != null && bRep.displaylist <= 0))) + (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0))) { Globals.lighttouched = true; } // all panes... + //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && (touched || (bRep != null && bRep.displaylist <= 0))) @@ -5768,16 +5895,27 @@ tex = GetTextures(); } - boolean failed = false; + boolean failedPigment = false; + boolean failedBump = false; try { - display.BindTextures(tex, texres); + display.BindPigmentTexture(tex, texres); } catch (Exception e) { System.err.println("FAILED: " + this); - failed = true; + failedPigment = true; + } + + try + { + display.BindBumpTexture(tex, texres); + } + catch (Exception e) + { + //System.err.println("FAILED: " + this); + failedBump = true; } if (!compiled) @@ -5800,8 +5938,11 @@ } } - if (!failed) - display.ReleaseTextures(tex); + if (!failedBump) + display.ReleaseBumpTexture(tex); + + if (!failedPigment) + display.ReleasePigmentTexture(tex); display.PopMaterial(this, selected); } @@ -7026,7 +7167,7 @@ spot.translate(32, 32); spotw = spot.x + spot.width; spoth = spot.y + spot.height; - info.g.setColor(Color.blue); + info.g.setColor(Color.cyan); info.g.fillRect(spot.x, spot.y, spot.width, spot.height); // if (CameraPane.Xmin > spot.x) // { @@ -7044,11 +7185,12 @@ // { // CameraPane.Ymax = spoth; // } - // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); - //info.g.drawLine(spotw, spoth, spotw - 15, spoth); + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 spot.translate(0, -32); - info.g.setColor(Color.green); + info.g.setColor(Color.yellow); info.g.fillRect(spot.x, spot.y, spot.width, spot.height); + info.g.setColor(Color.green); // if (CameraPane.Xmin > spot.x) // { // CameraPane.Xmin = spot.x; @@ -7366,19 +7508,20 @@ switch (info.pane.RenderCamera().viewCode) { case 3: // '\001' - if (modified) + if (modified || opposite) { //LA.matScale(toParent, 1, hScale, vScale); LA.matScale(toParent, totalScale, 1, 1); } // vScale, 1); else { + // EXCEPTION! LA.matScale(toParent, totalScale, totalScale, totalScale); } // vScale, 1); break; case 2: // '\002' - if (modified) + if (modified || opposite) { //LA.matScale(toParent, hScale, 1, vScale); LA.matScale(toParent, 1, totalScale, 1); @@ -7389,7 +7532,7 @@ break; case 1: // '\003' - if (modified) + if (modified || opposite) { //LA.matScale(toParent, hScale, vScale, 1); LA.matScale(toParent, 1, 1, totalScale); -- Gitblit v1.6.2