Normand Briere
2019-06-09 79d0f9a45d36656051a77a7b0837aa0318f81ee5
Object3D.java
....@@ -300,6 +300,7 @@
300300 }
301301
302302 boolean live = false;
303
+ boolean dontselect = false;
303304 boolean hide = false;
304305 boolean link2master = false; // performs reset support/master at each frame
305306 boolean marked = false; // animation node
....@@ -774,7 +775,7 @@
774775 if (step == 0)
775776 step = 1;
776777 if (maxcount == 0)
777
- maxcount = 2048; // 4;
778
+ maxcount = 128; // 2048; // 4;
778779 // if (acceleration == 0)
779780 // acceleration = 10;
780781 if (delay == 0) // serial
....@@ -797,7 +798,7 @@
797798
798799 if (marked && Globals.isLIVE() && live &&
799800 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
801
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
801802 currentframe != Globals.framecount)
802803 {
803804 currentframe = Globals.framecount;
....@@ -912,6 +913,11 @@
912913 fromParent = null; // LA.newMatrix();
913914 bRep = null; // new BoundaryRep();
914915
916
+ if (oname != null && oname.equals("LeftHand"))
917
+ {
918
+ name = oname;
919
+ }
920
+
915921 /*
916922 float hue = (float)Math.random();
917923 Color col;
....@@ -1470,7 +1476,7 @@
14701476 BoundaryRep.SEUIL = other.material.cameralight;
14711477
14721478 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1479
+ BoundaryRep.SEUIL /= 4; // 2;
14741480 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751481 }
14761482
....@@ -1829,12 +1835,15 @@
18291835 if (obj.name == null)
18301836 continue; // can't be a null one
18311837
1838
+ // Try perfect match first.
18321839 if (n.equals(obj.name))
18331840 {
18341841 theobj = obj;
18351842 count++;
18361843 }
18371844 }
1845
+
1846
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18381847
18391848 if (count != 1)
18401849 for (int i=Size(); --i>=0;)
....@@ -2983,6 +2992,33 @@
29832992 blockloop = false;
29842993 }
29852994
2995
+ void TransformChildren()
2996
+ {
2997
+ if (toParent != null)
2998
+ {
2999
+ for (int i=Size(); --i>=0;)
3000
+ {
3001
+ Object3D v = get(i);
3002
+
3003
+ if (v.toParent == null)
3004
+ {
3005
+ v.toParent = LA.newMatrix();
3006
+ v.fromParent = LA.newMatrix();
3007
+ }
3008
+
3009
+// LA.matConcat(v.toParent, toParent, v.toParent);
3010
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3011
+ LA.matConcat(toParent, v.toParent, v.toParent);
3012
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3013
+ }
3014
+
3015
+ toParent = null; // LA.matIdentity(toParent);
3016
+ fromParent = null; // LA.matIdentity(fromParent);
3017
+
3018
+ Touch();
3019
+ }
3020
+ }
3021
+
29863022 void TransformGeometry()
29873023 {
29883024 Object3D obj = this;
....@@ -3206,7 +3242,9 @@
32063242 bRep.support = null;
32073243 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32083244 // bRep.SplitInTwo(onlyone); // thread...
3209
- temprep.SplitInTwo(reduction34, onlyone);
3245
+
3246
+ while(temprep.SplitInTwo(reduction34, onlyone));
3247
+
32103248 bRep = temprep;
32113249 bRep.support = sup;
32123250 Touch();
....@@ -4681,7 +4719,7 @@
46814719
46824720 cTreePath SelectLeaf(int indexcount, boolean deselect)
46834721 {
4684
- if (hide)
4722
+ if (hide || dontselect)
46854723 return null;
46864724
46874725 if (count <= 0)
....@@ -4707,7 +4745,7 @@
47074745
47084746 cTreePath Select(int indexcount, boolean deselect)
47094747 {
4710
- if (hide)
4748
+ if (hide || dontselect)
47114749 return null;
47124750
47134751 if (count <= 0)
....@@ -5377,9 +5415,9 @@
53775415 boolean NeedSupport()
53785416 {
53795417 return
5380
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5418
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53815419 // PROBLEM with CROWD!!
5382
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5420
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53835421 }
53845422
53855423 static boolean DEBUG_SELECTION = false;
....@@ -5394,7 +5432,7 @@
53945432 }
53955433
53965434 if (display.DrawMode() == iCameraPane.SELECTION &&
5397
- hide)
5435
+ (hide || dontselect))
53985436 return;
53995437
54005438 if (name != null && name.contains("sclera"))
....@@ -5636,7 +5674,17 @@
56365674 tex = GetTextures();
56375675 }
56385676
5639
- display.BindTextures(tex, texres);
5677
+ boolean failed = false;
5678
+
5679
+ try
5680
+ {
5681
+ display.BindTextures(tex, texres);
5682
+ }
5683
+ catch (Exception e)
5684
+ {
5685
+ System.err.println("FAILED: " + this);
5686
+ failed = true;
5687
+ }
56405688
56415689 if (!compiled)
56425690 {
....@@ -5658,7 +5706,8 @@
56585706 }
56595707 }
56605708
5661
- display.ReleaseTextures(tex);
5709
+ if (!failed)
5710
+ display.ReleaseTextures(tex);
56625711
56635712 display.PopMaterial(this, selected);
56645713 }
....@@ -5787,6 +5836,9 @@
57875836
57885837 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57895838 {
5839
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5840
+ return;
5841
+
57905842 if (hide)
57915843 return;
57925844 // shadow optimisation
....@@ -5911,6 +5963,9 @@
59115963 {
59125964 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59135965 return; // no shadow for transparent objects
5966
+
5967
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5968
+ return;
59145969
59155970 if (hide)
59165971 return;
....@@ -6895,8 +6950,8 @@
68956950 // {
68966951 // CameraPane.Ymax = spoth;
68976952 // }
6898
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6899
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
6953
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
+ //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
69006955 spot.translate(0, -32);
69016956 info.g.setColor(Color.green);
69026957 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -6951,7 +7006,7 @@
69517006 startX = info.x;
69527007 startY = info.y;
69537008
6954
- hitSomething = 0;
7009
+ hitSomething = -1;
69557010 cVector origin = new cVector();
69567011 //LA.xformPos(origin, toParent, origin);
69577012 Rectangle spot = new Rectangle();
....@@ -7027,6 +7082,7 @@
70277082 //System.out.println("hitSomething = " + hitSomething);
70287083
70297084 double scale = 0.005f * info.camera.Distance();
7085
+
70307086 cVector xlate = new cVector();
70317087 //cVector xlate2 = new cVector();
70327088 switch (hitSomething)
....@@ -7175,24 +7231,27 @@
71757231
71767232 case hitScale: // scale
71777233 double hScale = (double) (info.x - centerPt.x) / 32;
7234
+ double sign = 1;
7235
+ if (hScale < 0)
7236
+ {
7237
+ sign = -1;
7238
+ }
7239
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71787240 if (hScale < 0.01)
71797241 {
7180
- hScale = 0.01;
7242
+ //hScale = 0.01;
71817243 }
7182
- hScale = Math.pow(hScale, scale * 50);
7183
- if (hScale < 0.01)
7184
- {
7185
- hScale = 0.01;
7186
- }
7244
+
71877245 double vScale = (double) (info.y - centerPt.y) / 32;
7188
- if (vScale < 0.01)
7246
+ sign = 1;
7247
+ if (vScale < 0)
71897248 {
7190
- vScale = 0.01;
7249
+ sign = -1;
71917250 }
7192
- vScale = Math.pow(vScale, scale * 50);
7251
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71937252 if (vScale < 0.01)
71947253 {
7195
- vScale = 0.01;
7254
+ //vScale = 0.01;
71967255 }
71977256 LA.matCopy(startMat, toParent);
71987257 /**/
....@@ -7203,17 +7262,24 @@
72037262 }
72047263 /**/
72057264
7265
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7266
+
7267
+ if (totalScale < 0.01)
7268
+ {
7269
+ totalScale = 0.01;
7270
+ }
7271
+
72067272 switch (info.pane.RenderCamera().viewCode)
72077273 {
72087274 case 3: // '\001'
72097275 if (modified)
72107276 {
72117277 //LA.matScale(toParent, 1, hScale, vScale);
7212
- LA.matScale(toParent, vScale, 1, 1);
7278
+ LA.matScale(toParent, totalScale, 1, 1);
72137279 } // vScale, 1);
72147280 else
72157281 {
7216
- LA.matScale(toParent, vScale, vScale, vScale);
7282
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
72177283 } // vScale, 1);
72187284 break;
72197285
....@@ -7221,10 +7287,10 @@
72217287 if (modified)
72227288 {
72237289 //LA.matScale(toParent, hScale, 1, vScale);
7224
- LA.matScale(toParent, 1, vScale, 1);
7290
+ LA.matScale(toParent, 1, totalScale, 1);
72257291 } else
72267292 {
7227
- LA.matScale(toParent, vScale, 1, vScale);
7293
+ LA.matScale(toParent, totalScale, 1, totalScale);
72287294 }
72297295 break;
72307296
....@@ -7232,10 +7298,10 @@
72327298 if (modified)
72337299 {
72347300 //LA.matScale(toParent, hScale, vScale, 1);
7235
- LA.matScale(toParent, 1, 1, vScale);
7301
+ LA.matScale(toParent, 1, 1, totalScale);
72367302 } else
72377303 {
7238
- LA.matScale(toParent, vScale, vScale, 1);
7304
+ LA.matScale(toParent, totalScale, totalScale, 1);
72397305 }
72407306 break;
72417307 }
....@@ -7368,14 +7434,22 @@
73687434 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73697435 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73707436 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7437
+
7438
+ String objname;
7439
+
73717440 if (false) //parent != null)
73727441 {
7373
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7442
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73747443 } else
73757444 {
7376
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7445
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73777446 } // + super.toString();
73787447 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7448
+
7449
+ if (!Globals.ADVANCED)
7450
+ return objname;
7451
+
7452
+ return objname + " " + System.identityHashCode(this);
73797453 }
73807454
73817455 public int hashCode()
....@@ -7616,9 +7690,9 @@
76167690 private static cVector edge2 = new cVector();
76177691 //private static cVector norm = new cVector();
76187692 /*transient private*/ int hitSomething;
7619
- private static final int hitCenter = 1;
7620
- private static final int hitScale = 2;
7621
- private static final int hitRotate = 3;
7693
+ static final int hitCenter = 1;
7694
+ static final int hitScale = 2;
7695
+ static final int hitRotate = 3;
76227696 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
76237697 /*transient*/ private Point centerPt;
76247698 /*transient*/ private int startX;