Normand Briere
2019-06-09 c5b599b48b333b34e554b464aefbca0b9bc66275
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;
....@@ -954,7 +960,7 @@
954960
955961 public Object clone()
956962 {
957
- return GrafreeD.clone(this);
963
+ return Grafreed.clone(this);
958964 }
959965
960966 Object3D copyExpand()
....@@ -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
....@@ -1729,7 +1735,7 @@
17291735 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301736 o.bRep = transientrep;
17311737 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1738
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331739 o.CreateMaterial();
17341740 o.SetAttributes(this, -1);
17351741 //parent
....@@ -1742,7 +1748,7 @@
17421748 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431749 o.bRep = bRep;
17441750 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1751
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461752 o.CreateMaterial();
17471753 //o.overwriteThis(this, -1);
17481754 o.SetAttributes(this, -1);
....@@ -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;)
....@@ -2300,6 +2309,7 @@
23002309 {
23012310 if (newWindow)
23022311 {
2312
+ new Exception().printStackTrace();
23032313 System.exit(0);
23042314 if (parent != null)
23052315 {
....@@ -2476,13 +2486,13 @@
24762486 return retval;
24772487 }
24782488
2479
- void doEditDrag(ClickInfo info)
2489
+ void doEditDrag(ClickInfo info, boolean opposite)
24802490 {
24812491 switch (doSomething)
24822492 {
24832493 case 1: // '\001'
24842494 //super.
2485
- doEditDrag0(info);
2495
+ doEditDrag0(info, opposite);
24862496 break;
24872497
24882498 case 2: // '\002'
....@@ -2495,11 +2505,11 @@
24952505 {
24962506 //sel.hitSomething = childToDrag.hitSomething;
24972507 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2508
+ sel.doEditDrag(info, opposite);
24992509 } else
25002510 {
25012511 //super.
2502
- doEditDrag0(info);
2512
+ doEditDrag0(info, opposite);
25032513 }
25042514 }
25052515 break;
....@@ -2982,6 +2992,33 @@
29822992 blockloop = false;
29832993 }
29842994
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
+
29853022 void TransformGeometry()
29863023 {
29873024 Object3D obj = this;
....@@ -3203,9 +3240,11 @@
32033240
32043241 BoundaryRep sup = bRep.support;
32053242 bRep.support = null;
3206
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3243
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32073244 // bRep.SplitInTwo(onlyone); // thread...
3208
- temprep.SplitInTwo(reduction34, onlyone);
3245
+
3246
+ while(temprep.SplitInTwo(reduction34, onlyone));
3247
+
32093248 bRep = temprep;
32103249 bRep.support = sup;
32113250 Touch();
....@@ -3727,7 +3766,7 @@
37273766 if (child == null)
37283767 continue;
37293768
3730
- if (GrafreeD.RENDERME > 0)
3769
+ if (Grafreed.RENDERME > 0)
37313770 {
37323771 if (child instanceof Merge)
37333772 ((Merge)child).renderme();
....@@ -3878,7 +3917,7 @@
38783917 if (child == null)
38793918 continue;
38803919
3881
- if (GrafreeD.RENDERME > 0)
3920
+ if (Grafreed.RENDERME > 0)
38823921 {
38833922 if (child instanceof Merge)
38843923 ((Merge)child).renderme();
....@@ -4073,7 +4112,7 @@
40734112 if (child == null)
40744113 continue;
40754114
4076
- if (GrafreeD.RENDERME > 0)
4115
+ if (Grafreed.RENDERME > 0)
40774116 {
40784117 if (child instanceof Merge)
40794118 ((Merge)child).renderme();
....@@ -4680,7 +4719,7 @@
46804719
46814720 cTreePath SelectLeaf(int indexcount, boolean deselect)
46824721 {
4683
- if (hide)
4722
+ if (hide || dontselect)
46844723 return null;
46854724
46864725 if (count <= 0)
....@@ -4706,7 +4745,7 @@
47064745
47074746 cTreePath Select(int indexcount, boolean deselect)
47084747 {
4709
- if (hide)
4748
+ if (hide || dontselect)
47104749 return null;
47114750
47124751 if (count <= 0)
....@@ -5158,10 +5197,34 @@
51585197
51595198 // System.out.println("Fullname = " + fullname);
51605199
5161
- if (fullname.name.indexOf(":") == -1)
5162
- return fullname.name;
5200
+ // Does not work on Windows due to C:
5201
+// if (fullname.name.indexOf(":") == -1)
5202
+// return fullname.name;
5203
+//
5204
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51635205
5164
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5206
+ String[] split = fullname.name.split(":");
5207
+
5208
+ if (split.length == 0)
5209
+ {
5210
+ return "";
5211
+ }
5212
+
5213
+ if (split.length <= 2)
5214
+ {
5215
+ if (fullname.name.endsWith(":"))
5216
+ {
5217
+ // Windows
5218
+ return fullname.name.substring(0, fullname.name.length()-1);
5219
+ }
5220
+
5221
+ return split[0];
5222
+ }
5223
+
5224
+ // Windows
5225
+ assert(split.length == 4);
5226
+
5227
+ return split[0] + ":" + split[1];
51655228 }
51665229
51675230 static String GetBump(cTexture fullname)
....@@ -5170,10 +5233,38 @@
51705233 return "";
51715234
51725235 // System.out.println("Fullname = " + fullname);
5173
- if (fullname.name.indexOf(":") == -1)
5174
- return "";
5175
-
5176
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5236
+ // Does not work on Windows due to C:
5237
+// if (fullname.name.indexOf(":") == -1)
5238
+// return "";
5239
+//
5240
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5241
+ String[] split = fullname.name.split(":");
5242
+
5243
+ if (split.length == 0)
5244
+ {
5245
+ return "";
5246
+ }
5247
+
5248
+ if (split.length == 1)
5249
+ {
5250
+ return "";
5251
+ }
5252
+
5253
+ if (split.length == 2)
5254
+ {
5255
+ if (fullname.name.endsWith(":"))
5256
+ {
5257
+ // Windows
5258
+ return "";
5259
+ }
5260
+
5261
+ return split[1];
5262
+ }
5263
+
5264
+ // Windows
5265
+ assert(split.length == 4);
5266
+
5267
+ return split[2] + ":" + split[3];
51775268 }
51785269
51795270 String GetPigmentTexture()
....@@ -5247,7 +5338,7 @@
52475338 System.out.print("; textures = " + textures);
52485339 System.out.println("; usedtextures = " + usedtextures);
52495340
5250
- if (GetTextures() == null)
5341
+ if (GetTextures() == null) // What is that??
52515342 GetTextures().name = ":";
52525343
52535344 String texname = tex;
....@@ -5324,9 +5415,9 @@
53245415 boolean NeedSupport()
53255416 {
53265417 return
5327
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5418
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53285419 // PROBLEM with CROWD!!
5329
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5420
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53305421 }
53315422
53325423 static boolean DEBUG_SELECTION = false;
....@@ -5341,7 +5432,7 @@
53415432 }
53425433
53435434 if (display.DrawMode() == iCameraPane.SELECTION &&
5344
- hide)
5435
+ (hide || dontselect))
53455436 return;
53465437
53475438 if (name != null && name.contains("sclera"))
....@@ -5583,7 +5674,17 @@
55835674 tex = GetTextures();
55845675 }
55855676
5586
- 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
+ }
55875688
55885689 if (!compiled)
55895690 {
....@@ -5605,7 +5706,8 @@
56055706 }
56065707 }
56075708
5608
- display.ReleaseTextures(tex);
5709
+ if (!failed)
5710
+ display.ReleaseTextures(tex);
56095711
56105712 display.PopMaterial(this, selected);
56115713 }
....@@ -5734,6 +5836,9 @@
57345836
57355837 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57365838 {
5839
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5840
+ return;
5841
+
57375842 if (hide)
57385843 return;
57395844 // shadow optimisation
....@@ -5858,6 +5963,9 @@
58585963 {
58595964 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58605965 return; // no shadow for transparent objects
5966
+
5967
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5968
+ return;
58615969
58625970 if (hide)
58635971 return;
....@@ -6842,8 +6950,8 @@
68426950 // {
68436951 // CameraPane.Ymax = spoth;
68446952 // }
6845
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6846
- 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);
68476955 spot.translate(0, -32);
68486956 info.g.setColor(Color.green);
68496957 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
....@@ -6898,7 +7006,7 @@
68987006 startX = info.x;
68997007 startY = info.y;
69007008
6901
- hitSomething = 0;
7009
+ hitSomething = -1;
69027010 cVector origin = new cVector();
69037011 //LA.xformPos(origin, toParent, origin);
69047012 Rectangle spot = new Rectangle();
....@@ -6931,7 +7039,7 @@
69317039 }
69327040
69337041 //System.out.println("info.modifiers = " + info.modifiers);
6934
- modified = (info.modifiers & CameraPane.META) != 0;
7042
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69357043 //System.out.println("modified = " + modified);
69367044 //new Exception().printStackTrace();
69377045 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6959,7 +7067,7 @@
69597067 return true;
69607068 }
69617069
6962
- void doEditDrag0(ClickInfo info)
7070
+ void doEditDrag0(ClickInfo info, boolean opposite)
69637071 {
69647072 if (hitSomething == 0)
69657073 {
....@@ -6974,6 +7082,7 @@
69747082 //System.out.println("hitSomething = " + hitSomething);
69757083
69767084 double scale = 0.005f * info.camera.Distance();
7085
+
69777086 cVector xlate = new cVector();
69787087 //cVector xlate2 = new cVector();
69797088 switch (hitSomething)
....@@ -6986,7 +7095,7 @@
69867095
69877096 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69887097
6989
- if (modified)
7098
+ if (modified || opposite)
69907099 {
69917100 //assert(false);
69927101 /*
....@@ -7080,6 +7189,7 @@
70807189
70817190 if (modified)
70827191 {
7192
+ // Rotate 90 degrees
70837193 angle /= (Math.PI / 4);
70847194 angle = Math.floor(angle + 0.5);
70857195 angle *= (Math.PI / 4);
....@@ -7121,24 +7231,27 @@
71217231
71227232 case hitScale: // scale
71237233 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);
71247240 if (hScale < 0.01)
71257241 {
7126
- hScale = 0.01;
7242
+ //hScale = 0.01;
71277243 }
7128
- hScale = Math.pow(hScale, scale * 50);
7129
- if (hScale < 0.01)
7130
- {
7131
- hScale = 0.01;
7132
- }
7244
+
71337245 double vScale = (double) (info.y - centerPt.y) / 32;
7134
- if (vScale < 0.01)
7246
+ sign = 1;
7247
+ if (vScale < 0)
71357248 {
7136
- vScale = 0.01;
7249
+ sign = -1;
71377250 }
7138
- vScale = Math.pow(vScale, scale * 50);
7251
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71397252 if (vScale < 0.01)
71407253 {
7141
- vScale = 0.01;
7254
+ //vScale = 0.01;
71427255 }
71437256 LA.matCopy(startMat, toParent);
71447257 /**/
....@@ -7149,17 +7262,24 @@
71497262 }
71507263 /**/
71517264
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
+
71527272 switch (info.pane.RenderCamera().viewCode)
71537273 {
71547274 case 3: // '\001'
71557275 if (modified)
71567276 {
71577277 //LA.matScale(toParent, 1, hScale, vScale);
7158
- LA.matScale(toParent, vScale, 1, 1);
7278
+ LA.matScale(toParent, totalScale, 1, 1);
71597279 } // vScale, 1);
71607280 else
71617281 {
7162
- LA.matScale(toParent, vScale, vScale, vScale);
7282
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71637283 } // vScale, 1);
71647284 break;
71657285
....@@ -7167,10 +7287,10 @@
71677287 if (modified)
71687288 {
71697289 //LA.matScale(toParent, hScale, 1, vScale);
7170
- LA.matScale(toParent, 1, vScale, 1);
7290
+ LA.matScale(toParent, 1, totalScale, 1);
71717291 } else
71727292 {
7173
- LA.matScale(toParent, vScale, 1, vScale);
7293
+ LA.matScale(toParent, totalScale, 1, totalScale);
71747294 }
71757295 break;
71767296
....@@ -7178,10 +7298,10 @@
71787298 if (modified)
71797299 {
71807300 //LA.matScale(toParent, hScale, vScale, 1);
7181
- LA.matScale(toParent, 1, 1, vScale);
7301
+ LA.matScale(toParent, 1, 1, totalScale);
71827302 } else
71837303 {
7184
- LA.matScale(toParent, vScale, vScale, 1);
7304
+ LA.matScale(toParent, totalScale, totalScale, 1);
71857305 }
71867306 break;
71877307 }
....@@ -7314,14 +7434,22 @@
73147434 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73157435 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73167436 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7437
+
7438
+ String objname;
7439
+
73177440 if (false) //parent != null)
73187441 {
7319
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7442
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73207443 } else
73217444 {
7322
- 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) ":"") */ "";
73237446 } // + super.toString();
73247447 //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);
73257453 }
73267454
73277455 public int hashCode()
....@@ -7377,6 +7505,7 @@
73777505 objectUI.closeUI();
73787506 if (editWindow != null)
73797507 {
7508
+ editWindow.ctrlPanel.FlushUI();
73807509 editWindow.refreshContents();
73817510 } // ? new
73827511 objectUI = null;
....@@ -7512,7 +7641,7 @@
75127641 {
75137642 assert(bRep != null);
75147643 if (!(support instanceof GenericJoint)) // support.bRep != null)
7515
- GrafreeD.Assert(support.bRep == bRep.support);
7644
+ Grafreed.Assert(support.bRep == bRep.support);
75167645 }
75177646 else
75187647 {
....@@ -7561,9 +7690,9 @@
75617690 private static cVector edge2 = new cVector();
75627691 //private static cVector norm = new cVector();
75637692 /*transient private*/ int hitSomething;
7564
- private static final int hitCenter = 1;
7565
- private static final int hitScale = 2;
7566
- private static final int hitRotate = 3;
7693
+ static final int hitCenter = 1;
7694
+ static final int hitScale = 2;
7695
+ static final int hitRotate = 3;
75677696 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75687697 /*transient*/ private Point centerPt;
75697698 /*transient*/ private int startX;