.. | .. |
---|
5 | 5 | import java.util.Vector; |
---|
6 | 6 | |
---|
7 | 7 | import javax.media.j3d.Transform3D; |
---|
| 8 | +import javax.media.opengl.GL; |
---|
8 | 9 | import javax.vecmath.Vector3d; |
---|
9 | 10 | |
---|
10 | 11 | import javax.imageio.ImageIO; |
---|
.. | .. |
---|
13 | 14 | import //weka.core. |
---|
14 | 15 | matrix.Matrix; |
---|
15 | 16 | |
---|
| 17 | +import java.util.UUID; |
---|
| 18 | + |
---|
16 | 19 | //import net.sourceforge.sizeof.SizeOf; |
---|
17 | 20 | public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> |
---|
18 | 21 | { |
---|
19 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
20 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
21 | 24 | |
---|
| 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 | + |
---|
22 | 35 | 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 | + } |
---|
23 | 49 | |
---|
24 | 50 | void MinMax(cVector minima, cVector maxima) |
---|
25 | 51 | { |
---|
.. | .. |
---|
86 | 112 | |
---|
87 | 113 | // transient boolean reduced; // for morph reduction |
---|
88 | 114 | |
---|
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 |
---|
91 | 117 | |
---|
92 | | -transient Object3D transientsupport; // for cloning |
---|
93 | | -transient boolean transientlink2master; |
---|
| 118 | + transient Object3D transientsupport; // for cloning |
---|
| 119 | + transient boolean transientlink2master; |
---|
94 | 120 | |
---|
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() |
---|
107 | 122 | { |
---|
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 | + } |
---|
109 | 146 | } |
---|
110 | | - |
---|
111 | | - for (int i = 0; i < Size(); i++) |
---|
| 147 | + |
---|
| 148 | + void RestoreSupports() |
---|
112 | 149 | { |
---|
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 | + |
---|
116 | 258 | 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 | + |
---|
118 | 267 | blockloop = false; |
---|
119 | 268 | } |
---|
120 | | -} |
---|
121 | 269 | |
---|
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) |
---|
133 | 271 | { |
---|
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; |
---|
135 | 286 | } |
---|
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 | | -} |
---|
147 | 287 | |
---|
148 | 288 | // MOCAP SUPPORT |
---|
149 | 289 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
286 | 426 | } |
---|
287 | 427 | |
---|
288 | 428 | boolean live = false; |
---|
| 429 | + transient boolean keepdontselect; |
---|
| 430 | + boolean dontselect = false; |
---|
289 | 431 | boolean hide = false; |
---|
290 | 432 | boolean link2master = false; // performs reset support/master at each frame |
---|
291 | 433 | boolean marked = false; // animation node |
---|
.. | .. |
---|
295 | 437 | boolean random = false; |
---|
296 | 438 | boolean speedup = false; |
---|
297 | 439 | boolean rewind = false; |
---|
| 440 | + |
---|
| 441 | + float NORMALPUSH = 0; |
---|
298 | 442 | |
---|
299 | 443 | Object3D support; |
---|
300 | 444 | |
---|
.. | .. |
---|
355 | 499 | |
---|
356 | 500 | int MemorySize() |
---|
357 | 501 | { |
---|
358 | | - if (memorysize == 0) |
---|
| 502 | + if (true) // memorysize == 0) |
---|
359 | 503 | { |
---|
360 | 504 | try |
---|
361 | 505 | { |
---|
.. | .. |
---|
415 | 559 | { |
---|
416 | 560 | Object3D copy = this; |
---|
417 | 561 | |
---|
418 | | - Camera parentcam = CameraPane.theRenderer.manipCamera; |
---|
| 562 | + Camera parentcam = Globals.theRenderer.ManipCamera(); |
---|
419 | 563 | |
---|
420 | | - if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0]) |
---|
| 564 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0]) |
---|
421 | 565 | { |
---|
422 | | - parentcam = CameraPane.theRenderer.cameras[1]; |
---|
| 566 | + parentcam = Globals.theRenderer.Cameras()[1]; |
---|
423 | 567 | } |
---|
424 | 568 | |
---|
425 | | - if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1]) |
---|
| 569 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1]) |
---|
426 | 570 | { |
---|
427 | | - parentcam = CameraPane.theRenderer.cameras[0]; |
---|
| 571 | + parentcam = Globals.theRenderer.Cameras()[0]; |
---|
428 | 572 | } |
---|
429 | 573 | |
---|
430 | 574 | if (this == parentcam) |
---|
.. | .. |
---|
432 | 576 | //assert(this instanceof Camera); |
---|
433 | 577 | |
---|
434 | 578 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
435 | | - LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt); |
---|
| 579 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt()); |
---|
436 | 580 | } |
---|
437 | 581 | |
---|
438 | 582 | copy.marked ^= true; |
---|
.. | .. |
---|
452 | 596 | //assert(this instanceof Camera); |
---|
453 | 597 | |
---|
454 | 598 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
455 | | - LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt); |
---|
| 599 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt()); |
---|
456 | 600 | } |
---|
457 | 601 | |
---|
458 | 602 | copy.Touch(); // display list issue |
---|
.. | .. |
---|
465 | 609 | toParent = LA.newMatrix(); |
---|
466 | 610 | fromParent = LA.newMatrix(); |
---|
467 | 611 | } |
---|
| 612 | + |
---|
468 | 613 | if (toParentMarked == null) |
---|
469 | 614 | { |
---|
470 | 615 | if (maxcount != 1) |
---|
471 | 616 | { |
---|
472 | 617 | new Exception().printStackTrace(); |
---|
473 | 618 | } |
---|
| 619 | + |
---|
474 | 620 | toParentMarked = LA.newMatrix(); |
---|
475 | 621 | fromParentMarked = LA.newMatrix(); |
---|
476 | 622 | } |
---|
.. | .. |
---|
587 | 733 | return; |
---|
588 | 734 | } |
---|
589 | 735 | |
---|
590 | | - if (CameraPane.fromscript) |
---|
| 736 | + if (Globals.fromscript) |
---|
591 | 737 | { |
---|
592 | 738 | transformcount = 0; |
---|
593 | 739 | return; |
---|
.. | .. |
---|
745 | 891 | |
---|
746 | 892 | int GetTransformCount() |
---|
747 | 893 | { |
---|
748 | | - // marde pour serialization de Texture |
---|
| 894 | + // patch pour serialization de Texture |
---|
749 | 895 | resetmaxcount(); |
---|
750 | 896 | resettransformcount(); |
---|
751 | 897 | resetstep(); |
---|
.. | .. |
---|
758 | 904 | if (step == 0) |
---|
759 | 905 | step = 1; |
---|
760 | 906 | if (maxcount == 0) |
---|
761 | | - maxcount = 2048; // 4; |
---|
| 907 | + maxcount = 128; // 2048; // 4; |
---|
762 | 908 | // if (acceleration == 0) |
---|
763 | 909 | // acceleration = 10; |
---|
764 | 910 | if (delay == 0) // serial |
---|
.. | .. |
---|
779 | 925 | // factor = CameraPane.STEP; |
---|
780 | 926 | // } |
---|
781 | 927 | |
---|
782 | | - 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) |
---|
783 | 932 | { |
---|
784 | | - currentframe = CameraPane.framecount; |
---|
| 933 | + currentframe = Globals.framecount; |
---|
785 | 934 | |
---|
786 | 935 | // System.err.println("transformcount = " + transformcount); |
---|
787 | 936 | // System.err.println("factor = " + factor); |
---|
.. | .. |
---|
790 | 939 | |
---|
791 | 940 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
792 | 941 | |
---|
793 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 942 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 943 | + (step == 1 && changedir)) |
---|
794 | 944 | { |
---|
795 | 945 | countdown = 1; |
---|
796 | 946 | delay = speedup?8:1; |
---|
.. | .. |
---|
862 | 1012 | if (material == null || material.multiply) |
---|
863 | 1013 | return true; |
---|
864 | 1014 | |
---|
| 1015 | + // Transparent objects are dynamic because we have to sort the triangles. |
---|
865 | 1016 | return material.opacity > 0.99; |
---|
866 | 1017 | } |
---|
867 | 1018 | |
---|
.. | .. |
---|
893 | 1044 | fromParent = null; // LA.newMatrix(); |
---|
894 | 1045 | bRep = null; // new BoundaryRep(); |
---|
895 | 1046 | |
---|
| 1047 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 1048 | + { |
---|
| 1049 | + name = oname; |
---|
| 1050 | + } |
---|
| 1051 | + |
---|
896 | 1052 | /* |
---|
897 | 1053 | float hue = (float)Math.random(); |
---|
898 | 1054 | Color col; |
---|
.. | .. |
---|
935 | 1091 | |
---|
936 | 1092 | public Object clone() |
---|
937 | 1093 | { |
---|
938 | | - return GraphreeD.clone(this); |
---|
| 1094 | + return Grafreed.clone(this); |
---|
939 | 1095 | } |
---|
940 | 1096 | |
---|
941 | 1097 | Object3D copyExpand() |
---|
.. | .. |
---|
1257 | 1413 | toParent = LA.newMatrix(); |
---|
1258 | 1414 | fromParent = LA.newMatrix(); |
---|
1259 | 1415 | } |
---|
| 1416 | + |
---|
1260 | 1417 | LA.matCopy(other.toParent, toParent); |
---|
1261 | 1418 | LA.matCopy(other.fromParent, fromParent); |
---|
1262 | 1419 | |
---|
.. | .. |
---|
1446 | 1603 | // if (other == null) |
---|
1447 | 1604 | // return; |
---|
1448 | 1605 | |
---|
1449 | | - System.out.println("Link support this = " + this + "; other = " + other); |
---|
| 1606 | + if (other != null) |
---|
| 1607 | + { |
---|
| 1608 | + BoundaryRep.SEUIL = other.material.cameralight; |
---|
| 1609 | + |
---|
| 1610 | + // Set default to 0.1 |
---|
| 1611 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
| 1612 | + System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
| 1613 | + } |
---|
| 1614 | + |
---|
| 1615 | + System.out.println("Link this = " + this + "; support = " + other); |
---|
1450 | 1616 | |
---|
1451 | 1617 | //if (bRep != null) |
---|
1452 | 1618 | // bRep.linkVerticesThis(other.bRep); |
---|
.. | .. |
---|
1701 | 1867 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1702 | 1868 | o.bRep = transientrep; |
---|
1703 | 1869 | if (clone) |
---|
1704 | | - o.bRep = (BoundaryRep) GraphreeD.clone(transientrep); |
---|
| 1870 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1705 | 1871 | o.CreateMaterial(); |
---|
1706 | 1872 | o.SetAttributes(this, -1); |
---|
1707 | 1873 | //parent |
---|
.. | .. |
---|
1714 | 1880 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1715 | 1881 | o.bRep = bRep; |
---|
1716 | 1882 | if (clone) |
---|
1717 | | - o.bRep = (BoundaryRep) GraphreeD.clone(bRep); |
---|
| 1883 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1718 | 1884 | o.CreateMaterial(); |
---|
1719 | 1885 | //o.overwriteThis(this, -1); |
---|
1720 | 1886 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1756 | 1922 | // { |
---|
1757 | 1923 | // assert(bRep == null); |
---|
1758 | 1924 | // Object3D o = new Object3D("Geometry:" + this.name); |
---|
1759 | | -// o.bRep = (BoundaryRep) GraphreeD.clone(transientrep); |
---|
| 1925 | +// o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
1760 | 1926 | // o.CreateMaterial(); |
---|
1761 | 1927 | // parent.addChild(o); |
---|
1762 | 1928 | // } |
---|
.. | .. |
---|
1765 | 1931 | // { |
---|
1766 | 1932 | // assert(transientrep == null); |
---|
1767 | 1933 | // Object3D o = new Object3D("Geometry:" + this.name); |
---|
1768 | | -// o.bRep = (BoundaryRep) GraphreeD.clone(bRep); |
---|
| 1934 | +// o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
1769 | 1935 | // o.CreateMaterial(); |
---|
1770 | 1936 | // parent.addChild(o); |
---|
1771 | 1937 | // } |
---|
.. | .. |
---|
1801 | 1967 | if (obj.name == null) |
---|
1802 | 1968 | continue; // can't be a null one |
---|
1803 | 1969 | |
---|
| 1970 | + // Try perfect match first. |
---|
1804 | 1971 | if (n.equals(obj.name)) |
---|
1805 | 1972 | { |
---|
1806 | 1973 | theobj = obj; |
---|
1807 | 1974 | count++; |
---|
1808 | 1975 | } |
---|
1809 | 1976 | } |
---|
| 1977 | + |
---|
| 1978 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1810 | 1979 | |
---|
1811 | 1980 | if (count != 1) |
---|
1812 | 1981 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
1816 | 1985 | if (obj.name == null) |
---|
1817 | 1986 | continue; // can't be a null one |
---|
1818 | 1987 | |
---|
1819 | | - //if (n.contains(obj.name)) // dec 2013 name.split(":")[0])) // Poser generates a count |
---|
1820 | | - if (n.startsWith(obj.name)) |
---|
| 1988 | + String name = obj.name.split(":")[0]; // Poser generates a count |
---|
| 1989 | + //if (n.startsWith(obj.name)) |
---|
| 1990 | + if (n.contains(name)) |
---|
1821 | 1991 | { |
---|
1822 | 1992 | theobj = obj; |
---|
1823 | 1993 | count++; |
---|
.. | .. |
---|
2120 | 2290 | if (/*parent != null &&*/ material == null) |
---|
2121 | 2291 | { |
---|
2122 | 2292 | 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 |
---|
| 2293 | + |
---|
| 2294 | + InitOthers(); |
---|
2132 | 2295 | |
---|
2133 | 2296 | if (this instanceof Camera) |
---|
2134 | 2297 | { |
---|
.. | .. |
---|
2272 | 2435 | } |
---|
2273 | 2436 | */ |
---|
2274 | 2437 | } |
---|
| 2438 | + else |
---|
| 2439 | + { |
---|
| 2440 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2441 | + } |
---|
2275 | 2442 | } |
---|
2276 | 2443 | |
---|
2277 | 2444 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
2278 | 2445 | { |
---|
2279 | 2446 | if (newWindow) |
---|
2280 | 2447 | { |
---|
| 2448 | + new Exception().printStackTrace(); |
---|
2281 | 2449 | System.exit(0); |
---|
2282 | 2450 | if (parent != null) |
---|
2283 | 2451 | { |
---|
.. | .. |
---|
2312 | 2480 | { |
---|
2313 | 2481 | editWindow.refreshContents(); |
---|
2314 | 2482 | } |
---|
| 2483 | + else |
---|
| 2484 | + { |
---|
| 2485 | + if (manipWindow != null) |
---|
| 2486 | + { |
---|
| 2487 | + manipWindow.refreshContents(); |
---|
| 2488 | + } |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2315 | 2491 | //if (parent != null) |
---|
2316 | 2492 | //parent.refreshEditWindow(); |
---|
2317 | 2493 | } |
---|
.. | .. |
---|
2454 | 2630 | return retval; |
---|
2455 | 2631 | } |
---|
2456 | 2632 | |
---|
2457 | | - void doEditDrag(ClickInfo info) |
---|
| 2633 | + void doEditDrag(ClickInfo info, boolean opposite) |
---|
2458 | 2634 | { |
---|
2459 | 2635 | switch (doSomething) |
---|
2460 | 2636 | { |
---|
2461 | 2637 | case 1: // '\001' |
---|
2462 | 2638 | //super. |
---|
2463 | | - doEditDrag0(info); |
---|
| 2639 | + doEditDrag0(info, opposite); |
---|
2464 | 2640 | break; |
---|
2465 | 2641 | |
---|
2466 | 2642 | case 2: // '\002' |
---|
.. | .. |
---|
2473 | 2649 | { |
---|
2474 | 2650 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2475 | 2651 | //childToDrag.doEditDrag(info); |
---|
2476 | | - sel.doEditDrag(info); |
---|
| 2652 | + sel.doEditDrag(info, opposite); |
---|
2477 | 2653 | } else |
---|
2478 | 2654 | { |
---|
2479 | 2655 | //super. |
---|
2480 | | - doEditDrag0(info); |
---|
| 2656 | + doEditDrag0(info, opposite); |
---|
2481 | 2657 | } |
---|
2482 | 2658 | } |
---|
2483 | 2659 | break; |
---|
.. | .. |
---|
2587 | 2763 | void GenNormalsS(boolean crease) |
---|
2588 | 2764 | { |
---|
2589 | 2765 | selection.GenNormals(crease); |
---|
| 2766 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2767 | +// { |
---|
| 2768 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2769 | +// selectee.GenNormals(crease); |
---|
| 2770 | +// } |
---|
| 2771 | + |
---|
| 2772 | + //Touch(); |
---|
| 2773 | + } |
---|
| 2774 | + |
---|
| 2775 | + void GenNormalsMeshS() |
---|
| 2776 | + { |
---|
| 2777 | + selection.GenNormalsMesh(); |
---|
2590 | 2778 | // for (int i=0; i<selection.size(); i++) |
---|
2591 | 2779 | // { |
---|
2592 | 2780 | // Object3D selectee = (Object3D) selection.elementAt(i); |
---|
.. | .. |
---|
2732 | 2920 | blockloop = false; |
---|
2733 | 2921 | } |
---|
2734 | 2922 | |
---|
| 2923 | + void GenNormalsMesh() |
---|
| 2924 | + { |
---|
| 2925 | + if (blockloop) |
---|
| 2926 | + return; |
---|
| 2927 | + |
---|
| 2928 | + blockloop = true; |
---|
| 2929 | + GenNormalsMesh0(); |
---|
| 2930 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2931 | + { |
---|
| 2932 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2933 | + if (child == null) |
---|
| 2934 | + continue; |
---|
| 2935 | + child.GenNormalsMesh(); |
---|
| 2936 | +// Children().release(i); |
---|
| 2937 | + } |
---|
| 2938 | + blockloop = false; |
---|
| 2939 | + } |
---|
| 2940 | + |
---|
| 2941 | + void GenNormalsMINE() |
---|
| 2942 | + { |
---|
| 2943 | + if (blockloop) |
---|
| 2944 | + return; |
---|
| 2945 | + |
---|
| 2946 | + blockloop = true; |
---|
| 2947 | + GenNormalsMINE0(); |
---|
| 2948 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2949 | + { |
---|
| 2950 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2951 | + if (child == null) |
---|
| 2952 | + continue; |
---|
| 2953 | + child.GenNormalsMINE(); |
---|
| 2954 | +// Children().release(i); |
---|
| 2955 | + } |
---|
| 2956 | + blockloop = false; |
---|
| 2957 | + } |
---|
| 2958 | + |
---|
2735 | 2959 | void ClearColors() |
---|
2736 | 2960 | { |
---|
2737 | 2961 | if (blockloop) |
---|
.. | .. |
---|
2866 | 3090 | { |
---|
2867 | 3091 | if (bRep != null) |
---|
2868 | 3092 | { |
---|
2869 | | - bRep.GenUV(); |
---|
| 3093 | + bRep.GenUV(); //1); |
---|
| 3094 | + //bRep.UnfoldUV(); |
---|
2870 | 3095 | Touch(); |
---|
2871 | 3096 | } |
---|
2872 | 3097 | } |
---|
.. | .. |
---|
2876 | 3101 | if (bRep != null) |
---|
2877 | 3102 | { |
---|
2878 | 3103 | bRep.GenerateNormals(crease); |
---|
| 3104 | + Touch(); |
---|
| 3105 | + } |
---|
| 3106 | + } |
---|
| 3107 | + |
---|
| 3108 | + void GenNormalsMesh0() |
---|
| 3109 | + { |
---|
| 3110 | + if (bRep != null) |
---|
| 3111 | + { |
---|
| 3112 | + bRep.GenerateNormalsMesh(); |
---|
| 3113 | + Touch(); |
---|
| 3114 | + } |
---|
| 3115 | + } |
---|
| 3116 | + |
---|
| 3117 | + void GenNormalsMINE0() |
---|
| 3118 | + { |
---|
| 3119 | + if (bRep != null) |
---|
| 3120 | + { |
---|
| 3121 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
2879 | 3122 | Touch(); |
---|
2880 | 3123 | } |
---|
2881 | 3124 | } |
---|
.. | .. |
---|
2932 | 3175 | blockloop = false; |
---|
2933 | 3176 | } |
---|
2934 | 3177 | |
---|
| 3178 | + void TransformChildren() |
---|
| 3179 | + { |
---|
| 3180 | + if (toParent != null) |
---|
| 3181 | + { |
---|
| 3182 | + for (int i=Size(); --i>=0;) |
---|
| 3183 | + { |
---|
| 3184 | + Object3D v = get(i); |
---|
| 3185 | + |
---|
| 3186 | + if (v.toParent == null) |
---|
| 3187 | + { |
---|
| 3188 | + v.toParent = LA.newMatrix(); |
---|
| 3189 | + v.fromParent = LA.newMatrix(); |
---|
| 3190 | + } |
---|
| 3191 | + |
---|
| 3192 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3193 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3194 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3195 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
| 3196 | + } |
---|
| 3197 | + |
---|
| 3198 | + toParent = null; // LA.matIdentity(toParent); |
---|
| 3199 | + fromParent = null; // LA.matIdentity(fromParent); |
---|
| 3200 | + |
---|
| 3201 | + Touch(); |
---|
| 3202 | + } |
---|
| 3203 | + } |
---|
| 3204 | + |
---|
2935 | 3205 | void TransformGeometry() |
---|
2936 | 3206 | { |
---|
2937 | 3207 | Object3D obj = this; |
---|
.. | .. |
---|
3153 | 3423 | |
---|
3154 | 3424 | BoundaryRep sup = bRep.support; |
---|
3155 | 3425 | bRep.support = null; |
---|
3156 | | - BoundaryRep temprep = (BoundaryRep) GraphreeD.clone(bRep); |
---|
| 3426 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3157 | 3427 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3158 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3428 | + |
---|
| 3429 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3430 | + |
---|
3159 | 3431 | bRep = temprep; |
---|
3160 | 3432 | bRep.support = sup; |
---|
3161 | 3433 | Touch(); |
---|
.. | .. |
---|
3292 | 3564 | if (blockloop) |
---|
3293 | 3565 | return; |
---|
3294 | 3566 | |
---|
3295 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3567 | + if (//marked || // does not make sense |
---|
| 3568 | + (bRep != null || material != null)) // borderline... |
---|
3296 | 3569 | live = h; |
---|
3297 | 3570 | |
---|
3298 | 3571 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3313 | 3586 | return; |
---|
3314 | 3587 | |
---|
3315 | 3588 | //if (bRep != null) |
---|
3316 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3589 | + if (//marked || // does not make sense |
---|
| 3590 | + (bRep != null || material != null)) // borderline... |
---|
3317 | 3591 | link2master = h; |
---|
3318 | 3592 | |
---|
3319 | 3593 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3333 | 3607 | if (blockloop) |
---|
3334 | 3608 | return; |
---|
3335 | 3609 | |
---|
3336 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3610 | + if (//marked || // does not make sense |
---|
| 3611 | + (bRep != null || material != null)) // borderline... |
---|
3337 | 3612 | hide = h; |
---|
3338 | 3613 | |
---|
3339 | 3614 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3353 | 3628 | if (blockloop) |
---|
3354 | 3629 | return; |
---|
3355 | 3630 | |
---|
3356 | | - if (bRep != null && material != null) // borderline... |
---|
| 3631 | + if (bRep != null || material != null) // borderline... |
---|
3357 | 3632 | marked = h; |
---|
3358 | 3633 | |
---|
3359 | 3634 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3363 | 3638 | continue; |
---|
3364 | 3639 | blockloop = true; |
---|
3365 | 3640 | child.MarkLeaves(h); |
---|
| 3641 | + blockloop = false; |
---|
| 3642 | + // release(i); |
---|
| 3643 | + } |
---|
| 3644 | + } |
---|
| 3645 | + |
---|
| 3646 | + void RewindLeaves(boolean h) |
---|
| 3647 | + { |
---|
| 3648 | + if (blockloop) |
---|
| 3649 | + return; |
---|
| 3650 | + |
---|
| 3651 | + if (bRep != null || material != null) // borderline... |
---|
| 3652 | + rewind = h; |
---|
| 3653 | + |
---|
| 3654 | + for (int i = 0; i < Size(); i++) |
---|
| 3655 | + { |
---|
| 3656 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3657 | + if (child == null) |
---|
| 3658 | + continue; |
---|
| 3659 | + blockloop = true; |
---|
| 3660 | + child.RewindLeaves(h); |
---|
| 3661 | + blockloop = false; |
---|
| 3662 | + // release(i); |
---|
| 3663 | + } |
---|
| 3664 | + } |
---|
| 3665 | + |
---|
| 3666 | + void RandomLeaves(boolean h) |
---|
| 3667 | + { |
---|
| 3668 | + if (blockloop) |
---|
| 3669 | + return; |
---|
| 3670 | + |
---|
| 3671 | + if (bRep != null || material != null) // borderline... |
---|
| 3672 | + random = h; |
---|
| 3673 | + |
---|
| 3674 | + for (int i = 0; i < Size(); i++) |
---|
| 3675 | + { |
---|
| 3676 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3677 | + if (child == null) |
---|
| 3678 | + continue; |
---|
| 3679 | + blockloop = true; |
---|
| 3680 | + child.RandomLeaves(h); |
---|
3366 | 3681 | blockloop = false; |
---|
3367 | 3682 | // release(i); |
---|
3368 | 3683 | } |
---|
.. | .. |
---|
3677 | 3992 | if (child == null) |
---|
3678 | 3993 | continue; |
---|
3679 | 3994 | |
---|
3680 | | - if (GraphreeD.RENDERME > 0) |
---|
| 3995 | + if (Grafreed.RENDERME > 0) |
---|
3681 | 3996 | { |
---|
3682 | 3997 | if (child instanceof Merge) |
---|
3683 | 3998 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3717 | 4032 | |
---|
3718 | 4033 | boolean getCentroid(cVector centroid, boolean xform) |
---|
3719 | 4034 | { |
---|
3720 | | - assert(false); |
---|
| 4035 | +// for speaker assert(false); |
---|
3721 | 4036 | if (blockloop) |
---|
3722 | 4037 | return false; |
---|
3723 | 4038 | |
---|
.. | .. |
---|
3828 | 4143 | if (child == null) |
---|
3829 | 4144 | continue; |
---|
3830 | 4145 | |
---|
3831 | | - if (GraphreeD.RENDERME > 0) |
---|
| 4146 | + if (Grafreed.RENDERME > 0) |
---|
3832 | 4147 | { |
---|
3833 | 4148 | if (child instanceof Merge) |
---|
3834 | 4149 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4023 | 4338 | if (child == null) |
---|
4024 | 4339 | continue; |
---|
4025 | 4340 | |
---|
4026 | | - if (GraphreeD.RENDERME > 0) |
---|
| 4341 | + if (Grafreed.RENDERME > 0) |
---|
4027 | 4342 | { |
---|
4028 | 4343 | if (child instanceof Merge) |
---|
4029 | 4344 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4111 | 4426 | if (blockloop) |
---|
4112 | 4427 | return; |
---|
4113 | 4428 | |
---|
4114 | | - for (int i=0; i<size(); i++) |
---|
| 4429 | + for (int i=0; i<Size(); i++) |
---|
4115 | 4430 | { |
---|
4116 | 4431 | if (get(i).parent != this) |
---|
4117 | 4432 | { |
---|
.. | .. |
---|
4120 | 4435 | } |
---|
4121 | 4436 | blockloop = true; |
---|
4122 | 4437 | get(i).RepairParent(); |
---|
| 4438 | + blockloop = false; |
---|
| 4439 | + } |
---|
| 4440 | + } |
---|
| 4441 | + |
---|
| 4442 | + void RepairShadow() |
---|
| 4443 | + { |
---|
| 4444 | + if (blockloop) |
---|
| 4445 | + return; |
---|
| 4446 | + |
---|
| 4447 | + if (this.material != null) |
---|
| 4448 | + this.InitOthers(); |
---|
| 4449 | + |
---|
| 4450 | + for (int i=0; i<Size(); i++) |
---|
| 4451 | + { |
---|
| 4452 | + blockloop = true; |
---|
| 4453 | + get(i).RepairShadow(); |
---|
| 4454 | + blockloop = false; |
---|
| 4455 | + } |
---|
| 4456 | + } |
---|
| 4457 | + |
---|
| 4458 | + void RepairSOV() |
---|
| 4459 | + { |
---|
| 4460 | + if (blockloop) |
---|
| 4461 | + return; |
---|
| 4462 | + |
---|
| 4463 | + String texname = this.GetPigmentTexture(); |
---|
| 4464 | + |
---|
| 4465 | + if (texname.startsWith("sov")) |
---|
| 4466 | + { |
---|
| 4467 | + String[] s = texname.split("/"); |
---|
| 4468 | + |
---|
| 4469 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4470 | + |
---|
| 4471 | + texname = sname[0]; |
---|
| 4472 | + |
---|
| 4473 | + if (sname.length > 1) |
---|
| 4474 | + { |
---|
| 4475 | + texname += "Color.jpg"; |
---|
| 4476 | + } |
---|
| 4477 | + |
---|
| 4478 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4479 | + } |
---|
| 4480 | + |
---|
| 4481 | + texname = this.GetBumpTexture(); |
---|
| 4482 | + |
---|
| 4483 | + if (texname.startsWith("sov")) |
---|
| 4484 | + { |
---|
| 4485 | + String[] s = texname.split("/"); |
---|
| 4486 | + |
---|
| 4487 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4488 | + |
---|
| 4489 | + texname = sname[0]; |
---|
| 4490 | + |
---|
| 4491 | + if (sname.length > 1) |
---|
| 4492 | + { |
---|
| 4493 | + texname += "Bump.jpg"; |
---|
| 4494 | + } |
---|
| 4495 | + |
---|
| 4496 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4497 | + } |
---|
| 4498 | + |
---|
| 4499 | + for (int i=0; i<Size(); i++) |
---|
| 4500 | + { |
---|
| 4501 | + blockloop = true; |
---|
| 4502 | + get(i).RepairSOV(); |
---|
4123 | 4503 | blockloop = false; |
---|
4124 | 4504 | } |
---|
4125 | 4505 | } |
---|
.. | .. |
---|
4515 | 4895 | |
---|
4516 | 4896 | Object3D GetFileRoot() |
---|
4517 | 4897 | { |
---|
| 4898 | + if (overflow) |
---|
| 4899 | + return null; |
---|
| 4900 | + |
---|
| 4901 | + overflow = true; |
---|
| 4902 | + |
---|
| 4903 | + Object3D pfr = null; |
---|
| 4904 | + |
---|
4518 | 4905 | if (parent == null && fileparent == null) |
---|
4519 | | - return this; |
---|
| 4906 | + pfr = this; |
---|
4520 | 4907 | |
---|
4521 | 4908 | if (parent == null && fileparent != null) // V4.gfd??? |
---|
4522 | | - return fileparent; |
---|
| 4909 | + pfr = fileparent; |
---|
4523 | 4910 | |
---|
4524 | | - if (parent == null) |
---|
4525 | | - return this; |
---|
| 4911 | + if (pfr == null && parent == null) |
---|
| 4912 | + pfr = this; |
---|
4526 | 4913 | |
---|
4527 | | - return parent.GetFileRoot(); |
---|
| 4914 | + if (pfr == null) |
---|
| 4915 | + pfr = parent.GetFileRoot(); |
---|
| 4916 | + |
---|
| 4917 | + overflow = false; |
---|
| 4918 | + |
---|
| 4919 | + return pfr; |
---|
4528 | 4920 | } |
---|
4529 | 4921 | |
---|
4530 | 4922 | cTreePath GetPath() |
---|
.. | .. |
---|
4602 | 4994 | |
---|
4603 | 4995 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4604 | 4996 | { |
---|
4605 | | - if (hide) |
---|
| 4997 | + if (hide || dontselect) |
---|
4606 | 4998 | return null; |
---|
4607 | 4999 | |
---|
4608 | 5000 | if (count <= 0) |
---|
.. | .. |
---|
4626 | 5018 | } |
---|
4627 | 5019 | } |
---|
4628 | 5020 | |
---|
| 5021 | + ObjEditor GetWindow() |
---|
| 5022 | + { |
---|
| 5023 | + if (editWindow != null) |
---|
| 5024 | + return editWindow; |
---|
| 5025 | + |
---|
| 5026 | + return manipWindow; |
---|
| 5027 | + } |
---|
| 5028 | + |
---|
4629 | 5029 | cTreePath Select(int indexcount, boolean deselect) |
---|
4630 | 5030 | { |
---|
4631 | | - if (hide) |
---|
| 5031 | + if (hide || dontselect) |
---|
4632 | 5032 | return null; |
---|
4633 | 5033 | |
---|
4634 | 5034 | if (count <= 0) |
---|
.. | .. |
---|
4662 | 5062 | if (leaf != null) |
---|
4663 | 5063 | { |
---|
4664 | 5064 | cTreePath tp = new cTreePath(this, leaf); |
---|
4665 | | - if (editWindow != null) |
---|
| 5065 | + ObjEditor window = GetWindow(); |
---|
| 5066 | + if (window != null) |
---|
4666 | 5067 | { |
---|
4667 | 5068 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4668 | | - editWindow.Select(tp, deselect, true); |
---|
| 5069 | + window.Select(tp, deselect, true); |
---|
4669 | 5070 | } |
---|
4670 | 5071 | |
---|
4671 | 5072 | return tp; |
---|
.. | .. |
---|
4682 | 5083 | |
---|
4683 | 5084 | if (child == null) |
---|
4684 | 5085 | continue; |
---|
| 5086 | + |
---|
4685 | 5087 | if (child.HasTransparency() && child.size() != 0) |
---|
4686 | 5088 | { |
---|
4687 | 5089 | cTreePath leaf = child.Select(indexcount, deselect); |
---|
.. | .. |
---|
4691 | 5093 | if (leaf != null) |
---|
4692 | 5094 | { |
---|
4693 | 5095 | cTreePath tp = new cTreePath(this, leaf); |
---|
4694 | | - if (editWindow != null) |
---|
| 5096 | + ObjEditor window = GetWindow(); |
---|
| 5097 | + if (window != null) |
---|
4695 | 5098 | { |
---|
4696 | | - editWindow.Select(tp, deselect, true); |
---|
| 5099 | + window.Select(tp, deselect, true); |
---|
4697 | 5100 | } |
---|
4698 | 5101 | |
---|
4699 | 5102 | return tp; |
---|
.. | .. |
---|
4778 | 5181 | return globalTransform; |
---|
4779 | 5182 | } |
---|
4780 | 5183 | |
---|
4781 | | - void PreprocessOcclusion(CameraPane cp) |
---|
| 5184 | + void PreprocessOcclusion(iCameraPane cp) |
---|
4782 | 5185 | { |
---|
4783 | 5186 | /* |
---|
4784 | 5187 | if (AOdone) |
---|
.. | .. |
---|
4925 | 5328 | } else // |
---|
4926 | 5329 | if (editWindow != null) |
---|
4927 | 5330 | { |
---|
4928 | | - editWindow.cameraView.lighttouched = true; |
---|
| 5331 | + //editWindow.cameraView.lighttouched = true; |
---|
| 5332 | + Globals.lighttouched = true; |
---|
4929 | 5333 | } |
---|
4930 | 5334 | } |
---|
4931 | 5335 | |
---|
.. | .. |
---|
5017 | 5421 | blockloop = false; |
---|
5018 | 5422 | } |
---|
5019 | 5423 | |
---|
| 5424 | + void ResetSelectable() |
---|
| 5425 | + { |
---|
| 5426 | + if (blockloop) |
---|
| 5427 | + return; |
---|
| 5428 | + |
---|
| 5429 | + blockloop = true; |
---|
| 5430 | + |
---|
| 5431 | + keepdontselect = dontselect; |
---|
| 5432 | + dontselect = true; |
---|
| 5433 | + |
---|
| 5434 | + Object3D child; |
---|
| 5435 | + int nb = Size(); |
---|
| 5436 | + for (int i = 0; i < nb; i++) |
---|
| 5437 | + { |
---|
| 5438 | + child = (Object3D) get(i); |
---|
| 5439 | + if (child == null) |
---|
| 5440 | + continue; |
---|
| 5441 | + child.ResetSelectable(); |
---|
| 5442 | + } |
---|
| 5443 | + |
---|
| 5444 | + blockloop = false; |
---|
| 5445 | + } |
---|
| 5446 | + |
---|
| 5447 | + void RestoreSelectable() |
---|
| 5448 | + { |
---|
| 5449 | + if (blockloop) |
---|
| 5450 | + return; |
---|
| 5451 | + |
---|
| 5452 | + blockloop = true; |
---|
| 5453 | + |
---|
| 5454 | + dontselect = keepdontselect; |
---|
| 5455 | + |
---|
| 5456 | + Object3D child; |
---|
| 5457 | + int nb = Size(); |
---|
| 5458 | + for (int i = 0; i < nb; i++) |
---|
| 5459 | + { |
---|
| 5460 | + child = (Object3D) get(i); |
---|
| 5461 | + if (child == null) |
---|
| 5462 | + continue; |
---|
| 5463 | + child.RestoreSelectable(); |
---|
| 5464 | + } |
---|
| 5465 | + |
---|
| 5466 | + blockloop = false; |
---|
| 5467 | + } |
---|
| 5468 | + |
---|
5020 | 5469 | boolean IsSelected() |
---|
5021 | 5470 | { |
---|
5022 | 5471 | if (parent == null) |
---|
.. | .. |
---|
5079 | 5528 | |
---|
5080 | 5529 | // System.out.println("Fullname = " + fullname); |
---|
5081 | 5530 | |
---|
5082 | | - if (fullname.name.indexOf(":") == -1) |
---|
5083 | | - return fullname.name; |
---|
| 5531 | + // Does not work on Windows due to C: |
---|
| 5532 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5533 | +// return fullname.name; |
---|
| 5534 | +// |
---|
| 5535 | +// return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
5084 | 5536 | |
---|
5085 | | - return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
| 5537 | + String[] split = fullname.name.split(":"); |
---|
| 5538 | + |
---|
| 5539 | + if (split.length == 0) |
---|
| 5540 | + { |
---|
| 5541 | + return ""; |
---|
| 5542 | + } |
---|
| 5543 | + |
---|
| 5544 | + if (split.length <= 2) |
---|
| 5545 | + { |
---|
| 5546 | + if (fullname.name.endsWith(":")) |
---|
| 5547 | + { |
---|
| 5548 | + // Windows |
---|
| 5549 | + return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5550 | + } |
---|
| 5551 | + |
---|
| 5552 | + return split[0]; |
---|
| 5553 | + } |
---|
| 5554 | + |
---|
| 5555 | + // Windows |
---|
| 5556 | + assert(split.length == 4); |
---|
| 5557 | + |
---|
| 5558 | + return split[0] + ":" + split[1]; |
---|
5086 | 5559 | } |
---|
5087 | 5560 | |
---|
5088 | 5561 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5091 | 5564 | return ""; |
---|
5092 | 5565 | |
---|
5093 | 5566 | // System.out.println("Fullname = " + fullname); |
---|
5094 | | - if (fullname.name.indexOf(":") == -1) |
---|
5095 | | - return ""; |
---|
5096 | | - |
---|
5097 | | - return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5567 | + // Does not work on Windows due to C: |
---|
| 5568 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5569 | +// return ""; |
---|
| 5570 | +// |
---|
| 5571 | +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5572 | + String[] split = fullname.name.split(":"); |
---|
| 5573 | + |
---|
| 5574 | + if (split.length == 0) |
---|
| 5575 | + { |
---|
| 5576 | + return ""; |
---|
| 5577 | + } |
---|
| 5578 | + |
---|
| 5579 | + if (split.length == 1) |
---|
| 5580 | + { |
---|
| 5581 | + return ""; |
---|
| 5582 | + } |
---|
| 5583 | + |
---|
| 5584 | + if (split.length == 2) |
---|
| 5585 | + { |
---|
| 5586 | + if (fullname.name.endsWith(":")) |
---|
| 5587 | + { |
---|
| 5588 | + // Windows |
---|
| 5589 | + return ""; |
---|
| 5590 | + } |
---|
| 5591 | + |
---|
| 5592 | + return split[1]; |
---|
| 5593 | + } |
---|
| 5594 | + |
---|
| 5595 | + // Windows |
---|
| 5596 | + assert(split.length == 4); |
---|
| 5597 | + |
---|
| 5598 | + return split[2] + ":" + split[3]; |
---|
5098 | 5599 | } |
---|
5099 | 5600 | |
---|
5100 | 5601 | String GetPigmentTexture() |
---|
.. | .. |
---|
5168 | 5669 | System.out.print("; textures = " + textures); |
---|
5169 | 5670 | System.out.println("; usedtextures = " + usedtextures); |
---|
5170 | 5671 | |
---|
5171 | | - if (GetTextures() == null) |
---|
| 5672 | + if (GetTextures() == null) // What is that?? |
---|
5172 | 5673 | GetTextures().name = ":"; |
---|
5173 | 5674 | |
---|
5174 | 5675 | String texname = tex; |
---|
.. | .. |
---|
5199 | 5700 | child.ResetPigmentTexture(); |
---|
5200 | 5701 | blockloop = false; |
---|
5201 | 5702 | } |
---|
| 5703 | + } |
---|
| 5704 | + |
---|
| 5705 | + UUID GetUUID() |
---|
| 5706 | + { |
---|
| 5707 | + if (uuid == null) |
---|
| 5708 | + { |
---|
| 5709 | + // Serial |
---|
| 5710 | + uuid = UUID.randomUUID(); |
---|
| 5711 | + } |
---|
| 5712 | + |
---|
| 5713 | + return uuid; |
---|
| 5714 | + } |
---|
| 5715 | + |
---|
| 5716 | + Object3D GetObject(UUID uid) |
---|
| 5717 | + { |
---|
| 5718 | + if (blockloop) |
---|
| 5719 | + return null; |
---|
| 5720 | + |
---|
| 5721 | + if (GetUUID().equals(uid)) |
---|
| 5722 | + return this; |
---|
| 5723 | + |
---|
| 5724 | + int nb = Size(); |
---|
| 5725 | + for (int i = 0; i < nb; i++) |
---|
| 5726 | + { |
---|
| 5727 | + Object3D child = (Object3D) get(i); |
---|
| 5728 | + |
---|
| 5729 | + if (child == null) |
---|
| 5730 | + continue; |
---|
| 5731 | + |
---|
| 5732 | + blockloop = true; |
---|
| 5733 | + Object3D obj = child.GetObject(uid); |
---|
| 5734 | + blockloop = false; |
---|
| 5735 | + if (obj != null) |
---|
| 5736 | + return obj; |
---|
| 5737 | + } |
---|
| 5738 | + |
---|
| 5739 | + return null; |
---|
5202 | 5740 | } |
---|
5203 | 5741 | |
---|
5204 | 5742 | void SetBumpTexture(String tex) |
---|
.. | .. |
---|
5237 | 5775 | } |
---|
5238 | 5776 | } |
---|
5239 | 5777 | |
---|
5240 | | - void draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 5778 | + void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5241 | 5779 | { |
---|
5242 | 5780 | Draw(display, root, selected, blocked); |
---|
5243 | 5781 | } |
---|
5244 | 5782 | |
---|
5245 | | - static cMaterial[] materialstack = new cMaterial[65536]; |
---|
5246 | | - static boolean[] selectedstack = new boolean[65536]; |
---|
5247 | | - static int materialdepth = 0; |
---|
5248 | | - |
---|
5249 | 5783 | boolean NeedSupport() |
---|
5250 | 5784 | { |
---|
5251 | 5785 | return |
---|
5252 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5786 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5253 | 5787 | // PROBLEM with CROWD!! |
---|
5254 | | - && (CameraPane.drawMode == CameraPane.SHADOW || CameraPane.CROWD); |
---|
| 5788 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5255 | 5789 | } |
---|
5256 | 5790 | |
---|
| 5791 | + static boolean DEBUG_SELECTION = false; |
---|
5257 | 5792 | |
---|
5258 | | - void Draw(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 5793 | + boolean IsLive() |
---|
| 5794 | + { |
---|
| 5795 | + if (live) |
---|
| 5796 | + return true; |
---|
| 5797 | + |
---|
| 5798 | + if (parent == null) |
---|
| 5799 | + return false; |
---|
| 5800 | + |
---|
| 5801 | + return parent.IsLive(); |
---|
| 5802 | + } |
---|
| 5803 | + |
---|
| 5804 | + void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5259 | 5805 | { |
---|
5260 | 5806 | Invariants(); // june 2013 |
---|
5261 | 5807 | |
---|
.. | .. |
---|
5264 | 5810 | // System.err.println("Draw " + this + " Frame # " + ((Mocap)((Merge)support).object).frame); |
---|
5265 | 5811 | } |
---|
5266 | 5812 | |
---|
5267 | | - if (display.drawMode == CameraPane.SELECTION && |
---|
5268 | | - hide) |
---|
| 5813 | + if (display.DrawMode() == iCameraPane.SELECTION && |
---|
| 5814 | + (hide || dontselect)) |
---|
5269 | 5815 | return; |
---|
5270 | 5816 | |
---|
5271 | 5817 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5280 | 5826 | if (name != null && name.contains("sclera")) |
---|
5281 | 5827 | name = name; |
---|
5282 | 5828 | |
---|
5283 | | - if (this instanceof CheckerIG) |
---|
| 5829 | + if (this instanceof Checker) |
---|
5284 | 5830 | return; |
---|
5285 | 5831 | |
---|
5286 | | - if (display.drawMode == display.SHADOW && PASSTEST) |
---|
| 5832 | + if (display.DrawMode() == display.SHADOW && PASSTEST) |
---|
5287 | 5833 | return; |
---|
5288 | 5834 | |
---|
5289 | 5835 | if (count <= 0) |
---|
.. | .. |
---|
5291 | 5837 | return; |
---|
5292 | 5838 | } |
---|
5293 | 5839 | |
---|
5294 | | - if ((//display.drawMode == CameraPane.SHADOW || |
---|
5295 | | - display.drawMode == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency()) |
---|
| 5840 | + if ((//display.DrawMode() == CameraPane.SHADOW || |
---|
| 5841 | + display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency()) |
---|
5296 | 5842 | { |
---|
5297 | 5843 | return; |
---|
5298 | 5844 | } |
---|
5299 | 5845 | |
---|
5300 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 5846 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5301 | 5847 | |
---|
5302 | 5848 | /* |
---|
5303 | 5849 | if (touched) |
---|
.. | .. |
---|
5316 | 5862 | support = support; |
---|
5317 | 5863 | |
---|
5318 | 5864 | //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5319 | | - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5865 | + boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5320 | 5866 | |
---|
5321 | 5867 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5322 | 5868 | { |
---|
.. | .. |
---|
5333 | 5879 | |
---|
5334 | 5880 | boolean compiled = false; |
---|
5335 | 5881 | |
---|
5336 | | - boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 5882 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5337 | 5883 | |
---|
5338 | | - if (!selectmode && //display.drawMode != display.SELECTION && |
---|
5339 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5884 | + if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
| 5885 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5886 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5340 | 5887 | { |
---|
5341 | | - display.lighttouched = true; |
---|
| 5888 | + Globals.lighttouched = true; |
---|
5342 | 5889 | } // all panes... |
---|
5343 | | - //if (usecalllists && display.drawMode != display.SELECTION && display.drawMode != display.SHADOW && |
---|
5344 | | - if (bRep != null && usecalllists && !selectmode && // june 2013 display.drawMode != display.SHADOW && |
---|
| 5890 | + |
---|
| 5891 | + //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
| 5892 | + if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5345 | 5893 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
5346 | 5894 | { |
---|
5347 | 5895 | if (!(this instanceof Composite)) |
---|
.. | .. |
---|
5349 | 5897 | //if (displaylist == -1 && usecalllists) |
---|
5350 | 5898 | if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
5351 | 5899 | { |
---|
5352 | | - bRep.displaylist = gl.glGenLists(1); |
---|
| 5900 | + bRep.displaylist = display.GenList(); |
---|
5353 | 5901 | assert(bRep.displaylist != 0); |
---|
5354 | 5902 | // System.err.println("glGenLists: " + bRep.displaylist + " for " + this); |
---|
5355 | 5903 | //System.out.println("\tgen list " + list); |
---|
.. | .. |
---|
5361 | 5909 | if (usecalllists) |
---|
5362 | 5910 | { |
---|
5363 | 5911 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5364 | | - gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 5912 | + display.NewList(bRep.displaylist); |
---|
5365 | 5913 | } |
---|
| 5914 | + |
---|
5366 | 5915 | CallList(display, root, selected, blocked); |
---|
| 5916 | + |
---|
5367 | 5917 | // compiled = true; |
---|
5368 | 5918 | if (usecalllists) |
---|
5369 | 5919 | { |
---|
5370 | 5920 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5371 | | - gl.glEndList(); |
---|
| 5921 | + display.EndList(); |
---|
5372 | 5922 | } |
---|
5373 | 5923 | //gl.glDrawBuffer(gl.GL_BACK); |
---|
5374 | 5924 | // XXX touched = false; |
---|
5375 | | - display.lighttouched = true; // all panes... |
---|
| 5925 | + Globals.lighttouched = true; // all panes... |
---|
5376 | 5926 | } |
---|
5377 | 5927 | |
---|
5378 | 5928 | touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; |
---|
.. | .. |
---|
5411 | 5961 | |
---|
5412 | 5962 | // frustum culling |
---|
5413 | 5963 | if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid |
---|
5414 | | - && display.drawMode != CameraPane.SELECTION) |
---|
| 5964 | + && display.DrawMode() != iCameraPane.SELECTION) |
---|
5415 | 5965 | { |
---|
5416 | | - if (display.drawMode == CameraPane.SHADOW) |
---|
| 5966 | + if (display.DrawMode() == iCameraPane.SHADOW) |
---|
5417 | 5967 | { |
---|
5418 | 5968 | if (!link2master // tricky to cull in shadow mode. |
---|
5419 | | - && GetBRep().FrustumCull(this, gl, display.lightCamera, true)) |
---|
| 5969 | + && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
5420 | 5970 | { |
---|
5421 | 5971 | //System.out.print("CULLED"); |
---|
5422 | 5972 | culled = true; |
---|
.. | .. |
---|
5424 | 5974 | } |
---|
5425 | 5975 | else |
---|
5426 | 5976 | //GetBRep().getBounds(v0, v1, this); |
---|
5427 | | - if (GetBRep().FrustumCull(this, gl, display.renderCamera, false)) |
---|
| 5977 | + if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false)) |
---|
5428 | 5978 | culled = true; |
---|
5429 | 5979 | |
---|
5430 | 5980 | // LA.xformPos(v0, display.renderCamera.toScreen, v0); |
---|
.. | .. |
---|
5460 | 6010 | |
---|
5461 | 6011 | |
---|
5462 | 6012 | if (!culled) |
---|
5463 | | - if (display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION) |
---|
| 6013 | + if (display.DrawMode() == display.SELECTION || display.IsDebugSelection()) |
---|
5464 | 6014 | { |
---|
5465 | 6015 | if (GetBRep() != null) |
---|
5466 | 6016 | { |
---|
5467 | | - CameraPane.NextIndex(this, gl); |
---|
| 6017 | + display.NextIndex(); |
---|
| 6018 | + |
---|
5468 | 6019 | // vertex color conflict : gl.glCallList(list); |
---|
5469 | 6020 | DrawNode(display, root, selected); |
---|
5470 | 6021 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5486 | 6037 | color[2] /= 2; |
---|
5487 | 6038 | gl.glMaterialfv(gl.GL_BACK, gl.GL_AMBIENT_AND_DIFFUSE, color, 0); |
---|
5488 | 6039 | */ |
---|
5489 | | - if (material != null) |
---|
5490 | | - { |
---|
5491 | | - materialstack[materialdepth] = material; |
---|
5492 | | - selectedstack[materialdepth] = selected; |
---|
5493 | | - cStatic.objectstack[materialdepth++] = this; |
---|
5494 | | - //System.out.println("material " + material); |
---|
5495 | | - //Applet3D.tracein(this, selected); |
---|
5496 | | - display.vector2buffer = projectedVertices; |
---|
5497 | | - if (this instanceof Camera) |
---|
5498 | | - { |
---|
5499 | | - display.options1[0] = material.shift; |
---|
5500 | | - //System.out.println("shift " + material.shift); |
---|
5501 | | - display.options1[1] = material.lightarea; |
---|
5502 | | - display.options1[2] = material.shadowbias; |
---|
5503 | | - display.options1[3] = material.aniso; |
---|
5504 | | - display.options1[4] = material.anisoV; |
---|
5505 | | - display.options2[0] = material.opacity; |
---|
5506 | | - display.options2[1] = material.diffuse; |
---|
5507 | | - display.options2[2] = material.factor; |
---|
5508 | | - |
---|
5509 | | - cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
5510 | | - display.options3[3] = material.cameralight/0.2f; |
---|
5511 | | - |
---|
5512 | | - // if (display.CURRENTANTIALIAS > 0) |
---|
5513 | | - // display.options3[3] /= 4; |
---|
5514 | | - |
---|
5515 | | - /* |
---|
5516 | | - System.out.println("Focus = " + display.options1[0]); |
---|
5517 | | - System.out.println("Aperture = " + display.options1[1]); |
---|
5518 | | - System.out.println("ShadowBlur = " + display.options1[2]); |
---|
5519 | | - System.out.println("Antialiasing = " + display.options1[3]); |
---|
5520 | | - System.out.println("Fog = " + display.options2[0]); |
---|
5521 | | - System.out.println("Intensity = " + display.options2[1]); |
---|
5522 | | - System.out.println("Elevation = " + display.options2[2]); |
---|
5523 | | - /**/ |
---|
5524 | | - } else |
---|
5525 | | - { |
---|
5526 | | - material.Draw(display, selected); |
---|
5527 | | - } |
---|
5528 | | - } else |
---|
5529 | | - { |
---|
5530 | | - if (selected && CameraPane.flash) |
---|
5531 | | - { |
---|
5532 | | - display.modelParams4[1] = 100; |
---|
5533 | | - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
5534 | | - } |
---|
5535 | | - } |
---|
| 6040 | + display.PushMaterial(this, selected); |
---|
5536 | 6041 | |
---|
5537 | 6042 | //System.out.println("call list " + list); |
---|
5538 | 6043 | //System.out.println(); |
---|
.. | .. |
---|
5551 | 6056 | tex = GetTextures(); |
---|
5552 | 6057 | } |
---|
5553 | 6058 | |
---|
5554 | | - display.BindTextures(tex, texres); |
---|
| 6059 | + boolean failedPigment = false; |
---|
| 6060 | + boolean failedBump = false; |
---|
| 6061 | + |
---|
| 6062 | + try |
---|
| 6063 | + { |
---|
| 6064 | + display.BindPigmentTexture(tex, texres); |
---|
| 6065 | + } |
---|
| 6066 | + catch (Exception e) |
---|
| 6067 | + { |
---|
| 6068 | + System.err.println("FAILED: " + this); |
---|
| 6069 | + failedPigment = true; |
---|
| 6070 | + } |
---|
| 6071 | + |
---|
| 6072 | + try |
---|
| 6073 | + { |
---|
| 6074 | + display.BindBumpTexture(tex, texres); |
---|
| 6075 | + } |
---|
| 6076 | + catch (Exception e) |
---|
| 6077 | + { |
---|
| 6078 | + //System.err.println("FAILED: " + this); |
---|
| 6079 | + failedBump = true; |
---|
| 6080 | + } |
---|
5555 | 6081 | |
---|
5556 | 6082 | if (!compiled) |
---|
5557 | 6083 | { |
---|
.. | .. |
---|
5567 | 6093 | |
---|
5568 | 6094 | // System.err.println("glCallList: " + bRep.displaylist + " for " + this); |
---|
5569 | 6095 | assert(bRep.displaylist != 0); |
---|
5570 | | - gl.glCallList(bRep.displaylist); |
---|
| 6096 | + display.CallList(bRep.displaylist); |
---|
5571 | 6097 | // june 2013 drawSelf(display, root, selected); |
---|
5572 | 6098 | } |
---|
5573 | 6099 | } |
---|
5574 | 6100 | } |
---|
5575 | 6101 | |
---|
5576 | | - display.ReleaseTextures(tex); |
---|
5577 | | - |
---|
5578 | | - //if (parent != null && parent.GetMaterial() != null) |
---|
5579 | | - // parent.GetMaterial().Draw(display, parent.IsSelected(this)); |
---|
5580 | | - if (material != null) |
---|
5581 | | - { |
---|
5582 | | - materialdepth -= 1; |
---|
5583 | | - if (materialdepth > 0) |
---|
5584 | | - { |
---|
5585 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
5586 | | - materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]); |
---|
5587 | | - } |
---|
5588 | | - //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
5589 | | - } else if (selected && CameraPane.flash && GetMaterial() != null) |
---|
5590 | | - { |
---|
5591 | | - display.modelParams4[1] = GetMaterial().cameralight; |
---|
5592 | | - gl.glProgramEnvParameter4fvARB(gl.GL_FRAGMENT_PROGRAM_ARB, 4, display.modelParams4, 0); |
---|
5593 | | - } |
---|
| 6102 | + if (!failedBump) |
---|
| 6103 | + display.ReleaseBumpTexture(tex); |
---|
| 6104 | + |
---|
| 6105 | + if (!failedPigment) |
---|
| 6106 | + display.ReleasePigmentTexture(tex); |
---|
| 6107 | + |
---|
| 6108 | + display.PopMaterial(this, selected); |
---|
5594 | 6109 | } |
---|
5595 | 6110 | |
---|
5596 | 6111 | if (this instanceof Texture || this instanceof TextureNode) |
---|
.. | .. |
---|
5632 | 6147 | // resetMasterNode(); |
---|
5633 | 6148 | } |
---|
5634 | 6149 | |
---|
5635 | | - void CallList(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 6150 | + void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5636 | 6151 | { |
---|
5637 | 6152 | if (GetBRep() == null) |
---|
5638 | 6153 | { |
---|
.. | .. |
---|
5715 | 6230 | boolean flipV = false; // true; |
---|
5716 | 6231 | int texres = 0; // 0 = low, 1 = normal, 2 = high res texture |
---|
5717 | 6232 | |
---|
5718 | | - void drawSelf(CameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
| 6233 | + void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5719 | 6234 | { |
---|
| 6235 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6236 | + return; |
---|
| 6237 | + |
---|
5720 | 6238 | if (hide) |
---|
5721 | 6239 | return; |
---|
5722 | 6240 | // shadow optimisation |
---|
.. | .. |
---|
5774 | 6292 | // // ??????????????????????????? Touch(); |
---|
5775 | 6293 | // } |
---|
5776 | 6294 | |
---|
5777 | | - if (material != null) |
---|
5778 | | - { |
---|
5779 | | - materialstack[materialdepth] = material; |
---|
5780 | | - selectedstack[materialdepth] = selected; |
---|
5781 | | - cStatic.objectstack[materialdepth++] = this; |
---|
5782 | | - //System.out.println("material " + material); |
---|
5783 | | - //Applet3D.tracein("selected ", selected); |
---|
5784 | | - display.vector2buffer = projectedVertices; |
---|
5785 | | - material.Draw(display, selected); |
---|
5786 | | - } |
---|
| 6295 | +display.PushMaterial2(this, selected); |
---|
5787 | 6296 | |
---|
5788 | 6297 | Object3D child; |
---|
5789 | 6298 | boolean sel; |
---|
.. | .. |
---|
5807 | 6316 | if (!child.HasTransparency()) |
---|
5808 | 6317 | { |
---|
5809 | 6318 | sel = root != null && root.selection != null && root.selection.indexOf(child) != -1; |
---|
5810 | | - // GraphreeD.tracein("draw ", child); |
---|
| 6319 | + // GrafreeD.tracein("draw ", child); |
---|
5811 | 6320 | boolean wasblocked = blockdraw; |
---|
5812 | 6321 | blockdraw = true; |
---|
5813 | 6322 | child.draw(display, root, selected || sel, wasblocked || blocked); // || child.IsSelected()); |
---|
5814 | 6323 | blockdraw = false; |
---|
5815 | | - // GraphreeD.traceout("draw ", child); |
---|
| 6324 | + // GrafreeD.traceout("draw ", child); |
---|
5816 | 6325 | } |
---|
5817 | 6326 | |
---|
5818 | 6327 | release(i); |
---|
.. | .. |
---|
5835 | 6344 | */ |
---|
5836 | 6345 | //depth += 1; |
---|
5837 | 6346 | |
---|
5838 | | - if (material != null) |
---|
5839 | | - { |
---|
5840 | | - materialdepth -= 1; |
---|
5841 | | - if (materialdepth > 0) |
---|
5842 | | - { |
---|
5843 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
5844 | | - materialstack[materialdepth - 1].Draw(display, selectedstack[materialdepth - 1]); |
---|
5845 | | - } |
---|
5846 | | - //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
5847 | | - //else |
---|
5848 | | - //material.Draw(display, false); |
---|
5849 | | - } |
---|
5850 | | - |
---|
| 6347 | +display.PopMaterial2(this); |
---|
5851 | 6348 | /* |
---|
5852 | 6349 | display.ReleaseTextures(tex); |
---|
5853 | 6350 | */ |
---|
.. | .. |
---|
5858 | 6355 | |
---|
5859 | 6356 | //static cVector min,max; |
---|
5860 | 6357 | |
---|
5861 | | - void DrawNode(CameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
| 6358 | + void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) |
---|
5862 | 6359 | { |
---|
5863 | | - if (display.drawMode == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
| 6360 | + if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5864 | 6361 | return; // no shadow for transparent objects |
---|
| 6362 | + |
---|
| 6363 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6364 | + return; |
---|
5865 | 6365 | |
---|
5866 | 6366 | if (hide) |
---|
5867 | 6367 | return; |
---|
.. | .. |
---|
5903 | 6403 | return; |
---|
5904 | 6404 | } |
---|
5905 | 6405 | |
---|
| 6406 | + //bRep.GenUV(1/material.diffuseness); |
---|
5906 | 6407 | // bRep.lock = true; |
---|
5907 | 6408 | |
---|
5908 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 6409 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5909 | 6410 | |
---|
5910 | | - if (CameraPane.BOXMODE) // || CameraPane.movingcamera) |
---|
| 6411 | + if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
5911 | 6412 | { |
---|
5912 | 6413 | int fc = bRep.FaceCount(); |
---|
5913 | 6414 | int vc = bRep.VertexCount(); |
---|
.. | .. |
---|
5922 | 6423 | |
---|
5923 | 6424 | bRep.getMinMax(min, max, 100); |
---|
5924 | 6425 | |
---|
5925 | | - gl.glBegin(gl.GL_LINES); |
---|
5926 | | - |
---|
5927 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5928 | | - gl.glVertex3d(min.x, min.y, max.z); |
---|
5929 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5930 | | - gl.glVertex3d(min.x, max.y, min.z); |
---|
5931 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5932 | | - gl.glVertex3d(max.x, min.y, min.z); |
---|
5933 | | - |
---|
5934 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5935 | | - gl.glVertex3d(min.x, max.y, max.z); |
---|
5936 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5937 | | - gl.glVertex3d(max.x, min.y, max.z); |
---|
5938 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5939 | | - gl.glVertex3d(max.x, max.y, min.z); |
---|
5940 | | - |
---|
5941 | | - gl.glEnd(); |
---|
| 6426 | + display.DrawBox(min, max); |
---|
5942 | 6427 | |
---|
5943 | 6428 | return; |
---|
5944 | 6429 | } |
---|
.. | .. |
---|
5982 | 6467 | { |
---|
5983 | 6468 | //throw new Error(); |
---|
5984 | 6469 | |
---|
5985 | | - boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 6470 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5986 | 6471 | |
---|
5987 | 6472 | int[] strips = bRep.getRawIndices(); |
---|
5988 | 6473 | |
---|
.. | .. |
---|
5992 | 6477 | new Exception().printStackTrace(); |
---|
5993 | 6478 | return; |
---|
5994 | 6479 | } |
---|
5995 | | - |
---|
5996 | | - // TRIANGLE STRIP ARRAY |
---|
5997 | | - if (bRep.trimmed) |
---|
| 6480 | + |
---|
| 6481 | + if (dontselect) |
---|
5998 | 6482 | { |
---|
5999 | | - float[] v = bRep.getRawVertices(); |
---|
6000 | | - float[] n = bRep.getRawNormals(); |
---|
6001 | | - float[] c = bRep.getRawColors(); |
---|
6002 | | - float[] uv = bRep.getRawUVMap(); |
---|
6003 | | - |
---|
6004 | | - int count2 = 0; |
---|
6005 | | - int count3 = 0; |
---|
6006 | | - |
---|
6007 | | - if (n.length > 0) |
---|
6008 | | - { |
---|
6009 | | - for (int i = 0; i < strips.length; i++) |
---|
6010 | | - { |
---|
6011 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6012 | | - |
---|
6013 | | - /* |
---|
6014 | | - boolean locked = false; |
---|
6015 | | - float eps = 0.1f; |
---|
6016 | | - boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
6017 | | - |
---|
6018 | | - int dot = 0; |
---|
6019 | | - |
---|
6020 | | - if ((dot&1) == 0) |
---|
6021 | | - dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
6022 | | - |
---|
6023 | | - if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
6024 | | - gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
6025 | | - else |
---|
6026 | | - { |
---|
6027 | | - locked = true; |
---|
6028 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6029 | | - } |
---|
6030 | | - //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
6031 | | - gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
6032 | | - if (hasnorm) |
---|
6033 | | - { |
---|
6034 | | - //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
6035 | | - gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
6036 | | - } |
---|
6037 | | - |
---|
6038 | | - if ((dot&4) == 0) |
---|
6039 | | - dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
6040 | | - |
---|
6041 | | - if (wrap || !locked && (dot&8) != 0) |
---|
6042 | | - gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
6043 | | - else |
---|
6044 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6045 | | - |
---|
6046 | | - f.dot = dot; |
---|
6047 | | - */ |
---|
6048 | | - |
---|
6049 | | - if (!selectmode) |
---|
6050 | | - { |
---|
6051 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6052 | | - { |
---|
6053 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6054 | | - } else |
---|
6055 | | - { |
---|
6056 | | - gl.glNormal3f(0, 0, 1); |
---|
6057 | | - } |
---|
6058 | | - |
---|
6059 | | - if (c != null) |
---|
6060 | | - //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
6061 | | - { |
---|
6062 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6063 | | - } |
---|
6064 | | - } |
---|
6065 | | - if (flipV) |
---|
6066 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6067 | | - else |
---|
6068 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6069 | | - //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6070 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6071 | | - |
---|
6072 | | - count2 += 2; |
---|
6073 | | - count3 += 3; |
---|
6074 | | - if (!selectmode) |
---|
6075 | | - { |
---|
6076 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6077 | | - { |
---|
6078 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6079 | | - } else |
---|
6080 | | - { |
---|
6081 | | - gl.glNormal3f(0, 0, 1); |
---|
6082 | | - } |
---|
6083 | | - if (c != null) |
---|
6084 | | - { |
---|
6085 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6086 | | - } |
---|
6087 | | - } |
---|
6088 | | - if (flipV) |
---|
6089 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6090 | | - else |
---|
6091 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6092 | | - //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6093 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6094 | | - |
---|
6095 | | - count2 += 2; |
---|
6096 | | - count3 += 3; |
---|
6097 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6098 | | - { |
---|
6099 | | - //gl.glTexCoord2d(...); |
---|
6100 | | - if (!selectmode) |
---|
6101 | | - { |
---|
6102 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6103 | | - { |
---|
6104 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6105 | | - } else |
---|
6106 | | - { |
---|
6107 | | - gl.glNormal3f(0, 0, 1); |
---|
6108 | | - } |
---|
6109 | | - if (c != null) |
---|
6110 | | - { |
---|
6111 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6112 | | - } |
---|
6113 | | - } |
---|
6114 | | - |
---|
6115 | | - if (flipV) |
---|
6116 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6117 | | - else |
---|
6118 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6119 | | - //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
6120 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6121 | | - count2 += 2; |
---|
6122 | | - count3 += 3; |
---|
6123 | | - } |
---|
6124 | | - |
---|
6125 | | - gl.glEnd(); |
---|
6126 | | - } |
---|
6127 | | - } |
---|
6128 | | - |
---|
6129 | | - assert count3 == v.length; |
---|
| 6483 | + //bRep.GenerateNormalsMINE(); |
---|
6130 | 6484 | } |
---|
6131 | | - else // !trimmed |
---|
6132 | | - { |
---|
6133 | | - int count = 0; |
---|
6134 | | - for (int i = 0; i < strips.length; i++) |
---|
6135 | | - { |
---|
6136 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6137 | | - |
---|
6138 | | - Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
6139 | | - Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
6140 | | - |
---|
6141 | | - drawVertex(gl, p, selectmode); |
---|
6142 | | - drawVertex(gl, q, selectmode); |
---|
6143 | | - |
---|
6144 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6145 | | - { |
---|
6146 | | - Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
6147 | | - |
---|
6148 | | -// if (j%2 == 0) |
---|
6149 | | -// drawFace(p, q, r, display, null); |
---|
6150 | | -// else |
---|
6151 | | -// drawFace(p, r, q, display, null); |
---|
6152 | | - |
---|
6153 | | -// p = q; |
---|
6154 | | -// q = r; |
---|
6155 | | - drawVertex(gl, r, selectmode); |
---|
6156 | | - } |
---|
6157 | | - |
---|
6158 | | - gl.glEnd(); |
---|
6159 | | - } |
---|
6160 | | - } |
---|
| 6485 | + |
---|
| 6486 | + display.DrawGeometry(bRep, flipV, selectmode); |
---|
6161 | 6487 | } else // catch (Error e) |
---|
6162 | 6488 | { |
---|
6163 | 6489 | // TRIANGLE ARRAY |
---|
6164 | 6490 | if (IsOpaque()) // Static()) |
---|
6165 | 6491 | { |
---|
6166 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6492 | + display.StartTriangles(); |
---|
6167 | 6493 | int facecount = bRep.FaceCount(); |
---|
6168 | 6494 | for (int i = 0; i < facecount; i++) |
---|
6169 | 6495 | { |
---|
.. | .. |
---|
6226 | 6552 | // // r.norm.dot(v3) > -0.5) |
---|
6227 | 6553 | // // continue; |
---|
6228 | 6554 | |
---|
6229 | | - drawFace(p, q, r, display, face); |
---|
| 6555 | + display.DrawFace(this, p, q, r, face); |
---|
6230 | 6556 | } |
---|
6231 | | - gl.glEnd(); |
---|
| 6557 | + display.EndTriangles(); |
---|
6232 | 6558 | } |
---|
6233 | 6559 | else |
---|
6234 | 6560 | { |
---|
.. | .. |
---|
6257 | 6583 | //System.out.println("SORT"); |
---|
6258 | 6584 | |
---|
6259 | 6585 | java.util.Arrays.sort(facescompare); |
---|
6260 | | - |
---|
6261 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6586 | + |
---|
| 6587 | + display.StartTriangles(); |
---|
6262 | 6588 | for (int i = 0; i < facecount; i++) |
---|
6263 | 6589 | { |
---|
6264 | 6590 | Face face = bRep.GetFace(facescompare[i].index); |
---|
.. | .. |
---|
6270 | 6596 | Vertex q = bRep.GetVertex(face.q); |
---|
6271 | 6597 | Vertex r = bRep.GetVertex(face.r); |
---|
6272 | 6598 | |
---|
6273 | | - drawFace(p, q, r, display, face); |
---|
| 6599 | + display.DrawFace(this, p, q, r, face); |
---|
6274 | 6600 | } |
---|
6275 | | - gl.glEnd(); |
---|
| 6601 | + display.EndTriangles(); |
---|
6276 | 6602 | } |
---|
6277 | 6603 | |
---|
6278 | 6604 | if (false) // live && support != null && support.bRep != null) // debug weights |
---|
6279 | 6605 | { |
---|
| 6606 | + /* |
---|
6280 | 6607 | gl.glDisable(gl.GL_LIGHTING); |
---|
6281 | 6608 | float[] colorV = new float[3]; |
---|
6282 | 6609 | |
---|
.. | .. |
---|
6355 | 6682 | // gl.glEnd(); |
---|
6356 | 6683 | } |
---|
6357 | 6684 | } |
---|
| 6685 | + */ |
---|
6358 | 6686 | } |
---|
6359 | 6687 | } |
---|
6360 | 6688 | |
---|
.. | .. |
---|
6399 | 6727 | center.add(r); |
---|
6400 | 6728 | center.mul(1.0/3); |
---|
6401 | 6729 | |
---|
6402 | | - center.sub(CameraPane.theRenderer.eyeCamera.location); |
---|
| 6730 | + center.sub(Globals.theRenderer.EyeCamera().location); |
---|
6403 | 6731 | |
---|
6404 | 6732 | distance = center.dot(center); |
---|
6405 | 6733 | } |
---|
.. | .. |
---|
6410 | 6738 | |
---|
6411 | 6739 | transient FaceCompare[] facescompare = null; |
---|
6412 | 6740 | |
---|
6413 | | - void SetColor(CameraPane display, Vertex p0) |
---|
6414 | | - { |
---|
6415 | | - if (display.RENDERPROGRAM == 0) |
---|
6416 | | - { |
---|
6417 | | - float r = 0; |
---|
6418 | | - if (bRep != null) |
---|
6419 | | - { |
---|
6420 | | - if (bRep.stripified) |
---|
6421 | | - { |
---|
6422 | | - r = 1; |
---|
6423 | | - } |
---|
6424 | | - } |
---|
6425 | | - float g = 0; |
---|
6426 | | - if (bRep != null) |
---|
6427 | | - { |
---|
6428 | | - if (bRep.trimmed) |
---|
6429 | | - { |
---|
6430 | | - g = 1; |
---|
6431 | | - } |
---|
6432 | | - } |
---|
6433 | | - float b = 0; |
---|
6434 | | - if (support != null && link2master) |
---|
6435 | | - { |
---|
6436 | | - b = 1; |
---|
6437 | | - } |
---|
6438 | | - display.GetGL().glColor3f(r*p0.AO, g*p0.AO, b*p0.AO); |
---|
6439 | | - return; |
---|
6440 | | - } |
---|
6441 | | - |
---|
6442 | | - if (display.drawMode != CameraPane.SHADOW) |
---|
6443 | | - return; |
---|
6444 | | - |
---|
6445 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
6446 | | -// if (true) return; |
---|
6447 | | -// float ao = p.AO; |
---|
6448 | | -// |
---|
6449 | | -// // if (ao == 0 && !bRep.AOdone) // transient problem! |
---|
6450 | | -// // ao = 1; |
---|
6451 | | -// |
---|
6452 | | -// gl.glColor4f(ao, ao, ao, 1); |
---|
6453 | | - |
---|
6454 | | -// CameraPane.selectedpoint. |
---|
6455 | | -// getAverage(cStatic.point1, true); |
---|
6456 | | - if (CameraPane.pointflow == null) // !random) // live) |
---|
6457 | | - { |
---|
6458 | | - return; |
---|
6459 | | - } |
---|
6460 | | - |
---|
6461 | | - cStatic.point1.set(0,0,0); |
---|
6462 | | - LA.xformPos(cStatic.point1, CameraPane.selectedpoint.toParent, cStatic.point1); |
---|
6463 | | - |
---|
6464 | | - cStatic.point1.sub(p0); |
---|
6465 | | - |
---|
6466 | | - |
---|
6467 | | -// if (marked && (p0.vertexlinks == null || support == null || support.bRep == null)) // no position delta? |
---|
6468 | | -// { |
---|
6469 | | -// return; |
---|
6470 | | -// } |
---|
6471 | | - |
---|
6472 | | - //if (true) |
---|
6473 | | - if (cStatic.point1.dot(cStatic.point1) > 0.000001) |
---|
6474 | | - { |
---|
6475 | | - return; |
---|
6476 | | - } |
---|
6477 | | - |
---|
6478 | | - float[] colorV = new float[3]; |
---|
6479 | | - |
---|
6480 | | - if (false) // marked) |
---|
6481 | | - { |
---|
6482 | | - // debug rigging weights |
---|
6483 | | - for (int object = 0; object < p0.vertexlinks.length; object++) |
---|
6484 | | - { |
---|
6485 | | - float weight = p0.weights[object] / p0.totalweight; |
---|
6486 | | - |
---|
6487 | | - // if (weight < 0.1) |
---|
6488 | | - // { |
---|
6489 | | - // assert(weight == 0); |
---|
6490 | | - // continue; |
---|
6491 | | - // } |
---|
6492 | | - |
---|
6493 | | - if (p0.vertexlinks[object] == -1) |
---|
6494 | | - continue; |
---|
6495 | | - |
---|
6496 | | - Vertex q = support.bRep.GetVertex(p0.vertexlinks[object]); |
---|
6497 | | - |
---|
6498 | | - int color = //1 << object; // |
---|
6499 | | - //p.vertexlinks.length; |
---|
6500 | | - support.bRep.supports[p0.closestsupport].links[object]; |
---|
6501 | | - colorV[2] += (color & 1) * weight; |
---|
6502 | | - colorV[1] += ((color & 2) >> 1) * weight; |
---|
6503 | | - colorV[0] += ((color & 4) >> 2) * weight; |
---|
6504 | | - } |
---|
6505 | | - } |
---|
6506 | | - else |
---|
6507 | | - { |
---|
6508 | | - if (drawingstarted) |
---|
6509 | | - { |
---|
6510 | | - // find next point |
---|
6511 | | - if (bRep.GetVertex(0).faceindices == null) |
---|
6512 | | - { |
---|
6513 | | - bRep.InitFaceIndices(); |
---|
6514 | | - } |
---|
6515 | | - |
---|
6516 | | - double ymin = p0.y; |
---|
6517 | | - |
---|
6518 | | - Vertex newp = p0; |
---|
6519 | | - |
---|
6520 | | - for (int fii = 0; fii < p0.faceindices.length; fii++) |
---|
6521 | | - { |
---|
6522 | | - int fi = p0.faceindices[fii]; |
---|
6523 | | - |
---|
6524 | | - if (fi == -1) |
---|
6525 | | - break; |
---|
6526 | | - |
---|
6527 | | - Face f = bRep.GetFace(fi); |
---|
6528 | | - |
---|
6529 | | - Vertex p = bRep.GetVertex(f.p); |
---|
6530 | | - Vertex q = bRep.GetVertex(f.q); |
---|
6531 | | - Vertex r = bRep.GetVertex(f.r); |
---|
6532 | | - |
---|
6533 | | - int swap = (int)(Math.random()*3); |
---|
6534 | | - |
---|
6535 | | -// for (int s=swap; --s>=0;) |
---|
6536 | | -// { |
---|
6537 | | -// Vertex t = p; |
---|
6538 | | -// p = q; |
---|
6539 | | -// q = r; |
---|
6540 | | -// r = t; |
---|
6541 | | -// } |
---|
6542 | | - if (ymin > p.y) |
---|
6543 | | - { |
---|
6544 | | - ymin = p.y; |
---|
6545 | | - newp = p; |
---|
6546 | | -// break; |
---|
6547 | | - } |
---|
6548 | | - if (ymin > q.y) |
---|
6549 | | - { |
---|
6550 | | - ymin = q.y; |
---|
6551 | | - newp = q; |
---|
6552 | | -// break; |
---|
6553 | | - } |
---|
6554 | | - if (ymin > r.y) |
---|
6555 | | - { |
---|
6556 | | - ymin = r.y; |
---|
6557 | | - newp = r; |
---|
6558 | | -// break; |
---|
6559 | | - } |
---|
6560 | | - } |
---|
6561 | | - |
---|
6562 | | - CameraPane.selectedpoint.toParent[3][0] = newp.x; |
---|
6563 | | - CameraPane.selectedpoint.toParent[3][1] = newp.y; |
---|
6564 | | - CameraPane.selectedpoint.toParent[3][2] = newp.z; |
---|
6565 | | - |
---|
6566 | | - drawingstarted = false; |
---|
6567 | | - |
---|
6568 | | - // return; |
---|
6569 | | - } |
---|
6570 | | - |
---|
6571 | | - if (false) // CameraPane.DRAW |
---|
6572 | | - { |
---|
6573 | | - p0.AO = colorV[0] = 2; |
---|
6574 | | - colorV[1] = 2; |
---|
6575 | | - colorV[2] = 2; |
---|
6576 | | - } |
---|
6577 | | - |
---|
6578 | | - CameraPane.pointflow.add(p0); |
---|
6579 | | - CameraPane.pointflow.Touch(); |
---|
6580 | | - } |
---|
6581 | | - |
---|
6582 | | -// gl.glColor3f(colorV[0], colorV[1], colorV[2]); |
---|
6583 | | -// gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, colorV, 0); |
---|
6584 | | -// gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
6585 | | - } |
---|
6586 | | - |
---|
6587 | 6741 | void Print(Vertex v) |
---|
6588 | 6742 | { |
---|
6589 | 6743 | //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")"); |
---|
6590 | 6744 | } |
---|
6591 | 6745 | |
---|
6592 | | - void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode) |
---|
6593 | | - { |
---|
6594 | | - if (!selectmode) |
---|
6595 | | - { |
---|
6596 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
6597 | | - gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
6598 | | - |
---|
6599 | | - if (flipV) |
---|
6600 | | - gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
6601 | | - else |
---|
6602 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6603 | | - } |
---|
6604 | | - |
---|
6605 | | - gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
6606 | | - } |
---|
6607 | | - |
---|
6608 | | - void drawFace(Vertex pv, Vertex qv, Vertex rv, |
---|
6609 | | - CameraPane display, Face face) |
---|
6610 | | - { |
---|
6611 | | - if (pv.y == -10000 || |
---|
6612 | | - qv.y == -10000 || |
---|
6613 | | - rv.y == -10000) |
---|
6614 | | - return; |
---|
6615 | | - |
---|
6616 | | -// float b = f.nbiterations & 1; |
---|
6617 | | -// float g = (f.nbiterations>>1) & 1; |
---|
6618 | | -// float r = (f.nbiterations>>2) & 1; |
---|
6619 | | -// |
---|
6620 | | -// //if (f.weight == 10000) |
---|
6621 | | -// //{ |
---|
6622 | | -// // r = 1; g = b = 0; |
---|
6623 | | -// //} |
---|
6624 | | -// //else |
---|
6625 | | -// //{ |
---|
6626 | | -// // assert(f.weight < 10000); |
---|
6627 | | -// r = g = b = (float)bRep.FaceWeight(f)*100; |
---|
6628 | | -// if (r<0) |
---|
6629 | | -// assert(r>=0); |
---|
6630 | | -// //} |
---|
6631 | | - |
---|
6632 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
6633 | | - |
---|
6634 | | - boolean selectmode = display.drawMode == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
6635 | | - |
---|
6636 | | - //System.out.println("p = " + pv + "; q = " + qv + "; r = " + rv); |
---|
6637 | | - if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
6638 | | - { |
---|
6639 | | - //gl.glBegin(gl.GL_TRIANGLES); |
---|
6640 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
6641 | | - if (!hasnorm) |
---|
6642 | | - { |
---|
6643 | | - // System.out.println("FUCK!!"); |
---|
6644 | | - LA.vecSub(pv/*.pos*/, qv/*.pos*/, v0); |
---|
6645 | | - LA.vecSub(pv/*.pos*/, rv/*.pos*/, v1); |
---|
6646 | | - LA.vecCross(v0, v1, v2); |
---|
6647 | | - LA.vecNormalize(v2); |
---|
6648 | | - gl.glNormal3f((float) v2.x, (float) v2.y, (float) v2.z); |
---|
6649 | | - } |
---|
6650 | | - |
---|
6651 | | - if (hasnorm) |
---|
6652 | | - { |
---|
6653 | | -// if (!pv.norm.normalized()) |
---|
6654 | | -// assert(pv.norm.normalized()); |
---|
6655 | | - |
---|
6656 | | - //System.out.println("normalp = " + pv.norm.x + ", " + pv.norm.y + ", " + pv.norm.z); |
---|
6657 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
6658 | | - } |
---|
6659 | | - gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
6660 | | - SetColor(display, pv); |
---|
6661 | | - //gl.glColor4f(r, g, b, 1); |
---|
6662 | | - //gl.glColor4f(pv.boundary, pv.boundary, pv.boundary, 1); |
---|
6663 | | - if (flipV) |
---|
6664 | | - gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
6665 | | - else |
---|
6666 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6667 | | - //System.out.println("vertexp = " + pv.x + ", " + pv.y + ", " + pv.z); |
---|
6668 | | - gl.glVertex3f((float) pv./*pos.*/x, (float) pv./*pos.*/y, (float) pv./*pos.*/z); |
---|
6669 | | -// Print(pv); |
---|
6670 | | - if (hasnorm) |
---|
6671 | | - { |
---|
6672 | | -// assert(qv.norm.normalized()); |
---|
6673 | | - //System.out.println("normalq = " + qv.norm.x + ", " + qv.norm.y + ", " + qv.norm.z); |
---|
6674 | | - gl.glNormal3f((float) qv.norm.x, (float) qv.norm.y, (float) qv.norm.z); |
---|
6675 | | - } |
---|
6676 | | - //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
6677 | | - // boolean locked = false; |
---|
6678 | | - // float eps = 0.1f; |
---|
6679 | | - // boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
6680 | | - |
---|
6681 | | - // int dot = 0; //*/ (int)f.dot; |
---|
6682 | | - |
---|
6683 | | - // if ((dot&1) == 0) |
---|
6684 | | - // dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
6685 | | - |
---|
6686 | | - // if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
6687 | | - if (flipV) |
---|
6688 | | - gl.glTexCoord2f((float) qv.s, 1-(float) qv.t); |
---|
6689 | | - else |
---|
6690 | | - gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
6691 | | - // else |
---|
6692 | | - // { |
---|
6693 | | - // locked = true; |
---|
6694 | | - // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6695 | | - // } |
---|
6696 | | - gl.glColor4f(qv.AO, qv.AO, qv.AO, 1); |
---|
6697 | | - SetColor(display, qv); |
---|
6698 | | - //gl.glColor4f(r, g, b, 1); |
---|
6699 | | - //gl.glColor4f(qv.boundary, qv.boundary, qv.boundary, 1); |
---|
6700 | | - //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
6701 | | - gl.glVertex3f((float) qv./*pos.*/x, (float) qv./*pos.*/y, (float) qv./*pos.*/z); |
---|
6702 | | -// Print(qv); |
---|
6703 | | - if (hasnorm) |
---|
6704 | | - { |
---|
6705 | | -// assert(rv.norm.normalized()); |
---|
6706 | | - //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
6707 | | - gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
6708 | | - } |
---|
6709 | | - |
---|
6710 | | - // if ((dot&4) == 0) |
---|
6711 | | - // dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
6712 | | - |
---|
6713 | | - // if (wrap || !locked && (dot&8) != 0) |
---|
6714 | | - if (flipV) |
---|
6715 | | - gl.glTexCoord2f((float) rv.s, 1-(float) rv.t); |
---|
6716 | | - else |
---|
6717 | | - gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
6718 | | - // else |
---|
6719 | | - // gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6720 | | - |
---|
6721 | | - // f.dot = dot; |
---|
6722 | | - |
---|
6723 | | - gl.glColor4f(rv.AO, rv.AO, rv.AO, 1); |
---|
6724 | | - SetColor(display, rv); |
---|
6725 | | - //gl.glColor4f(r, g, b, 1); |
---|
6726 | | - //gl.glColor4f(rv.boundary, rv.boundary, rv.boundary, 1); |
---|
6727 | | - //System.out.println("vertexr = " + rv.x + ", " + rv.y + ", " + rv.z); |
---|
6728 | | - gl.glVertex3f((float) rv./*pos.*/x, (float) rv./*pos.*/y, (float) rv./*pos.*/z); |
---|
6729 | | -// Print(rv); |
---|
6730 | | - //gl.glEnd(); |
---|
6731 | | - } |
---|
6732 | | - else |
---|
6733 | | - { |
---|
6734 | | - gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
6735 | | - gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
6736 | | - gl.glVertex3f((float) rv.x, (float) rv.y, (float) rv.z); |
---|
6737 | | - |
---|
6738 | | - } |
---|
6739 | | - |
---|
6740 | | - if (false) // (attributes & WIREFRAME) != 0) |
---|
6741 | | - { |
---|
6742 | | - gl.glDisable(gl.GL_LIGHTING); |
---|
6743 | | - |
---|
6744 | | - gl.glBegin(gl.GL_LINE_LOOP); |
---|
6745 | | - gl.glVertex3d(pv./*pos.*/x, pv./*pos.*/y, pv./*pos.*/z); |
---|
6746 | | - gl.glVertex3d(qv./*pos.*/x, qv./*pos.*/y, qv./*pos.*/z); |
---|
6747 | | - gl.glVertex3d(rv./*pos.*/x, rv./*pos.*/y, rv./*pos.*/z); |
---|
6748 | | - gl.glEnd(); |
---|
6749 | | - |
---|
6750 | | - gl.glEnable(gl.GL_LIGHTING); |
---|
6751 | | - } |
---|
6752 | | - } |
---|
6753 | | - |
---|
6754 | 6746 | void drawSelf(ClickInfo info, int level, boolean select) |
---|
6755 | 6747 | { |
---|
6756 | 6748 | if (bRep == null) |
---|
.. | .. |
---|
7322 | 7314 | int spotw = spot.x + spot.width; |
---|
7323 | 7315 | int spoth = spot.y + spot.height; |
---|
7324 | 7316 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7325 | | - if (CameraPane.Xmin > spot.x) |
---|
7326 | | - { |
---|
7327 | | - CameraPane.Xmin = spot.x; |
---|
7328 | | - } |
---|
7329 | | - if (CameraPane.Xmax < spotw) |
---|
7330 | | - { |
---|
7331 | | - CameraPane.Xmax = spotw; |
---|
7332 | | - } |
---|
7333 | | - if (CameraPane.Ymin > spot.y) |
---|
7334 | | - { |
---|
7335 | | - CameraPane.Ymin = spot.y; |
---|
7336 | | - } |
---|
7337 | | - if (CameraPane.Ymax < spoth) |
---|
7338 | | - { |
---|
7339 | | - CameraPane.Ymax = spoth; |
---|
7340 | | - } |
---|
| 7317 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7318 | +// { |
---|
| 7319 | +// CameraPane.Xmin = spot.x; |
---|
| 7320 | +// } |
---|
| 7321 | +// if (CameraPane.Xmax < spotw) |
---|
| 7322 | +// { |
---|
| 7323 | +// CameraPane.Xmax = spotw; |
---|
| 7324 | +// } |
---|
| 7325 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7326 | +// { |
---|
| 7327 | +// CameraPane.Ymin = spot.y; |
---|
| 7328 | +// } |
---|
| 7329 | +// if (CameraPane.Ymax < spoth) |
---|
| 7330 | +// { |
---|
| 7331 | +// CameraPane.Ymax = spoth; |
---|
| 7332 | +// } |
---|
7341 | 7333 | spot.translate(32, 32); |
---|
7342 | 7334 | spotw = spot.x + spot.width; |
---|
7343 | 7335 | spoth = spot.y + spot.height; |
---|
7344 | | - info.g.setColor(Color.blue); |
---|
| 7336 | + info.g.setColor(Color.cyan); |
---|
7345 | 7337 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7346 | | - if (CameraPane.Xmin > spot.x) |
---|
7347 | | - { |
---|
7348 | | - CameraPane.Xmin = spot.x; |
---|
7349 | | - } |
---|
7350 | | - if (CameraPane.Xmax < spotw) |
---|
7351 | | - { |
---|
7352 | | - CameraPane.Xmax = spotw; |
---|
7353 | | - } |
---|
7354 | | - if (CameraPane.Ymin > spot.y) |
---|
7355 | | - { |
---|
7356 | | - CameraPane.Ymin = spot.y; |
---|
7357 | | - } |
---|
7358 | | - if (CameraPane.Ymax < spoth) |
---|
7359 | | - { |
---|
7360 | | - CameraPane.Ymax = spoth; |
---|
7361 | | - } |
---|
7362 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
7363 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7338 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7339 | +// { |
---|
| 7340 | +// CameraPane.Xmin = spot.x; |
---|
| 7341 | +// } |
---|
| 7342 | +// if (CameraPane.Xmax < spotw) |
---|
| 7343 | +// { |
---|
| 7344 | +// CameraPane.Xmax = spotw; |
---|
| 7345 | +// } |
---|
| 7346 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7347 | +// { |
---|
| 7348 | +// CameraPane.Ymin = spot.y; |
---|
| 7349 | +// } |
---|
| 7350 | +// if (CameraPane.Ymax < spoth) |
---|
| 7351 | +// { |
---|
| 7352 | +// CameraPane.Ymax = spoth; |
---|
| 7353 | +// } |
---|
| 7354 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7355 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
7364 | 7356 | spot.translate(0, -32); |
---|
7365 | | - info.g.setColor(Color.green); |
---|
| 7357 | + info.g.setColor(Color.yellow); |
---|
7366 | 7358 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7367 | | - if (CameraPane.Xmin > spot.x) |
---|
7368 | | - { |
---|
7369 | | - CameraPane.Xmin = spot.x; |
---|
7370 | | - } |
---|
7371 | | - if (CameraPane.Xmax < spotw) |
---|
7372 | | - { |
---|
7373 | | - CameraPane.Xmax = spotw; |
---|
7374 | | - } |
---|
7375 | | - if (CameraPane.Ymin > spot.y) |
---|
7376 | | - { |
---|
7377 | | - CameraPane.Ymin = spot.y; |
---|
7378 | | - } |
---|
7379 | | - if (CameraPane.Ymax < spoth) |
---|
7380 | | - { |
---|
7381 | | - CameraPane.Ymax = spoth; |
---|
7382 | | - } |
---|
7383 | | - info.g.drawArc(boundary.x, boundary.y, |
---|
7384 | | - boundary.width, boundary.height, 0, 360); |
---|
| 7359 | + info.g.setColor(Color.green); |
---|
| 7360 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7361 | +// { |
---|
| 7362 | +// CameraPane.Xmin = spot.x; |
---|
| 7363 | +// } |
---|
| 7364 | +// if (CameraPane.Xmax < spotw) |
---|
| 7365 | +// { |
---|
| 7366 | +// CameraPane.Xmax = spotw; |
---|
| 7367 | +// } |
---|
| 7368 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7369 | +// { |
---|
| 7370 | +// CameraPane.Ymin = spot.y; |
---|
| 7371 | +// } |
---|
| 7372 | +// if (CameraPane.Ymax < spoth) |
---|
| 7373 | +// { |
---|
| 7374 | +// CameraPane.Ymax = spoth; |
---|
| 7375 | +// } |
---|
| 7376 | + info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY, |
---|
| 7377 | + (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360); |
---|
7385 | 7378 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
7386 | | - if (CameraPane.Xmin > boundary.x) |
---|
7387 | | - { |
---|
7388 | | - CameraPane.Xmin = boundary.x; |
---|
7389 | | - } |
---|
7390 | | - if (CameraPane.Xmax < boundary.x + boundary.width) |
---|
7391 | | - { |
---|
7392 | | - CameraPane.Xmax = boundary.x + boundary.width; |
---|
7393 | | - } |
---|
7394 | | - if (CameraPane.Ymin > boundary.y) |
---|
7395 | | - { |
---|
7396 | | - CameraPane.Ymin = boundary.y; |
---|
7397 | | - } |
---|
7398 | | - if (CameraPane.Ymax < boundary.y + boundary.height) |
---|
7399 | | - { |
---|
7400 | | - CameraPane.Ymax = boundary.y + boundary.height; |
---|
7401 | | - } |
---|
| 7379 | +// if (CameraPane.Xmin > boundary.x) |
---|
| 7380 | +// { |
---|
| 7381 | +// CameraPane.Xmin = boundary.x; |
---|
| 7382 | +// } |
---|
| 7383 | +// if (CameraPane.Xmax < boundary.x + boundary.width) |
---|
| 7384 | +// { |
---|
| 7385 | +// CameraPane.Xmax = boundary.x + boundary.width; |
---|
| 7386 | +// } |
---|
| 7387 | +// if (CameraPane.Ymin > boundary.y) |
---|
| 7388 | +// { |
---|
| 7389 | +// CameraPane.Ymin = boundary.y; |
---|
| 7390 | +// } |
---|
| 7391 | +// if (CameraPane.Ymax < boundary.y + boundary.height) |
---|
| 7392 | +// { |
---|
| 7393 | +// CameraPane.Ymax = boundary.y + boundary.height; |
---|
| 7394 | +// } |
---|
7402 | 7395 | return; |
---|
7403 | 7396 | } |
---|
7404 | 7397 | } |
---|
.. | .. |
---|
7415 | 7408 | startX = info.x; |
---|
7416 | 7409 | startY = info.y; |
---|
7417 | 7410 | |
---|
7418 | | - hitSomething = 0; |
---|
| 7411 | + hitSomething = -1; |
---|
7419 | 7412 | cVector origin = new cVector(); |
---|
7420 | 7413 | //LA.xformPos(origin, toParent, origin); |
---|
7421 | 7414 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7448 | 7441 | } |
---|
7449 | 7442 | |
---|
7450 | 7443 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7451 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7444 | + modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7452 | 7445 | //System.out.println("modified = " + modified); |
---|
7453 | 7446 | //new Exception().printStackTrace(); |
---|
7454 | 7447 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7476 | 7469 | return true; |
---|
7477 | 7470 | } |
---|
7478 | 7471 | |
---|
7479 | | - void doEditDrag0(ClickInfo info) |
---|
| 7472 | + void doEditDrag0(ClickInfo info, boolean opposite) |
---|
7480 | 7473 | { |
---|
7481 | 7474 | if (hitSomething == 0) |
---|
7482 | 7475 | { |
---|
.. | .. |
---|
7491 | 7484 | //System.out.println("hitSomething = " + hitSomething); |
---|
7492 | 7485 | |
---|
7493 | 7486 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7487 | + |
---|
7494 | 7488 | cVector xlate = new cVector(); |
---|
7495 | 7489 | //cVector xlate2 = new cVector(); |
---|
7496 | 7490 | switch (hitSomething) |
---|
.. | .. |
---|
7501 | 7495 | |
---|
7502 | 7496 | case hitCenter: // Translate |
---|
7503 | 7497 | |
---|
7504 | | - scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance(); |
---|
| 7498 | + scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7505 | 7499 | |
---|
7506 | | - if (modified) |
---|
| 7500 | + if (modified || opposite) |
---|
7507 | 7501 | { |
---|
7508 | 7502 | //assert(false); |
---|
7509 | 7503 | /* |
---|
.. | .. |
---|
7549 | 7543 | } |
---|
7550 | 7544 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7551 | 7545 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7552 | | - LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up); |
---|
| 7546 | + LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7553 | 7547 | LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
7554 | 7548 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7555 | | - LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away); |
---|
| 7549 | + LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7556 | 7550 | //LA.vecCross(up, cVector.Z, right2); |
---|
7557 | 7551 | |
---|
7558 | 7552 | cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
.. | .. |
---|
7597 | 7591 | |
---|
7598 | 7592 | if (modified) |
---|
7599 | 7593 | { |
---|
| 7594 | + // Rotate 90 degrees |
---|
7600 | 7595 | angle /= (Math.PI / 4); |
---|
7601 | 7596 | angle = Math.floor(angle + 0.5); |
---|
7602 | 7597 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7610 | 7605 | } |
---|
7611 | 7606 | /**/ |
---|
7612 | 7607 | |
---|
7613 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7608 | + switch (info.pane.RenderCamera().viewCode) |
---|
7614 | 7609 | { |
---|
7615 | 7610 | case 1: // '\001' |
---|
7616 | 7611 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7638 | 7633 | |
---|
7639 | 7634 | case hitScale: // scale |
---|
7640 | 7635 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7636 | + double sign = 1; |
---|
| 7637 | + if (hScale < 0) |
---|
| 7638 | + { |
---|
| 7639 | + sign = -1; |
---|
| 7640 | + } |
---|
| 7641 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7641 | 7642 | if (hScale < 0.01) |
---|
7642 | 7643 | { |
---|
7643 | | - hScale = 0.01; |
---|
| 7644 | + //hScale = 0.01; |
---|
7644 | 7645 | } |
---|
7645 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7646 | | - if (hScale < 0.01) |
---|
7647 | | - { |
---|
7648 | | - hScale = 0.01; |
---|
7649 | | - } |
---|
| 7646 | + |
---|
7650 | 7647 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7651 | | - if (vScale < 0.01) |
---|
| 7648 | + sign = 1; |
---|
| 7649 | + if (vScale < 0) |
---|
7652 | 7650 | { |
---|
7653 | | - vScale = 0.01; |
---|
| 7651 | + sign = -1; |
---|
7654 | 7652 | } |
---|
7655 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7653 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7656 | 7654 | if (vScale < 0.01) |
---|
7657 | 7655 | { |
---|
7658 | | - vScale = 0.01; |
---|
| 7656 | + //vScale = 0.01; |
---|
7659 | 7657 | } |
---|
7660 | 7658 | LA.matCopy(startMat, toParent); |
---|
7661 | 7659 | /**/ |
---|
.. | .. |
---|
7666 | 7664 | } |
---|
7667 | 7665 | /**/ |
---|
7668 | 7666 | |
---|
7669 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7667 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7668 | + |
---|
| 7669 | + if (totalScale < 0.01) |
---|
| 7670 | + { |
---|
| 7671 | + totalScale = 0.01; |
---|
| 7672 | + } |
---|
| 7673 | + |
---|
| 7674 | + switch (info.pane.RenderCamera().viewCode) |
---|
7670 | 7675 | { |
---|
7671 | 7676 | case 3: // '\001' |
---|
7672 | | - if (modified) |
---|
| 7677 | + if (modified || opposite) |
---|
7673 | 7678 | { |
---|
7674 | 7679 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7675 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7680 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7676 | 7681 | } // vScale, 1); |
---|
7677 | 7682 | else |
---|
7678 | 7683 | { |
---|
7679 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7684 | + // EXCEPTION! |
---|
| 7685 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7680 | 7686 | } // vScale, 1); |
---|
7681 | 7687 | break; |
---|
7682 | 7688 | |
---|
7683 | 7689 | case 2: // '\002' |
---|
7684 | | - if (modified) |
---|
| 7690 | + if (modified || opposite) |
---|
7685 | 7691 | { |
---|
7686 | 7692 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7687 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7693 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7688 | 7694 | } else |
---|
7689 | 7695 | { |
---|
7690 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7696 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7691 | 7697 | } |
---|
7692 | 7698 | break; |
---|
7693 | 7699 | |
---|
7694 | 7700 | case 1: // '\003' |
---|
7695 | | - if (modified) |
---|
| 7701 | + if (modified || opposite) |
---|
7696 | 7702 | { |
---|
7697 | 7703 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7698 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7704 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7699 | 7705 | } else |
---|
7700 | 7706 | { |
---|
7701 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7707 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7702 | 7708 | } |
---|
7703 | 7709 | break; |
---|
7704 | 7710 | } |
---|
.. | .. |
---|
7719 | 7725 | if (parent == null) |
---|
7720 | 7726 | { |
---|
7721 | 7727 | System.out.println("NULL PARENT"); |
---|
7722 | | - new Exception().printStackTrace(); |
---|
| 7728 | + //new Exception().printStackTrace(); |
---|
7723 | 7729 | } else |
---|
7724 | 7730 | { |
---|
7725 | 7731 | if (parent instanceof BezierPatch) |
---|
.. | .. |
---|
7735 | 7741 | info.pane.repaint(); |
---|
7736 | 7742 | } |
---|
7737 | 7743 | |
---|
| 7744 | + boolean overflow = false; |
---|
| 7745 | + |
---|
7738 | 7746 | void TransformToWorld(cVector out) // , cVector out) |
---|
7739 | 7747 | { |
---|
| 7748 | + if (overflow) |
---|
| 7749 | + return; |
---|
| 7750 | + |
---|
| 7751 | + overflow = true; |
---|
| 7752 | + |
---|
7740 | 7753 | // june 2013 ??? assert (in == out); |
---|
7741 | 7754 | cVector in = out; |
---|
7742 | 7755 | if (toParent != null && !(this instanceof Texture || this instanceof TextureNode)) |
---|
.. | .. |
---|
7753 | 7766 | { |
---|
7754 | 7767 | (parent!=null?parent:fileparent).TransformToWorld(out); //, out); |
---|
7755 | 7768 | } |
---|
| 7769 | + |
---|
| 7770 | + overflow = false; |
---|
7756 | 7771 | } |
---|
7757 | 7772 | |
---|
7758 | 7773 | void TransformToLocal(cVector out) //, cVector out) |
---|
.. | .. |
---|
7822 | 7837 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7823 | 7838 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7824 | 7839 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7840 | + |
---|
| 7841 | + String objname; |
---|
| 7842 | + |
---|
7825 | 7843 | if (false) //parent != null) |
---|
7826 | 7844 | { |
---|
7827 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7845 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7828 | 7846 | } else |
---|
7829 | 7847 | { |
---|
7830 | | - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); |
---|
| 7848 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7831 | 7849 | } // + super.toString(); |
---|
7832 | 7850 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
| 7851 | + |
---|
| 7852 | + if (!Globals.ADVANCED) |
---|
| 7853 | + return objname; |
---|
| 7854 | + |
---|
| 7855 | + return objname + " " + System.identityHashCode(this); |
---|
7833 | 7856 | } |
---|
7834 | 7857 | |
---|
7835 | 7858 | public int hashCode() |
---|
.. | .. |
---|
7885 | 7908 | objectUI.closeUI(); |
---|
7886 | 7909 | if (editWindow != null) |
---|
7887 | 7910 | { |
---|
| 7911 | + editWindow.ctrlPanel.FlushUI(); |
---|
7888 | 7912 | editWindow.refreshContents(); |
---|
7889 | 7913 | } // ? new |
---|
7890 | 7914 | objectUI = null; |
---|
.. | .. |
---|
7893 | 7917 | { |
---|
7894 | 7918 | editWindow = null; |
---|
7895 | 7919 | } // ? |
---|
| 7920 | + } |
---|
| 7921 | + else |
---|
| 7922 | + { |
---|
| 7923 | + //editWindow.closeUI(); |
---|
7896 | 7924 | } |
---|
7897 | 7925 | } |
---|
7898 | 7926 | |
---|
.. | .. |
---|
7905 | 7933 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7906 | 7934 | |
---|
7907 | 7935 | Object3D /*Composite*/ parent; |
---|
7908 | | - Object3D /*Composite*/ fileparent; |
---|
| 7936 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7909 | 7937 | |
---|
7910 | 7938 | double[][] toParent; // dynamic matrix |
---|
7911 | 7939 | double[][] fromParent; |
---|
.. | .. |
---|
7995 | 8023 | max = new cVector(); |
---|
7996 | 8024 | } |
---|
7997 | 8025 | |
---|
7998 | | - Object3D sourcenode = GetFileRoot(); |
---|
7999 | | - |
---|
8000 | | - if (!sourcenode.name.contains("rclab")) |
---|
| 8026 | + if (false) // Can crawl!! |
---|
8001 | 8027 | { |
---|
8002 | | - getBounds(min, max, true); |
---|
| 8028 | + Object3D sourcenode = GetFileRoot(); |
---|
8003 | 8029 | |
---|
8004 | | - if (min.y != Double.POSITIVE_INFINITY && min.y > 2) |
---|
| 8030 | + if (sourcenode != null && !sourcenode.name.contains("rclab")) |
---|
8005 | 8031 | { |
---|
8006 | | -// sourcenode.getBounds(min, max, true); |
---|
8007 | | - sourcenode.getBounds(v0, v1, true); |
---|
8008 | | -// sourcenode.toParent = sourcenode.toParent; |
---|
8009 | | -// get(0).toParent = get(0).toParent; |
---|
8010 | | -// sourcenode.GlobalTransform(); |
---|
| 8032 | + getBounds(min, max, true); |
---|
| 8033 | + |
---|
| 8034 | + if (min.y != Double.POSITIVE_INFINITY && min.y > 2) |
---|
| 8035 | + { |
---|
| 8036 | + // sourcenode.getBounds(min, max, true); |
---|
| 8037 | + sourcenode.getBounds(v0, v1, true); |
---|
| 8038 | + // sourcenode.toParent = sourcenode.toParent; |
---|
| 8039 | + // get(0).toParent = get(0).toParent; |
---|
| 8040 | + // sourcenode.GlobalTransform(); |
---|
| 8041 | + } |
---|
8011 | 8042 | } |
---|
8012 | 8043 | } |
---|
8013 | 8044 | |
---|
.. | .. |
---|
8016 | 8047 | if (support != null) |
---|
8017 | 8048 | { |
---|
8018 | 8049 | assert(bRep != null); |
---|
8019 | | - GraphreeD.Assert(support.bRep == bRep.support); |
---|
| 8050 | + if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
| 8051 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
8020 | 8052 | } |
---|
8021 | 8053 | else |
---|
8022 | 8054 | { |
---|
.. | .. |
---|
8047 | 8079 | } |
---|
8048 | 8080 | |
---|
8049 | 8081 | transient ObjEditor editWindow; |
---|
| 8082 | + transient ObjEditor manipWindow; |
---|
| 8083 | + |
---|
| 8084 | + transient boolean pinned; |
---|
| 8085 | + |
---|
8050 | 8086 | transient ObjectUI objectUI; |
---|
8051 | 8087 | public static int povDepth = 0; |
---|
8052 | 8088 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
8065 | 8101 | private static cVector edge2 = new cVector(); |
---|
8066 | 8102 | //private static cVector norm = new cVector(); |
---|
8067 | 8103 | /*transient private*/ int hitSomething; |
---|
8068 | | - private static final int hitCenter = 1; |
---|
8069 | | - private static final int hitScale = 2; |
---|
8070 | | - private static final int hitRotate = 3; |
---|
| 8104 | + static final int hitCenter = 1; |
---|
| 8105 | + static final int hitScale = 2; |
---|
| 8106 | + static final int hitRotate = 3; |
---|
8071 | 8107 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
8072 | 8108 | /*transient*/ private Point centerPt; |
---|
8073 | 8109 | /*transient*/ private int startX; |
---|
.. | .. |
---|
8099 | 8135 | { |
---|
8100 | 8136 | Object3D targ = this; |
---|
8101 | 8137 | |
---|
| 8138 | + targ.NORMALPUSH = obj.NORMALPUSH; |
---|
| 8139 | + |
---|
8102 | 8140 | if (obj.material != null) |
---|
8103 | 8141 | { |
---|
8104 | 8142 | if ((mask&MATERIAL)!=0) // ==(COLOR|MATERIAL)) |
---|