Normand Briere
2019-06-17 e36047725ce3217618d4e5807ac7c8769b9e3598
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) &&
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);
....@@ -893,6 +996,11 @@
893996 fromParent = null; // LA.newMatrix();
894997 bRep = null; // new BoundaryRep();
895998
999
+ if (oname != null && oname.equals("LeftHand"))
1000
+ {
1001
+ name = oname;
1002
+ }
1003
+
8961004 /*
8971005 float hue = (float)Math.random();
8981006 Color col;
....@@ -935,7 +1043,7 @@
9351043
9361044 public Object clone()
9371045 {
938
- return GrafreeD.clone(this);
1046
+ return Grafreed.clone(this);
9391047 }
9401048
9411049 Object3D copyExpand()
....@@ -1446,7 +1554,16 @@
14461554 // if (other == null)
14471555 // return;
14481556
1449
- System.out.println("Link support this = " + this + "; other = " + other);
1557
+ if (other != null)
1558
+ {
1559
+ BoundaryRep.SEUIL = other.material.cameralight;
1560
+
1561
+ // Set default to 0.1
1562
+ BoundaryRep.SEUIL /= 4; // 2;
1563
+ System.out.println("SEUIL = " + BoundaryRep.SEUIL);
1564
+ }
1565
+
1566
+ System.out.println("Link this = " + this + "; support = " + other);
14501567
14511568 //if (bRep != null)
14521569 // bRep.linkVerticesThis(other.bRep);
....@@ -1701,7 +1818,7 @@
17011818 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17021819 o.bRep = transientrep;
17031820 if (clone)
1704
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1821
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17051822 o.CreateMaterial();
17061823 o.SetAttributes(this, -1);
17071824 //parent
....@@ -1714,7 +1831,7 @@
17141831 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17151832 o.bRep = bRep;
17161833 if (clone)
1717
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1834
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17181835 o.CreateMaterial();
17191836 //o.overwriteThis(this, -1);
17201837 o.SetAttributes(this, -1);
....@@ -1801,12 +1918,15 @@
18011918 if (obj.name == null)
18021919 continue; // can't be a null one
18031920
1921
+ // Try perfect match first.
18041922 if (n.equals(obj.name))
18051923 {
18061924 theobj = obj;
18071925 count++;
18081926 }
18091927 }
1928
+
1929
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18101930
18111931 if (count != 1)
18121932 for (int i=Size(); --i>=0;)
....@@ -1816,8 +1936,9 @@
18161936 if (obj.name == null)
18171937 continue; // can't be a null one
18181938
1819
- //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count
1820
- if (n.startsWith(obj.name))
1939
+ String name = obj.name.split(":")[0]; // Poser generates a count
1940
+ //if (n.startsWith(obj.name))
1941
+ if (n.contains(name))
18211942 {
18221943 theobj = obj;
18231944 count++;
....@@ -2120,15 +2241,8 @@
21202241 if (/*parent != null &&*/ material == null)
21212242 {
21222243 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
2244
+
2245
+ InitOthers();
21322246
21332247 if (this instanceof Camera)
21342248 {
....@@ -2278,6 +2392,7 @@
22782392 {
22792393 if (newWindow)
22802394 {
2395
+ new Exception().printStackTrace();
22812396 System.exit(0);
22822397 if (parent != null)
22832398 {
....@@ -2454,13 +2569,13 @@
24542569 return retval;
24552570 }
24562571
2457
- void doEditDrag(ClickInfo info)
2572
+ void doEditDrag(ClickInfo info, boolean opposite)
24582573 {
24592574 switch (doSomething)
24602575 {
24612576 case 1: // '\001'
24622577 //super.
2463
- doEditDrag0(info);
2578
+ doEditDrag0(info, opposite);
24642579 break;
24652580
24662581 case 2: // '\002'
....@@ -2473,11 +2588,11 @@
24732588 {
24742589 //sel.hitSomething = childToDrag.hitSomething;
24752590 //childToDrag.doEditDrag(info);
2476
- sel.doEditDrag(info);
2591
+ sel.doEditDrag(info, opposite);
24772592 } else
24782593 {
24792594 //super.
2480
- doEditDrag0(info);
2595
+ doEditDrag0(info, opposite);
24812596 }
24822597 }
24832598 break;
....@@ -2587,6 +2702,18 @@
25872702 void GenNormalsS(boolean crease)
25882703 {
25892704 selection.GenNormals(crease);
2705
+// for (int i=0; i<selection.size(); i++)
2706
+// {
2707
+// Object3D selectee = (Object3D) selection.elementAt(i);
2708
+// selectee.GenNormals(crease);
2709
+// }
2710
+
2711
+ //Touch();
2712
+ }
2713
+
2714
+ void GenNormalsMeshS()
2715
+ {
2716
+ selection.GenNormalsMesh();
25902717 // for (int i=0; i<selection.size(); i++)
25912718 // {
25922719 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2732,6 +2859,42 @@
27322859 blockloop = false;
27332860 }
27342861
2862
+ void GenNormalsMesh()
2863
+ {
2864
+ if (blockloop)
2865
+ return;
2866
+
2867
+ blockloop = true;
2868
+ GenNormalsMesh0();
2869
+ for (int i = 0; i < Children().Size(); i++)
2870
+ {
2871
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2872
+ if (child == null)
2873
+ continue;
2874
+ child.GenNormalsMesh();
2875
+// Children().release(i);
2876
+ }
2877
+ blockloop = false;
2878
+ }
2879
+
2880
+ void GenNormalsMINE()
2881
+ {
2882
+ if (blockloop)
2883
+ return;
2884
+
2885
+ blockloop = true;
2886
+ GenNormalsMINE0();
2887
+ for (int i = 0; i < Children().Size(); i++)
2888
+ {
2889
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2890
+ if (child == null)
2891
+ continue;
2892
+ child.GenNormalsMINE();
2893
+// Children().release(i);
2894
+ }
2895
+ blockloop = false;
2896
+ }
2897
+
27352898 void ClearColors()
27362899 {
27372900 if (blockloop)
....@@ -2866,7 +3029,8 @@
28663029 {
28673030 if (bRep != null)
28683031 {
2869
- bRep.GenUV();
3032
+ bRep.GenUV(); //1);
3033
+ //bRep.UnfoldUV();
28703034 Touch();
28713035 }
28723036 }
....@@ -2876,6 +3040,24 @@
28763040 if (bRep != null)
28773041 {
28783042 bRep.GenerateNormals(crease);
3043
+ Touch();
3044
+ }
3045
+ }
3046
+
3047
+ void GenNormalsMesh0()
3048
+ {
3049
+ if (bRep != null)
3050
+ {
3051
+ bRep.GenerateNormalsMesh();
3052
+ Touch();
3053
+ }
3054
+ }
3055
+
3056
+ void GenNormalsMINE0()
3057
+ {
3058
+ if (bRep != null)
3059
+ {
3060
+ bRep.GenerateNormalsMINE();
28793061 Touch();
28803062 }
28813063 }
....@@ -2932,6 +3114,33 @@
29323114 blockloop = false;
29333115 }
29343116
3117
+ void TransformChildren()
3118
+ {
3119
+ if (toParent != null)
3120
+ {
3121
+ for (int i=Size(); --i>=0;)
3122
+ {
3123
+ Object3D v = get(i);
3124
+
3125
+ if (v.toParent == null)
3126
+ {
3127
+ v.toParent = LA.newMatrix();
3128
+ v.fromParent = LA.newMatrix();
3129
+ }
3130
+
3131
+// LA.matConcat(v.toParent, toParent, v.toParent);
3132
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3133
+ LA.matConcat(toParent, v.toParent, v.toParent);
3134
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3135
+ }
3136
+
3137
+ toParent = null; // LA.matIdentity(toParent);
3138
+ fromParent = null; // LA.matIdentity(fromParent);
3139
+
3140
+ Touch();
3141
+ }
3142
+ }
3143
+
29353144 void TransformGeometry()
29363145 {
29373146 Object3D obj = this;
....@@ -3153,9 +3362,11 @@
31533362
31543363 BoundaryRep sup = bRep.support;
31553364 bRep.support = null;
3156
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3365
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31573366 // bRep.SplitInTwo(onlyone); // thread...
3158
- temprep.SplitInTwo(reduction34, onlyone);
3367
+
3368
+ while(temprep.SplitInTwo(reduction34, onlyone));
3369
+
31593370 bRep = temprep;
31603371 bRep.support = sup;
31613372 Touch();
....@@ -3677,7 +3888,7 @@
36773888 if (child == null)
36783889 continue;
36793890
3680
- if (GrafreeD.RENDERME > 0)
3891
+ if (Grafreed.RENDERME > 0)
36813892 {
36823893 if (child instanceof Merge)
36833894 ((Merge)child).renderme();
....@@ -3828,7 +4039,7 @@
38284039 if (child == null)
38294040 continue;
38304041
3831
- if (GrafreeD.RENDERME > 0)
4042
+ if (Grafreed.RENDERME > 0)
38324043 {
38334044 if (child instanceof Merge)
38344045 ((Merge)child).renderme();
....@@ -4023,7 +4234,7 @@
40234234 if (child == null)
40244235 continue;
40254236
4026
- if (GrafreeD.RENDERME > 0)
4237
+ if (Grafreed.RENDERME > 0)
40274238 {
40284239 if (child instanceof Merge)
40294240 ((Merge)child).renderme();
....@@ -4111,7 +4322,7 @@
41114322 if (blockloop)
41124323 return;
41134324
4114
- for (int i=0; i<size(); i++)
4325
+ for (int i=0; i<Size(); i++)
41154326 {
41164327 if (get(i).parent != this)
41174328 {
....@@ -4120,6 +4331,71 @@
41204331 }
41214332 blockloop = true;
41224333 get(i).RepairParent();
4334
+ blockloop = false;
4335
+ }
4336
+ }
4337
+
4338
+ void RepairShadow()
4339
+ {
4340
+ if (blockloop)
4341
+ return;
4342
+
4343
+ if (this.material != null)
4344
+ this.InitOthers();
4345
+
4346
+ for (int i=0; i<Size(); i++)
4347
+ {
4348
+ blockloop = true;
4349
+ get(i).RepairShadow();
4350
+ blockloop = false;
4351
+ }
4352
+ }
4353
+
4354
+ void RepairSOV()
4355
+ {
4356
+ if (blockloop)
4357
+ return;
4358
+
4359
+ String texname = this.GetPigmentTexture();
4360
+
4361
+ if (texname.startsWith("sov"))
4362
+ {
4363
+ String[] s = texname.split("/");
4364
+
4365
+ String[] sname = s[1].split("Color.pn");
4366
+
4367
+ texname = sname[0];
4368
+
4369
+ if (sname.length > 1)
4370
+ {
4371
+ texname += "Color.jpg";
4372
+ }
4373
+
4374
+ this.SetPigmentTexture("sov/" + texname);
4375
+ }
4376
+
4377
+ texname = this.GetBumpTexture();
4378
+
4379
+ if (texname.startsWith("sov"))
4380
+ {
4381
+ String[] s = texname.split("/");
4382
+
4383
+ String[] sname = s[1].split("Bump.pn");
4384
+
4385
+ texname = sname[0];
4386
+
4387
+ if (sname.length > 1)
4388
+ {
4389
+ texname += "Bump.jpg";
4390
+ }
4391
+
4392
+ this.SetBumpTexture("sov/" + texname);
4393
+ }
4394
+
4395
+ for (int i=0; i<Size(); i++)
4396
+ {
4397
+ blockloop = true;
4398
+ get(i).RepairSOV();
41234399 blockloop = false;
41244400 }
41254401 }
....@@ -4614,7 +4890,7 @@
46144890
46154891 cTreePath SelectLeaf(int indexcount, boolean deselect)
46164892 {
4617
- if (hide)
4893
+ if (hide || dontselect)
46184894 return null;
46194895
46204896 if (count <= 0)
....@@ -4640,7 +4916,7 @@
46404916
46414917 cTreePath Select(int indexcount, boolean deselect)
46424918 {
4643
- if (hide)
4919
+ if (hide || dontselect)
46444920 return null;
46454921
46464922 if (count <= 0)
....@@ -4790,7 +5066,7 @@
47905066 return globalTransform;
47915067 }
47925068
4793
- void PreprocessOcclusion(CameraPane cp)
5069
+ void PreprocessOcclusion(iCameraPane cp)
47945070 {
47955071 /*
47965072 if (AOdone)
....@@ -4937,7 +5213,8 @@
49375213 } else //
49385214 if (editWindow != null)
49395215 {
4940
- editWindow.cameraView.lighttouched = true;
5216
+ //editWindow.cameraView.lighttouched = true;
5217
+ Globals.lighttouched = true;
49415218 }
49425219 }
49435220
....@@ -5091,10 +5368,34 @@
50915368
50925369 // System.out.println("Fullname = " + fullname);
50935370
5094
- if (fullname.name.indexOf(":") == -1)
5095
- return fullname.name;
5371
+ // Does not work on Windows due to C:
5372
+// if (fullname.name.indexOf(":") == -1)
5373
+// return fullname.name;
5374
+//
5375
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
50965376
5097
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5377
+ String[] split = fullname.name.split(":");
5378
+
5379
+ if (split.length == 0)
5380
+ {
5381
+ return "";
5382
+ }
5383
+
5384
+ if (split.length <= 2)
5385
+ {
5386
+ if (fullname.name.endsWith(":"))
5387
+ {
5388
+ // Windows
5389
+ return fullname.name.substring(0, fullname.name.length()-1);
5390
+ }
5391
+
5392
+ return split[0];
5393
+ }
5394
+
5395
+ // Windows
5396
+ assert(split.length == 4);
5397
+
5398
+ return split[0] + ":" + split[1];
50985399 }
50995400
51005401 static String GetBump(cTexture fullname)
....@@ -5103,10 +5404,38 @@
51035404 return "";
51045405
51055406 // 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());
5407
+ // Does not work on Windows due to C:
5408
+// if (fullname.name.indexOf(":") == -1)
5409
+// return "";
5410
+//
5411
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5412
+ String[] split = fullname.name.split(":");
5413
+
5414
+ if (split.length == 0)
5415
+ {
5416
+ return "";
5417
+ }
5418
+
5419
+ if (split.length == 1)
5420
+ {
5421
+ return "";
5422
+ }
5423
+
5424
+ if (split.length == 2)
5425
+ {
5426
+ if (fullname.name.endsWith(":"))
5427
+ {
5428
+ // Windows
5429
+ return "";
5430
+ }
5431
+
5432
+ return split[1];
5433
+ }
5434
+
5435
+ // Windows
5436
+ assert(split.length == 4);
5437
+
5438
+ return split[2] + ":" + split[3];
51105439 }
51115440
51125441 String GetPigmentTexture()
....@@ -5180,7 +5509,7 @@
51805509 System.out.print("; textures = " + textures);
51815510 System.out.println("; usedtextures = " + usedtextures);
51825511
5183
- if (GetTextures() == null)
5512
+ if (GetTextures() == null) // What is that??
51845513 GetTextures().name = ":";
51855514
51865515 String texname = tex;
....@@ -5211,6 +5540,43 @@
52115540 child.ResetPigmentTexture();
52125541 blockloop = false;
52135542 }
5543
+ }
5544
+
5545
+ UUID GetUUID()
5546
+ {
5547
+ if (uuid == null)
5548
+ {
5549
+ // Serial
5550
+ uuid = UUID.randomUUID();
5551
+ }
5552
+
5553
+ return uuid;
5554
+ }
5555
+
5556
+ Object3D GetObject(UUID uid)
5557
+ {
5558
+ if (blockloop)
5559
+ return null;
5560
+
5561
+ if (GetUUID().equals(uid))
5562
+ return this;
5563
+
5564
+ int nb = Size();
5565
+ for (int i = 0; i < nb; i++)
5566
+ {
5567
+ Object3D child = (Object3D) get(i);
5568
+
5569
+ if (child == null)
5570
+ continue;
5571
+
5572
+ blockloop = true;
5573
+ Object3D obj = child.GetObject(uid);
5574
+ blockloop = false;
5575
+ if (obj != null)
5576
+ return obj;
5577
+ }
5578
+
5579
+ return null;
52145580 }
52155581
52165582 void SetBumpTexture(String tex)
....@@ -5249,25 +5615,33 @@
52495615 }
52505616 }
52515617
5252
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5618
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52535619 {
52545620 Draw(display, root, selected, blocked);
52555621 }
52565622
5257
- static cMaterial[] materialstack = new cMaterial[65536];
5258
- static boolean[] selectedstack = new boolean[65536];
5259
- static int materialdepth = 0;
5260
-
52615623 boolean NeedSupport()
52625624 {
52635625 return
5264
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5626
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
52655627 // PROBLEM with CROWD!!
5266
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5628
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
52675629 }
52685630
5631
+ static boolean DEBUG_SELECTION = false;
52695632
5270
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5633
+ boolean IsLive()
5634
+ {
5635
+ if (live)
5636
+ return true;
5637
+
5638
+ if (parent == null)
5639
+ return false;
5640
+
5641
+ return parent.IsLive();
5642
+ }
5643
+
5644
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52715645 {
52725646 Invariants(); // june 2013
52735647
....@@ -5276,8 +5650,8 @@
52765650 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
52775651 }
52785652
5279
- if (display.drawMode == CameraPane.SELECTION &&
5280
- hide)
5653
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5654
+ (hide || dontselect))
52815655 return;
52825656
52835657 if (name != null && name.contains("sclera"))
....@@ -5295,7 +5669,7 @@
52955669 if (this instanceof Checker)
52965670 return;
52975671
5298
- if (display.drawMode == display.SHADOW && PASSTEST)
5672
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
52995673 return;
53005674
53015675 if (count <= 0)
....@@ -5303,13 +5677,13 @@
53035677 return;
53045678 }
53055679
5306
- if ((//display.drawMode == CameraPane.SHADOW ||
5307
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5680
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5681
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53085682 {
53095683 return;
53105684 }
53115685
5312
- javax.media.opengl.GL gl = display.GetGL();
5686
+ //javax.media.opengl.GL gl = display.GetGL();
53135687
53145688 /*
53155689 if (touched)
....@@ -5328,7 +5702,7 @@
53285702 support = support;
53295703
53305704 //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);
5705
+ boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53325706
53335707 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53345708 {
....@@ -5345,15 +5719,17 @@
53455719
53465720 boolean compiled = false;
53475721
5348
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5722
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53495723
5350
- if (!selectmode && //display.drawMode != display.SELECTION &&
5351
- (touched || (bRep != null && bRep.displaylist <= 0)))
5724
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5725
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5726
+ (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0)))
53525727 {
5353
- display.lighttouched = true;
5728
+ Globals.lighttouched = true;
53545729 } // 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 &&
5730
+
5731
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5732
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53575733 (touched || (bRep != null && bRep.displaylist <= 0)))
53585734 {
53595735 if (!(this instanceof Composite))
....@@ -5361,7 +5737,7 @@
53615737 //if (displaylist == -1 && usecalllists)
53625738 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
53635739 {
5364
- bRep.displaylist = gl.glGenLists(1);
5740
+ bRep.displaylist = display.GenList();
53655741 assert(bRep.displaylist != 0);
53665742 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
53675743 //System.out.println("\tgen list " + list);
....@@ -5373,18 +5749,20 @@
53735749 if (usecalllists)
53745750 {
53755751 // System.err.println("new list " + bRep.displaylist + " for " + this);
5376
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5752
+ display.NewList(bRep.displaylist);
53775753 }
5754
+
53785755 CallList(display, root, selected, blocked);
5756
+
53795757 // compiled = true;
53805758 if (usecalllists)
53815759 {
53825760 // System.err.println("end list " + bRep.displaylist + " for " + this);
5383
- gl.glEndList();
5761
+ display.EndList();
53845762 }
53855763 //gl.glDrawBuffer(gl.GL_BACK);
53865764 // XXX touched = false;
5387
- display.lighttouched = true; // all panes...
5765
+ Globals.lighttouched = true; // all panes...
53885766 }
53895767
53905768 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5423,12 +5801,12 @@
54235801
54245802 // frustum culling
54255803 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5426
- && display.drawMode != CameraPane.SELECTION)
5804
+ && display.DrawMode() != iCameraPane.SELECTION)
54275805 {
5428
- if (display.drawMode == CameraPane.SHADOW)
5806
+ if (display.DrawMode() == iCameraPane.SHADOW)
54295807 {
54305808 if (!link2master // tricky to cull in shadow mode.
5431
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
5809
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54325810 {
54335811 //System.out.print("CULLED");
54345812 culled = true;
....@@ -5436,7 +5814,7 @@
54365814 }
54375815 else
54385816 //GetBRep().getBounds(v0, v1, this);
5439
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
5817
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54405818 culled = true;
54415819
54425820 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5472,11 +5850,11 @@
54725850
54735851
54745852 if (!culled)
5475
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
5853
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
54765854 {
54775855 if (GetBRep() != null)
54785856 {
5479
- CameraPane.NextIndex(this, gl);
5857
+ display.NextIndex();
54805858 // vertex color conflict : gl.glCallList(list);
54815859 DrawNode(display, root, selected);
54825860 if (this instanceof BezierPatch)
....@@ -5498,53 +5876,7 @@
54985876 color[2] /= 2;
54995877 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55005878 */
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.options3[3] = material.cameralight/0.2f;
5523
-
5524
- // if (display.CURRENTANTIALIAS > 0)
5525
- // display.options3[3] /= 4;
5526
-
5527
- /*
5528
- System.out.println("Focus = " + display.options1[0]);
5529
- System.out.println("Aperture = " + display.options1[1]);
5530
- System.out.println("ShadowBlur = " + display.options1[2]);
5531
- System.out.println("Antialiasing = " + display.options1[3]);
5532
- System.out.println("Fog = " + display.options2[0]);
5533
- System.out.println("Intensity = " + display.options2[1]);
5534
- System.out.println("Elevation = " + display.options2[2]);
5535
- /**/
5536
- } else
5537
- {
5538
- material.Draw(display, selected);
5539
- }
5540
- } else
5541
- {
5542
- if (selected && CameraPane.flash)
5543
- {
5544
- display.modelParams4[1] = 100;
5545
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5546
- }
5547
- }
5879
+ display.PushMaterial(this, selected);
55485880
55495881 //System.out.println("call list " + list);
55505882 //System.out.println();
....@@ -5563,7 +5895,28 @@
55635895 tex = GetTextures();
55645896 }
55655897
5566
- display.BindTextures(tex, texres);
5898
+ boolean failedPigment = false;
5899
+ boolean failedBump = false;
5900
+
5901
+ try
5902
+ {
5903
+ display.BindPigmentTexture(tex, texres);
5904
+ }
5905
+ catch (Exception e)
5906
+ {
5907
+ System.err.println("FAILED: " + this);
5908
+ failedPigment = true;
5909
+ }
5910
+
5911
+ try
5912
+ {
5913
+ display.BindBumpTexture(tex, texres);
5914
+ }
5915
+ catch (Exception e)
5916
+ {
5917
+ //System.err.println("FAILED: " + this);
5918
+ failedBump = true;
5919
+ }
55675920
55685921 if (!compiled)
55695922 {
....@@ -5579,30 +5932,19 @@
55795932
55805933 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
55815934 assert(bRep.displaylist != 0);
5582
- gl.glCallList(bRep.displaylist);
5935
+ display.CallList(bRep.displaylist);
55835936 // june 2013 drawSelf(display, root, selected);
55845937 }
55855938 }
55865939 }
55875940
5588
- display.ReleaseTextures(tex);
5589
-
5590
- //if (parent != null && parent.GetMaterial() != null)
5591
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5592
- if (material != null)
5593
- {
5594
- materialdepth -= 1;
5595
- if (materialdepth > 0)
5596
- {
5597
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5598
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5599
- }
5600
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5601
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5602
- {
5603
- display.modelParams4[1] = GetMaterial().cameralight;
5604
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5605
- }
5941
+ if (!failedBump)
5942
+ display.ReleaseBumpTexture(tex);
5943
+
5944
+ if (!failedPigment)
5945
+ display.ReleasePigmentTexture(tex);
5946
+
5947
+ display.PopMaterial(this, selected);
56065948 }
56075949
56085950 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5644,7 +5986,7 @@
56445986 // resetMasterNode();
56455987 }
56465988
5647
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5989
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56485990 {
56495991 if (GetBRep() == null)
56505992 {
....@@ -5727,8 +6069,11 @@
57276069 boolean flipV = false; // true;
57286070 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57296071
5730
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6072
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57316073 {
6074
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6075
+ return;
6076
+
57326077 if (hide)
57336078 return;
57346079 // shadow optimisation
....@@ -5786,16 +6131,7 @@
57866131 // // ??????????????????????????? Touch();
57876132 // }
57886133
5789
- if (material != null)
5790
- {
5791
- materialstack[materialdepth] = material;
5792
- selectedstack[materialdepth] = selected;
5793
- cStatic.objectstack[materialdepth++] = this;
5794
- //System.out.println("material " + material);
5795
- //Applet3D.tracein("selected ", selected);
5796
- display.vector2buffer = projectedVertices;
5797
- material.Draw(display, selected);
5798
- }
6134
+display.PushMaterial2(this, selected);
57996135
58006136 Object3D child;
58016137 boolean sel;
....@@ -5847,19 +6183,7 @@
58476183 */
58486184 //depth += 1;
58496185
5850
- if (material != null)
5851
- {
5852
- materialdepth -= 1;
5853
- if (materialdepth > 0)
5854
- {
5855
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5856
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5857
- }
5858
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5859
- //else
5860
- //material.Draw(display, false);
5861
- }
5862
-
6186
+display.PopMaterial2(this);
58636187 /*
58646188 display.ReleaseTextures(tex);
58656189 */
....@@ -5870,10 +6194,13 @@
58706194
58716195 //static cVector min,max;
58726196
5873
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6197
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
58746198 {
5875
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6199
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
58766200 return; // no shadow for transparent objects
6201
+
6202
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6203
+ return;
58776204
58786205 if (hide)
58796206 return;
....@@ -5915,11 +6242,12 @@
59156242 return;
59166243 }
59176244
6245
+ //bRep.GenUV(1/material.diffuseness);
59186246 // bRep.lock = true;
59196247
5920
- javax.media.opengl.GL gl = display.GetGL();
6248
+ //javax.media.opengl.GL gl = display.GetGL();
59216249
5922
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6250
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59236251 {
59246252 int fc = bRep.FaceCount();
59256253 int vc = bRep.VertexCount();
....@@ -5934,23 +6262,7 @@
59346262
59356263 bRep.getMinMax(min, max, 100);
59366264
5937
- gl.glBegin(gl.GL_LINES);
5938
-
5939
- gl.glVertex3d(min.x, min.y, min.z);
5940
- gl.glVertex3d(min.x, min.y, max.z);
5941
- gl.glVertex3d(min.x, min.y, min.z);
5942
- gl.glVertex3d(min.x, max.y, min.z);
5943
- gl.glVertex3d(min.x, min.y, min.z);
5944
- gl.glVertex3d(max.x, min.y, min.z);
5945
-
5946
- gl.glVertex3d(max.x, max.y, max.z);
5947
- gl.glVertex3d(min.x, max.y, max.z);
5948
- gl.glVertex3d(max.x, max.y, max.z);
5949
- gl.glVertex3d(max.x, min.y, max.z);
5950
- gl.glVertex3d(max.x, max.y, max.z);
5951
- gl.glVertex3d(max.x, max.y, min.z);
5952
-
5953
- gl.glEnd();
6265
+ display.DrawBox(min, max);
59546266
59556267 return;
59566268 }
....@@ -5994,7 +6306,7 @@
59946306 {
59956307 //throw new Error();
59966308
5997
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6309
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
59986310
59996311 int[] strips = bRep.getRawIndices();
60006312
....@@ -6004,178 +6316,14 @@
60046316 new Exception().printStackTrace();
60056317 return;
60066318 }
6007
-
6008
- // TRIANGLE STRIP ARRAY
6009
- if (bRep.trimmed)
6010
- {
6011
- float[] v = bRep.getRawVertices();
6012
- float[] n = bRep.getRawNormals();
6013
- float[] c = bRep.getRawColors();
6014
- float[] uv = bRep.getRawUVMap();
6015
-
6016
- int count2 = 0;
6017
- int count3 = 0;
6018
-
6019
- if (n.length > 0)
6020
- {
6021
- for (int i = 0; i < strips.length; i++)
6022
- {
6023
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6024
-
6025
- /*
6026
- boolean locked = false;
6027
- float eps = 0.1f;
6028
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6029
-
6030
- int dot = 0;
6031
-
6032
- if ((dot&1) == 0)
6033
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6034
-
6035
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6036
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6037
- else
6038
- {
6039
- locked = true;
6040
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6041
- }
6042
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6043
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6044
- if (hasnorm)
6045
- {
6046
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6047
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6048
- }
6049
-
6050
- if ((dot&4) == 0)
6051
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6052
-
6053
- if (wrap || !locked && (dot&8) != 0)
6054
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6055
- else
6056
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6057
-
6058
- f.dot = dot;
6059
- */
6060
-
6061
- if (!selectmode)
6062
- {
6063
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6064
- {
6065
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6066
- } else
6067
- {
6068
- gl.glNormal3f(0, 0, 1);
6069
- }
6070
-
6071
- if (c != null)
6072
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6073
- {
6074
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6075
- }
6076
- }
6077
- if (flipV)
6078
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6079
- else
6080
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6081
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6082
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6083
-
6084
- count2 += 2;
6085
- count3 += 3;
6086
- if (!selectmode)
6087
- {
6088
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6089
- {
6090
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6091
- } else
6092
- {
6093
- gl.glNormal3f(0, 0, 1);
6094
- }
6095
- if (c != null)
6096
- {
6097
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6098
- }
6099
- }
6100
- if (flipV)
6101
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6102
- else
6103
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6104
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6105
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6106
-
6107
- count2 += 2;
6108
- count3 += 3;
6109
- for (int j = 0; j < strips[i] - 2; j++)
6110
- {
6111
- //gl.glTexCoord2d(...);
6112
- if (!selectmode)
6113
- {
6114
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6115
- {
6116
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6117
- } else
6118
- {
6119
- gl.glNormal3f(0, 0, 1);
6120
- }
6121
- if (c != null)
6122
- {
6123
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6124
- }
6125
- }
6126
-
6127
- if (flipV)
6128
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6129
- else
6130
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6131
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6132
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6133
- count2 += 2;
6134
- count3 += 3;
6135
- }
6136
-
6137
- gl.glEnd();
6138
- }
6139
- }
6140
-
6141
- assert count3 == v.length;
6142
- }
6143
- else // !trimmed
6144
- {
6145
- int count = 0;
6146
- for (int i = 0; i < strips.length; i++)
6147
- {
6148
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6149
-
6150
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6151
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6152
-
6153
- drawVertex(gl, p, selectmode);
6154
- drawVertex(gl, q, selectmode);
6155
-
6156
- for (int j = 0; j < strips[i] - 2; j++)
6157
- {
6158
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6159
-
6160
-// if (j%2 == 0)
6161
-// drawFace(p, q, r, display, null);
6162
-// else
6163
-// drawFace(p, r, q, display, null);
6164
-
6165
-// p = q;
6166
-// q = r;
6167
- drawVertex(gl, r, selectmode);
6168
- }
6169
-
6170
- gl.glEnd();
6171
- }
6172
- }
6319
+
6320
+ display.DrawGeometry(bRep, flipV, selectmode);
61736321 } else // catch (Error e)
61746322 {
61756323 // TRIANGLE ARRAY
61766324 if (IsOpaque()) // Static())
61776325 {
6178
- gl.glBegin(gl.GL_TRIANGLES);
6326
+ display.StartTriangles();
61796327 int facecount = bRep.FaceCount();
61806328 for (int i = 0; i < facecount; i++)
61816329 {
....@@ -6238,9 +6386,9 @@
62386386 // // r.norm.dot(v3) > -0.5)
62396387 // // continue;
62406388
6241
- drawFace(p, q, r, display, face);
6389
+ display.DrawFace(this, p, q, r, face);
62426390 }
6243
- gl.glEnd();
6391
+ display.EndTriangles();
62446392 }
62456393 else
62466394 {
....@@ -6269,8 +6417,8 @@
62696417 //System.out.println("SORT");
62706418
62716419 java.util.Arrays.sort(facescompare);
6272
-
6273
- gl.glBegin(gl.GL_TRIANGLES);
6420
+
6421
+ display.StartTriangles();
62746422 for (int i = 0; i < facecount; i++)
62756423 {
62766424 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6282,13 +6430,14 @@
62826430 Vertex q = bRep.GetVertex(face.q);
62836431 Vertex r = bRep.GetVertex(face.r);
62846432
6285
- drawFace(p, q, r, display, face);
6433
+ display.DrawFace(this, p, q, r, face);
62866434 }
6287
- gl.glEnd();
6435
+ display.EndTriangles();
62886436 }
62896437
62906438 if (false) // live && support != null && support.bRep != null) // debug weights
62916439 {
6440
+ /*
62926441 gl.glDisable(gl.GL_LIGHTING);
62936442 float[] colorV = new float[3];
62946443
....@@ -6367,6 +6516,7 @@
63676516 // gl.glEnd();
63686517 }
63696518 }
6519
+ */
63706520 }
63716521 }
63726522
....@@ -6411,7 +6561,7 @@
64116561 center.add(r);
64126562 center.mul(1.0/3);
64136563
6414
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6564
+ center.sub(Globals.theRenderer.EyeCamera().location);
64156565
64166566 distance = center.dot(center);
64176567 }
....@@ -6422,347 +6572,11 @@
64226572
64236573 transient FaceCompare[] facescompare = null;
64246574
6425
- void SetColor(CameraPane display, Vertex p0)
6426
- {
6427
- if (display.RENDERPROGRAM == 0)
6428
- {
6429
- float r = 0;
6430
- if (bRep != null)
6431
- {
6432
- if (bRep.stripified)
6433
- {
6434
- r = 1;
6435
- }
6436
- }
6437
- float g = 0;
6438
- if (bRep != null)
6439
- {
6440
- if (bRep.trimmed)
6441
- {
6442
- g = 1;
6443
- }
6444
- }
6445
- float b = 0;
6446
- if (support != null && link2master)
6447
- {
6448
- b = 1;
6449
- }
6450
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6451
- return;
6452
- }
6453
-
6454
- if (display.drawMode != CameraPane.SHADOW)
6455
- return;
6456
-
6457
- javax.media.opengl.GL gl = display.GetGL();
6458
-// if (true) return;
6459
-// float ao = p.AO;
6460
-//
6461
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6462
-// // ao = 1;
6463
-//
6464
-// gl.glColor4f(ao, ao, ao, 1);
6465
-
6466
-// CameraPane.selectedpoint.
6467
-// getAverage(cStatic.point1, true);
6468
- if (CameraPane.pointflow == null) // !random) // live)
6469
- {
6470
- return;
6471
- }
6472
-
6473
- cStatic.point1.set(0,0,0);
6474
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6475
-
6476
- cStatic.point1.sub(p0);
6477
-
6478
-
6479
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6480
-// {
6481
-// return;
6482
-// }
6483
-
6484
- //if (true)
6485
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6486
- {
6487
- return;
6488
- }
6489
-
6490
- float[] colorV = new float[3];
6491
-
6492
- if (false) // marked)
6493
- {
6494
- // debug rigging weights
6495
- for (int object = 0; object < p0.vertexlinks.length; object++)
6496
- {
6497
- float weight = p0.weights[object] / p0.totalweight;
6498
-
6499
- // if (weight < 0.1)
6500
- // {
6501
- // assert(weight == 0);
6502
- // continue;
6503
- // }
6504
-
6505
- if (p0.vertexlinks[object] == -1)
6506
- continue;
6507
-
6508
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6509
-
6510
- int color = //1 << object; //
6511
- //p.vertexlinks.length;
6512
- support.bRep.supports[p0.closestsupport].links[object];
6513
- colorV[2] += (color & 1) * weight;
6514
- colorV[1] += ((color & 2) >> 1) * weight;
6515
- colorV[0] += ((color & 4) >> 2) * weight;
6516
- }
6517
- }
6518
- else
6519
- {
6520
- if (drawingstarted)
6521
- {
6522
- // find next point
6523
- if (bRep.GetVertex(0).faceindices == null)
6524
- {
6525
- bRep.InitFaceIndices();
6526
- }
6527
-
6528
- double ymin = p0.y;
6529
-
6530
- Vertex newp = p0;
6531
-
6532
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6533
- {
6534
- int fi = p0.faceindices[fii];
6535
-
6536
- if (fi == -1)
6537
- break;
6538
-
6539
- Face f = bRep.GetFace(fi);
6540
-
6541
- Vertex p = bRep.GetVertex(f.p);
6542
- Vertex q = bRep.GetVertex(f.q);
6543
- Vertex r = bRep.GetVertex(f.r);
6544
-
6545
- int swap = (int)(Math.random()*3);
6546
-
6547
-// for (int s=swap; --s>=0;)
6548
-// {
6549
-// Vertex t = p;
6550
-// p = q;
6551
-// q = r;
6552
-// r = t;
6553
-// }
6554
- if (ymin > p.y)
6555
- {
6556
- ymin = p.y;
6557
- newp = p;
6558
-// break;
6559
- }
6560
- if (ymin > q.y)
6561
- {
6562
- ymin = q.y;
6563
- newp = q;
6564
-// break;
6565
- }
6566
- if (ymin > r.y)
6567
- {
6568
- ymin = r.y;
6569
- newp = r;
6570
-// break;
6571
- }
6572
- }
6573
-
6574
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6575
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6576
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6577
-
6578
- drawingstarted = false;
6579
-
6580
- // return;
6581
- }
6582
-
6583
- if (false) // CameraPane.DRAW
6584
- {
6585
- p0.AO = colorV[0] = 2;
6586
- colorV[1] = 2;
6587
- colorV[2] = 2;
6588
- }
6589
-
6590
- CameraPane.pointflow.add(p0);
6591
- CameraPane.pointflow.Touch();
6592
- }
6593
-
6594
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6595
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6596
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6597
- }
6598
-
65996575 void Print(Vertex v)
66006576 {
66016577 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66026578 }
66036579
6604
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6605
- {
6606
- if (!selectmode)
6607
- {
6608
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6609
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6610
-
6611
- if (flipV)
6612
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6613
- else
6614
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6615
- }
6616
-
6617
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6618
- }
6619
-
6620
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6621
- CameraPane display, Face face)
6622
- {
6623
- if (pv.y == -10000 ||
6624
- qv.y == -10000 ||
6625
- rv.y == -10000)
6626
- return;
6627
-
6628
-// float b = f.nbiterations & 1;
6629
-// float g = (f.nbiterations>>1) & 1;
6630
-// float r = (f.nbiterations>>2) & 1;
6631
-//
6632
-// //if (f.weight == 10000)
6633
-// //{
6634
-// // r = 1; g = b = 0;
6635
-// //}
6636
-// //else
6637
-// //{
6638
-// // assert(f.weight < 10000);
6639
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6640
-// if (r<0)
6641
-// assert(r>=0);
6642
-// //}
6643
-
6644
- javax.media.opengl.GL gl = display.GetGL();
6645
-
6646
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6647
-
6648
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6649
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6650
- {
6651
- //gl.glBegin(gl.GL_TRIANGLES);
6652
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6653
- if (!hasnorm)
6654
- {
6655
- // System.out.println("FUCK!!");
6656
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6657
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6658
- LA.vecCross(v0, v1, v2);
6659
- LA.vecNormalize(v2);
6660
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6661
- }
6662
-
6663
- if (hasnorm)
6664
- {
6665
-// if (!pv.norm.normalized())
6666
-// assert(pv.norm.normalized());
6667
-
6668
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6669
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6670
- }
6671
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6672
- SetColor(display, pv);
6673
- //gl.glColor4f(r, g, b, 1);
6674
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6675
- if (flipV)
6676
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6677
- else
6678
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6679
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6680
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6681
-// Print(pv);
6682
- if (hasnorm)
6683
- {
6684
-// assert(qv.norm.normalized());
6685
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6686
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6687
- }
6688
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6689
- // boolean locked = false;
6690
- // float eps = 0.1f;
6691
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6692
-
6693
- // int dot = 0; //*/ (int)f.dot;
6694
-
6695
- // if ((dot&1) == 0)
6696
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6697
-
6698
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6699
- if (flipV)
6700
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6701
- else
6702
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6703
- // else
6704
- // {
6705
- // locked = true;
6706
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6707
- // }
6708
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6709
- SetColor(display, qv);
6710
- //gl.glColor4f(r, g, b, 1);
6711
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6712
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6713
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6714
-// Print(qv);
6715
- if (hasnorm)
6716
- {
6717
-// assert(rv.norm.normalized());
6718
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6719
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6720
- }
6721
-
6722
- // if ((dot&4) == 0)
6723
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6724
-
6725
- // if (wrap || !locked && (dot&8) != 0)
6726
- if (flipV)
6727
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6728
- else
6729
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6730
- // else
6731
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6732
-
6733
- // f.dot = dot;
6734
-
6735
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6736
- SetColor(display, rv);
6737
- //gl.glColor4f(r, g, b, 1);
6738
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6739
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6740
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6741
-// Print(rv);
6742
- //gl.glEnd();
6743
- }
6744
- else
6745
- {
6746
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6747
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6748
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6749
-
6750
- }
6751
-
6752
- if (false) // (attributes & WIREFRAME) != 0)
6753
- {
6754
- gl.glDisable(gl.GL_LIGHTING);
6755
-
6756
- gl.glBegin(gl.GL_LINE_LOOP);
6757
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6758
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6759
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6760
- gl.glEnd();
6761
-
6762
- gl.glEnable(gl.GL_LIGHTING);
6763
- }
6764
- }
6765
-
67666580 void drawSelf(ClickInfo info, int level, boolean select)
67676581 {
67686582 if (bRep == null)
....@@ -7334,83 +7148,84 @@
73347148 int spotw = spot.x + spot.width;
73357149 int spoth = spot.y + spot.height;
73367150 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7337
- if (CameraPane.Xmin > spot.x)
7338
- {
7339
- CameraPane.Xmin = spot.x;
7340
- }
7341
- if (CameraPane.Xmax < spotw)
7342
- {
7343
- CameraPane.Xmax = spotw;
7344
- }
7345
- if (CameraPane.Ymin > spot.y)
7346
- {
7347
- CameraPane.Ymin = spot.y;
7348
- }
7349
- if (CameraPane.Ymax < spoth)
7350
- {
7351
- CameraPane.Ymax = spoth;
7352
- }
7151
+// if (CameraPane.Xmin > spot.x)
7152
+// {
7153
+// CameraPane.Xmin = spot.x;
7154
+// }
7155
+// if (CameraPane.Xmax < spotw)
7156
+// {
7157
+// CameraPane.Xmax = spotw;
7158
+// }
7159
+// if (CameraPane.Ymin > spot.y)
7160
+// {
7161
+// CameraPane.Ymin = spot.y;
7162
+// }
7163
+// if (CameraPane.Ymax < spoth)
7164
+// {
7165
+// CameraPane.Ymax = spoth;
7166
+// }
73537167 spot.translate(32, 32);
73547168 spotw = spot.x + spot.width;
73557169 spoth = spot.y + spot.height;
7356
- info.g.setColor(Color.blue);
7170
+ info.g.setColor(Color.cyan);
73577171 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7358
- if (CameraPane.Xmin > spot.x)
7359
- {
7360
- CameraPane.Xmin = spot.x;
7361
- }
7362
- if (CameraPane.Xmax < spotw)
7363
- {
7364
- CameraPane.Xmax = spotw;
7365
- }
7366
- if (CameraPane.Ymin > spot.y)
7367
- {
7368
- CameraPane.Ymin = spot.y;
7369
- }
7370
- if (CameraPane.Ymax < spoth)
7371
- {
7372
- CameraPane.Ymax = spoth;
7373
- }
7374
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7375
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7172
+// if (CameraPane.Xmin > spot.x)
7173
+// {
7174
+// CameraPane.Xmin = spot.x;
7175
+// }
7176
+// if (CameraPane.Xmax < spotw)
7177
+// {
7178
+// CameraPane.Xmax = spotw;
7179
+// }
7180
+// if (CameraPane.Ymin > spot.y)
7181
+// {
7182
+// CameraPane.Ymin = spot.y;
7183
+// }
7184
+// if (CameraPane.Ymax < spoth)
7185
+// {
7186
+// CameraPane.Ymax = spoth;
7187
+// }
7188
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7189
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
73767190 spot.translate(0, -32);
7377
- info.g.setColor(Color.green);
7191
+ info.g.setColor(Color.yellow);
73787192 info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7379
- if (CameraPane.Xmin > spot.x)
7380
- {
7381
- CameraPane.Xmin = spot.x;
7382
- }
7383
- if (CameraPane.Xmax < spotw)
7384
- {
7385
- CameraPane.Xmax = spotw;
7386
- }
7387
- if (CameraPane.Ymin > spot.y)
7388
- {
7389
- CameraPane.Ymin = spot.y;
7390
- }
7391
- if (CameraPane.Ymax < spoth)
7392
- {
7393
- CameraPane.Ymax = spoth;
7394
- }
7193
+ info.g.setColor(Color.green);
7194
+// if (CameraPane.Xmin > spot.x)
7195
+// {
7196
+// CameraPane.Xmin = spot.x;
7197
+// }
7198
+// if (CameraPane.Xmax < spotw)
7199
+// {
7200
+// CameraPane.Xmax = spotw;
7201
+// }
7202
+// if (CameraPane.Ymin > spot.y)
7203
+// {
7204
+// CameraPane.Ymin = spot.y;
7205
+// }
7206
+// if (CameraPane.Ymax < spoth)
7207
+// {
7208
+// CameraPane.Ymax = spoth;
7209
+// }
73957210 info.g.drawArc(boundary.x, boundary.y,
73967211 boundary.width, boundary.height, 0, 360);
73977212 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7398
- if (CameraPane.Xmin > boundary.x)
7399
- {
7400
- CameraPane.Xmin = boundary.x;
7401
- }
7402
- if (CameraPane.Xmax < boundary.x + boundary.width)
7403
- {
7404
- CameraPane.Xmax = boundary.x + boundary.width;
7405
- }
7406
- if (CameraPane.Ymin > boundary.y)
7407
- {
7408
- CameraPane.Ymin = boundary.y;
7409
- }
7410
- if (CameraPane.Ymax < boundary.y + boundary.height)
7411
- {
7412
- CameraPane.Ymax = boundary.y + boundary.height;
7413
- }
7213
+// if (CameraPane.Xmin > boundary.x)
7214
+// {
7215
+// CameraPane.Xmin = boundary.x;
7216
+// }
7217
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7218
+// {
7219
+// CameraPane.Xmax = boundary.x + boundary.width;
7220
+// }
7221
+// if (CameraPane.Ymin > boundary.y)
7222
+// {
7223
+// CameraPane.Ymin = boundary.y;
7224
+// }
7225
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7226
+// {
7227
+// CameraPane.Ymax = boundary.y + boundary.height;
7228
+// }
74147229 return;
74157230 }
74167231 }
....@@ -7427,7 +7242,7 @@
74277242 startX = info.x;
74287243 startY = info.y;
74297244
7430
- hitSomething = 0;
7245
+ hitSomething = -1;
74317246 cVector origin = new cVector();
74327247 //LA.xformPos(origin, toParent, origin);
74337248 Rectangle spot = new Rectangle();
....@@ -7460,7 +7275,7 @@
74607275 }
74617276
74627277 //System.out.println("info.modifiers = " + info.modifiers);
7463
- modified = (info.modifiers & CameraPane.META) != 0;
7278
+ modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META
74647279 //System.out.println("modified = " + modified);
74657280 //new Exception().printStackTrace();
74667281 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7488,7 +7303,7 @@
74887303 return true;
74897304 }
74907305
7491
- void doEditDrag0(ClickInfo info)
7306
+ void doEditDrag0(ClickInfo info, boolean opposite)
74927307 {
74937308 if (hitSomething == 0)
74947309 {
....@@ -7503,6 +7318,7 @@
75037318 //System.out.println("hitSomething = " + hitSomething);
75047319
75057320 double scale = 0.005f * info.camera.Distance();
7321
+
75067322 cVector xlate = new cVector();
75077323 //cVector xlate2 = new cVector();
75087324 switch (hitSomething)
....@@ -7513,9 +7329,9 @@
75137329
75147330 case hitCenter: // Translate
75157331
7516
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7332
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75177333
7518
- if (modified)
7334
+ if (modified || opposite)
75197335 {
75207336 //assert(false);
75217337 /*
....@@ -7561,10 +7377,10 @@
75617377 }
75627378 LA.xformDir(up, ClickInfo.matbuffer, up);
75637379 // if (!CameraPane.LOCALTRANSFORM)
7564
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7380
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
75657381 LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
75667382 // if (!CameraPane.LOCALTRANSFORM)
7567
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7383
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
75687384 //LA.vecCross(up, cVector.Z, right2);
75697385
75707386 cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
....@@ -7609,6 +7425,7 @@
76097425
76107426 if (modified)
76117427 {
7428
+ // Rotate 90 degrees
76127429 angle /= (Math.PI / 4);
76137430 angle = Math.floor(angle + 0.5);
76147431 angle *= (Math.PI / 4);
....@@ -7622,7 +7439,7 @@
76227439 }
76237440 /**/
76247441
7625
- switch (info.pane.renderCamera.viewCode)
7442
+ switch (info.pane.RenderCamera().viewCode)
76267443 {
76277444 case 1: // '\001'
76287445 LA.matZRotate(toParent, angle);
....@@ -7650,24 +7467,27 @@
76507467
76517468 case hitScale: // scale
76527469 double hScale = (double) (info.x - centerPt.x) / 32;
7470
+ double sign = 1;
7471
+ if (hScale < 0)
7472
+ {
7473
+ sign = -1;
7474
+ }
7475
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76537476 if (hScale < 0.01)
76547477 {
7655
- hScale = 0.01;
7478
+ //hScale = 0.01;
76567479 }
7657
- hScale = Math.pow(hScale, scale * 50);
7658
- if (hScale < 0.01)
7659
- {
7660
- hScale = 0.01;
7661
- }
7480
+
76627481 double vScale = (double) (info.y - centerPt.y) / 32;
7663
- if (vScale < 0.01)
7482
+ sign = 1;
7483
+ if (vScale < 0)
76647484 {
7665
- vScale = 0.01;
7485
+ sign = -1;
76667486 }
7667
- vScale = Math.pow(vScale, scale * 50);
7487
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
76687488 if (vScale < 0.01)
76697489 {
7670
- vScale = 0.01;
7490
+ //vScale = 0.01;
76717491 }
76727492 LA.matCopy(startMat, toParent);
76737493 /**/
....@@ -7678,39 +7498,47 @@
76787498 }
76797499 /**/
76807500
7681
- switch (info.pane.renderCamera.viewCode)
7501
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2);
7502
+
7503
+ if (totalScale < 0.01)
7504
+ {
7505
+ totalScale = 0.01;
7506
+ }
7507
+
7508
+ switch (info.pane.RenderCamera().viewCode)
76827509 {
76837510 case 3: // '\001'
7684
- if (modified)
7511
+ if (modified || opposite)
76857512 {
76867513 //LA.matScale(toParent, 1, hScale, vScale);
7687
- LA.matScale(toParent, vScale, 1, 1);
7514
+ LA.matScale(toParent, totalScale, 1, 1);
76887515 } // vScale, 1);
76897516 else
76907517 {
7691
- LA.matScale(toParent, vScale, vScale, vScale);
7518
+ // EXCEPTION!
7519
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
76927520 } // vScale, 1);
76937521 break;
76947522
76957523 case 2: // '\002'
7696
- if (modified)
7524
+ if (modified || opposite)
76977525 {
76987526 //LA.matScale(toParent, hScale, 1, vScale);
7699
- LA.matScale(toParent, 1, vScale, 1);
7527
+ LA.matScale(toParent, 1, totalScale, 1);
77007528 } else
77017529 {
7702
- LA.matScale(toParent, vScale, 1, vScale);
7530
+ LA.matScale(toParent, totalScale, 1, totalScale);
77037531 }
77047532 break;
77057533
77067534 case 1: // '\003'
7707
- if (modified)
7535
+ if (modified || opposite)
77087536 {
77097537 //LA.matScale(toParent, hScale, vScale, 1);
7710
- LA.matScale(toParent, 1, 1, vScale);
7538
+ LA.matScale(toParent, 1, 1, totalScale);
77117539 } else
77127540 {
7713
- LA.matScale(toParent, vScale, vScale, 1);
7541
+ LA.matScale(toParent, totalScale, totalScale, 1);
77147542 }
77157543 break;
77167544 }
....@@ -7731,7 +7559,7 @@
77317559 if (parent == null)
77327560 {
77337561 System.out.println("NULL PARENT");
7734
- new Exception().printStackTrace();
7562
+ //new Exception().printStackTrace();
77357563 } else
77367564 {
77377565 if (parent instanceof BezierPatch)
....@@ -7843,14 +7671,22 @@
78437671 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78447672 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78457673 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7674
+
7675
+ String objname;
7676
+
78467677 if (false) //parent != null)
78477678 {
7848
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7679
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78497680 } else
78507681 {
7851
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7682
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78527683 } // + super.toString();
78537684 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7685
+
7686
+ if (!Globals.ADVANCED)
7687
+ return objname;
7688
+
7689
+ return objname + " " + System.identityHashCode(this);
78547690 }
78557691
78567692 public int hashCode()
....@@ -7906,6 +7742,7 @@
79067742 objectUI.closeUI();
79077743 if (editWindow != null)
79087744 {
7745
+ editWindow.ctrlPanel.FlushUI();
79097746 editWindow.refreshContents();
79107747 } // ? new
79117748 objectUI = null;
....@@ -7926,7 +7763,7 @@
79267763 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79277764
79287765 Object3D /*Composite*/ parent;
7929
- Object3D /*Composite*/ fileparent;
7766
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79307767
79317768 double[][] toParent; // dynamic matrix
79327769 double[][] fromParent;
....@@ -8041,7 +7878,7 @@
80417878 {
80427879 assert(bRep != null);
80437880 if (!(support instanceof GenericJoint)) // support.bRep != null)
8044
- GrafreeD.Assert(support.bRep == bRep.support);
7881
+ Grafreed.Assert(support.bRep == bRep.support);
80457882 }
80467883 else
80477884 {
....@@ -8090,9 +7927,9 @@
80907927 private static cVector edge2 = new cVector();
80917928 //private static cVector norm = new cVector();
80927929 /*transient private*/ int hitSomething;
8093
- private static final int hitCenter = 1;
8094
- private static final int hitScale = 2;
8095
- private static final int hitRotate = 3;
7930
+ static final int hitCenter = 1;
7931
+ static final int hitScale = 2;
7932
+ static final int hitRotate = 3;
80967933 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
80977934 /*transient*/ private Point centerPt;
80987935 /*transient*/ private int startX;
....@@ -8124,6 +7961,8 @@
81247961 {
81257962 Object3D targ = this;
81267963
7964
+ targ.NORMALPUSH = obj.NORMALPUSH;
7965
+
81277966 if (obj.material != null)
81287967 {
81297968 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))