Normand Briere
2019-07-30 475f8cbdbd96fdbf8f5b216ffebb31a51f25c2f9
Object3D.java
....@@ -14,12 +14,27 @@
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
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ String skyboxname;
33
+ String skyboxext;
34
+
35
+ byte[] versions[];
36
+ int versionindex = -1;
37
+
2338 ScriptNode scriptnode;
2439
2540 void InitOthers()
....@@ -100,64 +115,178 @@
100115
101116 // transient boolean reduced; // for morph reduction
102117
103
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
104
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
118
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
119
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
105120
106
-transient Object3D transientsupport; // for cloning
107
-transient boolean transientlink2master;
121
+ transient Object3D transientsupport; // for cloning
122
+ transient boolean transientlink2master;
108123
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)
124
+ void SaveSupports()
121125 {
122
- bRep.SaveSupports();
126
+ if (blockloop)
127
+ return;
128
+
129
+ transientsupport = support;
130
+ transientlink2master = link2master;
131
+
132
+ support = null;
133
+ link2master = false;
134
+
135
+ if (bRep != null)
136
+ {
137
+ bRep.SaveSupports();
138
+ }
139
+
140
+ for (int i = 0; i < Size(); i++)
141
+ {
142
+ Object3D child = (Object3D) get(i);
143
+ if (child == null)
144
+ continue;
145
+ blockloop = true;
146
+ child.SaveSupports();
147
+ blockloop = false;
148
+ }
123149 }
124
-
125
- for (int i = 0; i < Size(); i++)
150
+
151
+ void RestoreSupports()
126152 {
127
- Object3D child = (Object3D) get(i);
128
- if (child == null)
129
- continue;
153
+ if (blockloop)
154
+ return;
155
+
156
+ support = transientsupport;
157
+ link2master = transientlink2master;
158
+ transientsupport = null;
159
+ transientlink2master = false;
160
+
161
+ if (bRep != null)
162
+ {
163
+ bRep.RestoreSupports();
164
+ }
165
+
166
+ for (int i = 0; i < Size(); i++)
167
+ {
168
+ Object3D child = (Object3D) get(i);
169
+ if (child == null)
170
+ continue;
171
+ blockloop = true;
172
+ child.RestoreSupports();
173
+ blockloop = false;
174
+ }
175
+ }
176
+
177
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
178
+ {
179
+ Object3D o;
180
+
181
+ if (hashtable.containsKey(GetUUID()))
182
+ {
183
+ o = hashtable.get(GetUUID());
184
+
185
+ Grafreed.Assert(this.bRep == o.bRep);
186
+ //if (this.bRep != null)
187
+ // assert(this.bRep.support == o.transientrep);
188
+ if (this.support != null)
189
+ assert(this.support.bRep == o.transientrep);
190
+ }
191
+ else
192
+ {
193
+ o = new Object3D("copy of " + this.name);
194
+
195
+ hashtable.put(GetUUID(), o);
196
+ }
197
+
198
+ if (!blockloop)
199
+ {
200
+ blockloop = true;
201
+
202
+ for (int i=0; i<Size(); i++)
203
+ {
204
+ get(i).ExtractBigData(hashtable);
205
+ }
206
+
207
+ blockloop = false;
208
+ }
209
+
210
+ ExtractBigData(o);
211
+ }
212
+
213
+ void ExtractBigData(Object3D o)
214
+ {
215
+ if (o.bRep != null)
216
+ Grafreed.Assert(o.bRep == this.bRep);
217
+
218
+ o.bRep = this.bRep;
219
+// July 2019 if (this.bRep != null)
220
+// {
221
+// o.transientrep = this.bRep.support;
222
+// o.bRep.support = null;
223
+// }
224
+ o.selection = this.selection;
225
+ o.versions = this.versions;
226
+ o.versionindex = this.versionindex;
227
+
228
+ if (this.support != null)
229
+ {
230
+ if (o.transientrep != null)
231
+ Grafreed.Assert(o.transientrep == this.support.bRep);
232
+
233
+ o.transientrep = this.support.bRep;
234
+ this.support.bRep = null;
235
+ }
236
+
237
+ // o.support = this.support;
238
+ // o.fileparent = this.fileparent;
239
+ // if (this.bRep != null)
240
+ // o.bRep = this.bRep.support;
241
+
242
+ this.bRep = null;
243
+ // if (this.bRep != null)
244
+ // this.bRep.support = null;
245
+ // this.support = null;
246
+ // this.fileparent = null;
247
+ }
248
+
249
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
250
+ {
251
+ if (!hashtable.containsKey(GetUUID()))
252
+ return;
253
+
254
+ Object3D o = hashtable.get(GetUUID());
255
+
256
+ RestoreBigData(o);
257
+
258
+ if (blockloop)
259
+ return;
260
+
130261 blockloop = true;
131
- child.SaveSupports();
262
+
263
+ //hashtable.remove(GetUUID());
264
+
265
+ for (int i=0; i<Size(); i++)
266
+ {
267
+ get(i).RestoreBigData(hashtable);
268
+ }
269
+
132270 blockloop = false;
133271 }
134
-}
135272
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)
273
+ void RestoreBigData(Object3D o)
147274 {
148
- bRep.RestoreSupports();
275
+ this.bRep = o.bRep;
276
+ if (this.support != null && o.transientrep != null)
277
+ {
278
+ this.support.bRep = o.transientrep;
279
+ }
280
+
281
+ this.selection = o.selection;
282
+
283
+ this.versions = o.versions;
284
+ this.versionindex = o.versionindex;
285
+// July 2019 if (this.bRep != null)
286
+// this.bRep.support = o.transientrep;
287
+ // this.support = o.support;
288
+ // this.fileparent = o.fileparent;
149289 }
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
-}
161290
162291 // MOCAP SUPPORT
163292 double tx,ty,tz,rx,ry,rz;
....@@ -300,6 +429,7 @@
300429 }
301430
302431 boolean live = false;
432
+ transient boolean keepdontselect;
303433 boolean dontselect = false;
304434 boolean hide = false;
305435 boolean link2master = false; // performs reset support/master at each frame
....@@ -482,12 +612,14 @@
482612 toParent = LA.newMatrix();
483613 fromParent = LA.newMatrix();
484614 }
615
+
485616 if (toParentMarked == null)
486617 {
487618 if (maxcount != 1)
488619 {
489620 new Exception().printStackTrace();
490621 }
622
+
491623 toParentMarked = LA.newMatrix();
492624 fromParentMarked = LA.newMatrix();
493625 }
....@@ -798,7 +930,7 @@
798930
799931 if (marked && Globals.isLIVE() && live &&
800932 //TEMP21aug2018
801
- (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) &&
933
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
802934 currentframe != Globals.framecount)
803935 {
804936 currentframe = Globals.framecount;
....@@ -810,7 +942,8 @@
810942
811943 boolean changedir = random && Math.random() < 0.01; // && !link2master;
812944
813
- if (transformcount*factor > maxcount || (step == 1 && changedir))
945
+ if (transformcount*factor >= maxcount && (rewind || random) ||
946
+ (step == 1 && changedir))
814947 {
815948 countdown = 1;
816949 delay = speedup?8:1;
....@@ -882,6 +1015,7 @@
8821015 if (material == null || material.multiply)
8831016 return true;
8841017
1018
+ // Transparent objects are dynamic because we have to sort the triangles.
8851019 return material.opacity > 0.99;
8861020 }
8871021
....@@ -1282,6 +1416,7 @@
12821416 toParent = LA.newMatrix();
12831417 fromParent = LA.newMatrix();
12841418 }
1419
+
12851420 LA.matCopy(other.toParent, toParent);
12861421 LA.matCopy(other.fromParent, fromParent);
12871422
....@@ -2303,6 +2438,10 @@
23032438 }
23042439 */
23052440 }
2441
+ else
2442
+ {
2443
+ //((ObjEditor)editWindow).SetupUI2(null);
2444
+ }
23062445 }
23072446
23082447 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
....@@ -2344,6 +2483,14 @@
23442483 {
23452484 editWindow.refreshContents();
23462485 }
2486
+ else
2487
+ {
2488
+ if (manipWindow != null)
2489
+ {
2490
+ manipWindow.refreshContents();
2491
+ }
2492
+ }
2493
+
23472494 //if (parent != null)
23482495 //parent.refreshEditWindow();
23492496 }
....@@ -2423,7 +2570,8 @@
24232570 private static final int editSelf = 1;
24242571 private static final int editChild = 2;
24252572
2426
- void drawEditHandles(ClickInfo info, int level)
2573
+ void drawEditHandles(//ClickInfo info,
2574
+ int level)
24272575 {
24282576 if (level == 0)
24292577 {
....@@ -2431,7 +2579,8 @@
24312579 return;
24322580
24332581 Object3D selectee;
2434
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2582
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2583
+ level + 1))
24352584 {
24362585 selectee = (Object3D) e.nextElement();
24372586 }
....@@ -2439,19 +2588,22 @@
24392588 } else
24402589 {
24412590 //super.
2442
- drawEditHandles0(info, level + 1);
2591
+ drawEditHandles0(//info,
2592
+ level + 1);
24432593 }
24442594 }
24452595
2446
- boolean doEditClick(ClickInfo info, int level)
2596
+ boolean doEditClick(//ClickInfo info,
2597
+ int level)
24472598 {
24482599 doSomething = 0;
24492600 if (level == 0)
24502601 {
2451
- return doParentClick(info);
2602
+ return doParentClick(); //info);
24522603 }
24532604 if (//super.
2454
- doEditClick0(info, level))
2605
+ doEditClick0(//info,
2606
+ level))
24552607 {
24562608 doSomething = 1;
24572609 return true;
....@@ -2461,7 +2613,7 @@
24612613 }
24622614 }
24632615
2464
- boolean doParentClick(ClickInfo info)
2616
+ boolean doParentClick() //ClickInfo info)
24652617 {
24662618 if (selection == null)
24672619 {
....@@ -2474,7 +2626,8 @@
24742626 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24752627 {
24762628 Object3D selectee = (Object3D) e.nextElement();
2477
- if (selectee.doEditClick(info, 1))
2629
+ if (selectee.doEditClick(//info,
2630
+ 1))
24782631 {
24792632 childToDrag = selectee;
24802633 doSomething = 2;
....@@ -2486,13 +2639,15 @@
24862639 return retval;
24872640 }
24882641
2489
- void doEditDrag(ClickInfo info, boolean opposite)
2642
+ void doEditDrag(//ClickInfo clickInfo,
2643
+ boolean opposite)
24902644 {
24912645 switch (doSomething)
24922646 {
24932647 case 1: // '\001'
24942648 //super.
2495
- doEditDrag0(info, opposite);
2649
+ doEditDrag0(//clickInfo,
2650
+ opposite);
24962651 break;
24972652
24982653 case 2: // '\002'
....@@ -2505,11 +2660,13 @@
25052660 {
25062661 //sel.hitSomething = childToDrag.hitSomething;
25072662 //childToDrag.doEditDrag(info);
2508
- sel.doEditDrag(info, opposite);
2663
+ sel.doEditDrag(//clickInfo,
2664
+ opposite);
25092665 } else
25102666 {
25112667 //super.
2512
- doEditDrag0(info, opposite);
2668
+ doEditDrag0(//clickInfo,
2669
+ opposite);
25132670 }
25142671 }
25152672 break;
....@@ -2527,6 +2684,9 @@
25272684 {
25282685 deselectAll();
25292686 }
2687
+
2688
+ new Exception().printStackTrace();
2689
+
25302690 ClickInfo newInfo = new ClickInfo();
25312691 newInfo.flags = info.flags;
25322692 newInfo.bounds = info.bounds;
....@@ -2619,6 +2779,18 @@
26192779 void GenNormalsS(boolean crease)
26202780 {
26212781 selection.GenNormals(crease);
2782
+// for (int i=0; i<selection.size(); i++)
2783
+// {
2784
+// Object3D selectee = (Object3D) selection.elementAt(i);
2785
+// selectee.GenNormals(crease);
2786
+// }
2787
+
2788
+ //Touch();
2789
+ }
2790
+
2791
+ void GenNormalsMeshS()
2792
+ {
2793
+ selection.GenNormalsMesh();
26222794 // for (int i=0; i<selection.size(); i++)
26232795 // {
26242796 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2759,6 +2931,24 @@
27592931 if (child == null)
27602932 continue;
27612933 child.GenNormals(crease);
2934
+// Children().release(i);
2935
+ }
2936
+ blockloop = false;
2937
+ }
2938
+
2939
+ void GenNormalsMesh()
2940
+ {
2941
+ if (blockloop)
2942
+ return;
2943
+
2944
+ blockloop = true;
2945
+ GenNormalsMesh0();
2946
+ for (int i = 0; i < Children().Size(); i++)
2947
+ {
2948
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2949
+ if (child == null)
2950
+ continue;
2951
+ child.GenNormalsMesh();
27622952 // Children().release(i);
27632953 }
27642954 blockloop = false;
....@@ -2931,11 +3121,20 @@
29313121 }
29323122 }
29333123
3124
+ void GenNormalsMesh0()
3125
+ {
3126
+ if (bRep != null)
3127
+ {
3128
+ bRep.GenerateNormalsMesh();
3129
+ Touch();
3130
+ }
3131
+ }
3132
+
29343133 void GenNormalsMINE0()
29353134 {
29363135 if (bRep != null)
29373136 {
2938
- bRep.GenerateNormalsMINE();
3137
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29393138 Touch();
29403139 }
29413140 }
....@@ -3381,7 +3580,8 @@
33813580 if (blockloop)
33823581 return;
33833582
3384
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33853585 live = h;
33863586
33873587 for (int i = 0; i < Size(); i++)
....@@ -3402,7 +3602,8 @@
34023602 return;
34033603
34043604 //if (bRep != null)
3405
- if (marked || (bRep != null && material != null)) // borderline...
3605
+ if (//marked || // does not make sense
3606
+ (bRep != null || material != null)) // borderline...
34063607 link2master = h;
34073608
34083609 for (int i = 0; i < Size(); i++)
....@@ -3422,7 +3623,8 @@
34223623 if (blockloop)
34233624 return;
34243625
3425
- if (marked || (bRep != null && material != null)) // borderline...
3626
+ if (//marked || // does not make sense
3627
+ (bRep != null || material != null)) // borderline...
34263628 hide = h;
34273629
34283630 for (int i = 0; i < Size(); i++)
....@@ -3442,7 +3644,7 @@
34423644 if (blockloop)
34433645 return;
34443646
3445
- if (bRep != null && material != null) // borderline...
3647
+ if (bRep != null || material != null) // borderline...
34463648 marked = h;
34473649
34483650 for (int i = 0; i < Size(); i++)
....@@ -3452,6 +3654,46 @@
34523654 continue;
34533655 blockloop = true;
34543656 child.MarkLeaves(h);
3657
+ blockloop = false;
3658
+ // release(i);
3659
+ }
3660
+ }
3661
+
3662
+ void RewindLeaves(boolean h)
3663
+ {
3664
+ if (blockloop)
3665
+ return;
3666
+
3667
+ if (bRep != null || material != null) // borderline...
3668
+ rewind = h;
3669
+
3670
+ for (int i = 0; i < Size(); i++)
3671
+ {
3672
+ Object3D child = (Object3D) get(i); // reserve(i);
3673
+ if (child == null)
3674
+ continue;
3675
+ blockloop = true;
3676
+ child.RewindLeaves(h);
3677
+ blockloop = false;
3678
+ // release(i);
3679
+ }
3680
+ }
3681
+
3682
+ void RandomLeaves(boolean h)
3683
+ {
3684
+ if (blockloop)
3685
+ return;
3686
+
3687
+ if (bRep != null || material != null) // borderline...
3688
+ random = h;
3689
+
3690
+ for (int i = 0; i < Size(); i++)
3691
+ {
3692
+ Object3D child = (Object3D) get(i); // reserve(i);
3693
+ if (child == null)
3694
+ continue;
3695
+ blockloop = true;
3696
+ child.RandomLeaves(h);
34553697 blockloop = false;
34563698 // release(i);
34573699 }
....@@ -4229,6 +4471,55 @@
42294471 }
42304472 }
42314473
4474
+ void RepairSOV()
4475
+ {
4476
+ if (blockloop)
4477
+ return;
4478
+
4479
+ String texname = this.GetPigmentTexture();
4480
+
4481
+ if (texname.startsWith("sov"))
4482
+ {
4483
+ String[] s = texname.split("/");
4484
+
4485
+ String[] sname = s[1].split("Color.pn");
4486
+
4487
+ texname = sname[0];
4488
+
4489
+ if (sname.length > 1)
4490
+ {
4491
+ texname += "Color.jpg";
4492
+ }
4493
+
4494
+ this.SetPigmentTexture("sov/" + texname);
4495
+ }
4496
+
4497
+ texname = this.GetBumpTexture();
4498
+
4499
+ if (texname.startsWith("sov"))
4500
+ {
4501
+ String[] s = texname.split("/");
4502
+
4503
+ String[] sname = s[1].split("Bump.pn");
4504
+
4505
+ texname = sname[0];
4506
+
4507
+ if (sname.length > 1)
4508
+ {
4509
+ texname += "Bump.jpg";
4510
+ }
4511
+
4512
+ this.SetBumpTexture("sov/" + texname);
4513
+ }
4514
+
4515
+ for (int i=0; i<Size(); i++)
4516
+ {
4517
+ blockloop = true;
4518
+ get(i).RepairSOV();
4519
+ blockloop = false;
4520
+ }
4521
+ }
4522
+
42324523 void RepairTexture()
42334524 {
42344525 if (this instanceof FileObject || blockloop)
....@@ -4743,6 +5034,14 @@
47435034 }
47445035 }
47455036
5037
+ ObjEditor GetWindow()
5038
+ {
5039
+ if (editWindow != null)
5040
+ return editWindow;
5041
+
5042
+ return manipWindow;
5043
+ }
5044
+
47465045 cTreePath Select(int indexcount, boolean deselect)
47475046 {
47485047 if (hide || dontselect)
....@@ -4779,10 +5078,11 @@
47795078 if (leaf != null)
47805079 {
47815080 cTreePath tp = new cTreePath(this, leaf);
4782
- if (editWindow != null)
5081
+ ObjEditor window = GetWindow();
5082
+ if (window != null)
47835083 {
47845084 //System.out.println("editWindow = " + editWindow + " vs " + this);
4785
- editWindow.Select(tp, deselect, true);
5085
+ window.Select(tp, deselect, true);
47865086 }
47875087
47885088 return tp;
....@@ -4799,6 +5099,7 @@
47995099
48005100 if (child == null)
48015101 continue;
5102
+
48025103 if (child.HasTransparency() && child.size() != 0)
48035104 {
48045105 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4808,9 +5109,10 @@
48085109 if (leaf != null)
48095110 {
48105111 cTreePath tp = new cTreePath(this, leaf);
4811
- if (editWindow != null)
5112
+ ObjEditor window = GetWindow();
5113
+ if (window != null)
48125114 {
4813
- editWindow.Select(tp, deselect, true);
5115
+ window.Select(tp, deselect, true);
48145116 }
48155117
48165118 return tp;
....@@ -5135,6 +5437,51 @@
51355437 blockloop = false;
51365438 }
51375439
5440
+ void ResetSelectable()
5441
+ {
5442
+ if (blockloop)
5443
+ return;
5444
+
5445
+ blockloop = true;
5446
+
5447
+ keepdontselect = dontselect;
5448
+ dontselect = true;
5449
+
5450
+ Object3D child;
5451
+ int nb = Size();
5452
+ for (int i = 0; i < nb; i++)
5453
+ {
5454
+ child = (Object3D) get(i);
5455
+ if (child == null)
5456
+ continue;
5457
+ child.ResetSelectable();
5458
+ }
5459
+
5460
+ blockloop = false;
5461
+ }
5462
+
5463
+ void RestoreSelectable()
5464
+ {
5465
+ if (blockloop)
5466
+ return;
5467
+
5468
+ blockloop = true;
5469
+
5470
+ dontselect = keepdontselect;
5471
+
5472
+ Object3D child;
5473
+ int nb = Size();
5474
+ for (int i = 0; i < nb; i++)
5475
+ {
5476
+ child = (Object3D) get(i);
5477
+ if (child == null)
5478
+ continue;
5479
+ child.RestoreSelectable();
5480
+ }
5481
+
5482
+ blockloop = false;
5483
+ }
5484
+
51385485 boolean IsSelected()
51395486 {
51405487 if (parent == null)
....@@ -5371,6 +5718,43 @@
53715718 }
53725719 }
53735720
5721
+ UUID GetUUID()
5722
+ {
5723
+ if (uuid == null)
5724
+ {
5725
+ // Serial
5726
+ uuid = UUID.randomUUID();
5727
+ }
5728
+
5729
+ return uuid;
5730
+ }
5731
+
5732
+ Object3D GetObject(UUID uid)
5733
+ {
5734
+ if (blockloop)
5735
+ return null;
5736
+
5737
+ if (GetUUID().equals(uid))
5738
+ return this;
5739
+
5740
+ int nb = Size();
5741
+ for (int i = 0; i < nb; i++)
5742
+ {
5743
+ Object3D child = (Object3D) get(i);
5744
+
5745
+ if (child == null)
5746
+ continue;
5747
+
5748
+ blockloop = true;
5749
+ Object3D obj = child.GetObject(uid);
5750
+ blockloop = false;
5751
+ if (obj != null)
5752
+ return obj;
5753
+ }
5754
+
5755
+ return null;
5756
+ }
5757
+
53745758 void SetBumpTexture(String tex)
53755759 {
53765760 if (GetTextures() == null)
....@@ -5407,6 +5791,38 @@
54075791 }
54085792 }
54095793
5794
+ void EmbedTextures(boolean embed)
5795
+ {
5796
+ if (blockloop)
5797
+ return;
5798
+
5799
+ //if (GetTextures() != null)
5800
+ if (embed)
5801
+ CameraPane.EmbedTextures(GetTextures());
5802
+ else
5803
+ {
5804
+ GetTextures().pigmentdata = null;
5805
+ GetTextures().bumpdata = null;
5806
+ GetTextures().pw = 0;
5807
+ GetTextures().ph = 0;
5808
+ GetTextures().bw = 0;
5809
+ GetTextures().bh = 0;
5810
+ }
5811
+
5812
+ int nb = Size();
5813
+ for (int i = 0; i < nb; i++)
5814
+ {
5815
+ Object3D child = (Object3D) get(i);
5816
+
5817
+ if (child == null)
5818
+ continue;
5819
+
5820
+ blockloop = true;
5821
+ child.EmbedTextures(embed);
5822
+ blockloop = false;
5823
+ }
5824
+ }
5825
+
54105826 void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54115827 {
54125828 Draw(display, root, selected, blocked);
....@@ -5415,12 +5831,23 @@
54155831 boolean NeedSupport()
54165832 {
54175833 return
5418
- CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null
5834
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
54195835 // PROBLEM with CROWD!!
54205836 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
54215837 }
54225838
54235839 static boolean DEBUG_SELECTION = false;
5840
+
5841
+ boolean IsLive()
5842
+ {
5843
+ if (live)
5844
+ return true;
5845
+
5846
+ if (parent == null)
5847
+ return false;
5848
+
5849
+ return parent.IsLive();
5850
+ }
54245851
54255852 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
54265853 {
....@@ -5483,7 +5910,7 @@
54835910 support = support;
54845911
54855912 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5486
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5913
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
54875914
54885915 if (!usecalllists && bRep != null && bRep.displaylist > 0)
54895916 {
....@@ -5503,10 +5930,12 @@
55035930 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
55045931
55055932 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5506
- (touched || (bRep != null && bRep.displaylist <= 0)))
5933
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5934
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
55075935 {
55085936 Globals.lighttouched = true;
55095937 } // all panes...
5938
+
55105939 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
55115940 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
55125941 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5634,6 +6063,7 @@
56346063 if (GetBRep() != null)
56356064 {
56366065 display.NextIndex();
6066
+
56376067 // vertex color conflict : gl.glCallList(list);
56386068 DrawNode(display, root, selected);
56396069 if (this instanceof BezierPatch)
....@@ -5674,16 +6104,27 @@
56746104 tex = GetTextures();
56756105 }
56766106
5677
- boolean failed = false;
6107
+ boolean failedPigment = false;
6108
+ boolean failedBump = false;
56786109
56796110 try
56806111 {
5681
- display.BindTextures(tex, texres);
6112
+ display.BindPigmentTexture(tex, texres);
56826113 }
56836114 catch (Exception e)
56846115 {
56856116 System.err.println("FAILED: " + this);
5686
- failed = true;
6117
+ failedPigment = true;
6118
+ }
6119
+
6120
+ try
6121
+ {
6122
+ display.BindBumpTexture(tex, texres);
6123
+ }
6124
+ catch (Exception e)
6125
+ {
6126
+ //System.err.println("FAILED: " + this);
6127
+ failedBump = true;
56876128 }
56886129
56896130 if (!compiled)
....@@ -5706,8 +6147,11 @@
57066147 }
57076148 }
57086149
5709
- if (!failed)
5710
- display.ReleaseTextures(tex);
6150
+ if (!failedBump)
6151
+ display.ReleaseBumpTexture(tex);
6152
+
6153
+ if (!failedPigment)
6154
+ display.ReleasePigmentTexture(tex);
57116155
57126156 display.PopMaterial(this, selected);
57136157 }
....@@ -6080,6 +6524,11 @@
60806524 // dec 2012
60816525 new Exception().printStackTrace();
60826526 return;
6527
+ }
6528
+
6529
+ if (dontselect)
6530
+ {
6531
+ //bRep.GenerateNormalsMINE();
60836532 }
60846533
60856534 display.DrawGeometry(bRep, flipV, selectmode);
....@@ -6865,20 +7314,23 @@
68657314 }
68667315 }
68677316
6868
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7317
+ static ClickInfo clickInfo = new ClickInfo();
7318
+
7319
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7320
+ Point outPt, Rectangle outRec)
68697321 {
6870
- int hc = info.bounds.x + info.bounds.width / 2;
6871
- int vc = info.bounds.y + info.bounds.height / 2;
6872
- double[][] toscreen = info.toScreen;
7322
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7323
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7324
+ double[][] toscreen = clickInfo.toScreen;
68737325 if (toscreen == null)
68747326 {
6875
- toscreen = new Camera(info.camera.viewCode).toScreen;
7327
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
68767328 }
68777329 cVector vec = in;
68787330 LA.xformPos(in, toscreen, in);
68797331 //System.out.println("Distance = " + info.camera.Distance());
6880
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
6881
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7332
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7333
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
68827334 outPt.x = hc + (int) vec.x;
68837335 outPt.y = vc - (int) vec.y;
68847336 outRec.x = outPt.x - 3;
....@@ -6886,15 +7338,18 @@
68867338 outRec.width = outRec.height = 6;
68877339 }
68887340
6889
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7341
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7342
+ )
68907343 {
68917344 Point pt = new Point(0, 0);
68927345 Rectangle rec = new Rectangle();
6893
- calcHotSpot(in, info, pt, rec);
7346
+ calcHotSpot(in, //clickInfo,
7347
+ pt, rec);
68947348 return rec;
68957349 }
68967350
6897
- void drawEditHandles0(ClickInfo info, int level)
7351
+ void drawEditHandles0(//ClickInfo clickInfo,
7352
+ int level)
68987353 {
68997354 if (level == 0)
69007355 {
....@@ -6903,16 +7358,19 @@
69037358 {
69047359 cVector origin = new cVector();
69057360 //LA.xformPos(origin, toParent, origin);
6906
- Rectangle spot = calcHotSpot(origin, info);
7361
+ if (this.clickInfo == null)
7362
+ this.clickInfo = new ClickInfo();
7363
+
7364
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
69077365 Rectangle boundary = new Rectangle();
69087366 boundary.x = spot.x - 30;
69097367 boundary.y = spot.y - 30;
69107368 boundary.width = spot.width + 60;
69117369 boundary.height = spot.height + 60;
6912
- info.g.setColor(Color.red);
7370
+ clickInfo.g.setColor(Color.red);
69137371 int spotw = spot.x + spot.width;
69147372 int spoth = spot.y + spot.height;
6915
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7373
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69167374 // if (CameraPane.Xmin > spot.x)
69177375 // {
69187376 // CameraPane.Xmin = spot.x;
....@@ -6932,8 +7390,8 @@
69327390 spot.translate(32, 32);
69337391 spotw = spot.x + spot.width;
69347392 spoth = spot.y + spot.height;
6935
- info.g.setColor(Color.blue);
6936
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7393
+ clickInfo.g.setColor(Color.cyan);
7394
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
69377395 // if (CameraPane.Xmin > spot.x)
69387396 // {
69397397 // CameraPane.Xmin = spot.x;
....@@ -6950,11 +7408,12 @@
69507408 // {
69517409 // CameraPane.Ymax = spoth;
69527410 // }
6953
- // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15);
6954
- //info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7411
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7412
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
69557413 spot.translate(0, -32);
6956
- info.g.setColor(Color.green);
6957
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7414
+ clickInfo.g.setColor(Color.yellow);
7415
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7416
+ clickInfo.g.setColor(Color.green);
69587417 // if (CameraPane.Xmin > spot.x)
69597418 // {
69607419 // CameraPane.Xmin = spot.x;
....@@ -6971,8 +7430,8 @@
69717430 // {
69727431 // CameraPane.Ymax = spoth;
69737432 // }
6974
- info.g.drawArc(boundary.x, boundary.y,
6975
- boundary.width, boundary.height, 0, 360);
7433
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7434
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
69767435 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
69777436 // if (CameraPane.Xmin > boundary.x)
69787437 // {
....@@ -6994,7 +7453,8 @@
69947453 }
69957454 }
69967455
6997
- boolean doEditClick0(ClickInfo info, int level)
7456
+ boolean doEditClick0(//ClickInfo clickInfo,
7457
+ int level)
69987458 {
69997459 if (level == 0)
70007460 {
....@@ -7003,8 +7463,8 @@
70037463
70047464 boolean retval = false;
70057465
7006
- startX = info.x;
7007
- startY = info.y;
7466
+ startX = clickInfo.x;
7467
+ startY = clickInfo.y;
70087468
70097469 hitSomething = -1;
70107470 cVector origin = new cVector();
....@@ -7014,22 +7474,51 @@
70147474 {
70157475 centerPt = new Point(0, 0);
70167476 }
7017
- calcHotSpot(origin, info, centerPt, spot);
7018
- if (spot.contains(info.x, info.y))
7477
+ calcHotSpot(origin, //info,
7478
+ centerPt, spot);
7479
+ if (spot.contains(clickInfo.x, clickInfo.y))
70197480 {
70207481 hitSomething = hitCenter;
70217482 retval = true;
70227483 }
70237484 spot.translate(32, 0);
7024
- if (spot.contains(info.x, info.y))
7485
+ if (spot.contains(clickInfo.x, clickInfo.y))
70257486 {
70267487 hitSomething = hitRotate;
70277488 retval = true;
70287489 }
70297490 spot.translate(0, 32);
7030
- if (spot.contains(info.x, info.y))
7491
+ if (spot.contains(clickInfo.x, clickInfo.y))
70317492 {
70327493 hitSomething = hitScale;
7494
+
7495
+ double scale = 0.005f * clickInfo.camera.Distance();
7496
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7497
+ double sign = 1;
7498
+ if (hScale < 0)
7499
+ {
7500
+ sign = -1;
7501
+ }
7502
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7503
+ if (hScale < 0.01)
7504
+ {
7505
+ //hScale = 0.01;
7506
+ }
7507
+
7508
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7509
+ sign = 1;
7510
+ if (vScale < 0)
7511
+ {
7512
+ sign = -1;
7513
+ }
7514
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7515
+ if (vScale < 0.01)
7516
+ {
7517
+ //vScale = 0.01;
7518
+ }
7519
+
7520
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7521
+
70337522 retval = true;
70347523 }
70357524
....@@ -7039,7 +7528,7 @@
70397528 }
70407529
70417530 //System.out.println("info.modifiers = " + info.modifiers);
7042
- modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
7531
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
70437532 //System.out.println("modified = " + modified);
70447533 //new Exception().printStackTrace();
70457534 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7067,7 +7556,8 @@
70677556 return true;
70687557 }
70697558
7070
- void doEditDrag0(ClickInfo info, boolean opposite)
7559
+ void doEditDrag0(//ClickInfo info,
7560
+ boolean opposite)
70717561 {
70727562 if (hitSomething == 0)
70737563 {
....@@ -7081,7 +7571,7 @@
70817571
70827572 //System.out.println("hitSomething = " + hitSomething);
70837573
7084
- double scale = 0.005f * info.camera.Distance();
7574
+ double scale = 0.005f * clickInfo.camera.Distance();
70857575
70867576 cVector xlate = new cVector();
70877577 //cVector xlate2 = new cVector();
....@@ -7115,8 +7605,8 @@
71157605 toParent[3][i] = xlate.get(i);
71167606 LA.matInvert(toParent, fromParent);
71177607 */
7118
- cVector delta = LA.newVector(0, 0, startY - info.y);
7119
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7608
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7609
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
71207610
71217611 LA.matCopy(startMat, toParent);
71227612 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7125,7 +7615,7 @@
71257615 } else
71267616 {
71277617 //LA.xformDir(delta, info.camera.fromScreen, delta);
7128
- cVector up = new cVector(info.camera.up);
7618
+ cVector up = new cVector(clickInfo.camera.up);
71297619 cVector away = new cVector();
71307620 //cVector right2 = new cVector();
71317621 //LA.vecCross(up, cVector.Z, right);
....@@ -7142,19 +7632,19 @@
71427632 LA.xformDir(up, ClickInfo.matbuffer, up);
71437633 // if (!CameraPane.LOCALTRANSFORM)
71447634 LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7145
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7635
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
71467636 // if (!CameraPane.LOCALTRANSFORM)
71477637 LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
71487638 //LA.vecCross(up, cVector.Z, right2);
71497639
7150
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7640
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
71517641
71527642 //System.out.println("DELTA0 = " + delta);
71537643 //System.out.println("AWAY = " + info.camera.away);
71547644 //System.out.println("UP = " + info.camera.up);
71557645 if (away.z > 0)
71567646 {
7157
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7647
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
71587648 {
71597649 delta.x = -delta.x;
71607650 } else
....@@ -7169,7 +7659,7 @@
71697659 //System.out.println("DELTA1 = " + delta);
71707660 LA.xformDir(delta, ClickInfo.matbuffer, delta);
71717661 //System.out.println("DELTA2 = " + delta);
7172
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7662
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
71737663 LA.matCopy(startMat, toParent);
71747664 //System.out.println("DELTA3 = " + delta);
71757665 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7179,8 +7669,8 @@
71797669 break;
71807670
71817671 case hitRotate: // rotate
7182
- int dx = info.x - centerPt.x;
7183
- int dy = -(info.y - centerPt.y);
7672
+ int dx = clickInfo.x - centerPt.x;
7673
+ int dy = -(clickInfo.y - centerPt.y);
71847674 double angle = (double) Math.atan2(dx, dy);
71857675 angle = -(1.570796 - angle);
71867676
....@@ -7203,7 +7693,7 @@
72037693 }
72047694 /**/
72057695
7206
- switch (info.pane.RenderCamera().viewCode)
7696
+ switch (clickInfo.pane.RenderCamera().viewCode)
72077697 {
72087698 case 1: // '\001'
72097699 LA.matZRotate(toParent, angle);
....@@ -7230,7 +7720,7 @@
72307720 break;
72317721
72327722 case hitScale: // scale
7233
- double hScale = (double) (info.x - centerPt.x) / 32;
7723
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
72347724 double sign = 1;
72357725 if (hScale < 0)
72367726 {
....@@ -7242,7 +7732,7 @@
72427732 //hScale = 0.01;
72437733 }
72447734
7245
- double vScale = (double) (info.y - centerPt.y) / 32;
7735
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
72467736 sign = 1;
72477737 if (vScale < 0)
72487738 {
....@@ -7253,6 +7743,7 @@
72537743 {
72547744 //vScale = 0.01;
72557745 }
7746
+
72567747 LA.matCopy(startMat, toParent);
72577748 /**/
72587749 for (int i = 0; i < 3; i++)
....@@ -7262,29 +7753,30 @@
72627753 }
72637754 /**/
72647755
7265
- double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7756
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
72667757
72677758 if (totalScale < 0.01)
72687759 {
72697760 totalScale = 0.01;
72707761 }
72717762
7272
- switch (info.pane.RenderCamera().viewCode)
7763
+ switch (clickInfo.pane.RenderCamera().viewCode)
72737764 {
72747765 case 3: // '\001'
7275
- if (modified)
7766
+ if (modified || opposite)
72767767 {
72777768 //LA.matScale(toParent, 1, hScale, vScale);
72787769 LA.matScale(toParent, totalScale, 1, 1);
72797770 } // vScale, 1);
72807771 else
72817772 {
7773
+ // EXCEPTION!
72827774 LA.matScale(toParent, totalScale, totalScale, totalScale);
72837775 } // vScale, 1);
72847776 break;
72857777
72867778 case 2: // '\002'
7287
- if (modified)
7779
+ if (modified || opposite)
72887780 {
72897781 //LA.matScale(toParent, hScale, 1, vScale);
72907782 LA.matScale(toParent, 1, totalScale, 1);
....@@ -7295,7 +7787,7 @@
72957787 break;
72967788
72977789 case 1: // '\003'
7298
- if (modified)
7790
+ if (modified || opposite)
72997791 {
73007792 //LA.matScale(toParent, hScale, vScale, 1);
73017793 LA.matScale(toParent, 1, 1, totalScale);
....@@ -7335,7 +7827,7 @@
73357827 } // NEW ...
73367828
73377829
7338
- info.pane.repaint();
7830
+ clickInfo.pane.repaint();
73397831 }
73407832
73417833 boolean overflow = false;
....@@ -7515,6 +8007,10 @@
75158007 editWindow = null;
75168008 } // ?
75178009 }
8010
+ else
8011
+ {
8012
+ //editWindow.closeUI();
8013
+ }
75188014 }
75198015
75208016 boolean root; // patch for edit windows
....@@ -7526,7 +8022,7 @@
75268022 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75278023
75288024 Object3D /*Composite*/ parent;
7529
- Object3D /*Composite*/ fileparent;
8025
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75308026
75318027 double[][] toParent; // dynamic matrix
75328028 double[][] fromParent;
....@@ -7672,6 +8168,10 @@
76728168 }
76738169
76748170 transient ObjEditor editWindow;
8171
+ transient ObjEditor manipWindow;
8172
+
8173
+ transient boolean pinned;
8174
+
76758175 transient ObjectUI objectUI;
76768176 public static int povDepth = 0;
76778177 private static cVector tbMin = new cVector();