Normand Briere
2019-06-24 c67da2e5d8655704601d6d06e8bc60aabe212253
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,35 @@
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
28
+ mocap.reader.BVHReader.BVHResult bvh;
29
+ Object3D skeleton;
30
+ //
31
+
2232 ScriptNode scriptnode;
33
+
34
+ void InitOthers()
35
+ {
36
+ if (projectedVertices == null || projectedVertices.length <= 2)
37
+ {
38
+ projectedVertices = new Object3D.cVector2[3];
39
+ }
40
+ for (int i = 0; i < 3; i++)
41
+ {
42
+ projectedVertices[i] = new cVector2(); // Others
43
+ }
44
+ projectedVertices[0].x = 100; // bump
45
+ }
2346
2447 void MinMax(cVector minima, cVector maxima)
2548 {
....@@ -86,64 +109,136 @@
86109
87110 // transient boolean reduced; // for morph reduction
88111
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
112
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
113
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
91114
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
115
+ transient Object3D transientsupport; // for cloning
116
+ transient boolean transientlink2master;
94117
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)
118
+ void SaveSupports()
107119 {
108
- bRep.SaveSupports();
109
- }
110
-
111
- for (int i = 0; i < Size(); i++)
112
- {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- continue;
116
- blockloop = true;
117
- child.SaveSupports();
118
- blockloop = false;
119
- }
120
-}
120
+ if (blockloop)
121
+ return;
121122
122
-void RestoreSupports()
123
-{
124
- if (blockloop)
125
- return;
123
+ transientsupport = support;
124
+ transientlink2master = link2master;
126125
127
- support = transientsupport;
128
- link2master = transientlink2master;
129
- transientsupport = null;
130
- transientlink2master = false;
131
-
132
- if (bRep != null)
133
- {
134
- bRep.RestoreSupports();
126
+ support = null;
127
+ link2master = false;
128
+
129
+ if (bRep != null)
130
+ {
131
+ bRep.SaveSupports();
132
+ }
133
+
134
+ for (int i = 0; i < Size(); i++)
135
+ {
136
+ Object3D child = (Object3D) get(i);
137
+ if (child == null)
138
+ continue;
139
+ blockloop = true;
140
+ child.SaveSupports();
141
+ blockloop = false;
142
+ }
135143 }
136
-
137
- for (int i = 0; i < Size(); i++)
144
+
145
+ void RestoreSupports()
138146 {
139
- Object3D child = (Object3D) get(i);
140
- if (child == null)
141
- continue;
142
- blockloop = true;
143
- child.RestoreSupports();
144
- blockloop = false;
147
+ if (blockloop)
148
+ return;
149
+
150
+ support = transientsupport;
151
+ link2master = transientlink2master;
152
+ transientsupport = null;
153
+ transientlink2master = false;
154
+
155
+ if (bRep != null)
156
+ {
157
+ bRep.RestoreSupports();
158
+ }
159
+
160
+ for (int i = 0; i < Size(); i++)
161
+ {
162
+ Object3D child = (Object3D) get(i);
163
+ if (child == null)
164
+ continue;
165
+ blockloop = true;
166
+ child.RestoreSupports();
167
+ blockloop = false;
168
+ }
145169 }
146
-}
170
+
171
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
172
+ {
173
+ if (hashtable.containsKey(GetUUID()))
174
+ {
175
+ Object3D o = hashtable.get(GetUUID());
176
+
177
+ Grafreed.Assert(this.bRep == o.bRep);
178
+ if (this.bRep != null)
179
+ assert(this.bRep.support == o.transientrep);
180
+
181
+ return;
182
+ }
183
+
184
+ Object3D o = new Object3D();
185
+
186
+ hashtable.put(GetUUID(), o);
187
+
188
+ for (int i=0; i<Size(); i++)
189
+ {
190
+ get(i).ExtractBigData(hashtable);
191
+ }
192
+
193
+ ExtractBigData(o);
194
+ }
195
+
196
+ void ExtractBigData(Object3D o)
197
+ {
198
+ o.bRep = this.bRep;
199
+ if (this.bRep != null)
200
+ {
201
+ o.transientrep = this.bRep.support;
202
+ o.bRep.support = null;
203
+ }
204
+
205
+ // o.support = this.support;
206
+ // o.fileparent = this.fileparent;
207
+ // if (this.bRep != null)
208
+ // o.bRep = this.bRep.support;
209
+
210
+ this.bRep = null;
211
+ // if (this.bRep != null)
212
+ // this.bRep.support = null;
213
+ // this.support = null;
214
+ // this.fileparent = null;
215
+ }
216
+
217
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
218
+ {
219
+ if (!hashtable.containsKey(GetUUID()))
220
+ return;
221
+
222
+ Object3D o = hashtable.get(GetUUID());
223
+
224
+ RestoreBigData(o);
225
+
226
+ hashtable.remove(GetUUID());
227
+
228
+ for (int i=0; i<Size(); i++)
229
+ {
230
+ get(i).RestoreBigData(hashtable);
231
+ }
232
+ }
233
+
234
+ void RestoreBigData(Object3D o)
235
+ {
236
+ this.bRep = o.bRep;
237
+ if (this.bRep != null)
238
+ this.bRep.support = o.transientrep;
239
+ // this.support = o.support;
240
+ // this.fileparent = o.fileparent;
241
+ }
147242
148243 // MOCAP SUPPORT
149244 double tx,ty,tz,rx,ry,rz;
....@@ -286,6 +381,7 @@
286381 }
287382
288383 boolean live = false;
384
+ boolean dontselect = false;
289385 boolean hide = false;
290386 boolean link2master = false; // performs reset support/master at each frame
291387 boolean marked = false; // animation node
....@@ -295,6 +391,8 @@
295391 boolean random = false;
296392 boolean speedup = false;
297393 boolean rewind = false;
394
+
395
+ float NORMALPUSH = 0;
298396
299397 Object3D support;
300398
....@@ -355,7 +453,7 @@
355453
356454 int MemorySize()
357455 {
358
- if (memorysize == 0)
456
+ if (true) // memorysize == 0)
359457 {
360458 try
361459 {
....@@ -415,16 +513,16 @@
415513 {
416514 Object3D copy = this;
417515
418
- Camera parentcam = CameraPane.theRenderer.manipCamera;
516
+ Camera parentcam = Globals.theRenderer.ManipCamera();
419517
420
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
518
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
421519 {
422
- parentcam = CameraPane.theRenderer.cameras[1];
520
+ parentcam = Globals.theRenderer.Cameras()[1];
423521 }
424522
425
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
523
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
426524 {
427
- parentcam = CameraPane.theRenderer.cameras[0];
525
+ parentcam = Globals.theRenderer.Cameras()[0];
428526 }
429527
430528 if (this == parentcam)
....@@ -432,7 +530,7 @@
432530 //assert(this instanceof Camera);
433531
434532 for (int count = parentcam.GetTransformCount(); --count>=0;)
435
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
533
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
436534 }
437535
438536 copy.marked ^= true;
....@@ -452,7 +550,7 @@
452550 //assert(this instanceof Camera);
453551
454552 for (int count = parentcam.GetTransformCount(); --count>=0;)
455
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
553
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
456554 }
457555
458556 copy.Touch(); // display list issue
....@@ -465,12 +563,14 @@
465563 toParent = LA.newMatrix();
466564 fromParent = LA.newMatrix();
467565 }
566
+
468567 if (toParentMarked == null)
469568 {
470569 if (maxcount != 1)
471570 {
472571 new Exception().printStackTrace();
473572 }
573
+
474574 toParentMarked = LA.newMatrix();
475575 fromParentMarked = LA.newMatrix();
476576 }
....@@ -587,7 +687,7 @@
587687 return;
588688 }
589689
590
- if (CameraPane.fromscript)
690
+ if (Globals.fromscript)
591691 {
592692 transformcount = 0;
593693 return;
....@@ -745,7 +845,7 @@
745845
746846 int GetTransformCount()
747847 {
748
- // marde pour serialization de Texture
848
+ // patch pour serialization de Texture
749849 resetmaxcount();
750850 resettransformcount();
751851 resetstep();
....@@ -758,7 +858,7 @@
758858 if (step == 0)
759859 step = 1;
760860 if (maxcount == 0)
761
- maxcount = 2048; // 4;
861
+ maxcount = 128; // 2048; // 4;
762862 // if (acceleration == 0)
763863 // acceleration = 10;
764864 if (delay == 0) // serial
....@@ -779,9 +879,12 @@
779879 // factor = CameraPane.STEP;
780880 // }
781881
782
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
882
+ if (marked && Globals.isLIVE() && live &&
883
+ //TEMP21aug2018
884
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
885
+ currentframe != Globals.framecount)
783886 {
784
- currentframe = CameraPane.framecount;
887
+ currentframe = Globals.framecount;
785888
786889 // System.err.println("transformcount = " + transformcount);
787890 // System.err.println("factor = " + factor);
....@@ -790,7 +893,8 @@
790893
791894 boolean changedir = random && Math.random() < 0.01; // && !link2master;
792895
793
- if (transformcount*factor > maxcount || (step == 1 && changedir))
896
+ if (transformcount*factor >= maxcount && (rewind || random) ||
897
+ (step == 1 && changedir))
794898 {
795899 countdown = 1;
796900 delay = speedup?8:1;
....@@ -862,6 +966,7 @@
862966 if (material == null || material.multiply)
863967 return true;
864968
969
+ // Transparent objects are dynamic because we have to sort the triangles.
865970 return material.opacity > 0.99;
866971 }
867972
....@@ -893,6 +998,11 @@
893998 fromParent = null; // LA.newMatrix();
894999 bRep = null; // new BoundaryRep();
8951000
1001
+ if (oname != null && oname.equals("LeftHand"))
1002
+ {
1003
+ name = oname;
1004
+ }
1005
+
8961006 /*
8971007 float hue = (float)Math.random();
8981008 Color col;
....@@ -935,7 +1045,7 @@
9351045
9361046 public Object clone()
9371047 {
938
- return GrafreeD.clone(this);
1048
+ return Grafreed.clone(this);
9391049 }
9401050
9411051 Object3D copyExpand()
....@@ -1446,7 +1556,16 @@
14461556 // if (other == null)
14471557 // return;
14481558
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1559
+ if (other != null)
1560
+ {
1561
+ BoundaryRep.SEUIL = other.material.cameralight;
1562
+
1563
+ // Set default to 0.1
1564
+ BoundaryRep.SEUIL /= 4; // 2;
1565
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1566
+ }
1567
+
1568
+ System.out.println("Link this = " + this + "; support = " + other);
14501569
14511570 //if (bRep != null)
14521571 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1820,7 @@
17011820 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021821 o.bRep = transientrep;
17031822 if (clone)
1704
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1823
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051824 o.CreateMaterial();
17061825 o.SetAttributes(this, -1);
17071826 //parent
....@@ -1714,7 +1833,7 @@
17141833 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151834 o.bRep = bRep;
17161835 if (clone)
1717
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1836
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181837 o.CreateMaterial();
17191838 //o.overwriteThis(this, -1);
17201839 o.SetAttributes(this, -1);
....@@ -1801,12 +1920,15 @@
18011920 if (obj.name == null)
18021921 continue; // can't be a null one
18031922
1923
+ // Try perfect match first.
18041924 if (n.equals(obj.name))
18051925 {
18061926 theobj = obj;
18071927 count++;
18081928 }
18091929 }
1930
+
1931
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18101932
18111933 if (count != 1)
18121934 for (int i=Size(); --i>=0;)
....@@ -1816,8 +1938,9 @@
18161938 if (obj.name == null)
18171939 continue; // can't be a null one
18181940
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1941
+ String name = obj.name.split(":")[0]; // Poser generates a count
1942
+ //if (n.startsWith(obj.name))
1943
+ if (n.contains(name))
18211944 {
18221945 theobj = obj;
18231946 count++;
....@@ -2120,15 +2243,8 @@
21202243 if (/*parent != null &&*/ material == null)
21212244 {
21222245 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
2246
+
2247
+ InitOthers();
21322248
21332249 if (this instanceof Camera)
21342250 {
....@@ -2272,12 +2388,17 @@
22722388 }
22732389 */
22742390 }
2391
+ else
2392
+ {
2393
+ //((ObjEditor)editWindow).SetupUI2(null);
2394
+ }
22752395 }
22762396
22772397 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22782398 {
22792399 if (newWindow)
22802400 {
2401
+ new Exception().printStackTrace();
22812402 System.exit(0);
22822403 if (parent != null)
22832404 {
....@@ -2454,13 +2575,13 @@
24542575 return retval;
24552576 }
24562577
2457
- void doEditDrag(ClickInfo info)
2578
+ void doEditDrag(ClickInfo info, boolean opposite)
24582579 {
24592580 switch (doSomething)
24602581 {
24612582 case 1: // '\001'
24622583 //super.
2463
- doEditDrag0(info);
2584
+ doEditDrag0(info, opposite);
24642585 break;
24652586
24662587 case 2: // '\002'
....@@ -2473,11 +2594,11 @@
24732594 {
24742595 //sel.hitSomething = childToDrag.hitSomething;
24752596 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2597
+ sel.doEditDrag(info, opposite);
24772598 } else
24782599 {
24792600 //super.
2480
- doEditDrag0(info);
2601
+ doEditDrag0(info, opposite);
24812602 }
24822603 }
24832604 break;
....@@ -2587,6 +2708,18 @@
25872708 void GenNormalsS(boolean crease)
25882709 {
25892710 selection.GenNormals(crease);
2711
+// for (int i=0; i<selection.size(); i++)
2712
+// {
2713
+// Object3D selectee = (Object3D) selection.elementAt(i);
2714
+// selectee.GenNormals(crease);
2715
+// }
2716
+
2717
+ //Touch();
2718
+ }
2719
+
2720
+ void GenNormalsMeshS()
2721
+ {
2722
+ selection.GenNormalsMesh();
25902723 // for (int i=0; i<selection.size(); i++)
25912724 // {
25922725 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2732,6 +2865,42 @@
27322865 blockloop = false;
27332866 }
27342867
2868
+ void GenNormalsMesh()
2869
+ {
2870
+ if (blockloop)
2871
+ return;
2872
+
2873
+ blockloop = true;
2874
+ GenNormalsMesh0();
2875
+ for (int i = 0; i < Children().Size(); i++)
2876
+ {
2877
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2878
+ if (child == null)
2879
+ continue;
2880
+ child.GenNormalsMesh();
2881
+// Children().release(i);
2882
+ }
2883
+ blockloop = false;
2884
+ }
2885
+
2886
+ void GenNormalsMINE()
2887
+ {
2888
+ if (blockloop)
2889
+ return;
2890
+
2891
+ blockloop = true;
2892
+ GenNormalsMINE0();
2893
+ for (int i = 0; i < Children().Size(); i++)
2894
+ {
2895
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2896
+ if (child == null)
2897
+ continue;
2898
+ child.GenNormalsMINE();
2899
+// Children().release(i);
2900
+ }
2901
+ blockloop = false;
2902
+ }
2903
+
27352904 void ClearColors()
27362905 {
27372906 if (blockloop)
....@@ -2866,7 +3035,8 @@
28663035 {
28673036 if (bRep != null)
28683037 {
2869
- bRep.GenUV();
3038
+ bRep.GenUV(); //1);
3039
+ //bRep.UnfoldUV();
28703040 Touch();
28713041 }
28723042 }
....@@ -2876,6 +3046,24 @@
28763046 if (bRep != null)
28773047 {
28783048 bRep.GenerateNormals(crease);
3049
+ Touch();
3050
+ }
3051
+ }
3052
+
3053
+ void GenNormalsMesh0()
3054
+ {
3055
+ if (bRep != null)
3056
+ {
3057
+ bRep.GenerateNormalsMesh();
3058
+ Touch();
3059
+ }
3060
+ }
3061
+
3062
+ void GenNormalsMINE0()
3063
+ {
3064
+ if (bRep != null)
3065
+ {
3066
+ bRep.GenerateNormalsMINE();
28793067 Touch();
28803068 }
28813069 }
....@@ -2932,6 +3120,33 @@
29323120 blockloop = false;
29333121 }
29343122
3123
+ void TransformChildren()
3124
+ {
3125
+ if (toParent != null)
3126
+ {
3127
+ for (int i=Size(); --i>=0;)
3128
+ {
3129
+ Object3D v = get(i);
3130
+
3131
+ if (v.toParent == null)
3132
+ {
3133
+ v.toParent = LA.newMatrix();
3134
+ v.fromParent = LA.newMatrix();
3135
+ }
3136
+
3137
+// LA.matConcat(v.toParent, toParent, v.toParent);
3138
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3139
+ LA.matConcat(toParent, v.toParent, v.toParent);
3140
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3141
+ }
3142
+
3143
+ toParent = null; // LA.matIdentity(toParent);
3144
+ fromParent = null; // LA.matIdentity(fromParent);
3145
+
3146
+ Touch();
3147
+ }
3148
+ }
3149
+
29353150 void TransformGeometry()
29363151 {
29373152 Object3D obj = this;
....@@ -3153,9 +3368,11 @@
31533368
31543369 BoundaryRep sup = bRep.support;
31553370 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3371
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573372 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3373
+
3374
+ while(temprep.SplitInTwo(reduction34, onlyone));
3375
+
31593376 bRep = temprep;
31603377 bRep.support = sup;
31613378 Touch();
....@@ -3292,7 +3509,8 @@
32923509 if (blockloop)
32933510 return;
32943511
3295
- if (marked || (bRep != null && material != null)) // borderline...
3512
+ if (//marked || // does not make sense
3513
+ (bRep != null || material != null)) // borderline...
32963514 live = h;
32973515
32983516 for (int i = 0; i < Size(); i++)
....@@ -3313,7 +3531,8 @@
33133531 return;
33143532
33153533 //if (bRep != null)
3316
- if (marked || (bRep != null && material != null)) // borderline...
3534
+ if (//marked || // does not make sense
3535
+ (bRep != null || material != null)) // borderline...
33173536 link2master = h;
33183537
33193538 for (int i = 0; i < Size(); i++)
....@@ -3333,7 +3552,8 @@
33333552 if (blockloop)
33343553 return;
33353554
3336
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
33373557 hide = h;
33383558
33393559 for (int i = 0; i < Size(); i++)
....@@ -3353,7 +3573,7 @@
33533573 if (blockloop)
33543574 return;
33553575
3356
- if (bRep != null && material != null) // borderline...
3576
+ if (bRep != null || material != null) // borderline...
33573577 marked = h;
33583578
33593579 for (int i = 0; i < Size(); i++)
....@@ -3363,6 +3583,46 @@
33633583 continue;
33643584 blockloop = true;
33653585 child.MarkLeaves(h);
3586
+ blockloop = false;
3587
+ // release(i);
3588
+ }
3589
+ }
3590
+
3591
+ void RewindLeaves(boolean h)
3592
+ {
3593
+ if (blockloop)
3594
+ return;
3595
+
3596
+ if (bRep != null || material != null) // borderline...
3597
+ rewind = h;
3598
+
3599
+ for (int i = 0; i < Size(); i++)
3600
+ {
3601
+ Object3D child = (Object3D) get(i); // reserve(i);
3602
+ if (child == null)
3603
+ continue;
3604
+ blockloop = true;
3605
+ child.RewindLeaves(h);
3606
+ blockloop = false;
3607
+ // release(i);
3608
+ }
3609
+ }
3610
+
3611
+ void RandomLeaves(boolean h)
3612
+ {
3613
+ if (blockloop)
3614
+ return;
3615
+
3616
+ if (bRep != null || material != null) // borderline...
3617
+ random = h;
3618
+
3619
+ for (int i = 0; i < Size(); i++)
3620
+ {
3621
+ Object3D child = (Object3D) get(i); // reserve(i);
3622
+ if (child == null)
3623
+ continue;
3624
+ blockloop = true;
3625
+ child.RandomLeaves(h);
33663626 blockloop = false;
33673627 // release(i);
33683628 }
....@@ -3677,7 +3937,7 @@
36773937 if (child == null)
36783938 continue;
36793939
3680
- if (GrafreeD.RENDERME > 0)
3940
+ if (Grafreed.RENDERME > 0)
36813941 {
36823942 if (child instanceof Merge)
36833943 ((Merge)child).renderme();
....@@ -3828,7 +4088,7 @@
38284088 if (child == null)
38294089 continue;
38304090
3831
- if (GrafreeD.RENDERME > 0)
4091
+ if (Grafreed.RENDERME > 0)
38324092 {
38334093 if (child instanceof Merge)
38344094 ((Merge)child).renderme();
....@@ -4023,7 +4283,7 @@
40234283 if (child == null)
40244284 continue;
40254285
4026
- if (GrafreeD.RENDERME > 0)
4286
+ if (Grafreed.RENDERME > 0)
40274287 {
40284288 if (child instanceof Merge)
40294289 ((Merge)child).renderme();
....@@ -4111,7 +4371,7 @@
41114371 if (blockloop)
41124372 return;
41134373
4114
- for (int i=0; i<size(); i++)
4374
+ for (int i=0; i<Size(); i++)
41154375 {
41164376 if (get(i).parent != this)
41174377 {
....@@ -4120,6 +4380,71 @@
41204380 }
41214381 blockloop = true;
41224382 get(i).RepairParent();
4383
+ blockloop = false;
4384
+ }
4385
+ }
4386
+
4387
+ void RepairShadow()
4388
+ {
4389
+ if (blockloop)
4390
+ return;
4391
+
4392
+ if (this.material != null)
4393
+ this.InitOthers();
4394
+
4395
+ for (int i=0; i<Size(); i++)
4396
+ {
4397
+ blockloop = true;
4398
+ get(i).RepairShadow();
4399
+ blockloop = false;
4400
+ }
4401
+ }
4402
+
4403
+ void RepairSOV()
4404
+ {
4405
+ if (blockloop)
4406
+ return;
4407
+
4408
+ String texname = this.GetPigmentTexture();
4409
+
4410
+ if (texname.startsWith("sov"))
4411
+ {
4412
+ String[] s = texname.split("/");
4413
+
4414
+ String[] sname = s[1].split("Color.pn");
4415
+
4416
+ texname = sname[0];
4417
+
4418
+ if (sname.length > 1)
4419
+ {
4420
+ texname += "Color.jpg";
4421
+ }
4422
+
4423
+ this.SetPigmentTexture("sov/" + texname);
4424
+ }
4425
+
4426
+ texname = this.GetBumpTexture();
4427
+
4428
+ if (texname.startsWith("sov"))
4429
+ {
4430
+ String[] s = texname.split("/");
4431
+
4432
+ String[] sname = s[1].split("Bump.pn");
4433
+
4434
+ texname = sname[0];
4435
+
4436
+ if (sname.length > 1)
4437
+ {
4438
+ texname += "Bump.jpg";
4439
+ }
4440
+
4441
+ this.SetBumpTexture("sov/" + texname);
4442
+ }
4443
+
4444
+ for (int i=0; i<Size(); i++)
4445
+ {
4446
+ blockloop = true;
4447
+ get(i).RepairSOV();
41234448 blockloop = false;
41244449 }
41254450 }
....@@ -4614,7 +4939,7 @@
46144939
46154940 cTreePath SelectLeaf(int indexcount, boolean deselect)
46164941 {
4617
- if (hide)
4942
+ if (hide || dontselect)
46184943 return null;
46194944
46204945 if (count <= 0)
....@@ -4640,7 +4965,7 @@
46404965
46414966 cTreePath Select(int indexcount, boolean deselect)
46424967 {
4643
- if (hide)
4968
+ if (hide || dontselect)
46444969 return null;
46454970
46464971 if (count <= 0)
....@@ -4790,7 +5115,7 @@
47905115 return globalTransform;
47915116 }
47925117
4793
- void PreprocessOcclusion(CameraPane cp)
5118
+ void PreprocessOcclusion(iCameraPane cp)
47945119 {
47955120 /*
47965121 if (AOdone)
....@@ -4937,7 +5262,8 @@
49375262 } else //
49385263 if (editWindow != null)
49395264 {
4940
- editWindow.cameraView.lighttouched = true;
5265
+ //editWindow.cameraView.lighttouched = true;
5266
+ Globals.lighttouched = true;
49415267 }
49425268 }
49435269
....@@ -5091,10 +5417,34 @@
50915417
50925418 // System.out.println("Fullname = " + fullname);
50935419
5094
- if (fullname.name.indexOf(":") == -1)
5095
- return fullname.name;
5420
+ // Does not work on Windows due to C:
5421
+// if (fullname.name.indexOf(":") == -1)
5422
+// return fullname.name;
5423
+//
5424
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50965425
5097
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5426
+ String[] split = fullname.name.split(":");
5427
+
5428
+ if (split.length == 0)
5429
+ {
5430
+ return "";
5431
+ }
5432
+
5433
+ if (split.length <= 2)
5434
+ {
5435
+ if (fullname.name.endsWith(":"))
5436
+ {
5437
+ // Windows
5438
+ return fullname.name.substring(0, fullname.name.length()-1);
5439
+ }
5440
+
5441
+ return split[0];
5442
+ }
5443
+
5444
+ // Windows
5445
+ assert(split.length == 4);
5446
+
5447
+ return split[0] + ":" + split[1];
50985448 }
50995449
51005450 static String GetBump(cTexture fullname)
....@@ -5103,10 +5453,38 @@
51035453 return "";
51045454
51055455 // 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());
5456
+ // Does not work on Windows due to C:
5457
+// if (fullname.name.indexOf(":") == -1)
5458
+// return "";
5459
+//
5460
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5461
+ String[] split = fullname.name.split(":");
5462
+
5463
+ if (split.length == 0)
5464
+ {
5465
+ return "";
5466
+ }
5467
+
5468
+ if (split.length == 1)
5469
+ {
5470
+ return "";
5471
+ }
5472
+
5473
+ if (split.length == 2)
5474
+ {
5475
+ if (fullname.name.endsWith(":"))
5476
+ {
5477
+ // Windows
5478
+ return "";
5479
+ }
5480
+
5481
+ return split[1];
5482
+ }
5483
+
5484
+ // Windows
5485
+ assert(split.length == 4);
5486
+
5487
+ return split[2] + ":" + split[3];
51105488 }
51115489
51125490 String GetPigmentTexture()
....@@ -5180,7 +5558,7 @@
51805558 System.out.print("; textures = " + textures);
51815559 System.out.println("; usedtextures = " + usedtextures);
51825560
5183
- if (GetTextures() == null)
5561
+ if (GetTextures() == null) // What is that??
51845562 GetTextures().name = ":";
51855563
51865564 String texname = tex;
....@@ -5211,6 +5589,43 @@
52115589 child.ResetPigmentTexture();
52125590 blockloop = false;
52135591 }
5592
+ }
5593
+
5594
+ UUID GetUUID()
5595
+ {
5596
+ if (uuid == null)
5597
+ {
5598
+ // Serial
5599
+ uuid = UUID.randomUUID();
5600
+ }
5601
+
5602
+ return uuid;
5603
+ }
5604
+
5605
+ Object3D GetObject(UUID uid)
5606
+ {
5607
+ if (blockloop)
5608
+ return null;
5609
+
5610
+ if (GetUUID().equals(uid))
5611
+ return this;
5612
+
5613
+ int nb = Size();
5614
+ for (int i = 0; i < nb; i++)
5615
+ {
5616
+ Object3D child = (Object3D) get(i);
5617
+
5618
+ if (child == null)
5619
+ continue;
5620
+
5621
+ blockloop = true;
5622
+ Object3D obj = child.GetObject(uid);
5623
+ blockloop = false;
5624
+ if (obj != null)
5625
+ return obj;
5626
+ }
5627
+
5628
+ return null;
52145629 }
52155630
52165631 void SetBumpTexture(String tex)
....@@ -5249,25 +5664,33 @@
52495664 }
52505665 }
52515666
5252
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5667
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52535668 {
52545669 Draw(display, root, selected, blocked);
52555670 }
52565671
5257
- static cMaterial[] materialstack = new cMaterial[65536];
5258
- static boolean[] selectedstack = new boolean[65536];
5259
- static int materialdepth = 0;
5260
-
52615672 boolean NeedSupport()
52625673 {
52635674 return
5264
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5675
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52655676 // PROBLEM with CROWD!!
5266
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5677
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52675678 }
52685679
5680
+ static boolean DEBUG_SELECTION = false;
52695681
5270
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5682
+ boolean IsLive()
5683
+ {
5684
+ if (live)
5685
+ return true;
5686
+
5687
+ if (parent == null)
5688
+ return false;
5689
+
5690
+ return parent.IsLive();
5691
+ }
5692
+
5693
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52715694 {
52725695 Invariants(); // june 2013
52735696
....@@ -5276,8 +5699,8 @@
52765699 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52775700 }
52785701
5279
- if (display.drawMode == CameraPane.SELECTION &&
5280
- hide)
5702
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5703
+ (hide || dontselect))
52815704 return;
52825705
52835706 if (name != null && name.contains("sclera"))
....@@ -5295,7 +5718,7 @@
52955718 if (this instanceof Checker)
52965719 return;
52975720
5298
- if (display.drawMode == display.SHADOW && PASSTEST)
5721
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52995722 return;
53005723
53015724 if (count <= 0)
....@@ -5303,13 +5726,13 @@
53035726 return;
53045727 }
53055728
5306
- if ((//display.drawMode == CameraPane.SHADOW ||
5307
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5729
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5730
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53085731 {
53095732 return;
53105733 }
53115734
5312
- javax.media.opengl.GL gl = display.GetGL();
5735
+ //javax.media.opengl.GL gl = display.GetGL();
53135736
53145737 /*
53155738 if (touched)
....@@ -5328,7 +5751,7 @@
53285751 support = support;
53295752
53305753 //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);
5754
+ boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53325755
53335756 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53345757 {
....@@ -5345,15 +5768,17 @@
53455768
53465769 boolean compiled = false;
53475770
5348
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5771
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53495772
5350
- if (!selectmode && //display.drawMode != display.SELECTION &&
5351
- (touched || (bRep != null && bRep.displaylist <= 0)))
5773
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5774
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5775
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0)))
53525776 {
5353
- display.lighttouched = true;
5777
+ Globals.lighttouched = true;
53545778 } // 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 &&
5779
+
5780
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5781
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53575782 (touched || (bRep != null && bRep.displaylist <= 0)))
53585783 {
53595784 if (!(this instanceof Composite))
....@@ -5361,7 +5786,7 @@
53615786 //if (displaylist == -1 && usecalllists)
53625787 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53635788 {
5364
- bRep.displaylist = gl.glGenLists(1);
5789
+ bRep.displaylist = display.GenList();
53655790 assert(bRep.displaylist != 0);
53665791 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53675792 //System.out.println("\tgen list " + list);
....@@ -5373,18 +5798,20 @@
53735798 if (usecalllists)
53745799 {
53755800 // System.err.println("new list " + bRep.displaylist + " for " + this);
5376
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5801
+ display.NewList(bRep.displaylist);
53775802 }
5803
+
53785804 CallList(display, root, selected, blocked);
5805
+
53795806 // compiled = true;
53805807 if (usecalllists)
53815808 {
53825809 // System.err.println("end list " + bRep.displaylist + " for " + this);
5383
- gl.glEndList();
5810
+ display.EndList();
53845811 }
53855812 //gl.glDrawBuffer(gl.GL_BACK);
53865813 // XXX touched = false;
5387
- display.lighttouched = true; // all panes...
5814
+ Globals.lighttouched = true; // all panes...
53885815 }
53895816
53905817 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5423,12 +5850,12 @@
54235850
54245851 // frustum culling
54255852 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5426
- && display.drawMode != CameraPane.SELECTION)
5853
+ && display.DrawMode() != iCameraPane.SELECTION)
54275854 {
5428
- if (display.drawMode == CameraPane.SHADOW)
5855
+ if (display.DrawMode() == iCameraPane.SHADOW)
54295856 {
54305857 if (!link2master // tricky to cull in shadow mode.
5431
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5858
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54325859 {
54335860 //System.out.print("CULLED");
54345861 culled = true;
....@@ -5436,7 +5863,7 @@
54365863 }
54375864 else
54385865 //GetBRep().getBounds(v0, v1, this);
5439
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5866
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54405867 culled = true;
54415868
54425869 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5472,11 +5899,11 @@
54725899
54735900
54745901 if (!culled)
5475
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5902
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54765903 {
54775904 if (GetBRep() != null)
54785905 {
5479
- CameraPane.NextIndex(this, gl);
5906
+ display.NextIndex();
54805907 // vertex color conflict : gl.glCallList(list);
54815908 DrawNode(display, root, selected);
54825909 if (this instanceof BezierPatch)
....@@ -5498,55 +5925,7 @@
54985925 color[2] /= 2;
54995926 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55005927 */
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
- }
5928
+ display.PushMaterial(this, selected);
55505929
55515930 //System.out.println("call list " + list);
55525931 //System.out.println();
....@@ -5565,7 +5944,28 @@
55655944 tex = GetTextures();
55665945 }
55675946
5568
- display.BindTextures(tex, texres);
5947
+ boolean failedPigment = false;
5948
+ boolean failedBump = false;
5949
+
5950
+ try
5951
+ {
5952
+ display.BindPigmentTexture(tex, texres);
5953
+ }
5954
+ catch (Exception e)
5955
+ {
5956
+ System.err.println("FAILED: " + this);
5957
+ failedPigment = true;
5958
+ }
5959
+
5960
+ try
5961
+ {
5962
+ display.BindBumpTexture(tex, texres);
5963
+ }
5964
+ catch (Exception e)
5965
+ {
5966
+ //System.err.println("FAILED: " + this);
5967
+ failedBump = true;
5968
+ }
55695969
55705970 if (!compiled)
55715971 {
....@@ -5581,30 +5981,19 @@
55815981
55825982 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55835983 assert(bRep.displaylist != 0);
5584
- gl.glCallList(bRep.displaylist);
5984
+ display.CallList(bRep.displaylist);
55855985 // june 2013 drawSelf(display, root, selected);
55865986 }
55875987 }
55885988 }
55895989
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
- }
5990
+ if (!failedBump)
5991
+ display.ReleaseBumpTexture(tex);
5992
+
5993
+ if (!failedPigment)
5994
+ display.ReleasePigmentTexture(tex);
5995
+
5996
+ display.PopMaterial(this, selected);
56085997 }
56095998
56105999 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5646,7 +6035,7 @@
56466035 // resetMasterNode();
56476036 }
56486037
5649
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6038
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56506039 {
56516040 if (GetBRep() == null)
56526041 {
....@@ -5729,8 +6118,11 @@
57296118 boolean flipV = false; // true;
57306119 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57316120
5732
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6121
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57336122 {
6123
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6124
+ return;
6125
+
57346126 if (hide)
57356127 return;
57366128 // shadow optimisation
....@@ -5788,16 +6180,7 @@
57886180 // // ??????????????????????????? Touch();
57896181 // }
57906182
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
- }
6183
+display.PushMaterial2(this, selected);
58016184
58026185 Object3D child;
58036186 boolean sel;
....@@ -5849,19 +6232,7 @@
58496232 */
58506233 //depth += 1;
58516234
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
-
6235
+display.PopMaterial2(this);
58656236 /*
58666237 display.ReleaseTextures(tex);
58676238 */
....@@ -5872,10 +6243,13 @@
58726243
58736244 //static cVector min,max;
58746245
5875
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6246
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58766247 {
5877
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6248
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58786249 return; // no shadow for transparent objects
6250
+
6251
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6252
+ return;
58796253
58806254 if (hide)
58816255 return;
....@@ -5917,11 +6291,12 @@
59176291 return;
59186292 }
59196293
6294
+ //bRep.GenUV(1/material.diffuseness);
59206295 // bRep.lock = true;
59216296
5922
- javax.media.opengl.GL gl = display.GetGL();
6297
+ //javax.media.opengl.GL gl = display.GetGL();
59236298
5924
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6299
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59256300 {
59266301 int fc = bRep.FaceCount();
59276302 int vc = bRep.VertexCount();
....@@ -5936,23 +6311,7 @@
59366311
59376312 bRep.getMinMax(min, max, 100);
59386313
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();
6314
+ display.DrawBox(min, max);
59566315
59576316 return;
59586317 }
....@@ -5996,7 +6355,7 @@
59966355 {
59976356 //throw new Error();
59986357
5999
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6358
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60006359
60016360 int[] strips = bRep.getRawIndices();
60026361
....@@ -6006,178 +6365,19 @@
60066365 new Exception().printStackTrace();
60076366 return;
60086367 }
6009
-
6010
- // TRIANGLE STRIP ARRAY
6011
- if (bRep.trimmed)
6368
+
6369
+ if (dontselect)
60126370 {
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;
6371
+ //bRep.GenerateNormalsMINE();
61446372 }
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
- }
6373
+
6374
+ display.DrawGeometry(bRep, flipV, selectmode);
61756375 } else // catch (Error e)
61766376 {
61776377 // TRIANGLE ARRAY
61786378 if (IsOpaque()) // Static())
61796379 {
6180
- gl.glBegin(gl.GL_TRIANGLES);
6380
+ display.StartTriangles();
61816381 int facecount = bRep.FaceCount();
61826382 for (int i = 0; i < facecount; i++)
61836383 {
....@@ -6240,9 +6440,9 @@
62406440 // // r.norm.dot(v3) > -0.5)
62416441 // // continue;
62426442
6243
- drawFace(p, q, r, display, face);
6443
+ display.DrawFace(this, p, q, r, face);
62446444 }
6245
- gl.glEnd();
6445
+ display.EndTriangles();
62466446 }
62476447 else
62486448 {
....@@ -6271,8 +6471,8 @@
62716471 //System.out.println("SORT");
62726472
62736473 java.util.Arrays.sort(facescompare);
6274
-
6275
- gl.glBegin(gl.GL_TRIANGLES);
6474
+
6475
+ display.StartTriangles();
62766476 for (int i = 0; i < facecount; i++)
62776477 {
62786478 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6284,13 +6484,14 @@
62846484 Vertex q = bRep.GetVertex(face.q);
62856485 Vertex r = bRep.GetVertex(face.r);
62866486
6287
- drawFace(p, q, r, display, face);
6487
+ display.DrawFace(this, p, q, r, face);
62886488 }
6289
- gl.glEnd();
6489
+ display.EndTriangles();
62906490 }
62916491
62926492 if (false) // live && support != null && support.bRep != null) // debug weights
62936493 {
6494
+ /*
62946495 gl.glDisable(gl.GL_LIGHTING);
62956496 float[] colorV = new float[3];
62966497
....@@ -6369,6 +6570,7 @@
63696570 // gl.glEnd();
63706571 }
63716572 }
6573
+ */
63726574 }
63736575 }
63746576
....@@ -6413,7 +6615,7 @@
64136615 center.add(r);
64146616 center.mul(1.0/3);
64156617
6416
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6618
+ center.sub(Globals.theRenderer.EyeCamera().location);
64176619
64186620 distance = center.dot(center);
64196621 }
....@@ -6424,347 +6626,11 @@
64246626
64256627 transient FaceCompare[] facescompare = null;
64266628
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
-
66016629 void Print(Vertex v)
66026630 {
66036631 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66046632 }
66056633
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
-
67686634 void drawSelf(ClickInfo info, int level, boolean select)
67696635 {
67706636 if (bRep == null)
....@@ -7336,83 +7202,84 @@
73367202 int spotw = spot.x + spot.width;
73377203 int spoth = spot.y + spot.height;
73387204 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
- }
7205
+// if (CameraPane.Xmin > spot.x)
7206
+// {
7207
+// CameraPane.Xmin = spot.x;
7208
+// }
7209
+// if (CameraPane.Xmax < spotw)
7210
+// {
7211
+// CameraPane.Xmax = spotw;
7212
+// }
7213
+// if (CameraPane.Ymin > spot.y)
7214
+// {
7215
+// CameraPane.Ymin = spot.y;
7216
+// }
7217
+// if (CameraPane.Ymax < spoth)
7218
+// {
7219
+// CameraPane.Ymax = spoth;
7220
+// }
73557221 spot.translate(32, 32);
73567222 spotw = spot.x + spot.width;
73577223 spoth = spot.y + spot.height;
7358
- info.g.setColor(Color.blue);
7224
+ info.g.setColor(Color.cyan);
73597225 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);
7226
+// if (CameraPane.Xmin > spot.x)
7227
+// {
7228
+// CameraPane.Xmin = spot.x;
7229
+// }
7230
+// if (CameraPane.Xmax < spotw)
7231
+// {
7232
+// CameraPane.Xmax = spotw;
7233
+// }
7234
+// if (CameraPane.Ymin > spot.y)
7235
+// {
7236
+// CameraPane.Ymin = spot.y;
7237
+// }
7238
+// if (CameraPane.Ymax < spoth)
7239
+// {
7240
+// CameraPane.Ymax = spoth;
7241
+// }
7242
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7243
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73787244 spot.translate(0, -32);
7379
- info.g.setColor(Color.green);
7245
+ info.g.setColor(Color.yellow);
73807246 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
- }
7247
+ info.g.setColor(Color.green);
7248
+// if (CameraPane.Xmin > spot.x)
7249
+// {
7250
+// CameraPane.Xmin = spot.x;
7251
+// }
7252
+// if (CameraPane.Xmax < spotw)
7253
+// {
7254
+// CameraPane.Xmax = spotw;
7255
+// }
7256
+// if (CameraPane.Ymin > spot.y)
7257
+// {
7258
+// CameraPane.Ymin = spot.y;
7259
+// }
7260
+// if (CameraPane.Ymax < spoth)
7261
+// {
7262
+// CameraPane.Ymax = spoth;
7263
+// }
73977264 info.g.drawArc(boundary.x, boundary.y,
73987265 boundary.width, boundary.height, 0, 360);
73997266 //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
- }
7267
+// if (CameraPane.Xmin > boundary.x)
7268
+// {
7269
+// CameraPane.Xmin = boundary.x;
7270
+// }
7271
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7272
+// {
7273
+// CameraPane.Xmax = boundary.x + boundary.width;
7274
+// }
7275
+// if (CameraPane.Ymin > boundary.y)
7276
+// {
7277
+// CameraPane.Ymin = boundary.y;
7278
+// }
7279
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7280
+// {
7281
+// CameraPane.Ymax = boundary.y + boundary.height;
7282
+// }
74167283 return;
74177284 }
74187285 }
....@@ -7429,7 +7296,7 @@
74297296 startX = info.x;
74307297 startY = info.y;
74317298
7432
- hitSomething = 0;
7299
+ hitSomething = -1;
74337300 cVector origin = new cVector();
74347301 //LA.xformPos(origin, toParent, origin);
74357302 Rectangle spot = new Rectangle();
....@@ -7462,7 +7329,7 @@
74627329 }
74637330
74647331 //System.out.println("info.modifiers = " + info.modifiers);
7465
- modified = (info.modifiers & CameraPane.META) != 0;
7332
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74667333 //System.out.println("modified = " + modified);
74677334 //new Exception().printStackTrace();
74687335 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7490,7 +7357,7 @@
74907357 return true;
74917358 }
74927359
7493
- void doEditDrag0(ClickInfo info)
7360
+ void doEditDrag0(ClickInfo info, boolean opposite)
74947361 {
74957362 if (hitSomething == 0)
74967363 {
....@@ -7505,6 +7372,7 @@
75057372 //System.out.println("hitSomething = " + hitSomething);
75067373
75077374 double scale = 0.005f * info.camera.Distance();
7375
+
75087376 cVector xlate = new cVector();
75097377 //cVector xlate2 = new cVector();
75107378 switch (hitSomething)
....@@ -7515,9 +7383,9 @@
75157383
75167384 case hitCenter: // Translate
75177385
7518
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7386
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75197387
7520
- if (modified)
7388
+ if (modified || opposite)
75217389 {
75227390 //assert(false);
75237391 /*
....@@ -7563,10 +7431,10 @@
75637431 }
75647432 LA.xformDir(up, ClickInfo.matbuffer, up);
75657433 // if (!CameraPane.LOCALTRANSFORM)
7566
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7434
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75677435 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75687436 // if (!CameraPane.LOCALTRANSFORM)
7569
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7437
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75707438 //LA.vecCross(up, cVector.Z, right2);
75717439
75727440 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7611,6 +7479,7 @@
76117479
76127480 if (modified)
76137481 {
7482
+ // Rotate 90 degrees
76147483 angle /= (Math.PI / 4);
76157484 angle = Math.floor(angle + 0.5);
76167485 angle *= (Math.PI / 4);
....@@ -7624,7 +7493,7 @@
76247493 }
76257494 /**/
76267495
7627
- switch (info.pane.renderCamera.viewCode)
7496
+ switch (info.pane.RenderCamera().viewCode)
76287497 {
76297498 case 1: // '\001'
76307499 LA.matZRotate(toParent, angle);
....@@ -7652,24 +7521,27 @@
76527521
76537522 case hitScale: // scale
76547523 double hScale = (double) (info.x - centerPt.x) / 32;
7524
+ double sign = 1;
7525
+ if (hScale < 0)
7526
+ {
7527
+ sign = -1;
7528
+ }
7529
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76557530 if (hScale < 0.01)
76567531 {
7657
- hScale = 0.01;
7532
+ //hScale = 0.01;
76587533 }
7659
- hScale = Math.pow(hScale, scale * 50);
7660
- if (hScale < 0.01)
7661
- {
7662
- hScale = 0.01;
7663
- }
7534
+
76647535 double vScale = (double) (info.y - centerPt.y) / 32;
7665
- if (vScale < 0.01)
7536
+ sign = 1;
7537
+ if (vScale < 0)
76667538 {
7667
- vScale = 0.01;
7539
+ sign = -1;
76687540 }
7669
- vScale = Math.pow(vScale, scale * 50);
7541
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76707542 if (vScale < 0.01)
76717543 {
7672
- vScale = 0.01;
7544
+ //vScale = 0.01;
76737545 }
76747546 LA.matCopy(startMat, toParent);
76757547 /**/
....@@ -7680,39 +7552,47 @@
76807552 }
76817553 /**/
76827554
7683
- switch (info.pane.renderCamera.viewCode)
7555
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7556
+
7557
+ if (totalScale < 0.01)
7558
+ {
7559
+ totalScale = 0.01;
7560
+ }
7561
+
7562
+ switch (info.pane.RenderCamera().viewCode)
76847563 {
76857564 case 3: // '\001'
7686
- if (modified)
7565
+ if (modified || opposite)
76877566 {
76887567 //LA.matScale(toParent, 1, hScale, vScale);
7689
- LA.matScale(toParent, vScale, 1, 1);
7568
+ LA.matScale(toParent, totalScale, 1, 1);
76907569 } // vScale, 1);
76917570 else
76927571 {
7693
- LA.matScale(toParent, vScale, vScale, vScale);
7572
+ // EXCEPTION!
7573
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
76947574 } // vScale, 1);
76957575 break;
76967576
76977577 case 2: // '\002'
7698
- if (modified)
7578
+ if (modified || opposite)
76997579 {
77007580 //LA.matScale(toParent, hScale, 1, vScale);
7701
- LA.matScale(toParent, 1, vScale, 1);
7581
+ LA.matScale(toParent, 1, totalScale, 1);
77027582 } else
77037583 {
7704
- LA.matScale(toParent, vScale, 1, vScale);
7584
+ LA.matScale(toParent, totalScale, 1, totalScale);
77057585 }
77067586 break;
77077587
77087588 case 1: // '\003'
7709
- if (modified)
7589
+ if (modified || opposite)
77107590 {
77117591 //LA.matScale(toParent, hScale, vScale, 1);
7712
- LA.matScale(toParent, 1, 1, vScale);
7592
+ LA.matScale(toParent, 1, 1, totalScale);
77137593 } else
77147594 {
7715
- LA.matScale(toParent, vScale, vScale, 1);
7595
+ LA.matScale(toParent, totalScale, totalScale, 1);
77167596 }
77177597 break;
77187598 }
....@@ -7733,7 +7613,7 @@
77337613 if (parent == null)
77347614 {
77357615 System.out.println("NULL PARENT");
7736
- new Exception().printStackTrace();
7616
+ //new Exception().printStackTrace();
77377617 } else
77387618 {
77397619 if (parent instanceof BezierPatch)
....@@ -7845,14 +7725,22 @@
78457725 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78467726 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78477727 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7728
+
7729
+ String objname;
7730
+
78487731 if (false) //parent != null)
78497732 {
7850
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7733
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78517734 } else
78527735 {
7853
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7736
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78547737 } // + super.toString();
78557738 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7739
+
7740
+ if (!Globals.ADVANCED)
7741
+ return objname;
7742
+
7743
+ return objname + " " + System.identityHashCode(this);
78567744 }
78577745
78587746 public int hashCode()
....@@ -7908,6 +7796,7 @@
79087796 objectUI.closeUI();
79097797 if (editWindow != null)
79107798 {
7799
+ editWindow.ctrlPanel.FlushUI();
79117800 editWindow.refreshContents();
79127801 } // ? new
79137802 objectUI = null;
....@@ -7916,6 +7805,10 @@
79167805 {
79177806 editWindow = null;
79187807 } // ?
7808
+ }
7809
+ else
7810
+ {
7811
+ //editWindow.closeUI();
79197812 }
79207813 }
79217814
....@@ -7928,7 +7821,7 @@
79287821 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79297822
79307823 Object3D /*Composite*/ parent;
7931
- Object3D /*Composite*/ fileparent;
7824
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79327825
79337826 double[][] toParent; // dynamic matrix
79347827 double[][] fromParent;
....@@ -8043,7 +7936,7 @@
80437936 {
80447937 assert(bRep != null);
80457938 if (!(support instanceof GenericJoint)) // support.bRep != null)
8046
- GrafreeD.Assert(support.bRep == bRep.support);
7939
+ Grafreed.Assert(support.bRep == bRep.support);
80477940 }
80487941 else
80497942 {
....@@ -8092,9 +7985,9 @@
80927985 private static cVector edge2 = new cVector();
80937986 //private static cVector norm = new cVector();
80947987 /*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;
7988
+ static final int hitCenter = 1;
7989
+ static final int hitScale = 2;
7990
+ static final int hitRotate = 3;
80987991 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80997992 /*transient*/ private Point centerPt;
81007993 /*transient*/ private int startX;
....@@ -8126,6 +8019,8 @@
81268019 {
81278020 Object3D targ = this;
81288021
8022
+ targ.NORMALPUSH = obj.NORMALPUSH;
8023
+
81298024 if (obj.material != null)
81308025 {
81318026 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))