Normand Briere
2019-08-06 b3ae4e889872ca0b9ca76f1d17b2f0b961226729
Object3D.java
....@@ -14,12 +14,28 @@
1414 import //weka.core.
1515 matrix.Matrix;
1616
17
+import java.util.UUID;
18
+
1719 //import net.sourceforge.sizeof.SizeOf;
1820 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1921 {
2022 //static final long serialVersionUID = -607422624994562685L;
2123 static final long serialVersionUID = 5022536242724664900L;
2224
25
+ // Use GetUUID for backward compatibility with null.
26
+ private UUID uuid = UUID.randomUUID();
27
+
28
+ // TEMPORARY for mocap undo. No need to be transient.
29
+ mocap.reader.BVHReader.BVHResult savebvh;
30
+ Object3D saveskeleton;
31
+ //
32
+
33
+ String skyboxname;
34
+ String skyboxext;
35
+
36
+ Object3D versionlist[];
37
+ int versionindex = -1;
38
+
2339 ScriptNode scriptnode;
2440
2541 void InitOthers()
....@@ -100,64 +116,201 @@
100116
101117 // transient boolean reduced; // for morph reduction
102118
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
119
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
120
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105121
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
122
+ transient Object3D transientsupport; // for cloning
123
+ transient boolean transientlink2master;
108124
109
-void SaveSupports()
110
-{
111
- if (blockloop)
112
- return;
113
-
114
- transientsupport = support;
115
- transientlink2master = link2master;
116
-
117
- support = null;
118
- link2master = false;
119
-
120
- if (bRep != null)
125
+ void SaveSupports()
121126 {
122
- bRep.SaveSupports();
127
+ if (blockloop)
128
+ return;
129
+
130
+ transientsupport = support;
131
+ transientlink2master = link2master;
132
+
133
+ support = null;
134
+ link2master = false;
135
+
136
+ if (bRep != null)
137
+ {
138
+ bRep.SaveSupports();
139
+ }
140
+
141
+ for (int i = 0; i < Size(); i++)
142
+ {
143
+ Object3D child = (Object3D) get(i);
144
+ if (child == null)
145
+ continue;
146
+ blockloop = true;
147
+ child.SaveSupports();
148
+ blockloop = false;
149
+ }
123150 }
124
-
125
- for (int i = 0; i < Size(); i++)
151
+
152
+ void RestoreSupports()
126153 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
154
+ if (blockloop)
155
+ return;
156
+
157
+ support = transientsupport;
158
+ link2master = transientlink2master;
159
+ transientsupport = null;
160
+ transientlink2master = false;
161
+
162
+ if (bRep != null)
163
+ {
164
+ bRep.RestoreSupports();
165
+ }
166
+
167
+ for (int i = 0; i < Size(); i++)
168
+ {
169
+ Object3D child = (Object3D) get(i);
170
+ if (child == null)
171
+ continue;
172
+ blockloop = true;
173
+ child.RestoreSupports();
174
+ blockloop = false;
175
+ }
176
+ }
177
+
178
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
179
+ {
180
+ Object3D o;
181
+
182
+ if (hashtable.containsKey(GetUUID()))
183
+ {
184
+ o = hashtable.get(GetUUID());
185
+
186
+ Grafreed.Assert(this.bRep == o.bRep);
187
+ //if (this.bRep != null)
188
+ // assert(this.bRep.support == o.transientrep);
189
+ if (this.support != null)
190
+ assert(this.support.bRep == o.transientrep);
191
+ }
192
+ else
193
+ {
194
+ o = new Object3D("copy of " + this.name);
195
+
196
+ hashtable.put(GetUUID(), o);
197
+ }
198
+
199
+ if (!blockloop)
200
+ {
201
+ blockloop = true;
202
+
203
+ for (int i=0; i<Size(); i++)
204
+ {
205
+ get(i).ExtractBigData(hashtable);
206
+ }
207
+
208
+ blockloop = false;
209
+ }
210
+
211
+ ExtractBigData(o);
212
+ }
213
+
214
+ void ExtractBigData(Object3D o)
215
+ {
216
+ if (o.bRep != null)
217
+ Grafreed.Assert(o.bRep == this.bRep);
218
+
219
+ o.bRep = this.bRep;
220
+// July 2019 if (this.bRep != null)
221
+// {
222
+// o.transientrep = this.bRep.support;
223
+// o.bRep.support = null;
224
+// }
225
+ o.selection = this.selection;
226
+ o.versionlist = this.versionlist;
227
+ o.versionindex = this.versionindex;
228
+
229
+ if (this.support != null)
230
+ {
231
+ if (o.transientrep != null)
232
+ Grafreed.Assert(o.transientrep == this.support.bRep);
233
+
234
+ o.transientrep = this.support.bRep;
235
+ this.support.bRep = null;
236
+ }
237
+
238
+ // o.support = this.support;
239
+ // o.fileparent = this.fileparent;
240
+ // if (this.bRep != null)
241
+ // o.bRep = this.bRep.support;
242
+
243
+ this.bRep = null;
244
+ // if (this.bRep != null)
245
+ // this.bRep.support = null;
246
+ // this.support = null;
247
+ // this.fileparent = null;
248
+ }
249
+
250
+// Object3D GetObject(java.util.UUID uuid)
251
+// {
252
+// if (this.uuid.equals(uuid))
253
+// return this;
254
+//
255
+// if (blockloop)
256
+// return null;
257
+//
258
+// blockloop = true;
259
+//
260
+// for (int i=0; i<Size(); i++)
261
+// {
262
+// Object3D o = get(i).GetObject(uuid);
263
+//
264
+// if (o != null)
265
+// return o;
266
+// }
267
+//
268
+// blockloop = false;
269
+//
270
+// return null;
271
+// }
272
+
273
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
274
+ {
275
+ if (!hashtable.containsKey(GetUUID()))
276
+ return;
277
+
278
+ Object3D o = hashtable.get(GetUUID());
279
+
280
+ RestoreBigData(o);
281
+
282
+ if (blockloop)
283
+ return;
284
+
130285 blockloop = true;
131
- child.SaveSupports();
286
+
287
+ //hashtable.remove(GetUUID());
288
+
289
+ for (int i=0; i<Size(); i++)
290
+ {
291
+ get(i).RestoreBigData(hashtable);
292
+ }
293
+
132294 blockloop = false;
133295 }
134
-}
135296
136
-void RestoreSupports()
137
-{
138
- if (blockloop)
139
- return;
140
-
141
- support = transientsupport;
142
- link2master = transientlink2master;
143
- transientsupport = null;
144
- transientlink2master = false;
145
-
146
- if (bRep != null)
297
+ void RestoreBigData(Object3D o)
147298 {
148
- bRep.RestoreSupports();
299
+ this.bRep = o.bRep;
300
+ if (this.support != null && o.transientrep != null)
301
+ {
302
+ this.support.bRep = o.transientrep;
303
+ }
304
+
305
+ this.selection = o.selection;
306
+
307
+ this.versionlist = o.versionlist;
308
+ this.versionindex = o.versionindex;
309
+// July 2019 if (this.bRep != null)
310
+// this.bRep.support = o.transientrep;
311
+ // this.support = o.support;
312
+ // this.fileparent = o.fileparent;
149313 }
150
-
151
- for (int i = 0; i < Size(); i++)
152
- {
153
- Object3D child = (Object3D) get(i);
154
- if (child == null)
155
- continue;
156
- blockloop = true;
157
- child.RestoreSupports();
158
- blockloop = false;
159
- }
160
-}
161314
162315 // MOCAP SUPPORT
163316 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +453,8 @@
300453 }
301454
302455 boolean live = false;
456
+ transient boolean keepdontselect;
457
+ boolean dontselect = false;
303458 boolean hide = false;
304459 boolean link2master = false; // performs reset support/master at each frame
305460 boolean marked = false; // animation node
....@@ -481,12 +636,14 @@
481636 toParent = LA.newMatrix();
482637 fromParent = LA.newMatrix();
483638 }
639
+
484640 if (toParentMarked == null)
485641 {
486642 if (maxcount != 1)
487643 {
488644 new Exception().printStackTrace();
489645 }
646
+
490647 toParentMarked = LA.newMatrix();
491648 fromParentMarked = LA.newMatrix();
492649 }
....@@ -774,7 +931,7 @@
774931 if (step == 0)
775932 step = 1;
776933 if (maxcount == 0)
777
- maxcount = 2048; // 4;
934
+ maxcount = 128; // 2048; // 4;
778935 // if (acceleration == 0)
779936 // acceleration = 10;
780937 if (delay == 0) // serial
....@@ -797,7 +954,7 @@
797954
798955 if (marked && Globals.isLIVE() && live &&
799956 //TEMP21aug2018
800
- Globals.DrawMode() == iCameraPane.SHADOW &&
957
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
801958 currentframe != Globals.framecount)
802959 {
803960 currentframe = Globals.framecount;
....@@ -809,7 +966,8 @@
809966
810967 boolean changedir = random && Math.random() < 0.01; // && !link2master;
811968
812
- if (transformcount*factor > maxcount || (step == 1 && changedir))
969
+ if (transformcount*factor >= maxcount && (rewind || random) ||
970
+ (step == 1 && changedir))
813971 {
814972 countdown = 1;
815973 delay = speedup?8:1;
....@@ -881,6 +1039,10 @@
8811039 if (material == null || material.multiply)
8821040 return true;
8831041
1042
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1043
+ return false;
1044
+
1045
+ // Transparent objects are dynamic because we have to sort the triangles.
8841046 return material.opacity > 0.99;
8851047 }
8861048
....@@ -912,6 +1074,11 @@
9121074 fromParent = null; // LA.newMatrix();
9131075 bRep = null; // new BoundaryRep();
9141076
1077
+ if (oname != null && oname.equals("LeftHand"))
1078
+ {
1079
+ name = oname;
1080
+ }
1081
+
9151082 /*
9161083 float hue = (float)Math.random();
9171084 Color col;
....@@ -954,7 +1121,7 @@
9541121
9551122 public Object clone()
9561123 {
957
- return GrafreeD.clone(this);
1124
+ return Grafreed.clone(this);
9581125 }
9591126
9601127 Object3D copyExpand()
....@@ -1276,6 +1443,7 @@
12761443 toParent = LA.newMatrix();
12771444 fromParent = LA.newMatrix();
12781445 }
1446
+
12791447 LA.matCopy(other.toParent, toParent);
12801448 LA.matCopy(other.fromParent, fromParent);
12811449
....@@ -1470,7 +1638,7 @@
14701638 BoundaryRep.SEUIL = other.material.cameralight;
14711639
14721640 // Set default to 0.1
1473
- BoundaryRep.SEUIL /= 2;
1641
+ BoundaryRep.SEUIL /= 4; // 2;
14741642 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14751643 }
14761644
....@@ -1729,7 +1897,7 @@
17291897 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17301898 o.bRep = transientrep;
17311899 if (clone)
1732
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1900
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17331901 o.CreateMaterial();
17341902 o.SetAttributes(this, -1);
17351903 //parent
....@@ -1742,7 +1910,7 @@
17421910 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17431911 o.bRep = bRep;
17441912 if (clone)
1745
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1913
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17461914 o.CreateMaterial();
17471915 //o.overwriteThis(this, -1);
17481916 o.SetAttributes(this, -1);
....@@ -1829,12 +1997,15 @@
18291997 if (obj.name == null)
18301998 continue; // can't be a null one
18311999
2000
+ // Try perfect match first.
18322001 if (n.equals(obj.name))
18332002 {
18342003 theobj = obj;
18352004 count++;
18362005 }
18372006 }
2007
+
2008
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18382009
18392010 if (count != 1)
18402011 for (int i=Size(); --i>=0;)
....@@ -2294,12 +2465,17 @@
22942465 }
22952466 */
22962467 }
2468
+ else
2469
+ {
2470
+ //((ObjEditor)editWindow).SetupUI2(null);
2471
+ }
22972472 }
22982473
22992474 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
23002475 {
23012476 if (newWindow)
23022477 {
2478
+ new Exception().printStackTrace();
23032479 System.exit(0);
23042480 if (parent != null)
23052481 {
....@@ -2334,6 +2510,14 @@
23342510 {
23352511 editWindow.refreshContents();
23362512 }
2513
+ else
2514
+ {
2515
+ if (manipWindow != null)
2516
+ {
2517
+ manipWindow.refreshContents();
2518
+ }
2519
+ }
2520
+
23372521 //if (parent != null)
23382522 //parent.refreshEditWindow();
23392523 }
....@@ -2413,7 +2597,8 @@
24132597 private static final int editSelf = 1;
24142598 private static final int editChild = 2;
24152599
2416
- void drawEditHandles(ClickInfo info, int level)
2600
+ void drawEditHandles(//ClickInfo info,
2601
+ int level)
24172602 {
24182603 if (level == 0)
24192604 {
....@@ -2421,7 +2606,8 @@
24212606 return;
24222607
24232608 Object3D selectee;
2424
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2609
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2610
+ level + 1))
24252611 {
24262612 selectee = (Object3D) e.nextElement();
24272613 }
....@@ -2429,19 +2615,22 @@
24292615 } else
24302616 {
24312617 //super.
2432
- drawEditHandles0(info, level + 1);
2618
+ drawEditHandles0(//info,
2619
+ level + 1);
24332620 }
24342621 }
24352622
2436
- boolean doEditClick(ClickInfo info, int level)
2623
+ boolean doEditClick(//ClickInfo info,
2624
+ int level)
24372625 {
24382626 doSomething = 0;
24392627 if (level == 0)
24402628 {
2441
- return doParentClick(info);
2629
+ return doParentClick(); //info);
24422630 }
24432631 if (//super.
2444
- doEditClick0(info, level))
2632
+ doEditClick0(//info,
2633
+ level))
24452634 {
24462635 doSomething = 1;
24472636 return true;
....@@ -2451,7 +2640,7 @@
24512640 }
24522641 }
24532642
2454
- boolean doParentClick(ClickInfo info)
2643
+ boolean doParentClick() //ClickInfo info)
24552644 {
24562645 if (selection == null)
24572646 {
....@@ -2464,7 +2653,8 @@
24642653 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24652654 {
24662655 Object3D selectee = (Object3D) e.nextElement();
2467
- if (selectee.doEditClick(info, 1))
2656
+ if (selectee.doEditClick(//info,
2657
+ 1))
24682658 {
24692659 childToDrag = selectee;
24702660 doSomething = 2;
....@@ -2476,13 +2666,15 @@
24762666 return retval;
24772667 }
24782668
2479
- void doEditDrag(ClickInfo info)
2669
+ void doEditDrag(//ClickInfo clickInfo,
2670
+ boolean opposite)
24802671 {
24812672 switch (doSomething)
24822673 {
24832674 case 1: // '\001'
24842675 //super.
2485
- doEditDrag0(info);
2676
+ doEditDrag0(//clickInfo,
2677
+ opposite);
24862678 break;
24872679
24882680 case 2: // '\002'
....@@ -2495,11 +2687,13 @@
24952687 {
24962688 //sel.hitSomething = childToDrag.hitSomething;
24972689 //childToDrag.doEditDrag(info);
2498
- sel.doEditDrag(info);
2690
+ sel.doEditDrag(//clickInfo,
2691
+ opposite);
24992692 } else
25002693 {
25012694 //super.
2502
- doEditDrag0(info);
2695
+ doEditDrag0(//clickInfo,
2696
+ opposite);
25032697 }
25042698 }
25052699 break;
....@@ -2517,6 +2711,9 @@
25172711 {
25182712 deselectAll();
25192713 }
2714
+
2715
+ new Exception().printStackTrace();
2716
+
25202717 ClickInfo newInfo = new ClickInfo();
25212718 newInfo.flags = info.flags;
25222719 newInfo.bounds = info.bounds;
....@@ -2609,6 +2806,18 @@
26092806 void GenNormalsS(boolean crease)
26102807 {
26112808 selection.GenNormals(crease);
2809
+// for (int i=0; i<selection.size(); i++)
2810
+// {
2811
+// Object3D selectee = (Object3D) selection.elementAt(i);
2812
+// selectee.GenNormals(crease);
2813
+// }
2814
+
2815
+ //Touch();
2816
+ }
2817
+
2818
+ void GenNormalsMeshS()
2819
+ {
2820
+ selection.GenNormalsMesh();
26122821 // for (int i=0; i<selection.size(); i++)
26132822 // {
26142823 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2749,6 +2958,24 @@
27492958 if (child == null)
27502959 continue;
27512960 child.GenNormals(crease);
2961
+// Children().release(i);
2962
+ }
2963
+ blockloop = false;
2964
+ }
2965
+
2966
+ void GenNormalsMesh()
2967
+ {
2968
+ if (blockloop)
2969
+ return;
2970
+
2971
+ blockloop = true;
2972
+ GenNormalsMesh0();
2973
+ for (int i = 0; i < Children().Size(); i++)
2974
+ {
2975
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2976
+ if (child == null)
2977
+ continue;
2978
+ child.GenNormalsMesh();
27522979 // Children().release(i);
27532980 }
27542981 blockloop = false;
....@@ -2906,7 +3133,8 @@
29063133 {
29073134 if (bRep != null)
29083135 {
2909
- bRep.GenUV();
3136
+ bRep.GenUV(); //1);
3137
+ //bRep.UnfoldUV();
29103138 Touch();
29113139 }
29123140 }
....@@ -2920,11 +3148,20 @@
29203148 }
29213149 }
29223150
3151
+ void GenNormalsMesh0()
3152
+ {
3153
+ if (bRep != null)
3154
+ {
3155
+ bRep.GenerateNormalsMesh();
3156
+ Touch();
3157
+ }
3158
+ }
3159
+
29233160 void GenNormalsMINE0()
29243161 {
29253162 if (bRep != null)
29263163 {
2927
- bRep.GenerateNormalsMINE();
3164
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29283165 Touch();
29293166 }
29303167 }
....@@ -2981,6 +3218,33 @@
29813218 blockloop = false;
29823219 }
29833220
3221
+ void TransformChildren()
3222
+ {
3223
+ if (toParent != null)
3224
+ {
3225
+ for (int i=Size(); --i>=0;)
3226
+ {
3227
+ Object3D v = get(i);
3228
+
3229
+ if (v.toParent == null)
3230
+ {
3231
+ v.toParent = LA.newMatrix();
3232
+ v.fromParent = LA.newMatrix();
3233
+ }
3234
+
3235
+// LA.matConcat(v.toParent, toParent, v.toParent);
3236
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3237
+ LA.matConcat(toParent, v.toParent, v.toParent);
3238
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3239
+ }
3240
+
3241
+ toParent = null; // LA.matIdentity(toParent);
3242
+ fromParent = null; // LA.matIdentity(fromParent);
3243
+
3244
+ Touch();
3245
+ }
3246
+ }
3247
+
29843248 void TransformGeometry()
29853249 {
29863250 Object3D obj = this;
....@@ -3202,9 +3466,11 @@
32023466
32033467 BoundaryRep sup = bRep.support;
32043468 bRep.support = null;
3205
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3469
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32063470 // bRep.SplitInTwo(onlyone); // thread...
3207
- temprep.SplitInTwo(reduction34, onlyone);
3471
+
3472
+ while(temprep.SplitInTwo(reduction34, onlyone));
3473
+
32083474 bRep = temprep;
32093475 bRep.support = sup;
32103476 Touch();
....@@ -3341,7 +3607,8 @@
33413607 if (blockloop)
33423608 return;
33433609
3344
- if (marked || (bRep != null && material != null)) // borderline...
3610
+ if (//marked || // does not make sense
3611
+ (bRep != null || material != null)) // borderline...
33453612 live = h;
33463613
33473614 for (int i = 0; i < Size(); i++)
....@@ -3362,7 +3629,8 @@
33623629 return;
33633630
33643631 //if (bRep != null)
3365
- if (marked || (bRep != null && material != null)) // borderline...
3632
+ if (//marked || // does not make sense
3633
+ (bRep != null || material != null)) // borderline...
33663634 link2master = h;
33673635
33683636 for (int i = 0; i < Size(); i++)
....@@ -3382,7 +3650,8 @@
33823650 if (blockloop)
33833651 return;
33843652
3385
- if (marked || (bRep != null && material != null)) // borderline...
3653
+ if (//marked || // does not make sense
3654
+ (bRep != null || material != null)) // borderline...
33863655 hide = h;
33873656
33883657 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3671,7 @@
34023671 if (blockloop)
34033672 return;
34043673
3405
- if (bRep != null && material != null) // borderline...
3674
+ if (bRep != null || material != null) // borderline...
34063675 marked = h;
34073676
34083677 for (int i = 0; i < Size(); i++)
....@@ -3412,6 +3681,46 @@
34123681 continue;
34133682 blockloop = true;
34143683 child.MarkLeaves(h);
3684
+ blockloop = false;
3685
+ // release(i);
3686
+ }
3687
+ }
3688
+
3689
+ void RewindLeaves(boolean h)
3690
+ {
3691
+ if (blockloop)
3692
+ return;
3693
+
3694
+ if (bRep != null || material != null) // borderline...
3695
+ rewind = h;
3696
+
3697
+ for (int i = 0; i < Size(); i++)
3698
+ {
3699
+ Object3D child = (Object3D) get(i); // reserve(i);
3700
+ if (child == null)
3701
+ continue;
3702
+ blockloop = true;
3703
+ child.RewindLeaves(h);
3704
+ blockloop = false;
3705
+ // release(i);
3706
+ }
3707
+ }
3708
+
3709
+ void RandomLeaves(boolean h)
3710
+ {
3711
+ if (blockloop)
3712
+ return;
3713
+
3714
+ if (bRep != null || material != null) // borderline...
3715
+ random = h;
3716
+
3717
+ for (int i = 0; i < Size(); i++)
3718
+ {
3719
+ Object3D child = (Object3D) get(i); // reserve(i);
3720
+ if (child == null)
3721
+ continue;
3722
+ blockloop = true;
3723
+ child.RandomLeaves(h);
34153724 blockloop = false;
34163725 // release(i);
34173726 }
....@@ -3726,7 +4035,7 @@
37264035 if (child == null)
37274036 continue;
37284037
3729
- if (GrafreeD.RENDERME > 0)
4038
+ if (Grafreed.RENDERME > 0)
37304039 {
37314040 if (child instanceof Merge)
37324041 ((Merge)child).renderme();
....@@ -3877,7 +4186,7 @@
38774186 if (child == null)
38784187 continue;
38794188
3880
- if (GrafreeD.RENDERME > 0)
4189
+ if (Grafreed.RENDERME > 0)
38814190 {
38824191 if (child instanceof Merge)
38834192 ((Merge)child).renderme();
....@@ -4072,7 +4381,7 @@
40724381 if (child == null)
40734382 continue;
40744383
4075
- if (GrafreeD.RENDERME > 0)
4384
+ if (Grafreed.RENDERME > 0)
40764385 {
40774386 if (child instanceof Merge)
40784387 ((Merge)child).renderme();
....@@ -4185,6 +4494,55 @@
41854494 {
41864495 blockloop = true;
41874496 get(i).RepairShadow();
4497
+ blockloop = false;
4498
+ }
4499
+ }
4500
+
4501
+ void RepairSOV()
4502
+ {
4503
+ if (blockloop)
4504
+ return;
4505
+
4506
+ String texname = this.GetPigmentTexture();
4507
+
4508
+ if (texname.startsWith("sov"))
4509
+ {
4510
+ String[] s = texname.split("/");
4511
+
4512
+ String[] sname = s[1].split("Color.pn");
4513
+
4514
+ texname = sname[0];
4515
+
4516
+ if (sname.length > 1)
4517
+ {
4518
+ texname += "Color.jpg";
4519
+ }
4520
+
4521
+ this.SetPigmentTexture("sov/" + texname);
4522
+ }
4523
+
4524
+ texname = this.GetBumpTexture();
4525
+
4526
+ if (texname.startsWith("sov"))
4527
+ {
4528
+ String[] s = texname.split("/");
4529
+
4530
+ String[] sname = s[1].split("Bump.pn");
4531
+
4532
+ texname = sname[0];
4533
+
4534
+ if (sname.length > 1)
4535
+ {
4536
+ texname += "Bump.jpg";
4537
+ }
4538
+
4539
+ this.SetBumpTexture("sov/" + texname);
4540
+ }
4541
+
4542
+ for (int i=0; i<Size(); i++)
4543
+ {
4544
+ blockloop = true;
4545
+ get(i).RepairSOV();
41884546 blockloop = false;
41894547 }
41904548 }
....@@ -4679,7 +5037,7 @@
46795037
46805038 cTreePath SelectLeaf(int indexcount, boolean deselect)
46815039 {
4682
- if (hide)
5040
+ if (hide || dontselect)
46835041 return null;
46845042
46855043 if (count <= 0)
....@@ -4703,9 +5061,17 @@
47035061 }
47045062 }
47055063
5064
+ ObjEditor GetWindow()
5065
+ {
5066
+ if (editWindow != null)
5067
+ return editWindow;
5068
+
5069
+ return manipWindow;
5070
+ }
5071
+
47065072 cTreePath Select(int indexcount, boolean deselect)
47075073 {
4708
- if (hide)
5074
+ if (hide || dontselect)
47095075 return null;
47105076
47115077 if (count <= 0)
....@@ -4739,10 +5105,11 @@
47395105 if (leaf != null)
47405106 {
47415107 cTreePath tp = new cTreePath(this, leaf);
4742
- if (editWindow != null)
5108
+ ObjEditor window = GetWindow();
5109
+ if (window != null)
47435110 {
47445111 //System.out.println("editWindow = " + editWindow + " vs " + this);
4745
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
47465113 }
47475114
47485115 return tp;
....@@ -4759,6 +5126,7 @@
47595126
47605127 if (child == null)
47615128 continue;
5129
+
47625130 if (child.HasTransparency() && child.size() != 0)
47635131 {
47645132 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4768,9 +5136,10 @@
47685136 if (leaf != null)
47695137 {
47705138 cTreePath tp = new cTreePath(this, leaf);
4771
- if (editWindow != null)
5139
+ ObjEditor window = GetWindow();
5140
+ if (window != null)
47725141 {
4773
- editWindow.Select(tp, deselect, true);
5142
+ window.Select(tp, deselect, true);
47745143 }
47755144
47765145 return tp;
....@@ -5095,6 +5464,51 @@
50955464 blockloop = false;
50965465 }
50975466
5467
+ void ResetSelectable()
5468
+ {
5469
+ if (blockloop)
5470
+ return;
5471
+
5472
+ blockloop = true;
5473
+
5474
+ keepdontselect = dontselect;
5475
+ dontselect = true;
5476
+
5477
+ Object3D child;
5478
+ int nb = Size();
5479
+ for (int i = 0; i < nb; i++)
5480
+ {
5481
+ child = (Object3D) get(i);
5482
+ if (child == null)
5483
+ continue;
5484
+ child.ResetSelectable();
5485
+ }
5486
+
5487
+ blockloop = false;
5488
+ }
5489
+
5490
+ void RestoreSelectable()
5491
+ {
5492
+ if (blockloop)
5493
+ return;
5494
+
5495
+ blockloop = true;
5496
+
5497
+ dontselect = keepdontselect;
5498
+
5499
+ Object3D child;
5500
+ int nb = Size();
5501
+ for (int i = 0; i < nb; i++)
5502
+ {
5503
+ child = (Object3D) get(i);
5504
+ if (child == null)
5505
+ continue;
5506
+ child.RestoreSelectable();
5507
+ }
5508
+
5509
+ blockloop = false;
5510
+ }
5511
+
50985512 boolean IsSelected()
50995513 {
51005514 if (parent == null)
....@@ -5157,10 +5571,34 @@
51575571
51585572 // System.out.println("Fullname = " + fullname);
51595573
5160
- if (fullname.name.indexOf(":") == -1)
5161
- return fullname.name;
5574
+ // Does not work on Windows due to C:
5575
+// if (fullname.name.indexOf(":") == -1)
5576
+// return fullname.name;
5577
+//
5578
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51625579
5163
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5580
+ String[] split = fullname.name.split(":");
5581
+
5582
+ if (split.length == 0)
5583
+ {
5584
+ return "";
5585
+ }
5586
+
5587
+ if (split.length <= 2)
5588
+ {
5589
+ if (fullname.name.endsWith(":"))
5590
+ {
5591
+ // Windows
5592
+ return fullname.name.substring(0, fullname.name.length()-1);
5593
+ }
5594
+
5595
+ return split[0];
5596
+ }
5597
+
5598
+ // Windows
5599
+ assert(split.length == 4);
5600
+
5601
+ return split[0] + ":" + split[1];
51645602 }
51655603
51665604 static String GetBump(cTexture fullname)
....@@ -5169,10 +5607,38 @@
51695607 return "";
51705608
51715609 // 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());
5610
+ // Does not work on Windows due to C:
5611
+// if (fullname.name.indexOf(":") == -1)
5612
+// return "";
5613
+//
5614
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5615
+ String[] split = fullname.name.split(":");
5616
+
5617
+ if (split.length == 0)
5618
+ {
5619
+ return "";
5620
+ }
5621
+
5622
+ if (split.length == 1)
5623
+ {
5624
+ return "";
5625
+ }
5626
+
5627
+ if (split.length == 2)
5628
+ {
5629
+ if (fullname.name.endsWith(":"))
5630
+ {
5631
+ // Windows
5632
+ return "";
5633
+ }
5634
+
5635
+ return split[1];
5636
+ }
5637
+
5638
+ // Windows
5639
+ assert(split.length == 4);
5640
+
5641
+ return split[2] + ":" + split[3];
51765642 }
51775643
51785644 String GetPigmentTexture()
....@@ -5246,7 +5712,7 @@
52465712 System.out.print("; textures = " + textures);
52475713 System.out.println("; usedtextures = " + usedtextures);
52485714
5249
- if (GetTextures() == null)
5715
+ if (GetTextures() == null) // What is that??
52505716 GetTextures().name = ":";
52515717
52525718 String texname = tex;
....@@ -5277,6 +5743,43 @@
52775743 child.ResetPigmentTexture();
52785744 blockloop = false;
52795745 }
5746
+ }
5747
+
5748
+ UUID GetUUID()
5749
+ {
5750
+ if (uuid == null)
5751
+ {
5752
+ // Serial
5753
+ uuid = UUID.randomUUID();
5754
+ }
5755
+
5756
+ return uuid;
5757
+ }
5758
+
5759
+ Object3D GetObject(UUID uid)
5760
+ {
5761
+ if (blockloop)
5762
+ return null;
5763
+
5764
+ if (GetUUID().equals(uid))
5765
+ return this;
5766
+
5767
+ int nb = Size();
5768
+ for (int i = 0; i < nb; i++)
5769
+ {
5770
+ Object3D child = (Object3D) get(i);
5771
+
5772
+ if (child == null)
5773
+ continue;
5774
+
5775
+ blockloop = true;
5776
+ Object3D obj = child.GetObject(uid);
5777
+ blockloop = false;
5778
+ if (obj != null)
5779
+ return obj;
5780
+ }
5781
+
5782
+ return null;
52805783 }
52815784
52825785 void SetBumpTexture(String tex)
....@@ -5315,6 +5818,38 @@
53155818 }
53165819 }
53175820
5821
+ void EmbedTextures(boolean embed)
5822
+ {
5823
+ if (blockloop)
5824
+ return;
5825
+
5826
+ //if (GetTextures() != null)
5827
+ if (embed)
5828
+ CameraPane.EmbedTextures(GetTextures());
5829
+ else
5830
+ {
5831
+ GetTextures().pigmentdata = null;
5832
+ GetTextures().bumpdata = null;
5833
+ GetTextures().pw = 0;
5834
+ GetTextures().ph = 0;
5835
+ GetTextures().bw = 0;
5836
+ GetTextures().bh = 0;
5837
+ }
5838
+
5839
+ int nb = Size();
5840
+ for (int i = 0; i < nb; i++)
5841
+ {
5842
+ Object3D child = (Object3D) get(i);
5843
+
5844
+ if (child == null)
5845
+ continue;
5846
+
5847
+ blockloop = true;
5848
+ child.EmbedTextures(embed);
5849
+ blockloop = false;
5850
+ }
5851
+ }
5852
+
53185853 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53195854 {
53205855 Draw(display, root, selected, blocked);
....@@ -5323,12 +5858,23 @@
53235858 boolean NeedSupport()
53245859 {
53255860 return
5326
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5861
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53275862 // PROBLEM with CROWD!!
5328
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5863
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53295864 }
53305865
53315866 static boolean DEBUG_SELECTION = false;
5867
+
5868
+ boolean IsLive()
5869
+ {
5870
+ if (live)
5871
+ return true;
5872
+
5873
+ if (parent == null)
5874
+ return false;
5875
+
5876
+ return parent.IsLive();
5877
+ }
53325878
53335879 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53345880 {
....@@ -5340,7 +5886,7 @@
53405886 }
53415887
53425888 if (display.DrawMode() == iCameraPane.SELECTION &&
5343
- hide)
5889
+ (hide || dontselect))
53445890 return;
53455891
53465892 if (name != null && name.contains("sclera"))
....@@ -5390,8 +5936,10 @@
53905936 if (support != null)
53915937 support = support;
53925938
5393
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5394
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5939
+ boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5940
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5941
+
5942
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
53955943
53965944 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53975945 {
....@@ -5401,8 +5949,9 @@
54015949 // usecalllists &= !(parent instanceof RandomNode);
54025950 // usecalllists = false;
54035951
5404
- if (GetBRep() != null)
5405
- usecalllists = usecalllists;
5952
+ if (display.DrawMode() == display.SHADOW)
5953
+ //GetBRep() != null)
5954
+ usecalllists = !!usecalllists;
54065955 //System.out.println("draw " + this);
54075956 //new Exception().printStackTrace();
54085957
....@@ -5411,10 +5960,12 @@
54115960 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54125961
54135962 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5414
- (touched || (bRep != null && bRep.displaylist <= 0)))
5963
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5964
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54155965 {
54165966 Globals.lighttouched = true;
54175967 } // all panes...
5968
+
54185969 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54195970 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54205971 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5973,7 @@
54225973 if (!(this instanceof Composite))
54235974 touched = false;
54245975 //if (displaylist == -1 && usecalllists)
5425
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
5976
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
54265977 {
54275978 bRep.displaylist = display.GenList();
54285979 assert(bRep.displaylist != 0);
....@@ -5433,7 +5984,7 @@
54335984
54345985 //System.out.println("\tnew list " + list);
54355986 //gl.glDrawBuffer(gl.GL_NONE);
5436
- if (usecalllists)
5987
+ if (usecalllists && bRep.displaylist > 0)
54375988 {
54385989 // System.err.println("new list " + bRep.displaylist + " for " + this);
54395990 display.NewList(bRep.displaylist);
....@@ -5442,7 +5993,7 @@
54425993 CallList(display, root, selected, blocked);
54435994
54445995 // compiled = true;
5445
- if (usecalllists)
5996
+ if (usecalllists && bRep.displaylist > 0)
54465997 {
54475998 // System.err.println("end list " + bRep.displaylist + " for " + this);
54485999 display.EndList();
....@@ -5542,6 +6093,7 @@
55426093 if (GetBRep() != null)
55436094 {
55446095 display.NextIndex();
6096
+
55456097 // vertex color conflict : gl.glCallList(list);
55466098 DrawNode(display, root, selected);
55476099 if (this instanceof BezierPatch)
....@@ -5582,7 +6134,28 @@
55826134 tex = GetTextures();
55836135 }
55846136
5585
- display.BindTextures(tex, texres);
6137
+ boolean failedPigment = false;
6138
+ boolean failedBump = false;
6139
+
6140
+ try
6141
+ {
6142
+ display.BindPigmentTexture(tex, texres);
6143
+ }
6144
+ catch (Exception e)
6145
+ {
6146
+ System.err.println("FAILED: " + this);
6147
+ failedPigment = true;
6148
+ }
6149
+
6150
+ try
6151
+ {
6152
+ display.BindBumpTexture(tex, texres);
6153
+ }
6154
+ catch (Exception e)
6155
+ {
6156
+ //System.err.println("FAILED: " + this);
6157
+ failedBump = true;
6158
+ }
55866159
55876160 if (!compiled)
55886161 {
....@@ -5604,7 +6177,11 @@
56046177 }
56056178 }
56066179
5607
- display.ReleaseTextures(tex);
6180
+ if (!failedBump)
6181
+ display.ReleaseBumpTexture(tex);
6182
+
6183
+ if (!failedPigment)
6184
+ display.ReleasePigmentTexture(tex);
56086185
56096186 display.PopMaterial(this, selected);
56106187 }
....@@ -5733,6 +6310,9 @@
57336310
57346311 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57356312 {
6313
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6314
+ return;
6315
+
57366316 if (hide)
57376317 return;
57386318 // shadow optimisation
....@@ -5858,6 +6438,9 @@
58586438 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58596439 return; // no shadow for transparent objects
58606440
6441
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6442
+ return;
6443
+
58616444 if (hide)
58626445 return;
58636446
....@@ -5898,6 +6481,7 @@
58986481 return;
58996482 }
59006483
6484
+ //bRep.GenUV(1/material.diffuseness);
59016485 // bRep.lock = true;
59026486
59036487 //javax.media.opengl.GL gl = display.GetGL();
....@@ -5970,6 +6554,11 @@
59706554 // dec 2012
59716555 new Exception().printStackTrace();
59726556 return;
6557
+ }
6558
+
6559
+ if (dontselect)
6560
+ {
6561
+ //bRep.GenerateNormalsMINE();
59736562 }
59746563
59756564 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6755,20 +7344,23 @@
67557344 }
67567345 }
67577346
6758
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7347
+ static ClickInfo clickInfo = new ClickInfo();
7348
+
7349
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7350
+ Point outPt, Rectangle outRec)
67597351 {
6760
- int hc = info.bounds.x + info.bounds.width / 2;
6761
- int vc = info.bounds.y + info.bounds.height / 2;
6762
- double[][] toscreen = info.toScreen;
7352
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7353
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7354
+ double[][] toscreen = clickInfo.toScreen;
67637355 if (toscreen == null)
67647356 {
6765
- toscreen = new Camera(info.camera.viewCode).toScreen;
7357
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
67667358 }
67677359 cVector vec = in;
67687360 LA.xformPos(in, toscreen, in);
67697361 //System.out.println("Distance = " + info.camera.Distance());
6770
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6771
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7362
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7363
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
67727364 outPt.x = hc + (int) vec.x;
67737365 outPt.y = vc - (int) vec.y;
67747366 outRec.x = outPt.x - 3;
....@@ -6776,15 +7368,18 @@
67767368 outRec.width = outRec.height = 6;
67777369 }
67787370
6779
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7371
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7372
+ )
67807373 {
67817374 Point pt = new Point(0, 0);
67827375 Rectangle rec = new Rectangle();
6783
- calcHotSpot(in, info, pt, rec);
7376
+ calcHotSpot(in, //clickInfo,
7377
+ pt, rec);
67847378 return rec;
67857379 }
67867380
6787
- void drawEditHandles0(ClickInfo info, int level)
7381
+ void drawEditHandles0(//ClickInfo clickInfo,
7382
+ int level)
67887383 {
67897384 if (level == 0)
67907385 {
....@@ -6793,16 +7388,19 @@
67937388 {
67947389 cVector origin = new cVector();
67957390 //LA.xformPos(origin, toParent, origin);
6796
- Rectangle spot = calcHotSpot(origin, info);
7391
+ if (this.clickInfo == null)
7392
+ this.clickInfo = new ClickInfo();
7393
+
7394
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
67977395 Rectangle boundary = new Rectangle();
67987396 boundary.x = spot.x - 30;
67997397 boundary.y = spot.y - 30;
68007398 boundary.width = spot.width + 60;
68017399 boundary.height = spot.height + 60;
6802
- info.g.setColor(Color.red);
7400
+ clickInfo.g.setColor(Color.red);
68037401 int spotw = spot.x + spot.width;
68047402 int spoth = spot.y + spot.height;
6805
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7403
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68067404 // if (CameraPane.Xmin > spot.x)
68077405 // {
68087406 // CameraPane.Xmin = spot.x;
....@@ -6822,8 +7420,8 @@
68227420 spot.translate(32, 32);
68237421 spotw = spot.x + spot.width;
68247422 spoth = spot.y + spot.height;
6825
- info.g.setColor(Color.blue);
6826
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7423
+ clickInfo.g.setColor(Color.cyan);
7424
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
68277425 // if (CameraPane.Xmin > spot.x)
68287426 // {
68297427 // CameraPane.Xmin = spot.x;
....@@ -6840,11 +7438,12 @@
68407438 // {
68417439 // CameraPane.Ymax = spoth;
68427440 // }
6843
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6844
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7441
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7442
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
68457443 spot.translate(0, -32);
6846
- info.g.setColor(Color.green);
6847
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7444
+ clickInfo.g.setColor(Color.yellow);
7445
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7446
+ clickInfo.g.setColor(Color.green);
68487447 // if (CameraPane.Xmin > spot.x)
68497448 // {
68507449 // CameraPane.Xmin = spot.x;
....@@ -6861,8 +7460,8 @@
68617460 // {
68627461 // CameraPane.Ymax = spoth;
68637462 // }
6864
- info.g.drawArc(boundary.x, boundary.y,
6865
- boundary.width, boundary.height, 0, 360);
7463
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7464
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
68667465 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
68677466 // if (CameraPane.Xmin > boundary.x)
68687467 // {
....@@ -6884,7 +7483,8 @@
68847483 }
68857484 }
68867485
6887
- boolean doEditClick0(ClickInfo info, int level)
7486
+ boolean doEditClick0(//ClickInfo clickInfo,
7487
+ int level)
68887488 {
68897489 if (level == 0)
68907490 {
....@@ -6893,10 +7493,10 @@
68937493
68947494 boolean retval = false;
68957495
6896
- startX = info.x;
6897
- startY = info.y;
7496
+ startX = clickInfo.x;
7497
+ startY = clickInfo.y;
68987498
6899
- hitSomething = 0;
7499
+ hitSomething = -1;
69007500 cVector origin = new cVector();
69017501 //LA.xformPos(origin, toParent, origin);
69027502 Rectangle spot = new Rectangle();
....@@ -6904,22 +7504,51 @@
69047504 {
69057505 centerPt = new Point(0, 0);
69067506 }
6907
- calcHotSpot(origin, info, centerPt, spot);
6908
- if (spot.contains(info.x, info.y))
7507
+ calcHotSpot(origin, //info,
7508
+ centerPt, spot);
7509
+ if (spot.contains(clickInfo.x, clickInfo.y))
69097510 {
69107511 hitSomething = hitCenter;
69117512 retval = true;
69127513 }
69137514 spot.translate(32, 0);
6914
- if (spot.contains(info.x, info.y))
7515
+ if (spot.contains(clickInfo.x, clickInfo.y))
69157516 {
69167517 hitSomething = hitRotate;
69177518 retval = true;
69187519 }
69197520 spot.translate(0, 32);
6920
- if (spot.contains(info.x, info.y))
7521
+ if (spot.contains(clickInfo.x, clickInfo.y))
69217522 {
69227523 hitSomething = hitScale;
7524
+
7525
+ double scale = 0.005f * clickInfo.camera.Distance();
7526
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7527
+ double sign = 1;
7528
+ if (hScale < 0)
7529
+ {
7530
+ sign = -1;
7531
+ }
7532
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7533
+ if (hScale < 0.01)
7534
+ {
7535
+ //hScale = 0.01;
7536
+ }
7537
+
7538
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7539
+ sign = 1;
7540
+ if (vScale < 0)
7541
+ {
7542
+ sign = -1;
7543
+ }
7544
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7545
+ if (vScale < 0.01)
7546
+ {
7547
+ //vScale = 0.01;
7548
+ }
7549
+
7550
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7551
+
69237552 retval = true;
69247553 }
69257554
....@@ -6929,7 +7558,7 @@
69297558 }
69307559
69317560 //System.out.println("info.modifiers = " + info.modifiers);
6932
- modified = (info.modifiers & CameraPane.META) != 0;
7561
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
69337562 //System.out.println("modified = " + modified);
69347563 //new Exception().printStackTrace();
69357564 //viewCode = info.pane.renderCamera.viewCode;
....@@ -6957,7 +7586,8 @@
69577586 return true;
69587587 }
69597588
6960
- void doEditDrag0(ClickInfo info)
7589
+ void doEditDrag0(//ClickInfo info,
7590
+ boolean opposite)
69617591 {
69627592 if (hitSomething == 0)
69637593 {
....@@ -6971,7 +7601,8 @@
69717601
69727602 //System.out.println("hitSomething = " + hitSomething);
69737603
6974
- double scale = 0.005f * info.camera.Distance();
7604
+ double scale = 0.005f * clickInfo.camera.Distance();
7605
+
69757606 cVector xlate = new cVector();
69767607 //cVector xlate2 = new cVector();
69777608 switch (hitSomething)
....@@ -6984,7 +7615,7 @@
69847615
69857616 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
69867617
6987
- if (modified)
7618
+ if (modified || opposite)
69887619 {
69897620 //assert(false);
69907621 /*
....@@ -7004,8 +7635,8 @@
70047635 toParent[3][i] = xlate.get(i);
70057636 LA.matInvert(toParent, fromParent);
70067637 */
7007
- cVector delta = LA.newVector(0, 0, startY - info.y);
7008
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7638
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7639
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70097640
70107641 LA.matCopy(startMat, toParent);
70117642 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7014,7 +7645,7 @@
70147645 } else
70157646 {
70167647 //LA.xformDir(delta, info.camera.fromScreen, delta);
7017
- cVector up = new cVector(info.camera.up);
7648
+ cVector up = new cVector(clickInfo.camera.up);
70187649 cVector away = new cVector();
70197650 //cVector right2 = new cVector();
70207651 //LA.vecCross(up, cVector.Z, right);
....@@ -7031,19 +7662,19 @@
70317662 LA.xformDir(up, ClickInfo.matbuffer, up);
70327663 // if (!CameraPane.LOCALTRANSFORM)
70337664 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7034
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7665
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
70357666 // if (!CameraPane.LOCALTRANSFORM)
70367667 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
70377668 //LA.vecCross(up, cVector.Z, right2);
70387669
7039
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7670
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
70407671
70417672 //System.out.println("DELTA0 = " + delta);
70427673 //System.out.println("AWAY = " + info.camera.away);
70437674 //System.out.println("UP = " + info.camera.up);
70447675 if (away.z > 0)
70457676 {
7046
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7677
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
70477678 {
70487679 delta.x = -delta.x;
70497680 } else
....@@ -7058,7 +7689,7 @@
70587689 //System.out.println("DELTA1 = " + delta);
70597690 LA.xformDir(delta, ClickInfo.matbuffer, delta);
70607691 //System.out.println("DELTA2 = " + delta);
7061
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7692
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
70627693 LA.matCopy(startMat, toParent);
70637694 //System.out.println("DELTA3 = " + delta);
70647695 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7068,8 +7699,8 @@
70687699 break;
70697700
70707701 case hitRotate: // rotate
7071
- int dx = info.x - centerPt.x;
7072
- int dy = -(info.y - centerPt.y);
7702
+ int dx = clickInfo.x - centerPt.x;
7703
+ int dy = -(clickInfo.y - centerPt.y);
70737704 double angle = (double) Math.atan2(dx, dy);
70747705 angle = -(1.570796 - angle);
70757706
....@@ -7078,6 +7709,7 @@
70787709
70797710 if (modified)
70807711 {
7712
+ // Rotate 90 degrees
70817713 angle /= (Math.PI / 4);
70827714 angle = Math.floor(angle + 0.5);
70837715 angle *= (Math.PI / 4);
....@@ -7091,7 +7723,7 @@
70917723 }
70927724 /**/
70937725
7094
- switch (info.pane.RenderCamera().viewCode)
7726
+ switch (clickInfo.pane.RenderCamera().viewCode)
70957727 {
70967728 case 1: // '\001'
70977729 LA.matZRotate(toParent, angle);
....@@ -7118,26 +7750,30 @@
71187750 break;
71197751
71207752 case hitScale: // scale
7121
- double hScale = (double) (info.x - centerPt.x) / 32;
7753
+ double hScale = (double) (clickInfo.x - centerPt.x) / 32;
7754
+ double sign = 1;
7755
+ if (hScale < 0)
7756
+ {
7757
+ sign = -1;
7758
+ }
7759
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
71227760 if (hScale < 0.01)
71237761 {
7124
- hScale = 0.01;
7762
+ //hScale = 0.01;
71257763 }
7126
- hScale = Math.pow(hScale, scale * 50);
7127
- if (hScale < 0.01)
7764
+
7765
+ double vScale = (double) (clickInfo.y - centerPt.y) / 32;
7766
+ sign = 1;
7767
+ if (vScale < 0)
71287768 {
7129
- hScale = 0.01;
7769
+ sign = -1;
71307770 }
7131
- double vScale = (double) (info.y - centerPt.y) / 32;
7771
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
71327772 if (vScale < 0.01)
71337773 {
7134
- vScale = 0.01;
7774
+ //vScale = 0.01;
71357775 }
7136
- vScale = Math.pow(vScale, scale * 50);
7137
- if (vScale < 0.01)
7138
- {
7139
- vScale = 0.01;
7140
- }
7776
+
71417777 LA.matCopy(startMat, toParent);
71427778 /**/
71437779 for (int i = 0; i < 3; i++)
....@@ -7147,39 +7783,47 @@
71477783 }
71487784 /**/
71497785
7150
- switch (info.pane.RenderCamera().viewCode)
7786
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7787
+
7788
+ if (totalScale < 0.01)
7789
+ {
7790
+ totalScale = 0.01;
7791
+ }
7792
+
7793
+ switch (clickInfo.pane.RenderCamera().viewCode)
71517794 {
71527795 case 3: // '\001'
7153
- if (modified)
7796
+ if (modified || opposite)
71547797 {
71557798 //LA.matScale(toParent, 1, hScale, vScale);
7156
- LA.matScale(toParent, vScale, 1, 1);
7799
+ LA.matScale(toParent, totalScale, 1, 1);
71577800 } // vScale, 1);
71587801 else
71597802 {
7160
- LA.matScale(toParent, vScale, vScale, vScale);
7803
+ // EXCEPTION!
7804
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
71617805 } // vScale, 1);
71627806 break;
71637807
71647808 case 2: // '\002'
7165
- if (modified)
7809
+ if (modified || opposite)
71667810 {
71677811 //LA.matScale(toParent, hScale, 1, vScale);
7168
- LA.matScale(toParent, 1, vScale, 1);
7812
+ LA.matScale(toParent, 1, totalScale, 1);
71697813 } else
71707814 {
7171
- LA.matScale(toParent, vScale, 1, vScale);
7815
+ LA.matScale(toParent, totalScale, 1, totalScale);
71727816 }
71737817 break;
71747818
71757819 case 1: // '\003'
7176
- if (modified)
7820
+ if (modified || opposite)
71777821 {
71787822 //LA.matScale(toParent, hScale, vScale, 1);
7179
- LA.matScale(toParent, 1, 1, vScale);
7823
+ LA.matScale(toParent, 1, 1, totalScale);
71807824 } else
71817825 {
7182
- LA.matScale(toParent, vScale, vScale, 1);
7826
+ LA.matScale(toParent, totalScale, totalScale, 1);
71837827 }
71847828 break;
71857829 }
....@@ -7213,7 +7857,7 @@
72137857 } // NEW ...
72147858
72157859
7216
- info.pane.repaint();
7860
+ clickInfo.pane.repaint();
72177861 }
72187862
72197863 boolean overflow = false;
....@@ -7312,14 +7956,22 @@
73127956 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
73137957 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
73147958 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7959
+
7960
+ String objname;
7961
+
73157962 if (false) //parent != null)
73167963 {
7317
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7964
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
73187965 } else
73197966 {
7320
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7967
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
73217968 } // + super.toString();
73227969 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7970
+
7971
+ if (!Globals.ADVANCED)
7972
+ return objname;
7973
+
7974
+ return objname + " " + System.identityHashCode(this);
73237975 }
73247976
73257977 public int hashCode()
....@@ -7375,6 +8027,7 @@
73758027 objectUI.closeUI();
73768028 if (editWindow != null)
73778029 {
8030
+ editWindow.ctrlPanel.FlushUI();
73788031 editWindow.refreshContents();
73798032 } // ? new
73808033 objectUI = null;
....@@ -7383,6 +8036,10 @@
73838036 {
73848037 editWindow = null;
73858038 } // ?
8039
+ }
8040
+ else
8041
+ {
8042
+ //editWindow.closeUI();
73868043 }
73878044 }
73888045
....@@ -7395,7 +8052,7 @@
73958052 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
73968053
73978054 Object3D /*Composite*/ parent;
7398
- Object3D /*Composite*/ fileparent;
8055
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
73998056
74008057 double[][] toParent; // dynamic matrix
74018058 double[][] fromParent;
....@@ -7510,7 +8167,7 @@
75108167 {
75118168 assert(bRep != null);
75128169 if (!(support instanceof GenericJoint)) // support.bRep != null)
7513
- GrafreeD.Assert(support.bRep == bRep.support);
8170
+ Grafreed.Assert(support.bRep == bRep.support);
75148171 }
75158172 else
75168173 {
....@@ -7541,6 +8198,10 @@
75418198 }
75428199
75438200 transient ObjEditor editWindow;
8201
+ transient ObjEditor manipWindow;
8202
+
8203
+ transient boolean pinned;
8204
+
75448205 transient ObjectUI objectUI;
75458206 public static int povDepth = 0;
75468207 private static cVector tbMin = new cVector();
....@@ -7559,9 +8220,9 @@
75598220 private static cVector edge2 = new cVector();
75608221 //private static cVector norm = new cVector();
75618222 /*transient private*/ int hitSomething;
7562
- private static final int hitCenter = 1;
7563
- private static final int hitScale = 2;
7564
- private static final int hitRotate = 3;
8223
+ static final int hitCenter = 1;
8224
+ static final int hitScale = 2;
8225
+ static final int hitRotate = 3;
75658226 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
75668227 /*transient*/ private Point centerPt;
75678228 /*transient*/ private int startX;