Normand Briere
2019-08-26 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a
Object3D.java
....@@ -22,10 +22,37 @@
2222 //static final long serialVersionUID = -607422624994562685L;
2323 static final long serialVersionUID = 5022536242724664900L;
2424
25
+ // Use GetUUID for backward compatibility with null.
2526 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
+
39
+ java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>();
2640
2741 ScriptNode scriptnode;
2842
43
+ int VersionCount()
44
+ {
45
+ int count = 0;
46
+
47
+ for (int i = versionlist.length; --i >= 0;)
48
+ {
49
+ if (versionlist[i] != null)
50
+ count++;
51
+ }
52
+
53
+ return count;
54
+ }
55
+
2956 void InitOthers()
3057 {
3158 if (projectedVertices == null || projectedVertices.length <= 2)
....@@ -104,125 +131,245 @@
104131
105132 // transient boolean reduced; // for morph reduction
106133
107
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
108
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
134
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
135
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
109136
110
-transient Object3D transientsupport; // for cloning
111
-transient boolean transientlink2master;
137
+ transient Object3D transientsupport; // for cloning
138
+ transient boolean transientlink2master;
112139
113
-void SaveSupports()
114
-{
115
- if (blockloop)
116
- return;
117
-
118
- transientsupport = support;
119
- transientlink2master = link2master;
120
-
121
- support = null;
122
- link2master = false;
123
-
124
- if (bRep != null)
140
+ void SaveSupports()
125141 {
126
- bRep.SaveSupports();
142
+ if (blockloop)
143
+ return;
144
+
145
+ transientsupport = support;
146
+ transientlink2master = link2master;
147
+
148
+ support = null;
149
+ link2master = false;
150
+
151
+ if (bRep != null)
152
+ {
153
+ bRep.SaveSupports();
154
+ }
155
+
156
+ for (int i = 0; i < Size(); i++)
157
+ {
158
+ Object3D child = (Object3D) get(i);
159
+ if (child == null)
160
+ continue;
161
+ blockloop = true;
162
+ child.SaveSupports();
163
+ blockloop = false;
164
+ }
127165 }
128
-
129
- for (int i = 0; i < Size(); i++)
166
+
167
+ void RestoreSupports()
130168 {
131
- Object3D child = (Object3D) get(i);
132
- if (child == null)
133
- continue;
169
+ if (blockloop)
170
+ return;
171
+
172
+ support = transientsupport;
173
+ link2master = transientlink2master;
174
+ transientsupport = null;
175
+ transientlink2master = false;
176
+
177
+ if (bRep != null)
178
+ {
179
+ bRep.RestoreSupports();
180
+ }
181
+
182
+ for (int i = 0; i < Size(); i++)
183
+ {
184
+ Object3D child = (Object3D) get(i);
185
+ if (child == null)
186
+ continue;
187
+ blockloop = true;
188
+ child.RestoreSupports();
189
+ blockloop = false;
190
+ }
191
+ }
192
+
193
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
194
+ {
195
+ Object3D o;
196
+
197
+ if (hashtable.containsKey(GetUUID()))
198
+ {
199
+ o = hashtable.get(GetUUID());
200
+
201
+ Grafreed.Assert(this.bRep == o.bRep);
202
+ //if (this.bRep != null)
203
+ // assert(this.bRep.support == o.transientrep);
204
+ if (this.support != null)
205
+ assert(this.support.bRep == o.transientrep);
206
+ }
207
+ else
208
+ {
209
+ o = new Object3D("copy of " + this.name);
210
+
211
+ hashtable.put(GetUUID(), o);
212
+ }
213
+
214
+ if (!blockloop)
215
+ {
216
+ blockloop = true;
217
+
218
+ for (int i=0; i<Size(); i++)
219
+ {
220
+ get(i).ExtractBigData(hashtable);
221
+ }
222
+
223
+ blockloop = false;
224
+ }
225
+
226
+ ExtractBigData(o);
227
+ }
228
+
229
+ void ExtractBigData(Object3D o)
230
+ {
231
+ if (o.bRep != null)
232
+ Grafreed.Assert(o.bRep == this.bRep);
233
+
234
+ o.bRep = this.bRep;
235
+// July 2019 if (this.bRep != null)
236
+// {
237
+// o.transientrep = this.bRep.support;
238
+// o.bRep.support = null;
239
+// }
240
+ o.selection = this.selection;
241
+ o.versionlist = this.versionlist;
242
+ o.versionindex = this.versionindex;
243
+
244
+ if (this.support != null)
245
+ {
246
+ if (o.transientrep != null)
247
+ Grafreed.Assert(o.transientrep == this.support.bRep);
248
+
249
+ o.transientrep = this.support.bRep;
250
+ this.support.bRep = null;
251
+ }
252
+
253
+ // o.support = this.support;
254
+ // o.fileparent = this.fileparent;
255
+ // if (this.bRep != null)
256
+ // o.bRep = this.bRep.support;
257
+
258
+ this.bRep = null;
259
+ // if (this.bRep != null)
260
+ // this.bRep.support = null;
261
+ // this.support = null;
262
+ // this.fileparent = null;
263
+ }
264
+
265
+// Object3D GetObject(java.util.UUID uuid)
266
+// {
267
+// if (this.uuid.equals(uuid))
268
+// return this;
269
+//
270
+// if (blockloop)
271
+// return null;
272
+//
273
+// blockloop = true;
274
+//
275
+// for (int i=0; i<Size(); i++)
276
+// {
277
+// Object3D o = get(i).GetObject(uuid);
278
+//
279
+// if (o != null)
280
+// return o;
281
+// }
282
+//
283
+// blockloop = false;
284
+//
285
+// return null;
286
+// }
287
+
288
+ transient boolean tag;
289
+
290
+ void TagObjects(Object3D o, boolean tag)
291
+ {
292
+ if (blockloop)
293
+ return;
294
+
295
+ o.tag = tag;
296
+
297
+ if (o == this)
298
+ return;
299
+
134300 blockloop = true;
135
- child.SaveSupports();
301
+
302
+ for (int i=0; i<Size(); i++)
303
+ {
304
+ get(i).TagObjects(o, tag);
305
+ }
306
+
136307 blockloop = false;
137308 }
138
-}
139309
140
-void RestoreSupports()
141
-{
142
- if (blockloop)
143
- return;
310
+ boolean HasTags()
311
+ {
312
+ if (blockloop)
313
+ return false;
144314
145
- support = transientsupport;
146
- link2master = transientlink2master;
147
- transientsupport = null;
148
- transientlink2master = false;
149
-
150
- if (bRep != null)
151
- {
152
- bRep.RestoreSupports();
153
- }
154
-
155
- for (int i = 0; i < Size(); i++)
156
- {
157
- Object3D child = (Object3D) get(i);
158
- if (child == null)
159
- continue;
160315 blockloop = true;
161
- child.RestoreSupports();
162
- blockloop = false;
163
- }
164
-}
165316
166
-void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
167
-{
168
- if (hashtable.containsKey(GetUUID()))
317
+ boolean hasTags = false;
318
+
319
+ for (int i=0; i<Size(); i++)
320
+ {
321
+ hasTags |= get(i).tag || get(i).HasTags();
322
+
323
+ if (hasTags)
324
+ break;
325
+ }
326
+
327
+ blockloop = false;
328
+
329
+ return hasTags;
330
+ }
331
+
332
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
169333 {
334
+ if (!hashtable.containsKey(GetUUID()))
335
+ return;
336
+
170337 Object3D o = hashtable.get(GetUUID());
171338
172
- assert(this.bRep == o.bRep);
173
- if (this.bRep != null)
174
- assert(this.bRep.support == o.transientrep);
175
-
176
- return;
177
- }
178
-
179
- Object3D o = new Object3D();
180
- o.bRep = this.bRep;
181
- if (this.bRep != null)
182
- {
183
- o.transientrep = this.bRep.support;
184
- o.bRep.support = null;
185
- }
186
-
187
-// o.support = this.support;
188
-// o.fileparent = this.fileparent;
189
-// if (this.bRep != null)
190
-// o.bRep = this.bRep.support;
191
-
192
- hashtable.put(GetUUID(), o);
193
-
194
- this.bRep = null;
195
-// if (this.bRep != null)
196
-// this.bRep.support = null;
197
-// this.support = null;
198
-// this.fileparent = null;
199
-
200
- for (int i=0; i<Size(); i++)
201
- {
202
- get(i).ExtractBigData(hashtable);
203
- }
204
-}
339
+ RestoreBigData(o);
205340
206
-void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
207
-{
208
- if (!hashtable.containsKey(GetUUID()))
209
- return;
210
-
211
- Object3D o = hashtable.get(GetUUID());
212
-
213
- this.bRep = o.bRep;
214
- if (this.bRep != null)
215
- this.bRep.support = o.transientrep;
216
-// this.support = o.support;
217
-// this.fileparent = o.fileparent;
218
-
219
- hashtable.remove(GetUUID());
220
-
221
- for (int i=0; i<Size(); i++)
222
- {
223
- get(i).RestoreBigData(hashtable);
341
+ if (blockloop)
342
+ return;
343
+
344
+ blockloop = true;
345
+
346
+ //hashtable.remove(GetUUID());
347
+
348
+ for (int i=0; i<Size(); i++)
349
+ {
350
+ get(i).RestoreBigData(hashtable);
351
+ }
352
+
353
+ blockloop = false;
224354 }
225
-}
355
+
356
+ void RestoreBigData(Object3D o)
357
+ {
358
+ this.bRep = o.bRep;
359
+ if (this.support != null && o.transientrep != null)
360
+ {
361
+ this.support.bRep = o.transientrep;
362
+ }
363
+
364
+ this.selection = o.selection;
365
+
366
+ this.versionlist = o.versionlist;
367
+ this.versionindex = o.versionindex;
368
+// July 2019 if (this.bRep != null)
369
+// this.bRep.support = o.transientrep;
370
+ // this.support = o.support;
371
+ // this.fileparent = o.fileparent;
372
+ }
226373
227374 // MOCAP SUPPORT
228375 double tx,ty,tz,rx,ry,rz;
....@@ -365,6 +512,7 @@
365512 }
366513
367514 boolean live = false;
515
+ transient boolean keepdontselect;
368516 boolean dontselect = false;
369517 boolean hide = false;
370518 boolean link2master = false; // performs reset support/master at each frame
....@@ -433,11 +581,11 @@
433581 }
434582 }
435583
436
- int memorysize;
584
+ transient int memorysize; // needs to be transient, dunno why
437585
438586 int MemorySize()
439587 {
440
- if (true) // memorysize == 0)
588
+ if (memorysize == 0)
441589 {
442590 try
443591 {
....@@ -547,12 +695,14 @@
547695 toParent = LA.newMatrix();
548696 fromParent = LA.newMatrix();
549697 }
698
+
550699 if (toParentMarked == null)
551700 {
552701 if (maxcount != 1)
553702 {
554
- new Exception().printStackTrace();
703
+ //new Exception().printStackTrace();
555704 }
705
+
556706 toParentMarked = LA.newMatrix();
557707 fromParentMarked = LA.newMatrix();
558708 }
....@@ -863,7 +1013,7 @@
8631013
8641014 if (marked && Globals.isLIVE() && live &&
8651015 //TEMP21aug2018
866
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
1016
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
8671017 currentframe != Globals.framecount)
8681018 {
8691019 currentframe = Globals.framecount;
....@@ -875,7 +1025,8 @@
8751025
8761026 boolean changedir = random && Math.random() < 0.01; // && !link2master;
8771027
878
- if (transformcount*factor > maxcount || (step == 1 && changedir))
1028
+ if (transformcount*factor >= maxcount && (rewind || random) ||
1029
+ (step == 1 && changedir))
8791030 {
8801031 countdown = 1;
8811032 delay = speedup?8:1;
....@@ -947,6 +1098,10 @@
9471098 if (material == null || material.multiply)
9481099 return true;
9491100
1101
+ if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
1102
+ return false;
1103
+
1104
+ // Transparent objects are dynamic because we have to sort the triangles.
9501105 return material.opacity > 0.99;
9511106 }
9521107
....@@ -1347,6 +1502,7 @@
13471502 toParent = LA.newMatrix();
13481503 fromParent = LA.newMatrix();
13491504 }
1505
+
13501506 LA.matCopy(other.toParent, toParent);
13511507 LA.matCopy(other.fromParent, fromParent);
13521508
....@@ -2226,11 +2382,6 @@
22262382
22272383 InitOthers();
22282384
2229
- if (this instanceof Camera)
2230
- {
2231
- material.shift = 90;
2232
- }
2233
-
22342385 material.multiply = multiply;
22352386
22362387 if (multiply)
....@@ -2368,6 +2519,15 @@
23682519 }
23692520 */
23702521 }
2522
+ else
2523
+ {
2524
+ //((ObjEditor)editWindow).SetupUI2(null);
2525
+ if (objectUI != null)
2526
+ ((ObjEditor)objectUI).pinButton.setSelected(pinned);
2527
+ else
2528
+ //new Exception().printStackTrace();
2529
+ System.err.println("objectUI is null");
2530
+ }
23712531 }
23722532
23732533 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2409,6 +2569,14 @@
24092569 {
24102570 editWindow.refreshContents();
24112571 }
2572
+ else
2573
+ {
2574
+ if (manipWindow != null)
2575
+ {
2576
+ manipWindow.refreshContents();
2577
+ }
2578
+ }
2579
+
24122580 //if (parent != null)
24132581 //parent.refreshEditWindow();
24142582 }
....@@ -2488,7 +2656,8 @@
24882656 private static final int editSelf = 1;
24892657 private static final int editChild = 2;
24902658
2491
- void drawEditHandles(ClickInfo info, int level)
2659
+ void drawEditHandles(//ClickInfo info,
2660
+ int level)
24922661 {
24932662 if (level == 0)
24942663 {
....@@ -2496,7 +2665,8 @@
24962665 return;
24972666
24982667 Object3D selectee;
2499
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2668
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2669
+ level + 1))
25002670 {
25012671 selectee = (Object3D) e.nextElement();
25022672 }
....@@ -2504,19 +2674,22 @@
25042674 } else
25052675 {
25062676 //super.
2507
- drawEditHandles0(info, level + 1);
2677
+ drawEditHandles0(//info,
2678
+ level + 1);
25082679 }
25092680 }
25102681
2511
- boolean doEditClick(ClickInfo info, int level)
2682
+ boolean doEditClick(//ClickInfo info,
2683
+ int level)
25122684 {
25132685 doSomething = 0;
25142686 if (level == 0)
25152687 {
2516
- return doParentClick(info);
2688
+ return doParentClick(); //info);
25172689 }
25182690 if (//super.
2519
- doEditClick0(info, level))
2691
+ doEditClick0(//info,
2692
+ level))
25202693 {
25212694 doSomething = 1;
25222695 return true;
....@@ -2526,7 +2699,7 @@
25262699 }
25272700 }
25282701
2529
- boolean doParentClick(ClickInfo info)
2702
+ boolean doParentClick() //ClickInfo info)
25302703 {
25312704 if (selection == null)
25322705 {
....@@ -2539,7 +2712,8 @@
25392712 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
25402713 {
25412714 Object3D selectee = (Object3D) e.nextElement();
2542
- if (selectee.doEditClick(info, 1))
2715
+ if (selectee.doEditClick(//info,
2716
+ 1))
25432717 {
25442718 childToDrag = selectee;
25452719 doSomething = 2;
....@@ -2551,13 +2725,15 @@
25512725 return retval;
25522726 }
25532727
2554
- void doEditDrag(ClickInfo info, boolean opposite)
2728
+ void doEditDrag(//ClickInfo clickInfo,
2729
+ boolean opposite)
25552730 {
25562731 switch (doSomething)
25572732 {
25582733 case 1: // '\001'
25592734 //super.
2560
- doEditDrag0(info, opposite);
2735
+ doEditDrag0(//clickInfo,
2736
+ opposite);
25612737 break;
25622738
25632739 case 2: // '\002'
....@@ -2570,11 +2746,13 @@
25702746 {
25712747 //sel.hitSomething = childToDrag.hitSomething;
25722748 //childToDrag.doEditDrag(info);
2573
- sel.doEditDrag(info, opposite);
2749
+ sel.doEditDrag(//clickInfo,
2750
+ opposite);
25742751 } else
25752752 {
25762753 //super.
2577
- doEditDrag0(info, opposite);
2754
+ doEditDrag0(//clickInfo,
2755
+ opposite);
25782756 }
25792757 }
25802758 break;
....@@ -2592,6 +2770,9 @@
25922770 {
25932771 deselectAll();
25942772 }
2773
+
2774
+ new Exception().printStackTrace();
2775
+
25952776 ClickInfo newInfo = new ClickInfo();
25962777 newInfo.flags = info.flags;
25972778 newInfo.bounds = info.bounds;
....@@ -2684,6 +2865,18 @@
26842865 void GenNormalsS(boolean crease)
26852866 {
26862867 selection.GenNormals(crease);
2868
+// for (int i=0; i<selection.size(); i++)
2869
+// {
2870
+// Object3D selectee = (Object3D) selection.elementAt(i);
2871
+// selectee.GenNormals(crease);
2872
+// }
2873
+
2874
+ //Touch();
2875
+ }
2876
+
2877
+ void GenNormalsMeshS()
2878
+ {
2879
+ selection.GenNormalsMesh();
26872880 // for (int i=0; i<selection.size(); i++)
26882881 // {
26892882 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2824,6 +3017,24 @@
28243017 if (child == null)
28253018 continue;
28263019 child.GenNormals(crease);
3020
+// Children().release(i);
3021
+ }
3022
+ blockloop = false;
3023
+ }
3024
+
3025
+ void GenNormalsMesh()
3026
+ {
3027
+ if (blockloop)
3028
+ return;
3029
+
3030
+ blockloop = true;
3031
+ GenNormalsMesh0();
3032
+ for (int i = 0; i < Children().Size(); i++)
3033
+ {
3034
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
3035
+ if (child == null)
3036
+ continue;
3037
+ child.GenNormalsMesh();
28273038 // Children().release(i);
28283039 }
28293040 blockloop = false;
....@@ -2996,11 +3207,20 @@
29963207 }
29973208 }
29983209
3210
+ void GenNormalsMesh0()
3211
+ {
3212
+ if (bRep != null)
3213
+ {
3214
+ bRep.GenerateNormalsMesh();
3215
+ Touch();
3216
+ }
3217
+ }
3218
+
29993219 void GenNormalsMINE0()
30003220 {
30013221 if (bRep != null)
30023222 {
3003
- bRep.GenerateNormalsMINE();
3223
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
30043224 Touch();
30053225 }
30063226 }
....@@ -3057,6 +3277,93 @@
30573277 blockloop = false;
30583278 }
30593279
3280
+ public void ResetTransform(int mask)
3281
+ {
3282
+ Object3D obj = this;
3283
+
3284
+ if (mask == -1)
3285
+ {
3286
+ if (obj instanceof Camera) // jan 2014
3287
+ {
3288
+ LA.matIdentity(obj.toParent);
3289
+ LA.matIdentity(obj.fromParent);
3290
+ }
3291
+ else
3292
+ {
3293
+ obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent);
3294
+ obj.fromParent = null; // LA.matIdentity(obj.fromParent);
3295
+ }
3296
+ return;
3297
+ }
3298
+
3299
+ if ((mask&2) != 0) // Scale/rotation
3300
+ {
3301
+ obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1;
3302
+ obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0;
3303
+ obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0;
3304
+ obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1;
3305
+ obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0;
3306
+ obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0;
3307
+ }
3308
+ if ((mask&1) != 0) // Translation
3309
+ {
3310
+ if (obj.toParent != null)
3311
+ {
3312
+ obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0;
3313
+ obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0;
3314
+ }
3315
+ }
3316
+ }
3317
+
3318
+ public void TextureRatioTransform(int axis)
3319
+ {
3320
+ cTexture tex = GetTextures();
3321
+
3322
+ com.sun.opengl.util.texture.TextureData texturedata = null;
3323
+
3324
+ try
3325
+ {
3326
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, texres);
3327
+ }
3328
+ catch (Exception e)
3329
+ {
3330
+ System.err.println("FAIL TextureRatio: " + this);
3331
+ }
3332
+
3333
+ LA.matIdentity(Object3D.mat);
3334
+ Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight();
3335
+
3336
+ if (toParent == null)
3337
+ {
3338
+ toParent = LA.newMatrix();
3339
+ fromParent = LA.newMatrix();
3340
+ }
3341
+
3342
+ ResetTransform(2);
3343
+
3344
+ LA.matConcat(Object3D.mat, fromParent, fromParent);
3345
+ LA.matInvert(fromParent, toParent);
3346
+ }
3347
+
3348
+ void TextureRatio(int axis)
3349
+ {
3350
+ if (blockloop)
3351
+ return;
3352
+
3353
+ blockloop = true;
3354
+
3355
+ TextureRatioTransform(axis);
3356
+
3357
+ for (int i=Size(); --i>=0;)
3358
+ {
3359
+ Object3D v = get(i);
3360
+
3361
+ v.TextureRatio(axis);
3362
+ }
3363
+
3364
+ blockloop = false;
3365
+ }
3366
+
30603367 void TransformChildren()
30613368 {
30623369 if (toParent != null)
....@@ -3410,15 +3717,47 @@
34103717
34113718 void ClearMaterials()
34123719 {
3720
+ if (blockloop)
3721
+ return;
3722
+
3723
+ blockloop = true;
3724
+
34133725 ClearMaterial();
3414
- for (int i = 0; i < size(); i++)
3726
+ for (int i = 0; i < Size(); i++)
34153727 {
3416
- Object3D child = (Object3D) reserve(i);
3728
+ Object3D child = (Object3D) get(i);
34173729 if (child == null)
34183730 continue;
34193731 child.ClearMaterials();
3420
- release(i);
34213732 }
3733
+
3734
+ blockloop = false;
3735
+ }
3736
+
3737
+ void ClearVersionList()
3738
+ {
3739
+ this.versionlist = null;
3740
+ this.versionindex = -1;
3741
+ this.versiontable = null;
3742
+ }
3743
+
3744
+ void ClearVersions()
3745
+ {
3746
+ if (blockloop)
3747
+ return;
3748
+
3749
+ blockloop = true;
3750
+
3751
+ ClearVersionList();
3752
+ for (int i = 0; i < Size(); i++)
3753
+ {
3754
+ Object3D child = (Object3D) get(i);
3755
+ if (child == null)
3756
+ continue;
3757
+ child.ClearVersions();
3758
+ }
3759
+
3760
+ blockloop = false;
34223761 }
34233762
34243763 void FlipV(boolean flip)
....@@ -3446,7 +3785,8 @@
34463785 if (blockloop)
34473786 return;
34483787
3449
- if (marked || (bRep != null && material != null)) // borderline...
3788
+ if (//marked || // does not make sense
3789
+ (bRep != null || material != null)) // borderline...
34503790 live = h;
34513791
34523792 for (int i = 0; i < Size(); i++)
....@@ -3467,7 +3807,8 @@
34673807 return;
34683808
34693809 //if (bRep != null)
3470
- if (marked || (bRep != null && material != null)) // borderline...
3810
+ if (//marked || // does not make sense
3811
+ (bRep != null || material != null)) // borderline...
34713812 link2master = h;
34723813
34733814 for (int i = 0; i < Size(); i++)
....@@ -3487,7 +3828,8 @@
34873828 if (blockloop)
34883829 return;
34893830
3490
- if (marked || (bRep != null && material != null)) // borderline...
3831
+ if (//marked || // does not make sense
3832
+ (bRep != null || material != null)) // borderline...
34913833 hide = h;
34923834
34933835 for (int i = 0; i < Size(); i++)
....@@ -3507,7 +3849,7 @@
35073849 if (blockloop)
35083850 return;
35093851
3510
- if (bRep != null && material != null) // borderline...
3852
+ if (bRep != null || material != null) // borderline...
35113853 marked = h;
35123854
35133855 for (int i = 0; i < Size(); i++)
....@@ -3517,6 +3859,46 @@
35173859 continue;
35183860 blockloop = true;
35193861 child.MarkLeaves(h);
3862
+ blockloop = false;
3863
+ // release(i);
3864
+ }
3865
+ }
3866
+
3867
+ void RewindLeaves(boolean h)
3868
+ {
3869
+ if (blockloop)
3870
+ return;
3871
+
3872
+ if (bRep != null || material != null) // borderline...
3873
+ rewind = h;
3874
+
3875
+ for (int i = 0; i < Size(); i++)
3876
+ {
3877
+ Object3D child = (Object3D) get(i); // reserve(i);
3878
+ if (child == null)
3879
+ continue;
3880
+ blockloop = true;
3881
+ child.RewindLeaves(h);
3882
+ blockloop = false;
3883
+ // release(i);
3884
+ }
3885
+ }
3886
+
3887
+ void RandomLeaves(boolean h)
3888
+ {
3889
+ if (blockloop)
3890
+ return;
3891
+
3892
+ if (bRep != null || material != null) // borderline...
3893
+ random = h;
3894
+
3895
+ for (int i = 0; i < Size(); i++)
3896
+ {
3897
+ Object3D child = (Object3D) get(i); // reserve(i);
3898
+ if (child == null)
3899
+ continue;
3900
+ blockloop = true;
3901
+ child.RandomLeaves(h);
35203902 blockloop = false;
35213903 // release(i);
35223904 }
....@@ -4294,6 +4676,55 @@
42944676 }
42954677 }
42964678
4679
+ void RepairSOV()
4680
+ {
4681
+ if (blockloop)
4682
+ return;
4683
+
4684
+ String texname = this.GetPigmentTexture();
4685
+
4686
+ if (texname.startsWith("sov"))
4687
+ {
4688
+ String[] s = texname.split("/");
4689
+
4690
+ String[] sname = s[1].split("Color.pn");
4691
+
4692
+ texname = sname[0];
4693
+
4694
+ if (sname.length > 1)
4695
+ {
4696
+ texname += "Color.jpg";
4697
+ }
4698
+
4699
+ this.SetPigmentTexture("sov/" + texname);
4700
+ }
4701
+
4702
+ texname = this.GetBumpTexture();
4703
+
4704
+ if (texname.startsWith("sov"))
4705
+ {
4706
+ String[] s = texname.split("/");
4707
+
4708
+ String[] sname = s[1].split("Bump.pn");
4709
+
4710
+ texname = sname[0];
4711
+
4712
+ if (sname.length > 1)
4713
+ {
4714
+ texname += "Bump.jpg";
4715
+ }
4716
+
4717
+ this.SetBumpTexture("sov/" + texname);
4718
+ }
4719
+
4720
+ for (int i=0; i<Size(); i++)
4721
+ {
4722
+ blockloop = true;
4723
+ get(i).RepairSOV();
4724
+ blockloop = false;
4725
+ }
4726
+ }
4727
+
42974728 void RepairTexture()
42984729 {
42994730 if (this instanceof FileObject || blockloop)
....@@ -4808,6 +5239,14 @@
48085239 }
48095240 }
48105241
5242
+ ObjEditor GetWindow()
5243
+ {
5244
+ if (editWindow != null)
5245
+ return editWindow;
5246
+
5247
+ return manipWindow;
5248
+ }
5249
+
48115250 cTreePath Select(int indexcount, boolean deselect)
48125251 {
48135252 if (hide || dontselect)
....@@ -4844,10 +5283,11 @@
48445283 if (leaf != null)
48455284 {
48465285 cTreePath tp = new cTreePath(this, leaf);
4847
- if (editWindow != null)
5286
+ ObjEditor window = GetWindow();
5287
+ if (window != null)
48485288 {
48495289 //System.out.println("editWindow = " + editWindow + " vs " + this);
4850
- editWindow.Select(tp, deselect, true);
5290
+ window.Select(tp, deselect, true);
48515291 }
48525292
48535293 return tp;
....@@ -4864,6 +5304,7 @@
48645304
48655305 if (child == null)
48665306 continue;
5307
+
48675308 if (child.HasTransparency() && child.size() != 0)
48685309 {
48695310 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4873,9 +5314,10 @@
48735314 if (leaf != null)
48745315 {
48755316 cTreePath tp = new cTreePath(this, leaf);
4876
- if (editWindow != null)
5317
+ ObjEditor window = GetWindow();
5318
+ if (window != null)
48775319 {
4878
- editWindow.Select(tp, deselect, true);
5320
+ window.Select(tp, deselect, true);
48795321 }
48805322
48815323 return tp;
....@@ -5200,6 +5642,51 @@
52005642 blockloop = false;
52015643 }
52025644
5645
+ void ResetSelectable()
5646
+ {
5647
+ if (blockloop)
5648
+ return;
5649
+
5650
+ blockloop = true;
5651
+
5652
+ keepdontselect = dontselect;
5653
+ dontselect = true;
5654
+
5655
+ Object3D child;
5656
+ int nb = Size();
5657
+ for (int i = 0; i < nb; i++)
5658
+ {
5659
+ child = (Object3D) get(i);
5660
+ if (child == null)
5661
+ continue;
5662
+ child.ResetSelectable();
5663
+ }
5664
+
5665
+ blockloop = false;
5666
+ }
5667
+
5668
+ void RestoreSelectable()
5669
+ {
5670
+ if (blockloop)
5671
+ return;
5672
+
5673
+ blockloop = true;
5674
+
5675
+ dontselect = keepdontselect;
5676
+
5677
+ Object3D child;
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ child = (Object3D) get(i);
5682
+ if (child == null)
5683
+ continue;
5684
+ child.RestoreSelectable();
5685
+ }
5686
+
5687
+ blockloop = false;
5688
+ }
5689
+
52035690 boolean IsSelected()
52045691 {
52055692 if (parent == null)
....@@ -5260,6 +5747,11 @@
52605747 if (fullname == null)
52615748 return "";
52625749
5750
+ if (fullname.pigment != null)
5751
+ {
5752
+ return fullname.pigment;
5753
+ }
5754
+
52635755 // System.out.println("Fullname = " + fullname);
52645756
52655757 // Does not work on Windows due to C:
....@@ -5272,7 +5764,7 @@
52725764
52735765 if (split.length == 0)
52745766 {
5275
- return "";
5767
+ return fullname.pigment = "";
52765768 }
52775769
52785770 if (split.length <= 2)
....@@ -5280,22 +5772,27 @@
52805772 if (fullname.name.endsWith(":"))
52815773 {
52825774 // Windows
5283
- return fullname.name.substring(0, fullname.name.length()-1);
5775
+ return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1);
52845776 }
52855777
5286
- return split[0];
5778
+ return fullname.pigment = split[0];
52875779 }
52885780
52895781 // Windows
52905782 assert(split.length == 4);
52915783
5292
- return split[0] + ":" + split[1];
5784
+ return fullname.pigment = split[0] + ":" + split[1];
52935785 }
52945786
52955787 static String GetBump(cTexture fullname)
52965788 {
52975789 if (fullname == null)
52985790 return "";
5791
+
5792
+ if (fullname.bump != null)
5793
+ {
5794
+ return fullname.bump;
5795
+ }
52995796
53005797 // System.out.println("Fullname = " + fullname);
53015798 // Does not work on Windows due to C:
....@@ -5307,12 +5804,12 @@
53075804
53085805 if (split.length == 0)
53095806 {
5310
- return "";
5807
+ return fullname.bump = "";
53115808 }
53125809
53135810 if (split.length == 1)
53145811 {
5315
- return "";
5812
+ return fullname.bump = "";
53165813 }
53175814
53185815 if (split.length == 2)
....@@ -5320,16 +5817,16 @@
53205817 if (fullname.name.endsWith(":"))
53215818 {
53225819 // Windows
5323
- return "";
5820
+ return fullname.bump = "";
53245821 }
53255822
5326
- return split[1];
5823
+ return fullname.bump = split[1];
53275824 }
53285825
53295826 // Windows
53305827 assert(split.length == 4);
53315828
5332
- return split[2] + ":" + split[3];
5829
+ return fullname.bump = split[2] + ":" + split[3];
53335830 }
53345831
53355832 String GetPigmentTexture()
....@@ -5412,6 +5909,9 @@
54125909 texname = "";
54135910
54145911 GetTextures().name = texname + ":" + GetBump(GetTextures());
5912
+
5913
+ GetTextures().pigment = null;
5914
+
54155915 Touch();
54165916 }
54175917
....@@ -5485,6 +5985,8 @@
54855985
54865986 GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname;
54875987
5988
+ GetTextures().bump = null;
5989
+
54885990 Touch();
54895991 }
54905992
....@@ -5509,6 +6011,38 @@
55096011 }
55106012 }
55116013
6014
+ void EmbedTextures(boolean embed)
6015
+ {
6016
+ if (blockloop)
6017
+ return;
6018
+
6019
+ //if (GetTextures() != null)
6020
+ if (embed)
6021
+ CameraPane.EmbedTextures(GetTextures());
6022
+ else
6023
+ {
6024
+ GetTextures().pigmentdata = null;
6025
+ GetTextures().bumpdata = null;
6026
+ GetTextures().pw = 0;
6027
+ GetTextures().ph = 0;
6028
+ GetTextures().bw = 0;
6029
+ GetTextures().bh = 0;
6030
+ }
6031
+
6032
+ int nb = Size();
6033
+ for (int i = 0; i < nb; i++)
6034
+ {
6035
+ Object3D child = (Object3D) get(i);
6036
+
6037
+ if (child == null)
6038
+ continue;
6039
+
6040
+ blockloop = true;
6041
+ child.EmbedTextures(embed);
6042
+ blockloop = false;
6043
+ }
6044
+ }
6045
+
55126046 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55136047 {
55146048 Draw(display, root, selected, blocked);
....@@ -5517,12 +6051,28 @@
55176051 boolean NeedSupport()
55186052 {
55196053 return
5520
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
6054
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
55216055 // PROBLEM with CROWD!!
55226056 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
55236057 }
55246058
55256059 static boolean DEBUG_SELECTION = false;
6060
+
6061
+ boolean IsLive()
6062
+ {
6063
+ if (live)
6064
+ return true;
6065
+
6066
+ if (parent == null)
6067
+ return false;
6068
+
6069
+ return parent.IsLive();
6070
+ }
6071
+
6072
+ boolean IsDynamic()
6073
+ {
6074
+ return live && bRep != null;
6075
+ }
55266076
55276077 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
55286078 {
....@@ -5584,8 +6134,11 @@
55846134 if (support != null)
55856135 support = support;
55866136
5587
- //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5588
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6137
+ boolean usecalllists = !IsDynamic() &&
6138
+ IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6139
+ //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
6140
+
6141
+ //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass.
55896142
55906143 if (!usecalllists && bRep != null && bRep.displaylist > 0)
55916144 {
....@@ -5595,8 +6148,9 @@
55956148 // usecalllists &= !(parent instanceof RandomNode);
55966149 // usecalllists = false;
55976150
5598
- if (GetBRep() != null)
5599
- usecalllists = usecalllists;
6151
+ if (display.DrawMode() == display.SHADOW)
6152
+ //GetBRep() != null)
6153
+ usecalllists = !!usecalllists;
56006154 //System.out.println("draw " + this);
56016155 //new Exception().printStackTrace();
56026156
....@@ -5605,10 +6159,12 @@
56056159 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
56066160
56076161 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5608
- (touched || (bRep != null && bRep.displaylist <= 0)))
6162
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
6163
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
56096164 {
56106165 Globals.lighttouched = true;
56116166 } // all panes...
6167
+
56126168 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
56136169 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
56146170 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5616,7 +6172,7 @@
56166172 if (!(this instanceof Composite))
56176173 touched = false;
56186174 //if (displaylist == -1 && usecalllists)
5619
- if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
6175
+ if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013
56206176 {
56216177 bRep.displaylist = display.GenList();
56226178 assert(bRep.displaylist != 0);
....@@ -5627,7 +6183,7 @@
56276183
56286184 //System.out.println("\tnew list " + list);
56296185 //gl.glDrawBuffer(gl.GL_NONE);
5630
- if (usecalllists)
6186
+ if (usecalllists && bRep.displaylist > 0)
56316187 {
56326188 // System.err.println("new list " + bRep.displaylist + " for " + this);
56336189 display.NewList(bRep.displaylist);
....@@ -5636,7 +6192,7 @@
56366192 CallList(display, root, selected, blocked);
56376193
56386194 // compiled = true;
5639
- if (usecalllists)
6195
+ if (usecalllists && bRep.displaylist > 0)
56406196 {
56416197 // System.err.println("end list " + bRep.displaylist + " for " + this);
56426198 display.EndList();
....@@ -5736,6 +6292,7 @@
57366292 if (GetBRep() != null)
57376293 {
57386294 display.NextIndex();
6295
+
57396296 // vertex color conflict : gl.glCallList(list);
57406297 DrawNode(display, root, selected);
57416298 if (this instanceof BezierPatch)
....@@ -5776,16 +6333,27 @@
57766333 tex = GetTextures();
57776334 }
57786335
5779
- boolean failed = false;
6336
+ boolean failedPigment = false;
6337
+ boolean failedBump = false;
57806338
57816339 try
57826340 {
5783
- display.BindTextures(tex, texres);
6341
+ display.BindPigmentTexture(tex, texres);
57846342 }
57856343 catch (Exception e)
57866344 {
57876345 System.err.println("FAILED: " + this);
5788
- failed = true;
6346
+ failedPigment = true;
6347
+ }
6348
+
6349
+ try
6350
+ {
6351
+ display.BindBumpTexture(tex, texres);
6352
+ }
6353
+ catch (Exception e)
6354
+ {
6355
+ //System.err.println("FAILED: " + this);
6356
+ failedBump = true;
57896357 }
57906358
57916359 if (!compiled)
....@@ -5808,8 +6376,11 @@
58086376 }
58096377 }
58106378
5811
- if (!failed)
5812
- display.ReleaseTextures(tex);
6379
+ if (!failedBump)
6380
+ display.ReleaseBumpTexture(tex);
6381
+
6382
+ if (!failedPigment)
6383
+ display.ReleasePigmentTexture(tex);
58136384
58146385 display.PopMaterial(this, selected);
58156386 }
....@@ -6182,6 +6753,11 @@
61826753 // dec 2012
61836754 new Exception().printStackTrace();
61846755 return;
6756
+ }
6757
+
6758
+ if (dontselect)
6759
+ {
6760
+ //bRep.GenerateNormalsMINE();
61856761 }
61866762
61876763 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6967,20 +7543,23 @@
69677543 }
69687544 }
69697545
6970
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7546
+ static ClickInfo clickInfo = new ClickInfo();
7547
+
7548
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7549
+ Point outPt, Rectangle outRec)
69717550 {
6972
- int hc = info.bounds.x + info.bounds.width / 2;
6973
- int vc = info.bounds.y + info.bounds.height / 2;
6974
- double[][] toscreen = info.toScreen;
7551
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7552
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7553
+ double[][] toscreen = clickInfo.toScreen;
69757554 if (toscreen == null)
69767555 {
6977
- toscreen = new Camera(info.camera.viewCode).toScreen;
7556
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
69787557 }
69797558 cVector vec = in;
69807559 LA.xformPos(in, toscreen, in);
69817560 //System.out.println("Distance = " + info.camera.Distance());
6982
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6983
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7561
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7562
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
69847563 outPt.x = hc + (int) vec.x;
69857564 outPt.y = vc - (int) vec.y;
69867565 outRec.x = outPt.x - 3;
....@@ -6988,15 +7567,18 @@
69887567 outRec.width = outRec.height = 6;
69897568 }
69907569
6991
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7570
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7571
+ )
69927572 {
69937573 Point pt = new Point(0, 0);
69947574 Rectangle rec = new Rectangle();
6995
- calcHotSpot(in, info, pt, rec);
7575
+ calcHotSpot(in, //clickInfo,
7576
+ pt, rec);
69967577 return rec;
69977578 }
69987579
6999
- void drawEditHandles0(ClickInfo info, int level)
7580
+ void drawEditHandles0(//ClickInfo clickInfo,
7581
+ int level)
70007582 {
70017583 if (level == 0)
70027584 {
....@@ -7005,16 +7587,19 @@
70057587 {
70067588 cVector origin = new cVector();
70077589 //LA.xformPos(origin, toParent, origin);
7008
- Rectangle spot = calcHotSpot(origin, info);
7590
+ if (this.clickInfo == null)
7591
+ this.clickInfo = new ClickInfo();
7592
+
7593
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
70097594 Rectangle boundary = new Rectangle();
70107595 boundary.x = spot.x - 30;
70117596 boundary.y = spot.y - 30;
70127597 boundary.width = spot.width + 60;
70137598 boundary.height = spot.height + 60;
7014
- info.g.setColor(Color.red);
7599
+ clickInfo.g.setColor(Color.white);
70157600 int spotw = spot.x + spot.width;
70167601 int spoth = spot.y + spot.height;
7017
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7602
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187603 // if (CameraPane.Xmin > spot.x)
70197604 // {
70207605 // CameraPane.Xmin = spot.x;
....@@ -7031,11 +7616,33 @@
70317616 // {
70327617 // CameraPane.Ymax = spoth;
70337618 // }
7034
- spot.translate(32, 32);
7619
+// if (CameraPane.Xmin > spot.x)
7620
+// {
7621
+// CameraPane.Xmin = spot.x;
7622
+// }
7623
+// if (CameraPane.Xmax < spotw)
7624
+// {
7625
+// CameraPane.Xmax = spotw;
7626
+// }
7627
+// if (CameraPane.Ymin > spot.y)
7628
+// {
7629
+// CameraPane.Ymin = spot.y;
7630
+// }
7631
+// if (CameraPane.Ymax < spoth)
7632
+// {
7633
+// CameraPane.Ymax = spoth;
7634
+// }
7635
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7636
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
7637
+ spot.translate(32, 0);
7638
+ clickInfo.g.setColor(Color.yellow);
7639
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7640
+
7641
+ spot.translate(32, 64);
70357642 spotw = spot.x + spot.width;
70367643 spoth = spot.y + spot.height;
7037
- info.g.setColor(Color.blue);
7038
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7644
+ clickInfo.g.setColor(Color.cyan);
7645
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70397646 // if (CameraPane.Xmin > spot.x)
70407647 // {
70417648 // CameraPane.Xmin = spot.x;
....@@ -7052,29 +7659,9 @@
70527659 // {
70537660 // CameraPane.Ymax = spoth;
70547661 // }
7055
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7056
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7057
- spot.translate(0, -32);
7058
- info.g.setColor(Color.green);
7059
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7060
-// if (CameraPane.Xmin > spot.x)
7061
-// {
7062
-// CameraPane.Xmin = spot.x;
7063
-// }
7064
-// if (CameraPane.Xmax < spotw)
7065
-// {
7066
-// CameraPane.Xmax = spotw;
7067
-// }
7068
-// if (CameraPane.Ymin > spot.y)
7069
-// {
7070
-// CameraPane.Ymin = spot.y;
7071
-// }
7072
-// if (CameraPane.Ymax < spoth)
7073
-// {
7074
-// CameraPane.Ymax = spoth;
7075
-// }
7076
- info.g.drawArc(boundary.x, boundary.y,
7077
- boundary.width, boundary.height, 0, 360);
7662
+ clickInfo.g.setColor(Color.green);
7663
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7664
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
70787665 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70797666 // if (CameraPane.Xmin > boundary.x)
70807667 // {
....@@ -7096,7 +7683,8 @@
70967683 }
70977684 }
70987685
7099
- boolean doEditClick0(ClickInfo info, int level)
7686
+ boolean doEditClick0(//ClickInfo clickInfo,
7687
+ int level)
71007688 {
71017689 if (level == 0)
71027690 {
....@@ -7105,8 +7693,8 @@
71057693
71067694 boolean retval = false;
71077695
7108
- startX = info.x;
7109
- startY = info.y;
7696
+ startX = clickInfo.x;
7697
+ startY = clickInfo.y;
71107698
71117699 hitSomething = -1;
71127700 cVector origin = new cVector();
....@@ -7116,22 +7704,53 @@
71167704 {
71177705 centerPt = new Point(0, 0);
71187706 }
7119
- calcHotSpot(origin, info, centerPt, spot);
7120
- if (spot.contains(info.x, info.y))
7707
+ calcHotSpot(origin, //info,
7708
+ centerPt, spot);
7709
+ if (spot.contains(clickInfo.x, clickInfo.y))
71217710 {
71227711 hitSomething = hitCenter;
71237712 retval = true;
71247713 }
71257714 spot.translate(32, 0);
7126
- if (spot.contains(info.x, info.y))
7715
+ if (spot.contains(clickInfo.x, clickInfo.y))
71277716 {
71287717 hitSomething = hitRotate;
71297718 retval = true;
71307719 }
71317720 spot.translate(0, 32);
7132
- if (spot.contains(info.x, info.y))
7721
+ spot.translate(32, 0);
7722
+ spot.translate(0, 32);
7723
+ if (spot.contains(clickInfo.x, clickInfo.y))
71337724 {
71347725 hitSomething = hitScale;
7726
+
7727
+ double scale = 0.005f * clickInfo.camera.Distance();
7728
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
7729
+ double sign = 1;
7730
+ if (hScale < 0)
7731
+ {
7732
+ sign = -1;
7733
+ }
7734
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7735
+ if (hScale < 0.01)
7736
+ {
7737
+ //hScale = 0.01;
7738
+ }
7739
+
7740
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
7741
+ sign = 1;
7742
+ if (vScale < 0)
7743
+ {
7744
+ sign = -1;
7745
+ }
7746
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7747
+ if (vScale < 0.01)
7748
+ {
7749
+ //vScale = 0.01;
7750
+ }
7751
+
7752
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7753
+
71357754 retval = true;
71367755 }
71377756
....@@ -7141,7 +7760,7 @@
71417760 }
71427761
71437762 //System.out.println("info.modifiers = " + info.modifiers);
7144
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7763
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
71457764 //System.out.println("modified = " + modified);
71467765 //new Exception().printStackTrace();
71477766 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7169,7 +7788,8 @@
71697788 return true;
71707789 }
71717790
7172
- void doEditDrag0(ClickInfo info, boolean opposite)
7791
+ void doEditDrag0(//ClickInfo info,
7792
+ boolean opposite)
71737793 {
71747794 if (hitSomething == 0)
71757795 {
....@@ -7183,7 +7803,7 @@
71837803
71847804 //System.out.println("hitSomething = " + hitSomething);
71857805
7186
- double scale = 0.005f * info.camera.Distance();
7806
+ double scale = 0.005f * clickInfo.camera.Distance();
71877807
71887808 cVector xlate = new cVector();
71897809 //cVector xlate2 = new cVector();
....@@ -7197,7 +7817,9 @@
71977817
71987818 scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71997819
7200
- if (modified || opposite)
7820
+ // Modified could snap
7821
+ if (//modified ||
7822
+ opposite)
72017823 {
72027824 //assert(false);
72037825 /*
....@@ -7217,8 +7839,8 @@
72177839 toParent[3][i] = xlate.get(i);
72187840 LA.matInvert(toParent, fromParent);
72197841 */
7220
- cVector delta = LA.newVector(0, 0, startY - info.y);
7221
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7842
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7843
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72227844
72237845 LA.matCopy(startMat, toParent);
72247846 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7227,7 +7849,7 @@
72277849 } else
72287850 {
72297851 //LA.xformDir(delta, info.camera.fromScreen, delta);
7230
- cVector up = new cVector(info.camera.up);
7852
+ cVector up = new cVector(clickInfo.camera.up);
72317853 cVector away = new cVector();
72327854 //cVector right2 = new cVector();
72337855 //LA.vecCross(up, cVector.Z, right);
....@@ -7244,19 +7866,19 @@
72447866 LA.xformDir(up, ClickInfo.matbuffer, up);
72457867 // if (!CameraPane.LOCALTRANSFORM)
72467868 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7247
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7869
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
72487870 // if (!CameraPane.LOCALTRANSFORM)
72497871 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72507872 //LA.vecCross(up, cVector.Z, right2);
72517873
7252
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7874
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
72537875
72547876 //System.out.println("DELTA0 = " + delta);
72557877 //System.out.println("AWAY = " + info.camera.away);
72567878 //System.out.println("UP = " + info.camera.up);
72577879 if (away.z > 0)
72587880 {
7259
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7881
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
72607882 {
72617883 delta.x = -delta.x;
72627884 } else
....@@ -7271,7 +7893,7 @@
72717893 //System.out.println("DELTA1 = " + delta);
72727894 LA.xformDir(delta, ClickInfo.matbuffer, delta);
72737895 //System.out.println("DELTA2 = " + delta);
7274
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7896
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
72757897 LA.matCopy(startMat, toParent);
72767898 //System.out.println("DELTA3 = " + delta);
72777899 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7281,8 +7903,8 @@
72817903 break;
72827904
72837905 case hitRotate: // rotate
7284
- int dx = info.x - centerPt.x;
7285
- int dy = -(info.y - centerPt.y);
7906
+ int dx = clickInfo.x - centerPt.x;
7907
+ int dy = -(clickInfo.y - centerPt.y);
72867908 double angle = (double) Math.atan2(dx, dy);
72877909 angle = -(1.570796 - angle);
72887910
....@@ -7291,7 +7913,7 @@
72917913
72927914 if (modified)
72937915 {
7294
- // Rotate 90 degrees
7916
+ // Rotate 45 degrees
72957917 angle /= (Math.PI / 4);
72967918 angle = Math.floor(angle + 0.5);
72977919 angle *= (Math.PI / 4);
....@@ -7305,7 +7927,7 @@
73057927 }
73067928 /**/
73077929
7308
- switch (info.pane.RenderCamera().viewCode)
7930
+ switch (clickInfo.pane.RenderCamera().viewCode)
73097931 {
73107932 case 1: // '\001'
73117933 LA.matZRotate(toParent, angle);
....@@ -7332,7 +7954,7 @@
73327954 break;
73337955
73347956 case hitScale: // scale
7335
- double hScale = (double) (info.x - centerPt.x) / 32;
7957
+ double hScale = (double) (clickInfo.x - centerPt.x) / 64;
73367958 double sign = 1;
73377959 if (hScale < 0)
73387960 {
....@@ -7344,7 +7966,7 @@
73447966 //hScale = 0.01;
73457967 }
73467968
7347
- double vScale = (double) (info.y - centerPt.y) / 32;
7969
+ double vScale = (double) (clickInfo.y - centerPt.y) / 64;
73487970 sign = 1;
73497971 if (vScale < 0)
73507972 {
....@@ -7355,6 +7977,7 @@
73557977 {
73567978 //vScale = 0.01;
73577979 }
7980
+
73587981 LA.matCopy(startMat, toParent);
73597982 /**/
73607983 for (int i = 0; i < 3; i++)
....@@ -7364,32 +7987,39 @@
73647987 }
73657988 /**/
73667989
7367
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7990
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
73687991
73697992 if (totalScale < 0.01)
73707993 {
73717994 totalScale = 0.01;
73727995 }
73737996
7374
- switch (info.pane.RenderCamera().viewCode)
7997
+ switch (clickInfo.pane.RenderCamera().viewCode)
73757998 {
73767999 case 3: // '\001'
7377
- if (modified)
8000
+ if (modified || opposite)
73788001 {
8002
+ if (modified) // && opposite)
8003
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8004
+ else
73798005 //LA.matScale(toParent, 1, hScale, vScale);
7380
- LA.matScale(toParent, totalScale, 1, 1);
8006
+ LA.matScale(toParent, totalScale, 1, 1);
73818007 } // vScale, 1);
73828008 else
73838009 {
7384
- LA.matScale(toParent, totalScale, totalScale, totalScale);
8010
+ // EXCEPTION!
8011
+ LA.matScale(toParent, 1, totalScale, totalScale);
73858012 } // vScale, 1);
73868013 break;
73878014
73888015 case 2: // '\002'
7389
- if (modified)
8016
+ if (modified || opposite)
73908017 {
7391
- //LA.matScale(toParent, hScale, 1, vScale);
7392
- LA.matScale(toParent, 1, totalScale, 1);
8018
+ if (modified) // && opposite)
8019
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8020
+ else
8021
+ //LA.matScale(toParent, hScale, 1, vScale);
8022
+ LA.matScale(toParent, 1, totalScale, 1);
73938023 } else
73948024 {
73958025 LA.matScale(toParent, totalScale, 1, totalScale);
....@@ -7397,10 +8027,13 @@
73978027 break;
73988028
73998029 case 1: // '\003'
7400
- if (modified)
8030
+ if (modified || opposite)
74018031 {
7402
- //LA.matScale(toParent, hScale, vScale, 1);
7403
- LA.matScale(toParent, 1, 1, totalScale);
8032
+ if (modified) // && opposite)
8033
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
8034
+ else
8035
+ //LA.matScale(toParent, hScale, vScale, 1);
8036
+ LA.matScale(toParent, 1, 1, totalScale);
74048037 } else
74058038 {
74068039 LA.matScale(toParent, totalScale, totalScale, 1);
....@@ -7437,7 +8070,7 @@
74378070 } // NEW ...
74388071
74398072
7440
- info.pane.repaint();
8073
+ clickInfo.pane.repaint();
74418074 }
74428075
74438076 boolean overflow = false;
....@@ -7548,10 +8181,10 @@
75488181 } // + super.toString();
75498182 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
75508183
7551
- if (!Globals.ADVANCED)
7552
- return objname;
8184
+// if (!Globals.ADVANCED)
8185
+// return objname;
75538186
7554
- return objname + " " + System.identityHashCode(this);
8187
+ return objname + " " + System.identityHashCode(this); // + GetUUID()
75558188 }
75568189
75578190 public int hashCode()
....@@ -7616,6 +8249,10 @@
76168249 {
76178250 editWindow = null;
76188251 } // ?
8252
+ }
8253
+ else
8254
+ {
8255
+ //editWindow.closeUI();
76198256 }
76208257 }
76218258
....@@ -7774,6 +8411,10 @@
77748411 }
77758412
77768413 transient ObjEditor editWindow;
8414
+ transient ObjEditor manipWindow;
8415
+
8416
+ transient boolean pinned;
8417
+
77778418 transient ObjectUI objectUI;
77788419 public static int povDepth = 0;
77798420 private static cVector tbMin = new cVector();