Normand Briere
2019-07-18 d7a17c35c443e2cb6c09eaa3cfeaf590a571faa1
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,12 +14,24 @@
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;
2124
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
+ byte[] versions[] = new byte[100][];
33
+ int versionindex = -1;
34
+
2235 ScriptNode scriptnode;
2336
2437 void InitOthers()
....@@ -99,64 +112,178 @@
99112
100113 // transient boolean reduced; // for morph reduction
101114
102
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
103
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
115
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
116
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
104117
105
-transient Object3D transientsupport; // for cloning
106
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
107120
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)
121
+ void SaveSupports()
120122 {
121
- bRep.SaveSupports();
123
+ if (blockloop)
124
+ return;
125
+
126
+ transientsupport = support;
127
+ transientlink2master = link2master;
128
+
129
+ support = null;
130
+ link2master = false;
131
+
132
+ if (bRep != null)
133
+ {
134
+ bRep.SaveSupports();
135
+ }
136
+
137
+ for (int i = 0; i < Size(); i++)
138
+ {
139
+ Object3D child = (Object3D) get(i);
140
+ if (child == null)
141
+ continue;
142
+ blockloop = true;
143
+ child.SaveSupports();
144
+ blockloop = false;
145
+ }
122146 }
123
-
124
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
125149 {
126
- Object3D child = (Object3D) get(i);
127
- if (child == null)
128
- continue;
150
+ if (blockloop)
151
+ return;
152
+
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
157
+
158
+ if (bRep != null)
159
+ {
160
+ bRep.RestoreSupports();
161
+ }
162
+
163
+ for (int i = 0; i < Size(); i++)
164
+ {
165
+ Object3D child = (Object3D) get(i);
166
+ if (child == null)
167
+ continue;
168
+ blockloop = true;
169
+ child.RestoreSupports();
170
+ blockloop = false;
171
+ }
172
+ }
173
+
174
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175
+ {
176
+ Object3D o;
177
+
178
+ if (hashtable.containsKey(GetUUID()))
179
+ {
180
+ o = hashtable.get(GetUUID());
181
+
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
191
+
192
+ hashtable.put(GetUUID(), o);
193
+ }
194
+
195
+ if (!blockloop)
196
+ {
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
205
+ }
206
+
207
+ ExtractBigData(o);
208
+ }
209
+
210
+ void ExtractBigData(Object3D o)
211
+ {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
215
+ o.bRep = this.bRep;
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
226
+ {
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
232
+ }
233
+
234
+ // o.support = this.support;
235
+ // o.fileparent = this.fileparent;
236
+ // if (this.bRep != null)
237
+ // o.bRep = this.bRep.support;
238
+
239
+ this.bRep = null;
240
+ // if (this.bRep != null)
241
+ // this.bRep.support = null;
242
+ // this.support = null;
243
+ // this.fileparent = null;
244
+ }
245
+
246
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247
+ {
248
+ if (!hashtable.containsKey(GetUUID()))
249
+ return;
250
+
251
+ Object3D o = hashtable.get(GetUUID());
252
+
253
+ RestoreBigData(o);
254
+
255
+ if (blockloop)
256
+ return;
257
+
129258 blockloop = true;
130
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
131267 blockloop = false;
132268 }
133
-}
134269
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)
270
+ void RestoreBigData(Object3D o)
146271 {
147
- bRep.RestoreSupports();
272
+ this.bRep = o.bRep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
284
+ // this.support = o.support;
285
+ // this.fileparent = o.fileparent;
148286 }
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
-}
160287
161288 // MOCAP SUPPORT
162289 double tx,ty,tz,rx,ry,rz;
....@@ -299,6 +426,7 @@
299426 }
300427
301428 boolean live = false;
429
+ boolean dontselect = false;
302430 boolean hide = false;
303431 boolean link2master = false; // performs reset support/master at each frame
304432 boolean marked = false; // animation node
....@@ -430,16 +558,16 @@
430558 {
431559 Object3D copy = this;
432560
433
- Camera parentcam = CameraPane.theRenderer.manipCamera;
561
+ Camera parentcam = Globals.theRenderer.ManipCamera();
434562
435
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
563
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
436564 {
437
- parentcam = CameraPane.theRenderer.cameras[1];
565
+ parentcam = Globals.theRenderer.Cameras()[1];
438566 }
439567
440
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
568
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
441569 {
442
- parentcam = CameraPane.theRenderer.cameras[0];
570
+ parentcam = Globals.theRenderer.Cameras()[0];
443571 }
444572
445573 if (this == parentcam)
....@@ -447,7 +575,7 @@
447575 //assert(this instanceof Camera);
448576
449577 for (int count = parentcam.GetTransformCount(); --count>=0;)
450
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
578
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
451579 }
452580
453581 copy.marked ^= true;
....@@ -467,7 +595,7 @@
467595 //assert(this instanceof Camera);
468596
469597 for (int count = parentcam.GetTransformCount(); --count>=0;)
470
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
598
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
471599 }
472600
473601 copy.Touch(); // display list issue
....@@ -480,12 +608,14 @@
480608 toParent = LA.newMatrix();
481609 fromParent = LA.newMatrix();
482610 }
611
+
483612 if (toParentMarked == null)
484613 {
485614 if (maxcount != 1)
486615 {
487616 new Exception().printStackTrace();
488617 }
618
+
489619 toParentMarked = LA.newMatrix();
490620 fromParentMarked = LA.newMatrix();
491621 }
....@@ -602,7 +732,7 @@
602732 return;
603733 }
604734
605
- if (CameraPane.fromscript)
735
+ if (Globals.fromscript)
606736 {
607737 transformcount = 0;
608738 return;
....@@ -773,7 +903,7 @@
773903 if (step == 0)
774904 step = 1;
775905 if (maxcount == 0)
776
- maxcount = 2048; // 4;
906
+ maxcount = 128; // 2048; // 4;
777907 // if (acceleration == 0)
778908 // acceleration = 10;
779909 if (delay == 0) // serial
....@@ -796,7 +926,7 @@
796926
797927 if (marked && Globals.isLIVE() && live &&
798928 //TEMP21aug2018
799
- Globals.DrawMode() == iCameraPane.SHADOW &&
929
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
800930 currentframe != Globals.framecount)
801931 {
802932 currentframe = Globals.framecount;
....@@ -808,7 +938,8 @@
808938
809939 boolean changedir = random && Math.random() < 0.01; // && !link2master;
810940
811
- if (transformcount*factor > maxcount || (step == 1 && changedir))
941
+ if (transformcount*factor >= maxcount && (rewind || random) ||
942
+ (step == 1 && changedir))
812943 {
813944 countdown = 1;
814945 delay = speedup?8:1;
....@@ -880,6 +1011,7 @@
8801011 if (material == null || material.multiply)
8811012 return true;
8821013
1014
+ // Transparent objects are dynamic because we have to sort the triangles.
8831015 return material.opacity > 0.99;
8841016 }
8851017
....@@ -911,6 +1043,11 @@
9111043 fromParent = null; // LA.newMatrix();
9121044 bRep = null; // new BoundaryRep();
9131045
1046
+ if (oname != null && oname.equals("LeftHand"))
1047
+ {
1048
+ name = oname;
1049
+ }
1050
+
9141051 /*
9151052 float hue = (float)Math.random();
9161053 Color col;
....@@ -953,7 +1090,7 @@
9531090
9541091 public Object clone()
9551092 {
956
- return GrafreeD.clone(this);
1093
+ return Grafreed.clone(this);
9571094 }
9581095
9591096 Object3D copyExpand()
....@@ -1275,6 +1412,7 @@
12751412 toParent = LA.newMatrix();
12761413 fromParent = LA.newMatrix();
12771414 }
1415
+
12781416 LA.matCopy(other.toParent, toParent);
12791417 LA.matCopy(other.fromParent, fromParent);
12801418
....@@ -1469,7 +1607,7 @@
14691607 BoundaryRep.SEUIL = other.material.cameralight;
14701608
14711609 // Set default to 0.1
1472
- BoundaryRep.SEUIL /= 2;
1610
+ BoundaryRep.SEUIL /= 4; // 2;
14731611 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14741612 }
14751613
....@@ -1728,7 +1866,7 @@
17281866 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17291867 o.bRep = transientrep;
17301868 if (clone)
1731
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1869
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17321870 o.CreateMaterial();
17331871 o.SetAttributes(this, -1);
17341872 //parent
....@@ -1741,7 +1879,7 @@
17411879 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17421880 o.bRep = bRep;
17431881 if (clone)
1744
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1882
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17451883 o.CreateMaterial();
17461884 //o.overwriteThis(this, -1);
17471885 o.SetAttributes(this, -1);
....@@ -1828,12 +1966,15 @@
18281966 if (obj.name == null)
18291967 continue; // can't be a null one
18301968
1969
+ // Try perfect match first.
18311970 if (n.equals(obj.name))
18321971 {
18331972 theobj = obj;
18341973 count++;
18351974 }
18361975 }
1976
+
1977
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18371978
18381979 if (count != 1)
18391980 for (int i=Size(); --i>=0;)
....@@ -2293,12 +2434,17 @@
22932434 }
22942435 */
22952436 }
2437
+ else
2438
+ {
2439
+ //((ObjEditor)editWindow).SetupUI2(null);
2440
+ }
22962441 }
22972442
22982443 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22992444 {
23002445 if (newWindow)
23012446 {
2447
+ new Exception().printStackTrace();
23022448 System.exit(0);
23032449 if (parent != null)
23042450 {
....@@ -2333,6 +2479,14 @@
23332479 {
23342480 editWindow.refreshContents();
23352481 }
2482
+ else
2483
+ {
2484
+ if (manipWindow != null)
2485
+ {
2486
+ manipWindow.refreshContents();
2487
+ }
2488
+ }
2489
+
23362490 //if (parent != null)
23372491 //parent.refreshEditWindow();
23382492 }
....@@ -2475,13 +2629,13 @@
24752629 return retval;
24762630 }
24772631
2478
- void doEditDrag(ClickInfo info)
2632
+ void doEditDrag(ClickInfo info, boolean opposite)
24792633 {
24802634 switch (doSomething)
24812635 {
24822636 case 1: // '\001'
24832637 //super.
2484
- doEditDrag0(info);
2638
+ doEditDrag0(info, opposite);
24852639 break;
24862640
24872641 case 2: // '\002'
....@@ -2494,11 +2648,11 @@
24942648 {
24952649 //sel.hitSomething = childToDrag.hitSomething;
24962650 //childToDrag.doEditDrag(info);
2497
- sel.doEditDrag(info);
2651
+ sel.doEditDrag(info, opposite);
24982652 } else
24992653 {
25002654 //super.
2501
- doEditDrag0(info);
2655
+ doEditDrag0(info, opposite);
25022656 }
25032657 }
25042658 break;
....@@ -2608,6 +2762,18 @@
26082762 void GenNormalsS(boolean crease)
26092763 {
26102764 selection.GenNormals(crease);
2765
+// for (int i=0; i<selection.size(); i++)
2766
+// {
2767
+// Object3D selectee = (Object3D) selection.elementAt(i);
2768
+// selectee.GenNormals(crease);
2769
+// }
2770
+
2771
+ //Touch();
2772
+ }
2773
+
2774
+ void GenNormalsMeshS()
2775
+ {
2776
+ selection.GenNormalsMesh();
26112777 // for (int i=0; i<selection.size(); i++)
26122778 // {
26132779 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2748,6 +2914,24 @@
27482914 if (child == null)
27492915 continue;
27502916 child.GenNormals(crease);
2917
+// Children().release(i);
2918
+ }
2919
+ blockloop = false;
2920
+ }
2921
+
2922
+ void GenNormalsMesh()
2923
+ {
2924
+ if (blockloop)
2925
+ return;
2926
+
2927
+ blockloop = true;
2928
+ GenNormalsMesh0();
2929
+ for (int i = 0; i < Children().Size(); i++)
2930
+ {
2931
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2932
+ if (child == null)
2933
+ continue;
2934
+ child.GenNormalsMesh();
27512935 // Children().release(i);
27522936 }
27532937 blockloop = false;
....@@ -2905,7 +3089,8 @@
29053089 {
29063090 if (bRep != null)
29073091 {
2908
- bRep.GenUV();
3092
+ bRep.GenUV(); //1);
3093
+ //bRep.UnfoldUV();
29093094 Touch();
29103095 }
29113096 }
....@@ -2915,6 +3100,15 @@
29153100 if (bRep != null)
29163101 {
29173102 bRep.GenerateNormals(crease);
3103
+ Touch();
3104
+ }
3105
+ }
3106
+
3107
+ void GenNormalsMesh0()
3108
+ {
3109
+ if (bRep != null)
3110
+ {
3111
+ bRep.GenerateNormalsMesh();
29183112 Touch();
29193113 }
29203114 }
....@@ -2980,6 +3174,33 @@
29803174 blockloop = false;
29813175 }
29823176
3177
+ void TransformChildren()
3178
+ {
3179
+ if (toParent != null)
3180
+ {
3181
+ for (int i=Size(); --i>=0;)
3182
+ {
3183
+ Object3D v = get(i);
3184
+
3185
+ if (v.toParent == null)
3186
+ {
3187
+ v.toParent = LA.newMatrix();
3188
+ v.fromParent = LA.newMatrix();
3189
+ }
3190
+
3191
+// LA.matConcat(v.toParent, toParent, v.toParent);
3192
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3193
+ LA.matConcat(toParent, v.toParent, v.toParent);
3194
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3195
+ }
3196
+
3197
+ toParent = null; // LA.matIdentity(toParent);
3198
+ fromParent = null; // LA.matIdentity(fromParent);
3199
+
3200
+ Touch();
3201
+ }
3202
+ }
3203
+
29833204 void TransformGeometry()
29843205 {
29853206 Object3D obj = this;
....@@ -3201,9 +3422,11 @@
32013422
32023423 BoundaryRep sup = bRep.support;
32033424 bRep.support = null;
3204
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3425
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
32053426 // bRep.SplitInTwo(onlyone); // thread...
3206
- temprep.SplitInTwo(reduction34, onlyone);
3427
+
3428
+ while(temprep.SplitInTwo(reduction34, onlyone));
3429
+
32073430 bRep = temprep;
32083431 bRep.support = sup;
32093432 Touch();
....@@ -3340,7 +3563,8 @@
33403563 if (blockloop)
33413564 return;
33423565
3343
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
33443568 live = h;
33453569
33463570 for (int i = 0; i < Size(); i++)
....@@ -3361,7 +3585,8 @@
33613585 return;
33623586
33633587 //if (bRep != null)
3364
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
33653590 link2master = h;
33663591
33673592 for (int i = 0; i < Size(); i++)
....@@ -3381,7 +3606,8 @@
33813606 if (blockloop)
33823607 return;
33833608
3384
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
33853611 hide = h;
33863612
33873613 for (int i = 0; i < Size(); i++)
....@@ -3401,7 +3627,7 @@
34013627 if (blockloop)
34023628 return;
34033629
3404
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
34053631 marked = h;
34063632
34073633 for (int i = 0; i < Size(); i++)
....@@ -3411,6 +3637,46 @@
34113637 continue;
34123638 blockloop = true;
34133639 child.MarkLeaves(h);
3640
+ blockloop = false;
3641
+ // release(i);
3642
+ }
3643
+ }
3644
+
3645
+ void RewindLeaves(boolean h)
3646
+ {
3647
+ if (blockloop)
3648
+ return;
3649
+
3650
+ if (bRep != null || material != null) // borderline...
3651
+ rewind = h;
3652
+
3653
+ for (int i = 0; i < Size(); i++)
3654
+ {
3655
+ Object3D child = (Object3D) get(i); // reserve(i);
3656
+ if (child == null)
3657
+ continue;
3658
+ blockloop = true;
3659
+ child.RewindLeaves(h);
3660
+ blockloop = false;
3661
+ // release(i);
3662
+ }
3663
+ }
3664
+
3665
+ void RandomLeaves(boolean h)
3666
+ {
3667
+ if (blockloop)
3668
+ return;
3669
+
3670
+ if (bRep != null || material != null) // borderline...
3671
+ random = h;
3672
+
3673
+ for (int i = 0; i < Size(); i++)
3674
+ {
3675
+ Object3D child = (Object3D) get(i); // reserve(i);
3676
+ if (child == null)
3677
+ continue;
3678
+ blockloop = true;
3679
+ child.RandomLeaves(h);
34143680 blockloop = false;
34153681 // release(i);
34163682 }
....@@ -3725,7 +3991,7 @@
37253991 if (child == null)
37263992 continue;
37273993
3728
- if (GrafreeD.RENDERME > 0)
3994
+ if (Grafreed.RENDERME > 0)
37293995 {
37303996 if (child instanceof Merge)
37313997 ((Merge)child).renderme();
....@@ -3876,7 +4142,7 @@
38764142 if (child == null)
38774143 continue;
38784144
3879
- if (GrafreeD.RENDERME > 0)
4145
+ if (Grafreed.RENDERME > 0)
38804146 {
38814147 if (child instanceof Merge)
38824148 ((Merge)child).renderme();
....@@ -4071,7 +4337,7 @@
40714337 if (child == null)
40724338 continue;
40734339
4074
- if (GrafreeD.RENDERME > 0)
4340
+ if (Grafreed.RENDERME > 0)
40754341 {
40764342 if (child instanceof Merge)
40774343 ((Merge)child).renderme();
....@@ -4184,6 +4450,55 @@
41844450 {
41854451 blockloop = true;
41864452 get(i).RepairShadow();
4453
+ blockloop = false;
4454
+ }
4455
+ }
4456
+
4457
+ void RepairSOV()
4458
+ {
4459
+ if (blockloop)
4460
+ return;
4461
+
4462
+ String texname = this.GetPigmentTexture();
4463
+
4464
+ if (texname.startsWith("sov"))
4465
+ {
4466
+ String[] s = texname.split("/");
4467
+
4468
+ String[] sname = s[1].split("Color.pn");
4469
+
4470
+ texname = sname[0];
4471
+
4472
+ if (sname.length > 1)
4473
+ {
4474
+ texname += "Color.jpg";
4475
+ }
4476
+
4477
+ this.SetPigmentTexture("sov/" + texname);
4478
+ }
4479
+
4480
+ texname = this.GetBumpTexture();
4481
+
4482
+ if (texname.startsWith("sov"))
4483
+ {
4484
+ String[] s = texname.split("/");
4485
+
4486
+ String[] sname = s[1].split("Bump.pn");
4487
+
4488
+ texname = sname[0];
4489
+
4490
+ if (sname.length > 1)
4491
+ {
4492
+ texname += "Bump.jpg";
4493
+ }
4494
+
4495
+ this.SetBumpTexture("sov/" + texname);
4496
+ }
4497
+
4498
+ for (int i=0; i<Size(); i++)
4499
+ {
4500
+ blockloop = true;
4501
+ get(i).RepairSOV();
41874502 blockloop = false;
41884503 }
41894504 }
....@@ -4678,7 +4993,7 @@
46784993
46794994 cTreePath SelectLeaf(int indexcount, boolean deselect)
46804995 {
4681
- if (hide)
4996
+ if (hide || dontselect)
46824997 return null;
46834998
46844999 if (count <= 0)
....@@ -4702,9 +5017,17 @@
47025017 }
47035018 }
47045019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
47055028 cTreePath Select(int indexcount, boolean deselect)
47065029 {
4707
- if (hide)
5030
+ if (hide || dontselect)
47085031 return null;
47095032
47105033 if (count <= 0)
....@@ -4738,10 +5061,11 @@
47385061 if (leaf != null)
47395062 {
47405063 cTreePath tp = new cTreePath(this, leaf);
4741
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
47425066 {
47435067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4744
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
47455069 }
47465070
47475071 return tp;
....@@ -4758,6 +5082,7 @@
47585082
47595083 if (child == null)
47605084 continue;
5085
+
47615086 if (child.HasTransparency() && child.size() != 0)
47625087 {
47635088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4767,9 +5092,10 @@
47675092 if (leaf != null)
47685093 {
47695094 cTreePath tp = new cTreePath(this, leaf);
4770
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
47715097 {
4772
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
47735099 }
47745100
47755101 return tp;
....@@ -4854,7 +5180,7 @@
48545180 return globalTransform;
48555181 }
48565182
4857
- void PreprocessOcclusion(CameraPane cp)
5183
+ void PreprocessOcclusion(iCameraPane cp)
48585184 {
48595185 /*
48605186 if (AOdone)
....@@ -5156,10 +5482,34 @@
51565482
51575483 // System.out.println("Fullname = " + fullname);
51585484
5159
- if (fullname.name.indexOf(":") == -1)
5160
- return fullname.name;
5485
+ // Does not work on Windows due to C:
5486
+// if (fullname.name.indexOf(":") == -1)
5487
+// return fullname.name;
5488
+//
5489
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51615490
5162
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5491
+ String[] split = fullname.name.split(":");
5492
+
5493
+ if (split.length == 0)
5494
+ {
5495
+ return "";
5496
+ }
5497
+
5498
+ if (split.length <= 2)
5499
+ {
5500
+ if (fullname.name.endsWith(":"))
5501
+ {
5502
+ // Windows
5503
+ return fullname.name.substring(0, fullname.name.length()-1);
5504
+ }
5505
+
5506
+ return split[0];
5507
+ }
5508
+
5509
+ // Windows
5510
+ assert(split.length == 4);
5511
+
5512
+ return split[0] + ":" + split[1];
51635513 }
51645514
51655515 static String GetBump(cTexture fullname)
....@@ -5168,10 +5518,38 @@
51685518 return "";
51695519
51705520 // 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());
5521
+ // Does not work on Windows due to C:
5522
+// if (fullname.name.indexOf(":") == -1)
5523
+// return "";
5524
+//
5525
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5526
+ String[] split = fullname.name.split(":");
5527
+
5528
+ if (split.length == 0)
5529
+ {
5530
+ return "";
5531
+ }
5532
+
5533
+ if (split.length == 1)
5534
+ {
5535
+ return "";
5536
+ }
5537
+
5538
+ if (split.length == 2)
5539
+ {
5540
+ if (fullname.name.endsWith(":"))
5541
+ {
5542
+ // Windows
5543
+ return "";
5544
+ }
5545
+
5546
+ return split[1];
5547
+ }
5548
+
5549
+ // Windows
5550
+ assert(split.length == 4);
5551
+
5552
+ return split[2] + ":" + split[3];
51755553 }
51765554
51775555 String GetPigmentTexture()
....@@ -5245,7 +5623,7 @@
52455623 System.out.print("; textures = " + textures);
52465624 System.out.println("; usedtextures = " + usedtextures);
52475625
5248
- if (GetTextures() == null)
5626
+ if (GetTextures() == null) // What is that??
52495627 GetTextures().name = ":";
52505628
52515629 String texname = tex;
....@@ -5276,6 +5654,43 @@
52765654 child.ResetPigmentTexture();
52775655 blockloop = false;
52785656 }
5657
+ }
5658
+
5659
+ UUID GetUUID()
5660
+ {
5661
+ if (uuid == null)
5662
+ {
5663
+ // Serial
5664
+ uuid = UUID.randomUUID();
5665
+ }
5666
+
5667
+ return uuid;
5668
+ }
5669
+
5670
+ Object3D GetObject(UUID uid)
5671
+ {
5672
+ if (blockloop)
5673
+ return null;
5674
+
5675
+ if (GetUUID().equals(uid))
5676
+ return this;
5677
+
5678
+ int nb = Size();
5679
+ for (int i = 0; i < nb; i++)
5680
+ {
5681
+ Object3D child = (Object3D) get(i);
5682
+
5683
+ if (child == null)
5684
+ continue;
5685
+
5686
+ blockloop = true;
5687
+ Object3D obj = child.GetObject(uid);
5688
+ blockloop = false;
5689
+ if (obj != null)
5690
+ return obj;
5691
+ }
5692
+
5693
+ return null;
52795694 }
52805695
52815696 void SetBumpTexture(String tex)
....@@ -5322,11 +5737,23 @@
53225737 boolean NeedSupport()
53235738 {
53245739 return
5325
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5740
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53265741 // PROBLEM with CROWD!!
5327
- && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD);
5742
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53285743 }
53295744
5745
+ static boolean DEBUG_SELECTION = false;
5746
+
5747
+ boolean IsLive()
5748
+ {
5749
+ if (live)
5750
+ return true;
5751
+
5752
+ if (parent == null)
5753
+ return false;
5754
+
5755
+ return parent.IsLive();
5756
+ }
53305757
53315758 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53325759 {
....@@ -5338,7 +5765,7 @@
53385765 }
53395766
53405767 if (display.DrawMode() == iCameraPane.SELECTION &&
5341
- hide)
5768
+ (hide || dontselect))
53425769 return;
53435770
53445771 if (name != null && name.contains("sclera"))
....@@ -5365,12 +5792,12 @@
53655792 }
53665793
53675794 if ((//display.DrawMode() == CameraPane.SHADOW ||
5368
- display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5795
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53695796 {
53705797 return;
53715798 }
53725799
5373
- javax.media.opengl.GL gl = display.GetGL();
5800
+ //javax.media.opengl.GL gl = display.GetGL();
53745801
53755802 /*
53765803 if (touched)
....@@ -5389,7 +5816,7 @@
53895816 support = support;
53905817
53915818 //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);
5819
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53935820
53945821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53955822 {
....@@ -5406,13 +5833,15 @@
54065833
54075834 boolean compiled = false;
54085835
5409
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
5836
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54105837
54115838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5412
- (touched || (bRep != null && bRep.displaylist <= 0)))
5839
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5840
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
54135841 {
54145842 Globals.lighttouched = true;
54155843 } // all panes...
5844
+
54165845 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54175846 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54185847 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5422,7 +5851,7 @@
54225851 //if (displaylist == -1 && usecalllists)
54235852 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54245853 {
5425
- bRep.displaylist = gl.glGenLists(1);
5854
+ bRep.displaylist = display.GenList();
54265855 assert(bRep.displaylist != 0);
54275856 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54285857 //System.out.println("\tgen list " + list);
....@@ -5434,14 +5863,16 @@
54345863 if (usecalllists)
54355864 {
54365865 // System.err.println("new list " + bRep.displaylist + " for " + this);
5437
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5866
+ display.NewList(bRep.displaylist);
54385867 }
5868
+
54395869 CallList(display, root, selected, blocked);
5870
+
54405871 // compiled = true;
54415872 if (usecalllists)
54425873 {
54435874 // System.err.println("end list " + bRep.displaylist + " for " + this);
5444
- gl.glEndList();
5875
+ display.EndList();
54455876 }
54465877 //gl.glDrawBuffer(gl.GL_BACK);
54475878 // XXX touched = false;
....@@ -5484,12 +5915,12 @@
54845915
54855916 // frustum culling
54865917 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5487
- && display.DrawMode() != CameraPane.SELECTION)
5918
+ && display.DrawMode() != iCameraPane.SELECTION)
54885919 {
5489
- if (display.DrawMode() == CameraPane.SHADOW)
5920
+ if (display.DrawMode() == iCameraPane.SHADOW)
54905921 {
54915922 if (!link2master // tricky to cull in shadow mode.
5492
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5923
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54935924 {
54945925 //System.out.print("CULLED");
54955926 culled = true;
....@@ -5497,7 +5928,7 @@
54975928 }
54985929 else
54995930 //GetBRep().getBounds(v0, v1, this);
5500
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5931
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55015932 culled = true;
55025933
55035934 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5533,11 +5964,12 @@
55335964
55345965
55355966 if (!culled)
5536
- if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION)
5967
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55375968 {
55385969 if (GetBRep() != null)
55395970 {
5540
- CameraPane.NextIndex(this, gl);
5971
+ display.NextIndex();
5972
+
55415973 // vertex color conflict : gl.glCallList(list);
55425974 DrawNode(display, root, selected);
55435975 if (this instanceof BezierPatch)
....@@ -5578,7 +6010,28 @@
55786010 tex = GetTextures();
55796011 }
55806012
5581
- display.BindTextures(tex, texres);
6013
+ boolean failedPigment = false;
6014
+ boolean failedBump = false;
6015
+
6016
+ try
6017
+ {
6018
+ display.BindPigmentTexture(tex, texres);
6019
+ }
6020
+ catch (Exception e)
6021
+ {
6022
+ System.err.println("FAILED: " + this);
6023
+ failedPigment = true;
6024
+ }
6025
+
6026
+ try
6027
+ {
6028
+ display.BindBumpTexture(tex, texres);
6029
+ }
6030
+ catch (Exception e)
6031
+ {
6032
+ //System.err.println("FAILED: " + this);
6033
+ failedBump = true;
6034
+ }
55826035
55836036 if (!compiled)
55846037 {
....@@ -5594,13 +6047,17 @@
55946047
55956048 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55966049 assert(bRep.displaylist != 0);
5597
- gl.glCallList(bRep.displaylist);
6050
+ display.CallList(bRep.displaylist);
55986051 // june 2013 drawSelf(display, root, selected);
55996052 }
56006053 }
56016054 }
56026055
5603
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
56046061
56056062 display.PopMaterial(this, selected);
56066063 }
....@@ -5729,6 +6186,9 @@
57296186
57306187 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316188 {
6189
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6190
+ return;
6191
+
57326192 if (hide)
57336193 return;
57346194 // shadow optimisation
....@@ -5854,6 +6314,9 @@
58546314 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58556315 return; // no shadow for transparent objects
58566316
6317
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
+ return;
6319
+
58576320 if (hide)
58586321 return;
58596322
....@@ -5894,9 +6357,10 @@
58946357 return;
58956358 }
58966359
6360
+ //bRep.GenUV(1/material.diffuseness);
58976361 // bRep.lock = true;
58986362
5899
- javax.media.opengl.GL gl = display.GetGL();
6363
+ //javax.media.opengl.GL gl = display.GetGL();
59006364
59016365 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59026366 {
....@@ -5913,23 +6377,7 @@
59136377
59146378 bRep.getMinMax(min, max, 100);
59156379
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();
6380
+ display.DrawBox(min, max);
59336381
59346382 return;
59356383 }
....@@ -5973,7 +6421,7 @@
59736421 {
59746422 //throw new Error();
59756423
5976
- boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION;
6424
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59776425
59786426 int[] strips = bRep.getRawIndices();
59796427
....@@ -5983,178 +6431,19 @@
59836431 new Exception().printStackTrace();
59846432 return;
59856433 }
5986
-
5987
- // TRIANGLE STRIP ARRAY
5988
- if (bRep.trimmed)
6434
+
6435
+ if (dontselect)
59896436 {
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;
6437
+ //bRep.GenerateNormalsMINE();
61216438 }
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
- }
6439
+
6440
+ display.DrawGeometry(bRep, flipV, selectmode);
61526441 } else // catch (Error e)
61536442 {
61546443 // TRIANGLE ARRAY
61556444 if (IsOpaque()) // Static())
61566445 {
6157
- gl.glBegin(gl.GL_TRIANGLES);
6446
+ display.StartTriangles();
61586447 int facecount = bRep.FaceCount();
61596448 for (int i = 0; i < facecount; i++)
61606449 {
....@@ -6219,7 +6508,7 @@
62196508
62206509 display.DrawFace(this, p, q, r, face);
62216510 }
6222
- gl.glEnd();
6511
+ display.EndTriangles();
62236512 }
62246513 else
62256514 {
....@@ -6248,8 +6537,8 @@
62486537 //System.out.println("SORT");
62496538
62506539 java.util.Arrays.sort(facescompare);
6251
-
6252
- gl.glBegin(gl.GL_TRIANGLES);
6540
+
6541
+ display.StartTriangles();
62536542 for (int i = 0; i < facecount; i++)
62546543 {
62556544 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6263,11 +6552,12 @@
62636552
62646553 display.DrawFace(this, p, q, r, face);
62656554 }
6266
- gl.glEnd();
6555
+ display.EndTriangles();
62676556 }
62686557
62696558 if (false) // live && support != null && support.bRep != null) // debug weights
62706559 {
6560
+ /*
62716561 gl.glDisable(gl.GL_LIGHTING);
62726562 float[] colorV = new float[3];
62736563
....@@ -6346,6 +6636,7 @@
63466636 // gl.glEnd();
63476637 }
63486638 }
6639
+ */
63496640 }
63506641 }
63516642
....@@ -6390,7 +6681,7 @@
63906681 center.add(r);
63916682 center.mul(1.0/3);
63926683
6393
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6684
+ center.sub(Globals.theRenderer.EyeCamera().location);
63946685
63956686 distance = center.dot(center);
63966687 }
....@@ -6404,22 +6695,6 @@
64046695 void Print(Vertex v)
64056696 {
64066697 //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);
64236698 }
64246699
64256700 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -6993,83 +7268,84 @@
69937268 int spotw = spot.x + spot.width;
69947269 int spoth = spot.y + spot.height;
69957270 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
- }
7271
+// if (CameraPane.Xmin > spot.x)
7272
+// {
7273
+// CameraPane.Xmin = spot.x;
7274
+// }
7275
+// if (CameraPane.Xmax < spotw)
7276
+// {
7277
+// CameraPane.Xmax = spotw;
7278
+// }
7279
+// if (CameraPane.Ymin > spot.y)
7280
+// {
7281
+// CameraPane.Ymin = spot.y;
7282
+// }
7283
+// if (CameraPane.Ymax < spoth)
7284
+// {
7285
+// CameraPane.Ymax = spoth;
7286
+// }
70127287 spot.translate(32, 32);
70137288 spotw = spot.x + spot.width;
70147289 spoth = spot.y + spot.height;
7015
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
70167291 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);
7292
+// if (CameraPane.Xmin > spot.x)
7293
+// {
7294
+// CameraPane.Xmin = spot.x;
7295
+// }
7296
+// if (CameraPane.Xmax < spotw)
7297
+// {
7298
+// CameraPane.Xmax = spotw;
7299
+// }
7300
+// if (CameraPane.Ymin > spot.y)
7301
+// {
7302
+// CameraPane.Ymin = spot.y;
7303
+// }
7304
+// if (CameraPane.Ymax < spoth)
7305
+// {
7306
+// CameraPane.Ymax = spoth;
7307
+// }
7308
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7309
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
70357310 spot.translate(0, -32);
7036
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
70377312 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);
7313
+ info.g.setColor(Color.green);
7314
+// if (CameraPane.Xmin > spot.x)
7315
+// {
7316
+// CameraPane.Xmin = spot.x;
7317
+// }
7318
+// if (CameraPane.Xmax < spotw)
7319
+// {
7320
+// CameraPane.Xmax = spotw;
7321
+// }
7322
+// if (CameraPane.Ymin > spot.y)
7323
+// {
7324
+// CameraPane.Ymin = spot.y;
7325
+// }
7326
+// if (CameraPane.Ymax < spoth)
7327
+// {
7328
+// CameraPane.Ymax = spoth;
7329
+// }
7330
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7331
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
70567332 //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
- }
7333
+// if (CameraPane.Xmin > boundary.x)
7334
+// {
7335
+// CameraPane.Xmin = boundary.x;
7336
+// }
7337
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7338
+// {
7339
+// CameraPane.Xmax = boundary.x + boundary.width;
7340
+// }
7341
+// if (CameraPane.Ymin > boundary.y)
7342
+// {
7343
+// CameraPane.Ymin = boundary.y;
7344
+// }
7345
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7346
+// {
7347
+// CameraPane.Ymax = boundary.y + boundary.height;
7348
+// }
70737349 return;
70747350 }
70757351 }
....@@ -7086,7 +7362,7 @@
70867362 startX = info.x;
70877363 startY = info.y;
70887364
7089
- hitSomething = 0;
7365
+ hitSomething = -1;
70907366 cVector origin = new cVector();
70917367 //LA.xformPos(origin, toParent, origin);
70927368 Rectangle spot = new Rectangle();
....@@ -7119,7 +7395,7 @@
71197395 }
71207396
71217397 //System.out.println("info.modifiers = " + info.modifiers);
7122
- modified = (info.modifiers & CameraPane.META) != 0;
7398
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71237399 //System.out.println("modified = " + modified);
71247400 //new Exception().printStackTrace();
71257401 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7147,7 +7423,7 @@
71477423 return true;
71487424 }
71497425
7150
- void doEditDrag0(ClickInfo info)
7426
+ void doEditDrag0(ClickInfo info, boolean opposite)
71517427 {
71527428 if (hitSomething == 0)
71537429 {
....@@ -7162,6 +7438,7 @@
71627438 //System.out.println("hitSomething = " + hitSomething);
71637439
71647440 double scale = 0.005f * info.camera.Distance();
7441
+
71657442 cVector xlate = new cVector();
71667443 //cVector xlate2 = new cVector();
71677444 switch (hitSomething)
....@@ -7172,9 +7449,9 @@
71727449
71737450 case hitCenter: // Translate
71747451
7175
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7452
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71767453
7177
- if (modified)
7454
+ if (modified || opposite)
71787455 {
71797456 //assert(false);
71807457 /*
....@@ -7220,10 +7497,10 @@
72207497 }
72217498 LA.xformDir(up, ClickInfo.matbuffer, up);
72227499 // if (!CameraPane.LOCALTRANSFORM)
7223
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7500
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72247501 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72257502 // if (!CameraPane.LOCALTRANSFORM)
7226
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7503
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72277504 //LA.vecCross(up, cVector.Z, right2);
72287505
72297506 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7268,6 +7545,7 @@
72687545
72697546 if (modified)
72707547 {
7548
+ // Rotate 90 degrees
72717549 angle /= (Math.PI / 4);
72727550 angle = Math.floor(angle + 0.5);
72737551 angle *= (Math.PI / 4);
....@@ -7281,7 +7559,7 @@
72817559 }
72827560 /**/
72837561
7284
- switch (info.pane.renderCamera.viewCode)
7562
+ switch (info.pane.RenderCamera().viewCode)
72857563 {
72867564 case 1: // '\001'
72877565 LA.matZRotate(toParent, angle);
....@@ -7309,24 +7587,27 @@
73097587
73107588 case hitScale: // scale
73117589 double hScale = (double) (info.x - centerPt.x) / 32;
7590
+ double sign = 1;
7591
+ if (hScale < 0)
7592
+ {
7593
+ sign = -1;
7594
+ }
7595
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
73127596 if (hScale < 0.01)
73137597 {
7314
- hScale = 0.01;
7598
+ //hScale = 0.01;
73157599 }
7316
- hScale = Math.pow(hScale, scale * 50);
7317
- if (hScale < 0.01)
7318
- {
7319
- hScale = 0.01;
7320
- }
7600
+
73217601 double vScale = (double) (info.y - centerPt.y) / 32;
7322
- if (vScale < 0.01)
7602
+ sign = 1;
7603
+ if (vScale < 0)
73237604 {
7324
- vScale = 0.01;
7605
+ sign = -1;
73257606 }
7326
- vScale = Math.pow(vScale, scale * 50);
7607
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73277608 if (vScale < 0.01)
73287609 {
7329
- vScale = 0.01;
7610
+ //vScale = 0.01;
73307611 }
73317612 LA.matCopy(startMat, toParent);
73327613 /**/
....@@ -7337,39 +7618,47 @@
73377618 }
73387619 /**/
73397620
7340
- switch (info.pane.renderCamera.viewCode)
7621
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7622
+
7623
+ if (totalScale < 0.01)
7624
+ {
7625
+ totalScale = 0.01;
7626
+ }
7627
+
7628
+ switch (info.pane.RenderCamera().viewCode)
73417629 {
73427630 case 3: // '\001'
7343
- if (modified)
7631
+ if (modified || opposite)
73447632 {
73457633 //LA.matScale(toParent, 1, hScale, vScale);
7346
- LA.matScale(toParent, vScale, 1, 1);
7634
+ LA.matScale(toParent, totalScale, 1, 1);
73477635 } // vScale, 1);
73487636 else
73497637 {
7350
- LA.matScale(toParent, vScale, vScale, vScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73517640 } // vScale, 1);
73527641 break;
73537642
73547643 case 2: // '\002'
7355
- if (modified)
7644
+ if (modified || opposite)
73567645 {
73577646 //LA.matScale(toParent, hScale, 1, vScale);
7358
- LA.matScale(toParent, 1, vScale, 1);
7647
+ LA.matScale(toParent, 1, totalScale, 1);
73597648 } else
73607649 {
7361
- LA.matScale(toParent, vScale, 1, vScale);
7650
+ LA.matScale(toParent, totalScale, 1, totalScale);
73627651 }
73637652 break;
73647653
73657654 case 1: // '\003'
7366
- if (modified)
7655
+ if (modified || opposite)
73677656 {
73687657 //LA.matScale(toParent, hScale, vScale, 1);
7369
- LA.matScale(toParent, 1, 1, vScale);
7658
+ LA.matScale(toParent, 1, 1, totalScale);
73707659 } else
73717660 {
7372
- LA.matScale(toParent, vScale, vScale, 1);
7661
+ LA.matScale(toParent, totalScale, totalScale, 1);
73737662 }
73747663 break;
73757664 }
....@@ -7502,14 +7791,22 @@
75027791 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75037792 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75047793 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7794
+
7795
+ String objname;
7796
+
75057797 if (false) //parent != null)
75067798 {
7507
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7799
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75087800 } else
75097801 {
7510
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7802
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
75117803 } // + super.toString();
75127804 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7805
+
7806
+ if (!Globals.ADVANCED)
7807
+ return objname;
7808
+
7809
+ return objname + " " + System.identityHashCode(this);
75137810 }
75147811
75157812 public int hashCode()
....@@ -7565,6 +7862,7 @@
75657862 objectUI.closeUI();
75667863 if (editWindow != null)
75677864 {
7865
+ editWindow.ctrlPanel.FlushUI();
75687866 editWindow.refreshContents();
75697867 } // ? new
75707868 objectUI = null;
....@@ -7573,6 +7871,10 @@
75737871 {
75747872 editWindow = null;
75757873 } // ?
7874
+ }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
75767878 }
75777879 }
75787880
....@@ -7585,7 +7887,7 @@
75857887 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75867888
75877889 Object3D /*Composite*/ parent;
7588
- Object3D /*Composite*/ fileparent;
7890
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75897891
75907892 double[][] toParent; // dynamic matrix
75917893 double[][] fromParent;
....@@ -7700,7 +8002,7 @@
77008002 {
77018003 assert(bRep != null);
77028004 if (!(support instanceof GenericJoint)) // support.bRep != null)
7703
- GrafreeD.Assert(support.bRep == bRep.support);
8005
+ Grafreed.Assert(support.bRep == bRep.support);
77048006 }
77058007 else
77068008 {
....@@ -7731,6 +8033,10 @@
77318033 }
77328034
77338035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
77348040 transient ObjectUI objectUI;
77358041 public static int povDepth = 0;
77368042 private static cVector tbMin = new cVector();
....@@ -7749,9 +8055,9 @@
77498055 private static cVector edge2 = new cVector();
77508056 //private static cVector norm = new cVector();
77518057 /*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;
8058
+ static final int hitCenter = 1;
8059
+ static final int hitScale = 2;
8060
+ static final int hitRotate = 3;
77558061 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77568062 /*transient*/ private Point centerPt;
77578063 /*transient*/ private int startX;