From 6ed65dcb597fb2153cef75bf1845978f1115658c Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Fri, 14 Dec 2018 22:53:55 -0500 Subject: [PATCH] Repair shadow, normal push + attractor mesh. --- Object3D.java | 155 ++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 132 insertions(+), 23 deletions(-) diff --git a/Object3D.java b/Object3D.java index ebab7df..8a39641 100644 --- a/Object3D.java +++ b/Object3D.java @@ -21,6 +21,19 @@ ScriptNode scriptnode; + void InitOthers() + { + if (projectedVertices == null || projectedVertices.length <= 2) + { + projectedVertices = new Object3D.cVector2[3]; + } + for (int i = 0; i < 3; i++) + { + projectedVertices[i] = new cVector2(); // Others + } + projectedVertices[0].x = 100; // bump + } + void MinMax(cVector minima, cVector maxima) { for (int xyz = 0; xyz < 3; xyz++) @@ -296,6 +309,8 @@ boolean speedup = false; boolean rewind = false; + float NORMALPUSH = 0; + Object3D support; Object3D GetObject() @@ -355,7 +370,7 @@ int MemorySize() { - if (memorysize == 0) + if (true) // memorysize == 0) { try { @@ -779,7 +794,10 @@ // factor = CameraPane.STEP; // } - if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount) + if (marked && CameraPane.isLIVE() && live && + //TEMP21aug2018 + CameraPane.drawMode == CameraPane.SHADOW && + currentframe != CameraPane.framecount) { currentframe = CameraPane.framecount; @@ -1446,7 +1464,16 @@ // if (other == null) // return; - System.out.println("Link support this = " + this + "; other = " + other); + if (other != null) + { + BoundaryRep.SEUIL = other.material.cameralight; + + // Set default to 0.1 + BoundaryRep.SEUIL /= 2; + System.out.println("SEUIL = " + BoundaryRep.SEUIL); + } + + System.out.println("Link this = " + this + "; support = " + other); //if (bRep != null) // bRep.linkVerticesThis(other.bRep); @@ -1816,8 +1843,9 @@ if (obj.name == null) continue; // can't be a null one - //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count - if (n.startsWith(obj.name)) + String name = obj.name.split(":")[0]; // Poser generates a count + //if (n.startsWith(obj.name)) + if (n.contains(name)) { theobj = obj; count++; @@ -2120,15 +2148,8 @@ if (/*parent != null &&*/ material == null) { material = new cMaterial(GetMaterial()); - if (projectedVertices == null || projectedVertices.length <= 2) - { - projectedVertices = new Object3D.cVector2[3]; - } - for (int i = 0; i < 3; i++) - { - projectedVertices[i] = new cVector2(); // Others - } - projectedVertices[0].x = 100; // bump + + InitOthers(); if (this instanceof Camera) { @@ -2732,6 +2753,24 @@ blockloop = false; } + void GenNormalsMINE() + { + if (blockloop) + return; + + blockloop = true; + GenNormalsMINE0(); + for (int i = 0; i < Children().Size(); i++) + { + Object3D child = (Object3D) Children().get(i); // reserve(i); + if (child == null) + continue; + child.GenNormalsMINE(); +// Children().release(i); + } + blockloop = false; + } + void ClearColors() { if (blockloop) @@ -2876,6 +2915,15 @@ if (bRep != null) { bRep.GenerateNormals(crease); + Touch(); + } + } + + void GenNormalsMINE0() + { + if (bRep != null) + { + bRep.GenerateNormalsMINE(); Touch(); } } @@ -4111,7 +4159,7 @@ if (blockloop) return; - for (int i=0; i<size(); i++) + for (int i=0; i<Size(); i++) { if (get(i).parent != this) { @@ -4120,6 +4168,22 @@ } blockloop = true; get(i).RepairParent(); + blockloop = false; + } + } + + void RepairShadow() + { + if (blockloop) + return; + + if (this.material != null) + this.InitOthers(); + + for (int i=0; i<Size(); i++) + { + blockloop = true; + get(i).RepairShadow(); blockloop = false; } } @@ -5921,7 +5985,7 @@ javax.media.opengl.GL gl = display.GetGL(); - if (CameraPane.BOXMODE) // || CameraPane.movingcamera) + if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) { int fc = bRep.FaceCount(); int vc = bRep.VertexCount(); @@ -6662,13 +6726,26 @@ gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z); } + // P + float x = (float)pv.x; + float y = (float)pv.y; + float z = (float)pv.z; + if (hasnorm) { // if (!pv.norm.normalized()) // assert(pv.norm.normalized()); //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); + float nx = (float)pv.norm.x; + float ny = (float)pv.norm.y; + float nz = (float)pv.norm.z; + + x += nx * NORMALPUSH; + y += ny * NORMALPUSH; + z += nz * NORMALPUSH; + + gl.glNormal3f(nx, ny, nz); } gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); SetColor(display, pv); @@ -6679,13 +6756,28 @@ else gl.glTexCoord2f((float) pv.s, (float) pv.t); //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); - gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z); + + gl.glVertex3f(x, y, z); + + // Q + x = (float)qv.x; + y = (float)qv.y; + z = (float)qv.z; + // Print(pv); if (hasnorm) { // assert(qv.norm.normalized()); //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); - gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z); + float nx = (float)qv.norm.x; + float ny = (float)qv.norm.y; + float nz = (float)qv.norm.z; + + x += nx * NORMALPUSH; + y += ny * NORMALPUSH; + z += nz * NORMALPUSH; + + gl.glNormal3f(nx, ny, nz); } //System.out.println("vertexq = " + qv.s + ", " + qv.t); // boolean locked = false; @@ -6709,16 +6801,31 @@ // } gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); SetColor(display, qv); + + gl.glVertex3f(x, y, z); //gl.glColor4f(r, g, b, 1); //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); - gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z); // Print(qv); + + // R + x = (float)rv.x; + y = (float)rv.y; + z = (float)rv.z; + if (hasnorm) { // assert(rv.norm.normalized()); //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); - gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); + float nx = (float)rv.norm.x; + float ny = (float)rv.norm.y; + float nz = (float)rv.norm.z; + + x += nx * NORMALPUSH; + y += ny * NORMALPUSH; + z += nz * NORMALPUSH; + + gl.glNormal3f(nx, ny, nz); } // if ((dot&4) == 0) @@ -6739,7 +6846,7 @@ //gl.glColor4f(r, g, b, 1); //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); - gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z); + gl.glVertex3f(x, y, z); // Print(rv); //gl.glEnd(); } @@ -7733,7 +7840,7 @@ if (parent == null) { System.out.println("NULL PARENT"); - new Exception().printStackTrace(); + //new Exception().printStackTrace(); } else { if (parent instanceof BezierPatch) @@ -8126,6 +8233,8 @@ { Object3D targ = this; + targ.NORMALPUSH = obj.NORMALPUSH; + if (obj.material != null) { if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL)) -- Gitblit v1.6.2