Normand Briere
2019-07-19 e79247ef52a0bbb3864d46bb1e2c716005b3ecf3
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 }
....@@ -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 }
....@@ -2919,11 +3104,20 @@
29193104 }
29203105 }
29213106
3107
+ void GenNormalsMesh0()
3108
+ {
3109
+ if (bRep != null)
3110
+ {
3111
+ bRep.GenerateNormalsMesh();
3112
+ Touch();
3113
+ }
3114
+ }
3115
+
29223116 void GenNormalsMINE0()
29233117 {
29243118 if (bRep != null)
29253119 {
2926
- bRep.GenerateNormalsMINE();
3120
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29273121 Touch();
29283122 }
29293123 }
....@@ -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;
....@@ -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,12 +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
53305745 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
+ }
53315757
53325758 void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53335759 {
....@@ -5339,7 +5765,7 @@
53395765 }
53405766
53415767 if (display.DrawMode() == iCameraPane.SELECTION &&
5342
- hide)
5768
+ (hide || dontselect))
53435769 return;
53445770
53455771 if (name != null && name.contains("sclera"))
....@@ -5371,7 +5797,7 @@
53715797 return;
53725798 }
53735799
5374
- javax.media.opengl.GL gl = display.GetGL();
5800
+ //javax.media.opengl.GL gl = display.GetGL();
53755801
53765802 /*
53775803 if (touched)
....@@ -5390,7 +5816,7 @@
53905816 support = support;
53915817
53925818 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5393
- 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);
53945820
53955821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53965822 {
....@@ -5410,10 +5836,12 @@
54105836 boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
54115837
54125838 if (!selectmode && //display.DrawMode() != display.SELECTION &&
5413
- (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)))
54145841 {
54155842 Globals.lighttouched = true;
54165843 } // all panes...
5844
+
54175845 //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
54185846 if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
54195847 (touched || (bRep != null && bRep.displaylist <= 0)))
....@@ -5423,7 +5851,7 @@
54235851 //if (displaylist == -1 && usecalllists)
54245852 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54255853 {
5426
- bRep.displaylist = gl.glGenLists(1);
5854
+ bRep.displaylist = display.GenList();
54275855 assert(bRep.displaylist != 0);
54285856 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54295857 //System.out.println("\tgen list " + list);
....@@ -5435,14 +5863,16 @@
54355863 if (usecalllists)
54365864 {
54375865 // System.err.println("new list " + bRep.displaylist + " for " + this);
5438
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5866
+ display.NewList(bRep.displaylist);
54395867 }
5868
+
54405869 CallList(display, root, selected, blocked);
5870
+
54415871 // compiled = true;
54425872 if (usecalllists)
54435873 {
54445874 // System.err.println("end list " + bRep.displaylist + " for " + this);
5445
- gl.glEndList();
5875
+ display.EndList();
54465876 }
54475877 //gl.glDrawBuffer(gl.GL_BACK);
54485878 // XXX touched = false;
....@@ -5490,7 +5920,7 @@
54905920 if (display.DrawMode() == iCameraPane.SHADOW)
54915921 {
54925922 if (!link2master // tricky to cull in shadow mode.
5493
- && GetBRep().FrustumCull(this, gl, display.LightCamera(), true))
5923
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54945924 {
54955925 //System.out.print("CULLED");
54965926 culled = true;
....@@ -5498,7 +5928,7 @@
54985928 }
54995929 else
55005930 //GetBRep().getBounds(v0, v1, this);
5501
- if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false))
5931
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
55025932 culled = true;
55035933
55045934 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5538,7 +5968,8 @@
55385968 {
55395969 if (GetBRep() != null)
55405970 {
5541
- CameraPane.NextIndex(this, gl);
5971
+ display.NextIndex();
5972
+
55425973 // vertex color conflict : gl.glCallList(list);
55435974 DrawNode(display, root, selected);
55445975 if (this instanceof BezierPatch)
....@@ -5579,7 +6010,28 @@
55796010 tex = GetTextures();
55806011 }
55816012
5582
- 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
+ }
55836035
55846036 if (!compiled)
55856037 {
....@@ -5595,13 +6047,17 @@
55956047
55966048 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55976049 assert(bRep.displaylist != 0);
5598
- gl.glCallList(bRep.displaylist);
6050
+ display.CallList(bRep.displaylist);
55996051 // june 2013 drawSelf(display, root, selected);
56006052 }
56016053 }
56026054 }
56036055
5604
- display.ReleaseTextures(tex);
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
56056061
56066062 display.PopMaterial(this, selected);
56076063 }
....@@ -5730,6 +6186,9 @@
57306186
57316187 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57326188 {
6189
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6190
+ return;
6191
+
57336192 if (hide)
57346193 return;
57356194 // shadow optimisation
....@@ -5855,6 +6314,9 @@
58556314 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58566315 return; // no shadow for transparent objects
58576316
6317
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
+ return;
6319
+
58586320 if (hide)
58596321 return;
58606322
....@@ -5895,9 +6357,10 @@
58956357 return;
58966358 }
58976359
6360
+ //bRep.GenUV(1/material.diffuseness);
58986361 // bRep.lock = true;
58996362
5900
- javax.media.opengl.GL gl = display.GetGL();
6363
+ //javax.media.opengl.GL gl = display.GetGL();
59016364
59026365 if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59036366 {
....@@ -5914,23 +6377,7 @@
59146377
59156378 bRep.getMinMax(min, max, 100);
59166379
5917
- gl.glBegin(gl.GL_LINES);
5918
-
5919
- gl.glVertex3d(min.x, min.y, min.z);
5920
- gl.glVertex3d(min.x, min.y, max.z);
5921
- gl.glVertex3d(min.x, min.y, min.z);
5922
- gl.glVertex3d(min.x, max.y, min.z);
5923
- gl.glVertex3d(min.x, min.y, min.z);
5924
- gl.glVertex3d(max.x, min.y, min.z);
5925
-
5926
- gl.glVertex3d(max.x, max.y, max.z);
5927
- gl.glVertex3d(min.x, max.y, max.z);
5928
- gl.glVertex3d(max.x, max.y, max.z);
5929
- gl.glVertex3d(max.x, min.y, max.z);
5930
- gl.glVertex3d(max.x, max.y, max.z);
5931
- gl.glVertex3d(max.x, max.y, min.z);
5932
-
5933
- gl.glEnd();
6380
+ display.DrawBox(min, max);
59346381
59356382 return;
59366383 }
....@@ -5984,178 +6431,19 @@
59846431 new Exception().printStackTrace();
59856432 return;
59866433 }
5987
-
5988
- // TRIANGLE STRIP ARRAY
5989
- if (bRep.trimmed)
6434
+
6435
+ if (dontselect)
59906436 {
5991
- float[] v = bRep.getRawVertices();
5992
- float[] n = bRep.getRawNormals();
5993
- float[] c = bRep.getRawColors();
5994
- float[] uv = bRep.getRawUVMap();
5995
-
5996
- int count2 = 0;
5997
- int count3 = 0;
5998
-
5999
- if (n.length > 0)
6000
- {
6001
- for (int i = 0; i < strips.length; i++)
6002
- {
6003
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6004
-
6005
- /*
6006
- boolean locked = false;
6007
- float eps = 0.1f;
6008
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6009
-
6010
- int dot = 0;
6011
-
6012
- if ((dot&1) == 0)
6013
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6014
-
6015
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6016
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6017
- else
6018
- {
6019
- locked = true;
6020
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6021
- }
6022
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6023
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6024
- if (hasnorm)
6025
- {
6026
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6027
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6028
- }
6029
-
6030
- if ((dot&4) == 0)
6031
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6032
-
6033
- if (wrap || !locked && (dot&8) != 0)
6034
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6035
- else
6036
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6037
-
6038
- f.dot = dot;
6039
- */
6040
-
6041
- if (!selectmode)
6042
- {
6043
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6044
- {
6045
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6046
- } else
6047
- {
6048
- gl.glNormal3f(0, 0, 1);
6049
- }
6050
-
6051
- if (c != null)
6052
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6053
- {
6054
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6055
- }
6056
- }
6057
- if (flipV)
6058
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6059
- else
6060
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6061
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6062
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6063
-
6064
- count2 += 2;
6065
- count3 += 3;
6066
- if (!selectmode)
6067
- {
6068
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6069
- {
6070
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6071
- } else
6072
- {
6073
- gl.glNormal3f(0, 0, 1);
6074
- }
6075
- if (c != null)
6076
- {
6077
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6078
- }
6079
- }
6080
- if (flipV)
6081
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6082
- else
6083
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6084
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6085
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6086
-
6087
- count2 += 2;
6088
- count3 += 3;
6089
- for (int j = 0; j < strips[i] - 2; j++)
6090
- {
6091
- //gl.glTexCoord2d(...);
6092
- if (!selectmode)
6093
- {
6094
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6095
- {
6096
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6097
- } else
6098
- {
6099
- gl.glNormal3f(0, 0, 1);
6100
- }
6101
- if (c != null)
6102
- {
6103
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6104
- }
6105
- }
6106
-
6107
- if (flipV)
6108
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6109
- else
6110
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6111
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6112
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6113
- count2 += 2;
6114
- count3 += 3;
6115
- }
6116
-
6117
- gl.glEnd();
6118
- }
6119
- }
6120
-
6121
- assert count3 == v.length;
6437
+ //bRep.GenerateNormalsMINE();
61226438 }
6123
- else // !trimmed
6124
- {
6125
- int count = 0;
6126
- for (int i = 0; i < strips.length; i++)
6127
- {
6128
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6129
-
6130
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6131
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6132
-
6133
- drawVertex(gl, p, selectmode);
6134
- drawVertex(gl, q, selectmode);
6135
-
6136
- for (int j = 0; j < strips[i] - 2; j++)
6137
- {
6138
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6139
-
6140
-// if (j%2 == 0)
6141
-// drawFace(p, q, r, display, null);
6142
-// else
6143
-// drawFace(p, r, q, display, null);
6144
-
6145
-// p = q;
6146
-// q = r;
6147
- drawVertex(gl, r, selectmode);
6148
- }
6149
-
6150
- gl.glEnd();
6151
- }
6152
- }
6439
+
6440
+ display.DrawGeometry(bRep, flipV, selectmode);
61536441 } else // catch (Error e)
61546442 {
61556443 // TRIANGLE ARRAY
61566444 if (IsOpaque()) // Static())
61576445 {
6158
- gl.glBegin(gl.GL_TRIANGLES);
6446
+ display.StartTriangles();
61596447 int facecount = bRep.FaceCount();
61606448 for (int i = 0; i < facecount; i++)
61616449 {
....@@ -6220,7 +6508,7 @@
62206508
62216509 display.DrawFace(this, p, q, r, face);
62226510 }
6223
- gl.glEnd();
6511
+ display.EndTriangles();
62246512 }
62256513 else
62266514 {
....@@ -6249,8 +6537,8 @@
62496537 //System.out.println("SORT");
62506538
62516539 java.util.Arrays.sort(facescompare);
6252
-
6253
- gl.glBegin(gl.GL_TRIANGLES);
6540
+
6541
+ display.StartTriangles();
62546542 for (int i = 0; i < facecount; i++)
62556543 {
62566544 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6264,11 +6552,12 @@
62646552
62656553 display.DrawFace(this, p, q, r, face);
62666554 }
6267
- gl.glEnd();
6555
+ display.EndTriangles();
62686556 }
62696557
62706558 if (false) // live && support != null && support.bRep != null) // debug weights
62716559 {
6560
+ /*
62726561 gl.glDisable(gl.GL_LIGHTING);
62736562 float[] colorV = new float[3];
62746563
....@@ -6347,6 +6636,7 @@
63476636 // gl.glEnd();
63486637 }
63496638 }
6639
+ */
63506640 }
63516641 }
63526642
....@@ -6391,7 +6681,7 @@
63916681 center.add(r);
63926682 center.mul(1.0/3);
63936683
6394
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6684
+ center.sub(Globals.theRenderer.EyeCamera().location);
63956685
63966686 distance = center.dot(center);
63976687 }
....@@ -6405,22 +6695,6 @@
64056695 void Print(Vertex v)
64066696 {
64076697 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
6408
- }
6409
-
6410
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6411
- {
6412
- if (!selectmode)
6413
- {
6414
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6415
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6416
-
6417
- if (flipV)
6418
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6419
- else
6420
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6421
- }
6422
-
6423
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
64246698 }
64256699
64266700 void drawSelf(ClickInfo info, int level, boolean select)
....@@ -7013,7 +7287,7 @@
70137287 spot.translate(32, 32);
70147288 spotw = spot.x + spot.width;
70157289 spoth = spot.y + spot.height;
7016
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
70177291 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
70187292 // if (CameraPane.Xmin > spot.x)
70197293 // {
....@@ -7031,11 +7305,12 @@
70317305 // {
70327306 // CameraPane.Ymax = spoth;
70337307 // }
7034
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7035
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
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
70367310 spot.translate(0, -32);
7037
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
70387312 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7313
+ info.g.setColor(Color.green);
70397314 // if (CameraPane.Xmin > spot.x)
70407315 // {
70417316 // CameraPane.Xmin = spot.x;
....@@ -7052,8 +7327,8 @@
70527327 // {
70537328 // CameraPane.Ymax = spoth;
70547329 // }
7055
- info.g.drawArc(boundary.x, boundary.y,
7056
- boundary.width, boundary.height, 0, 360);
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);
70577332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
70587333 // if (CameraPane.Xmin > boundary.x)
70597334 // {
....@@ -7087,7 +7362,7 @@
70877362 startX = info.x;
70887363 startY = info.y;
70897364
7090
- hitSomething = 0;
7365
+ hitSomething = -1;
70917366 cVector origin = new cVector();
70927367 //LA.xformPos(origin, toParent, origin);
70937368 Rectangle spot = new Rectangle();
....@@ -7120,7 +7395,7 @@
71207395 }
71217396
71227397 //System.out.println("info.modifiers = " + info.modifiers);
7123
- modified = (info.modifiers & CameraPane.META) != 0;
7398
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
71247399 //System.out.println("modified = " + modified);
71257400 //new Exception().printStackTrace();
71267401 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7148,7 +7423,7 @@
71487423 return true;
71497424 }
71507425
7151
- void doEditDrag0(ClickInfo info)
7426
+ void doEditDrag0(ClickInfo info, boolean opposite)
71527427 {
71537428 if (hitSomething == 0)
71547429 {
....@@ -7163,6 +7438,7 @@
71637438 //System.out.println("hitSomething = " + hitSomething);
71647439
71657440 double scale = 0.005f * info.camera.Distance();
7441
+
71667442 cVector xlate = new cVector();
71677443 //cVector xlate2 = new cVector();
71687444 switch (hitSomething)
....@@ -7173,9 +7449,9 @@
71737449
71747450 case hitCenter: // Translate
71757451
7176
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7452
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
71777453
7178
- if (modified)
7454
+ if (modified || opposite)
71797455 {
71807456 //assert(false);
71817457 /*
....@@ -7221,10 +7497,10 @@
72217497 }
72227498 LA.xformDir(up, ClickInfo.matbuffer, up);
72237499 // if (!CameraPane.LOCALTRANSFORM)
7224
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7500
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
72257501 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
72267502 // if (!CameraPane.LOCALTRANSFORM)
7227
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7503
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
72287504 //LA.vecCross(up, cVector.Z, right2);
72297505
72307506 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7269,6 +7545,7 @@
72697545
72707546 if (modified)
72717547 {
7548
+ // Rotate 90 degrees
72727549 angle /= (Math.PI / 4);
72737550 angle = Math.floor(angle + 0.5);
72747551 angle *= (Math.PI / 4);
....@@ -7282,7 +7559,7 @@
72827559 }
72837560 /**/
72847561
7285
- switch (info.pane.renderCamera.viewCode)
7562
+ switch (info.pane.RenderCamera().viewCode)
72867563 {
72877564 case 1: // '\001'
72887565 LA.matZRotate(toParent, angle);
....@@ -7310,24 +7587,27 @@
73107587
73117588 case hitScale: // scale
73127589 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);
73137596 if (hScale < 0.01)
73147597 {
7315
- hScale = 0.01;
7598
+ //hScale = 0.01;
73167599 }
7317
- hScale = Math.pow(hScale, scale * 50);
7318
- if (hScale < 0.01)
7319
- {
7320
- hScale = 0.01;
7321
- }
7600
+
73227601 double vScale = (double) (info.y - centerPt.y) / 32;
7323
- if (vScale < 0.01)
7602
+ sign = 1;
7603
+ if (vScale < 0)
73247604 {
7325
- vScale = 0.01;
7605
+ sign = -1;
73267606 }
7327
- vScale = Math.pow(vScale, scale * 50);
7607
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
73287608 if (vScale < 0.01)
73297609 {
7330
- vScale = 0.01;
7610
+ //vScale = 0.01;
73317611 }
73327612 LA.matCopy(startMat, toParent);
73337613 /**/
....@@ -7338,39 +7618,47 @@
73387618 }
73397619 /**/
73407620
7341
- 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)
73427629 {
73437630 case 3: // '\001'
7344
- if (modified)
7631
+ if (modified || opposite)
73457632 {
73467633 //LA.matScale(toParent, 1, hScale, vScale);
7347
- LA.matScale(toParent, vScale, 1, 1);
7634
+ LA.matScale(toParent, totalScale, 1, 1);
73487635 } // vScale, 1);
73497636 else
73507637 {
7351
- LA.matScale(toParent, vScale, vScale, vScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
73527640 } // vScale, 1);
73537641 break;
73547642
73557643 case 2: // '\002'
7356
- if (modified)
7644
+ if (modified || opposite)
73577645 {
73587646 //LA.matScale(toParent, hScale, 1, vScale);
7359
- LA.matScale(toParent, 1, vScale, 1);
7647
+ LA.matScale(toParent, 1, totalScale, 1);
73607648 } else
73617649 {
7362
- LA.matScale(toParent, vScale, 1, vScale);
7650
+ LA.matScale(toParent, totalScale, 1, totalScale);
73637651 }
73647652 break;
73657653
73667654 case 1: // '\003'
7367
- if (modified)
7655
+ if (modified || opposite)
73687656 {
73697657 //LA.matScale(toParent, hScale, vScale, 1);
7370
- LA.matScale(toParent, 1, 1, vScale);
7658
+ LA.matScale(toParent, 1, 1, totalScale);
73717659 } else
73727660 {
7373
- LA.matScale(toParent, vScale, vScale, 1);
7661
+ LA.matScale(toParent, totalScale, totalScale, 1);
73747662 }
73757663 break;
73767664 }
....@@ -7503,14 +7791,22 @@
75037791 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
75047792 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
75057793 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7794
+
7795
+ String objname;
7796
+
75067797 if (false) //parent != null)
75077798 {
7508
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7799
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
75097800 } else
75107801 {
7511
- 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) ":"") */ "";
75127803 } // + super.toString();
75137804 //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);
75147810 }
75157811
75167812 public int hashCode()
....@@ -7566,6 +7862,7 @@
75667862 objectUI.closeUI();
75677863 if (editWindow != null)
75687864 {
7865
+ editWindow.ctrlPanel.FlushUI();
75697866 editWindow.refreshContents();
75707867 } // ? new
75717868 objectUI = null;
....@@ -7574,6 +7871,10 @@
75747871 {
75757872 editWindow = null;
75767873 } // ?
7874
+ }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
75777878 }
75787879 }
75797880
....@@ -7586,7 +7887,7 @@
75867887 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
75877888
75887889 Object3D /*Composite*/ parent;
7589
- Object3D /*Composite*/ fileparent;
7890
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
75907891
75917892 double[][] toParent; // dynamic matrix
75927893 double[][] fromParent;
....@@ -7701,7 +8002,7 @@
77018002 {
77028003 assert(bRep != null);
77038004 if (!(support instanceof GenericJoint)) // support.bRep != null)
7704
- GrafreeD.Assert(support.bRep == bRep.support);
8005
+ Grafreed.Assert(support.bRep == bRep.support);
77058006 }
77068007 else
77078008 {
....@@ -7732,6 +8033,10 @@
77328033 }
77338034
77348035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
77358040 transient ObjectUI objectUI;
77368041 public static int povDepth = 0;
77378042 private static cVector tbMin = new cVector();
....@@ -7750,9 +8055,9 @@
77508055 private static cVector edge2 = new cVector();
77518056 //private static cVector norm = new cVector();
77528057 /*transient private*/ int hitSomething;
7753
- private static final int hitCenter = 1;
7754
- private static final int hitScale = 2;
7755
- private static final int hitRotate = 3;
8058
+ static final int hitCenter = 1;
8059
+ static final int hitScale = 2;
8060
+ static final int hitRotate = 3;
77568061 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
77578062 /*transient*/ private Point centerPt;
77588063 /*transient*/ private int startX;