Normand Briere
2019-07-25 f2b6a33fdf84a06b958f9cb9d667a2eff3063d8b
Object3D.java
....@@ -5,6 +5,7 @@
55 import java.util.Vector;
66
77 import javax.media.j3d.Transform3D;
8
+import javax.media.opengl.GL;
89 import javax.vecmath.Vector3d;
910
1011 import javax.imageio.ImageIO;
....@@ -13,13 +14,38 @@
1314 import //weka.core.
1415 matrix.Matrix;
1516
17
+import java.util.UUID;
18
+
1619 //import net.sourceforge.sizeof.SizeOf;
1720 public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D>
1821 {
1922 //static final long serialVersionUID = -607422624994562685L;
2023 static final long serialVersionUID = 5022536242724664900L;
2124
25
+ private UUID uuid = UUID.randomUUID();
26
+
27
+ // TEMPORARY for mocap undo. No need to be transient.
28
+ mocap.reader.BVHReader.BVHResult savebvh;
29
+ Object3D saveskeleton;
30
+ //
31
+
32
+ byte[] versions[];
33
+ int versionindex = -1;
34
+
2235 ScriptNode scriptnode;
36
+
37
+ void InitOthers()
38
+ {
39
+ if (projectedVertices == null || projectedVertices.length <= 2)
40
+ {
41
+ projectedVertices = new Object3D.cVector2[3];
42
+ }
43
+ for (int i = 0; i < 3; i++)
44
+ {
45
+ projectedVertices[i] = new cVector2(); // Others
46
+ }
47
+ projectedVertices[0].x = 100; // bump
48
+ }
2349
2450 void MinMax(cVector minima, cVector maxima)
2551 {
....@@ -86,64 +112,178 @@
86112
87113 // transient boolean reduced; // for morph reduction
88114
89
-transient com.bulletphysics.linearmath.Transform cache; // for fast merge
90
-transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
115
+ transient com.bulletphysics.linearmath.Transform cache; // for fast merge
116
+ transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge
91117
92
-transient Object3D transientsupport; // for cloning
93
-transient boolean transientlink2master;
118
+ transient Object3D transientsupport; // for cloning
119
+ transient boolean transientlink2master;
94120
95
-void SaveSupports()
96
-{
97
- if (blockloop)
98
- return;
99
-
100
- transientsupport = support;
101
- transientlink2master = link2master;
102
-
103
- support = null;
104
- link2master = false;
105
-
106
- if (bRep != null)
121
+ void SaveSupports()
107122 {
108
- bRep.SaveSupports();
123
+ if (blockloop)
124
+ return;
125
+
126
+ transientsupport = support;
127
+ transientlink2master = link2master;
128
+
129
+ support = null;
130
+ link2master = false;
131
+
132
+ if (bRep != null)
133
+ {
134
+ bRep.SaveSupports();
135
+ }
136
+
137
+ for (int i = 0; i < Size(); i++)
138
+ {
139
+ Object3D child = (Object3D) get(i);
140
+ if (child == null)
141
+ continue;
142
+ blockloop = true;
143
+ child.SaveSupports();
144
+ blockloop = false;
145
+ }
109146 }
110
-
111
- for (int i = 0; i < Size(); i++)
147
+
148
+ void RestoreSupports()
112149 {
113
- Object3D child = (Object3D) get(i);
114
- if (child == null)
115
- continue;
150
+ if (blockloop)
151
+ return;
152
+
153
+ support = transientsupport;
154
+ link2master = transientlink2master;
155
+ transientsupport = null;
156
+ transientlink2master = false;
157
+
158
+ if (bRep != null)
159
+ {
160
+ bRep.RestoreSupports();
161
+ }
162
+
163
+ for (int i = 0; i < Size(); i++)
164
+ {
165
+ Object3D child = (Object3D) get(i);
166
+ if (child == null)
167
+ continue;
168
+ blockloop = true;
169
+ child.RestoreSupports();
170
+ blockloop = false;
171
+ }
172
+ }
173
+
174
+ void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
175
+ {
176
+ Object3D o;
177
+
178
+ if (hashtable.containsKey(GetUUID()))
179
+ {
180
+ o = hashtable.get(GetUUID());
181
+
182
+ Grafreed.Assert(this.bRep == o.bRep);
183
+ //if (this.bRep != null)
184
+ // assert(this.bRep.support == o.transientrep);
185
+ if (this.support != null)
186
+ assert(this.support.bRep == o.transientrep);
187
+ }
188
+ else
189
+ {
190
+ o = new Object3D("copy of " + this.name);
191
+
192
+ hashtable.put(GetUUID(), o);
193
+ }
194
+
195
+ if (!blockloop)
196
+ {
197
+ blockloop = true;
198
+
199
+ for (int i=0; i<Size(); i++)
200
+ {
201
+ get(i).ExtractBigData(hashtable);
202
+ }
203
+
204
+ blockloop = false;
205
+ }
206
+
207
+ ExtractBigData(o);
208
+ }
209
+
210
+ void ExtractBigData(Object3D o)
211
+ {
212
+ if (o.bRep != null)
213
+ Grafreed.Assert(o.bRep == this.bRep);
214
+
215
+ o.bRep = this.bRep;
216
+// July 2019 if (this.bRep != null)
217
+// {
218
+// o.transientrep = this.bRep.support;
219
+// o.bRep.support = null;
220
+// }
221
+ o.selection = this.selection;
222
+ o.versions = this.versions;
223
+ o.versionindex = this.versionindex;
224
+
225
+ if (this.support != null)
226
+ {
227
+ if (o.transientrep != null)
228
+ Grafreed.Assert(o.transientrep == this.support.bRep);
229
+
230
+ o.transientrep = this.support.bRep;
231
+ this.support.bRep = null;
232
+ }
233
+
234
+ // o.support = this.support;
235
+ // o.fileparent = this.fileparent;
236
+ // if (this.bRep != null)
237
+ // o.bRep = this.bRep.support;
238
+
239
+ this.bRep = null;
240
+ // if (this.bRep != null)
241
+ // this.bRep.support = null;
242
+ // this.support = null;
243
+ // this.fileparent = null;
244
+ }
245
+
246
+ void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable)
247
+ {
248
+ if (!hashtable.containsKey(GetUUID()))
249
+ return;
250
+
251
+ Object3D o = hashtable.get(GetUUID());
252
+
253
+ RestoreBigData(o);
254
+
255
+ if (blockloop)
256
+ return;
257
+
116258 blockloop = true;
117
- child.SaveSupports();
259
+
260
+ //hashtable.remove(GetUUID());
261
+
262
+ for (int i=0; i<Size(); i++)
263
+ {
264
+ get(i).RestoreBigData(hashtable);
265
+ }
266
+
118267 blockloop = false;
119268 }
120
-}
121269
122
-void RestoreSupports()
123
-{
124
- if (blockloop)
125
- return;
126
-
127
- support = transientsupport;
128
- link2master = transientlink2master;
129
- transientsupport = null;
130
- transientlink2master = false;
131
-
132
- if (bRep != null)
270
+ void RestoreBigData(Object3D o)
133271 {
134
- bRep.RestoreSupports();
272
+ this.bRep = o.bRep;
273
+ if (this.support != null && o.transientrep != null)
274
+ {
275
+ this.support.bRep = o.transientrep;
276
+ }
277
+
278
+ this.selection = o.selection;
279
+
280
+ this.versions = o.versions;
281
+ this.versionindex = o.versionindex;
282
+// July 2019 if (this.bRep != null)
283
+// this.bRep.support = o.transientrep;
284
+ // this.support = o.support;
285
+ // this.fileparent = o.fileparent;
135286 }
136
-
137
- for (int i = 0; i < Size(); i++)
138
- {
139
- Object3D child = (Object3D) get(i);
140
- if (child == null)
141
- continue;
142
- blockloop = true;
143
- child.RestoreSupports();
144
- blockloop = false;
145
- }
146
-}
147287
148288 // MOCAP SUPPORT
149289 double tx,ty,tz,rx,ry,rz;
....@@ -285,8 +425,9 @@
285425 return parent.GetName() + "#";
286426 }
287427
288
- boolean timeline = false;
289428 boolean live = false;
429
+ transient boolean keepdontselect;
430
+ boolean dontselect = false;
290431 boolean hide = false;
291432 boolean link2master = false; // performs reset support/master at each frame
292433 boolean marked = false; // animation node
....@@ -296,6 +437,8 @@
296437 boolean random = false;
297438 boolean speedup = false;
298439 boolean rewind = false;
440
+
441
+ float NORMALPUSH = 0;
299442
300443 Object3D support;
301444
....@@ -416,16 +559,16 @@
416559 {
417560 Object3D copy = this;
418561
419
- Camera parentcam = CameraPane.theRenderer.manipCamera;
562
+ Camera parentcam = Globals.theRenderer.ManipCamera();
420563
421
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0])
564
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0])
422565 {
423
- parentcam = CameraPane.theRenderer.cameras[1];
566
+ parentcam = Globals.theRenderer.Cameras()[1];
424567 }
425568
426
- if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1])
569
+ if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1])
427570 {
428
- parentcam = CameraPane.theRenderer.cameras[0];
571
+ parentcam = Globals.theRenderer.Cameras()[0];
429572 }
430573
431574 if (this == parentcam)
....@@ -433,7 +576,7 @@
433576 //assert(this instanceof Camera);
434577
435578 for (int count = parentcam.GetTransformCount(); --count>=0;)
436
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt);
579
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt());
437580 }
438581
439582 copy.marked ^= true;
....@@ -453,7 +596,7 @@
453596 //assert(this instanceof Camera);
454597
455598 for (int count = parentcam.GetTransformCount(); --count>=0;)
456
- LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt);
599
+ LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt());
457600 }
458601
459602 copy.Touch(); // display list issue
....@@ -466,12 +609,14 @@
466609 toParent = LA.newMatrix();
467610 fromParent = LA.newMatrix();
468611 }
612
+
469613 if (toParentMarked == null)
470614 {
471615 if (maxcount != 1)
472616 {
473617 new Exception().printStackTrace();
474618 }
619
+
475620 toParentMarked = LA.newMatrix();
476621 fromParentMarked = LA.newMatrix();
477622 }
....@@ -588,7 +733,7 @@
588733 return;
589734 }
590735
591
- if (CameraPane.fromscript)
736
+ if (Globals.fromscript)
592737 {
593738 transformcount = 0;
594739 return;
....@@ -746,7 +891,7 @@
746891
747892 int GetTransformCount()
748893 {
749
- // marde pour serialization de Texture
894
+ // patch pour serialization de Texture
750895 resetmaxcount();
751896 resettransformcount();
752897 resetstep();
....@@ -759,7 +904,7 @@
759904 if (step == 0)
760905 step = 1;
761906 if (maxcount == 0)
762
- maxcount = 2048; // 4;
907
+ maxcount = 128; // 2048; // 4;
763908 // if (acceleration == 0)
764909 // acceleration = 10;
765910 if (delay == 0) // serial
....@@ -780,9 +925,12 @@
780925 // factor = CameraPane.STEP;
781926 // }
782927
783
- if (marked && CameraPane.isLIVE() && live && CameraPane.drawMode == CameraPane.SHADOW && currentframe != CameraPane.framecount)
928
+ if (marked && Globals.isLIVE() && live &&
929
+ //TEMP21aug2018
930
+ (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) &&
931
+ currentframe != Globals.framecount)
784932 {
785
- currentframe = CameraPane.framecount;
933
+ currentframe = Globals.framecount;
786934
787935 // System.err.println("transformcount = " + transformcount);
788936 // System.err.println("factor = " + factor);
....@@ -791,7 +939,8 @@
791939
792940 boolean changedir = random && Math.random() < 0.01; // && !link2master;
793941
794
- if (transformcount*factor > maxcount || (step == 1 && changedir))
942
+ if (transformcount*factor >= maxcount && (rewind || random) ||
943
+ (step == 1 && changedir))
795944 {
796945 countdown = 1;
797946 delay = speedup?8:1;
....@@ -863,6 +1012,7 @@
8631012 if (material == null || material.multiply)
8641013 return true;
8651014
1015
+ // Transparent objects are dynamic because we have to sort the triangles.
8661016 return material.opacity > 0.99;
8671017 }
8681018
....@@ -894,6 +1044,11 @@
8941044 fromParent = null; // LA.newMatrix();
8951045 bRep = null; // new BoundaryRep();
8961046
1047
+ if (oname != null && oname.equals("LeftHand"))
1048
+ {
1049
+ name = oname;
1050
+ }
1051
+
8971052 /*
8981053 float hue = (float)Math.random();
8991054 Color col;
....@@ -936,7 +1091,7 @@
9361091
9371092 public Object clone()
9381093 {
939
- return GrafreeD.clone(this);
1094
+ return Grafreed.clone(this);
9401095 }
9411096
9421097 Object3D copyExpand()
....@@ -1258,6 +1413,7 @@
12581413 toParent = LA.newMatrix();
12591414 fromParent = LA.newMatrix();
12601415 }
1416
+
12611417 LA.matCopy(other.toParent, toParent);
12621418 LA.matCopy(other.fromParent, fromParent);
12631419
....@@ -1452,7 +1608,7 @@
14521608 BoundaryRep.SEUIL = other.material.cameralight;
14531609
14541610 // Set default to 0.1
1455
- BoundaryRep.SEUIL /= 2;
1611
+ BoundaryRep.SEUIL /= 4; // 2;
14561612 System.out.println("SEUIL = " + BoundaryRep.SEUIL);
14571613 }
14581614
....@@ -1711,7 +1867,7 @@
17111867 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17121868 o.bRep = transientrep;
17131869 if (clone)
1714
- o.bRep = (BoundaryRep) GrafreeD.clone(transientrep);
1870
+ o.bRep = (BoundaryRep) Grafreed.clone(transientrep);
17151871 o.CreateMaterial();
17161872 o.SetAttributes(this, -1);
17171873 //parent
....@@ -1724,7 +1880,7 @@
17241880 Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name);
17251881 o.bRep = bRep;
17261882 if (clone)
1727
- o.bRep = (BoundaryRep) GrafreeD.clone(bRep);
1883
+ o.bRep = (BoundaryRep) Grafreed.clone(bRep);
17281884 o.CreateMaterial();
17291885 //o.overwriteThis(this, -1);
17301886 o.SetAttributes(this, -1);
....@@ -1811,12 +1967,15 @@
18111967 if (obj.name == null)
18121968 continue; // can't be a null one
18131969
1970
+ // Try perfect match first.
18141971 if (n.equals(obj.name))
18151972 {
18161973 theobj = obj;
18171974 count++;
18181975 }
18191976 }
1977
+
1978
+ // not needed: n = n.split(":")[0]; // Poser generates a count
18201979
18211980 if (count != 1)
18221981 for (int i=Size(); --i>=0;)
....@@ -2131,15 +2290,8 @@
21312290 if (/*parent != null &&*/ material == null)
21322291 {
21332292 material = new cMaterial(GetMaterial());
2134
- if (projectedVertices == null || projectedVertices.length <= 2)
2135
- {
2136
- projectedVertices = new Object3D.cVector2[3];
2137
- }
2138
- for (int i = 0; i < 3; i++)
2139
- {
2140
- projectedVertices[i] = new cVector2(); // Others
2141
- }
2142
- projectedVertices[0].x = 100; // bump
2293
+
2294
+ InitOthers();
21432295
21442296 if (this instanceof Camera)
21452297 {
....@@ -2283,12 +2435,17 @@
22832435 }
22842436 */
22852437 }
2438
+ else
2439
+ {
2440
+ //((ObjEditor)editWindow).SetupUI2(null);
2441
+ }
22862442 }
22872443
22882444 void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root)
22892445 {
22902446 if (newWindow)
22912447 {
2448
+ new Exception().printStackTrace();
22922449 System.exit(0);
22932450 if (parent != null)
22942451 {
....@@ -2323,6 +2480,14 @@
23232480 {
23242481 editWindow.refreshContents();
23252482 }
2483
+ else
2484
+ {
2485
+ if (manipWindow != null)
2486
+ {
2487
+ manipWindow.refreshContents();
2488
+ }
2489
+ }
2490
+
23262491 //if (parent != null)
23272492 //parent.refreshEditWindow();
23282493 }
....@@ -2402,7 +2567,8 @@
24022567 private static final int editSelf = 1;
24032568 private static final int editChild = 2;
24042569
2405
- void drawEditHandles(ClickInfo info, int level)
2570
+ void drawEditHandles(//ClickInfo info,
2571
+ int level)
24062572 {
24072573 if (level == 0)
24082574 {
....@@ -2410,7 +2576,8 @@
24102576 return;
24112577
24122578 Object3D selectee;
2413
- for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1))
2579
+ for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info,
2580
+ level + 1))
24142581 {
24152582 selectee = (Object3D) e.nextElement();
24162583 }
....@@ -2418,19 +2585,22 @@
24182585 } else
24192586 {
24202587 //super.
2421
- drawEditHandles0(info, level + 1);
2588
+ drawEditHandles0(//info,
2589
+ level + 1);
24222590 }
24232591 }
24242592
2425
- boolean doEditClick(ClickInfo info, int level)
2593
+ boolean doEditClick(//ClickInfo info,
2594
+ int level)
24262595 {
24272596 doSomething = 0;
24282597 if (level == 0)
24292598 {
2430
- return doParentClick(info);
2599
+ return doParentClick(); //info);
24312600 }
24322601 if (//super.
2433
- doEditClick0(info, level))
2602
+ doEditClick0(//info,
2603
+ level))
24342604 {
24352605 doSomething = 1;
24362606 return true;
....@@ -2440,7 +2610,7 @@
24402610 }
24412611 }
24422612
2443
- boolean doParentClick(ClickInfo info)
2613
+ boolean doParentClick() //ClickInfo info)
24442614 {
24452615 if (selection == null)
24462616 {
....@@ -2453,7 +2623,8 @@
24532623 for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();)
24542624 {
24552625 Object3D selectee = (Object3D) e.nextElement();
2456
- if (selectee.doEditClick(info, 1))
2626
+ if (selectee.doEditClick(//info,
2627
+ 1))
24572628 {
24582629 childToDrag = selectee;
24592630 doSomething = 2;
....@@ -2465,13 +2636,15 @@
24652636 return retval;
24662637 }
24672638
2468
- void doEditDrag(ClickInfo info)
2639
+ void doEditDrag(//ClickInfo clickInfo,
2640
+ boolean opposite)
24692641 {
24702642 switch (doSomething)
24712643 {
24722644 case 1: // '\001'
24732645 //super.
2474
- doEditDrag0(info);
2646
+ doEditDrag0(//clickInfo,
2647
+ opposite);
24752648 break;
24762649
24772650 case 2: // '\002'
....@@ -2484,11 +2657,13 @@
24842657 {
24852658 //sel.hitSomething = childToDrag.hitSomething;
24862659 //childToDrag.doEditDrag(info);
2487
- sel.doEditDrag(info);
2660
+ sel.doEditDrag(//clickInfo,
2661
+ opposite);
24882662 } else
24892663 {
24902664 //super.
2491
- doEditDrag0(info);
2665
+ doEditDrag0(//clickInfo,
2666
+ opposite);
24922667 }
24932668 }
24942669 break;
....@@ -2506,6 +2681,9 @@
25062681 {
25072682 deselectAll();
25082683 }
2684
+
2685
+ new Exception().printStackTrace();
2686
+
25092687 ClickInfo newInfo = new ClickInfo();
25102688 newInfo.flags = info.flags;
25112689 newInfo.bounds = info.bounds;
....@@ -2598,6 +2776,18 @@
25982776 void GenNormalsS(boolean crease)
25992777 {
26002778 selection.GenNormals(crease);
2779
+// for (int i=0; i<selection.size(); i++)
2780
+// {
2781
+// Object3D selectee = (Object3D) selection.elementAt(i);
2782
+// selectee.GenNormals(crease);
2783
+// }
2784
+
2785
+ //Touch();
2786
+ }
2787
+
2788
+ void GenNormalsMeshS()
2789
+ {
2790
+ selection.GenNormalsMesh();
26012791 // for (int i=0; i<selection.size(); i++)
26022792 // {
26032793 // Object3D selectee = (Object3D) selection.elementAt(i);
....@@ -2738,6 +2928,24 @@
27382928 if (child == null)
27392929 continue;
27402930 child.GenNormals(crease);
2931
+// Children().release(i);
2932
+ }
2933
+ blockloop = false;
2934
+ }
2935
+
2936
+ void GenNormalsMesh()
2937
+ {
2938
+ if (blockloop)
2939
+ return;
2940
+
2941
+ blockloop = true;
2942
+ GenNormalsMesh0();
2943
+ for (int i = 0; i < Children().Size(); i++)
2944
+ {
2945
+ Object3D child = (Object3D) Children().get(i); // reserve(i);
2946
+ if (child == null)
2947
+ continue;
2948
+ child.GenNormalsMesh();
27412949 // Children().release(i);
27422950 }
27432951 blockloop = false;
....@@ -2895,7 +3103,8 @@
28953103 {
28963104 if (bRep != null)
28973105 {
2898
- bRep.GenUV();
3106
+ bRep.GenUV(); //1);
3107
+ //bRep.UnfoldUV();
28993108 Touch();
29003109 }
29013110 }
....@@ -2909,11 +3118,20 @@
29093118 }
29103119 }
29113120
3121
+ void GenNormalsMesh0()
3122
+ {
3123
+ if (bRep != null)
3124
+ {
3125
+ bRep.GenerateNormalsMesh();
3126
+ Touch();
3127
+ }
3128
+ }
3129
+
29123130 void GenNormalsMINE0()
29133131 {
29143132 if (bRep != null)
29153133 {
2916
- bRep.GenerateNormalsMINE();
3134
+ bRep.MergeNormals(); //.GenerateNormalsMINE();
29173135 Touch();
29183136 }
29193137 }
....@@ -2970,6 +3188,33 @@
29703188 blockloop = false;
29713189 }
29723190
3191
+ void TransformChildren()
3192
+ {
3193
+ if (toParent != null)
3194
+ {
3195
+ for (int i=Size(); --i>=0;)
3196
+ {
3197
+ Object3D v = get(i);
3198
+
3199
+ if (v.toParent == null)
3200
+ {
3201
+ v.toParent = LA.newMatrix();
3202
+ v.fromParent = LA.newMatrix();
3203
+ }
3204
+
3205
+// LA.matConcat(v.toParent, toParent, v.toParent);
3206
+// LA.matConcat(fromParent, v.fromParent, v.fromParent);
3207
+ LA.matConcat(toParent, v.toParent, v.toParent);
3208
+ LA.matConcat(v.fromParent, fromParent, v.fromParent);
3209
+ }
3210
+
3211
+ toParent = null; // LA.matIdentity(toParent);
3212
+ fromParent = null; // LA.matIdentity(fromParent);
3213
+
3214
+ Touch();
3215
+ }
3216
+ }
3217
+
29733218 void TransformGeometry()
29743219 {
29753220 Object3D obj = this;
....@@ -3191,9 +3436,11 @@
31913436
31923437 BoundaryRep sup = bRep.support;
31933438 bRep.support = null;
3194
- BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep);
3439
+ BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep);
31953440 // bRep.SplitInTwo(onlyone); // thread...
3196
- temprep.SplitInTwo(reduction34, onlyone);
3441
+
3442
+ while(temprep.SplitInTwo(reduction34, onlyone));
3443
+
31973444 bRep = temprep;
31983445 bRep.support = sup;
31993446 Touch();
....@@ -3330,7 +3577,8 @@
33303577 if (blockloop)
33313578 return;
33323579
3333
- if (marked || (bRep != null && material != null)) // borderline...
3580
+ if (//marked || // does not make sense
3581
+ (bRep != null || material != null)) // borderline...
33343582 live = h;
33353583
33363584 for (int i = 0; i < Size(); i++)
....@@ -3351,7 +3599,8 @@
33513599 return;
33523600
33533601 //if (bRep != null)
3354
- if (marked || (bRep != null && material != null)) // borderline...
3602
+ if (//marked || // does not make sense
3603
+ (bRep != null || material != null)) // borderline...
33553604 link2master = h;
33563605
33573606 for (int i = 0; i < Size(); i++)
....@@ -3371,7 +3620,8 @@
33713620 if (blockloop)
33723621 return;
33733622
3374
- if (marked || (bRep != null && material != null)) // borderline...
3623
+ if (//marked || // does not make sense
3624
+ (bRep != null || material != null)) // borderline...
33753625 hide = h;
33763626
33773627 for (int i = 0; i < Size(); i++)
....@@ -3391,7 +3641,7 @@
33913641 if (blockloop)
33923642 return;
33933643
3394
- if (bRep != null && material != null) // borderline...
3644
+ if (bRep != null || material != null) // borderline...
33953645 marked = h;
33963646
33973647 for (int i = 0; i < Size(); i++)
....@@ -3401,6 +3651,46 @@
34013651 continue;
34023652 blockloop = true;
34033653 child.MarkLeaves(h);
3654
+ blockloop = false;
3655
+ // release(i);
3656
+ }
3657
+ }
3658
+
3659
+ void RewindLeaves(boolean h)
3660
+ {
3661
+ if (blockloop)
3662
+ return;
3663
+
3664
+ if (bRep != null || material != null) // borderline...
3665
+ rewind = h;
3666
+
3667
+ for (int i = 0; i < Size(); i++)
3668
+ {
3669
+ Object3D child = (Object3D) get(i); // reserve(i);
3670
+ if (child == null)
3671
+ continue;
3672
+ blockloop = true;
3673
+ child.RewindLeaves(h);
3674
+ blockloop = false;
3675
+ // release(i);
3676
+ }
3677
+ }
3678
+
3679
+ void RandomLeaves(boolean h)
3680
+ {
3681
+ if (blockloop)
3682
+ return;
3683
+
3684
+ if (bRep != null || material != null) // borderline...
3685
+ random = h;
3686
+
3687
+ for (int i = 0; i < Size(); i++)
3688
+ {
3689
+ Object3D child = (Object3D) get(i); // reserve(i);
3690
+ if (child == null)
3691
+ continue;
3692
+ blockloop = true;
3693
+ child.RandomLeaves(h);
34043694 blockloop = false;
34053695 // release(i);
34063696 }
....@@ -3715,7 +4005,7 @@
37154005 if (child == null)
37164006 continue;
37174007
3718
- if (GrafreeD.RENDERME > 0)
4008
+ if (Grafreed.RENDERME > 0)
37194009 {
37204010 if (child instanceof Merge)
37214011 ((Merge)child).renderme();
....@@ -3866,7 +4156,7 @@
38664156 if (child == null)
38674157 continue;
38684158
3869
- if (GrafreeD.RENDERME > 0)
4159
+ if (Grafreed.RENDERME > 0)
38704160 {
38714161 if (child instanceof Merge)
38724162 ((Merge)child).renderme();
....@@ -4061,7 +4351,7 @@
40614351 if (child == null)
40624352 continue;
40634353
4064
- if (GrafreeD.RENDERME > 0)
4354
+ if (Grafreed.RENDERME > 0)
40654355 {
40664356 if (child instanceof Merge)
40674357 ((Merge)child).renderme();
....@@ -4158,6 +4448,71 @@
41584448 }
41594449 blockloop = true;
41604450 get(i).RepairParent();
4451
+ blockloop = false;
4452
+ }
4453
+ }
4454
+
4455
+ void RepairShadow()
4456
+ {
4457
+ if (blockloop)
4458
+ return;
4459
+
4460
+ if (this.material != null)
4461
+ this.InitOthers();
4462
+
4463
+ for (int i=0; i<Size(); i++)
4464
+ {
4465
+ blockloop = true;
4466
+ get(i).RepairShadow();
4467
+ blockloop = false;
4468
+ }
4469
+ }
4470
+
4471
+ void RepairSOV()
4472
+ {
4473
+ if (blockloop)
4474
+ return;
4475
+
4476
+ String texname = this.GetPigmentTexture();
4477
+
4478
+ if (texname.startsWith("sov"))
4479
+ {
4480
+ String[] s = texname.split("/");
4481
+
4482
+ String[] sname = s[1].split("Color.pn");
4483
+
4484
+ texname = sname[0];
4485
+
4486
+ if (sname.length > 1)
4487
+ {
4488
+ texname += "Color.jpg";
4489
+ }
4490
+
4491
+ this.SetPigmentTexture("sov/" + texname);
4492
+ }
4493
+
4494
+ texname = this.GetBumpTexture();
4495
+
4496
+ if (texname.startsWith("sov"))
4497
+ {
4498
+ String[] s = texname.split("/");
4499
+
4500
+ String[] sname = s[1].split("Bump.pn");
4501
+
4502
+ texname = sname[0];
4503
+
4504
+ if (sname.length > 1)
4505
+ {
4506
+ texname += "Bump.jpg";
4507
+ }
4508
+
4509
+ this.SetBumpTexture("sov/" + texname);
4510
+ }
4511
+
4512
+ for (int i=0; i<Size(); i++)
4513
+ {
4514
+ blockloop = true;
4515
+ get(i).RepairSOV();
41614516 blockloop = false;
41624517 }
41634518 }
....@@ -4652,7 +5007,7 @@
46525007
46535008 cTreePath SelectLeaf(int indexcount, boolean deselect)
46545009 {
4655
- if (hide)
5010
+ if (hide || dontselect)
46565011 return null;
46575012
46585013 if (count <= 0)
....@@ -4676,9 +5031,17 @@
46765031 }
46775032 }
46785033
5034
+ ObjEditor GetWindow()
5035
+ {
5036
+ if (editWindow != null)
5037
+ return editWindow;
5038
+
5039
+ return manipWindow;
5040
+ }
5041
+
46795042 cTreePath Select(int indexcount, boolean deselect)
46805043 {
4681
- if (hide)
5044
+ if (hide || dontselect)
46825045 return null;
46835046
46845047 if (count <= 0)
....@@ -4712,10 +5075,11 @@
47125075 if (leaf != null)
47135076 {
47145077 cTreePath tp = new cTreePath(this, leaf);
4715
- if (editWindow != null)
5078
+ ObjEditor window = GetWindow();
5079
+ if (window != null)
47165080 {
47175081 //System.out.println("editWindow = " + editWindow + " vs " + this);
4718
- editWindow.Select(tp, deselect, true);
5082
+ window.Select(tp, deselect, true);
47195083 }
47205084
47215085 return tp;
....@@ -4732,6 +5096,7 @@
47325096
47335097 if (child == null)
47345098 continue;
5099
+
47355100 if (child.HasTransparency() && child.size() != 0)
47365101 {
47375102 cTreePath leaf = child.Select(indexcount, deselect);
....@@ -4741,9 +5106,10 @@
47415106 if (leaf != null)
47425107 {
47435108 cTreePath tp = new cTreePath(this, leaf);
4744
- if (editWindow != null)
5109
+ ObjEditor window = GetWindow();
5110
+ if (window != null)
47455111 {
4746
- editWindow.Select(tp, deselect, true);
5112
+ window.Select(tp, deselect, true);
47475113 }
47485114
47495115 return tp;
....@@ -4828,7 +5194,7 @@
48285194 return globalTransform;
48295195 }
48305196
4831
- void PreprocessOcclusion(CameraPane cp)
5197
+ void PreprocessOcclusion(iCameraPane cp)
48325198 {
48335199 /*
48345200 if (AOdone)
....@@ -4975,7 +5341,8 @@
49755341 } else //
49765342 if (editWindow != null)
49775343 {
4978
- editWindow.cameraView.lighttouched = true;
5344
+ //editWindow.cameraView.lighttouched = true;
5345
+ Globals.lighttouched = true;
49795346 }
49805347 }
49815348
....@@ -5067,6 +5434,51 @@
50675434 blockloop = false;
50685435 }
50695436
5437
+ void ResetSelectable()
5438
+ {
5439
+ if (blockloop)
5440
+ return;
5441
+
5442
+ blockloop = true;
5443
+
5444
+ keepdontselect = dontselect;
5445
+ dontselect = true;
5446
+
5447
+ Object3D child;
5448
+ int nb = Size();
5449
+ for (int i = 0; i < nb; i++)
5450
+ {
5451
+ child = (Object3D) get(i);
5452
+ if (child == null)
5453
+ continue;
5454
+ child.ResetSelectable();
5455
+ }
5456
+
5457
+ blockloop = false;
5458
+ }
5459
+
5460
+ void RestoreSelectable()
5461
+ {
5462
+ if (blockloop)
5463
+ return;
5464
+
5465
+ blockloop = true;
5466
+
5467
+ dontselect = keepdontselect;
5468
+
5469
+ Object3D child;
5470
+ int nb = Size();
5471
+ for (int i = 0; i < nb; i++)
5472
+ {
5473
+ child = (Object3D) get(i);
5474
+ if (child == null)
5475
+ continue;
5476
+ child.RestoreSelectable();
5477
+ }
5478
+
5479
+ blockloop = false;
5480
+ }
5481
+
50705482 boolean IsSelected()
50715483 {
50725484 if (parent == null)
....@@ -5129,10 +5541,34 @@
51295541
51305542 // System.out.println("Fullname = " + fullname);
51315543
5132
- if (fullname.name.indexOf(":") == -1)
5133
- return fullname.name;
5544
+ // Does not work on Windows due to C:
5545
+// if (fullname.name.indexOf(":") == -1)
5546
+// return fullname.name;
5547
+//
5548
+// return fullname.name.substring(0,fullname.name.indexOf(":"));
51345549
5135
- return fullname.name.substring(0,fullname.name.indexOf(":"));
5550
+ String[] split = fullname.name.split(":");
5551
+
5552
+ if (split.length == 0)
5553
+ {
5554
+ return "";
5555
+ }
5556
+
5557
+ if (split.length <= 2)
5558
+ {
5559
+ if (fullname.name.endsWith(":"))
5560
+ {
5561
+ // Windows
5562
+ return fullname.name.substring(0, fullname.name.length()-1);
5563
+ }
5564
+
5565
+ return split[0];
5566
+ }
5567
+
5568
+ // Windows
5569
+ assert(split.length == 4);
5570
+
5571
+ return split[0] + ":" + split[1];
51365572 }
51375573
51385574 static String GetBump(cTexture fullname)
....@@ -5141,10 +5577,38 @@
51415577 return "";
51425578
51435579 // System.out.println("Fullname = " + fullname);
5144
- if (fullname.name.indexOf(":") == -1)
5145
- return "";
5146
-
5147
- return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5580
+ // Does not work on Windows due to C:
5581
+// if (fullname.name.indexOf(":") == -1)
5582
+// return "";
5583
+//
5584
+// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length());
5585
+ String[] split = fullname.name.split(":");
5586
+
5587
+ if (split.length == 0)
5588
+ {
5589
+ return "";
5590
+ }
5591
+
5592
+ if (split.length == 1)
5593
+ {
5594
+ return "";
5595
+ }
5596
+
5597
+ if (split.length == 2)
5598
+ {
5599
+ if (fullname.name.endsWith(":"))
5600
+ {
5601
+ // Windows
5602
+ return "";
5603
+ }
5604
+
5605
+ return split[1];
5606
+ }
5607
+
5608
+ // Windows
5609
+ assert(split.length == 4);
5610
+
5611
+ return split[2] + ":" + split[3];
51485612 }
51495613
51505614 String GetPigmentTexture()
....@@ -5218,7 +5682,7 @@
52185682 System.out.print("; textures = " + textures);
52195683 System.out.println("; usedtextures = " + usedtextures);
52205684
5221
- if (GetTextures() == null)
5685
+ if (GetTextures() == null) // What is that??
52225686 GetTextures().name = ":";
52235687
52245688 String texname = tex;
....@@ -5249,6 +5713,43 @@
52495713 child.ResetPigmentTexture();
52505714 blockloop = false;
52515715 }
5716
+ }
5717
+
5718
+ UUID GetUUID()
5719
+ {
5720
+ if (uuid == null)
5721
+ {
5722
+ // Serial
5723
+ uuid = UUID.randomUUID();
5724
+ }
5725
+
5726
+ return uuid;
5727
+ }
5728
+
5729
+ Object3D GetObject(UUID uid)
5730
+ {
5731
+ if (blockloop)
5732
+ return null;
5733
+
5734
+ if (GetUUID().equals(uid))
5735
+ return this;
5736
+
5737
+ int nb = Size();
5738
+ for (int i = 0; i < nb; i++)
5739
+ {
5740
+ Object3D child = (Object3D) get(i);
5741
+
5742
+ if (child == null)
5743
+ continue;
5744
+
5745
+ blockloop = true;
5746
+ Object3D obj = child.GetObject(uid);
5747
+ blockloop = false;
5748
+ if (obj != null)
5749
+ return obj;
5750
+ }
5751
+
5752
+ return null;
52525753 }
52535754
52545755 void SetBumpTexture(String tex)
....@@ -5287,25 +5788,65 @@
52875788 }
52885789 }
52895790
5290
- void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5791
+ void EmbedTextures(boolean embed)
5792
+ {
5793
+ if (blockloop)
5794
+ return;
5795
+
5796
+ //if (GetTextures() != null)
5797
+ if (embed)
5798
+ CameraPane.EmbedTextures(GetTextures());
5799
+ else
5800
+ {
5801
+ GetTextures().pigmentdata = null;
5802
+ GetTextures().bumpdata = null;
5803
+ GetTextures().pw = 0;
5804
+ GetTextures().ph = 0;
5805
+ GetTextures().bw = 0;
5806
+ GetTextures().bh = 0;
5807
+ }
5808
+
5809
+ int nb = Size();
5810
+ for (int i = 0; i < nb; i++)
5811
+ {
5812
+ Object3D child = (Object3D) get(i);
5813
+
5814
+ if (child == null)
5815
+ continue;
5816
+
5817
+ blockloop = true;
5818
+ child.EmbedTextures(embed);
5819
+ blockloop = false;
5820
+ }
5821
+ }
5822
+
5823
+ void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
52915824 {
52925825 Draw(display, root, selected, blocked);
52935826 }
52945827
5295
- static cMaterial[] materialstack = new cMaterial[65536];
5296
- static boolean[] selectedstack = new boolean[65536];
5297
- static int materialdepth = 0;
5298
-
52995828 boolean NeedSupport()
53005829 {
53015830 return
5302
- CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null
5831
+ CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null
53035832 // PROBLEM with CROWD!!
5304
- && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD);
5833
+ && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD);
53055834 }
53065835
5836
+ static boolean DEBUG_SELECTION = false;
53075837
5308
- void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
5838
+ boolean IsLive()
5839
+ {
5840
+ if (live)
5841
+ return true;
5842
+
5843
+ if (parent == null)
5844
+ return false;
5845
+
5846
+ return parent.IsLive();
5847
+ }
5848
+
5849
+ void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
53095850 {
53105851 Invariants(); // june 2013
53115852
....@@ -5314,8 +5855,8 @@
53145855 // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame);
53155856 }
53165857
5317
- if (display.drawMode == CameraPane.SELECTION &&
5318
- hide)
5858
+ if (display.DrawMode() == iCameraPane.SELECTION &&
5859
+ (hide || dontselect))
53195860 return;
53205861
53215862 if (name != null && name.contains("sclera"))
....@@ -5333,7 +5874,7 @@
53335874 if (this instanceof Checker)
53345875 return;
53355876
5336
- if (display.drawMode == display.SHADOW && PASSTEST)
5877
+ if (display.DrawMode() == display.SHADOW && PASSTEST)
53375878 return;
53385879
53395880 if (count <= 0)
....@@ -5341,13 +5882,13 @@
53415882 return;
53425883 }
53435884
5344
- if ((//display.drawMode == CameraPane.SHADOW ||
5345
- display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency())
5885
+ if ((//display.DrawMode() == CameraPane.SHADOW ||
5886
+ display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency())
53465887 {
53475888 return;
53485889 }
53495890
5350
- javax.media.opengl.GL gl = display.GetGL();
5891
+ //javax.media.opengl.GL gl = display.GetGL();
53515892
53525893 /*
53535894 if (touched)
....@@ -5366,7 +5907,7 @@
53665907 support = support;
53675908
53685909 //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5369
- boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
5910
+ boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch);
53705911
53715912 if (!usecalllists && bRep != null && bRep.displaylist > 0)
53725913 {
....@@ -5383,15 +5924,17 @@
53835924
53845925 boolean compiled = false;
53855926
5386
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
5927
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
53875928
5388
- if (!selectmode && //display.drawMode != display.SELECTION &&
5389
- (touched || (bRep != null && bRep.displaylist <= 0)))
5929
+ if (!selectmode && //display.DrawMode() != display.SELECTION &&
5930
+ //(touched || (bRep != null && bRep.displaylist <= 0)))
5931
+ (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0)))
53905932 {
5391
- display.lighttouched = true;
5933
+ Globals.lighttouched = true;
53925934 } // all panes...
5393
- //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW &&
5394
- if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW &&
5935
+
5936
+ //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW &&
5937
+ if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW &&
53955938 (touched || (bRep != null && bRep.displaylist <= 0)))
53965939 {
53975940 if (!(this instanceof Composite))
....@@ -5399,7 +5942,7 @@
53995942 //if (displaylist == -1 && usecalllists)
54005943 if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013
54015944 {
5402
- bRep.displaylist = gl.glGenLists(1);
5945
+ bRep.displaylist = display.GenList();
54035946 assert(bRep.displaylist != 0);
54045947 // System.err.println("glGenLists: " + bRep.displaylist + " for " + this);
54055948 //System.out.println("\tgen list " + list);
....@@ -5411,18 +5954,20 @@
54115954 if (usecalllists)
54125955 {
54135956 // System.err.println("new list " + bRep.displaylist + " for " + this);
5414
- gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE);
5957
+ display.NewList(bRep.displaylist);
54155958 }
5959
+
54165960 CallList(display, root, selected, blocked);
5961
+
54175962 // compiled = true;
54185963 if (usecalllists)
54195964 {
54205965 // System.err.println("end list " + bRep.displaylist + " for " + this);
5421
- gl.glEndList();
5966
+ display.EndList();
54225967 }
54235968 //gl.glDrawBuffer(gl.GL_BACK);
54245969 // XXX touched = false;
5425
- display.lighttouched = true; // all panes...
5970
+ Globals.lighttouched = true; // all panes...
54265971 }
54275972
54285973 touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false;
....@@ -5461,12 +6006,12 @@
54616006
54626007 // frustum culling
54636008 if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid
5464
- && display.drawMode != CameraPane.SELECTION)
6009
+ && display.DrawMode() != iCameraPane.SELECTION)
54656010 {
5466
- if (display.drawMode == CameraPane.SHADOW)
6011
+ if (display.DrawMode() == iCameraPane.SHADOW)
54676012 {
54686013 if (!link2master // tricky to cull in shadow mode.
5469
- && GetBRep().FrustumCull(this, gl, display.lightCamera, true))
6014
+ && GetBRep().FrustumCull(this, null, display.LightCamera(), true))
54706015 {
54716016 //System.out.print("CULLED");
54726017 culled = true;
....@@ -5474,7 +6019,7 @@
54746019 }
54756020 else
54766021 //GetBRep().getBounds(v0, v1, this);
5477
- if (GetBRep().FrustumCull(this, gl, display.renderCamera, false))
6022
+ if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false))
54786023 culled = true;
54796024
54806025 // LA.xformPos(v0, display.renderCamera.toScreen, v0);
....@@ -5510,11 +6055,12 @@
55106055
55116056
55126057 if (!culled)
5513
- if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION)
6058
+ if (display.DrawMode() == display.SELECTION || display.IsDebugSelection())
55146059 {
55156060 if (GetBRep() != null)
55166061 {
5517
- CameraPane.NextIndex(this, gl);
6062
+ display.NextIndex();
6063
+
55186064 // vertex color conflict : gl.glCallList(list);
55196065 DrawNode(display, root, selected);
55206066 if (this instanceof BezierPatch)
....@@ -5536,55 +6082,7 @@
55366082 color[2] /= 2;
55376083 gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0);
55386084 */
5539
- if (material != null)
5540
- {
5541
- materialstack[materialdepth] = material;
5542
- selectedstack[materialdepth] = selected;
5543
- cStatic.objectstack[materialdepth++] = this;
5544
- //System.out.println("material " + material);
5545
- //Applet3D.tracein(this, selected);
5546
- display.vector2buffer = projectedVertices;
5547
- if (this instanceof Camera)
5548
- {
5549
- display.options1[0] = material.shift;
5550
- //System.out.println("shift " + material.shift);
5551
- display.options1[1] = material.lightarea;
5552
- display.options1[2] = material.shadowbias;
5553
- display.options1[3] = material.aniso;
5554
- display.options1[4] = material.anisoV;
5555
- display.options2[0] = material.opacity;
5556
- display.options2[1] = material.diffuse;
5557
- display.options2[2] = material.factor;
5558
-
5559
- cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
5560
- display.options4[0] = material.cameralight/0.2f;
5561
- display.options4[1] = material.subsurface;
5562
- display.options4[2] = material.sheen;
5563
-
5564
- // if (display.CURRENTANTIALIAS > 0)
5565
- // display.options3[3] /= 4;
5566
-
5567
- /*
5568
- System.out.println("Focus = " + display.options1[0]);
5569
- System.out.println("Aperture = " + display.options1[1]);
5570
- System.out.println("ShadowBlur = " + display.options1[2]);
5571
- System.out.println("Antialiasing = " + display.options1[3]);
5572
- System.out.println("Fog = " + display.options2[0]);
5573
- System.out.println("Intensity = " + display.options2[1]);
5574
- System.out.println("Elevation = " + display.options2[2]);
5575
- /**/
5576
- } else
5577
- {
5578
- material.Draw(display, selected);
5579
- }
5580
- } else
5581
- {
5582
- if (selected && CameraPane.flash)
5583
- {
5584
- display.modelParams4[1] = 100;
5585
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5586
- }
5587
- }
6085
+ display.PushMaterial(this, selected);
55886086
55896087 //System.out.println("call list " + list);
55906088 //System.out.println();
....@@ -5603,7 +6101,28 @@
56036101 tex = GetTextures();
56046102 }
56056103
5606
- display.BindTextures(tex, texres);
6104
+ boolean failedPigment = false;
6105
+ boolean failedBump = false;
6106
+
6107
+ try
6108
+ {
6109
+ display.BindPigmentTexture(tex, texres);
6110
+ }
6111
+ catch (Exception e)
6112
+ {
6113
+ System.err.println("FAILED: " + this);
6114
+ failedPigment = true;
6115
+ }
6116
+
6117
+ try
6118
+ {
6119
+ display.BindBumpTexture(tex, texres);
6120
+ }
6121
+ catch (Exception e)
6122
+ {
6123
+ //System.err.println("FAILED: " + this);
6124
+ failedBump = true;
6125
+ }
56076126
56086127 if (!compiled)
56096128 {
....@@ -5619,30 +6138,19 @@
56196138
56206139 // System.err.println("glCallList: " + bRep.displaylist + " for " + this);
56216140 assert(bRep.displaylist != 0);
5622
- gl.glCallList(bRep.displaylist);
6141
+ display.CallList(bRep.displaylist);
56236142 // june 2013 drawSelf(display, root, selected);
56246143 }
56256144 }
56266145 }
56276146
5628
- display.ReleaseTextures(tex);
5629
-
5630
- //if (parent != null && parent.GetMaterial() != null)
5631
- // parent.GetMaterial().Draw(display, parent.IsSelected(this));
5632
- if (material != null)
5633
- {
5634
- materialdepth -= 1;
5635
- if (materialdepth > 0)
5636
- {
5637
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5638
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5639
- }
5640
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5641
- } else if (selected && CameraPane.flash && GetMaterial() != null)
5642
- {
5643
- display.modelParams4[1] = GetMaterial().cameralight;
5644
- gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0);
5645
- }
6147
+ if (!failedBump)
6148
+ display.ReleaseBumpTexture(tex);
6149
+
6150
+ if (!failedPigment)
6151
+ display.ReleasePigmentTexture(tex);
6152
+
6153
+ display.PopMaterial(this, selected);
56466154 }
56476155
56486156 if (this instanceof Texture || this instanceof TextureNode)
....@@ -5684,7 +6192,7 @@
56846192 // resetMasterNode();
56856193 }
56866194
5687
- void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6195
+ void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
56886196 {
56896197 if (GetBRep() == null)
56906198 {
....@@ -5767,8 +6275,11 @@
57676275 boolean flipV = false; // true;
57686276 int texres = 0; // 0 = low, 1 = normal, 2 = high res texture
57696277
5770
- void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
6278
+ void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked)
57716279 {
6280
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6281
+ return;
6282
+
57726283 if (hide)
57736284 return;
57746285 // shadow optimisation
....@@ -5826,16 +6337,7 @@
58266337 // // ??????????????????????????? Touch();
58276338 // }
58286339
5829
- if (material != null)
5830
- {
5831
- materialstack[materialdepth] = material;
5832
- selectedstack[materialdepth] = selected;
5833
- cStatic.objectstack[materialdepth++] = this;
5834
- //System.out.println("material " + material);
5835
- //Applet3D.tracein("selected ", selected);
5836
- display.vector2buffer = projectedVertices;
5837
- material.Draw(display, selected);
5838
- }
6340
+display.PushMaterial2(this, selected);
58396341
58406342 Object3D child;
58416343 boolean sel;
....@@ -5887,19 +6389,7 @@
58876389 */
58886390 //depth += 1;
58896391
5890
- if (material != null)
5891
- {
5892
- materialdepth -= 1;
5893
- if (materialdepth > 0)
5894
- {
5895
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
5896
- materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]);
5897
- }
5898
- //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
5899
- //else
5900
- //material.Draw(display, false);
5901
- }
5902
-
6392
+display.PopMaterial2(this);
59036393 /*
59046394 display.ReleaseTextures(tex);
59056395 */
....@@ -5910,10 +6400,13 @@
59106400
59116401 //static cVector min,max;
59126402
5913
- void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected)
6403
+ void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected)
59146404 {
5915
- if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
6405
+ if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000)
59166406 return; // no shadow for transparent objects
6407
+
6408
+ if (display.DrawMode() == iCameraPane.SELECTION && dontselect)
6409
+ return;
59176410
59186411 if (hide)
59196412 return;
....@@ -5955,11 +6448,12 @@
59556448 return;
59566449 }
59576450
6451
+ //bRep.GenUV(1/material.diffuseness);
59586452 // bRep.lock = true;
59596453
5960
- javax.media.opengl.GL gl = display.GetGL();
6454
+ //javax.media.opengl.GL gl = display.GetGL();
59616455
5962
- if (CameraPane.BOXMODE) // || CameraPane.movingcamera)
6456
+ if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera)
59636457 {
59646458 int fc = bRep.FaceCount();
59656459 int vc = bRep.VertexCount();
....@@ -5974,23 +6468,7 @@
59746468
59756469 bRep.getMinMax(min, max, 100);
59766470
5977
- gl.glBegin(gl.GL_LINES);
5978
-
5979
- gl.glVertex3d(min.x, min.y, min.z);
5980
- gl.glVertex3d(min.x, min.y, max.z);
5981
- gl.glVertex3d(min.x, min.y, min.z);
5982
- gl.glVertex3d(min.x, max.y, min.z);
5983
- gl.glVertex3d(min.x, min.y, min.z);
5984
- gl.glVertex3d(max.x, min.y, min.z);
5985
-
5986
- gl.glVertex3d(max.x, max.y, max.z);
5987
- gl.glVertex3d(min.x, max.y, max.z);
5988
- gl.glVertex3d(max.x, max.y, max.z);
5989
- gl.glVertex3d(max.x, min.y, max.z);
5990
- gl.glVertex3d(max.x, max.y, max.z);
5991
- gl.glVertex3d(max.x, max.y, min.z);
5992
-
5993
- gl.glEnd();
6471
+ display.DrawBox(min, max);
59946472
59956473 return;
59966474 }
....@@ -6034,7 +6512,7 @@
60346512 {
60356513 //throw new Error();
60366514
6037
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6515
+ boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection();
60386516
60396517 int[] strips = bRep.getRawIndices();
60406518
....@@ -6044,178 +6522,19 @@
60446522 new Exception().printStackTrace();
60456523 return;
60466524 }
6047
-
6048
- // TRIANGLE STRIP ARRAY
6049
- if (bRep.trimmed)
6525
+
6526
+ if (dontselect)
60506527 {
6051
- float[] v = bRep.getRawVertices();
6052
- float[] n = bRep.getRawNormals();
6053
- float[] c = bRep.getRawColors();
6054
- float[] uv = bRep.getRawUVMap();
6055
-
6056
- int count2 = 0;
6057
- int count3 = 0;
6058
-
6059
- if (n.length > 0)
6060
- {
6061
- for (int i = 0; i < strips.length; i++)
6062
- {
6063
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6064
-
6065
- /*
6066
- boolean locked = false;
6067
- float eps = 0.1f;
6068
- boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6069
-
6070
- int dot = 0;
6071
-
6072
- if ((dot&1) == 0)
6073
- dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6074
-
6075
- if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6076
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6077
- else
6078
- {
6079
- locked = true;
6080
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6081
- }
6082
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6083
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6084
- if (hasnorm)
6085
- {
6086
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6087
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6088
- }
6089
-
6090
- if ((dot&4) == 0)
6091
- dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6092
-
6093
- if (wrap || !locked && (dot&8) != 0)
6094
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6095
- else
6096
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6097
-
6098
- f.dot = dot;
6099
- */
6100
-
6101
- if (!selectmode)
6102
- {
6103
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6104
- {
6105
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6106
- } else
6107
- {
6108
- gl.glNormal3f(0, 0, 1);
6109
- }
6110
-
6111
- if (c != null)
6112
- //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]);
6113
- {
6114
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6115
- }
6116
- }
6117
- if (flipV)
6118
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6119
- else
6120
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6121
- //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6122
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6123
-
6124
- count2 += 2;
6125
- count3 += 3;
6126
- if (!selectmode)
6127
- {
6128
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6129
- {
6130
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6131
- } else
6132
- {
6133
- gl.glNormal3f(0, 0, 1);
6134
- }
6135
- if (c != null)
6136
- {
6137
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6138
- }
6139
- }
6140
- if (flipV)
6141
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6142
- else
6143
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6144
- //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
6145
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6146
-
6147
- count2 += 2;
6148
- count3 += 3;
6149
- for (int j = 0; j < strips[i] - 2; j++)
6150
- {
6151
- //gl.glTexCoord2d(...);
6152
- if (!selectmode)
6153
- {
6154
- if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
6155
- {
6156
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
6157
- } else
6158
- {
6159
- gl.glNormal3f(0, 0, 1);
6160
- }
6161
- if (c != null)
6162
- {
6163
- gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
6164
- }
6165
- }
6166
-
6167
- if (flipV)
6168
- gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
6169
- else
6170
- gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
6171
- //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
6172
- gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
6173
- count2 += 2;
6174
- count3 += 3;
6175
- }
6176
-
6177
- gl.glEnd();
6178
- }
6179
- }
6180
-
6181
- assert count3 == v.length;
6528
+ //bRep.GenerateNormalsMINE();
61826529 }
6183
- else // !trimmed
6184
- {
6185
- int count = 0;
6186
- for (int i = 0; i < strips.length; i++)
6187
- {
6188
- gl.glBegin(gl.GL_TRIANGLE_STRIP);
6189
-
6190
- Vertex p = bRep.GetVertex(bRep.indices[count++]);
6191
- Vertex q = bRep.GetVertex(bRep.indices[count++]);
6192
-
6193
- drawVertex(gl, p, selectmode);
6194
- drawVertex(gl, q, selectmode);
6195
-
6196
- for (int j = 0; j < strips[i] - 2; j++)
6197
- {
6198
- Vertex r = bRep.GetVertex(bRep.indices[count++]);
6199
-
6200
-// if (j%2 == 0)
6201
-// drawFace(p, q, r, display, null);
6202
-// else
6203
-// drawFace(p, r, q, display, null);
6204
-
6205
-// p = q;
6206
-// q = r;
6207
- drawVertex(gl, r, selectmode);
6208
- }
6209
-
6210
- gl.glEnd();
6211
- }
6212
- }
6530
+
6531
+ display.DrawGeometry(bRep, flipV, selectmode);
62136532 } else // catch (Error e)
62146533 {
62156534 // TRIANGLE ARRAY
62166535 if (IsOpaque()) // Static())
62176536 {
6218
- gl.glBegin(gl.GL_TRIANGLES);
6537
+ display.StartTriangles();
62196538 int facecount = bRep.FaceCount();
62206539 for (int i = 0; i < facecount; i++)
62216540 {
....@@ -6278,9 +6597,9 @@
62786597 // // r.norm.dot(v3) > -0.5)
62796598 // // continue;
62806599
6281
- drawFace(p, q, r, display, face);
6600
+ display.DrawFace(this, p, q, r, face);
62826601 }
6283
- gl.glEnd();
6602
+ display.EndTriangles();
62846603 }
62856604 else
62866605 {
....@@ -6309,8 +6628,8 @@
63096628 //System.out.println("SORT");
63106629
63116630 java.util.Arrays.sort(facescompare);
6312
-
6313
- gl.glBegin(gl.GL_TRIANGLES);
6631
+
6632
+ display.StartTriangles();
63146633 for (int i = 0; i < facecount; i++)
63156634 {
63166635 Face face = bRep.GetFace(facescompare[i].index);
....@@ -6322,13 +6641,14 @@
63226641 Vertex q = bRep.GetVertex(face.q);
63236642 Vertex r = bRep.GetVertex(face.r);
63246643
6325
- drawFace(p, q, r, display, face);
6644
+ display.DrawFace(this, p, q, r, face);
63266645 }
6327
- gl.glEnd();
6646
+ display.EndTriangles();
63286647 }
63296648
63306649 if (false) // live && support != null && support.bRep != null) // debug weights
63316650 {
6651
+ /*
63326652 gl.glDisable(gl.GL_LIGHTING);
63336653 float[] colorV = new float[3];
63346654
....@@ -6407,6 +6727,7 @@
64076727 // gl.glEnd();
64086728 }
64096729 }
6730
+ */
64106731 }
64116732 }
64126733
....@@ -6451,7 +6772,7 @@
64516772 center.add(r);
64526773 center.mul(1.0/3);
64536774
6454
- center.sub(CameraPane.theRenderer.eyeCamera.location);
6775
+ center.sub(Globals.theRenderer.EyeCamera().location);
64556776
64566777 distance = center.dot(center);
64576778 }
....@@ -6462,347 +6783,11 @@
64626783
64636784 transient FaceCompare[] facescompare = null;
64646785
6465
- void SetColor(CameraPane display, Vertex p0)
6466
- {
6467
- if (display.RENDERPROGRAM == 0)
6468
- {
6469
- float r = 0;
6470
- if (bRep != null)
6471
- {
6472
- if (bRep.stripified)
6473
- {
6474
- r = 1;
6475
- }
6476
- }
6477
- float g = 0;
6478
- if (bRep != null)
6479
- {
6480
- if (bRep.trimmed)
6481
- {
6482
- g = 1;
6483
- }
6484
- }
6485
- float b = 0;
6486
- if (support != null && link2master)
6487
- {
6488
- b = 1;
6489
- }
6490
- display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO);
6491
- return;
6492
- }
6493
-
6494
- if (display.drawMode != CameraPane.SHADOW)
6495
- return;
6496
-
6497
- javax.media.opengl.GL gl = display.GetGL();
6498
-// if (true) return;
6499
-// float ao = p.AO;
6500
-//
6501
-// // if (ao == 0 && !bRep.AOdone) // transient problem!
6502
-// // ao = 1;
6503
-//
6504
-// gl.glColor4f(ao, ao, ao, 1);
6505
-
6506
-// CameraPane.selectedpoint.
6507
-// getAverage(cStatic.point1, true);
6508
- if (CameraPane.pointflow == null) // !random) // live)
6509
- {
6510
- return;
6511
- }
6512
-
6513
- cStatic.point1.set(0,0,0);
6514
- LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1);
6515
-
6516
- cStatic.point1.sub(p0);
6517
-
6518
-
6519
-// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta?
6520
-// {
6521
-// return;
6522
-// }
6523
-
6524
- //if (true)
6525
- if (cStatic.point1.dot(cStatic.point1) > 0.000001)
6526
- {
6527
- return;
6528
- }
6529
-
6530
- float[] colorV = new float[3];
6531
-
6532
- if (false) // marked)
6533
- {
6534
- // debug rigging weights
6535
- for (int object = 0; object < p0.vertexlinks.length; object++)
6536
- {
6537
- float weight = p0.weights[object] / p0.totalweight;
6538
-
6539
- // if (weight < 0.1)
6540
- // {
6541
- // assert(weight == 0);
6542
- // continue;
6543
- // }
6544
-
6545
- if (p0.vertexlinks[object] == -1)
6546
- continue;
6547
-
6548
- Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]);
6549
-
6550
- int color = //1 << object; //
6551
- //p.vertexlinks.length;
6552
- support.bRep.supports[p0.closestsupport].links[object];
6553
- colorV[2] += (color & 1) * weight;
6554
- colorV[1] += ((color & 2) >> 1) * weight;
6555
- colorV[0] += ((color & 4) >> 2) * weight;
6556
- }
6557
- }
6558
- else
6559
- {
6560
- if (drawingstarted)
6561
- {
6562
- // find next point
6563
- if (bRep.GetVertex(0).faceindices == null)
6564
- {
6565
- bRep.InitFaceIndices();
6566
- }
6567
-
6568
- double ymin = p0.y;
6569
-
6570
- Vertex newp = p0;
6571
-
6572
- for (int fii = 0; fii < p0.faceindices.length; fii++)
6573
- {
6574
- int fi = p0.faceindices[fii];
6575
-
6576
- if (fi == -1)
6577
- break;
6578
-
6579
- Face f = bRep.GetFace(fi);
6580
-
6581
- Vertex p = bRep.GetVertex(f.p);
6582
- Vertex q = bRep.GetVertex(f.q);
6583
- Vertex r = bRep.GetVertex(f.r);
6584
-
6585
- int swap = (int)(Math.random()*3);
6586
-
6587
-// for (int s=swap; --s>=0;)
6588
-// {
6589
-// Vertex t = p;
6590
-// p = q;
6591
-// q = r;
6592
-// r = t;
6593
-// }
6594
- if (ymin > p.y)
6595
- {
6596
- ymin = p.y;
6597
- newp = p;
6598
-// break;
6599
- }
6600
- if (ymin > q.y)
6601
- {
6602
- ymin = q.y;
6603
- newp = q;
6604
-// break;
6605
- }
6606
- if (ymin > r.y)
6607
- {
6608
- ymin = r.y;
6609
- newp = r;
6610
-// break;
6611
- }
6612
- }
6613
-
6614
- CameraPane.selectedpoint.toParent[3][0] = newp.x;
6615
- CameraPane.selectedpoint.toParent[3][1] = newp.y;
6616
- CameraPane.selectedpoint.toParent[3][2] = newp.z;
6617
-
6618
- drawingstarted = false;
6619
-
6620
- // return;
6621
- }
6622
-
6623
- if (false) // CameraPane.DRAW
6624
- {
6625
- p0.AO = colorV[0] = 2;
6626
- colorV[1] = 2;
6627
- colorV[2] = 2;
6628
- }
6629
-
6630
- CameraPane.pointflow.add(p0);
6631
- CameraPane.pointflow.Touch();
6632
- }
6633
-
6634
-// gl.glColor3f(colorV[0], colorV[1], colorV[2]);
6635
-// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0);
6636
-// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
6637
- }
6638
-
66396786 void Print(Vertex v)
66406787 {
66416788 //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")");
66426789 }
66436790
6644
- void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode)
6645
- {
6646
- if (!selectmode)
6647
- {
6648
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6649
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6650
-
6651
- if (flipV)
6652
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6653
- else
6654
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6655
- }
6656
-
6657
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6658
- }
6659
-
6660
- void drawFace(Vertex pv, Vertex qv, Vertex rv,
6661
- CameraPane display, Face face)
6662
- {
6663
- if (pv.y == -10000 ||
6664
- qv.y == -10000 ||
6665
- rv.y == -10000)
6666
- return;
6667
-
6668
-// float b = f.nbiterations & 1;
6669
-// float g = (f.nbiterations>>1) & 1;
6670
-// float r = (f.nbiterations>>2) & 1;
6671
-//
6672
-// //if (f.weight == 10000)
6673
-// //{
6674
-// // r = 1; g = b = 0;
6675
-// //}
6676
-// //else
6677
-// //{
6678
-// // assert(f.weight < 10000);
6679
-// r = g = b = (float)bRep.FaceWeight(f)*100;
6680
-// if (r<0)
6681
-// assert(r>=0);
6682
-// //}
6683
-
6684
- javax.media.opengl.GL gl = display.GetGL();
6685
-
6686
- boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION;
6687
-
6688
- //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv);
6689
- if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
6690
- {
6691
- //gl.glBegin(gl.GL_TRIANGLES);
6692
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
6693
- if (!hasnorm)
6694
- {
6695
- // System.out.println("FUCK!!");
6696
- LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0);
6697
- LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1);
6698
- LA.vecCross(v0, v1, v2);
6699
- LA.vecNormalize(v2);
6700
- gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z);
6701
- }
6702
-
6703
- if (hasnorm)
6704
- {
6705
-// if (!pv.norm.normalized())
6706
-// assert(pv.norm.normalized());
6707
-
6708
- //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z);
6709
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
6710
- }
6711
- gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
6712
- SetColor(display, pv);
6713
- //gl.glColor4f(r, g, b, 1);
6714
- //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1);
6715
- if (flipV)
6716
- gl.glTexCoord2f((float) pv.s, 1-(float) pv.t);
6717
- else
6718
- gl.glTexCoord2f((float) pv.s, (float) pv.t);
6719
- //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z);
6720
- gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z);
6721
-// Print(pv);
6722
- if (hasnorm)
6723
- {
6724
-// assert(qv.norm.normalized());
6725
- //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z);
6726
- gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z);
6727
- }
6728
- //System.out.println("vertexq = " + qv.s + ", " + qv.t);
6729
- // boolean locked = false;
6730
- // float eps = 0.1f;
6731
- // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice
6732
-
6733
- // int dot = 0; //*/ (int)f.dot;
6734
-
6735
- // if ((dot&1) == 0)
6736
- // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1;
6737
-
6738
- // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps)
6739
- if (flipV)
6740
- gl.glTexCoord2f((float) qv.s, 1-(float) qv.t);
6741
- else
6742
- gl.glTexCoord2f((float) qv.s, (float) qv.t);
6743
- // else
6744
- // {
6745
- // locked = true;
6746
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6747
- // }
6748
- gl.glColor4f(qv.AO, qv.AO, qv.AO, 1);
6749
- SetColor(display, qv);
6750
- //gl.glColor4f(r, g, b, 1);
6751
- //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1);
6752
- //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z);
6753
- gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z);
6754
-// Print(qv);
6755
- if (hasnorm)
6756
- {
6757
-// assert(rv.norm.normalized());
6758
- //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z);
6759
- gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z);
6760
- }
6761
-
6762
- // if ((dot&4) == 0)
6763
- // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4;
6764
-
6765
- // if (wrap || !locked && (dot&8) != 0)
6766
- if (flipV)
6767
- gl.glTexCoord2f((float) rv.s, 1-(float) rv.t);
6768
- else
6769
- gl.glTexCoord2f((float) rv.s, (float) rv.t);
6770
- // else
6771
- // gl.glTexCoord2f((float) pv.s, (float) pv.t);
6772
-
6773
- // f.dot = dot;
6774
-
6775
- gl.glColor4f(rv.AO, rv.AO, rv.AO, 1);
6776
- SetColor(display, rv);
6777
- //gl.glColor4f(r, g, b, 1);
6778
- //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1);
6779
- //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z);
6780
- gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z);
6781
-// Print(rv);
6782
- //gl.glEnd();
6783
- }
6784
- else
6785
- {
6786
- gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
6787
- gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z);
6788
- gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z);
6789
-
6790
- }
6791
-
6792
- if (false) // (attributes & WIREFRAME) != 0)
6793
- {
6794
- gl.glDisable(gl.GL_LIGHTING);
6795
-
6796
- gl.glBegin(gl.GL_LINE_LOOP);
6797
- gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z);
6798
- gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z);
6799
- gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z);
6800
- gl.glEnd();
6801
-
6802
- gl.glEnable(gl.GL_LIGHTING);
6803
- }
6804
- }
6805
-
68066791 void drawSelf(ClickInfo info, int level, boolean select)
68076792 {
68086793 if (bRep == null)
....@@ -7326,20 +7311,23 @@
73267311 }
73277312 }
73287313
7329
- protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec)
7314
+ static ClickInfo clickInfo = new ClickInfo();
7315
+
7316
+ protected void calcHotSpot(cVector in, //ClickInfo clickInfo,
7317
+ Point outPt, Rectangle outRec)
73307318 {
7331
- int hc = info.bounds.x + info.bounds.width / 2;
7332
- int vc = info.bounds.y + info.bounds.height / 2;
7333
- double[][] toscreen = info.toScreen;
7319
+ int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2;
7320
+ int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2;
7321
+ double[][] toscreen = clickInfo.toScreen;
73347322 if (toscreen == null)
73357323 {
7336
- toscreen = new Camera(info.camera.viewCode).toScreen;
7324
+ toscreen = new Camera(clickInfo.camera.viewCode).toScreen;
73377325 }
73387326 cVector vec = in;
73397327 LA.xformPos(in, toscreen, in);
73407328 //System.out.println("Distance = " + info.camera.Distance());
7341
- vec.x *= 100 * info.camera.SCALE / info.camera.Distance();
7342
- vec.y *= 100 * info.camera.SCALE / info.camera.Distance();
7329
+ vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
7330
+ vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance();
73437331 outPt.x = hc + (int) vec.x;
73447332 outPt.y = vc - (int) vec.y;
73457333 outRec.x = outPt.x - 3;
....@@ -7347,15 +7335,18 @@
73477335 outRec.width = outRec.height = 6;
73487336 }
73497337
7350
- protected Rectangle calcHotSpot(cVector in, ClickInfo info)
7338
+ protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo
7339
+ )
73517340 {
73527341 Point pt = new Point(0, 0);
73537342 Rectangle rec = new Rectangle();
7354
- calcHotSpot(in, info, pt, rec);
7343
+ calcHotSpot(in, //clickInfo,
7344
+ pt, rec);
73557345 return rec;
73567346 }
73577347
7358
- void drawEditHandles0(ClickInfo info, int level)
7348
+ void drawEditHandles0(//ClickInfo clickInfo,
7349
+ int level)
73597350 {
73607351 if (level == 0)
73617352 {
....@@ -7364,98 +7355,103 @@
73647355 {
73657356 cVector origin = new cVector();
73667357 //LA.xformPos(origin, toParent, origin);
7367
- Rectangle spot = calcHotSpot(origin, info);
7358
+ if (this.clickInfo == null)
7359
+ this.clickInfo = new ClickInfo();
7360
+
7361
+ Rectangle spot = calcHotSpot(origin); //, clickInfo);
73687362 Rectangle boundary = new Rectangle();
73697363 boundary.x = spot.x - 30;
73707364 boundary.y = spot.y - 30;
73717365 boundary.width = spot.width + 60;
73727366 boundary.height = spot.height + 60;
7373
- info.g.setColor(Color.red);
7367
+ clickInfo.g.setColor(Color.red);
73747368 int spotw = spot.x + spot.width;
73757369 int spoth = spot.y + spot.height;
7376
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7377
- if (CameraPane.Xmin > spot.x)
7378
- {
7379
- CameraPane.Xmin = spot.x;
7380
- }
7381
- if (CameraPane.Xmax < spotw)
7382
- {
7383
- CameraPane.Xmax = spotw;
7384
- }
7385
- if (CameraPane.Ymin > spot.y)
7386
- {
7387
- CameraPane.Ymin = spot.y;
7388
- }
7389
- if (CameraPane.Ymax < spoth)
7390
- {
7391
- CameraPane.Ymax = spoth;
7392
- }
7370
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7371
+// if (CameraPane.Xmin > spot.x)
7372
+// {
7373
+// CameraPane.Xmin = spot.x;
7374
+// }
7375
+// if (CameraPane.Xmax < spotw)
7376
+// {
7377
+// CameraPane.Xmax = spotw;
7378
+// }
7379
+// if (CameraPane.Ymin > spot.y)
7380
+// {
7381
+// CameraPane.Ymin = spot.y;
7382
+// }
7383
+// if (CameraPane.Ymax < spoth)
7384
+// {
7385
+// CameraPane.Ymax = spoth;
7386
+// }
73937387 spot.translate(32, 32);
73947388 spotw = spot.x + spot.width;
73957389 spoth = spot.y + spot.height;
7396
- info.g.setColor(Color.blue);
7397
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7398
- if (CameraPane.Xmin > spot.x)
7399
- {
7400
- CameraPane.Xmin = spot.x;
7401
- }
7402
- if (CameraPane.Xmax < spotw)
7403
- {
7404
- CameraPane.Xmax = spotw;
7405
- }
7406
- if (CameraPane.Ymin > spot.y)
7407
- {
7408
- CameraPane.Ymin = spot.y;
7409
- }
7410
- if (CameraPane.Ymax < spoth)
7411
- {
7412
- CameraPane.Ymax = spoth;
7413
- }
7414
- info.g.drawLine(spotw, spoth, spotw, spoth - 15);
7415
- info.g.drawLine(spotw, spoth, spotw - 15, spoth);
7390
+ clickInfo.g.setColor(Color.cyan);
7391
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7392
+// if (CameraPane.Xmin > spot.x)
7393
+// {
7394
+// CameraPane.Xmin = spot.x;
7395
+// }
7396
+// if (CameraPane.Xmax < spotw)
7397
+// {
7398
+// CameraPane.Xmax = spotw;
7399
+// }
7400
+// if (CameraPane.Ymin > spot.y)
7401
+// {
7402
+// CameraPane.Ymin = spot.y;
7403
+// }
7404
+// if (CameraPane.Ymax < spoth)
7405
+// {
7406
+// CameraPane.Ymax = spoth;
7407
+// }
7408
+ // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15
7409
+ //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15
74167410 spot.translate(0, -32);
7417
- info.g.setColor(Color.green);
7418
- info.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7419
- if (CameraPane.Xmin > spot.x)
7420
- {
7421
- CameraPane.Xmin = spot.x;
7422
- }
7423
- if (CameraPane.Xmax < spotw)
7424
- {
7425
- CameraPane.Xmax = spotw;
7426
- }
7427
- if (CameraPane.Ymin > spot.y)
7428
- {
7429
- CameraPane.Ymin = spot.y;
7430
- }
7431
- if (CameraPane.Ymax < spoth)
7432
- {
7433
- CameraPane.Ymax = spoth;
7434
- }
7435
- info.g.drawArc(boundary.x, boundary.y,
7436
- boundary.width, boundary.height, 0, 360);
7411
+ clickInfo.g.setColor(Color.yellow);
7412
+ clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height);
7413
+ clickInfo.g.setColor(Color.green);
7414
+// if (CameraPane.Xmin > spot.x)
7415
+// {
7416
+// CameraPane.Xmin = spot.x;
7417
+// }
7418
+// if (CameraPane.Xmax < spotw)
7419
+// {
7420
+// CameraPane.Xmax = spotw;
7421
+// }
7422
+// if (CameraPane.Ymin > spot.y)
7423
+// {
7424
+// CameraPane.Ymin = spot.y;
7425
+// }
7426
+// if (CameraPane.Ymax < spoth)
7427
+// {
7428
+// CameraPane.Ymax = spoth;
7429
+// }
7430
+ clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY,
7431
+ (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360);
74377432 //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360);
7438
- if (CameraPane.Xmin > boundary.x)
7439
- {
7440
- CameraPane.Xmin = boundary.x;
7441
- }
7442
- if (CameraPane.Xmax < boundary.x + boundary.width)
7443
- {
7444
- CameraPane.Xmax = boundary.x + boundary.width;
7445
- }
7446
- if (CameraPane.Ymin > boundary.y)
7447
- {
7448
- CameraPane.Ymin = boundary.y;
7449
- }
7450
- if (CameraPane.Ymax < boundary.y + boundary.height)
7451
- {
7452
- CameraPane.Ymax = boundary.y + boundary.height;
7453
- }
7433
+// if (CameraPane.Xmin > boundary.x)
7434
+// {
7435
+// CameraPane.Xmin = boundary.x;
7436
+// }
7437
+// if (CameraPane.Xmax < boundary.x + boundary.width)
7438
+// {
7439
+// CameraPane.Xmax = boundary.x + boundary.width;
7440
+// }
7441
+// if (CameraPane.Ymin > boundary.y)
7442
+// {
7443
+// CameraPane.Ymin = boundary.y;
7444
+// }
7445
+// if (CameraPane.Ymax < boundary.y + boundary.height)
7446
+// {
7447
+// CameraPane.Ymax = boundary.y + boundary.height;
7448
+// }
74547449 return;
74557450 }
74567451 }
74577452
7458
- boolean doEditClick0(ClickInfo info, int level)
7453
+ boolean doEditClick0(//ClickInfo clickInfo,
7454
+ int level)
74597455 {
74607456 if (level == 0)
74617457 {
....@@ -7464,10 +7460,10 @@
74647460
74657461 boolean retval = false;
74667462
7467
- startX = info.x;
7468
- startY = info.y;
7463
+ startX = clickInfo.x;
7464
+ startY = clickInfo.y;
74697465
7470
- hitSomething = 0;
7466
+ hitSomething = -1;
74717467 cVector origin = new cVector();
74727468 //LA.xformPos(origin, toParent, origin);
74737469 Rectangle spot = new Rectangle();
....@@ -7475,22 +7471,51 @@
74757471 {
74767472 centerPt = new Point(0, 0);
74777473 }
7478
- calcHotSpot(origin, info, centerPt, spot);
7479
- if (spot.contains(info.x, info.y))
7474
+ calcHotSpot(origin, //info,
7475
+ centerPt, spot);
7476
+ if (spot.contains(clickInfo.x, clickInfo.y))
74807477 {
74817478 hitSomething = hitCenter;
74827479 retval = true;
74837480 }
74847481 spot.translate(32, 0);
7485
- if (spot.contains(info.x, info.y))
7482
+ if (spot.contains(clickInfo.x, clickInfo.y))
74867483 {
74877484 hitSomething = hitRotate;
74887485 retval = true;
74897486 }
74907487 spot.translate(0, 32);
7491
- if (spot.contains(info.x, info.y))
7488
+ if (spot.contains(clickInfo.x, clickInfo.y))
74927489 {
74937490 hitSomething = hitScale;
7491
+
7492
+ double scale = 0.005f * clickInfo.camera.Distance();
7493
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7494
+ double sign = 1;
7495
+ if (hScale < 0)
7496
+ {
7497
+ sign = -1;
7498
+ }
7499
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
7500
+ if (hScale < 0.01)
7501
+ {
7502
+ //hScale = 0.01;
7503
+ }
7504
+
7505
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7506
+ sign = 1;
7507
+ if (vScale < 0)
7508
+ {
7509
+ sign = -1;
7510
+ }
7511
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
7512
+ if (vScale < 0.01)
7513
+ {
7514
+ //vScale = 0.01;
7515
+ }
7516
+
7517
+ clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale);
7518
+
74947519 retval = true;
74957520 }
74967521
....@@ -7500,7 +7525,7 @@
75007525 }
75017526
75027527 //System.out.println("info.modifiers = " + info.modifiers);
7503
- modified = (info.modifiers & CameraPane.META) != 0;
7528
+ modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META
75047529 //System.out.println("modified = " + modified);
75057530 //new Exception().printStackTrace();
75067531 //viewCode = info.pane.renderCamera.viewCode;
....@@ -7528,7 +7553,8 @@
75287553 return true;
75297554 }
75307555
7531
- void doEditDrag0(ClickInfo info)
7556
+ void doEditDrag0(//ClickInfo info,
7557
+ boolean opposite)
75327558 {
75337559 if (hitSomething == 0)
75347560 {
....@@ -7542,7 +7568,8 @@
75427568
75437569 //System.out.println("hitSomething = " + hitSomething);
75447570
7545
- double scale = 0.005f * info.camera.Distance();
7571
+ double scale = 0.005f * clickInfo.camera.Distance();
7572
+
75467573 cVector xlate = new cVector();
75477574 //cVector xlate2 = new cVector();
75487575 switch (hitSomething)
....@@ -7553,9 +7580,9 @@
75537580
75547581 case hitCenter: // Translate
75557582
7556
- scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance();
7583
+ scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance();
75577584
7558
- if (modified)
7585
+ if (modified || opposite)
75597586 {
75607587 //assert(false);
75617588 /*
....@@ -7575,8 +7602,8 @@
75757602 toParent[3][i] = xlate.get(i);
75767603 LA.matInvert(toParent, fromParent);
75777604 */
7578
- cVector delta = LA.newVector(0, 0, startY - info.y);
7579
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7605
+ cVector delta = LA.newVector(0, 0, startY - clickInfo.y);
7606
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
75807607
75817608 LA.matCopy(startMat, toParent);
75827609 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7585,7 +7612,7 @@
75857612 } else
75867613 {
75877614 //LA.xformDir(delta, info.camera.fromScreen, delta);
7588
- cVector up = new cVector(info.camera.up);
7615
+ cVector up = new cVector(clickInfo.camera.up);
75897616 cVector away = new cVector();
75907617 //cVector right2 = new cVector();
75917618 //LA.vecCross(up, cVector.Z, right);
....@@ -7601,20 +7628,20 @@
76017628 }
76027629 LA.xformDir(up, ClickInfo.matbuffer, up);
76037630 // if (!CameraPane.LOCALTRANSFORM)
7604
- LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up);
7605
- LA.xformDir(info.camera.away, ClickInfo.matbuffer, away);
7631
+ LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up);
7632
+ LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away);
76067633 // if (!CameraPane.LOCALTRANSFORM)
7607
- LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away);
7634
+ LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away);
76087635 //LA.vecCross(up, cVector.Z, right2);
76097636
7610
- cVector delta = LA.newVector(info.x - startX, startY - info.y, 0);
7637
+ cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0);
76117638
76127639 //System.out.println("DELTA0 = " + delta);
76137640 //System.out.println("AWAY = " + info.camera.away);
76147641 //System.out.println("UP = " + info.camera.up);
76157642 if (away.z > 0)
76167643 {
7617
- if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0)
7644
+ if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0)
76187645 {
76197646 delta.x = -delta.x;
76207647 } else
....@@ -7629,7 +7656,7 @@
76297656 //System.out.println("DELTA1 = " + delta);
76307657 LA.xformDir(delta, ClickInfo.matbuffer, delta);
76317658 //System.out.println("DELTA2 = " + delta);
7632
- LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta);
7659
+ LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta);
76337660 LA.matCopy(startMat, toParent);
76347661 //System.out.println("DELTA3 = " + delta);
76357662 LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale);
....@@ -7639,8 +7666,8 @@
76397666 break;
76407667
76417668 case hitRotate: // rotate
7642
- int dx = info.x - centerPt.x;
7643
- int dy = -(info.y - centerPt.y);
7669
+ int dx = clickInfo.x - centerPt.x;
7670
+ int dy = -(clickInfo.y - centerPt.y);
76447671 double angle = (double) Math.atan2(dx, dy);
76457672 angle = -(1.570796 - angle);
76467673
....@@ -7649,6 +7676,7 @@
76497676
76507677 if (modified)
76517678 {
7679
+ // Rotate 90 degrees
76527680 angle /= (Math.PI / 4);
76537681 angle = Math.floor(angle + 0.5);
76547682 angle *= (Math.PI / 4);
....@@ -7662,7 +7690,7 @@
76627690 }
76637691 /**/
76647692
7665
- switch (info.pane.renderCamera.viewCode)
7693
+ switch (clickInfo.pane.RenderCamera().viewCode)
76667694 {
76677695 case 1: // '\001'
76687696 LA.matZRotate(toParent, angle);
....@@ -7689,26 +7717,30 @@
76897717 break;
76907718
76917719 case hitScale: // scale
7692
- double hScale = (double) (info.x - centerPt.x) / 32;
7720
+ double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32;
7721
+ double sign = 1;
7722
+ if (hScale < 0)
7723
+ {
7724
+ sign = -1;
7725
+ }
7726
+ hScale = sign*Math.pow(sign*hScale, scale * 50);
76937727 if (hScale < 0.01)
76947728 {
7695
- hScale = 0.01;
7729
+ //hScale = 0.01;
76967730 }
7697
- hScale = Math.pow(hScale, scale * 50);
7698
- if (hScale < 0.01)
7731
+
7732
+ double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32;
7733
+ sign = 1;
7734
+ if (vScale < 0)
76997735 {
7700
- hScale = 0.01;
7736
+ sign = -1;
77017737 }
7702
- double vScale = (double) (info.y - centerPt.y) / 32;
7738
+ vScale = sign*Math.pow(sign*vScale, scale * 50);
77037739 if (vScale < 0.01)
77047740 {
7705
- vScale = 0.01;
7741
+ //vScale = 0.01;
77067742 }
7707
- vScale = Math.pow(vScale, scale * 50);
7708
- if (vScale < 0.01)
7709
- {
7710
- vScale = 0.01;
7711
- }
7743
+
77127744 LA.matCopy(startMat, toParent);
77137745 /**/
77147746 for (int i = 0; i < 3; i++)
....@@ -7718,39 +7750,47 @@
77187750 }
77197751 /**/
77207752
7721
- switch (info.pane.renderCamera.viewCode)
7753
+ double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale;
7754
+
7755
+ if (totalScale < 0.01)
7756
+ {
7757
+ totalScale = 0.01;
7758
+ }
7759
+
7760
+ switch (clickInfo.pane.RenderCamera().viewCode)
77227761 {
77237762 case 3: // '\001'
7724
- if (modified)
7763
+ if (modified || opposite)
77257764 {
77267765 //LA.matScale(toParent, 1, hScale, vScale);
7727
- LA.matScale(toParent, vScale, 1, 1);
7766
+ LA.matScale(toParent, totalScale, 1, 1);
77287767 } // vScale, 1);
77297768 else
77307769 {
7731
- LA.matScale(toParent, vScale, vScale, vScale);
7770
+ // EXCEPTION!
7771
+ LA.matScale(toParent, totalScale, totalScale, totalScale);
77327772 } // vScale, 1);
77337773 break;
77347774
77357775 case 2: // '\002'
7736
- if (modified)
7776
+ if (modified || opposite)
77377777 {
77387778 //LA.matScale(toParent, hScale, 1, vScale);
7739
- LA.matScale(toParent, 1, vScale, 1);
7779
+ LA.matScale(toParent, 1, totalScale, 1);
77407780 } else
77417781 {
7742
- LA.matScale(toParent, vScale, 1, vScale);
7782
+ LA.matScale(toParent, totalScale, 1, totalScale);
77437783 }
77447784 break;
77457785
77467786 case 1: // '\003'
7747
- if (modified)
7787
+ if (modified || opposite)
77487788 {
77497789 //LA.matScale(toParent, hScale, vScale, 1);
7750
- LA.matScale(toParent, 1, 1, vScale);
7790
+ LA.matScale(toParent, 1, 1, totalScale);
77517791 } else
77527792 {
7753
- LA.matScale(toParent, vScale, vScale, 1);
7793
+ LA.matScale(toParent, totalScale, totalScale, 1);
77547794 }
77557795 break;
77567796 }
....@@ -7784,7 +7824,7 @@
77847824 } // NEW ...
77857825
77867826
7787
- info.pane.repaint();
7827
+ clickInfo.pane.repaint();
77887828 }
77897829
77907830 boolean overflow = false;
....@@ -7883,14 +7923,22 @@
78837923 //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")";
78847924 //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString();
78857925 //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString();
7926
+
7927
+ String objname;
7928
+
78867929 if (false) //parent != null)
78877930 {
7888
- return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
7931
+ objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")";
78897932 } else
78907933 {
7891
- return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this);
7934
+ objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ "";
78927935 } // + super.toString();
78937936 //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName();
7937
+
7938
+ if (!Globals.ADVANCED)
7939
+ return objname;
7940
+
7941
+ return objname + " " + System.identityHashCode(this);
78947942 }
78957943
78967944 public int hashCode()
....@@ -7946,6 +7994,7 @@
79467994 objectUI.closeUI();
79477995 if (editWindow != null)
79487996 {
7997
+ editWindow.ctrlPanel.FlushUI();
79497998 editWindow.refreshContents();
79507999 } // ? new
79518000 objectUI = null;
....@@ -7954,6 +8003,10 @@
79548003 {
79558004 editWindow = null;
79568005 } // ?
8006
+ }
8007
+ else
8008
+ {
8009
+ //editWindow.closeUI();
79578010 }
79588011 }
79598012
....@@ -7966,7 +8019,7 @@
79668019 /*transient*/ cVector2[] projectedVertices = new cVector2[0];
79678020
79688021 Object3D /*Composite*/ parent;
7969
- Object3D /*Composite*/ fileparent;
8022
+ Object3D /*Composite*/ fileparent; // In the case of FileObject
79708023
79718024 double[][] toParent; // dynamic matrix
79728025 double[][] fromParent;
....@@ -8081,7 +8134,7 @@
80818134 {
80828135 assert(bRep != null);
80838136 if (!(support instanceof GenericJoint)) // support.bRep != null)
8084
- GrafreeD.Assert(support.bRep == bRep.support);
8137
+ Grafreed.Assert(support.bRep == bRep.support);
80858138 }
80868139 else
80878140 {
....@@ -8112,6 +8165,10 @@
81128165 }
81138166
81148167 transient ObjEditor editWindow;
8168
+ transient ObjEditor manipWindow;
8169
+
8170
+ transient boolean pinned;
8171
+
81158172 transient ObjectUI objectUI;
81168173 public static int povDepth = 0;
81178174 private static cVector tbMin = new cVector();
....@@ -8130,9 +8187,9 @@
81308187 private static cVector edge2 = new cVector();
81318188 //private static cVector norm = new cVector();
81328189 /*transient private*/ int hitSomething;
8133
- private static final int hitCenter = 1;
8134
- private static final int hitScale = 2;
8135
- private static final int hitRotate = 3;
8190
+ static final int hitCenter = 1;
8191
+ static final int hitScale = 2;
8192
+ static final int hitRotate = 3;
81368193 /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag
81378194 /*transient*/ private Point centerPt;
81388195 /*transient*/ private int startX;
....@@ -8164,6 +8221,8 @@
81648221 {
81658222 Object3D targ = this;
81668223
8224
+ targ.NORMALPUSH = obj.NORMALPUSH;
8225
+
81678226 if (obj.material != null)
81688227 {
81698228 if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL))