From 98896326eb94666451b7e419becfb5d721840313 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 10 Jun 2019 20:36:03 -0400 Subject: [PATCH] Fix shadow in light mode --- Object3D.java | 100 ++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 76 insertions(+), 24 deletions(-) diff --git a/Object3D.java b/Object3D.java index 56b46d5..2c2cf4d 100644 --- a/Object3D.java +++ b/Object3D.java @@ -14,11 +14,15 @@ import //weka.core. matrix.Matrix; +import java.util.UUID; + //import net.sourceforge.sizeof.SizeOf; public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> { //static final long serialVersionUID = -607422624994562685L; static final long serialVersionUID = 5022536242724664900L; + + private UUID uuid = UUID.randomUUID(); ScriptNode scriptnode; @@ -775,7 +779,7 @@ if (step == 0) step = 1; if (maxcount == 0) - maxcount = 2048; // 4; + maxcount = 128; // 2048; // 4; // if (acceleration == 0) // acceleration = 10; if (delay == 0) // serial @@ -5371,6 +5375,43 @@ } } + UUID GetUUID() + { + if (uuid == null) + { + // Serial + uuid = UUID.randomUUID(); + } + + return uuid; + } + + Object3D GetObject(UUID uid) + { + if (blockloop) + return null; + + if (GetUUID().equals(uid)) + return this; + + int nb = Size(); + for (int i = 0; i < nb; i++) + { + Object3D child = (Object3D) get(i); + + if (child == null) + continue; + + blockloop = true; + Object3D obj = child.GetObject(uid); + blockloop = false; + if (obj != null) + return obj; + } + + return null; + } + void SetBumpTexture(String tex) { if (GetTextures() == null) @@ -6950,8 +6991,8 @@ // { // CameraPane.Ymax = spoth; // } - info.g.drawLine(spotw, spoth, spotw, spoth - 15); - info.g.drawLine(spotw, spoth, spotw - 15, spoth); + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); + //info.g.drawLine(spotw, spoth, spotw - 15, spoth); spot.translate(0, -32); info.g.setColor(Color.green); info.g.fillRect(spot.x, spot.y, spot.width, spot.height); @@ -7006,7 +7047,7 @@ startX = info.x; startY = info.y; - hitSomething = 0; + hitSomething = -1; cVector origin = new cVector(); //LA.xformPos(origin, toParent, origin); Rectangle spot = new Rectangle(); @@ -7082,6 +7123,7 @@ //System.out.println("hitSomething = " + hitSomething); double scale = 0.005f * info.camera.Distance(); + cVector xlate = new cVector(); //cVector xlate2 = new cVector(); switch (hitSomething) @@ -7230,24 +7272,27 @@ case hitScale: // scale double hScale = (double) (info.x - centerPt.x) / 32; + double sign = 1; + if (hScale < 0) + { + sign = -1; + } + hScale = sign*Math.pow(sign*hScale, scale * 50); if (hScale < 0.01) { - hScale = 0.01; + //hScale = 0.01; } - hScale = Math.pow(hScale, scale * 50); - if (hScale < 0.01) - { - hScale = 0.01; - } + double vScale = (double) (info.y - centerPt.y) / 32; - if (vScale < 0.01) + sign = 1; + if (vScale < 0) { - vScale = 0.01; + sign = -1; } - vScale = Math.pow(vScale, scale * 50); + vScale = sign*Math.pow(sign*vScale, scale * 50); if (vScale < 0.01) { - vScale = 0.01; + //vScale = 0.01; } LA.matCopy(startMat, toParent); /**/ @@ -7258,17 +7303,24 @@ } /**/ + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); + + if (totalScale < 0.01) + { + totalScale = 0.01; + } + switch (info.pane.RenderCamera().viewCode) { case 3: // '\001' if (modified) { //LA.matScale(toParent, 1, hScale, vScale); - LA.matScale(toParent, vScale, 1, 1); + LA.matScale(toParent, totalScale, 1, 1); } // vScale, 1); else { - LA.matScale(toParent, vScale, vScale, vScale); + LA.matScale(toParent, totalScale, totalScale, totalScale); } // vScale, 1); break; @@ -7276,10 +7328,10 @@ if (modified) { //LA.matScale(toParent, hScale, 1, vScale); - LA.matScale(toParent, 1, vScale, 1); + LA.matScale(toParent, 1, totalScale, 1); } else { - LA.matScale(toParent, vScale, 1, vScale); + LA.matScale(toParent, totalScale, 1, totalScale); } break; @@ -7287,10 +7339,10 @@ if (modified) { //LA.matScale(toParent, hScale, vScale, 1); - LA.matScale(toParent, 1, 1, vScale); + LA.matScale(toParent, 1, 1, totalScale); } else { - LA.matScale(toParent, vScale, vScale, 1); + LA.matScale(toParent, totalScale, totalScale, 1); } break; } @@ -7431,7 +7483,7 @@ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; } else { - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; + 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(); @@ -7679,9 +7731,9 @@ private static cVector edge2 = new cVector(); //private static cVector norm = new cVector(); /*transient private*/ int hitSomething; - private static final int hitCenter = 1; - private static final int hitScale = 2; - private static final int hitRotate = 3; + static final int hitCenter = 1; + static final int hitScale = 2; + static final int hitRotate = 3; /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag /*transient*/ private Point centerPt; /*transient*/ private int startX; -- Gitblit v1.6.2