Normand Briere
2019-07-17 a5580a47d246c1272b10adba68070f6e13da5e41
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,173 @@
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
+
223
+ if (this.support != null)
224
+ {
225
+ if (o.transientrep != null)
226
+ Grafreed.Assert(o.transientrep == this.support.bRep);
227
+
228
+ o.transientrep = this.support.bRep;
229
+ this.support.bRep = null;
230
+ }
231
+
232
+ // o.support = this.support;
233
+ // o.fileparent = this.fileparent;
234
+ // if (this.bRep != null)
235
+ // o.bRep = this.bRep.support;
236
+
237
+ this.bRep = null;
238
+ // if (this.bRep != null)
239
+ // this.bRep.support = null;
240
+ // this.support = null;
241
+ // this.fileparent = null;
242
+ }
243
+
244
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
245
+ {
246
+ if (!hashtable.containsKey(GetUUID()))
247
+ return;
248
+
249
+ Object3D o = hashtable.get(GetUUID());
250
+
251
+ RestoreBigData(o);
252
+
253
+ if (blockloop)
254
+ return;
255
+
116256 blockloop = true;
117
- child.SaveSupports();
257
+
258
+ //hashtable.remove(GetUUID());
259
+
260
+ for (int i=0; i<Size(); i++)
261
+ {
262
+ get(i).RestoreBigData(hashtable);
263
+ }
264
+
118265 blockloop = false;
119266 }
120
-}
121267
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)
268
+ void RestoreBigData(Object3D o)
133269 {
134
- bRep.RestoreSupports();
270
+ this.bRep = o.bRep;
271
+ if (this.support != null && o.transientrep != null)
272
+ {
273
+ this.support.bRep = o.transientrep;
274
+ }
275
+
276
+ this.selection = o.selection;
277
+// July 2019 if (this.bRep != null)
278
+// this.bRep.support = o.transientrep;
279
+ // this.support = o.support;
280
+ // this.fileparent = o.fileparent;
135281 }
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
-}
147282
148283 // MOCAP SUPPORT
149284 double tx,ty,tz,rx,ry,rz;
....@@ -286,6 +421,7 @@
286421 }
287422
288423 boolean live = false;
424
+ boolean dontselect = false;
289425 boolean hide = false;
290426 boolean link2master = false; // performs reset support/master at each frame
291427 boolean marked = false; // animation node
....@@ -295,6 +431,8 @@
295431 boolean random = false;
296432 boolean speedup = false;
297433 boolean rewind = false;
434
+
435
+ float NORMALPUSH = 0;
298436
299437 Object3D support;
300438
....@@ -355,7 +493,7 @@
355493
356494 int MemorySize()
357495 {
358
- if (memorysize == 0)
496
+ if (true) // memorysize == 0)
359497 {
360498 try
361499 {
....@@ -415,16 +553,16 @@
415553 {
416554 Object3D copy = this;
417555
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
556
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419557
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
558
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421559 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
560
+ parentcam = Globals.theRenderer.Cameras()[1];
423561 }
424562
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
563
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426564 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
565
+ parentcam = Globals.theRenderer.Cameras()[0];
428566 }
429567
430568 if (this == parentcam)
....@@ -432,7 +570,7 @@
432570 //assert(this instanceof Camera);
433571
434572 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
573
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436574 }
437575
438576 copy.marked ^= true;
....@@ -452,7 +590,7 @@
452590 //assert(this instanceof Camera);
453591
454592 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
593
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456594 }
457595
458596 copy.Touch(); // display list issue
....@@ -465,12 +603,14 @@
465603 toParent = LA.newMatrix();
466604 fromParent = LA.newMatrix();
467605 }
606
+
468607 if (toParentMarked == null)
469608 {
470609 if (maxcount != 1)
471610 {
472611 new Exception().printStackTrace();
473612 }
613
+
474614 toParentMarked = LA.newMatrix();
475615 fromParentMarked = LA.newMatrix();
476616 }
....@@ -587,7 +727,7 @@
587727 return;
588728 }
589729
590
- if (CameraPane.fromscript)
730
+ if (Globals.fromscript)
591731 {
592732 transformcount = 0;
593733 return;
....@@ -745,7 +885,7 @@
745885
746886 int GetTransformCount()
747887 {
748
- // marde pour serialization de Texture
888
+ // patch pour serialization de Texture
749889 resetmaxcount();
750890 resettransformcount();
751891 resetstep();
....@@ -758,7 +898,7 @@
758898 if (step == 0)
759899 step = 1;
760900 if (maxcount == 0)
761
- maxcount = 2048; // 4;
901
+ maxcount = 128; // 2048; // 4;
762902 // if (acceleration == 0)
763903 // acceleration = 10;
764904 if (delay == 0) // serial
....@@ -779,9 +919,12 @@
779919 // factor = CameraPane.STEP;
780920 // }
781921
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
922
+ if (marked && Globals.isLIVE() && live &&
923
+ //TEMP21aug2018
924
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
925
+ currentframe != Globals.framecount)
783926 {
784
- currentframe = CameraPane.framecount;
927
+ currentframe = Globals.framecount;
785928
786929 // System.err.println("transformcount = " + transformcount);
787930 // System.err.println("factor = " + factor);
....@@ -790,7 +933,8 @@
790933
791934 boolean changedir = random && Math.random() < 0.01; // && !link2master;
792935
793
- if (transformcount*factor > maxcount || (step == 1 && changedir))
936
+ if (transformcount*factor >= maxcount && (rewind || random) ||
937
+ (step == 1 && changedir))
794938 {
795939 countdown = 1;
796940 delay = speedup?8:1;
....@@ -862,6 +1006,7 @@
8621006 if (material == null || material.multiply)
8631007 return true;
8641008
1009
+ // Transparent objects are dynamic because we have to sort the triangles.
8651010 return material.opacity > 0.99;
8661011 }
8671012
....@@ -893,6 +1038,11 @@
8931038 fromParent = null; // LA.newMatrix();
8941039 bRep = null; // new BoundaryRep();
8951040
1041
+ if (oname != null && oname.equals("LeftHand"))
1042
+ {
1043
+ name = oname;
1044
+ }
1045
+
8961046 /*
8971047 float hue = (float)Math.random();
8981048 Color col;
....@@ -935,7 +1085,7 @@
9351085
9361086 public Object clone()
9371087 {
938
- return GrafreeD.clone(this);
1088
+ return Grafreed.clone(this);
9391089 }
9401090
9411091 Object3D copyExpand()
....@@ -1257,6 +1407,7 @@
12571407 toParent = LA.newMatrix();
12581408 fromParent = LA.newMatrix();
12591409 }
1410
+
12601411 LA.matCopy(other.toParent, toParent);
12611412 LA.matCopy(other.fromParent, fromParent);
12621413
....@@ -1446,7 +1597,16 @@
14461597 // if (other == null)
14471598 // return;
14481599
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1600
+ if (other != null)
1601
+ {
1602
+ BoundaryRep.SEUIL = other.material.cameralight;
1603
+
1604
+ // Set default to 0.1
1605
+ BoundaryRep.SEUIL /= 4; // 2;
1606
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1607
+ }
1608
+
1609
+ System.out.println("Link this = " + this + "; support = " + other);
14501610
14511611 //if (bRep != null)
14521612 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1861,7 @@
17011861 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021862 o.bRep = transientrep;
17031863 if (clone)
1704
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1864
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051865 o.CreateMaterial();
17061866 o.SetAttributes(this, -1);
17071867 //parent
....@@ -1714,7 +1874,7 @@
17141874 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151875 o.bRep = bRep;
17161876 if (clone)
1717
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1877
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181878 o.CreateMaterial();
17191879 //o.overwriteThis(this, -1);
17201880 o.SetAttributes(this, -1);
....@@ -1801,12 +1961,15 @@
18011961 if (obj.name == null)
18021962 continue; // can't be a null one
18031963
1964
+ // Try perfect match first.
18041965 if (n.equals(obj.name))
18051966 {
18061967 theobj = obj;
18071968 count++;
18081969 }
18091970 }
1971
+
1972
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18101973
18111974 if (count != 1)
18121975 for (int i=Size(); --i>=0;)
....@@ -1816,8 +1979,9 @@
18161979 if (obj.name == null)
18171980 continue; // can't be a null one
18181981
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1982
+ String name = obj.name.split(":")[0]; // Poser generates a count
1983
+ //if (n.startsWith(obj.name))
1984
+ if (n.contains(name))
18211985 {
18221986 theobj = obj;
18231987 count++;
....@@ -2120,15 +2284,8 @@
21202284 if (/*parent != null &&*/ material == null)
21212285 {
21222286 material = new cMaterial(GetMaterial());
2123
- if (projectedVertices == null || projectedVertices.length <= 2)
2124
- {
2125
- projectedVertices = new Object3D.cVector2[3];
2126
- }
2127
- for (int i = 0; i < 3; i++)
2128
- {
2129
- projectedVertices[i] = new cVector2(); // Others
2130
- }
2131
- projectedVertices[0].x = 100; // bump
2287
+
2288
+ InitOthers();
21322289
21332290 if (this instanceof Camera)
21342291 {
....@@ -2272,12 +2429,17 @@
22722429 }
22732430 */
22742431 }
2432
+ else
2433
+ {
2434
+ //((ObjEditor)editWindow).SetupUI2(null);
2435
+ }
22752436 }
22762437
22772438 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22782439 {
22792440 if (newWindow)
22802441 {
2442
+ new Exception().printStackTrace();
22812443 System.exit(0);
22822444 if (parent != null)
22832445 {
....@@ -2312,6 +2474,14 @@
23122474 {
23132475 editWindow.refreshContents();
23142476 }
2477
+ else
2478
+ {
2479
+ if (manipWindow != null)
2480
+ {
2481
+ manipWindow.refreshContents();
2482
+ }
2483
+ }
2484
+
23152485 //if (parent != null)
23162486 //parent.refreshEditWindow();
23172487 }
....@@ -2454,13 +2624,13 @@
24542624 return retval;
24552625 }
24562626
2457
- void doEditDrag(ClickInfo info)
2627
+ void doEditDrag(ClickInfo info, boolean opposite)
24582628 {
24592629 switch (doSomething)
24602630 {
24612631 case 1: // '\001'
24622632 //super.
2463
- doEditDrag0(info);
2633
+ doEditDrag0(info, opposite);
24642634 break;
24652635
24662636 case 2: // '\002'
....@@ -2473,11 +2643,11 @@
24732643 {
24742644 //sel.hitSomething = childToDrag.hitSomething;
24752645 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2646
+ sel.doEditDrag(info, opposite);
24772647 } else
24782648 {
24792649 //super.
2480
- doEditDrag0(info);
2650
+ doEditDrag0(info, opposite);
24812651 }
24822652 }
24832653 break;
....@@ -2587,6 +2757,18 @@
25872757 void GenNormalsS(boolean crease)
25882758 {
25892759 selection.GenNormals(crease);
2760
+// for (int i=0; i<selection.size(); i++)
2761
+// {
2762
+// Object3D selectee = (Object3D) selection.elementAt(i);
2763
+// selectee.GenNormals(crease);
2764
+// }
2765
+
2766
+ //Touch();
2767
+ }
2768
+
2769
+ void GenNormalsMeshS()
2770
+ {
2771
+ selection.GenNormalsMesh();
25902772 // for (int i=0; i<selection.size(); i++)
25912773 // {
25922774 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2732,6 +2914,42 @@
27322914 blockloop = false;
27332915 }
27342916
2917
+ void GenNormalsMesh()
2918
+ {
2919
+ if (blockloop)
2920
+ return;
2921
+
2922
+ blockloop = true;
2923
+ GenNormalsMesh0();
2924
+ for (int i = 0; i < Children().Size(); i++)
2925
+ {
2926
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2927
+ if (child == null)
2928
+ continue;
2929
+ child.GenNormalsMesh();
2930
+// Children().release(i);
2931
+ }
2932
+ blockloop = false;
2933
+ }
2934
+
2935
+ void GenNormalsMINE()
2936
+ {
2937
+ if (blockloop)
2938
+ return;
2939
+
2940
+ blockloop = true;
2941
+ GenNormalsMINE0();
2942
+ for (int i = 0; i < Children().Size(); i++)
2943
+ {
2944
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2945
+ if (child == null)
2946
+ continue;
2947
+ child.GenNormalsMINE();
2948
+// Children().release(i);
2949
+ }
2950
+ blockloop = false;
2951
+ }
2952
+
27352953 void ClearColors()
27362954 {
27372955 if (blockloop)
....@@ -2866,7 +3084,8 @@
28663084 {
28673085 if (bRep != null)
28683086 {
2869
- bRep.GenUV();
3087
+ bRep.GenUV(); //1);
3088
+ //bRep.UnfoldUV();
28703089 Touch();
28713090 }
28723091 }
....@@ -2876,6 +3095,24 @@
28763095 if (bRep != null)
28773096 {
28783097 bRep.GenerateNormals(crease);
3098
+ Touch();
3099
+ }
3100
+ }
3101
+
3102
+ void GenNormalsMesh0()
3103
+ {
3104
+ if (bRep != null)
3105
+ {
3106
+ bRep.GenerateNormalsMesh();
3107
+ Touch();
3108
+ }
3109
+ }
3110
+
3111
+ void GenNormalsMINE0()
3112
+ {
3113
+ if (bRep != null)
3114
+ {
3115
+ bRep.GenerateNormalsMINE();
28793116 Touch();
28803117 }
28813118 }
....@@ -2932,6 +3169,33 @@
29323169 blockloop = false;
29333170 }
29343171
3172
+ void TransformChildren()
3173
+ {
3174
+ if (toParent != null)
3175
+ {
3176
+ for (int i=Size(); --i>=0;)
3177
+ {
3178
+ Object3D v = get(i);
3179
+
3180
+ if (v.toParent == null)
3181
+ {
3182
+ v.toParent = LA.newMatrix();
3183
+ v.fromParent = LA.newMatrix();
3184
+ }
3185
+
3186
+// LA.matConcat(v.toParent, toParent, v.toParent);
3187
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3188
+ LA.matConcat(toParent, v.toParent, v.toParent);
3189
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3190
+ }
3191
+
3192
+ toParent = null; // LA.matIdentity(toParent);
3193
+ fromParent = null; // LA.matIdentity(fromParent);
3194
+
3195
+ Touch();
3196
+ }
3197
+ }
3198
+
29353199 void TransformGeometry()
29363200 {
29373201 Object3D obj = this;
....@@ -3153,9 +3417,11 @@
31533417
31543418 BoundaryRep sup = bRep.support;
31553419 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3420
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573421 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3422
+
3423
+ while(temprep.SplitInTwo(reduction34, onlyone));
3424
+
31593425 bRep = temprep;
31603426 bRep.support = sup;
31613427 Touch();
....@@ -3292,7 +3558,8 @@
32923558 if (blockloop)
32933559 return;
32943560
3295
- if (marked || (bRep != null && material != null)) // borderline...
3561
+ if (//marked || // does not make sense
3562
+ (bRep != null || material != null)) // borderline...
32963563 live = h;
32973564
32983565 for (int i = 0; i < Size(); i++)
....@@ -3313,7 +3580,8 @@
33133580 return;
33143581
33153582 //if (bRep != null)
3316
- if (marked || (bRep != null && material != null)) // borderline...
3583
+ if (//marked || // does not make sense
3584
+ (bRep != null || material != null)) // borderline...
33173585 link2master = h;
33183586
33193587 for (int i = 0; i < Size(); i++)
....@@ -3333,7 +3601,8 @@
33333601 if (blockloop)
33343602 return;
33353603
3336
- if (marked || (bRep != null && material != null)) // borderline...
3604
+ if (//marked || // does not make sense
3605
+ (bRep != null || material != null)) // borderline...
33373606 hide = h;
33383607
33393608 for (int i = 0; i < Size(); i++)
....@@ -3353,7 +3622,7 @@
33533622 if (blockloop)
33543623 return;
33553624
3356
- if (bRep != null && material != null) // borderline...
3625
+ if (bRep != null || material != null) // borderline...
33573626 marked = h;
33583627
33593628 for (int i = 0; i < Size(); i++)
....@@ -3363,6 +3632,46 @@
33633632 continue;
33643633 blockloop = true;
33653634 child.MarkLeaves(h);
3635
+ blockloop = false;
3636
+ // release(i);
3637
+ }
3638
+ }
3639
+
3640
+ void RewindLeaves(boolean h)
3641
+ {
3642
+ if (blockloop)
3643
+ return;
3644
+
3645
+ if (bRep != null || material != null) // borderline...
3646
+ rewind = h;
3647
+
3648
+ for (int i = 0; i < Size(); i++)
3649
+ {
3650
+ Object3D child = (Object3D) get(i); // reserve(i);
3651
+ if (child == null)
3652
+ continue;
3653
+ blockloop = true;
3654
+ child.RewindLeaves(h);
3655
+ blockloop = false;
3656
+ // release(i);
3657
+ }
3658
+ }
3659
+
3660
+ void RandomLeaves(boolean h)
3661
+ {
3662
+ if (blockloop)
3663
+ return;
3664
+
3665
+ if (bRep != null || material != null) // borderline...
3666
+ random = h;
3667
+
3668
+ for (int i = 0; i < Size(); i++)
3669
+ {
3670
+ Object3D child = (Object3D) get(i); // reserve(i);
3671
+ if (child == null)
3672
+ continue;
3673
+ blockloop = true;
3674
+ child.RandomLeaves(h);
33663675 blockloop = false;
33673676 // release(i);
33683677 }
....@@ -3677,7 +3986,7 @@
36773986 if (child == null)
36783987 continue;
36793988
3680
- if (GrafreeD.RENDERME > 0)
3989
+ if (Grafreed.RENDERME > 0)
36813990 {
36823991 if (child instanceof Merge)
36833992 ((Merge)child).renderme();
....@@ -3828,7 +4137,7 @@
38284137 if (child == null)
38294138 continue;
38304139
3831
- if (GrafreeD.RENDERME > 0)
4140
+ if (Grafreed.RENDERME > 0)
38324141 {
38334142 if (child instanceof Merge)
38344143 ((Merge)child).renderme();
....@@ -4023,7 +4332,7 @@
40234332 if (child == null)
40244333 continue;
40254334
4026
- if (GrafreeD.RENDERME > 0)
4335
+ if (Grafreed.RENDERME > 0)
40274336 {
40284337 if (child instanceof Merge)
40294338 ((Merge)child).renderme();
....@@ -4111,7 +4420,7 @@
41114420 if (blockloop)
41124421 return;
41134422
4114
- for (int i=0; i<size(); i++)
4423
+ for (int i=0; i<Size(); i++)
41154424 {
41164425 if (get(i).parent != this)
41174426 {
....@@ -4120,6 +4429,71 @@
41204429 }
41214430 blockloop = true;
41224431 get(i).RepairParent();
4432
+ blockloop = false;
4433
+ }
4434
+ }
4435
+
4436
+ void RepairShadow()
4437
+ {
4438
+ if (blockloop)
4439
+ return;
4440
+
4441
+ if (this.material != null)
4442
+ this.InitOthers();
4443
+
4444
+ for (int i=0; i<Size(); i++)
4445
+ {
4446
+ blockloop = true;
4447
+ get(i).RepairShadow();
4448
+ blockloop = false;
4449
+ }
4450
+ }
4451
+
4452
+ void RepairSOV()
4453
+ {
4454
+ if (blockloop)
4455
+ return;
4456
+
4457
+ String texname = this.GetPigmentTexture();
4458
+
4459
+ if (texname.startsWith("sov"))
4460
+ {
4461
+ String[] s = texname.split("/");
4462
+
4463
+ String[] sname = s[1].split("Color.pn");
4464
+
4465
+ texname = sname[0];
4466
+
4467
+ if (sname.length > 1)
4468
+ {
4469
+ texname += "Color.jpg";
4470
+ }
4471
+
4472
+ this.SetPigmentTexture("sov/" + texname);
4473
+ }
4474
+
4475
+ texname = this.GetBumpTexture();
4476
+
4477
+ if (texname.startsWith("sov"))
4478
+ {
4479
+ String[] s = texname.split("/");
4480
+
4481
+ String[] sname = s[1].split("Bump.pn");
4482
+
4483
+ texname = sname[0];
4484
+
4485
+ if (sname.length > 1)
4486
+ {
4487
+ texname += "Bump.jpg";
4488
+ }
4489
+
4490
+ this.SetBumpTexture("sov/" + texname);
4491
+ }
4492
+
4493
+ for (int i=0; i<Size(); i++)
4494
+ {
4495
+ blockloop = true;
4496
+ get(i).RepairSOV();
41234497 blockloop = false;
41244498 }
41254499 }
....@@ -4614,7 +4988,7 @@
46144988
46154989 cTreePath SelectLeaf(int indexcount, boolean deselect)
46164990 {
4617
- if (hide)
4991
+ if (hide || dontselect)
46184992 return null;
46194993
46204994 if (count <= 0)
....@@ -4638,9 +5012,17 @@
46385012 }
46395013 }
46405014
5015
+ ObjEditor GetWindow()
5016
+ {
5017
+ if (editWindow != null)
5018
+ return editWindow;
5019
+
5020
+ return manipWindow;
5021
+ }
5022
+
46415023 cTreePath Select(int indexcount, boolean deselect)
46425024 {
4643
- if (hide)
5025
+ if (hide || dontselect)
46445026 return null;
46455027
46465028 if (count <= 0)
....@@ -4674,10 +5056,11 @@
46745056 if (leaf != null)
46755057 {
46765058 cTreePath tp = new cTreePath(this, leaf);
4677
- if (editWindow != null)
5059
+ ObjEditor window = GetWindow();
5060
+ if (window != null)
46785061 {
46795062 //System.out.println("editWindow = " + editWindow + " vs " + this);
4680
- editWindow.Select(tp, deselect, true);
5063
+ window.Select(tp, deselect, true);
46815064 }
46825065
46835066 return tp;
....@@ -4694,6 +5077,7 @@
46945077
46955078 if (child == null)
46965079 continue;
5080
+
46975081 if (child.HasTransparency() && child.size() != 0)
46985082 {
46995083 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4703,9 +5087,10 @@
47035087 if (leaf != null)
47045088 {
47055089 cTreePath tp = new cTreePath(this, leaf);
4706
- if (editWindow != null)
5090
+ ObjEditor window = GetWindow();
5091
+ if (window != null)
47075092 {
4708
- editWindow.Select(tp, deselect, true);
5093
+ window.Select(tp, deselect, true);
47095094 }
47105095
47115096 return tp;
....@@ -4790,7 +5175,7 @@
47905175 return globalTransform;
47915176 }
47925177
4793
- void PreprocessOcclusion(CameraPane cp)
5178
+ void PreprocessOcclusion(iCameraPane cp)
47945179 {
47955180 /*
47965181 if (AOdone)
....@@ -4937,7 +5322,8 @@
49375322 } else //
49385323 if (editWindow != null)
49395324 {
4940
- editWindow.cameraView.lighttouched = true;
5325
+ //editWindow.cameraView.lighttouched = true;
5326
+ Globals.lighttouched = true;
49415327 }
49425328 }
49435329
....@@ -5091,10 +5477,34 @@
50915477
50925478 // System.out.println("Fullname = " + fullname);
50935479
5094
- if (fullname.name.indexOf(":") == -1)
5095
- return fullname.name;
5480
+ // Does not work on Windows due to C:
5481
+// if (fullname.name.indexOf(":") == -1)
5482
+// return fullname.name;
5483
+//
5484
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50965485
5097
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5486
+ String[] split = fullname.name.split(":");
5487
+
5488
+ if (split.length == 0)
5489
+ {
5490
+ return "";
5491
+ }
5492
+
5493
+ if (split.length <= 2)
5494
+ {
5495
+ if (fullname.name.endsWith(":"))
5496
+ {
5497
+ // Windows
5498
+ return fullname.name.substring(0, fullname.name.length()-1);
5499
+ }
5500
+
5501
+ return split[0];
5502
+ }
5503
+
5504
+ // Windows
5505
+ assert(split.length == 4);
5506
+
5507
+ return split[0] + ":" + split[1];
50985508 }
50995509
51005510 static String GetBump(cTexture fullname)
....@@ -5103,10 +5513,38 @@
51035513 return "";
51045514
51055515 // System.out.println("Fullname = " + fullname);
5106
- if (fullname.name.indexOf(":") == -1)
5107
- return "";
5108
-
5109
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5516
+ // Does not work on Windows due to C:
5517
+// if (fullname.name.indexOf(":") == -1)
5518
+// return "";
5519
+//
5520
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5521
+ String[] split = fullname.name.split(":");
5522
+
5523
+ if (split.length == 0)
5524
+ {
5525
+ return "";
5526
+ }
5527
+
5528
+ if (split.length == 1)
5529
+ {
5530
+ return "";
5531
+ }
5532
+
5533
+ if (split.length == 2)
5534
+ {
5535
+ if (fullname.name.endsWith(":"))
5536
+ {
5537
+ // Windows
5538
+ return "";
5539
+ }
5540
+
5541
+ return split[1];
5542
+ }
5543
+
5544
+ // Windows
5545
+ assert(split.length == 4);
5546
+
5547
+ return split[2] + ":" + split[3];
51105548 }
51115549
51125550 String GetPigmentTexture()
....@@ -5180,7 +5618,7 @@
51805618 System.out.print("; textures = " + textures);
51815619 System.out.println("; usedtextures = " + usedtextures);
51825620
5183
- if (GetTextures() == null)
5621
+ if (GetTextures() == null) // What is that??
51845622 GetTextures().name = ":";
51855623
51865624 String texname = tex;
....@@ -5211,6 +5649,43 @@
52115649 child.ResetPigmentTexture();
52125650 blockloop = false;
52135651 }
5652
+ }
5653
+
5654
+ UUID GetUUID()
5655
+ {
5656
+ if (uuid == null)
5657
+ {
5658
+ // Serial
5659
+ uuid = UUID.randomUUID();
5660
+ }
5661
+
5662
+ return uuid;
5663
+ }
5664
+
5665
+ Object3D GetObject(UUID uid)
5666
+ {
5667
+ if (blockloop)
5668
+ return null;
5669
+
5670
+ if (GetUUID().equals(uid))
5671
+ return this;
5672
+
5673
+ int nb = Size();
5674
+ for (int i = 0; i < nb; i++)
5675
+ {
5676
+ Object3D child = (Object3D) get(i);
5677
+
5678
+ if (child == null)
5679
+ continue;
5680
+
5681
+ blockloop = true;
5682
+ Object3D obj = child.GetObject(uid);
5683
+ blockloop = false;
5684
+ if (obj != null)
5685
+ return obj;
5686
+ }
5687
+
5688
+ return null;
52145689 }
52155690
52165691 void SetBumpTexture(String tex)
....@@ -5249,25 +5724,33 @@
52495724 }
52505725 }
52515726
5252
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5727
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52535728 {
52545729 Draw(display, root, selected, blocked);
52555730 }
52565731
5257
- static cMaterial[] materialstack = new cMaterial[65536];
5258
- static boolean[] selectedstack = new boolean[65536];
5259
- static int materialdepth = 0;
5260
-
52615732 boolean NeedSupport()
52625733 {
52635734 return
5264
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5735
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52655736 // PROBLEM with CROWD!!
5266
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5737
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52675738 }
52685739
5740
+ static boolean DEBUG_SELECTION = false;
52695741
5270
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5742
+ boolean IsLive()
5743
+ {
5744
+ if (live)
5745
+ return true;
5746
+
5747
+ if (parent == null)
5748
+ return false;
5749
+
5750
+ return parent.IsLive();
5751
+ }
5752
+
5753
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52715754 {
52725755 Invariants(); // june 2013
52735756
....@@ -5276,8 +5759,8 @@
52765759 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52775760 }
52785761
5279
- if (display.drawMode == CameraPane.SELECTION &&
5280
- hide)
5762
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5763
+ (hide || dontselect))
52815764 return;
52825765
52835766 if (name != null && name.contains("sclera"))
....@@ -5295,7 +5778,7 @@
52955778 if (this instanceof Checker)
52965779 return;
52975780
5298
- if (display.drawMode == display.SHADOW && PASSTEST)
5781
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52995782 return;
53005783
53015784 if (count <= 0)
....@@ -5303,13 +5786,13 @@
53035786 return;
53045787 }
53055788
5306
- if ((//display.drawMode == CameraPane.SHADOW ||
5307
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5789
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5790
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53085791 {
53095792 return;
53105793 }
53115794
5312
- javax.media.opengl.GL gl = display.GetGL();
5795
+ //javax.media.opengl.GL gl = display.GetGL();
53135796
53145797 /*
53155798 if (touched)
....@@ -5328,7 +5811,7 @@
53285811 support = support;
53295812
53305813 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5331
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5814
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53325815
53335816 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53345817 {
....@@ -5345,15 +5828,17 @@
53455828
53465829 boolean compiled = false;
53475830
5348
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5831
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53495832
5350
- if (!selectmode && //display.drawMode != display.SELECTION &&
5351
- (touched || (bRep != null && bRep.displaylist <= 0)))
5833
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5834
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5835
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
53525836 {
5353
- display.lighttouched = true;
5837
+ Globals.lighttouched = true;
53545838 } // all panes...
5355
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5356
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5839
+
5840
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5841
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53575842 (touched || (bRep != null && bRep.displaylist <= 0)))
53585843 {
53595844 if (!(this instanceof Composite))
....@@ -5361,7 +5846,7 @@
53615846 //if (displaylist == -1 && usecalllists)
53625847 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53635848 {
5364
- bRep.displaylist = gl.glGenLists(1);
5849
+ bRep.displaylist = display.GenList();
53655850 assert(bRep.displaylist != 0);
53665851 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53675852 //System.out.println("\tgen list " + list);
....@@ -5373,18 +5858,20 @@
53735858 if (usecalllists)
53745859 {
53755860 // System.err.println("new list " + bRep.displaylist + " for " + this);
5376
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5861
+ display.NewList(bRep.displaylist);
53775862 }
5863
+
53785864 CallList(display, root, selected, blocked);
5865
+
53795866 // compiled = true;
53805867 if (usecalllists)
53815868 {
53825869 // System.err.println("end list " + bRep.displaylist + " for " + this);
5383
- gl.glEndList();
5870
+ display.EndList();
53845871 }
53855872 //gl.glDrawBuffer(gl.GL_BACK);
53865873 // XXX touched = false;
5387
- display.lighttouched = true; // all panes...
5874
+ Globals.lighttouched = true; // all panes...
53885875 }
53895876
53905877 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5423,12 +5910,12 @@
54235910
54245911 // frustum culling
54255912 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5426
- && display.drawMode != CameraPane.SELECTION)
5913
+ && display.DrawMode() != iCameraPane.SELECTION)
54275914 {
5428
- if (display.drawMode == CameraPane.SHADOW)
5915
+ if (display.DrawMode() == iCameraPane.SHADOW)
54295916 {
54305917 if (!link2master // tricky to cull in shadow mode.
5431
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5918
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54325919 {
54335920 //System.out.print("CULLED");
54345921 culled = true;
....@@ -5436,7 +5923,7 @@
54365923 }
54375924 else
54385925 //GetBRep().getBounds(v0, v1, this);
5439
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5926
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54405927 culled = true;
54415928
54425929 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5472,11 +5959,12 @@
54725959
54735960
54745961 if (!culled)
5475
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5962
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54765963 {
54775964 if (GetBRep() != null)
54785965 {
5479
- CameraPane.NextIndex(this, gl);
5966
+ display.NextIndex();
5967
+
54805968 // vertex color conflict : gl.glCallList(list);
54815969 DrawNode(display, root, selected);
54825970 if (this instanceof BezierPatch)
....@@ -5498,55 +5986,7 @@
54985986 color[2] /= 2;
54995987 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55005988 */
5501
- if (material != null)
5502
- {
5503
- materialstack[materialdepth] = material;
5504
- selectedstack[materialdepth] = selected;
5505
- cStatic.objectstack[materialdepth++] = this;
5506
- //System.out.println("material " + material);
5507
- //Applet3D.tracein(this, selected);
5508
- display.vector2buffer = projectedVertices;
5509
- if (this instanceof Camera)
5510
- {
5511
- display.options1[0] = material.shift;
5512
- //System.out.println("shift " + material.shift);
5513
- display.options1[1] = material.lightarea;
5514
- display.options1[2] = material.shadowbias;
5515
- display.options1[3] = material.aniso;
5516
- display.options1[4] = material.anisoV;
5517
- display.options2[0] = material.opacity;
5518
- display.options2[1] = material.diffuse;
5519
- display.options2[2] = material.factor;
5520
-
5521
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5522
- display.options4[0] = material.cameralight/0.2f;
5523
- display.options4[1] = material.subsurface;
5524
- display.options4[2] = material.sheen;
5525
-
5526
- // if (display.CURRENTANTIALIAS > 0)
5527
- // display.options3[3] /= 4;
5528
-
5529
- /*
5530
- System.out.println("Focus = " + display.options1[0]);
5531
- System.out.println("Aperture = " + display.options1[1]);
5532
- System.out.println("ShadowBlur = " + display.options1[2]);
5533
- System.out.println("Antialiasing = " + display.options1[3]);
5534
- System.out.println("Fog = " + display.options2[0]);
5535
- System.out.println("Intensity = " + display.options2[1]);
5536
- System.out.println("Elevation = " + display.options2[2]);
5537
- /**/
5538
- } else
5539
- {
5540
- material.Draw(display, selected);
5541
- }
5542
- } else
5543
- {
5544
- if (selected && CameraPane.flash)
5545
- {
5546
- display.modelParams4[1] = 100;
5547
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5548
- }
5549
- }
5989
+ display.PushMaterial(this, selected);
55505990
55515991 //System.out.println("call list " + list);
55525992 //System.out.println();
....@@ -5565,7 +6005,28 @@
55656005 tex = GetTextures();
55666006 }
55676007
5568
- display.BindTextures(tex, texres);
6008
+ boolean failedPigment = false;
6009
+ boolean failedBump = false;
6010
+
6011
+ try
6012
+ {
6013
+ display.BindPigmentTexture(tex, texres);
6014
+ }
6015
+ catch (Exception e)
6016
+ {
6017
+ System.err.println("FAILED: " + this);
6018
+ failedPigment = true;
6019
+ }
6020
+
6021
+ try
6022
+ {
6023
+ display.BindBumpTexture(tex, texres);
6024
+ }
6025
+ catch (Exception e)
6026
+ {
6027
+ //System.err.println("FAILED: " + this);
6028
+ failedBump = true;
6029
+ }
55696030
55706031 if (!compiled)
55716032 {
....@@ -5581,30 +6042,19 @@
55816042
55826043 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55836044 assert(bRep.displaylist != 0);
5584
- gl.glCallList(bRep.displaylist);
6045
+ display.CallList(bRep.displaylist);
55856046 // june 2013 drawSelf(display, root, selected);
55866047 }
55876048 }
55886049 }
55896050
5590
- display.ReleaseTextures(tex);
5591
-
5592
- //if (parent != null && parent.GetMaterial() != null)
5593
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5594
- if (material != null)
5595
- {
5596
- materialdepth -= 1;
5597
- if (materialdepth > 0)
5598
- {
5599
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5600
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5601
- }
5602
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5603
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5604
- {
5605
- display.modelParams4[1] = GetMaterial().cameralight;
5606
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5607
- }
6051
+ if (!failedBump)
6052
+ display.ReleaseBumpTexture(tex);
6053
+
6054
+ if (!failedPigment)
6055
+ display.ReleasePigmentTexture(tex);
6056
+
6057
+ display.PopMaterial(this, selected);
56086058 }
56096059
56106060 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5646,7 +6096,7 @@
56466096 // resetMasterNode();
56476097 }
56486098
5649
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6099
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56506100 {
56516101 if (GetBRep() == null)
56526102 {
....@@ -5729,8 +6179,11 @@
57296179 boolean flipV = false; // true;
57306180 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57316181
5732
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6182
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57336183 {
6184
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6185
+ return;
6186
+
57346187 if (hide)
57356188 return;
57366189 // shadow optimisation
....@@ -5788,16 +6241,7 @@
57886241 // // ??????????????????????????? Touch();
57896242 // }
57906243
5791
- if (material != null)
5792
- {
5793
- materialstack[materialdepth] = material;
5794
- selectedstack[materialdepth] = selected;
5795
- cStatic.objectstack[materialdepth++] = this;
5796
- //System.out.println("material " + material);
5797
- //Applet3D.tracein("selected ", selected);
5798
- display.vector2buffer = projectedVertices;
5799
- material.Draw(display, selected);
5800
- }
6244
+display.PushMaterial2(this, selected);
58016245
58026246 Object3D child;
58036247 boolean sel;
....@@ -5849,19 +6293,7 @@
58496293 */
58506294 //depth += 1;
58516295
5852
- if (material != null)
5853
- {
5854
- materialdepth -= 1;
5855
- if (materialdepth > 0)
5856
- {
5857
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5858
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5859
- }
5860
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5861
- //else
5862
- //material.Draw(display, false);
5863
- }
5864
-
6296
+display.PopMaterial2(this);
58656297 /*
58666298 display.ReleaseTextures(tex);
58676299 */
....@@ -5872,10 +6304,13 @@
58726304
58736305 //static cVector min,max;
58746306
5875
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6307
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58766308 {
5877
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6309
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58786310 return; // no shadow for transparent objects
6311
+
6312
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6313
+ return;
58796314
58806315 if (hide)
58816316 return;
....@@ -5917,11 +6352,12 @@
59176352 return;
59186353 }
59196354
6355
+ //bRep.GenUV(1/material.diffuseness);
59206356 // bRep.lock = true;
59216357
5922
- javax.media.opengl.GL gl = display.GetGL();
6358
+ //javax.media.opengl.GL gl = display.GetGL();
59236359
5924
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6360
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59256361 {
59266362 int fc = bRep.FaceCount();
59276363 int vc = bRep.VertexCount();
....@@ -5936,23 +6372,7 @@
59366372
59376373 bRep.getMinMax(min, max, 100);
59386374
5939
- gl.glBegin(gl.GL_LINES);
5940
-
5941
- gl.glVertex3d(min.x, min.y, min.z);
5942
- gl.glVertex3d(min.x, min.y, max.z);
5943
- gl.glVertex3d(min.x, min.y, min.z);
5944
- gl.glVertex3d(min.x, max.y, min.z);
5945
- gl.glVertex3d(min.x, min.y, min.z);
5946
- gl.glVertex3d(max.x, min.y, min.z);
5947
-
5948
- gl.glVertex3d(max.x, max.y, max.z);
5949
- gl.glVertex3d(min.x, max.y, max.z);
5950
- gl.glVertex3d(max.x, max.y, max.z);
5951
- gl.glVertex3d(max.x, min.y, max.z);
5952
- gl.glVertex3d(max.x, max.y, max.z);
5953
- gl.glVertex3d(max.x, max.y, min.z);
5954
-
5955
- gl.glEnd();
6375
+ display.DrawBox(min, max);
59566376
59576377 return;
59586378 }
....@@ -5996,7 +6416,7 @@
59966416 {
59976417 //throw new Error();
59986418
5999
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6419
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60006420
60016421 int[] strips = bRep.getRawIndices();
60026422
....@@ -6006,178 +6426,19 @@
60066426 new Exception().printStackTrace();
60076427 return;
60086428 }
6009
-
6010
- // TRIANGLE STRIP ARRAY
6011
- if (bRep.trimmed)
6429
+
6430
+ if (dontselect)
60126431 {
6013
- float[] v = bRep.getRawVertices();
6014
- float[] n = bRep.getRawNormals();
6015
- float[] c = bRep.getRawColors();
6016
- float[] uv = bRep.getRawUVMap();
6017
-
6018
- int count2 = 0;
6019
- int count3 = 0;
6020
-
6021
- if (n.length > 0)
6022
- {
6023
- for (int i = 0; i < strips.length; i++)
6024
- {
6025
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6026
-
6027
- /*
6028
- boolean locked = false;
6029
- float eps = 0.1f;
6030
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6031
-
6032
- int dot = 0;
6033
-
6034
- if ((dot&1) == 0)
6035
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6036
-
6037
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6038
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6039
- else
6040
- {
6041
- locked = true;
6042
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6043
- }
6044
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6045
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6046
- if (hasnorm)
6047
- {
6048
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6049
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6050
- }
6051
-
6052
- if ((dot&4) == 0)
6053
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6054
-
6055
- if (wrap || !locked && (dot&8) != 0)
6056
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6057
- else
6058
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6059
-
6060
- f.dot = dot;
6061
- */
6062
-
6063
- if (!selectmode)
6064
- {
6065
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6066
- {
6067
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6068
- } else
6069
- {
6070
- gl.glNormal3f(0, 0, 1);
6071
- }
6072
-
6073
- if (c != null)
6074
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6075
- {
6076
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6077
- }
6078
- }
6079
- if (flipV)
6080
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6081
- else
6082
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6083
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6084
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6085
-
6086
- count2 += 2;
6087
- count3 += 3;
6088
- if (!selectmode)
6089
- {
6090
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6091
- {
6092
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6093
- } else
6094
- {
6095
- gl.glNormal3f(0, 0, 1);
6096
- }
6097
- if (c != null)
6098
- {
6099
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6100
- }
6101
- }
6102
- if (flipV)
6103
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6104
- else
6105
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6106
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6107
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6108
-
6109
- count2 += 2;
6110
- count3 += 3;
6111
- for (int j = 0; j < strips[i] - 2; j++)
6112
- {
6113
- //gl.glTexCoord2d(...);
6114
- if (!selectmode)
6115
- {
6116
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6117
- {
6118
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6119
- } else
6120
- {
6121
- gl.glNormal3f(0, 0, 1);
6122
- }
6123
- if (c != null)
6124
- {
6125
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6126
- }
6127
- }
6128
-
6129
- if (flipV)
6130
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6131
- else
6132
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6133
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6134
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6135
- count2 += 2;
6136
- count3 += 3;
6137
- }
6138
-
6139
- gl.glEnd();
6140
- }
6141
- }
6142
-
6143
- assert count3 == v.length;
6432
+ //bRep.GenerateNormalsMINE();
61446433 }
6145
- else // !trimmed
6146
- {
6147
- int count = 0;
6148
- for (int i = 0; i < strips.length; i++)
6149
- {
6150
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6151
-
6152
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6153
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6154
-
6155
- drawVertex(gl, p, selectmode);
6156
- drawVertex(gl, q, selectmode);
6157
-
6158
- for (int j = 0; j < strips[i] - 2; j++)
6159
- {
6160
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6161
-
6162
-// if (j%2 == 0)
6163
-// drawFace(p, q, r, display, null);
6164
-// else
6165
-// drawFace(p, r, q, display, null);
6166
-
6167
-// p = q;
6168
-// q = r;
6169
- drawVertex(gl, r, selectmode);
6170
- }
6171
-
6172
- gl.glEnd();
6173
- }
6174
- }
6434
+
6435
+ display.DrawGeometry(bRep, flipV, selectmode);
61756436 } else // catch (Error e)
61766437 {
61776438 // TRIANGLE ARRAY
61786439 if (IsOpaque()) // Static())
61796440 {
6180
- gl.glBegin(gl.GL_TRIANGLES);
6441
+ display.StartTriangles();
61816442 int facecount = bRep.FaceCount();
61826443 for (int i = 0; i < facecount; i++)
61836444 {
....@@ -6240,9 +6501,9 @@
62406501 // // r.norm.dot(v3) > -0.5)
62416502 // // continue;
62426503
6243
- drawFace(p, q, r, display, face);
6504
+ display.DrawFace(this, p, q, r, face);
62446505 }
6245
- gl.glEnd();
6506
+ display.EndTriangles();
62466507 }
62476508 else
62486509 {
....@@ -6271,8 +6532,8 @@
62716532 //System.out.println("SORT");
62726533
62736534 java.util.Arrays.sort(facescompare);
6274
-
6275
- gl.glBegin(gl.GL_TRIANGLES);
6535
+
6536
+ display.StartTriangles();
62766537 for (int i = 0; i < facecount; i++)
62776538 {
62786539 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6284,13 +6545,14 @@
62846545 Vertex q = bRep.GetVertex(face.q);
62856546 Vertex r = bRep.GetVertex(face.r);
62866547
6287
- drawFace(p, q, r, display, face);
6548
+ display.DrawFace(this, p, q, r, face);
62886549 }
6289
- gl.glEnd();
6550
+ display.EndTriangles();
62906551 }
62916552
62926553 if (false) // live && support != null && support.bRep != null) // debug weights
62936554 {
6555
+ /*
62946556 gl.glDisable(gl.GL_LIGHTING);
62956557 float[] colorV = new float[3];
62966558
....@@ -6369,6 +6631,7 @@
63696631 // gl.glEnd();
63706632 }
63716633 }
6634
+ */
63726635 }
63736636 }
63746637
....@@ -6413,7 +6676,7 @@
64136676 center.add(r);
64146677 center.mul(1.0/3);
64156678
6416
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6679
+ center.sub(Globals.theRenderer.EyeCamera().location);
64176680
64186681 distance = center.dot(center);
64196682 }
....@@ -6424,347 +6687,11 @@
64246687
64256688 transient FaceCompare[] facescompare = null;
64266689
6427
- void SetColor(CameraPane display, Vertex p0)
6428
- {
6429
- if (display.RENDERPROGRAM == 0)
6430
- {
6431
- float r = 0;
6432
- if (bRep != null)
6433
- {
6434
- if (bRep.stripified)
6435
- {
6436
- r = 1;
6437
- }
6438
- }
6439
- float g = 0;
6440
- if (bRep != null)
6441
- {
6442
- if (bRep.trimmed)
6443
- {
6444
- g = 1;
6445
- }
6446
- }
6447
- float b = 0;
6448
- if (support != null && link2master)
6449
- {
6450
- b = 1;
6451
- }
6452
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6453
- return;
6454
- }
6455
-
6456
- if (display.drawMode != CameraPane.SHADOW)
6457
- return;
6458
-
6459
- javax.media.opengl.GL gl = display.GetGL();
6460
-// if (true) return;
6461
-// float ao = p.AO;
6462
-//
6463
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6464
-// // ao = 1;
6465
-//
6466
-// gl.glColor4f(ao, ao, ao, 1);
6467
-
6468
-// CameraPane.selectedpoint.
6469
-// getAverage(cStatic.point1, true);
6470
- if (CameraPane.pointflow == null) // !random) // live)
6471
- {
6472
- return;
6473
- }
6474
-
6475
- cStatic.point1.set(0,0,0);
6476
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6477
-
6478
- cStatic.point1.sub(p0);
6479
-
6480
-
6481
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6482
-// {
6483
-// return;
6484
-// }
6485
-
6486
- //if (true)
6487
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6488
- {
6489
- return;
6490
- }
6491
-
6492
- float[] colorV = new float[3];
6493
-
6494
- if (false) // marked)
6495
- {
6496
- // debug rigging weights
6497
- for (int object = 0; object < p0.vertexlinks.length; object++)
6498
- {
6499
- float weight = p0.weights[object] / p0.totalweight;
6500
-
6501
- // if (weight < 0.1)
6502
- // {
6503
- // assert(weight == 0);
6504
- // continue;
6505
- // }
6506
-
6507
- if (p0.vertexlinks[object] == -1)
6508
- continue;
6509
-
6510
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6511
-
6512
- int color = //1 << object; //
6513
- //p.vertexlinks.length;
6514
- support.bRep.supports[p0.closestsupport].links[object];
6515
- colorV[2] += (color & 1) * weight;
6516
- colorV[1] += ((color & 2) >> 1) * weight;
6517
- colorV[0] += ((color & 4) >> 2) * weight;
6518
- }
6519
- }
6520
- else
6521
- {
6522
- if (drawingstarted)
6523
- {
6524
- // find next point
6525
- if (bRep.GetVertex(0).faceindices == null)
6526
- {
6527
- bRep.InitFaceIndices();
6528
- }
6529
-
6530
- double ymin = p0.y;
6531
-
6532
- Vertex newp = p0;
6533
-
6534
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6535
- {
6536
- int fi = p0.faceindices[fii];
6537
-
6538
- if (fi == -1)
6539
- break;
6540
-
6541
- Face f = bRep.GetFace(fi);
6542
-
6543
- Vertex p = bRep.GetVertex(f.p);
6544
- Vertex q = bRep.GetVertex(f.q);
6545
- Vertex r = bRep.GetVertex(f.r);
6546
-
6547
- int swap = (int)(Math.random()*3);
6548
-
6549
-// for (int s=swap; --s>=0;)
6550
-// {
6551
-// Vertex t = p;
6552
-// p = q;
6553
-// q = r;
6554
-// r = t;
6555
-// }
6556
- if (ymin > p.y)
6557
- {
6558
- ymin = p.y;
6559
- newp = p;
6560
-// break;
6561
- }
6562
- if (ymin > q.y)
6563
- {
6564
- ymin = q.y;
6565
- newp = q;
6566
-// break;
6567
- }
6568
- if (ymin > r.y)
6569
- {
6570
- ymin = r.y;
6571
- newp = r;
6572
-// break;
6573
- }
6574
- }
6575
-
6576
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6577
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6578
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6579
-
6580
- drawingstarted = false;
6581
-
6582
- // return;
6583
- }
6584
-
6585
- if (false) // CameraPane.DRAW
6586
- {
6587
- p0.AO = colorV[0] = 2;
6588
- colorV[1] = 2;
6589
- colorV[2] = 2;
6590
- }
6591
-
6592
- CameraPane.pointflow.add(p0);
6593
- CameraPane.pointflow.Touch();
6594
- }
6595
-
6596
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6597
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6598
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6599
- }
6600
-
66016690 void Print(Vertex v)
66026691 {
66036692 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66046693 }
66056694
6606
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6607
- {
6608
- if (!selectmode)
6609
- {
6610
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6611
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6612
-
6613
- if (flipV)
6614
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6615
- else
6616
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6617
- }
6618
-
6619
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6620
- }
6621
-
6622
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6623
- CameraPane display, Face face)
6624
- {
6625
- if (pv.y == -10000 ||
6626
- qv.y == -10000 ||
6627
- rv.y == -10000)
6628
- return;
6629
-
6630
-// float b = f.nbiterations & 1;
6631
-// float g = (f.nbiterations>>1) & 1;
6632
-// float r = (f.nbiterations>>2) & 1;
6633
-//
6634
-// //if (f.weight == 10000)
6635
-// //{
6636
-// // r = 1; g = b = 0;
6637
-// //}
6638
-// //else
6639
-// //{
6640
-// // assert(f.weight < 10000);
6641
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6642
-// if (r<0)
6643
-// assert(r>=0);
6644
-// //}
6645
-
6646
- javax.media.opengl.GL gl = display.GetGL();
6647
-
6648
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6649
-
6650
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6651
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6652
- {
6653
- //gl.glBegin(gl.GL_TRIANGLES);
6654
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6655
- if (!hasnorm)
6656
- {
6657
- // System.out.println("FUCK!!");
6658
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6659
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6660
- LA.vecCross(v0, v1, v2);
6661
- LA.vecNormalize(v2);
6662
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6663
- }
6664
-
6665
- if (hasnorm)
6666
- {
6667
-// if (!pv.norm.normalized())
6668
-// assert(pv.norm.normalized());
6669
-
6670
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6671
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6672
- }
6673
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6674
- SetColor(display, pv);
6675
- //gl.glColor4f(r, g, b, 1);
6676
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6677
- if (flipV)
6678
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6679
- else
6680
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6681
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6682
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6683
-// Print(pv);
6684
- if (hasnorm)
6685
- {
6686
-// assert(qv.norm.normalized());
6687
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6688
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6689
- }
6690
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6691
- // boolean locked = false;
6692
- // float eps = 0.1f;
6693
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6694
-
6695
- // int dot = 0; //*/ (int)f.dot;
6696
-
6697
- // if ((dot&1) == 0)
6698
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6699
-
6700
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6701
- if (flipV)
6702
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6703
- else
6704
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6705
- // else
6706
- // {
6707
- // locked = true;
6708
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6709
- // }
6710
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6711
- SetColor(display, qv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6714
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6715
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6716
-// Print(qv);
6717
- if (hasnorm)
6718
- {
6719
-// assert(rv.norm.normalized());
6720
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6721
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6722
- }
6723
-
6724
- // if ((dot&4) == 0)
6725
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6726
-
6727
- // if (wrap || !locked && (dot&8) != 0)
6728
- if (flipV)
6729
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6730
- else
6731
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6732
- // else
6733
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6734
-
6735
- // f.dot = dot;
6736
-
6737
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6738
- SetColor(display, rv);
6739
- //gl.glColor4f(r, g, b, 1);
6740
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6741
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6742
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6743
-// Print(rv);
6744
- //gl.glEnd();
6745
- }
6746
- else
6747
- {
6748
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6749
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6750
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6751
-
6752
- }
6753
-
6754
- if (false) // (attributes & WIREFRAME) != 0)
6755
- {
6756
- gl.glDisable(gl.GL_LIGHTING);
6757
-
6758
- gl.glBegin(gl.GL_LINE_LOOP);
6759
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6760
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6761
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6762
- gl.glEnd();
6763
-
6764
- gl.glEnable(gl.GL_LIGHTING);
6765
- }
6766
- }
6767
-
67686695 void drawSelf(ClickInfo info, int level, boolean select)
67696696 {
67706697 if (bRep == null)
....@@ -7336,83 +7263,84 @@
73367263 int spotw = spot.x + spot.width;
73377264 int spoth = spot.y + spot.height;
73387265 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7339
- if (CameraPane.Xmin > spot.x)
7340
- {
7341
- CameraPane.Xmin = spot.x;
7342
- }
7343
- if (CameraPane.Xmax < spotw)
7344
- {
7345
- CameraPane.Xmax = spotw;
7346
- }
7347
- if (CameraPane.Ymin > spot.y)
7348
- {
7349
- CameraPane.Ymin = spot.y;
7350
- }
7351
- if (CameraPane.Ymax < spoth)
7352
- {
7353
- CameraPane.Ymax = spoth;
7354
- }
7266
+// if (CameraPane.Xmin > spot.x)
7267
+// {
7268
+// CameraPane.Xmin = spot.x;
7269
+// }
7270
+// if (CameraPane.Xmax < spotw)
7271
+// {
7272
+// CameraPane.Xmax = spotw;
7273
+// }
7274
+// if (CameraPane.Ymin > spot.y)
7275
+// {
7276
+// CameraPane.Ymin = spot.y;
7277
+// }
7278
+// if (CameraPane.Ymax < spoth)
7279
+// {
7280
+// CameraPane.Ymax = spoth;
7281
+// }
73557282 spot.translate(32, 32);
73567283 spotw = spot.x + spot.width;
73577284 spoth = spot.y + spot.height;
7358
- info.g.setColor(Color.blue);
7285
+ info.g.setColor(Color.cyan);
73597286 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7360
- if (CameraPane.Xmin > spot.x)
7361
- {
7362
- CameraPane.Xmin = spot.x;
7363
- }
7364
- if (CameraPane.Xmax < spotw)
7365
- {
7366
- CameraPane.Xmax = spotw;
7367
- }
7368
- if (CameraPane.Ymin > spot.y)
7369
- {
7370
- CameraPane.Ymin = spot.y;
7371
- }
7372
- if (CameraPane.Ymax < spoth)
7373
- {
7374
- CameraPane.Ymax = spoth;
7375
- }
7376
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7377
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7287
+// if (CameraPane.Xmin > spot.x)
7288
+// {
7289
+// CameraPane.Xmin = spot.x;
7290
+// }
7291
+// if (CameraPane.Xmax < spotw)
7292
+// {
7293
+// CameraPane.Xmax = spotw;
7294
+// }
7295
+// if (CameraPane.Ymin > spot.y)
7296
+// {
7297
+// CameraPane.Ymin = spot.y;
7298
+// }
7299
+// if (CameraPane.Ymax < spoth)
7300
+// {
7301
+// CameraPane.Ymax = spoth;
7302
+// }
7303
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7304
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73787305 spot.translate(0, -32);
7379
- info.g.setColor(Color.green);
7306
+ info.g.setColor(Color.yellow);
73807307 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7381
- if (CameraPane.Xmin > spot.x)
7382
- {
7383
- CameraPane.Xmin = spot.x;
7384
- }
7385
- if (CameraPane.Xmax < spotw)
7386
- {
7387
- CameraPane.Xmax = spotw;
7388
- }
7389
- if (CameraPane.Ymin > spot.y)
7390
- {
7391
- CameraPane.Ymin = spot.y;
7392
- }
7393
- if (CameraPane.Ymax < spoth)
7394
- {
7395
- CameraPane.Ymax = spoth;
7396
- }
7397
- info.g.drawArc(boundary.x, boundary.y,
7398
- boundary.width, boundary.height, 0, 360);
7308
+ info.g.setColor(Color.green);
7309
+// if (CameraPane.Xmin > spot.x)
7310
+// {
7311
+// CameraPane.Xmin = spot.x;
7312
+// }
7313
+// if (CameraPane.Xmax < spotw)
7314
+// {
7315
+// CameraPane.Xmax = spotw;
7316
+// }
7317
+// if (CameraPane.Ymin > spot.y)
7318
+// {
7319
+// CameraPane.Ymin = spot.y;
7320
+// }
7321
+// if (CameraPane.Ymax < spoth)
7322
+// {
7323
+// CameraPane.Ymax = spoth;
7324
+// }
7325
+ info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY,
7326
+ (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360);
73997327 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7400
- if (CameraPane.Xmin > boundary.x)
7401
- {
7402
- CameraPane.Xmin = boundary.x;
7403
- }
7404
- if (CameraPane.Xmax < boundary.x + boundary.width)
7405
- {
7406
- CameraPane.Xmax = boundary.x + boundary.width;
7407
- }
7408
- if (CameraPane.Ymin > boundary.y)
7409
- {
7410
- CameraPane.Ymin = boundary.y;
7411
- }
7412
- if (CameraPane.Ymax < boundary.y + boundary.height)
7413
- {
7414
- CameraPane.Ymax = boundary.y + boundary.height;
7415
- }
7328
+// if (CameraPane.Xmin > boundary.x)
7329
+// {
7330
+// CameraPane.Xmin = boundary.x;
7331
+// }
7332
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7333
+// {
7334
+// CameraPane.Xmax = boundary.x + boundary.width;
7335
+// }
7336
+// if (CameraPane.Ymin > boundary.y)
7337
+// {
7338
+// CameraPane.Ymin = boundary.y;
7339
+// }
7340
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7341
+// {
7342
+// CameraPane.Ymax = boundary.y + boundary.height;
7343
+// }
74167344 return;
74177345 }
74187346 }
....@@ -7429,7 +7357,7 @@
74297357 startX = info.x;
74307358 startY = info.y;
74317359
7432
- hitSomething = 0;
7360
+ hitSomething = -1;
74337361 cVector origin = new cVector();
74347362 //LA.xformPos(origin, toParent, origin);
74357363 Rectangle spot = new Rectangle();
....@@ -7462,7 +7390,7 @@
74627390 }
74637391
74647392 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.META) != 0;
7393
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74667394 //System.out.println("modified = " + modified);
74677395 //new Exception().printStackTrace();
74687396 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7418,7 @@
74907418 return true;
74917419 }
74927420
7493
- void doEditDrag0(ClickInfo info)
7421
+ void doEditDrag0(ClickInfo info, boolean opposite)
74947422 {
74957423 if (hitSomething == 0)
74967424 {
....@@ -7505,6 +7433,7 @@
75057433 //System.out.println("hitSomething = " + hitSomething);
75067434
75077435 double scale = 0.005f * info.camera.Distance();
7436
+
75087437 cVector xlate = new cVector();
75097438 //cVector xlate2 = new cVector();
75107439 switch (hitSomething)
....@@ -7515,9 +7444,9 @@
75157444
75167445 case hitCenter: // Translate
75177446
7518
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7447
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75197448
7520
- if (modified)
7449
+ if (modified || opposite)
75217450 {
75227451 //assert(false);
75237452 /*
....@@ -7563,10 +7492,10 @@
75637492 }
75647493 LA.xformDir(up, ClickInfo.matbuffer, up);
75657494 // if (!CameraPane.LOCALTRANSFORM)
7566
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7495
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75677496 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75687497 // if (!CameraPane.LOCALTRANSFORM)
7569
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7498
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75707499 //LA.vecCross(up, cVector.Z, right2);
75717500
75727501 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7611,6 +7540,7 @@
76117540
76127541 if (modified)
76137542 {
7543
+ // Rotate 90 degrees
76147544 angle /= (Math.PI / 4);
76157545 angle = Math.floor(angle + 0.5);
76167546 angle *= (Math.PI / 4);
....@@ -7624,7 +7554,7 @@
76247554 }
76257555 /**/
76267556
7627
- switch (info.pane.renderCamera.viewCode)
7557
+ switch (info.pane.RenderCamera().viewCode)
76287558 {
76297559 case 1: // '\001'
76307560 LA.matZRotate(toParent, angle);
....@@ -7652,24 +7582,27 @@
76527582
76537583 case hitScale: // scale
76547584 double hScale = (double) (info.x - centerPt.x) / 32;
7585
+ double sign = 1;
7586
+ if (hScale < 0)
7587
+ {
7588
+ sign = -1;
7589
+ }
7590
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76557591 if (hScale < 0.01)
76567592 {
7657
- hScale = 0.01;
7593
+ //hScale = 0.01;
76587594 }
7659
- hScale = Math.pow(hScale, scale * 50);
7660
- if (hScale < 0.01)
7661
- {
7662
- hScale = 0.01;
7663
- }
7595
+
76647596 double vScale = (double) (info.y - centerPt.y) / 32;
7665
- if (vScale < 0.01)
7597
+ sign = 1;
7598
+ if (vScale < 0)
76667599 {
7667
- vScale = 0.01;
7600
+ sign = -1;
76687601 }
7669
- vScale = Math.pow(vScale, scale * 50);
7602
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76707603 if (vScale < 0.01)
76717604 {
7672
- vScale = 0.01;
7605
+ //vScale = 0.01;
76737606 }
76747607 LA.matCopy(startMat, toParent);
76757608 /**/
....@@ -7680,39 +7613,47 @@
76807613 }
76817614 /**/
76827615
7683
- switch (info.pane.renderCamera.viewCode)
7616
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7617
+
7618
+ if (totalScale < 0.01)
7619
+ {
7620
+ totalScale = 0.01;
7621
+ }
7622
+
7623
+ switch (info.pane.RenderCamera().viewCode)
76847624 {
76857625 case 3: // '\001'
7686
- if (modified)
7626
+ if (modified || opposite)
76877627 {
76887628 //LA.matScale(toParent, 1, hScale, vScale);
7689
- LA.matScale(toParent, vScale, 1, 1);
7629
+ LA.matScale(toParent, totalScale, 1, 1);
76907630 } // vScale, 1);
76917631 else
76927632 {
7693
- LA.matScale(toParent, vScale, vScale, vScale);
7633
+ // EXCEPTION!
7634
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
76947635 } // vScale, 1);
76957636 break;
76967637
76977638 case 2: // '\002'
7698
- if (modified)
7639
+ if (modified || opposite)
76997640 {
77007641 //LA.matScale(toParent, hScale, 1, vScale);
7701
- LA.matScale(toParent, 1, vScale, 1);
7642
+ LA.matScale(toParent, 1, totalScale, 1);
77027643 } else
77037644 {
7704
- LA.matScale(toParent, vScale, 1, vScale);
7645
+ LA.matScale(toParent, totalScale, 1, totalScale);
77057646 }
77067647 break;
77077648
77087649 case 1: // '\003'
7709
- if (modified)
7650
+ if (modified || opposite)
77107651 {
77117652 //LA.matScale(toParent, hScale, vScale, 1);
7712
- LA.matScale(toParent, 1, 1, vScale);
7653
+ LA.matScale(toParent, 1, 1, totalScale);
77137654 } else
77147655 {
7715
- LA.matScale(toParent, vScale, vScale, 1);
7656
+ LA.matScale(toParent, totalScale, totalScale, 1);
77167657 }
77177658 break;
77187659 }
....@@ -7733,7 +7674,7 @@
77337674 if (parent == null)
77347675 {
77357676 System.out.println("NULL PARENT");
7736
- new Exception().printStackTrace();
7677
+ //new Exception().printStackTrace();
77377678 } else
77387679 {
77397680 if (parent instanceof BezierPatch)
....@@ -7845,14 +7786,22 @@
78457786 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78467787 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78477788 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7789
+
7790
+ String objname;
7791
+
78487792 if (false) //parent != null)
78497793 {
7850
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7794
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78517795 } else
78527796 {
7853
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7797
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78547798 } // + super.toString();
78557799 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7800
+
7801
+ if (!Globals.ADVANCED)
7802
+ return objname;
7803
+
7804
+ return objname + " " + System.identityHashCode(this);
78567805 }
78577806
78587807 public int hashCode()
....@@ -7908,6 +7857,7 @@
79087857 objectUI.closeUI();
79097858 if (editWindow != null)
79107859 {
7860
+ editWindow.ctrlPanel.FlushUI();
79117861 editWindow.refreshContents();
79127862 } // ? new
79137863 objectUI = null;
....@@ -7916,6 +7866,10 @@
79167866 {
79177867 editWindow = null;
79187868 } // ?
7869
+ }
7870
+ else
7871
+ {
7872
+ //editWindow.closeUI();
79197873 }
79207874 }
79217875
....@@ -7928,7 +7882,7 @@
79287882 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79297883
79307884 Object3D /*Composite*/ parent;
7931
- Object3D /*Composite*/ fileparent;
7885
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79327886
79337887 double[][] toParent; // dynamic matrix
79347888 double[][] fromParent;
....@@ -8043,7 +7997,7 @@
80437997 {
80447998 assert(bRep != null);
80457999 if (!(support instanceof GenericJoint)) // support.bRep != null)
8046
- GrafreeD.Assert(support.bRep == bRep.support);
8000
+ Grafreed.Assert(support.bRep == bRep.support);
80478001 }
80488002 else
80498003 {
....@@ -8074,6 +8028,10 @@
80748028 }
80758029
80768030 transient ObjEditor editWindow;
8031
+ transient ObjEditor manipWindow;
8032
+
8033
+ transient boolean pinned;
8034
+
80778035 transient ObjectUI objectUI;
80788036 public static int povDepth = 0;
80798037 private static cVector tbMin = new cVector();
....@@ -8092,9 +8050,9 @@
80928050 private static cVector edge2 = new cVector();
80938051 //private static cVector norm = new cVector();
80948052 /*transient private*/ int hitSomething;
8095
- private static final int hitCenter = 1;
8096
- private static final int hitScale = 2;
8097
- private static final int hitRotate = 3;
8053
+ static final int hitCenter = 1;
8054
+ static final int hitScale = 2;
8055
+ static final int hitRotate = 3;
80988056 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80998057 /*transient*/ private Point centerPt;
81008058 /*transient*/ private int startX;
....@@ -8126,6 +8084,8 @@
81268084 {
81278085 Object3D targ = this;
81288086
8087
+ targ.NORMALPUSH = obj.NORMALPUSH;
8088
+
81298089 if (obj.material != null)
81308090 {
81318091 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))