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
....@@ -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()
....@@ -1451,7 +1561,7 @@
14511561 BoundaryRep.SEUIL = other.material.cameralight;
14521562
14531563 // Set default to 0.1
1454
- BoundaryRep.SEUIL /= 2;
1564
+ BoundaryRep.SEUIL /= 4; // 2;
14551565 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14561566 }
14571567
....@@ -1710,7 +1820,7 @@
17101820 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17111821 o.bRep = transientrep;
17121822 if (clone)
1713
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1823
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17141824 o.CreateMaterial();
17151825 o.SetAttributes(this, -1);
17161826 //parent
....@@ -1723,7 +1833,7 @@
17231833 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17241834 o.bRep = bRep;
17251835 if (clone)
1726
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1836
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17271837 o.CreateMaterial();
17281838 //o.overwriteThis(this, -1);
17291839 o.SetAttributes(this, -1);
....@@ -1810,12 +1920,15 @@
18101920 if (obj.name == null)
18111921 continue; // can't be a null one
18121922
1923
+ // Try perfect match first.
18131924 if (n.equals(obj.name))
18141925 {
18151926 theobj = obj;
18161927 count++;
18171928 }
18181929 }
1930
+
1931
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18191932
18201933 if (count != 1)
18211934 for (int i=Size(); --i>=0;)
....@@ -2130,15 +2243,8 @@
21302243 if (/*parent != null &&*/ material == null)
21312244 {
21322245 material = new cMaterial(GetMaterial());
2133
- if (projectedVertices == null || projectedVertices.length <= 2)
2134
- {
2135
- projectedVertices = new Object3D.cVector2[3];
2136
- }
2137
- for (int i = 0; i < 3; i++)
2138
- {
2139
- projectedVertices[i] = new cVector2(); // Others
2140
- }
2141
- projectedVertices[0].x = 100; // bump
2246
+
2247
+ InitOthers();
21422248
21432249 if (this instanceof Camera)
21442250 {
....@@ -2282,12 +2388,17 @@
22822388 }
22832389 */
22842390 }
2391
+ else
2392
+ {
2393
+ //((ObjEditor)editWindow).SetupUI2(null);
2394
+ }
22852395 }
22862396
22872397 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22882398 {
22892399 if (newWindow)
22902400 {
2401
+ new Exception().printStackTrace();
22912402 System.exit(0);
22922403 if (parent != null)
22932404 {
....@@ -2464,13 +2575,13 @@
24642575 return retval;
24652576 }
24662577
2467
- void doEditDrag(ClickInfo info)
2578
+ void doEditDrag(ClickInfo info, boolean opposite)
24682579 {
24692580 switch (doSomething)
24702581 {
24712582 case 1: // '\001'
24722583 //super.
2473
- doEditDrag0(info);
2584
+ doEditDrag0(info, opposite);
24742585 break;
24752586
24762587 case 2: // '\002'
....@@ -2483,11 +2594,11 @@
24832594 {
24842595 //sel.hitSomething = childToDrag.hitSomething;
24852596 //childToDrag.doEditDrag(info);
2486
- sel.doEditDrag(info);
2597
+ sel.doEditDrag(info, opposite);
24872598 } else
24882599 {
24892600 //super.
2490
- doEditDrag0(info);
2601
+ doEditDrag0(info, opposite);
24912602 }
24922603 }
24932604 break;
....@@ -2597,6 +2708,18 @@
25972708 void GenNormalsS(boolean crease)
25982709 {
25992710 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();
26002723 // for (int i=0; i<selection.size(); i++)
26012724 // {
26022725 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2737,6 +2860,24 @@
27372860 if (child == null)
27382861 continue;
27392862 child.GenNormals(crease);
2863
+// Children().release(i);
2864
+ }
2865
+ blockloop = false;
2866
+ }
2867
+
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();
27402881 // Children().release(i);
27412882 }
27422883 blockloop = false;
....@@ -2894,7 +3035,8 @@
28943035 {
28953036 if (bRep != null)
28963037 {
2897
- bRep.GenUV();
3038
+ bRep.GenUV(); //1);
3039
+ //bRep.UnfoldUV();
28983040 Touch();
28993041 }
29003042 }
....@@ -2904,6 +3046,15 @@
29043046 if (bRep != null)
29053047 {
29063048 bRep.GenerateNormals(crease);
3049
+ Touch();
3050
+ }
3051
+ }
3052
+
3053
+ void GenNormalsMesh0()
3054
+ {
3055
+ if (bRep != null)
3056
+ {
3057
+ bRep.GenerateNormalsMesh();
29073058 Touch();
29083059 }
29093060 }
....@@ -2969,6 +3120,33 @@
29693120 blockloop = false;
29703121 }
29713122
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
+
29723150 void TransformGeometry()
29733151 {
29743152 Object3D obj = this;
....@@ -3190,9 +3368,11 @@
31903368
31913369 BoundaryRep sup = bRep.support;
31923370 bRep.support = null;
3193
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3371
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31943372 // bRep.SplitInTwo(onlyone); // thread...
3195
- temprep.SplitInTwo(reduction34, onlyone);
3373
+
3374
+ while(temprep.SplitInTwo(reduction34, onlyone));
3375
+
31963376 bRep = temprep;
31973377 bRep.support = sup;
31983378 Touch();
....@@ -3329,7 +3509,8 @@
33293509 if (blockloop)
33303510 return;
33313511
3332
- if (marked || (bRep != null && material != null)) // borderline...
3512
+ if (//marked || // does not make sense
3513
+ (bRep != null || material != null)) // borderline...
33333514 live = h;
33343515
33353516 for (int i = 0; i < Size(); i++)
....@@ -3350,7 +3531,8 @@
33503531 return;
33513532
33523533 //if (bRep != null)
3353
- if (marked || (bRep != null && material != null)) // borderline...
3534
+ if (//marked || // does not make sense
3535
+ (bRep != null || material != null)) // borderline...
33543536 link2master = h;
33553537
33563538 for (int i = 0; i < Size(); i++)
....@@ -3370,7 +3552,8 @@
33703552 if (blockloop)
33713553 return;
33723554
3373
- if (marked || (bRep != null && material != null)) // borderline...
3555
+ if (//marked || // does not make sense
3556
+ (bRep != null || material != null)) // borderline...
33743557 hide = h;
33753558
33763559 for (int i = 0; i < Size(); i++)
....@@ -3390,7 +3573,7 @@
33903573 if (blockloop)
33913574 return;
33923575
3393
- if (bRep != null && material != null) // borderline...
3576
+ if (bRep != null || material != null) // borderline...
33943577 marked = h;
33953578
33963579 for (int i = 0; i < Size(); i++)
....@@ -3400,6 +3583,46 @@
34003583 continue;
34013584 blockloop = true;
34023585 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);
34033626 blockloop = false;
34043627 // release(i);
34053628 }
....@@ -3714,7 +3937,7 @@
37143937 if (child == null)
37153938 continue;
37163939
3717
- if (GrafreeD.RENDERME > 0)
3940
+ if (Grafreed.RENDERME > 0)
37183941 {
37193942 if (child instanceof Merge)
37203943 ((Merge)child).renderme();
....@@ -3865,7 +4088,7 @@
38654088 if (child == null)
38664089 continue;
38674090
3868
- if (GrafreeD.RENDERME > 0)
4091
+ if (Grafreed.RENDERME > 0)
38694092 {
38704093 if (child instanceof Merge)
38714094 ((Merge)child).renderme();
....@@ -4060,7 +4283,7 @@
40604283 if (child == null)
40614284 continue;
40624285
4063
- if (GrafreeD.RENDERME > 0)
4286
+ if (Grafreed.RENDERME > 0)
40644287 {
40654288 if (child instanceof Merge)
40664289 ((Merge)child).renderme();
....@@ -4157,6 +4380,71 @@
41574380 }
41584381 blockloop = true;
41594382 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();
41604448 blockloop = false;
41614449 }
41624450 }
....@@ -4651,7 +4939,7 @@
46514939
46524940 cTreePath SelectLeaf(int indexcount, boolean deselect)
46534941 {
4654
- if (hide)
4942
+ if (hide || dontselect)
46554943 return null;
46564944
46574945 if (count <= 0)
....@@ -4677,7 +4965,7 @@
46774965
46784966 cTreePath Select(int indexcount, boolean deselect)
46794967 {
4680
- if (hide)
4968
+ if (hide || dontselect)
46814969 return null;
46824970
46834971 if (count <= 0)
....@@ -4827,7 +5115,7 @@
48275115 return globalTransform;
48285116 }
48295117
4830
- void PreprocessOcclusion(CameraPane cp)
5118
+ void PreprocessOcclusion(iCameraPane cp)
48315119 {
48325120 /*
48335121 if (AOdone)
....@@ -4974,7 +5262,8 @@
49745262 } else //
49755263 if (editWindow != null)
49765264 {
4977
- editWindow.cameraView.lighttouched = true;
5265
+ //editWindow.cameraView.lighttouched = true;
5266
+ Globals.lighttouched = true;
49785267 }
49795268 }
49805269
....@@ -5128,10 +5417,34 @@
51285417
51295418 // System.out.println("Fullname = " + fullname);
51305419
5131
- if (fullname.name.indexOf(":") == -1)
5132
- 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(":"));
51335425
5134
- 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];
51355448 }
51365449
51375450 static String GetBump(cTexture fullname)
....@@ -5140,10 +5453,38 @@
51405453 return "";
51415454
51425455 // System.out.println("Fullname = " + fullname);
5143
- if (fullname.name.indexOf(":") == -1)
5144
- return "";
5145
-
5146
- 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];
51475488 }
51485489
51495490 String GetPigmentTexture()
....@@ -5217,7 +5558,7 @@
52175558 System.out.print("; textures = " + textures);
52185559 System.out.println("; usedtextures = " + usedtextures);
52195560
5220
- if (GetTextures() == null)
5561
+ if (GetTextures() == null) // What is that??
52215562 GetTextures().name = ":";
52225563
52235564 String texname = tex;
....@@ -5248,6 +5589,43 @@
52485589 child.ResetPigmentTexture();
52495590 blockloop = false;
52505591 }
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;
52515629 }
52525630
52535631 void SetBumpTexture(String tex)
....@@ -5286,25 +5664,33 @@
52865664 }
52875665 }
52885666
5289
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5667
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52905668 {
52915669 Draw(display, root, selected, blocked);
52925670 }
52935671
5294
- static cMaterial[] materialstack = new cMaterial[65536];
5295
- static boolean[] selectedstack = new boolean[65536];
5296
- static int materialdepth = 0;
5297
-
52985672 boolean NeedSupport()
52995673 {
53005674 return
5301
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5675
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53025676 // PROBLEM with CROWD!!
5303
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5677
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53045678 }
53055679
5680
+ static boolean DEBUG_SELECTION = false;
53065681
5307
- 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)
53085694 {
53095695 Invariants(); // june 2013
53105696
....@@ -5313,8 +5699,8 @@
53135699 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53145700 }
53155701
5316
- if (display.drawMode == CameraPane.SELECTION &&
5317
- hide)
5702
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5703
+ (hide || dontselect))
53185704 return;
53195705
53205706 if (name != null && name.contains("sclera"))
....@@ -5332,7 +5718,7 @@
53325718 if (this instanceof Checker)
53335719 return;
53345720
5335
- if (display.drawMode == display.SHADOW && PASSTEST)
5721
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53365722 return;
53375723
53385724 if (count <= 0)
....@@ -5340,13 +5726,13 @@
53405726 return;
53415727 }
53425728
5343
- if ((//display.drawMode == CameraPane.SHADOW ||
5344
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5729
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5730
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53455731 {
53465732 return;
53475733 }
53485734
5349
- javax.media.opengl.GL gl = display.GetGL();
5735
+ //javax.media.opengl.GL gl = display.GetGL();
53505736
53515737 /*
53525738 if (touched)
....@@ -5365,7 +5751,7 @@
53655751 support = support;
53665752
53675753 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5368
- 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);
53695755
53705756 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53715757 {
....@@ -5382,15 +5768,17 @@
53825768
53835769 boolean compiled = false;
53845770
5385
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5771
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53865772
5387
- if (!selectmode && //display.drawMode != display.SELECTION &&
5388
- (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)))
53895776 {
5390
- display.lighttouched = true;
5777
+ Globals.lighttouched = true;
53915778 } // all panes...
5392
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5393
- 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 &&
53945782 (touched || (bRep != null && bRep.displaylist <= 0)))
53955783 {
53965784 if (!(this instanceof Composite))
....@@ -5398,7 +5786,7 @@
53985786 //if (displaylist == -1 && usecalllists)
53995787 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54005788 {
5401
- bRep.displaylist = gl.glGenLists(1);
5789
+ bRep.displaylist = display.GenList();
54025790 assert(bRep.displaylist != 0);
54035791 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54045792 //System.out.println("\tgen list " + list);
....@@ -5410,18 +5798,20 @@
54105798 if (usecalllists)
54115799 {
54125800 // System.err.println("new list " + bRep.displaylist + " for " + this);
5413
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5801
+ display.NewList(bRep.displaylist);
54145802 }
5803
+
54155804 CallList(display, root, selected, blocked);
5805
+
54165806 // compiled = true;
54175807 if (usecalllists)
54185808 {
54195809 // System.err.println("end list " + bRep.displaylist + " for " + this);
5420
- gl.glEndList();
5810
+ display.EndList();
54215811 }
54225812 //gl.glDrawBuffer(gl.GL_BACK);
54235813 // XXX touched = false;
5424
- display.lighttouched = true; // all panes...
5814
+ Globals.lighttouched = true; // all panes...
54255815 }
54265816
54275817 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5460,12 +5850,12 @@
54605850
54615851 // frustum culling
54625852 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5463
- && display.drawMode != CameraPane.SELECTION)
5853
+ && display.DrawMode() != iCameraPane.SELECTION)
54645854 {
5465
- if (display.drawMode == CameraPane.SHADOW)
5855
+ if (display.DrawMode() == iCameraPane.SHADOW)
54665856 {
54675857 if (!link2master // tricky to cull in shadow mode.
5468
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5858
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54695859 {
54705860 //System.out.print("CULLED");
54715861 culled = true;
....@@ -5473,7 +5863,7 @@
54735863 }
54745864 else
54755865 //GetBRep().getBounds(v0, v1, this);
5476
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5866
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54775867 culled = true;
54785868
54795869 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5509,11 +5899,11 @@
55095899
55105900
55115901 if (!culled)
5512
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5902
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55135903 {
55145904 if (GetBRep() != null)
55155905 {
5516
- CameraPane.NextIndex(this, gl);
5906
+ display.NextIndex();
55175907 // vertex color conflict : gl.glCallList(list);
55185908 DrawNode(display, root, selected);
55195909 if (this instanceof BezierPatch)
....@@ -5535,55 +5925,7 @@
55355925 color[2] /= 2;
55365926 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55375927 */
5538
- if (material != null)
5539
- {
5540
- materialstack[materialdepth] = material;
5541
- selectedstack[materialdepth] = selected;
5542
- cStatic.objectstack[materialdepth++] = this;
5543
- //System.out.println("material " + material);
5544
- //Applet3D.tracein(this, selected);
5545
- display.vector2buffer = projectedVertices;
5546
- if (this instanceof Camera)
5547
- {
5548
- display.options1[0] = material.shift;
5549
- //System.out.println("shift " + material.shift);
5550
- display.options1[1] = material.lightarea;
5551
- display.options1[2] = material.shadowbias;
5552
- display.options1[3] = material.aniso;
5553
- display.options1[4] = material.anisoV;
5554
- display.options2[0] = material.opacity;
5555
- display.options2[1] = material.diffuse;
5556
- display.options2[2] = material.factor;
5557
-
5558
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5559
- display.options4[0] = material.cameralight/0.2f;
5560
- display.options4[1] = material.subsurface;
5561
- display.options4[2] = material.sheen;
5562
-
5563
- // if (display.CURRENTANTIALIAS > 0)
5564
- // display.options3[3] /= 4;
5565
-
5566
- /*
5567
- System.out.println("Focus = " + display.options1[0]);
5568
- System.out.println("Aperture = " + display.options1[1]);
5569
- System.out.println("ShadowBlur = " + display.options1[2]);
5570
- System.out.println("Antialiasing = " + display.options1[3]);
5571
- System.out.println("Fog = " + display.options2[0]);
5572
- System.out.println("Intensity = " + display.options2[1]);
5573
- System.out.println("Elevation = " + display.options2[2]);
5574
- /**/
5575
- } else
5576
- {
5577
- material.Draw(display, selected);
5578
- }
5579
- } else
5580
- {
5581
- if (selected && CameraPane.flash)
5582
- {
5583
- display.modelParams4[1] = 100;
5584
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5585
- }
5586
- }
5928
+ display.PushMaterial(this, selected);
55875929
55885930 //System.out.println("call list " + list);
55895931 //System.out.println();
....@@ -5602,7 +5944,28 @@
56025944 tex = GetTextures();
56035945 }
56045946
5605
- 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
+ }
56065969
56075970 if (!compiled)
56085971 {
....@@ -5618,30 +5981,19 @@
56185981
56195982 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56205983 assert(bRep.displaylist != 0);
5621
- gl.glCallList(bRep.displaylist);
5984
+ display.CallList(bRep.displaylist);
56225985 // june 2013 drawSelf(display, root, selected);
56235986 }
56245987 }
56255988 }
56265989
5627
- display.ReleaseTextures(tex);
5628
-
5629
- //if (parent != null && parent.GetMaterial() != null)
5630
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5631
- if (material != null)
5632
- {
5633
- materialdepth -= 1;
5634
- if (materialdepth > 0)
5635
- {
5636
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5637
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5638
- }
5639
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5640
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5641
- {
5642
- display.modelParams4[1] = GetMaterial().cameralight;
5643
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5644
- }
5990
+ if (!failedBump)
5991
+ display.ReleaseBumpTexture(tex);
5992
+
5993
+ if (!failedPigment)
5994
+ display.ReleasePigmentTexture(tex);
5995
+
5996
+ display.PopMaterial(this, selected);
56455997 }
56465998
56475999 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5683,7 +6035,7 @@
56836035 // resetMasterNode();
56846036 }
56856037
5686
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6038
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56876039 {
56886040 if (GetBRep() == null)
56896041 {
....@@ -5766,8 +6118,11 @@
57666118 boolean flipV = false; // true;
57676119 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57686120
5769
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6121
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57706122 {
6123
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6124
+ return;
6125
+
57716126 if (hide)
57726127 return;
57736128 // shadow optimisation
....@@ -5825,16 +6180,7 @@
58256180 // // ??????????????????????????? Touch();
58266181 // }
58276182
5828
- if (material != null)
5829
- {
5830
- materialstack[materialdepth] = material;
5831
- selectedstack[materialdepth] = selected;
5832
- cStatic.objectstack[materialdepth++] = this;
5833
- //System.out.println("material " + material);
5834
- //Applet3D.tracein("selected ", selected);
5835
- display.vector2buffer = projectedVertices;
5836
- material.Draw(display, selected);
5837
- }
6183
+display.PushMaterial2(this, selected);
58386184
58396185 Object3D child;
58406186 boolean sel;
....@@ -5886,19 +6232,7 @@
58866232 */
58876233 //depth += 1;
58886234
5889
- if (material != null)
5890
- {
5891
- materialdepth -= 1;
5892
- if (materialdepth > 0)
5893
- {
5894
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5895
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5896
- }
5897
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5898
- //else
5899
- //material.Draw(display, false);
5900
- }
5901
-
6235
+display.PopMaterial2(this);
59026236 /*
59036237 display.ReleaseTextures(tex);
59046238 */
....@@ -5909,10 +6243,13 @@
59096243
59106244 //static cVector min,max;
59116245
5912
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6246
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59136247 {
5914
- 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)
59156249 return; // no shadow for transparent objects
6250
+
6251
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6252
+ return;
59166253
59176254 if (hide)
59186255 return;
....@@ -5954,11 +6291,12 @@
59546291 return;
59556292 }
59566293
6294
+ //bRep.GenUV(1/material.diffuseness);
59576295 // bRep.lock = true;
59586296
5959
- javax.media.opengl.GL gl = display.GetGL();
6297
+ //javax.media.opengl.GL gl = display.GetGL();
59606298
5961
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6299
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59626300 {
59636301 int fc = bRep.FaceCount();
59646302 int vc = bRep.VertexCount();
....@@ -5973,23 +6311,7 @@
59736311
59746312 bRep.getMinMax(min, max, 100);
59756313
5976
- gl.glBegin(gl.GL_LINES);
5977
-
5978
- gl.glVertex3d(min.x, min.y, min.z);
5979
- gl.glVertex3d(min.x, min.y, max.z);
5980
- gl.glVertex3d(min.x, min.y, min.z);
5981
- gl.glVertex3d(min.x, max.y, min.z);
5982
- gl.glVertex3d(min.x, min.y, min.z);
5983
- gl.glVertex3d(max.x, min.y, min.z);
5984
-
5985
- gl.glVertex3d(max.x, max.y, max.z);
5986
- gl.glVertex3d(min.x, max.y, max.z);
5987
- gl.glVertex3d(max.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, min.y, max.z);
5989
- gl.glVertex3d(max.x, max.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, min.z);
5991
-
5992
- gl.glEnd();
6314
+ display.DrawBox(min, max);
59936315
59946316 return;
59956317 }
....@@ -6033,7 +6355,7 @@
60336355 {
60346356 //throw new Error();
60356357
6036
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6358
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60376359
60386360 int[] strips = bRep.getRawIndices();
60396361
....@@ -6043,178 +6365,19 @@
60436365 new Exception().printStackTrace();
60446366 return;
60456367 }
6046
-
6047
- // TRIANGLE STRIP ARRAY
6048
- if (bRep.trimmed)
6368
+
6369
+ if (dontselect)
60496370 {
6050
- float[] v = bRep.getRawVertices();
6051
- float[] n = bRep.getRawNormals();
6052
- float[] c = bRep.getRawColors();
6053
- float[] uv = bRep.getRawUVMap();
6054
-
6055
- int count2 = 0;
6056
- int count3 = 0;
6057
-
6058
- if (n.length > 0)
6059
- {
6060
- for (int i = 0; i < strips.length; i++)
6061
- {
6062
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6063
-
6064
- /*
6065
- boolean locked = false;
6066
- float eps = 0.1f;
6067
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6068
-
6069
- int dot = 0;
6070
-
6071
- if ((dot&1) == 0)
6072
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6073
-
6074
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6075
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6076
- else
6077
- {
6078
- locked = true;
6079
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6080
- }
6081
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6082
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6083
- if (hasnorm)
6084
- {
6085
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6086
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6087
- }
6088
-
6089
- if ((dot&4) == 0)
6090
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6091
-
6092
- if (wrap || !locked && (dot&8) != 0)
6093
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6094
- else
6095
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6096
-
6097
- f.dot = dot;
6098
- */
6099
-
6100
- if (!selectmode)
6101
- {
6102
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6103
- {
6104
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6105
- } else
6106
- {
6107
- gl.glNormal3f(0, 0, 1);
6108
- }
6109
-
6110
- if (c != null)
6111
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6112
- {
6113
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6114
- }
6115
- }
6116
- if (flipV)
6117
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6118
- else
6119
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6120
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6121
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6122
-
6123
- count2 += 2;
6124
- count3 += 3;
6125
- if (!selectmode)
6126
- {
6127
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6128
- {
6129
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6130
- } else
6131
- {
6132
- gl.glNormal3f(0, 0, 1);
6133
- }
6134
- if (c != null)
6135
- {
6136
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6137
- }
6138
- }
6139
- if (flipV)
6140
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6141
- else
6142
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6143
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6144
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6145
-
6146
- count2 += 2;
6147
- count3 += 3;
6148
- for (int j = 0; j < strips[i] - 2; j++)
6149
- {
6150
- //gl.glTexCoord2d(...);
6151
- if (!selectmode)
6152
- {
6153
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6154
- {
6155
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6156
- } else
6157
- {
6158
- gl.glNormal3f(0, 0, 1);
6159
- }
6160
- if (c != null)
6161
- {
6162
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6163
- }
6164
- }
6165
-
6166
- if (flipV)
6167
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6168
- else
6169
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6170
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6171
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6172
- count2 += 2;
6173
- count3 += 3;
6174
- }
6175
-
6176
- gl.glEnd();
6177
- }
6178
- }
6179
-
6180
- assert count3 == v.length;
6371
+ //bRep.GenerateNormalsMINE();
61816372 }
6182
- else // !trimmed
6183
- {
6184
- int count = 0;
6185
- for (int i = 0; i < strips.length; i++)
6186
- {
6187
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6188
-
6189
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6190
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6191
-
6192
- drawVertex(gl, p, selectmode);
6193
- drawVertex(gl, q, selectmode);
6194
-
6195
- for (int j = 0; j < strips[i] - 2; j++)
6196
- {
6197
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6198
-
6199
-// if (j%2 == 0)
6200
-// drawFace(p, q, r, display, null);
6201
-// else
6202
-// drawFace(p, r, q, display, null);
6203
-
6204
-// p = q;
6205
-// q = r;
6206
- drawVertex(gl, r, selectmode);
6207
- }
6208
-
6209
- gl.glEnd();
6210
- }
6211
- }
6373
+
6374
+ display.DrawGeometry(bRep, flipV, selectmode);
62126375 } else // catch (Error e)
62136376 {
62146377 // TRIANGLE ARRAY
62156378 if (IsOpaque()) // Static())
62166379 {
6217
- gl.glBegin(gl.GL_TRIANGLES);
6380
+ display.StartTriangles();
62186381 int facecount = bRep.FaceCount();
62196382 for (int i = 0; i < facecount; i++)
62206383 {
....@@ -6277,9 +6440,9 @@
62776440 // // r.norm.dot(v3) > -0.5)
62786441 // // continue;
62796442
6280
- drawFace(p, q, r, display, face);
6443
+ display.DrawFace(this, p, q, r, face);
62816444 }
6282
- gl.glEnd();
6445
+ display.EndTriangles();
62836446 }
62846447 else
62856448 {
....@@ -6308,8 +6471,8 @@
63086471 //System.out.println("SORT");
63096472
63106473 java.util.Arrays.sort(facescompare);
6311
-
6312
- gl.glBegin(gl.GL_TRIANGLES);
6474
+
6475
+ display.StartTriangles();
63136476 for (int i = 0; i < facecount; i++)
63146477 {
63156478 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6321,13 +6484,14 @@
63216484 Vertex q = bRep.GetVertex(face.q);
63226485 Vertex r = bRep.GetVertex(face.r);
63236486
6324
- drawFace(p, q, r, display, face);
6487
+ display.DrawFace(this, p, q, r, face);
63256488 }
6326
- gl.glEnd();
6489
+ display.EndTriangles();
63276490 }
63286491
63296492 if (false) // live && support != null && support.bRep != null) // debug weights
63306493 {
6494
+ /*
63316495 gl.glDisable(gl.GL_LIGHTING);
63326496 float[] colorV = new float[3];
63336497
....@@ -6406,6 +6570,7 @@
64066570 // gl.glEnd();
64076571 }
64086572 }
6573
+ */
64096574 }
64106575 }
64116576
....@@ -6450,7 +6615,7 @@
64506615 center.add(r);
64516616 center.mul(1.0/3);
64526617
6453
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6618
+ center.sub(Globals.theRenderer.EyeCamera().location);
64546619
64556620 distance = center.dot(center);
64566621 }
....@@ -6461,347 +6626,11 @@
64616626
64626627 transient FaceCompare[] facescompare = null;
64636628
6464
- void SetColor(CameraPane display, Vertex p0)
6465
- {
6466
- if (display.RENDERPROGRAM == 0)
6467
- {
6468
- float r = 0;
6469
- if (bRep != null)
6470
- {
6471
- if (bRep.stripified)
6472
- {
6473
- r = 1;
6474
- }
6475
- }
6476
- float g = 0;
6477
- if (bRep != null)
6478
- {
6479
- if (bRep.trimmed)
6480
- {
6481
- g = 1;
6482
- }
6483
- }
6484
- float b = 0;
6485
- if (support != null && link2master)
6486
- {
6487
- b = 1;
6488
- }
6489
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6490
- return;
6491
- }
6492
-
6493
- if (display.drawMode != CameraPane.SHADOW)
6494
- return;
6495
-
6496
- javax.media.opengl.GL gl = display.GetGL();
6497
-// if (true) return;
6498
-// float ao = p.AO;
6499
-//
6500
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6501
-// // ao = 1;
6502
-//
6503
-// gl.glColor4f(ao, ao, ao, 1);
6504
-
6505
-// CameraPane.selectedpoint.
6506
-// getAverage(cStatic.point1, true);
6507
- if (CameraPane.pointflow == null) // !random) // live)
6508
- {
6509
- return;
6510
- }
6511
-
6512
- cStatic.point1.set(0,0,0);
6513
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6514
-
6515
- cStatic.point1.sub(p0);
6516
-
6517
-
6518
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6519
-// {
6520
-// return;
6521
-// }
6522
-
6523
- //if (true)
6524
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6525
- {
6526
- return;
6527
- }
6528
-
6529
- float[] colorV = new float[3];
6530
-
6531
- if (false) // marked)
6532
- {
6533
- // debug rigging weights
6534
- for (int object = 0; object < p0.vertexlinks.length; object++)
6535
- {
6536
- float weight = p0.weights[object] / p0.totalweight;
6537
-
6538
- // if (weight < 0.1)
6539
- // {
6540
- // assert(weight == 0);
6541
- // continue;
6542
- // }
6543
-
6544
- if (p0.vertexlinks[object] == -1)
6545
- continue;
6546
-
6547
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6548
-
6549
- int color = //1 << object; //
6550
- //p.vertexlinks.length;
6551
- support.bRep.supports[p0.closestsupport].links[object];
6552
- colorV[2] += (color & 1) * weight;
6553
- colorV[1] += ((color & 2) >> 1) * weight;
6554
- colorV[0] += ((color & 4) >> 2) * weight;
6555
- }
6556
- }
6557
- else
6558
- {
6559
- if (drawingstarted)
6560
- {
6561
- // find next point
6562
- if (bRep.GetVertex(0).faceindices == null)
6563
- {
6564
- bRep.InitFaceIndices();
6565
- }
6566
-
6567
- double ymin = p0.y;
6568
-
6569
- Vertex newp = p0;
6570
-
6571
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6572
- {
6573
- int fi = p0.faceindices[fii];
6574
-
6575
- if (fi == -1)
6576
- break;
6577
-
6578
- Face f = bRep.GetFace(fi);
6579
-
6580
- Vertex p = bRep.GetVertex(f.p);
6581
- Vertex q = bRep.GetVertex(f.q);
6582
- Vertex r = bRep.GetVertex(f.r);
6583
-
6584
- int swap = (int)(Math.random()*3);
6585
-
6586
-// for (int s=swap; --s>=0;)
6587
-// {
6588
-// Vertex t = p;
6589
-// p = q;
6590
-// q = r;
6591
-// r = t;
6592
-// }
6593
- if (ymin > p.y)
6594
- {
6595
- ymin = p.y;
6596
- newp = p;
6597
-// break;
6598
- }
6599
- if (ymin > q.y)
6600
- {
6601
- ymin = q.y;
6602
- newp = q;
6603
-// break;
6604
- }
6605
- if (ymin > r.y)
6606
- {
6607
- ymin = r.y;
6608
- newp = r;
6609
-// break;
6610
- }
6611
- }
6612
-
6613
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6614
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6615
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6616
-
6617
- drawingstarted = false;
6618
-
6619
- // return;
6620
- }
6621
-
6622
- if (false) // CameraPane.DRAW
6623
- {
6624
- p0.AO = colorV[0] = 2;
6625
- colorV[1] = 2;
6626
- colorV[2] = 2;
6627
- }
6628
-
6629
- CameraPane.pointflow.add(p0);
6630
- CameraPane.pointflow.Touch();
6631
- }
6632
-
6633
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6634
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6635
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6636
- }
6637
-
66386629 void Print(Vertex v)
66396630 {
66406631 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66416632 }
66426633
6643
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6644
- {
6645
- if (!selectmode)
6646
- {
6647
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6648
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6649
-
6650
- if (flipV)
6651
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6652
- else
6653
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6654
- }
6655
-
6656
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6657
- }
6658
-
6659
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6660
- CameraPane display, Face face)
6661
- {
6662
- if (pv.y == -10000 ||
6663
- qv.y == -10000 ||
6664
- rv.y == -10000)
6665
- return;
6666
-
6667
-// float b = f.nbiterations & 1;
6668
-// float g = (f.nbiterations>>1) & 1;
6669
-// float r = (f.nbiterations>>2) & 1;
6670
-//
6671
-// //if (f.weight == 10000)
6672
-// //{
6673
-// // r = 1; g = b = 0;
6674
-// //}
6675
-// //else
6676
-// //{
6677
-// // assert(f.weight < 10000);
6678
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6679
-// if (r<0)
6680
-// assert(r>=0);
6681
-// //}
6682
-
6683
- javax.media.opengl.GL gl = display.GetGL();
6684
-
6685
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6686
-
6687
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6688
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6689
- {
6690
- //gl.glBegin(gl.GL_TRIANGLES);
6691
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6692
- if (!hasnorm)
6693
- {
6694
- // System.out.println("FUCK!!");
6695
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6696
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6697
- LA.vecCross(v0, v1, v2);
6698
- LA.vecNormalize(v2);
6699
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6700
- }
6701
-
6702
- if (hasnorm)
6703
- {
6704
-// if (!pv.norm.normalized())
6705
-// assert(pv.norm.normalized());
6706
-
6707
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6708
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6709
- }
6710
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6711
- SetColor(display, pv);
6712
- //gl.glColor4f(r, g, b, 1);
6713
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6714
- if (flipV)
6715
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6716
- else
6717
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6718
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6719
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6720
-// Print(pv);
6721
- if (hasnorm)
6722
- {
6723
-// assert(qv.norm.normalized());
6724
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6725
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6726
- }
6727
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6728
- // boolean locked = false;
6729
- // float eps = 0.1f;
6730
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6731
-
6732
- // int dot = 0; //*/ (int)f.dot;
6733
-
6734
- // if ((dot&1) == 0)
6735
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6736
-
6737
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6738
- if (flipV)
6739
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6740
- else
6741
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6742
- // else
6743
- // {
6744
- // locked = true;
6745
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6746
- // }
6747
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6748
- SetColor(display, qv);
6749
- //gl.glColor4f(r, g, b, 1);
6750
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6751
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6752
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6753
-// Print(qv);
6754
- if (hasnorm)
6755
- {
6756
-// assert(rv.norm.normalized());
6757
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6758
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6759
- }
6760
-
6761
- // if ((dot&4) == 0)
6762
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6763
-
6764
- // if (wrap || !locked && (dot&8) != 0)
6765
- if (flipV)
6766
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6767
- else
6768
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6769
- // else
6770
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6771
-
6772
- // f.dot = dot;
6773
-
6774
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6775
- SetColor(display, rv);
6776
- //gl.glColor4f(r, g, b, 1);
6777
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6778
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6779
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6780
-// Print(rv);
6781
- //gl.glEnd();
6782
- }
6783
- else
6784
- {
6785
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6786
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6787
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6788
-
6789
- }
6790
-
6791
- if (false) // (attributes & WIREFRAME) != 0)
6792
- {
6793
- gl.glDisable(gl.GL_LIGHTING);
6794
-
6795
- gl.glBegin(gl.GL_LINE_LOOP);
6796
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6797
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6798
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6799
- gl.glEnd();
6800
-
6801
- gl.glEnable(gl.GL_LIGHTING);
6802
- }
6803
- }
6804
-
68056634 void drawSelf(ClickInfo info, int level, boolean select)
68066635 {
68076636 if (bRep == null)
....@@ -7373,83 +7202,84 @@
73737202 int spotw = spot.x + spot.width;
73747203 int spoth = spot.y + spot.height;
73757204 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7376
- if (CameraPane.Xmin > spot.x)
7377
- {
7378
- CameraPane.Xmin = spot.x;
7379
- }
7380
- if (CameraPane.Xmax < spotw)
7381
- {
7382
- CameraPane.Xmax = spotw;
7383
- }
7384
- if (CameraPane.Ymin > spot.y)
7385
- {
7386
- CameraPane.Ymin = spot.y;
7387
- }
7388
- if (CameraPane.Ymax < spoth)
7389
- {
7390
- CameraPane.Ymax = spoth;
7391
- }
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
+// }
73927221 spot.translate(32, 32);
73937222 spotw = spot.x + spot.width;
73947223 spoth = spot.y + spot.height;
7395
- info.g.setColor(Color.blue);
7224
+ info.g.setColor(Color.cyan);
73967225 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7397
- if (CameraPane.Xmin > spot.x)
7398
- {
7399
- CameraPane.Xmin = spot.x;
7400
- }
7401
- if (CameraPane.Xmax < spotw)
7402
- {
7403
- CameraPane.Xmax = spotw;
7404
- }
7405
- if (CameraPane.Ymin > spot.y)
7406
- {
7407
- CameraPane.Ymin = spot.y;
7408
- }
7409
- if (CameraPane.Ymax < spoth)
7410
- {
7411
- CameraPane.Ymax = spoth;
7412
- }
7413
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7414
- 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
74157244 spot.translate(0, -32);
7416
- info.g.setColor(Color.green);
7245
+ info.g.setColor(Color.yellow);
74177246 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7418
- if (CameraPane.Xmin > spot.x)
7419
- {
7420
- CameraPane.Xmin = spot.x;
7421
- }
7422
- if (CameraPane.Xmax < spotw)
7423
- {
7424
- CameraPane.Xmax = spotw;
7425
- }
7426
- if (CameraPane.Ymin > spot.y)
7427
- {
7428
- CameraPane.Ymin = spot.y;
7429
- }
7430
- if (CameraPane.Ymax < spoth)
7431
- {
7432
- CameraPane.Ymax = spoth;
7433
- }
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
+// }
74347264 info.g.drawArc(boundary.x, boundary.y,
74357265 boundary.width, boundary.height, 0, 360);
74367266 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7437
- if (CameraPane.Xmin > boundary.x)
7438
- {
7439
- CameraPane.Xmin = boundary.x;
7440
- }
7441
- if (CameraPane.Xmax < boundary.x + boundary.width)
7442
- {
7443
- CameraPane.Xmax = boundary.x + boundary.width;
7444
- }
7445
- if (CameraPane.Ymin > boundary.y)
7446
- {
7447
- CameraPane.Ymin = boundary.y;
7448
- }
7449
- if (CameraPane.Ymax < boundary.y + boundary.height)
7450
- {
7451
- CameraPane.Ymax = boundary.y + boundary.height;
7452
- }
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
+// }
74537283 return;
74547284 }
74557285 }
....@@ -7466,7 +7296,7 @@
74667296 startX = info.x;
74677297 startY = info.y;
74687298
7469
- hitSomething = 0;
7299
+ hitSomething = -1;
74707300 cVector origin = new cVector();
74717301 //LA.xformPos(origin, toParent, origin);
74727302 Rectangle spot = new Rectangle();
....@@ -7499,7 +7329,7 @@
74997329 }
75007330
75017331 //System.out.println("info.modifiers = " + info.modifiers);
7502
- modified = (info.modifiers & CameraPane.META) != 0;
7332
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
75037333 //System.out.println("modified = " + modified);
75047334 //new Exception().printStackTrace();
75057335 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7527,7 +7357,7 @@
75277357 return true;
75287358 }
75297359
7530
- void doEditDrag0(ClickInfo info)
7360
+ void doEditDrag0(ClickInfo info, boolean opposite)
75317361 {
75327362 if (hitSomething == 0)
75337363 {
....@@ -7542,6 +7372,7 @@
75427372 //System.out.println("hitSomething = " + hitSomething);
75437373
75447374 double scale = 0.005f * info.camera.Distance();
7375
+
75457376 cVector xlate = new cVector();
75467377 //cVector xlate2 = new cVector();
75477378 switch (hitSomething)
....@@ -7552,9 +7383,9 @@
75527383
75537384 case hitCenter: // Translate
75547385
7555
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7386
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75567387
7557
- if (modified)
7388
+ if (modified || opposite)
75587389 {
75597390 //assert(false);
75607391 /*
....@@ -7600,10 +7431,10 @@
76007431 }
76017432 LA.xformDir(up, ClickInfo.matbuffer, up);
76027433 // if (!CameraPane.LOCALTRANSFORM)
7603
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7434
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
76047435 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
76057436 // if (!CameraPane.LOCALTRANSFORM)
7606
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7437
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76077438 //LA.vecCross(up, cVector.Z, right2);
76087439
76097440 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7648,6 +7479,7 @@
76487479
76497480 if (modified)
76507481 {
7482
+ // Rotate 90 degrees
76517483 angle /= (Math.PI / 4);
76527484 angle = Math.floor(angle + 0.5);
76537485 angle *= (Math.PI / 4);
....@@ -7661,7 +7493,7 @@
76617493 }
76627494 /**/
76637495
7664
- switch (info.pane.renderCamera.viewCode)
7496
+ switch (info.pane.RenderCamera().viewCode)
76657497 {
76667498 case 1: // '\001'
76677499 LA.matZRotate(toParent, angle);
....@@ -7689,24 +7521,27 @@
76897521
76907522 case hitScale: // scale
76917523 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);
76927530 if (hScale < 0.01)
76937531 {
7694
- hScale = 0.01;
7532
+ //hScale = 0.01;
76957533 }
7696
- hScale = Math.pow(hScale, scale * 50);
7697
- if (hScale < 0.01)
7698
- {
7699
- hScale = 0.01;
7700
- }
7534
+
77017535 double vScale = (double) (info.y - centerPt.y) / 32;
7702
- if (vScale < 0.01)
7536
+ sign = 1;
7537
+ if (vScale < 0)
77037538 {
7704
- vScale = 0.01;
7539
+ sign = -1;
77057540 }
7706
- vScale = Math.pow(vScale, scale * 50);
7541
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77077542 if (vScale < 0.01)
77087543 {
7709
- vScale = 0.01;
7544
+ //vScale = 0.01;
77107545 }
77117546 LA.matCopy(startMat, toParent);
77127547 /**/
....@@ -7717,39 +7552,47 @@
77177552 }
77187553 /**/
77197554
7720
- 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)
77217563 {
77227564 case 3: // '\001'
7723
- if (modified)
7565
+ if (modified || opposite)
77247566 {
77257567 //LA.matScale(toParent, 1, hScale, vScale);
7726
- LA.matScale(toParent, vScale, 1, 1);
7568
+ LA.matScale(toParent, totalScale, 1, 1);
77277569 } // vScale, 1);
77287570 else
77297571 {
7730
- LA.matScale(toParent, vScale, vScale, vScale);
7572
+ // EXCEPTION!
7573
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
77317574 } // vScale, 1);
77327575 break;
77337576
77347577 case 2: // '\002'
7735
- if (modified)
7578
+ if (modified || opposite)
77367579 {
77377580 //LA.matScale(toParent, hScale, 1, vScale);
7738
- LA.matScale(toParent, 1, vScale, 1);
7581
+ LA.matScale(toParent, 1, totalScale, 1);
77397582 } else
77407583 {
7741
- LA.matScale(toParent, vScale, 1, vScale);
7584
+ LA.matScale(toParent, totalScale, 1, totalScale);
77427585 }
77437586 break;
77447587
77457588 case 1: // '\003'
7746
- if (modified)
7589
+ if (modified || opposite)
77477590 {
77487591 //LA.matScale(toParent, hScale, vScale, 1);
7749
- LA.matScale(toParent, 1, 1, vScale);
7592
+ LA.matScale(toParent, 1, 1, totalScale);
77507593 } else
77517594 {
7752
- LA.matScale(toParent, vScale, vScale, 1);
7595
+ LA.matScale(toParent, totalScale, totalScale, 1);
77537596 }
77547597 break;
77557598 }
....@@ -7882,14 +7725,22 @@
78827725 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78837726 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78847727 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7728
+
7729
+ String objname;
7730
+
78857731 if (false) //parent != null)
78867732 {
7887
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7733
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78887734 } else
78897735 {
7890
- 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) ":"") */ "";
78917737 } // + super.toString();
78927738 //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);
78937744 }
78947745
78957746 public int hashCode()
....@@ -7945,6 +7796,7 @@
79457796 objectUI.closeUI();
79467797 if (editWindow != null)
79477798 {
7799
+ editWindow.ctrlPanel.FlushUI();
79487800 editWindow.refreshContents();
79497801 } // ? new
79507802 objectUI = null;
....@@ -7953,6 +7805,10 @@
79537805 {
79547806 editWindow = null;
79557807 } // ?
7808
+ }
7809
+ else
7810
+ {
7811
+ //editWindow.closeUI();
79567812 }
79577813 }
79587814
....@@ -7965,7 +7821,7 @@
79657821 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79667822
79677823 Object3D /*Composite*/ parent;
7968
- Object3D /*Composite*/ fileparent;
7824
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79697825
79707826 double[][] toParent; // dynamic matrix
79717827 double[][] fromParent;
....@@ -8080,7 +7936,7 @@
80807936 {
80817937 assert(bRep != null);
80827938 if (!(support instanceof GenericJoint)) // support.bRep != null)
8083
- GrafreeD.Assert(support.bRep == bRep.support);
7939
+ Grafreed.Assert(support.bRep == bRep.support);
80847940 }
80857941 else
80867942 {
....@@ -8129,9 +7985,9 @@
81297985 private static cVector edge2 = new cVector();
81307986 //private static cVector norm = new cVector();
81317987 /*transient private*/ int hitSomething;
8132
- private static final int hitCenter = 1;
8133
- private static final int hitScale = 2;
8134
- private static final int hitRotate = 3;
7988
+ static final int hitCenter = 1;
7989
+ static final int hitScale = 2;
7990
+ static final int hitRotate = 3;
81357991 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81367992 /*transient*/ private Point centerPt;
81377993 /*transient*/ private int startX;
....@@ -8163,6 +8019,8 @@
81638019 {
81648020 Object3D targ = this;
81658021
8022
+ targ.NORMALPUSH = obj.NORMALPUSH;
8023
+
81668024 if (obj.material != null)
81678025 {
81688026 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))