Normand Briere
2019-06-09 cd87df088b1850ba0c90beb6c866c443e4eaf3b9
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
....@@ -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;
....@@ -2906,7 +2916,8 @@
29062916 {
29072917 if (bRep != null)
29082918 {
2909
- bRep.GenUV();
2919
+ bRep.GenUV(); //1);
2920
+ //bRep.UnfoldUV();
29102921 Touch();
29112922 }
29122923 }
....@@ -2981,6 +2992,33 @@
29812992 blockloop = false;
29822993 }
29832994
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
+
29843022 void TransformGeometry()
29853023 {
29863024 Object3D obj = this;
....@@ -3202,9 +3240,11 @@
32023240
32033241 BoundaryRep sup = bRep.support;
32043242 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3243
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063244 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3245
+
3246
+ while(temprep.SplitInTwo(reduction34, onlyone));
3247
+
32083248 bRep = temprep;
32093249 bRep.support = sup;
32103250 Touch();
....@@ -3726,7 +3766,7 @@
37263766 if (child == null)
37273767 continue;
37283768
3729
- if (GrafreeD.RENDERME > 0)
3769
+ if (Grafreed.RENDERME > 0)
37303770 {
37313771 if (child instanceof Merge)
37323772 ((Merge)child).renderme();
....@@ -3877,7 +3917,7 @@
38773917 if (child == null)
38783918 continue;
38793919
3880
- if (GrafreeD.RENDERME > 0)
3920
+ if (Grafreed.RENDERME > 0)
38813921 {
38823922 if (child instanceof Merge)
38833923 ((Merge)child).renderme();
....@@ -4072,7 +4112,7 @@
40724112 if (child == null)
40734113 continue;
40744114
4075
- if (GrafreeD.RENDERME > 0)
4115
+ if (Grafreed.RENDERME > 0)
40764116 {
40774117 if (child instanceof Merge)
40784118 ((Merge)child).renderme();
....@@ -4679,7 +4719,7 @@
46794719
46804720 cTreePath SelectLeaf(int indexcount, boolean deselect)
46814721 {
4682
- if (hide)
4722
+ if (hide || dontselect)
46834723 return null;
46844724
46854725 if (count <= 0)
....@@ -4705,7 +4745,7 @@
47054745
47064746 cTreePath Select(int indexcount, boolean deselect)
47074747 {
4708
- if (hide)
4748
+ if (hide || dontselect)
47094749 return null;
47104750
47114751 if (count <= 0)
....@@ -5157,10 +5197,34 @@
51575197
51585198 // System.out.println("Fullname = " + fullname);
51595199
5160
- if (fullname.name.indexOf(":") == -1)
5161
- 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(":"));
51625205
5163
- 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];
51645228 }
51655229
51665230 static String GetBump(cTexture fullname)
....@@ -5169,10 +5233,38 @@
51695233 return "";
51705234
51715235 // System.out.println("Fullname = " + fullname);
5172
- if (fullname.name.indexOf(":") == -1)
5173
- return "";
5174
-
5175
- 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];
51765268 }
51775269
51785270 String GetPigmentTexture()
....@@ -5246,7 +5338,7 @@
52465338 System.out.print("; textures = " + textures);
52475339 System.out.println("; usedtextures = " + usedtextures);
52485340
5249
- if (GetTextures() == null)
5341
+ if (GetTextures() == null) // What is that??
52505342 GetTextures().name = ":";
52515343
52525344 String texname = tex;
....@@ -5323,9 +5415,9 @@
53235415 boolean NeedSupport()
53245416 {
53255417 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5418
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
53275419 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5420
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295421 }
53305422
53315423 static boolean DEBUG_SELECTION = false;
....@@ -5340,7 +5432,7 @@
53405432 }
53415433
53425434 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5435
+ (hide || dontselect))
53445436 return;
53455437
53465438 if (name != null && name.contains("sclera"))
....@@ -5582,7 +5674,17 @@
55825674 tex = GetTextures();
55835675 }
55845676
5585
- 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
+ }
55865688
55875689 if (!compiled)
55885690 {
....@@ -5604,7 +5706,8 @@
56045706 }
56055707 }
56065708
5607
- display.ReleaseTextures(tex);
5709
+ if (!failed)
5710
+ display.ReleaseTextures(tex);
56085711
56095712 display.PopMaterial(this, selected);
56105713 }
....@@ -5733,6 +5836,9 @@
57335836
57345837 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57355838 {
5839
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5840
+ return;
5841
+
57365842 if (hide)
57375843 return;
57385844 // shadow optimisation
....@@ -5858,6 +5964,9 @@
58585964 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58595965 return; // no shadow for transparent objects
58605966
5967
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
5968
+ return;
5969
+
58615970 if (hide)
58625971 return;
58635972
....@@ -5898,6 +6007,7 @@
58986007 return;
58996008 }
59006009
6010
+ //bRep.GenUV(1/material.diffuseness);
59016011 // bRep.lock = true;
59026012
59036013 //javax.media.opengl.GL gl = display.GetGL();
....@@ -6929,7 +7039,7 @@
69297039 }
69307040
69317041 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7042
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
69337043 //System.out.println("modified = " + modified);
69347044 //new Exception().printStackTrace();
69357045 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7067,7 @@
69577067 return true;
69587068 }
69597069
6960
- void doEditDrag0(ClickInfo info)
7070
+ void doEditDrag0(ClickInfo info, boolean opposite)
69617071 {
69627072 if (hitSomething == 0)
69637073 {
....@@ -6984,7 +7094,7 @@
69847094
69857095 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867096
6987
- if (modified)
7097
+ if (modified || opposite)
69887098 {
69897099 //assert(false);
69907100 /*
....@@ -7078,6 +7188,7 @@
70787188
70797189 if (modified)
70807190 {
7191
+ // Rotate 90 degrees
70817192 angle /= (Math.PI / 4);
70827193 angle = Math.floor(angle + 0.5);
70837194 angle *= (Math.PI / 4);
....@@ -7312,14 +7423,22 @@
73127423 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73137424 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73147425 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7426
+
7427
+ String objname;
7428
+
73157429 if (false) //parent != null)
73167430 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7431
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73187432 } else
73197433 {
7320
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7434
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73217435 } // + super.toString();
73227436 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7437
+
7438
+ if (!Globals.ADVANCED)
7439
+ return objname;
7440
+
7441
+ return objname + " " + System.identityHashCode(this);
73237442 }
73247443
73257444 public int hashCode()
....@@ -7375,6 +7494,7 @@
73757494 objectUI.closeUI();
73767495 if (editWindow != null)
73777496 {
7497
+ editWindow.ctrlPanel.FlushUI();
73787498 editWindow.refreshContents();
73797499 } // ? new
73807500 objectUI = null;
....@@ -7510,7 +7630,7 @@
75107630 {
75117631 assert(bRep != null);
75127632 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
7633
+ Grafreed.Assert(support.bRep == bRep.support);
75147634 }
75157635 else
75167636 {