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,13 +14,38 @@
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;
36
+
37
+ void InitOthers()
38
+ {
39
+ if (projectedVertices == null || projectedVertices.length <= 2)
40
+ {
41
+ projectedVertices = new Object3D.cVector2[3];
42
+ }
43
+ for (int i = 0; i < 3; i++)
44
+ {
45
+ projectedVertices[i] = new cVector2(); // Others
46
+ }
47
+ projectedVertices[0].x = 100; // bump
48
+ }
2349
2450 void MinMax(cVector minima, cVector maxima)
2551 {
....@@ -86,64 +112,178 @@
86112
87113 // transient boolean reduced; // for morph reduction
88114
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-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
91117
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
94120
95
-void SaveSupports()
96
-{
97
- if (blockloop)
98
- return;
99
-
100
- transientsupport = support;
101
- transientlink2master = link2master;
102
-
103
- support = null;
104
- link2master = false;
105
-
106
- if (bRep != null)
121
+ void SaveSupports()
107122 {
108
- 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
+ }
109146 }
110
-
111
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
112149 {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- 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
+
116258 blockloop = true;
117
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
118267 blockloop = false;
119268 }
120
-}
121269
122
-void RestoreSupports()
123
-{
124
- if (blockloop)
125
- return;
126
-
127
- support = transientsupport;
128
- link2master = transientlink2master;
129
- transientsupport = null;
130
- transientlink2master = false;
131
-
132
- if (bRep != null)
270
+ void RestoreBigData(Object3D o)
133271 {
134
- 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;
135286 }
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.RestoreSupports();
144
- blockloop = false;
145
- }
146
-}
147287
148288 // MOCAP SUPPORT
149289 double tx,ty,tz,rx,ry,rz;
....@@ -285,8 +425,8 @@
285425 return parent.GetName() + "#";
286426 }
287427
288
- boolean timeline = false;
289428 boolean live = false;
429
+ boolean dontselect = false;
290430 boolean hide = false;
291431 boolean link2master = false; // performs reset support/master at each frame
292432 boolean marked = false; // animation node
....@@ -296,6 +436,8 @@
296436 boolean random = false;
297437 boolean speedup = false;
298438 boolean rewind = false;
439
+
440
+ float NORMALPUSH = 0;
299441
300442 Object3D support;
301443
....@@ -416,16 +558,16 @@
416558 {
417559 Object3D copy = this;
418560
419
- Camera parentcam = CameraPane.theRenderer.manipCamera;
561
+ Camera parentcam = Globals.theRenderer.ManipCamera();
420562
421
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
563
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
422564 {
423
- parentcam = CameraPane.theRenderer.cameras[1];
565
+ parentcam = Globals.theRenderer.Cameras()[1];
424566 }
425567
426
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
568
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
427569 {
428
- parentcam = CameraPane.theRenderer.cameras[0];
570
+ parentcam = Globals.theRenderer.Cameras()[0];
429571 }
430572
431573 if (this == parentcam)
....@@ -433,7 +575,7 @@
433575 //assert(this instanceof Camera);
434576
435577 for (int count = parentcam.GetTransformCount(); --count>=0;)
436
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
578
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
437579 }
438580
439581 copy.marked ^= true;
....@@ -453,7 +595,7 @@
453595 //assert(this instanceof Camera);
454596
455597 for (int count = parentcam.GetTransformCount(); --count>=0;)
456
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
598
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
457599 }
458600
459601 copy.Touch(); // display list issue
....@@ -466,12 +608,14 @@
466608 toParent = LA.newMatrix();
467609 fromParent = LA.newMatrix();
468610 }
611
+
469612 if (toParentMarked == null)
470613 {
471614 if (maxcount != 1)
472615 {
473616 new Exception().printStackTrace();
474617 }
618
+
475619 toParentMarked = LA.newMatrix();
476620 fromParentMarked = LA.newMatrix();
477621 }
....@@ -588,7 +732,7 @@
588732 return;
589733 }
590734
591
- if (CameraPane.fromscript)
735
+ if (Globals.fromscript)
592736 {
593737 transformcount = 0;
594738 return;
....@@ -746,7 +890,7 @@
746890
747891 int GetTransformCount()
748892 {
749
- // marde pour serialization de Texture
893
+ // patch pour serialization de Texture
750894 resetmaxcount();
751895 resettransformcount();
752896 resetstep();
....@@ -759,7 +903,7 @@
759903 if (step == 0)
760904 step = 1;
761905 if (maxcount == 0)
762
- maxcount = 2048; // 4;
906
+ maxcount = 128; // 2048; // 4;
763907 // if (acceleration == 0)
764908 // acceleration = 10;
765909 if (delay == 0) // serial
....@@ -780,9 +924,12 @@
780924 // factor = CameraPane.STEP;
781925 // }
782926
783
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
927
+ if (marked && Globals.isLIVE() && live &&
928
+ //TEMP21aug2018
929
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
930
+ currentframe != Globals.framecount)
784931 {
785
- currentframe = CameraPane.framecount;
932
+ currentframe = Globals.framecount;
786933
787934 // System.err.println("transformcount = " + transformcount);
788935 // System.err.println("factor = " + factor);
....@@ -791,7 +938,8 @@
791938
792939 boolean changedir = random && Math.random() < 0.01; // && !link2master;
793940
794
- if (transformcount*factor > maxcount || (step == 1 && changedir))
941
+ if (transformcount*factor >= maxcount && (rewind || random) ||
942
+ (step == 1 && changedir))
795943 {
796944 countdown = 1;
797945 delay = speedup?8:1;
....@@ -863,6 +1011,7 @@
8631011 if (material == null || material.multiply)
8641012 return true;
8651013
1014
+ // Transparent objects are dynamic because we have to sort the triangles.
8661015 return material.opacity > 0.99;
8671016 }
8681017
....@@ -894,6 +1043,11 @@
8941043 fromParent = null; // LA.newMatrix();
8951044 bRep = null; // new BoundaryRep();
8961045
1046
+ if (oname != null && oname.equals("LeftHand"))
1047
+ {
1048
+ name = oname;
1049
+ }
1050
+
8971051 /*
8981052 float hue = (float)Math.random();
8991053 Color col;
....@@ -936,7 +1090,7 @@
9361090
9371091 public Object clone()
9381092 {
939
- return GrafreeD.clone(this);
1093
+ return Grafreed.clone(this);
9401094 }
9411095
9421096 Object3D copyExpand()
....@@ -1258,6 +1412,7 @@
12581412 toParent = LA.newMatrix();
12591413 fromParent = LA.newMatrix();
12601414 }
1415
+
12611416 LA.matCopy(other.toParent, toParent);
12621417 LA.matCopy(other.fromParent, fromParent);
12631418
....@@ -1452,7 +1607,7 @@
14521607 BoundaryRep.SEUIL = other.material.cameralight;
14531608
14541609 // Set default to 0.1
1455
- BoundaryRep.SEUIL /= 2;
1610
+ BoundaryRep.SEUIL /= 4; // 2;
14561611 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14571612 }
14581613
....@@ -1711,7 +1866,7 @@
17111866 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17121867 o.bRep = transientrep;
17131868 if (clone)
1714
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1869
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17151870 o.CreateMaterial();
17161871 o.SetAttributes(this, -1);
17171872 //parent
....@@ -1724,7 +1879,7 @@
17241879 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17251880 o.bRep = bRep;
17261881 if (clone)
1727
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1882
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17281883 o.CreateMaterial();
17291884 //o.overwriteThis(this, -1);
17301885 o.SetAttributes(this, -1);
....@@ -1811,12 +1966,15 @@
18111966 if (obj.name == null)
18121967 continue; // can't be a null one
18131968
1969
+ // Try perfect match first.
18141970 if (n.equals(obj.name))
18151971 {
18161972 theobj = obj;
18171973 count++;
18181974 }
18191975 }
1976
+
1977
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18201978
18211979 if (count != 1)
18221980 for (int i=Size(); --i>=0;)
....@@ -2131,15 +2289,8 @@
21312289 if (/*parent != null &&*/ material == null)
21322290 {
21332291 material = new cMaterial(GetMaterial());
2134
- if (projectedVertices == null || projectedVertices.length <= 2)
2135
- {
2136
- projectedVertices = new Object3D.cVector2[3];
2137
- }
2138
- for (int i = 0; i < 3; i++)
2139
- {
2140
- projectedVertices[i] = new cVector2(); // Others
2141
- }
2142
- projectedVertices[0].x = 100; // bump
2292
+
2293
+ InitOthers();
21432294
21442295 if (this instanceof Camera)
21452296 {
....@@ -2283,12 +2434,17 @@
22832434 }
22842435 */
22852436 }
2437
+ else
2438
+ {
2439
+ //((ObjEditor)editWindow).SetupUI2(null);
2440
+ }
22862441 }
22872442
22882443 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22892444 {
22902445 if (newWindow)
22912446 {
2447
+ new Exception().printStackTrace();
22922448 System.exit(0);
22932449 if (parent != null)
22942450 {
....@@ -2323,6 +2479,14 @@
23232479 {
23242480 editWindow.refreshContents();
23252481 }
2482
+ else
2483
+ {
2484
+ if (manipWindow != null)
2485
+ {
2486
+ manipWindow.refreshContents();
2487
+ }
2488
+ }
2489
+
23262490 //if (parent != null)
23272491 //parent.refreshEditWindow();
23282492 }
....@@ -2465,13 +2629,13 @@
24652629 return retval;
24662630 }
24672631
2468
- void doEditDrag(ClickInfo info)
2632
+ void doEditDrag(ClickInfo info, boolean opposite)
24692633 {
24702634 switch (doSomething)
24712635 {
24722636 case 1: // '\001'
24732637 //super.
2474
- doEditDrag0(info);
2638
+ doEditDrag0(info, opposite);
24752639 break;
24762640
24772641 case 2: // '\002'
....@@ -2484,11 +2648,11 @@
24842648 {
24852649 //sel.hitSomething = childToDrag.hitSomething;
24862650 //childToDrag.doEditDrag(info);
2487
- sel.doEditDrag(info);
2651
+ sel.doEditDrag(info, opposite);
24882652 } else
24892653 {
24902654 //super.
2491
- doEditDrag0(info);
2655
+ doEditDrag0(info, opposite);
24922656 }
24932657 }
24942658 break;
....@@ -2598,6 +2762,18 @@
25982762 void GenNormalsS(boolean crease)
25992763 {
26002764 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();
26012777 // for (int i=0; i<selection.size(); i++)
26022778 // {
26032779 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2738,6 +2914,24 @@
27382914 if (child == null)
27392915 continue;
27402916 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();
27412935 // Children().release(i);
27422936 }
27432937 blockloop = false;
....@@ -2895,7 +3089,8 @@
28953089 {
28963090 if (bRep != null)
28973091 {
2898
- bRep.GenUV();
3092
+ bRep.GenUV(); //1);
3093
+ //bRep.UnfoldUV();
28993094 Touch();
29003095 }
29013096 }
....@@ -2905,6 +3100,15 @@
29053100 if (bRep != null)
29063101 {
29073102 bRep.GenerateNormals(crease);
3103
+ Touch();
3104
+ }
3105
+ }
3106
+
3107
+ void GenNormalsMesh0()
3108
+ {
3109
+ if (bRep != null)
3110
+ {
3111
+ bRep.GenerateNormalsMesh();
29083112 Touch();
29093113 }
29103114 }
....@@ -2970,6 +3174,33 @@
29703174 blockloop = false;
29713175 }
29723176
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
+
29733204 void TransformGeometry()
29743205 {
29753206 Object3D obj = this;
....@@ -3191,9 +3422,11 @@
31913422
31923423 BoundaryRep sup = bRep.support;
31933424 bRep.support = null;
3194
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3425
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31953426 // bRep.SplitInTwo(onlyone); // thread...
3196
- temprep.SplitInTwo(reduction34, onlyone);
3427
+
3428
+ while(temprep.SplitInTwo(reduction34, onlyone));
3429
+
31973430 bRep = temprep;
31983431 bRep.support = sup;
31993432 Touch();
....@@ -3330,7 +3563,8 @@
33303563 if (blockloop)
33313564 return;
33323565
3333
- if (marked || (bRep != null && material != null)) // borderline...
3566
+ if (//marked || // does not make sense
3567
+ (bRep != null || material != null)) // borderline...
33343568 live = h;
33353569
33363570 for (int i = 0; i < Size(); i++)
....@@ -3351,7 +3585,8 @@
33513585 return;
33523586
33533587 //if (bRep != null)
3354
- if (marked || (bRep != null && material != null)) // borderline...
3588
+ if (//marked || // does not make sense
3589
+ (bRep != null || material != null)) // borderline...
33553590 link2master = h;
33563591
33573592 for (int i = 0; i < Size(); i++)
....@@ -3371,7 +3606,8 @@
33713606 if (blockloop)
33723607 return;
33733608
3374
- if (marked || (bRep != null && material != null)) // borderline...
3609
+ if (//marked || // does not make sense
3610
+ (bRep != null || material != null)) // borderline...
33753611 hide = h;
33763612
33773613 for (int i = 0; i < Size(); i++)
....@@ -3391,7 +3627,7 @@
33913627 if (blockloop)
33923628 return;
33933629
3394
- if (bRep != null && material != null) // borderline...
3630
+ if (bRep != null || material != null) // borderline...
33953631 marked = h;
33963632
33973633 for (int i = 0; i < Size(); i++)
....@@ -3401,6 +3637,46 @@
34013637 continue;
34023638 blockloop = true;
34033639 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);
34043680 blockloop = false;
34053681 // release(i);
34063682 }
....@@ -3715,7 +3991,7 @@
37153991 if (child == null)
37163992 continue;
37173993
3718
- if (GrafreeD.RENDERME > 0)
3994
+ if (Grafreed.RENDERME > 0)
37193995 {
37203996 if (child instanceof Merge)
37213997 ((Merge)child).renderme();
....@@ -3866,7 +4142,7 @@
38664142 if (child == null)
38674143 continue;
38684144
3869
- if (GrafreeD.RENDERME > 0)
4145
+ if (Grafreed.RENDERME > 0)
38704146 {
38714147 if (child instanceof Merge)
38724148 ((Merge)child).renderme();
....@@ -4061,7 +4337,7 @@
40614337 if (child == null)
40624338 continue;
40634339
4064
- if (GrafreeD.RENDERME > 0)
4340
+ if (Grafreed.RENDERME > 0)
40654341 {
40664342 if (child instanceof Merge)
40674343 ((Merge)child).renderme();
....@@ -4158,6 +4434,71 @@
41584434 }
41594435 blockloop = true;
41604436 get(i).RepairParent();
4437
+ blockloop = false;
4438
+ }
4439
+ }
4440
+
4441
+ void RepairShadow()
4442
+ {
4443
+ if (blockloop)
4444
+ return;
4445
+
4446
+ if (this.material != null)
4447
+ this.InitOthers();
4448
+
4449
+ for (int i=0; i<Size(); i++)
4450
+ {
4451
+ blockloop = true;
4452
+ 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();
41614502 blockloop = false;
41624503 }
41634504 }
....@@ -4652,7 +4993,7 @@
46524993
46534994 cTreePath SelectLeaf(int indexcount, boolean deselect)
46544995 {
4655
- if (hide)
4996
+ if (hide || dontselect)
46564997 return null;
46574998
46584999 if (count <= 0)
....@@ -4676,9 +5017,17 @@
46765017 }
46775018 }
46785019
5020
+ ObjEditor GetWindow()
5021
+ {
5022
+ if (editWindow != null)
5023
+ return editWindow;
5024
+
5025
+ return manipWindow;
5026
+ }
5027
+
46795028 cTreePath Select(int indexcount, boolean deselect)
46805029 {
4681
- if (hide)
5030
+ if (hide || dontselect)
46825031 return null;
46835032
46845033 if (count <= 0)
....@@ -4712,10 +5061,11 @@
47125061 if (leaf != null)
47135062 {
47145063 cTreePath tp = new cTreePath(this, leaf);
4715
- if (editWindow != null)
5064
+ ObjEditor window = GetWindow();
5065
+ if (window != null)
47165066 {
47175067 //System.out.println("editWindow = " + editWindow + " vs " + this);
4718
- editWindow.Select(tp, deselect, true);
5068
+ window.Select(tp, deselect, true);
47195069 }
47205070
47215071 return tp;
....@@ -4732,6 +5082,7 @@
47325082
47335083 if (child == null)
47345084 continue;
5085
+
47355086 if (child.HasTransparency() && child.size() != 0)
47365087 {
47375088 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4741,9 +5092,10 @@
47415092 if (leaf != null)
47425093 {
47435094 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5095
+ ObjEditor window = GetWindow();
5096
+ if (window != null)
47455097 {
4746
- editWindow.Select(tp, deselect, true);
5098
+ window.Select(tp, deselect, true);
47475099 }
47485100
47495101 return tp;
....@@ -4828,7 +5180,7 @@
48285180 return globalTransform;
48295181 }
48305182
4831
- void PreprocessOcclusion(CameraPane cp)
5183
+ void PreprocessOcclusion(iCameraPane cp)
48325184 {
48335185 /*
48345186 if (AOdone)
....@@ -4975,7 +5327,8 @@
49755327 } else //
49765328 if (editWindow != null)
49775329 {
4978
- editWindow.cameraView.lighttouched = true;
5330
+ //editWindow.cameraView.lighttouched = true;
5331
+ Globals.lighttouched = true;
49795332 }
49805333 }
49815334
....@@ -5129,10 +5482,34 @@
51295482
51305483 // System.out.println("Fullname = " + fullname);
51315484
5132
- if (fullname.name.indexOf(":") == -1)
5133
- 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(":"));
51345490
5135
- 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];
51365513 }
51375514
51385515 static String GetBump(cTexture fullname)
....@@ -5141,10 +5518,38 @@
51415518 return "";
51425519
51435520 // System.out.println("Fullname = " + fullname);
5144
- if (fullname.name.indexOf(":") == -1)
5145
- return "";
5146
-
5147
- 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];
51485553 }
51495554
51505555 String GetPigmentTexture()
....@@ -5218,7 +5623,7 @@
52185623 System.out.print("; textures = " + textures);
52195624 System.out.println("; usedtextures = " + usedtextures);
52205625
5221
- if (GetTextures() == null)
5626
+ if (GetTextures() == null) // What is that??
52225627 GetTextures().name = ":";
52235628
52245629 String texname = tex;
....@@ -5249,6 +5654,43 @@
52495654 child.ResetPigmentTexture();
52505655 blockloop = false;
52515656 }
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;
52525694 }
52535695
52545696 void SetBumpTexture(String tex)
....@@ -5287,25 +5729,33 @@
52875729 }
52885730 }
52895731
5290
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5732
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52915733 {
52925734 Draw(display, root, selected, blocked);
52935735 }
52945736
5295
- static cMaterial[] materialstack = new cMaterial[65536];
5296
- static boolean[] selectedstack = new boolean[65536];
5297
- static int materialdepth = 0;
5298
-
52995737 boolean NeedSupport()
53005738 {
53015739 return
5302
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5740
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53035741 // PROBLEM with CROWD!!
5304
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5742
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53055743 }
53065744
5745
+ static boolean DEBUG_SELECTION = false;
53075746
5308
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5747
+ boolean IsLive()
5748
+ {
5749
+ if (live)
5750
+ return true;
5751
+
5752
+ if (parent == null)
5753
+ return false;
5754
+
5755
+ return parent.IsLive();
5756
+ }
5757
+
5758
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53095759 {
53105760 Invariants(); // june 2013
53115761
....@@ -5314,8 +5764,8 @@
53145764 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53155765 }
53165766
5317
- if (display.drawMode == CameraPane.SELECTION &&
5318
- hide)
5767
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5768
+ (hide || dontselect))
53195769 return;
53205770
53215771 if (name != null && name.contains("sclera"))
....@@ -5333,7 +5783,7 @@
53335783 if (this instanceof Checker)
53345784 return;
53355785
5336
- if (display.drawMode == display.SHADOW && PASSTEST)
5786
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53375787 return;
53385788
53395789 if (count <= 0)
....@@ -5341,13 +5791,13 @@
53415791 return;
53425792 }
53435793
5344
- if ((//display.drawMode == CameraPane.SHADOW ||
5345
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5794
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5795
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53465796 {
53475797 return;
53485798 }
53495799
5350
- javax.media.opengl.GL gl = display.GetGL();
5800
+ //javax.media.opengl.GL gl = display.GetGL();
53515801
53525802 /*
53535803 if (touched)
....@@ -5366,7 +5816,7 @@
53665816 support = support;
53675817
53685818 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5369
- 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);
53705820
53715821 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53725822 {
....@@ -5383,15 +5833,17 @@
53835833
53845834 boolean compiled = false;
53855835
5386
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5836
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53875837
5388
- if (!selectmode && //display.drawMode != display.SELECTION &&
5389
- (touched || (bRep != null && bRep.displaylist <= 0)))
5838
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5839
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5840
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
53905841 {
5391
- display.lighttouched = true;
5842
+ Globals.lighttouched = true;
53925843 } // all panes...
5393
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5394
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5844
+
5845
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5846
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53955847 (touched || (bRep != null && bRep.displaylist <= 0)))
53965848 {
53975849 if (!(this instanceof Composite))
....@@ -5399,7 +5851,7 @@
53995851 //if (displaylist == -1 && usecalllists)
54005852 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54015853 {
5402
- bRep.displaylist = gl.glGenLists(1);
5854
+ bRep.displaylist = display.GenList();
54035855 assert(bRep.displaylist != 0);
54045856 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54055857 //System.out.println("\tgen list " + list);
....@@ -5411,18 +5863,20 @@
54115863 if (usecalllists)
54125864 {
54135865 // System.err.println("new list " + bRep.displaylist + " for " + this);
5414
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5866
+ display.NewList(bRep.displaylist);
54155867 }
5868
+
54165869 CallList(display, root, selected, blocked);
5870
+
54175871 // compiled = true;
54185872 if (usecalllists)
54195873 {
54205874 // System.err.println("end list " + bRep.displaylist + " for " + this);
5421
- gl.glEndList();
5875
+ display.EndList();
54225876 }
54235877 //gl.glDrawBuffer(gl.GL_BACK);
54245878 // XXX touched = false;
5425
- display.lighttouched = true; // all panes...
5879
+ Globals.lighttouched = true; // all panes...
54265880 }
54275881
54285882 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5461,12 +5915,12 @@
54615915
54625916 // frustum culling
54635917 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5464
- && display.drawMode != CameraPane.SELECTION)
5918
+ && display.DrawMode() != iCameraPane.SELECTION)
54655919 {
5466
- if (display.drawMode == CameraPane.SHADOW)
5920
+ if (display.DrawMode() == iCameraPane.SHADOW)
54675921 {
54685922 if (!link2master // tricky to cull in shadow mode.
5469
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5923
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54705924 {
54715925 //System.out.print("CULLED");
54725926 culled = true;
....@@ -5474,7 +5928,7 @@
54745928 }
54755929 else
54765930 //GetBRep().getBounds(v0, v1, this);
5477
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5931
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54785932 culled = true;
54795933
54805934 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5510,11 +5964,12 @@
55105964
55115965
55125966 if (!culled)
5513
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5967
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55145968 {
55155969 if (GetBRep() != null)
55165970 {
5517
- CameraPane.NextIndex(this, gl);
5971
+ display.NextIndex();
5972
+
55185973 // vertex color conflict : gl.glCallList(list);
55195974 DrawNode(display, root, selected);
55205975 if (this instanceof BezierPatch)
....@@ -5536,55 +5991,7 @@
55365991 color[2] /= 2;
55375992 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55385993 */
5539
- if (material != null)
5540
- {
5541
- materialstack[materialdepth] = material;
5542
- selectedstack[materialdepth] = selected;
5543
- cStatic.objectstack[materialdepth++] = this;
5544
- //System.out.println("material " + material);
5545
- //Applet3D.tracein(this, selected);
5546
- display.vector2buffer = projectedVertices;
5547
- if (this instanceof Camera)
5548
- {
5549
- display.options1[0] = material.shift;
5550
- //System.out.println("shift " + material.shift);
5551
- display.options1[1] = material.lightarea;
5552
- display.options1[2] = material.shadowbias;
5553
- display.options1[3] = material.aniso;
5554
- display.options1[4] = material.anisoV;
5555
- display.options2[0] = material.opacity;
5556
- display.options2[1] = material.diffuse;
5557
- display.options2[2] = material.factor;
5558
-
5559
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5560
- display.options4[0] = material.cameralight/0.2f;
5561
- display.options4[1] = material.subsurface;
5562
- display.options4[2] = material.sheen;
5563
-
5564
- // if (display.CURRENTANTIALIAS > 0)
5565
- // display.options3[3] /= 4;
5566
-
5567
- /*
5568
- System.out.println("Focus = " + display.options1[0]);
5569
- System.out.println("Aperture = " + display.options1[1]);
5570
- System.out.println("ShadowBlur = " + display.options1[2]);
5571
- System.out.println("Antialiasing = " + display.options1[3]);
5572
- System.out.println("Fog = " + display.options2[0]);
5573
- System.out.println("Intensity = " + display.options2[1]);
5574
- System.out.println("Elevation = " + display.options2[2]);
5575
- /**/
5576
- } else
5577
- {
5578
- material.Draw(display, selected);
5579
- }
5580
- } else
5581
- {
5582
- if (selected && CameraPane.flash)
5583
- {
5584
- display.modelParams4[1] = 100;
5585
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5586
- }
5587
- }
5994
+ display.PushMaterial(this, selected);
55885995
55895996 //System.out.println("call list " + list);
55905997 //System.out.println();
....@@ -5603,7 +6010,28 @@
56036010 tex = GetTextures();
56046011 }
56056012
5606
- 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
+ }
56076035
56086036 if (!compiled)
56096037 {
....@@ -5619,30 +6047,19 @@
56196047
56206048 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56216049 assert(bRep.displaylist != 0);
5622
- gl.glCallList(bRep.displaylist);
6050
+ display.CallList(bRep.displaylist);
56236051 // june 2013 drawSelf(display, root, selected);
56246052 }
56256053 }
56266054 }
56276055
5628
- display.ReleaseTextures(tex);
5629
-
5630
- //if (parent != null && parent.GetMaterial() != null)
5631
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5632
- if (material != null)
5633
- {
5634
- materialdepth -= 1;
5635
- if (materialdepth > 0)
5636
- {
5637
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5638
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5639
- }
5640
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5641
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5642
- {
5643
- display.modelParams4[1] = GetMaterial().cameralight;
5644
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5645
- }
6056
+ if (!failedBump)
6057
+ display.ReleaseBumpTexture(tex);
6058
+
6059
+ if (!failedPigment)
6060
+ display.ReleasePigmentTexture(tex);
6061
+
6062
+ display.PopMaterial(this, selected);
56466063 }
56476064
56486065 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5684,7 +6101,7 @@
56846101 // resetMasterNode();
56856102 }
56866103
5687
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6104
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56886105 {
56896106 if (GetBRep() == null)
56906107 {
....@@ -5767,8 +6184,11 @@
57676184 boolean flipV = false; // true;
57686185 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57696186
5770
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6187
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57716188 {
6189
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6190
+ return;
6191
+
57726192 if (hide)
57736193 return;
57746194 // shadow optimisation
....@@ -5826,16 +6246,7 @@
58266246 // // ??????????????????????????? Touch();
58276247 // }
58286248
5829
- if (material != null)
5830
- {
5831
- materialstack[materialdepth] = material;
5832
- selectedstack[materialdepth] = selected;
5833
- cStatic.objectstack[materialdepth++] = this;
5834
- //System.out.println("material " + material);
5835
- //Applet3D.tracein("selected ", selected);
5836
- display.vector2buffer = projectedVertices;
5837
- material.Draw(display, selected);
5838
- }
6249
+display.PushMaterial2(this, selected);
58396250
58406251 Object3D child;
58416252 boolean sel;
....@@ -5887,19 +6298,7 @@
58876298 */
58886299 //depth += 1;
58896300
5890
- if (material != null)
5891
- {
5892
- materialdepth -= 1;
5893
- if (materialdepth > 0)
5894
- {
5895
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5896
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5897
- }
5898
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5899
- //else
5900
- //material.Draw(display, false);
5901
- }
5902
-
6301
+display.PopMaterial2(this);
59036302 /*
59046303 display.ReleaseTextures(tex);
59056304 */
....@@ -5910,10 +6309,13 @@
59106309
59116310 //static cVector min,max;
59126311
5913
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6312
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59146313 {
5915
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6314
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59166315 return; // no shadow for transparent objects
6316
+
6317
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6318
+ return;
59176319
59186320 if (hide)
59196321 return;
....@@ -5955,11 +6357,12 @@
59556357 return;
59566358 }
59576359
6360
+ //bRep.GenUV(1/material.diffuseness);
59586361 // bRep.lock = true;
59596362
5960
- javax.media.opengl.GL gl = display.GetGL();
6363
+ //javax.media.opengl.GL gl = display.GetGL();
59616364
5962
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6365
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59636366 {
59646367 int fc = bRep.FaceCount();
59656368 int vc = bRep.VertexCount();
....@@ -5974,23 +6377,7 @@
59746377
59756378 bRep.getMinMax(min, max, 100);
59766379
5977
- gl.glBegin(gl.GL_LINES);
5978
-
5979
- gl.glVertex3d(min.x, min.y, min.z);
5980
- gl.glVertex3d(min.x, min.y, max.z);
5981
- gl.glVertex3d(min.x, min.y, min.z);
5982
- gl.glVertex3d(min.x, max.y, min.z);
5983
- gl.glVertex3d(min.x, min.y, min.z);
5984
- gl.glVertex3d(max.x, min.y, min.z);
5985
-
5986
- gl.glVertex3d(max.x, max.y, max.z);
5987
- gl.glVertex3d(min.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, max.y, max.z);
5989
- gl.glVertex3d(max.x, min.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, max.z);
5991
- gl.glVertex3d(max.x, max.y, min.z);
5992
-
5993
- gl.glEnd();
6380
+ display.DrawBox(min, max);
59946381
59956382 return;
59966383 }
....@@ -6034,7 +6421,7 @@
60346421 {
60356422 //throw new Error();
60366423
6037
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6424
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60386425
60396426 int[] strips = bRep.getRawIndices();
60406427
....@@ -6044,178 +6431,19 @@
60446431 new Exception().printStackTrace();
60456432 return;
60466433 }
6047
-
6048
- // TRIANGLE STRIP ARRAY
6049
- if (bRep.trimmed)
6434
+
6435
+ if (dontselect)
60506436 {
6051
- float[] v = bRep.getRawVertices();
6052
- float[] n = bRep.getRawNormals();
6053
- float[] c = bRep.getRawColors();
6054
- float[] uv = bRep.getRawUVMap();
6055
-
6056
- int count2 = 0;
6057
- int count3 = 0;
6058
-
6059
- if (n.length > 0)
6060
- {
6061
- for (int i = 0; i < strips.length; i++)
6062
- {
6063
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6064
-
6065
- /*
6066
- boolean locked = false;
6067
- float eps = 0.1f;
6068
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6069
-
6070
- int dot = 0;
6071
-
6072
- if ((dot&1) == 0)
6073
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6074
-
6075
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6076
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6077
- else
6078
- {
6079
- locked = true;
6080
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6081
- }
6082
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6083
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6084
- if (hasnorm)
6085
- {
6086
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6087
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6088
- }
6089
-
6090
- if ((dot&4) == 0)
6091
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6092
-
6093
- if (wrap || !locked && (dot&8) != 0)
6094
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6095
- else
6096
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6097
-
6098
- f.dot = dot;
6099
- */
6100
-
6101
- if (!selectmode)
6102
- {
6103
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6104
- {
6105
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6106
- } else
6107
- {
6108
- gl.glNormal3f(0, 0, 1);
6109
- }
6110
-
6111
- if (c != null)
6112
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6113
- {
6114
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6115
- }
6116
- }
6117
- if (flipV)
6118
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6119
- else
6120
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6121
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6122
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6123
-
6124
- count2 += 2;
6125
- count3 += 3;
6126
- if (!selectmode)
6127
- {
6128
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6129
- {
6130
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6131
- } else
6132
- {
6133
- gl.glNormal3f(0, 0, 1);
6134
- }
6135
- if (c != null)
6136
- {
6137
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6138
- }
6139
- }
6140
- if (flipV)
6141
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6142
- else
6143
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6144
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6145
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6146
-
6147
- count2 += 2;
6148
- count3 += 3;
6149
- for (int j = 0; j < strips[i] - 2; j++)
6150
- {
6151
- //gl.glTexCoord2d(...);
6152
- if (!selectmode)
6153
- {
6154
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6155
- {
6156
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6157
- } else
6158
- {
6159
- gl.glNormal3f(0, 0, 1);
6160
- }
6161
- if (c != null)
6162
- {
6163
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6164
- }
6165
- }
6166
-
6167
- if (flipV)
6168
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6169
- else
6170
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6171
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6172
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6173
- count2 += 2;
6174
- count3 += 3;
6175
- }
6176
-
6177
- gl.glEnd();
6178
- }
6179
- }
6180
-
6181
- assert count3 == v.length;
6437
+ //bRep.GenerateNormalsMINE();
61826438 }
6183
- else // !trimmed
6184
- {
6185
- int count = 0;
6186
- for (int i = 0; i < strips.length; i++)
6187
- {
6188
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6189
-
6190
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6191
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6192
-
6193
- drawVertex(gl, p, selectmode);
6194
- drawVertex(gl, q, selectmode);
6195
-
6196
- for (int j = 0; j < strips[i] - 2; j++)
6197
- {
6198
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6199
-
6200
-// if (j%2 == 0)
6201
-// drawFace(p, q, r, display, null);
6202
-// else
6203
-// drawFace(p, r, q, display, null);
6204
-
6205
-// p = q;
6206
-// q = r;
6207
- drawVertex(gl, r, selectmode);
6208
- }
6209
-
6210
- gl.glEnd();
6211
- }
6212
- }
6439
+
6440
+ display.DrawGeometry(bRep, flipV, selectmode);
62136441 } else // catch (Error e)
62146442 {
62156443 // TRIANGLE ARRAY
62166444 if (IsOpaque()) // Static())
62176445 {
6218
- gl.glBegin(gl.GL_TRIANGLES);
6446
+ display.StartTriangles();
62196447 int facecount = bRep.FaceCount();
62206448 for (int i = 0; i < facecount; i++)
62216449 {
....@@ -6278,9 +6506,9 @@
62786506 // // r.norm.dot(v3) > -0.5)
62796507 // // continue;
62806508
6281
- drawFace(p, q, r, display, face);
6509
+ display.DrawFace(this, p, q, r, face);
62826510 }
6283
- gl.glEnd();
6511
+ display.EndTriangles();
62846512 }
62856513 else
62866514 {
....@@ -6309,8 +6537,8 @@
63096537 //System.out.println("SORT");
63106538
63116539 java.util.Arrays.sort(facescompare);
6312
-
6313
- gl.glBegin(gl.GL_TRIANGLES);
6540
+
6541
+ display.StartTriangles();
63146542 for (int i = 0; i < facecount; i++)
63156543 {
63166544 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6322,13 +6550,14 @@
63226550 Vertex q = bRep.GetVertex(face.q);
63236551 Vertex r = bRep.GetVertex(face.r);
63246552
6325
- drawFace(p, q, r, display, face);
6553
+ display.DrawFace(this, p, q, r, face);
63266554 }
6327
- gl.glEnd();
6555
+ display.EndTriangles();
63286556 }
63296557
63306558 if (false) // live && support != null && support.bRep != null) // debug weights
63316559 {
6560
+ /*
63326561 gl.glDisable(gl.GL_LIGHTING);
63336562 float[] colorV = new float[3];
63346563
....@@ -6407,6 +6636,7 @@
64076636 // gl.glEnd();
64086637 }
64096638 }
6639
+ */
64106640 }
64116641 }
64126642
....@@ -6451,7 +6681,7 @@
64516681 center.add(r);
64526682 center.mul(1.0/3);
64536683
6454
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6684
+ center.sub(Globals.theRenderer.EyeCamera().location);
64556685
64566686 distance = center.dot(center);
64576687 }
....@@ -6462,347 +6692,11 @@
64626692
64636693 transient FaceCompare[] facescompare = null;
64646694
6465
- void SetColor(CameraPane display, Vertex p0)
6466
- {
6467
- if (display.RENDERPROGRAM == 0)
6468
- {
6469
- float r = 0;
6470
- if (bRep != null)
6471
- {
6472
- if (bRep.stripified)
6473
- {
6474
- r = 1;
6475
- }
6476
- }
6477
- float g = 0;
6478
- if (bRep != null)
6479
- {
6480
- if (bRep.trimmed)
6481
- {
6482
- g = 1;
6483
- }
6484
- }
6485
- float b = 0;
6486
- if (support != null && link2master)
6487
- {
6488
- b = 1;
6489
- }
6490
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6491
- return;
6492
- }
6493
-
6494
- if (display.drawMode != CameraPane.SHADOW)
6495
- return;
6496
-
6497
- javax.media.opengl.GL gl = display.GetGL();
6498
-// if (true) return;
6499
-// float ao = p.AO;
6500
-//
6501
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6502
-// // ao = 1;
6503
-//
6504
-// gl.glColor4f(ao, ao, ao, 1);
6505
-
6506
-// CameraPane.selectedpoint.
6507
-// getAverage(cStatic.point1, true);
6508
- if (CameraPane.pointflow == null) // !random) // live)
6509
- {
6510
- return;
6511
- }
6512
-
6513
- cStatic.point1.set(0,0,0);
6514
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6515
-
6516
- cStatic.point1.sub(p0);
6517
-
6518
-
6519
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6520
-// {
6521
-// return;
6522
-// }
6523
-
6524
- //if (true)
6525
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6526
- {
6527
- return;
6528
- }
6529
-
6530
- float[] colorV = new float[3];
6531
-
6532
- if (false) // marked)
6533
- {
6534
- // debug rigging weights
6535
- for (int object = 0; object < p0.vertexlinks.length; object++)
6536
- {
6537
- float weight = p0.weights[object] / p0.totalweight;
6538
-
6539
- // if (weight < 0.1)
6540
- // {
6541
- // assert(weight == 0);
6542
- // continue;
6543
- // }
6544
-
6545
- if (p0.vertexlinks[object] == -1)
6546
- continue;
6547
-
6548
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6549
-
6550
- int color = //1 << object; //
6551
- //p.vertexlinks.length;
6552
- support.bRep.supports[p0.closestsupport].links[object];
6553
- colorV[2] += (color & 1) * weight;
6554
- colorV[1] += ((color & 2) >> 1) * weight;
6555
- colorV[0] += ((color & 4) >> 2) * weight;
6556
- }
6557
- }
6558
- else
6559
- {
6560
- if (drawingstarted)
6561
- {
6562
- // find next point
6563
- if (bRep.GetVertex(0).faceindices == null)
6564
- {
6565
- bRep.InitFaceIndices();
6566
- }
6567
-
6568
- double ymin = p0.y;
6569
-
6570
- Vertex newp = p0;
6571
-
6572
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6573
- {
6574
- int fi = p0.faceindices[fii];
6575
-
6576
- if (fi == -1)
6577
- break;
6578
-
6579
- Face f = bRep.GetFace(fi);
6580
-
6581
- Vertex p = bRep.GetVertex(f.p);
6582
- Vertex q = bRep.GetVertex(f.q);
6583
- Vertex r = bRep.GetVertex(f.r);
6584
-
6585
- int swap = (int)(Math.random()*3);
6586
-
6587
-// for (int s=swap; --s>=0;)
6588
-// {
6589
-// Vertex t = p;
6590
-// p = q;
6591
-// q = r;
6592
-// r = t;
6593
-// }
6594
- if (ymin > p.y)
6595
- {
6596
- ymin = p.y;
6597
- newp = p;
6598
-// break;
6599
- }
6600
- if (ymin > q.y)
6601
- {
6602
- ymin = q.y;
6603
- newp = q;
6604
-// break;
6605
- }
6606
- if (ymin > r.y)
6607
- {
6608
- ymin = r.y;
6609
- newp = r;
6610
-// break;
6611
- }
6612
- }
6613
-
6614
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6615
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6616
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6617
-
6618
- drawingstarted = false;
6619
-
6620
- // return;
6621
- }
6622
-
6623
- if (false) // CameraPane.DRAW
6624
- {
6625
- p0.AO = colorV[0] = 2;
6626
- colorV[1] = 2;
6627
- colorV[2] = 2;
6628
- }
6629
-
6630
- CameraPane.pointflow.add(p0);
6631
- CameraPane.pointflow.Touch();
6632
- }
6633
-
6634
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6635
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6636
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6637
- }
6638
-
66396695 void Print(Vertex v)
66406696 {
66416697 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66426698 }
66436699
6644
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6645
- {
6646
- if (!selectmode)
6647
- {
6648
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6649
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6650
-
6651
- if (flipV)
6652
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6653
- else
6654
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6655
- }
6656
-
6657
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6658
- }
6659
-
6660
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6661
- CameraPane display, Face face)
6662
- {
6663
- if (pv.y == -10000 ||
6664
- qv.y == -10000 ||
6665
- rv.y == -10000)
6666
- return;
6667
-
6668
-// float b = f.nbiterations & 1;
6669
-// float g = (f.nbiterations>>1) & 1;
6670
-// float r = (f.nbiterations>>2) & 1;
6671
-//
6672
-// //if (f.weight == 10000)
6673
-// //{
6674
-// // r = 1; g = b = 0;
6675
-// //}
6676
-// //else
6677
-// //{
6678
-// // assert(f.weight < 10000);
6679
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6680
-// if (r<0)
6681
-// assert(r>=0);
6682
-// //}
6683
-
6684
- javax.media.opengl.GL gl = display.GetGL();
6685
-
6686
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6687
-
6688
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6689
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6690
- {
6691
- //gl.glBegin(gl.GL_TRIANGLES);
6692
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6693
- if (!hasnorm)
6694
- {
6695
- // System.out.println("FUCK!!");
6696
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6697
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6698
- LA.vecCross(v0, v1, v2);
6699
- LA.vecNormalize(v2);
6700
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6701
- }
6702
-
6703
- if (hasnorm)
6704
- {
6705
-// if (!pv.norm.normalized())
6706
-// assert(pv.norm.normalized());
6707
-
6708
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6709
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6710
- }
6711
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6712
- SetColor(display, pv);
6713
- //gl.glColor4f(r, g, b, 1);
6714
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6715
- if (flipV)
6716
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6717
- else
6718
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6719
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6720
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6721
-// Print(pv);
6722
- if (hasnorm)
6723
- {
6724
-// assert(qv.norm.normalized());
6725
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6726
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6727
- }
6728
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6729
- // boolean locked = false;
6730
- // float eps = 0.1f;
6731
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6732
-
6733
- // int dot = 0; //*/ (int)f.dot;
6734
-
6735
- // if ((dot&1) == 0)
6736
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6737
-
6738
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6739
- if (flipV)
6740
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6741
- else
6742
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6743
- // else
6744
- // {
6745
- // locked = true;
6746
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6747
- // }
6748
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6749
- SetColor(display, qv);
6750
- //gl.glColor4f(r, g, b, 1);
6751
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6752
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6753
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6754
-// Print(qv);
6755
- if (hasnorm)
6756
- {
6757
-// assert(rv.norm.normalized());
6758
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6759
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6760
- }
6761
-
6762
- // if ((dot&4) == 0)
6763
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6764
-
6765
- // if (wrap || !locked && (dot&8) != 0)
6766
- if (flipV)
6767
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6768
- else
6769
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6770
- // else
6771
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6772
-
6773
- // f.dot = dot;
6774
-
6775
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6776
- SetColor(display, rv);
6777
- //gl.glColor4f(r, g, b, 1);
6778
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6779
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6780
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6781
-// Print(rv);
6782
- //gl.glEnd();
6783
- }
6784
- else
6785
- {
6786
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6787
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6788
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6789
-
6790
- }
6791
-
6792
- if (false) // (attributes & WIREFRAME) != 0)
6793
- {
6794
- gl.glDisable(gl.GL_LIGHTING);
6795
-
6796
- gl.glBegin(gl.GL_LINE_LOOP);
6797
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6798
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6799
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6800
- gl.glEnd();
6801
-
6802
- gl.glEnable(gl.GL_LIGHTING);
6803
- }
6804
- }
6805
-
68066700 void drawSelf(ClickInfo info, int level, boolean select)
68076701 {
68086702 if (bRep == null)
....@@ -7374,83 +7268,84 @@
73747268 int spotw = spot.x + spot.width;
73757269 int spoth = spot.y + spot.height;
73767270 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7377
- if (CameraPane.Xmin > spot.x)
7378
- {
7379
- CameraPane.Xmin = spot.x;
7380
- }
7381
- if (CameraPane.Xmax < spotw)
7382
- {
7383
- CameraPane.Xmax = spotw;
7384
- }
7385
- if (CameraPane.Ymin > spot.y)
7386
- {
7387
- CameraPane.Ymin = spot.y;
7388
- }
7389
- if (CameraPane.Ymax < spoth)
7390
- {
7391
- CameraPane.Ymax = spoth;
7392
- }
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
+// }
73937287 spot.translate(32, 32);
73947288 spotw = spot.x + spot.width;
73957289 spoth = spot.y + spot.height;
7396
- info.g.setColor(Color.blue);
7290
+ info.g.setColor(Color.cyan);
73977291 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7398
- if (CameraPane.Xmin > spot.x)
7399
- {
7400
- CameraPane.Xmin = spot.x;
7401
- }
7402
- if (CameraPane.Xmax < spotw)
7403
- {
7404
- CameraPane.Xmax = spotw;
7405
- }
7406
- if (CameraPane.Ymin > spot.y)
7407
- {
7408
- CameraPane.Ymin = spot.y;
7409
- }
7410
- if (CameraPane.Ymax < spoth)
7411
- {
7412
- CameraPane.Ymax = spoth;
7413
- }
7414
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7415
- 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
74167310 spot.translate(0, -32);
7417
- info.g.setColor(Color.green);
7311
+ info.g.setColor(Color.yellow);
74187312 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7419
- if (CameraPane.Xmin > spot.x)
7420
- {
7421
- CameraPane.Xmin = spot.x;
7422
- }
7423
- if (CameraPane.Xmax < spotw)
7424
- {
7425
- CameraPane.Xmax = spotw;
7426
- }
7427
- if (CameraPane.Ymin > spot.y)
7428
- {
7429
- CameraPane.Ymin = spot.y;
7430
- }
7431
- if (CameraPane.Ymax < spoth)
7432
- {
7433
- CameraPane.Ymax = spoth;
7434
- }
7435
- info.g.drawArc(boundary.x, boundary.y,
7436
- 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);
74377332 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7438
- if (CameraPane.Xmin > boundary.x)
7439
- {
7440
- CameraPane.Xmin = boundary.x;
7441
- }
7442
- if (CameraPane.Xmax < boundary.x + boundary.width)
7443
- {
7444
- CameraPane.Xmax = boundary.x + boundary.width;
7445
- }
7446
- if (CameraPane.Ymin > boundary.y)
7447
- {
7448
- CameraPane.Ymin = boundary.y;
7449
- }
7450
- if (CameraPane.Ymax < boundary.y + boundary.height)
7451
- {
7452
- CameraPane.Ymax = boundary.y + boundary.height;
7453
- }
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
+// }
74547349 return;
74557350 }
74567351 }
....@@ -7467,7 +7362,7 @@
74677362 startX = info.x;
74687363 startY = info.y;
74697364
7470
- hitSomething = 0;
7365
+ hitSomething = -1;
74717366 cVector origin = new cVector();
74727367 //LA.xformPos(origin, toParent, origin);
74737368 Rectangle spot = new Rectangle();
....@@ -7500,7 +7395,7 @@
75007395 }
75017396
75027397 //System.out.println("info.modifiers = " + info.modifiers);
7503
- modified = (info.modifiers & CameraPane.META) != 0;
7398
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
75047399 //System.out.println("modified = " + modified);
75057400 //new Exception().printStackTrace();
75067401 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7528,7 +7423,7 @@
75287423 return true;
75297424 }
75307425
7531
- void doEditDrag0(ClickInfo info)
7426
+ void doEditDrag0(ClickInfo info, boolean opposite)
75327427 {
75337428 if (hitSomething == 0)
75347429 {
....@@ -7543,6 +7438,7 @@
75437438 //System.out.println("hitSomething = " + hitSomething);
75447439
75457440 double scale = 0.005f * info.camera.Distance();
7441
+
75467442 cVector xlate = new cVector();
75477443 //cVector xlate2 = new cVector();
75487444 switch (hitSomething)
....@@ -7553,9 +7449,9 @@
75537449
75547450 case hitCenter: // Translate
75557451
7556
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7452
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75577453
7558
- if (modified)
7454
+ if (modified || opposite)
75597455 {
75607456 //assert(false);
75617457 /*
....@@ -7601,10 +7497,10 @@
76017497 }
76027498 LA.xformDir(up, ClickInfo.matbuffer, up);
76037499 // if (!CameraPane.LOCALTRANSFORM)
7604
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7500
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
76057501 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
76067502 // if (!CameraPane.LOCALTRANSFORM)
7607
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7503
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76087504 //LA.vecCross(up, cVector.Z, right2);
76097505
76107506 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7649,6 +7545,7 @@
76497545
76507546 if (modified)
76517547 {
7548
+ // Rotate 90 degrees
76527549 angle /= (Math.PI / 4);
76537550 angle = Math.floor(angle + 0.5);
76547551 angle *= (Math.PI / 4);
....@@ -7662,7 +7559,7 @@
76627559 }
76637560 /**/
76647561
7665
- switch (info.pane.renderCamera.viewCode)
7562
+ switch (info.pane.RenderCamera().viewCode)
76667563 {
76677564 case 1: // '\001'
76687565 LA.matZRotate(toParent, angle);
....@@ -7690,24 +7587,27 @@
76907587
76917588 case hitScale: // scale
76927589 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);
76937596 if (hScale < 0.01)
76947597 {
7695
- hScale = 0.01;
7598
+ //hScale = 0.01;
76967599 }
7697
- hScale = Math.pow(hScale, scale * 50);
7698
- if (hScale < 0.01)
7699
- {
7700
- hScale = 0.01;
7701
- }
7600
+
77027601 double vScale = (double) (info.y - centerPt.y) / 32;
7703
- if (vScale < 0.01)
7602
+ sign = 1;
7603
+ if (vScale < 0)
77047604 {
7705
- vScale = 0.01;
7605
+ sign = -1;
77067606 }
7707
- vScale = Math.pow(vScale, scale * 50);
7607
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77087608 if (vScale < 0.01)
77097609 {
7710
- vScale = 0.01;
7610
+ //vScale = 0.01;
77117611 }
77127612 LA.matCopy(startMat, toParent);
77137613 /**/
....@@ -7718,39 +7618,47 @@
77187618 }
77197619 /**/
77207620
7721
- 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)
77227629 {
77237630 case 3: // '\001'
7724
- if (modified)
7631
+ if (modified || opposite)
77257632 {
77267633 //LA.matScale(toParent, 1, hScale, vScale);
7727
- LA.matScale(toParent, vScale, 1, 1);
7634
+ LA.matScale(toParent, totalScale, 1, 1);
77287635 } // vScale, 1);
77297636 else
77307637 {
7731
- LA.matScale(toParent, vScale, vScale, vScale);
7638
+ // EXCEPTION!
7639
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
77327640 } // vScale, 1);
77337641 break;
77347642
77357643 case 2: // '\002'
7736
- if (modified)
7644
+ if (modified || opposite)
77377645 {
77387646 //LA.matScale(toParent, hScale, 1, vScale);
7739
- LA.matScale(toParent, 1, vScale, 1);
7647
+ LA.matScale(toParent, 1, totalScale, 1);
77407648 } else
77417649 {
7742
- LA.matScale(toParent, vScale, 1, vScale);
7650
+ LA.matScale(toParent, totalScale, 1, totalScale);
77437651 }
77447652 break;
77457653
77467654 case 1: // '\003'
7747
- if (modified)
7655
+ if (modified || opposite)
77487656 {
77497657 //LA.matScale(toParent, hScale, vScale, 1);
7750
- LA.matScale(toParent, 1, 1, vScale);
7658
+ LA.matScale(toParent, 1, 1, totalScale);
77517659 } else
77527660 {
7753
- LA.matScale(toParent, vScale, vScale, 1);
7661
+ LA.matScale(toParent, totalScale, totalScale, 1);
77547662 }
77557663 break;
77567664 }
....@@ -7883,14 +7791,22 @@
78837791 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78847792 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78857793 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7794
+
7795
+ String objname;
7796
+
78867797 if (false) //parent != null)
78877798 {
7888
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7799
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78897800 } else
78907801 {
7891
- 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) ":"") */ "";
78927803 } // + super.toString();
78937804 //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);
78947810 }
78957811
78967812 public int hashCode()
....@@ -7946,6 +7862,7 @@
79467862 objectUI.closeUI();
79477863 if (editWindow != null)
79487864 {
7865
+ editWindow.ctrlPanel.FlushUI();
79497866 editWindow.refreshContents();
79507867 } // ? new
79517868 objectUI = null;
....@@ -7954,6 +7871,10 @@
79547871 {
79557872 editWindow = null;
79567873 } // ?
7874
+ }
7875
+ else
7876
+ {
7877
+ //editWindow.closeUI();
79577878 }
79587879 }
79597880
....@@ -7966,7 +7887,7 @@
79667887 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79677888
79687889 Object3D /*Composite*/ parent;
7969
- Object3D /*Composite*/ fileparent;
7890
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79707891
79717892 double[][] toParent; // dynamic matrix
79727893 double[][] fromParent;
....@@ -8081,7 +8002,7 @@
80818002 {
80828003 assert(bRep != null);
80838004 if (!(support instanceof GenericJoint)) // support.bRep != null)
8084
- GrafreeD.Assert(support.bRep == bRep.support);
8005
+ Grafreed.Assert(support.bRep == bRep.support);
80858006 }
80868007 else
80878008 {
....@@ -8112,6 +8033,10 @@
81128033 }
81138034
81148035 transient ObjEditor editWindow;
8036
+ transient ObjEditor manipWindow;
8037
+
8038
+ transient boolean pinned;
8039
+
81158040 transient ObjectUI objectUI;
81168041 public static int povDepth = 0;
81178042 private static cVector tbMin = new cVector();
....@@ -8130,9 +8055,9 @@
81308055 private static cVector edge2 = new cVector();
81318056 //private static cVector norm = new cVector();
81328057 /*transient private*/ int hitSomething;
8133
- private static final int hitCenter = 1;
8134
- private static final int hitScale = 2;
8135
- private static final int hitRotate = 3;
8058
+ static final int hitCenter = 1;
8059
+ static final int hitScale = 2;
8060
+ static final int hitRotate = 3;
81368061 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81378062 /*transient*/ private Point centerPt;
81388063 /*transient*/ private int startX;
....@@ -8164,6 +8089,8 @@
81648089 {
81658090 Object3D targ = this;
81668091
8092
+ targ.NORMALPUSH = obj.NORMALPUSH;
8093
+
81678094 if (obj.material != null)
81688095 {
81698096 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))