Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -13,11 +14,20 @@
1314 import //weka.core.
1415 matrix.Matrix;
1516
17
+import java.util.UUID;
18
+
1619 //import net.sourceforge.sizeof.SizeOf;
1720 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1821 {
1922 //static final long serialVersionUID = -607422624994562685L;
2023 static final long serialVersionUID = 5022536242724664900L;
24
+
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
+ //
2131
2232 ScriptNode scriptnode;
2333
....@@ -99,64 +109,170 @@
99109
100110 // transient boolean reduced; // for morph reduction
101111
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104114
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
107117
108
-void SaveSupports()
109
-{
110
- if (blockloop)
111
- return;
112
-
113
- transientsupport = support;
114
- transientlink2master = link2master;
115
-
116
- support = null;
117
- link2master = false;
118
-
119
- if (bRep != null)
118
+ void SaveSupports()
120119 {
121
- bRep.SaveSupports();
120
+ if (blockloop)
121
+ return;
122
+
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
125
+
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
122143 }
123
-
124
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
125146 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
169
+ }
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ Object3D o;
174
+
175
+ if (hashtable.containsKey(GetUUID()))
176
+ {
177
+ o = hashtable.get(GetUUID());
178
+
179
+ Grafreed.Assert(this.bRep == o.bRep);
180
+ //if (this.bRep != null)
181
+ // assert(this.bRep.support == o.transientrep);
182
+ if (this.support != null)
183
+ assert(this.support.bRep == o.transientrep);
184
+ }
185
+ else
186
+ {
187
+ o = new Object3D("copy of " + this.name);
188
+
189
+ hashtable.put(GetUUID(), o);
190
+ }
191
+
192
+ if (!blockloop)
193
+ {
194
+ blockloop = true;
195
+
196
+ for (int i=0; i<Size(); i++)
197
+ {
198
+ get(i).ExtractBigData(hashtable);
199
+ }
200
+
201
+ blockloop = false;
202
+ }
203
+
204
+ ExtractBigData(o);
205
+ }
206
+
207
+ void ExtractBigData(Object3D o)
208
+ {
209
+ if (o.bRep != null)
210
+ Grafreed.Assert(o.bRep == this.bRep);
211
+
212
+ o.bRep = this.bRep;
213
+// July 2019 if (this.bRep != null)
214
+// {
215
+// o.transientrep = this.bRep.support;
216
+// o.bRep.support = null;
217
+// }
218
+
219
+ if (this.support != null)
220
+ {
221
+ if (o.transientrep != null)
222
+ Grafreed.Assert(o.transientrep == this.support.bRep);
223
+
224
+ o.transientrep = this.support.bRep;
225
+ this.support.bRep = null;
226
+ }
227
+
228
+ // o.support = this.support;
229
+ // o.fileparent = this.fileparent;
230
+ // if (this.bRep != null)
231
+ // o.bRep = this.bRep.support;
232
+
233
+ this.bRep = null;
234
+ // if (this.bRep != null)
235
+ // this.bRep.support = null;
236
+ // this.support = null;
237
+ // this.fileparent = null;
238
+ }
239
+
240
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
241
+ {
242
+ if (!hashtable.containsKey(GetUUID()))
243
+ return;
244
+
245
+ Object3D o = hashtable.get(GetUUID());
246
+
247
+ RestoreBigData(o);
248
+
249
+ if (blockloop)
250
+ return;
251
+
129252 blockloop = true;
130
- child.SaveSupports();
253
+
254
+ //hashtable.remove(GetUUID());
255
+
256
+ for (int i=0; i<Size(); i++)
257
+ {
258
+ get(i).RestoreBigData(hashtable);
259
+ }
260
+
131261 blockloop = false;
132262 }
133
-}
134263
135
-void RestoreSupports()
136
-{
137
- if (blockloop)
138
- return;
139
-
140
- support = transientsupport;
141
- link2master = transientlink2master;
142
- transientsupport = null;
143
- transientlink2master = false;
144
-
145
- if (bRep != null)
264
+ void RestoreBigData(Object3D o)
146265 {
147
- bRep.RestoreSupports();
266
+ this.bRep = o.bRep;
267
+ if (this.support != null && o.transientrep != null)
268
+ {
269
+ this.support.bRep = o.transientrep;
270
+ }
271
+// July 2019 if (this.bRep != null)
272
+// this.bRep.support = o.transientrep;
273
+ // this.support = o.support;
274
+ // this.fileparent = o.fileparent;
148275 }
149
-
150
- for (int i = 0; i < Size(); i++)
151
- {
152
- Object3D child = (Object3D) get(i);
153
- if (child == null)
154
- continue;
155
- blockloop = true;
156
- child.RestoreSupports();
157
- blockloop = false;
158
- }
159
-}
160276
161277 // MOCAP SUPPORT
162278 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +415,7 @@
299415 }
300416
301417 boolean live = false;
418
+ boolean dontselect = false;
302419 boolean hide = false;
303420 boolean link2master = false; // performs reset support/master at each frame
304421 boolean marked = false; // animation node
....@@ -430,16 +547,16 @@
430547 {
431548 Object3D copy = this;
432549
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
550
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434551
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
552
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436553 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
554
+ parentcam = Globals.theRenderer.Cameras()[1];
438555 }
439556
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
557
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441558 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
559
+ parentcam = Globals.theRenderer.Cameras()[0];
443560 }
444561
445562 if (this == parentcam)
....@@ -447,7 +564,7 @@
447564 //assert(this instanceof Camera);
448565
449566 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
567
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451568 }
452569
453570 copy.marked ^= true;
....@@ -467,7 +584,7 @@
467584 //assert(this instanceof Camera);
468585
469586 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
587
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471588 }
472589
473590 copy.Touch(); // display list issue
....@@ -480,12 +597,14 @@
480597 toParent = LA.newMatrix();
481598 fromParent = LA.newMatrix();
482599 }
600
+
483601 if (toParentMarked == null)
484602 {
485603 if (maxcount != 1)
486604 {
487605 new Exception().printStackTrace();
488606 }
607
+
489608 toParentMarked = LA.newMatrix();
490609 fromParentMarked = LA.newMatrix();
491610 }
....@@ -602,7 +721,7 @@
602721 return;
603722 }
604723
605
- if (CameraPane.fromscript)
724
+ if (Globals.fromscript)
606725 {
607726 transformcount = 0;
608727 return;
....@@ -773,7 +892,7 @@
773892 if (step == 0)
774893 step = 1;
775894 if (maxcount == 0)
776
- maxcount = 2048; // 4;
895
+ maxcount = 128; // 2048; // 4;
777896 // if (acceleration == 0)
778897 // acceleration = 10;
779898 if (delay == 0) // serial
....@@ -796,7 +915,7 @@
796915
797916 if (marked && Globals.isLIVE() && live &&
798917 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
918
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800919 currentframe != Globals.framecount)
801920 {
802921 currentframe = Globals.framecount;
....@@ -808,7 +927,8 @@
808927
809928 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810929
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
930
+ if (transformcount*factor >= maxcount && (rewind || random) ||
931
+ (step == 1 && changedir))
812932 {
813933 countdown = 1;
814934 delay = speedup?8:1;
....@@ -880,6 +1000,7 @@
8801000 if (material == null || material.multiply)
8811001 return true;
8821002
1003
+ // Transparent objects are dynamic because we have to sort the triangles.
8831004 return material.opacity > 0.99;
8841005 }
8851006
....@@ -911,6 +1032,11 @@
9111032 fromParent = null; // LA.newMatrix();
9121033 bRep = null; // new BoundaryRep();
9131034
1035
+ if (oname != null && oname.equals("LeftHand"))
1036
+ {
1037
+ name = oname;
1038
+ }
1039
+
9141040 /*
9151041 float hue = (float)Math.random();
9161042 Color col;
....@@ -953,7 +1079,7 @@
9531079
9541080 public Object clone()
9551081 {
956
- return GrafreeD.clone(this);
1082
+ return Grafreed.clone(this);
9571083 }
9581084
9591085 Object3D copyExpand()
....@@ -1275,6 +1401,7 @@
12751401 toParent = LA.newMatrix();
12761402 fromParent = LA.newMatrix();
12771403 }
1404
+
12781405 LA.matCopy(other.toParent, toParent);
12791406 LA.matCopy(other.fromParent, fromParent);
12801407
....@@ -1469,7 +1596,7 @@
14691596 BoundaryRep.SEUIL = other.material.cameralight;
14701597
14711598 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1599
+ BoundaryRep.SEUIL /= 4; // 2;
14731600 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741601 }
14751602
....@@ -1728,7 +1855,7 @@
17281855 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291856 o.bRep = transientrep;
17301857 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1858
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321859 o.CreateMaterial();
17331860 o.SetAttributes(this, -1);
17341861 //parent
....@@ -1741,7 +1868,7 @@
17411868 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421869 o.bRep = bRep;
17431870 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1871
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451872 o.CreateMaterial();
17461873 //o.overwriteThis(this, -1);
17471874 o.SetAttributes(this, -1);
....@@ -1828,12 +1955,15 @@
18281955 if (obj.name == null)
18291956 continue; // can't be a null one
18301957
1958
+ // Try perfect match first.
18311959 if (n.equals(obj.name))
18321960 {
18331961 theobj = obj;
18341962 count++;
18351963 }
18361964 }
1965
+
1966
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371967
18381968 if (count != 1)
18391969 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2423,17 @@
22932423 }
22942424 */
22952425 }
2426
+ else
2427
+ {
2428
+ //((ObjEditor)editWindow).SetupUI2(null);
2429
+ }
22962430 }
22972431
22982432 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992433 {
23002434 if (newWindow)
23012435 {
2436
+ new Exception().printStackTrace();
23022437 System.exit(0);
23032438 if (parent != null)
23042439 {
....@@ -2333,6 +2468,14 @@
23332468 {
23342469 editWindow.refreshContents();
23352470 }
2471
+ else
2472
+ {
2473
+ if (manipWindow != null)
2474
+ {
2475
+ manipWindow.refreshContents();
2476
+ }
2477
+ }
2478
+
23362479 //if (parent != null)
23372480 //parent.refreshEditWindow();
23382481 }
....@@ -2475,13 +2618,13 @@
24752618 return retval;
24762619 }
24772620
2478
- void doEditDrag(ClickInfo info)
2621
+ void doEditDrag(ClickInfo info, boolean opposite)
24792622 {
24802623 switch (doSomething)
24812624 {
24822625 case 1: // '\001'
24832626 //super.
2484
- doEditDrag0(info);
2627
+ doEditDrag0(info, opposite);
24852628 break;
24862629
24872630 case 2: // '\002'
....@@ -2494,11 +2637,11 @@
24942637 {
24952638 //sel.hitSomething = childToDrag.hitSomething;
24962639 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2640
+ sel.doEditDrag(info, opposite);
24982641 } else
24992642 {
25002643 //super.
2501
- doEditDrag0(info);
2644
+ doEditDrag0(info, opposite);
25022645 }
25032646 }
25042647 break;
....@@ -2608,6 +2751,18 @@
26082751 void GenNormalsS(boolean crease)
26092752 {
26102753 selection.GenNormals(crease);
2754
+// for (int i=0; i<selection.size(); i++)
2755
+// {
2756
+// Object3D selectee = (Object3D) selection.elementAt(i);
2757
+// selectee.GenNormals(crease);
2758
+// }
2759
+
2760
+ //Touch();
2761
+ }
2762
+
2763
+ void GenNormalsMeshS()
2764
+ {
2765
+ selection.GenNormalsMesh();
26112766 // for (int i=0; i<selection.size(); i++)
26122767 // {
26132768 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2903,24 @@
27482903 if (child == null)
27492904 continue;
27502905 child.GenNormals(crease);
2906
+// Children().release(i);
2907
+ }
2908
+ blockloop = false;
2909
+ }
2910
+
2911
+ void GenNormalsMesh()
2912
+ {
2913
+ if (blockloop)
2914
+ return;
2915
+
2916
+ blockloop = true;
2917
+ GenNormalsMesh0();
2918
+ for (int i = 0; i < Children().Size(); i++)
2919
+ {
2920
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2921
+ if (child == null)
2922
+ continue;
2923
+ child.GenNormalsMesh();
27512924 // Children().release(i);
27522925 }
27532926 blockloop = false;
....@@ -2905,7 +3078,8 @@
29053078 {
29063079 if (bRep != null)
29073080 {
2908
- bRep.GenUV();
3081
+ bRep.GenUV(); //1);
3082
+ //bRep.UnfoldUV();
29093083 Touch();
29103084 }
29113085 }
....@@ -2915,6 +3089,15 @@
29153089 if (bRep != null)
29163090 {
29173091 bRep.GenerateNormals(crease);
3092
+ Touch();
3093
+ }
3094
+ }
3095
+
3096
+ void GenNormalsMesh0()
3097
+ {
3098
+ if (bRep != null)
3099
+ {
3100
+ bRep.GenerateNormalsMesh();
29183101 Touch();
29193102 }
29203103 }
....@@ -2980,6 +3163,33 @@
29803163 blockloop = false;
29813164 }
29823165
3166
+ void TransformChildren()
3167
+ {
3168
+ if (toParent != null)
3169
+ {
3170
+ for (int i=Size(); --i>=0;)
3171
+ {
3172
+ Object3D v = get(i);
3173
+
3174
+ if (v.toParent == null)
3175
+ {
3176
+ v.toParent = LA.newMatrix();
3177
+ v.fromParent = LA.newMatrix();
3178
+ }
3179
+
3180
+// LA.matConcat(v.toParent, toParent, v.toParent);
3181
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3182
+ LA.matConcat(toParent, v.toParent, v.toParent);
3183
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3184
+ }
3185
+
3186
+ toParent = null; // LA.matIdentity(toParent);
3187
+ fromParent = null; // LA.matIdentity(fromParent);
3188
+
3189
+ Touch();
3190
+ }
3191
+ }
3192
+
29833193 void TransformGeometry()
29843194 {
29853195 Object3D obj = this;
....@@ -3201,9 +3411,11 @@
32013411
32023412 BoundaryRep sup = bRep.support;
32033413 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3414
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053415 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3416
+
3417
+ while(temprep.SplitInTwo(reduction34, onlyone));
3418
+
32073419 bRep = temprep;
32083420 bRep.support = sup;
32093421 Touch();
....@@ -3340,7 +3552,8 @@
33403552 if (blockloop)
33413553 return;
33423554
3343
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
33443557 live = h;
33453558
33463559 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3574,8 @@
33613574 return;
33623575
33633576 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3577
+ if (//marked || // does not make sense
3578
+ (bRep != null || material != null)) // borderline...
33653579 link2master = h;
33663580
33673581 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3595,8 @@
33813595 if (blockloop)
33823596 return;
33833597
3384
- if (marked || (bRep != null && material != null)) // borderline...
3598
+ if (//marked || // does not make sense
3599
+ (bRep != null || material != null)) // borderline...
33853600 hide = h;
33863601
33873602 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3616,7 @@
34013616 if (blockloop)
34023617 return;
34033618
3404
- if (bRep != null && material != null) // borderline...
3619
+ if (bRep != null || material != null) // borderline...
34053620 marked = h;
34063621
34073622 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3626,46 @@
34113626 continue;
34123627 blockloop = true;
34133628 child.MarkLeaves(h);
3629
+ blockloop = false;
3630
+ // release(i);
3631
+ }
3632
+ }
3633
+
3634
+ void RewindLeaves(boolean h)
3635
+ {
3636
+ if (blockloop)
3637
+ return;
3638
+
3639
+ if (bRep != null || material != null) // borderline...
3640
+ rewind = h;
3641
+
3642
+ for (int i = 0; i < Size(); i++)
3643
+ {
3644
+ Object3D child = (Object3D) get(i); // reserve(i);
3645
+ if (child == null)
3646
+ continue;
3647
+ blockloop = true;
3648
+ child.RewindLeaves(h);
3649
+ blockloop = false;
3650
+ // release(i);
3651
+ }
3652
+ }
3653
+
3654
+ void RandomLeaves(boolean h)
3655
+ {
3656
+ if (blockloop)
3657
+ return;
3658
+
3659
+ if (bRep != null || material != null) // borderline...
3660
+ random = h;
3661
+
3662
+ for (int i = 0; i < Size(); i++)
3663
+ {
3664
+ Object3D child = (Object3D) get(i); // reserve(i);
3665
+ if (child == null)
3666
+ continue;
3667
+ blockloop = true;
3668
+ child.RandomLeaves(h);
34143669 blockloop = false;
34153670 // release(i);
34163671 }
....@@ -3725,7 +3980,7 @@
37253980 if (child == null)
37263981 continue;
37273982
3728
- if (GrafreeD.RENDERME > 0)
3983
+ if (Grafreed.RENDERME > 0)
37293984 {
37303985 if (child instanceof Merge)
37313986 ((Merge)child).renderme();
....@@ -3876,7 +4131,7 @@
38764131 if (child == null)
38774132 continue;
38784133
3879
- if (GrafreeD.RENDERME > 0)
4134
+ if (Grafreed.RENDERME > 0)
38804135 {
38814136 if (child instanceof Merge)
38824137 ((Merge)child).renderme();
....@@ -4071,7 +4326,7 @@
40714326 if (child == null)
40724327 continue;
40734328
4074
- if (GrafreeD.RENDERME > 0)
4329
+ if (Grafreed.RENDERME > 0)
40754330 {
40764331 if (child instanceof Merge)
40774332 ((Merge)child).renderme();
....@@ -4184,6 +4439,55 @@
41844439 {
41854440 blockloop = true;
41864441 get(i).RepairShadow();
4442
+ blockloop = false;
4443
+ }
4444
+ }
4445
+
4446
+ void RepairSOV()
4447
+ {
4448
+ if (blockloop)
4449
+ return;
4450
+
4451
+ String texname = this.GetPigmentTexture();
4452
+
4453
+ if (texname.startsWith("sov"))
4454
+ {
4455
+ String[] s = texname.split("/");
4456
+
4457
+ String[] sname = s[1].split("Color.pn");
4458
+
4459
+ texname = sname[0];
4460
+
4461
+ if (sname.length > 1)
4462
+ {
4463
+ texname += "Color.jpg";
4464
+ }
4465
+
4466
+ this.SetPigmentTexture("sov/" + texname);
4467
+ }
4468
+
4469
+ texname = this.GetBumpTexture();
4470
+
4471
+ if (texname.startsWith("sov"))
4472
+ {
4473
+ String[] s = texname.split("/");
4474
+
4475
+ String[] sname = s[1].split("Bump.pn");
4476
+
4477
+ texname = sname[0];
4478
+
4479
+ if (sname.length > 1)
4480
+ {
4481
+ texname += "Bump.jpg";
4482
+ }
4483
+
4484
+ this.SetBumpTexture("sov/" + texname);
4485
+ }
4486
+
4487
+ for (int i=0; i<Size(); i++)
4488
+ {
4489
+ blockloop = true;
4490
+ get(i).RepairSOV();
41874491 blockloop = false;
41884492 }
41894493 }
....@@ -4678,7 +4982,7 @@
46784982
46794983 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804984 {
4681
- if (hide)
4985
+ if (hide || dontselect)
46824986 return null;
46834987
46844988 if (count <= 0)
....@@ -4702,9 +5006,17 @@
47025006 }
47035007 }
47045008
5009
+ ObjEditor GetWindow()
5010
+ {
5011
+ if (editWindow != null)
5012
+ return editWindow;
5013
+
5014
+ return manipWindow;
5015
+ }
5016
+
47055017 cTreePath Select(int indexcount, boolean deselect)
47065018 {
4707
- if (hide)
5019
+ if (hide || dontselect)
47085020 return null;
47095021
47105022 if (count <= 0)
....@@ -4738,10 +5050,11 @@
47385050 if (leaf != null)
47395051 {
47405052 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5053
+ ObjEditor window = GetWindow();
5054
+ if (window != null)
47425055 {
47435056 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5057
+ window.Select(tp, deselect, true);
47455058 }
47465059
47475060 return tp;
....@@ -4758,6 +5071,7 @@
47585071
47595072 if (child == null)
47605073 continue;
5074
+
47615075 if (child.HasTransparency() && child.size() != 0)
47625076 {
47635077 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5081,10 @@
47675081 if (leaf != null)
47685082 {
47695083 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5084
+ ObjEditor window = GetWindow();
5085
+ if (window != null)
47715086 {
4772
- editWindow.Select(tp, deselect, true);
5087
+ window.Select(tp, deselect, true);
47735088 }
47745089
47755090 return tp;
....@@ -4854,7 +5169,7 @@
48545169 return globalTransform;
48555170 }
48565171
4857
- void PreprocessOcclusion(CameraPane cp)
5172
+ void PreprocessOcclusion(iCameraPane cp)
48585173 {
48595174 /*
48605175 if (AOdone)
....@@ -5156,10 +5471,34 @@
51565471
51575472 // System.out.println("Fullname = " + fullname);
51585473
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5474
+ // Does not work on Windows due to C:
5475
+// if (fullname.name.indexOf(":") == -1)
5476
+// return fullname.name;
5477
+//
5478
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615479
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5480
+ String[] split = fullname.name.split(":");
5481
+
5482
+ if (split.length == 0)
5483
+ {
5484
+ return "";
5485
+ }
5486
+
5487
+ if (split.length <= 2)
5488
+ {
5489
+ if (fullname.name.endsWith(":"))
5490
+ {
5491
+ // Windows
5492
+ return fullname.name.substring(0, fullname.name.length()-1);
5493
+ }
5494
+
5495
+ return split[0];
5496
+ }
5497
+
5498
+ // Windows
5499
+ assert(split.length == 4);
5500
+
5501
+ return split[0] + ":" + split[1];
51635502 }
51645503
51655504 static String GetBump(cTexture fullname)
....@@ -5168,10 +5507,38 @@
51685507 return "";
51695508
51705509 // System.out.println("Fullname = " + fullname);
5171
- if (fullname.name.indexOf(":") == -1)
5172
- return "";
5173
-
5174
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5510
+ // Does not work on Windows due to C:
5511
+// if (fullname.name.indexOf(":") == -1)
5512
+// return "";
5513
+//
5514
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5515
+ String[] split = fullname.name.split(":");
5516
+
5517
+ if (split.length == 0)
5518
+ {
5519
+ return "";
5520
+ }
5521
+
5522
+ if (split.length == 1)
5523
+ {
5524
+ return "";
5525
+ }
5526
+
5527
+ if (split.length == 2)
5528
+ {
5529
+ if (fullname.name.endsWith(":"))
5530
+ {
5531
+ // Windows
5532
+ return "";
5533
+ }
5534
+
5535
+ return split[1];
5536
+ }
5537
+
5538
+ // Windows
5539
+ assert(split.length == 4);
5540
+
5541
+ return split[2] + ":" + split[3];
51755542 }
51765543
51775544 String GetPigmentTexture()
....@@ -5245,7 +5612,7 @@
52455612 System.out.print("; textures = " + textures);
52465613 System.out.println("; usedtextures = " + usedtextures);
52475614
5248
- if (GetTextures() == null)
5615
+ if (GetTextures() == null) // What is that??
52495616 GetTextures().name = ":";
52505617
52515618 String texname = tex;
....@@ -5276,6 +5643,43 @@
52765643 child.ResetPigmentTexture();
52775644 blockloop = false;
52785645 }
5646
+ }
5647
+
5648
+ UUID GetUUID()
5649
+ {
5650
+ if (uuid == null)
5651
+ {
5652
+ // Serial
5653
+ uuid = UUID.randomUUID();
5654
+ }
5655
+
5656
+ return uuid;
5657
+ }
5658
+
5659
+ Object3D GetObject(UUID uid)
5660
+ {
5661
+ if (blockloop)
5662
+ return null;
5663
+
5664
+ if (GetUUID().equals(uid))
5665
+ return this;
5666
+
5667
+ int nb = Size();
5668
+ for (int i = 0; i < nb; i++)
5669
+ {
5670
+ Object3D child = (Object3D) get(i);
5671
+
5672
+ if (child == null)
5673
+ continue;
5674
+
5675
+ blockloop = true;
5676
+ Object3D obj = child.GetObject(uid);
5677
+ blockloop = false;
5678
+ if (obj != null)
5679
+ return obj;
5680
+ }
5681
+
5682
+ return null;
52795683 }
52805684
52815685 void SetBumpTexture(String tex)
....@@ -5322,11 +5726,23 @@
53225726 boolean NeedSupport()
53235727 {
53245728 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5729
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265730 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5731
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285732 }
53295733
5734
+ static boolean DEBUG_SELECTION = false;
5735
+
5736
+ boolean IsLive()
5737
+ {
5738
+ if (live)
5739
+ return true;
5740
+
5741
+ if (parent == null)
5742
+ return false;
5743
+
5744
+ return parent.IsLive();
5745
+ }
53305746
53315747 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325748 {
....@@ -5338,7 +5754,7 @@
53385754 }
53395755
53405756 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5757
+ (hide || dontselect))
53425758 return;
53435759
53445760 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5781,12 @@
53655781 }
53665782
53675783 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5784
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695785 {
53705786 return;
53715787 }
53725788
5373
- javax.media.opengl.GL gl = display.GetGL();
5789
+ //javax.media.opengl.GL gl = display.GetGL();
53745790
53755791 /*
53765792 if (touched)
....@@ -5389,7 +5805,7 @@
53895805 support = support;
53905806
53915807 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5392
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5808
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53935809
53945810 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53955811 {
....@@ -5406,13 +5822,15 @@
54065822
54075823 boolean compiled = false;
54085824
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5825
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105826
54115827 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5412
- (touched || (bRep != null && bRep.displaylist <= 0)))
5828
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5829
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54135830 {
54145831 Globals.lighttouched = true;
54155832 } // all panes...
5833
+
54165834 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54175835 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54185836 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5840,7 @@
54225840 //if (displaylist == -1 && usecalllists)
54235841 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245842 {
5425
- bRep.displaylist = gl.glGenLists(1);
5843
+ bRep.displaylist = display.GenList();
54265844 assert(bRep.displaylist != 0);
54275845 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285846 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5852,16 @@
54345852 if (usecalllists)
54355853 {
54365854 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5855
+ display.NewList(bRep.displaylist);
54385856 }
5857
+
54395858 CallList(display, root, selected, blocked);
5859
+
54405860 // compiled = true;
54415861 if (usecalllists)
54425862 {
54435863 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5864
+ display.EndList();
54455865 }
54465866 //gl.glDrawBuffer(gl.GL_BACK);
54475867 // XXX touched = false;
....@@ -5484,12 +5904,12 @@
54845904
54855905 // frustum culling
54865906 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5907
+ && display.DrawMode() != iCameraPane.SELECTION)
54885908 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5909
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905910 {
54915911 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5912
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54935913 {
54945914 //System.out.print("CULLED");
54955915 culled = true;
....@@ -5497,7 +5917,7 @@
54975917 }
54985918 else
54995919 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5920
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55015921 culled = true;
55025922
55035923 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +5953,12 @@
55335953
55345954
55355955 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5956
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375957 {
55385958 if (GetBRep() != null)
55395959 {
5540
- CameraPane.NextIndex(this, gl);
5960
+ display.NextIndex();
5961
+
55415962 // vertex color conflict : gl.glCallList(list);
55425963 DrawNode(display, root, selected);
55435964 if (this instanceof BezierPatch)
....@@ -5578,7 +5999,28 @@
55785999 tex = GetTextures();
55796000 }
55806001
5581
- display.BindTextures(tex, texres);
6002
+ boolean failedPigment = false;
6003
+ boolean failedBump = false;
6004
+
6005
+ try
6006
+ {
6007
+ display.BindPigmentTexture(tex, texres);
6008
+ }
6009
+ catch (Exception e)
6010
+ {
6011
+ System.err.println("FAILED: " + this);
6012
+ failedPigment = true;
6013
+ }
6014
+
6015
+ try
6016
+ {
6017
+ display.BindBumpTexture(tex, texres);
6018
+ }
6019
+ catch (Exception e)
6020
+ {
6021
+ //System.err.println("FAILED: " + this);
6022
+ failedBump = true;
6023
+ }
55826024
55836025 if (!compiled)
55846026 {
....@@ -5594,13 +6036,17 @@
55946036
55956037 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55966038 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
6039
+ display.CallList(bRep.displaylist);
55986040 // june 2013 drawSelf(display, root, selected);
55996041 }
56006042 }
56016043 }
56026044
5603
- display.ReleaseTextures(tex);
6045
+ if (!failedBump)
6046
+ display.ReleaseBumpTexture(tex);
6047
+
6048
+ if (!failedPigment)
6049
+ display.ReleasePigmentTexture(tex);
56046050
56056051 display.PopMaterial(this, selected);
56066052 }
....@@ -5729,6 +6175,9 @@
57296175
57306176 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316177 {
6178
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6179
+ return;
6180
+
57326181 if (hide)
57336182 return;
57346183 // shadow optimisation
....@@ -5854,6 +6303,9 @@
58546303 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58556304 return; // no shadow for transparent objects
58566305
6306
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6307
+ return;
6308
+
58576309 if (hide)
58586310 return;
58596311
....@@ -5894,9 +6346,10 @@
58946346 return;
58956347 }
58966348
6349
+ //bRep.GenUV(1/material.diffuseness);
58976350 // bRep.lock = true;
58986351
5899
- javax.media.opengl.GL gl = display.GetGL();
6352
+ //javax.media.opengl.GL gl = display.GetGL();
59006353
59016354 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026355 {
....@@ -5913,23 +6366,7 @@
59136366
59146367 bRep.getMinMax(min, max, 100);
59156368
5916
- gl.glBegin(gl.GL_LINES);
5917
-
5918
- gl.glVertex3d(min.x, min.y, min.z);
5919
- gl.glVertex3d(min.x, min.y, max.z);
5920
- gl.glVertex3d(min.x, min.y, min.z);
5921
- gl.glVertex3d(min.x, max.y, min.z);
5922
- gl.glVertex3d(min.x, min.y, min.z);
5923
- gl.glVertex3d(max.x, min.y, min.z);
5924
-
5925
- gl.glVertex3d(max.x, max.y, max.z);
5926
- gl.glVertex3d(min.x, max.y, max.z);
5927
- gl.glVertex3d(max.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, min.y, max.z);
5929
- gl.glVertex3d(max.x, max.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, min.z);
5931
-
5932
- gl.glEnd();
6369
+ display.DrawBox(min, max);
59336370
59346371 return;
59356372 }
....@@ -5973,7 +6410,7 @@
59736410 {
59746411 //throw new Error();
59756412
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6413
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776414
59786415 int[] strips = bRep.getRawIndices();
59796416
....@@ -5983,178 +6420,19 @@
59836420 new Exception().printStackTrace();
59846421 return;
59856422 }
5986
-
5987
- // TRIANGLE STRIP ARRAY
5988
- if (bRep.trimmed)
6423
+
6424
+ if (dontselect)
59896425 {
5990
- float[] v = bRep.getRawVertices();
5991
- float[] n = bRep.getRawNormals();
5992
- float[] c = bRep.getRawColors();
5993
- float[] uv = bRep.getRawUVMap();
5994
-
5995
- int count2 = 0;
5996
- int count3 = 0;
5997
-
5998
- if (n.length > 0)
5999
- {
6000
- for (int i = 0; i < strips.length; i++)
6001
- {
6002
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6003
-
6004
- /*
6005
- boolean locked = false;
6006
- float eps = 0.1f;
6007
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6008
-
6009
- int dot = 0;
6010
-
6011
- if ((dot&1) == 0)
6012
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6013
-
6014
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6015
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6016
- else
6017
- {
6018
- locked = true;
6019
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6020
- }
6021
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6022
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6023
- if (hasnorm)
6024
- {
6025
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6026
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6027
- }
6028
-
6029
- if ((dot&4) == 0)
6030
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6031
-
6032
- if (wrap || !locked && (dot&8) != 0)
6033
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6034
- else
6035
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6036
-
6037
- f.dot = dot;
6038
- */
6039
-
6040
- if (!selectmode)
6041
- {
6042
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6043
- {
6044
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6045
- } else
6046
- {
6047
- gl.glNormal3f(0, 0, 1);
6048
- }
6049
-
6050
- if (c != null)
6051
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6052
- {
6053
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6054
- }
6055
- }
6056
- if (flipV)
6057
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6058
- else
6059
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6060
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6061
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6062
-
6063
- count2 += 2;
6064
- count3 += 3;
6065
- if (!selectmode)
6066
- {
6067
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6068
- {
6069
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6070
- } else
6071
- {
6072
- gl.glNormal3f(0, 0, 1);
6073
- }
6074
- if (c != null)
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- for (int j = 0; j < strips[i] - 2; j++)
6089
- {
6090
- //gl.glTexCoord2d(...);
6091
- if (!selectmode)
6092
- {
6093
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6094
- {
6095
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6096
- } else
6097
- {
6098
- gl.glNormal3f(0, 0, 1);
6099
- }
6100
- if (c != null)
6101
- {
6102
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6103
- }
6104
- }
6105
-
6106
- if (flipV)
6107
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6108
- else
6109
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6110
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6111
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6112
- count2 += 2;
6113
- count3 += 3;
6114
- }
6115
-
6116
- gl.glEnd();
6117
- }
6118
- }
6119
-
6120
- assert count3 == v.length;
6426
+ //bRep.GenerateNormalsMINE();
61216427 }
6122
- else // !trimmed
6123
- {
6124
- int count = 0;
6125
- for (int i = 0; i < strips.length; i++)
6126
- {
6127
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6128
-
6129
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6130
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6131
-
6132
- drawVertex(gl, p, selectmode);
6133
- drawVertex(gl, q, selectmode);
6134
-
6135
- for (int j = 0; j < strips[i] - 2; j++)
6136
- {
6137
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6138
-
6139
-// if (j%2 == 0)
6140
-// drawFace(p, q, r, display, null);
6141
-// else
6142
-// drawFace(p, r, q, display, null);
6143
-
6144
-// p = q;
6145
-// q = r;
6146
- drawVertex(gl, r, selectmode);
6147
- }
6148
-
6149
- gl.glEnd();
6150
- }
6151
- }
6428
+
6429
+ display.DrawGeometry(bRep, flipV, selectmode);
61526430 } else // catch (Error e)
61536431 {
61546432 // TRIANGLE ARRAY
61556433 if (IsOpaque()) // Static())
61566434 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6435
+ display.StartTriangles();
61586436 int facecount = bRep.FaceCount();
61596437 for (int i = 0; i < facecount; i++)
61606438 {
....@@ -6219,7 +6497,7 @@
62196497
62206498 display.DrawFace(this, p, q, r, face);
62216499 }
6222
- gl.glEnd();
6500
+ display.EndTriangles();
62236501 }
62246502 else
62256503 {
....@@ -6248,8 +6526,8 @@
62486526 //System.out.println("SORT");
62496527
62506528 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6529
+
6530
+ display.StartTriangles();
62536531 for (int i = 0; i < facecount; i++)
62546532 {
62556533 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6541,12 @@
62636541
62646542 display.DrawFace(this, p, q, r, face);
62656543 }
6266
- gl.glEnd();
6544
+ display.EndTriangles();
62676545 }
62686546
62696547 if (false) // live && support != null && support.bRep != null) // debug weights
62706548 {
6549
+ /*
62716550 gl.glDisable(gl.GL_LIGHTING);
62726551 float[] colorV = new float[3];
62736552
....@@ -6346,6 +6625,7 @@
63466625 // gl.glEnd();
63476626 }
63486627 }
6628
+ */
63496629 }
63506630 }
63516631
....@@ -6390,7 +6670,7 @@
63906670 center.add(r);
63916671 center.mul(1.0/3);
63926672
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6673
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946674
63956675 distance = center.dot(center);
63966676 }
....@@ -6404,22 +6684,6 @@
64046684 void Print(Vertex v)
64056685 {
64066686 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6407
- }
6408
-
6409
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6410
- {
6411
- if (!selectmode)
6412
- {
6413
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6414
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6415
-
6416
- if (flipV)
6417
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6418
- else
6419
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6420
- }
6421
-
6422
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64236687 }
64246688
64256689 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +7257,84 @@
69937257 int spotw = spot.x + spot.width;
69947258 int spoth = spot.y + spot.height;
69957259 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
6996
- if (CameraPane.Xmin > spot.x)
6997
- {
6998
- CameraPane.Xmin = spot.x;
6999
- }
7000
- if (CameraPane.Xmax < spotw)
7001
- {
7002
- CameraPane.Xmax = spotw;
7003
- }
7004
- if (CameraPane.Ymin > spot.y)
7005
- {
7006
- CameraPane.Ymin = spot.y;
7007
- }
7008
- if (CameraPane.Ymax < spoth)
7009
- {
7010
- CameraPane.Ymax = spoth;
7011
- }
7260
+// if (CameraPane.Xmin > spot.x)
7261
+// {
7262
+// CameraPane.Xmin = spot.x;
7263
+// }
7264
+// if (CameraPane.Xmax < spotw)
7265
+// {
7266
+// CameraPane.Xmax = spotw;
7267
+// }
7268
+// if (CameraPane.Ymin > spot.y)
7269
+// {
7270
+// CameraPane.Ymin = spot.y;
7271
+// }
7272
+// if (CameraPane.Ymax < spoth)
7273
+// {
7274
+// CameraPane.Ymax = spoth;
7275
+// }
70127276 spot.translate(32, 32);
70137277 spotw = spot.x + spot.width;
70147278 spoth = spot.y + spot.height;
7015
- info.g.setColor(Color.blue);
7279
+ info.g.setColor(Color.cyan);
70167280 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7017
- if (CameraPane.Xmin > spot.x)
7018
- {
7019
- CameraPane.Xmin = spot.x;
7020
- }
7021
- if (CameraPane.Xmax < spotw)
7022
- {
7023
- CameraPane.Xmax = spotw;
7024
- }
7025
- if (CameraPane.Ymin > spot.y)
7026
- {
7027
- CameraPane.Ymin = spot.y;
7028
- }
7029
- if (CameraPane.Ymax < spoth)
7030
- {
7031
- CameraPane.Ymax = spoth;
7032
- }
7033
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7034
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7281
+// if (CameraPane.Xmin > spot.x)
7282
+// {
7283
+// CameraPane.Xmin = spot.x;
7284
+// }
7285
+// if (CameraPane.Xmax < spotw)
7286
+// {
7287
+// CameraPane.Xmax = spotw;
7288
+// }
7289
+// if (CameraPane.Ymin > spot.y)
7290
+// {
7291
+// CameraPane.Ymin = spot.y;
7292
+// }
7293
+// if (CameraPane.Ymax < spoth)
7294
+// {
7295
+// CameraPane.Ymax = spoth;
7296
+// }
7297
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7298
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70357299 spot.translate(0, -32);
7036
- info.g.setColor(Color.green);
7300
+ info.g.setColor(Color.yellow);
70377301 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7038
- if (CameraPane.Xmin > spot.x)
7039
- {
7040
- CameraPane.Xmin = spot.x;
7041
- }
7042
- if (CameraPane.Xmax < spotw)
7043
- {
7044
- CameraPane.Xmax = spotw;
7045
- }
7046
- if (CameraPane.Ymin > spot.y)
7047
- {
7048
- CameraPane.Ymin = spot.y;
7049
- }
7050
- if (CameraPane.Ymax < spoth)
7051
- {
7052
- CameraPane.Ymax = spoth;
7053
- }
7054
- info.g.drawArc(boundary.x, boundary.y,
7055
- boundary.width, boundary.height, 0, 360);
7302
+ info.g.setColor(Color.green);
7303
+// if (CameraPane.Xmin > spot.x)
7304
+// {
7305
+// CameraPane.Xmin = spot.x;
7306
+// }
7307
+// if (CameraPane.Xmax < spotw)
7308
+// {
7309
+// CameraPane.Xmax = spotw;
7310
+// }
7311
+// if (CameraPane.Ymin > spot.y)
7312
+// {
7313
+// CameraPane.Ymin = spot.y;
7314
+// }
7315
+// if (CameraPane.Ymax < spoth)
7316
+// {
7317
+// CameraPane.Ymax = spoth;
7318
+// }
7319
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7320
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
70567321 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7057
- if (CameraPane.Xmin > boundary.x)
7058
- {
7059
- CameraPane.Xmin = boundary.x;
7060
- }
7061
- if (CameraPane.Xmax < boundary.x + boundary.width)
7062
- {
7063
- CameraPane.Xmax = boundary.x + boundary.width;
7064
- }
7065
- if (CameraPane.Ymin > boundary.y)
7066
- {
7067
- CameraPane.Ymin = boundary.y;
7068
- }
7069
- if (CameraPane.Ymax < boundary.y + boundary.height)
7070
- {
7071
- CameraPane.Ymax = boundary.y + boundary.height;
7072
- }
7322
+// if (CameraPane.Xmin > boundary.x)
7323
+// {
7324
+// CameraPane.Xmin = boundary.x;
7325
+// }
7326
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7327
+// {
7328
+// CameraPane.Xmax = boundary.x + boundary.width;
7329
+// }
7330
+// if (CameraPane.Ymin > boundary.y)
7331
+// {
7332
+// CameraPane.Ymin = boundary.y;
7333
+// }
7334
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7335
+// {
7336
+// CameraPane.Ymax = boundary.y + boundary.height;
7337
+// }
70737338 return;
70747339 }
70757340 }
....@@ -7086,7 +7351,7 @@
70867351 startX = info.x;
70877352 startY = info.y;
70887353
7089
- hitSomething = 0;
7354
+ hitSomething = -1;
70907355 cVector origin = new cVector();
70917356 //LA.xformPos(origin, toParent, origin);
70927357 Rectangle spot = new Rectangle();
....@@ -7119,7 +7384,7 @@
71197384 }
71207385
71217386 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7387
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237388 //System.out.println("modified = " + modified);
71247389 //new Exception().printStackTrace();
71257390 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7412,7 @@
71477412 return true;
71487413 }
71497414
7150
- void doEditDrag0(ClickInfo info)
7415
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517416 {
71527417 if (hitSomething == 0)
71537418 {
....@@ -7162,6 +7427,7 @@
71627427 //System.out.println("hitSomething = " + hitSomething);
71637428
71647429 double scale = 0.005f * info.camera.Distance();
7430
+
71657431 cVector xlate = new cVector();
71667432 //cVector xlate2 = new cVector();
71677433 switch (hitSomething)
....@@ -7172,9 +7438,9 @@
71727438
71737439 case hitCenter: // Translate
71747440
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7441
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767442
7177
- if (modified)
7443
+ if (modified || opposite)
71787444 {
71797445 //assert(false);
71807446 /*
....@@ -7220,10 +7486,10 @@
72207486 }
72217487 LA.xformDir(up, ClickInfo.matbuffer, up);
72227488 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7489
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247490 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257491 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7492
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277493 //LA.vecCross(up, cVector.Z, right2);
72287494
72297495 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7534,7 @@
72687534
72697535 if (modified)
72707536 {
7537
+ // Rotate 90 degrees
72717538 angle /= (Math.PI / 4);
72727539 angle = Math.floor(angle + 0.5);
72737540 angle *= (Math.PI / 4);
....@@ -7281,7 +7548,7 @@
72817548 }
72827549 /**/
72837550
7284
- switch (info.pane.renderCamera.viewCode)
7551
+ switch (info.pane.RenderCamera().viewCode)
72857552 {
72867553 case 1: // '\001'
72877554 LA.matZRotate(toParent, angle);
....@@ -7309,24 +7576,27 @@
73097576
73107577 case hitScale: // scale
73117578 double hScale = (double) (info.x - centerPt.x) / 32;
7579
+ double sign = 1;
7580
+ if (hScale < 0)
7581
+ {
7582
+ sign = -1;
7583
+ }
7584
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73127585 if (hScale < 0.01)
73137586 {
7314
- hScale = 0.01;
7587
+ //hScale = 0.01;
73157588 }
7316
- hScale = Math.pow(hScale, scale * 50);
7317
- if (hScale < 0.01)
7318
- {
7319
- hScale = 0.01;
7320
- }
7589
+
73217590 double vScale = (double) (info.y - centerPt.y) / 32;
7322
- if (vScale < 0.01)
7591
+ sign = 1;
7592
+ if (vScale < 0)
73237593 {
7324
- vScale = 0.01;
7594
+ sign = -1;
73257595 }
7326
- vScale = Math.pow(vScale, scale * 50);
7596
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73277597 if (vScale < 0.01)
73287598 {
7329
- vScale = 0.01;
7599
+ //vScale = 0.01;
73307600 }
73317601 LA.matCopy(startMat, toParent);
73327602 /**/
....@@ -7337,39 +7607,47 @@
73377607 }
73387608 /**/
73397609
7340
- switch (info.pane.renderCamera.viewCode)
7610
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7611
+
7612
+ if (totalScale < 0.01)
7613
+ {
7614
+ totalScale = 0.01;
7615
+ }
7616
+
7617
+ switch (info.pane.RenderCamera().viewCode)
73417618 {
73427619 case 3: // '\001'
7343
- if (modified)
7620
+ if (modified || opposite)
73447621 {
73457622 //LA.matScale(toParent, 1, hScale, vScale);
7346
- LA.matScale(toParent, vScale, 1, 1);
7623
+ LA.matScale(toParent, totalScale, 1, 1);
73477624 } // vScale, 1);
73487625 else
73497626 {
7350
- LA.matScale(toParent, vScale, vScale, vScale);
7627
+ // EXCEPTION!
7628
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73517629 } // vScale, 1);
73527630 break;
73537631
73547632 case 2: // '\002'
7355
- if (modified)
7633
+ if (modified || opposite)
73567634 {
73577635 //LA.matScale(toParent, hScale, 1, vScale);
7358
- LA.matScale(toParent, 1, vScale, 1);
7636
+ LA.matScale(toParent, 1, totalScale, 1);
73597637 } else
73607638 {
7361
- LA.matScale(toParent, vScale, 1, vScale);
7639
+ LA.matScale(toParent, totalScale, 1, totalScale);
73627640 }
73637641 break;
73647642
73657643 case 1: // '\003'
7366
- if (modified)
7644
+ if (modified || opposite)
73677645 {
73687646 //LA.matScale(toParent, hScale, vScale, 1);
7369
- LA.matScale(toParent, 1, 1, vScale);
7647
+ LA.matScale(toParent, 1, 1, totalScale);
73707648 } else
73717649 {
7372
- LA.matScale(toParent, vScale, vScale, 1);
7650
+ LA.matScale(toParent, totalScale, totalScale, 1);
73737651 }
73747652 break;
73757653 }
....@@ -7502,14 +7780,22 @@
75027780 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037781 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047782 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7783
+
7784
+ String objname;
7785
+
75057786 if (false) //parent != null)
75067787 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7788
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087789 } else
75097790 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7791
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117792 } // + super.toString();
75127793 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7794
+
7795
+ if (!Globals.ADVANCED)
7796
+ return objname;
7797
+
7798
+ return objname + " " + System.identityHashCode(this);
75137799 }
75147800
75157801 public int hashCode()
....@@ -7565,6 +7851,7 @@
75657851 objectUI.closeUI();
75667852 if (editWindow != null)
75677853 {
7854
+ editWindow.ctrlPanel.FlushUI();
75687855 editWindow.refreshContents();
75697856 } // ? new
75707857 objectUI = null;
....@@ -7573,6 +7860,10 @@
75737860 {
75747861 editWindow = null;
75757862 } // ?
7863
+ }
7864
+ else
7865
+ {
7866
+ //editWindow.closeUI();
75767867 }
75777868 }
75787869
....@@ -7585,7 +7876,7 @@
75857876 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75867877
75877878 Object3D /*Composite*/ parent;
7588
- Object3D /*Composite*/ fileparent;
7879
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75897880
75907881 double[][] toParent; // dynamic matrix
75917882 double[][] fromParent;
....@@ -7700,7 +7991,7 @@
77007991 {
77017992 assert(bRep != null);
77027993 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
7994
+ Grafreed.Assert(support.bRep == bRep.support);
77047995 }
77057996 else
77067997 {
....@@ -7731,6 +8022,10 @@
77318022 }
77328023
77338024 transient ObjEditor editWindow;
8025
+ transient ObjEditor manipWindow;
8026
+
8027
+ transient boolean pinned;
8028
+
77348029 transient ObjectUI objectUI;
77358030 public static int povDepth = 0;
77368031 private static cVector tbMin = new cVector();
....@@ -7749,9 +8044,9 @@
77498044 private static cVector edge2 = new cVector();
77508045 //private static cVector norm = new cVector();
77518046 /*transient private*/ int hitSomething;
7752
- private static final int hitCenter = 1;
7753
- private static final int hitScale = 2;
7754
- private static final int hitRotate = 3;
8047
+ static final int hitCenter = 1;
8048
+ static final int hitScale = 2;
8049
+ static final int hitRotate = 3;
77558050 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77568051 /*transient*/ private Point centerPt;
77578052 /*transient*/ private int startX;