.. | .. |
---|
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; |
---|
| 24 | + |
---|
| 25 | + // Use GetUUID for backward compatibility with null. |
---|
| 26 | + private UUID uuid = UUID.randomUUID(); |
---|
| 27 | + |
---|
| 28 | + // TEMPORARY for mocap undo. No need to be transient. |
---|
| 29 | + mocap.reader.BVHReader.BVHResult savebvh; |
---|
| 30 | + Object3D saveskeleton; |
---|
| 31 | + // |
---|
| 32 | + |
---|
| 33 | + String skyboxname; |
---|
| 34 | + String skyboxext; |
---|
| 35 | + |
---|
| 36 | + Object3D versionlist[]; |
---|
| 37 | + int versionindex = -1; |
---|
| 38 | + |
---|
| 39 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
21 | 40 | |
---|
22 | 41 | ScriptNode scriptnode; |
---|
23 | 42 | |
---|
.. | .. |
---|
99 | 118 | |
---|
100 | 119 | // transient boolean reduced; // for morph reduction |
---|
101 | 120 | |
---|
102 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
| 121 | + transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
| 122 | + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
104 | 123 | |
---|
105 | | -transient Object3D transientsupport; // for cloning |
---|
106 | | -transient boolean transientlink2master; |
---|
| 124 | + transient Object3D transientsupport; // for cloning |
---|
| 125 | + transient boolean transientlink2master; |
---|
107 | 126 | |
---|
108 | | -void SaveSupports() |
---|
109 | | -{ |
---|
110 | | - if (blockloop) |
---|
111 | | - return; |
---|
112 | | - |
---|
113 | | - transientsupport = support; |
---|
114 | | - transientlink2master = link2master; |
---|
115 | | - |
---|
116 | | - support = null; |
---|
117 | | - link2master = false; |
---|
118 | | - |
---|
119 | | - if (bRep != null) |
---|
| 127 | + void SaveSupports() |
---|
120 | 128 | { |
---|
121 | | - bRep.SaveSupports(); |
---|
| 129 | + if (blockloop) |
---|
| 130 | + return; |
---|
| 131 | + |
---|
| 132 | + transientsupport = support; |
---|
| 133 | + transientlink2master = link2master; |
---|
| 134 | + |
---|
| 135 | + support = null; |
---|
| 136 | + link2master = false; |
---|
| 137 | + |
---|
| 138 | + if (bRep != null) |
---|
| 139 | + { |
---|
| 140 | + bRep.SaveSupports(); |
---|
| 141 | + } |
---|
| 142 | + |
---|
| 143 | + for (int i = 0; i < Size(); i++) |
---|
| 144 | + { |
---|
| 145 | + Object3D child = (Object3D) get(i); |
---|
| 146 | + if (child == null) |
---|
| 147 | + continue; |
---|
| 148 | + blockloop = true; |
---|
| 149 | + child.SaveSupports(); |
---|
| 150 | + blockloop = false; |
---|
| 151 | + } |
---|
122 | 152 | } |
---|
123 | | - |
---|
124 | | - for (int i = 0; i < Size(); i++) |
---|
| 153 | + |
---|
| 154 | + void RestoreSupports() |
---|
125 | 155 | { |
---|
126 | | - Object3D child = (Object3D) get(i); |
---|
127 | | - if (child == null) |
---|
128 | | - continue; |
---|
| 156 | + if (blockloop) |
---|
| 157 | + return; |
---|
| 158 | + |
---|
| 159 | + support = transientsupport; |
---|
| 160 | + link2master = transientlink2master; |
---|
| 161 | + transientsupport = null; |
---|
| 162 | + transientlink2master = false; |
---|
| 163 | + |
---|
| 164 | + if (bRep != null) |
---|
| 165 | + { |
---|
| 166 | + bRep.RestoreSupports(); |
---|
| 167 | + } |
---|
| 168 | + |
---|
| 169 | + for (int i = 0; i < Size(); i++) |
---|
| 170 | + { |
---|
| 171 | + Object3D child = (Object3D) get(i); |
---|
| 172 | + if (child == null) |
---|
| 173 | + continue; |
---|
| 174 | + blockloop = true; |
---|
| 175 | + child.RestoreSupports(); |
---|
| 176 | + blockloop = false; |
---|
| 177 | + } |
---|
| 178 | + } |
---|
| 179 | + |
---|
| 180 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 181 | + { |
---|
| 182 | + Object3D o; |
---|
| 183 | + |
---|
| 184 | + if (hashtable.containsKey(GetUUID())) |
---|
| 185 | + { |
---|
| 186 | + o = hashtable.get(GetUUID()); |
---|
| 187 | + |
---|
| 188 | + Grafreed.Assert(this.bRep == o.bRep); |
---|
| 189 | + //if (this.bRep != null) |
---|
| 190 | + // assert(this.bRep.support == o.transientrep); |
---|
| 191 | + if (this.support != null) |
---|
| 192 | + assert(this.support.bRep == o.transientrep); |
---|
| 193 | + } |
---|
| 194 | + else |
---|
| 195 | + { |
---|
| 196 | + o = new Object3D("copy of " + this.name); |
---|
| 197 | + |
---|
| 198 | + hashtable.put(GetUUID(), o); |
---|
| 199 | + } |
---|
| 200 | + |
---|
| 201 | + if (!blockloop) |
---|
| 202 | + { |
---|
| 203 | + blockloop = true; |
---|
| 204 | + |
---|
| 205 | + for (int i=0; i<Size(); i++) |
---|
| 206 | + { |
---|
| 207 | + get(i).ExtractBigData(hashtable); |
---|
| 208 | + } |
---|
| 209 | + |
---|
| 210 | + blockloop = false; |
---|
| 211 | + } |
---|
| 212 | + |
---|
| 213 | + ExtractBigData(o); |
---|
| 214 | + } |
---|
| 215 | + |
---|
| 216 | + void ExtractBigData(Object3D o) |
---|
| 217 | + { |
---|
| 218 | + if (o.bRep != null) |
---|
| 219 | + Grafreed.Assert(o.bRep == this.bRep); |
---|
| 220 | + |
---|
| 221 | + o.bRep = this.bRep; |
---|
| 222 | +// July 2019 if (this.bRep != null) |
---|
| 223 | +// { |
---|
| 224 | +// o.transientrep = this.bRep.support; |
---|
| 225 | +// o.bRep.support = null; |
---|
| 226 | +// } |
---|
| 227 | + o.selection = this.selection; |
---|
| 228 | + o.versionlist = this.versionlist; |
---|
| 229 | + o.versionindex = this.versionindex; |
---|
| 230 | + |
---|
| 231 | + if (this.support != null) |
---|
| 232 | + { |
---|
| 233 | + if (o.transientrep != null) |
---|
| 234 | + Grafreed.Assert(o.transientrep == this.support.bRep); |
---|
| 235 | + |
---|
| 236 | + o.transientrep = this.support.bRep; |
---|
| 237 | + this.support.bRep = null; |
---|
| 238 | + } |
---|
| 239 | + |
---|
| 240 | + // o.support = this.support; |
---|
| 241 | + // o.fileparent = this.fileparent; |
---|
| 242 | + // if (this.bRep != null) |
---|
| 243 | + // o.bRep = this.bRep.support; |
---|
| 244 | + |
---|
| 245 | + this.bRep = null; |
---|
| 246 | + // if (this.bRep != null) |
---|
| 247 | + // this.bRep.support = null; |
---|
| 248 | + // this.support = null; |
---|
| 249 | + // this.fileparent = null; |
---|
| 250 | + } |
---|
| 251 | + |
---|
| 252 | +// Object3D GetObject(java.util.UUID uuid) |
---|
| 253 | +// { |
---|
| 254 | +// if (this.uuid.equals(uuid)) |
---|
| 255 | +// return this; |
---|
| 256 | +// |
---|
| 257 | +// if (blockloop) |
---|
| 258 | +// return null; |
---|
| 259 | +// |
---|
| 260 | +// blockloop = true; |
---|
| 261 | +// |
---|
| 262 | +// for (int i=0; i<Size(); i++) |
---|
| 263 | +// { |
---|
| 264 | +// Object3D o = get(i).GetObject(uuid); |
---|
| 265 | +// |
---|
| 266 | +// if (o != null) |
---|
| 267 | +// return o; |
---|
| 268 | +// } |
---|
| 269 | +// |
---|
| 270 | +// blockloop = false; |
---|
| 271 | +// |
---|
| 272 | +// return null; |
---|
| 273 | +// } |
---|
| 274 | + |
---|
| 275 | + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 276 | + { |
---|
| 277 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 278 | + return; |
---|
| 279 | + |
---|
| 280 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 281 | + |
---|
| 282 | + RestoreBigData(o); |
---|
| 283 | + |
---|
| 284 | + if (blockloop) |
---|
| 285 | + return; |
---|
| 286 | + |
---|
129 | 287 | blockloop = true; |
---|
130 | | - child.SaveSupports(); |
---|
| 288 | + |
---|
| 289 | + //hashtable.remove(GetUUID()); |
---|
| 290 | + |
---|
| 291 | + for (int i=0; i<Size(); i++) |
---|
| 292 | + { |
---|
| 293 | + get(i).RestoreBigData(hashtable); |
---|
| 294 | + } |
---|
| 295 | + |
---|
131 | 296 | blockloop = false; |
---|
132 | 297 | } |
---|
133 | | -} |
---|
134 | 298 | |
---|
135 | | -void RestoreSupports() |
---|
136 | | -{ |
---|
137 | | - if (blockloop) |
---|
138 | | - return; |
---|
139 | | - |
---|
140 | | - support = transientsupport; |
---|
141 | | - link2master = transientlink2master; |
---|
142 | | - transientsupport = null; |
---|
143 | | - transientlink2master = false; |
---|
144 | | - |
---|
145 | | - if (bRep != null) |
---|
| 299 | + void RestoreBigData(Object3D o) |
---|
146 | 300 | { |
---|
147 | | - bRep.RestoreSupports(); |
---|
| 301 | + this.bRep = o.bRep; |
---|
| 302 | + if (this.support != null && o.transientrep != null) |
---|
| 303 | + { |
---|
| 304 | + this.support.bRep = o.transientrep; |
---|
| 305 | + } |
---|
| 306 | + |
---|
| 307 | + this.selection = o.selection; |
---|
| 308 | + |
---|
| 309 | + this.versionlist = o.versionlist; |
---|
| 310 | + this.versionindex = o.versionindex; |
---|
| 311 | +// July 2019 if (this.bRep != null) |
---|
| 312 | +// this.bRep.support = o.transientrep; |
---|
| 313 | + // this.support = o.support; |
---|
| 314 | + // this.fileparent = o.fileparent; |
---|
148 | 315 | } |
---|
149 | | - |
---|
150 | | - for (int i = 0; i < Size(); i++) |
---|
151 | | - { |
---|
152 | | - Object3D child = (Object3D) get(i); |
---|
153 | | - if (child == null) |
---|
154 | | - continue; |
---|
155 | | - blockloop = true; |
---|
156 | | - child.RestoreSupports(); |
---|
157 | | - blockloop = false; |
---|
158 | | - } |
---|
159 | | -} |
---|
160 | 316 | |
---|
161 | 317 | // MOCAP SUPPORT |
---|
162 | 318 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
299 | 455 | } |
---|
300 | 456 | |
---|
301 | 457 | boolean live = false; |
---|
| 458 | + transient boolean keepdontselect; |
---|
| 459 | + boolean dontselect = false; |
---|
302 | 460 | boolean hide = false; |
---|
303 | 461 | boolean link2master = false; // performs reset support/master at each frame |
---|
304 | 462 | boolean marked = false; // animation node |
---|
.. | .. |
---|
430 | 588 | { |
---|
431 | 589 | Object3D copy = this; |
---|
432 | 590 | |
---|
433 | | - Camera parentcam = CameraPane.theRenderer.ManipCamera(); |
---|
| 591 | + Camera parentcam = Globals.theRenderer.ManipCamera(); |
---|
434 | 592 | |
---|
435 | | - if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[0]) |
---|
| 593 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0]) |
---|
436 | 594 | { |
---|
437 | | - parentcam = CameraPane.theRenderer.Cameras()[1]; |
---|
| 595 | + parentcam = Globals.theRenderer.Cameras()[1]; |
---|
438 | 596 | } |
---|
439 | 597 | |
---|
440 | | - if (CameraPane.theRenderer.ManipCamera() == CameraPane.theRenderer.Cameras()[1]) |
---|
| 598 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1]) |
---|
441 | 599 | { |
---|
442 | | - parentcam = CameraPane.theRenderer.Cameras()[0]; |
---|
| 600 | + parentcam = Globals.theRenderer.Cameras()[0]; |
---|
443 | 601 | } |
---|
444 | 602 | |
---|
445 | 603 | if (this == parentcam) |
---|
.. | .. |
---|
447 | 605 | //assert(this instanceof Camera); |
---|
448 | 606 | |
---|
449 | 607 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
450 | | - LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.toParent, CameraPane.theRenderer.TargetLookAt()); |
---|
| 608 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt()); |
---|
451 | 609 | } |
---|
452 | 610 | |
---|
453 | 611 | copy.marked ^= true; |
---|
.. | .. |
---|
467 | 625 | //assert(this instanceof Camera); |
---|
468 | 626 | |
---|
469 | 627 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
470 | | - LA.xformPos(CameraPane.theRenderer.TargetLookAt(), parentcam.fromParent, CameraPane.theRenderer.TargetLookAt()); |
---|
| 628 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt()); |
---|
471 | 629 | } |
---|
472 | 630 | |
---|
473 | 631 | copy.Touch(); // display list issue |
---|
.. | .. |
---|
480 | 638 | toParent = LA.newMatrix(); |
---|
481 | 639 | fromParent = LA.newMatrix(); |
---|
482 | 640 | } |
---|
| 641 | + |
---|
483 | 642 | if (toParentMarked == null) |
---|
484 | 643 | { |
---|
485 | 644 | if (maxcount != 1) |
---|
486 | 645 | { |
---|
487 | 646 | new Exception().printStackTrace(); |
---|
488 | 647 | } |
---|
| 648 | + |
---|
489 | 649 | toParentMarked = LA.newMatrix(); |
---|
490 | 650 | fromParentMarked = LA.newMatrix(); |
---|
491 | 651 | } |
---|
.. | .. |
---|
773 | 933 | if (step == 0) |
---|
774 | 934 | step = 1; |
---|
775 | 935 | if (maxcount == 0) |
---|
776 | | - maxcount = 2048; // 4; |
---|
| 936 | + maxcount = 128; // 2048; // 4; |
---|
777 | 937 | // if (acceleration == 0) |
---|
778 | 938 | // acceleration = 10; |
---|
779 | 939 | if (delay == 0) // serial |
---|
.. | .. |
---|
796 | 956 | |
---|
797 | 957 | if (marked && Globals.isLIVE() && live && |
---|
798 | 958 | //TEMP21aug2018 |
---|
799 | | - Globals.DrawMode() == iCameraPane.SHADOW && |
---|
| 959 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
800 | 960 | currentframe != Globals.framecount) |
---|
801 | 961 | { |
---|
802 | 962 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
808 | 968 | |
---|
809 | 969 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
810 | 970 | |
---|
811 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 971 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 972 | + (step == 1 && changedir)) |
---|
812 | 973 | { |
---|
813 | 974 | countdown = 1; |
---|
814 | 975 | delay = speedup?8:1; |
---|
.. | .. |
---|
880 | 1041 | if (material == null || material.multiply) |
---|
881 | 1042 | return true; |
---|
882 | 1043 | |
---|
| 1044 | + if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
| 1045 | + return false; |
---|
| 1046 | + |
---|
| 1047 | + // Transparent objects are dynamic because we have to sort the triangles. |
---|
883 | 1048 | return material.opacity > 0.99; |
---|
884 | 1049 | } |
---|
885 | 1050 | |
---|
.. | .. |
---|
911 | 1076 | fromParent = null; // LA.newMatrix(); |
---|
912 | 1077 | bRep = null; // new BoundaryRep(); |
---|
913 | 1078 | |
---|
| 1079 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 1080 | + { |
---|
| 1081 | + name = oname; |
---|
| 1082 | + } |
---|
| 1083 | + |
---|
914 | 1084 | /* |
---|
915 | 1085 | float hue = (float)Math.random(); |
---|
916 | 1086 | Color col; |
---|
.. | .. |
---|
953 | 1123 | |
---|
954 | 1124 | public Object clone() |
---|
955 | 1125 | { |
---|
956 | | - return GrafreeD.clone(this); |
---|
| 1126 | + return Grafreed.clone(this); |
---|
957 | 1127 | } |
---|
958 | 1128 | |
---|
959 | 1129 | Object3D copyExpand() |
---|
.. | .. |
---|
1275 | 1445 | toParent = LA.newMatrix(); |
---|
1276 | 1446 | fromParent = LA.newMatrix(); |
---|
1277 | 1447 | } |
---|
| 1448 | + |
---|
1278 | 1449 | LA.matCopy(other.toParent, toParent); |
---|
1279 | 1450 | LA.matCopy(other.fromParent, fromParent); |
---|
1280 | 1451 | |
---|
.. | .. |
---|
1469 | 1640 | BoundaryRep.SEUIL = other.material.cameralight; |
---|
1470 | 1641 | |
---|
1471 | 1642 | // Set default to 0.1 |
---|
1472 | | - BoundaryRep.SEUIL /= 2; |
---|
| 1643 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
1473 | 1644 | System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
1474 | 1645 | } |
---|
1475 | 1646 | |
---|
.. | .. |
---|
1728 | 1899 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1729 | 1900 | o.bRep = transientrep; |
---|
1730 | 1901 | if (clone) |
---|
1731 | | - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 1902 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1732 | 1903 | o.CreateMaterial(); |
---|
1733 | 1904 | o.SetAttributes(this, -1); |
---|
1734 | 1905 | //parent |
---|
.. | .. |
---|
1741 | 1912 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1742 | 1913 | o.bRep = bRep; |
---|
1743 | 1914 | if (clone) |
---|
1744 | | - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 1915 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1745 | 1916 | o.CreateMaterial(); |
---|
1746 | 1917 | //o.overwriteThis(this, -1); |
---|
1747 | 1918 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1828 | 1999 | if (obj.name == null) |
---|
1829 | 2000 | continue; // can't be a null one |
---|
1830 | 2001 | |
---|
| 2002 | + // Try perfect match first. |
---|
1831 | 2003 | if (n.equals(obj.name)) |
---|
1832 | 2004 | { |
---|
1833 | 2005 | theobj = obj; |
---|
1834 | 2006 | count++; |
---|
1835 | 2007 | } |
---|
1836 | 2008 | } |
---|
| 2009 | + |
---|
| 2010 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1837 | 2011 | |
---|
1838 | 2012 | if (count != 1) |
---|
1839 | 2013 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2293 | 2467 | } |
---|
2294 | 2468 | */ |
---|
2295 | 2469 | } |
---|
| 2470 | + else |
---|
| 2471 | + { |
---|
| 2472 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2473 | + if (objectUI != null) |
---|
| 2474 | + ((ObjEditor)objectUI).pinButton.setSelected(pinned); |
---|
| 2475 | + else |
---|
| 2476 | + //new Exception().printStackTrace(); |
---|
| 2477 | + System.err.println("objectUI is null"); |
---|
| 2478 | + } |
---|
2296 | 2479 | } |
---|
2297 | 2480 | |
---|
2298 | 2481 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
2299 | 2482 | { |
---|
2300 | 2483 | if (newWindow) |
---|
2301 | 2484 | { |
---|
| 2485 | + new Exception().printStackTrace(); |
---|
2302 | 2486 | System.exit(0); |
---|
2303 | 2487 | if (parent != null) |
---|
2304 | 2488 | { |
---|
.. | .. |
---|
2333 | 2517 | { |
---|
2334 | 2518 | editWindow.refreshContents(); |
---|
2335 | 2519 | } |
---|
| 2520 | + else |
---|
| 2521 | + { |
---|
| 2522 | + if (manipWindow != null) |
---|
| 2523 | + { |
---|
| 2524 | + manipWindow.refreshContents(); |
---|
| 2525 | + } |
---|
| 2526 | + } |
---|
| 2527 | + |
---|
2336 | 2528 | //if (parent != null) |
---|
2337 | 2529 | //parent.refreshEditWindow(); |
---|
2338 | 2530 | } |
---|
.. | .. |
---|
2412 | 2604 | private static final int editSelf = 1; |
---|
2413 | 2605 | private static final int editChild = 2; |
---|
2414 | 2606 | |
---|
2415 | | - void drawEditHandles(ClickInfo info, int level) |
---|
| 2607 | + void drawEditHandles(//ClickInfo info, |
---|
| 2608 | + int level) |
---|
2416 | 2609 | { |
---|
2417 | 2610 | if (level == 0) |
---|
2418 | 2611 | { |
---|
.. | .. |
---|
2420 | 2613 | return; |
---|
2421 | 2614 | |
---|
2422 | 2615 | Object3D selectee; |
---|
2423 | | - for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1)) |
---|
| 2616 | + for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info, |
---|
| 2617 | + level + 1)) |
---|
2424 | 2618 | { |
---|
2425 | 2619 | selectee = (Object3D) e.nextElement(); |
---|
2426 | 2620 | } |
---|
.. | .. |
---|
2428 | 2622 | } else |
---|
2429 | 2623 | { |
---|
2430 | 2624 | //super. |
---|
2431 | | - drawEditHandles0(info, level + 1); |
---|
| 2625 | + drawEditHandles0(//info, |
---|
| 2626 | + level + 1); |
---|
2432 | 2627 | } |
---|
2433 | 2628 | } |
---|
2434 | 2629 | |
---|
2435 | | - boolean doEditClick(ClickInfo info, int level) |
---|
| 2630 | + boolean doEditClick(//ClickInfo info, |
---|
| 2631 | + int level) |
---|
2436 | 2632 | { |
---|
2437 | 2633 | doSomething = 0; |
---|
2438 | 2634 | if (level == 0) |
---|
2439 | 2635 | { |
---|
2440 | | - return doParentClick(info); |
---|
| 2636 | + return doParentClick(); //info); |
---|
2441 | 2637 | } |
---|
2442 | 2638 | if (//super. |
---|
2443 | | - doEditClick0(info, level)) |
---|
| 2639 | + doEditClick0(//info, |
---|
| 2640 | + level)) |
---|
2444 | 2641 | { |
---|
2445 | 2642 | doSomething = 1; |
---|
2446 | 2643 | return true; |
---|
.. | .. |
---|
2450 | 2647 | } |
---|
2451 | 2648 | } |
---|
2452 | 2649 | |
---|
2453 | | - boolean doParentClick(ClickInfo info) |
---|
| 2650 | + boolean doParentClick() //ClickInfo info) |
---|
2454 | 2651 | { |
---|
2455 | 2652 | if (selection == null) |
---|
2456 | 2653 | { |
---|
.. | .. |
---|
2463 | 2660 | for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();) |
---|
2464 | 2661 | { |
---|
2465 | 2662 | Object3D selectee = (Object3D) e.nextElement(); |
---|
2466 | | - if (selectee.doEditClick(info, 1)) |
---|
| 2663 | + if (selectee.doEditClick(//info, |
---|
| 2664 | + 1)) |
---|
2467 | 2665 | { |
---|
2468 | 2666 | childToDrag = selectee; |
---|
2469 | 2667 | doSomething = 2; |
---|
.. | .. |
---|
2475 | 2673 | return retval; |
---|
2476 | 2674 | } |
---|
2477 | 2675 | |
---|
2478 | | - void doEditDrag(ClickInfo info) |
---|
| 2676 | + void doEditDrag(//ClickInfo clickInfo, |
---|
| 2677 | + boolean opposite) |
---|
2479 | 2678 | { |
---|
2480 | 2679 | switch (doSomething) |
---|
2481 | 2680 | { |
---|
2482 | 2681 | case 1: // '\001' |
---|
2483 | 2682 | //super. |
---|
2484 | | - doEditDrag0(info); |
---|
| 2683 | + doEditDrag0(//clickInfo, |
---|
| 2684 | + opposite); |
---|
2485 | 2685 | break; |
---|
2486 | 2686 | |
---|
2487 | 2687 | case 2: // '\002' |
---|
.. | .. |
---|
2494 | 2694 | { |
---|
2495 | 2695 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2496 | 2696 | //childToDrag.doEditDrag(info); |
---|
2497 | | - sel.doEditDrag(info); |
---|
| 2697 | + sel.doEditDrag(//clickInfo, |
---|
| 2698 | + opposite); |
---|
2498 | 2699 | } else |
---|
2499 | 2700 | { |
---|
2500 | 2701 | //super. |
---|
2501 | | - doEditDrag0(info); |
---|
| 2702 | + doEditDrag0(//clickInfo, |
---|
| 2703 | + opposite); |
---|
2502 | 2704 | } |
---|
2503 | 2705 | } |
---|
2504 | 2706 | break; |
---|
.. | .. |
---|
2516 | 2718 | { |
---|
2517 | 2719 | deselectAll(); |
---|
2518 | 2720 | } |
---|
| 2721 | + |
---|
| 2722 | + new Exception().printStackTrace(); |
---|
| 2723 | + |
---|
2519 | 2724 | ClickInfo newInfo = new ClickInfo(); |
---|
2520 | 2725 | newInfo.flags = info.flags; |
---|
2521 | 2726 | newInfo.bounds = info.bounds; |
---|
.. | .. |
---|
2608 | 2813 | void GenNormalsS(boolean crease) |
---|
2609 | 2814 | { |
---|
2610 | 2815 | selection.GenNormals(crease); |
---|
| 2816 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2817 | +// { |
---|
| 2818 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2819 | +// selectee.GenNormals(crease); |
---|
| 2820 | +// } |
---|
| 2821 | + |
---|
| 2822 | + //Touch(); |
---|
| 2823 | + } |
---|
| 2824 | + |
---|
| 2825 | + void GenNormalsMeshS() |
---|
| 2826 | + { |
---|
| 2827 | + selection.GenNormalsMesh(); |
---|
2611 | 2828 | // for (int i=0; i<selection.size(); i++) |
---|
2612 | 2829 | // { |
---|
2613 | 2830 | // Object3D selectee = (Object3D) selection.elementAt(i); |
---|
.. | .. |
---|
2748 | 2965 | if (child == null) |
---|
2749 | 2966 | continue; |
---|
2750 | 2967 | child.GenNormals(crease); |
---|
| 2968 | +// Children().release(i); |
---|
| 2969 | + } |
---|
| 2970 | + blockloop = false; |
---|
| 2971 | + } |
---|
| 2972 | + |
---|
| 2973 | + void GenNormalsMesh() |
---|
| 2974 | + { |
---|
| 2975 | + if (blockloop) |
---|
| 2976 | + return; |
---|
| 2977 | + |
---|
| 2978 | + blockloop = true; |
---|
| 2979 | + GenNormalsMesh0(); |
---|
| 2980 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2981 | + { |
---|
| 2982 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2983 | + if (child == null) |
---|
| 2984 | + continue; |
---|
| 2985 | + child.GenNormalsMesh(); |
---|
2751 | 2986 | // Children().release(i); |
---|
2752 | 2987 | } |
---|
2753 | 2988 | blockloop = false; |
---|
.. | .. |
---|
2905 | 3140 | { |
---|
2906 | 3141 | if (bRep != null) |
---|
2907 | 3142 | { |
---|
2908 | | - bRep.GenUV(); |
---|
| 3143 | + bRep.GenUV(); //1); |
---|
| 3144 | + //bRep.UnfoldUV(); |
---|
2909 | 3145 | Touch(); |
---|
2910 | 3146 | } |
---|
2911 | 3147 | } |
---|
.. | .. |
---|
2919 | 3155 | } |
---|
2920 | 3156 | } |
---|
2921 | 3157 | |
---|
| 3158 | + void GenNormalsMesh0() |
---|
| 3159 | + { |
---|
| 3160 | + if (bRep != null) |
---|
| 3161 | + { |
---|
| 3162 | + bRep.GenerateNormalsMesh(); |
---|
| 3163 | + Touch(); |
---|
| 3164 | + } |
---|
| 3165 | + } |
---|
| 3166 | + |
---|
2922 | 3167 | void GenNormalsMINE0() |
---|
2923 | 3168 | { |
---|
2924 | 3169 | if (bRep != null) |
---|
2925 | 3170 | { |
---|
2926 | | - bRep.GenerateNormalsMINE(); |
---|
| 3171 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
2927 | 3172 | Touch(); |
---|
2928 | 3173 | } |
---|
2929 | 3174 | } |
---|
.. | .. |
---|
2980 | 3225 | blockloop = false; |
---|
2981 | 3226 | } |
---|
2982 | 3227 | |
---|
| 3228 | + void TransformChildren() |
---|
| 3229 | + { |
---|
| 3230 | + if (toParent != null) |
---|
| 3231 | + { |
---|
| 3232 | + for (int i=Size(); --i>=0;) |
---|
| 3233 | + { |
---|
| 3234 | + Object3D v = get(i); |
---|
| 3235 | + |
---|
| 3236 | + if (v.toParent == null) |
---|
| 3237 | + { |
---|
| 3238 | + v.toParent = LA.newMatrix(); |
---|
| 3239 | + v.fromParent = LA.newMatrix(); |
---|
| 3240 | + } |
---|
| 3241 | + |
---|
| 3242 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3243 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3244 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3245 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
| 3246 | + } |
---|
| 3247 | + |
---|
| 3248 | + toParent = null; // LA.matIdentity(toParent); |
---|
| 3249 | + fromParent = null; // LA.matIdentity(fromParent); |
---|
| 3250 | + |
---|
| 3251 | + Touch(); |
---|
| 3252 | + } |
---|
| 3253 | + } |
---|
| 3254 | + |
---|
2983 | 3255 | void TransformGeometry() |
---|
2984 | 3256 | { |
---|
2985 | 3257 | Object3D obj = this; |
---|
.. | .. |
---|
3201 | 3473 | |
---|
3202 | 3474 | BoundaryRep sup = bRep.support; |
---|
3203 | 3475 | bRep.support = null; |
---|
3204 | | - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 3476 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3205 | 3477 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3206 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3478 | + |
---|
| 3479 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3480 | + |
---|
3207 | 3481 | bRep = temprep; |
---|
3208 | 3482 | bRep.support = sup; |
---|
3209 | 3483 | Touch(); |
---|
.. | .. |
---|
3340 | 3614 | if (blockloop) |
---|
3341 | 3615 | return; |
---|
3342 | 3616 | |
---|
3343 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3617 | + if (//marked || // does not make sense |
---|
| 3618 | + (bRep != null || material != null)) // borderline... |
---|
3344 | 3619 | live = h; |
---|
3345 | 3620 | |
---|
3346 | 3621 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3361 | 3636 | return; |
---|
3362 | 3637 | |
---|
3363 | 3638 | //if (bRep != null) |
---|
3364 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3639 | + if (//marked || // does not make sense |
---|
| 3640 | + (bRep != null || material != null)) // borderline... |
---|
3365 | 3641 | link2master = h; |
---|
3366 | 3642 | |
---|
3367 | 3643 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3381 | 3657 | if (blockloop) |
---|
3382 | 3658 | return; |
---|
3383 | 3659 | |
---|
3384 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3660 | + if (//marked || // does not make sense |
---|
| 3661 | + (bRep != null || material != null)) // borderline... |
---|
3385 | 3662 | hide = h; |
---|
3386 | 3663 | |
---|
3387 | 3664 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3401 | 3678 | if (blockloop) |
---|
3402 | 3679 | return; |
---|
3403 | 3680 | |
---|
3404 | | - if (bRep != null && material != null) // borderline... |
---|
| 3681 | + if (bRep != null || material != null) // borderline... |
---|
3405 | 3682 | marked = h; |
---|
3406 | 3683 | |
---|
3407 | 3684 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3411 | 3688 | continue; |
---|
3412 | 3689 | blockloop = true; |
---|
3413 | 3690 | child.MarkLeaves(h); |
---|
| 3691 | + blockloop = false; |
---|
| 3692 | + // release(i); |
---|
| 3693 | + } |
---|
| 3694 | + } |
---|
| 3695 | + |
---|
| 3696 | + void RewindLeaves(boolean h) |
---|
| 3697 | + { |
---|
| 3698 | + if (blockloop) |
---|
| 3699 | + return; |
---|
| 3700 | + |
---|
| 3701 | + if (bRep != null || material != null) // borderline... |
---|
| 3702 | + rewind = h; |
---|
| 3703 | + |
---|
| 3704 | + for (int i = 0; i < Size(); i++) |
---|
| 3705 | + { |
---|
| 3706 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3707 | + if (child == null) |
---|
| 3708 | + continue; |
---|
| 3709 | + blockloop = true; |
---|
| 3710 | + child.RewindLeaves(h); |
---|
| 3711 | + blockloop = false; |
---|
| 3712 | + // release(i); |
---|
| 3713 | + } |
---|
| 3714 | + } |
---|
| 3715 | + |
---|
| 3716 | + void RandomLeaves(boolean h) |
---|
| 3717 | + { |
---|
| 3718 | + if (blockloop) |
---|
| 3719 | + return; |
---|
| 3720 | + |
---|
| 3721 | + if (bRep != null || material != null) // borderline... |
---|
| 3722 | + random = h; |
---|
| 3723 | + |
---|
| 3724 | + for (int i = 0; i < Size(); i++) |
---|
| 3725 | + { |
---|
| 3726 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3727 | + if (child == null) |
---|
| 3728 | + continue; |
---|
| 3729 | + blockloop = true; |
---|
| 3730 | + child.RandomLeaves(h); |
---|
3414 | 3731 | blockloop = false; |
---|
3415 | 3732 | // release(i); |
---|
3416 | 3733 | } |
---|
.. | .. |
---|
3725 | 4042 | if (child == null) |
---|
3726 | 4043 | continue; |
---|
3727 | 4044 | |
---|
3728 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4045 | + if (Grafreed.RENDERME > 0) |
---|
3729 | 4046 | { |
---|
3730 | 4047 | if (child instanceof Merge) |
---|
3731 | 4048 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3876 | 4193 | if (child == null) |
---|
3877 | 4194 | continue; |
---|
3878 | 4195 | |
---|
3879 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4196 | + if (Grafreed.RENDERME > 0) |
---|
3880 | 4197 | { |
---|
3881 | 4198 | if (child instanceof Merge) |
---|
3882 | 4199 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4071 | 4388 | if (child == null) |
---|
4072 | 4389 | continue; |
---|
4073 | 4390 | |
---|
4074 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4391 | + if (Grafreed.RENDERME > 0) |
---|
4075 | 4392 | { |
---|
4076 | 4393 | if (child instanceof Merge) |
---|
4077 | 4394 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4184 | 4501 | { |
---|
4185 | 4502 | blockloop = true; |
---|
4186 | 4503 | get(i).RepairShadow(); |
---|
| 4504 | + blockloop = false; |
---|
| 4505 | + } |
---|
| 4506 | + } |
---|
| 4507 | + |
---|
| 4508 | + void RepairSOV() |
---|
| 4509 | + { |
---|
| 4510 | + if (blockloop) |
---|
| 4511 | + return; |
---|
| 4512 | + |
---|
| 4513 | + String texname = this.GetPigmentTexture(); |
---|
| 4514 | + |
---|
| 4515 | + if (texname.startsWith("sov")) |
---|
| 4516 | + { |
---|
| 4517 | + String[] s = texname.split("/"); |
---|
| 4518 | + |
---|
| 4519 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4520 | + |
---|
| 4521 | + texname = sname[0]; |
---|
| 4522 | + |
---|
| 4523 | + if (sname.length > 1) |
---|
| 4524 | + { |
---|
| 4525 | + texname += "Color.jpg"; |
---|
| 4526 | + } |
---|
| 4527 | + |
---|
| 4528 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4529 | + } |
---|
| 4530 | + |
---|
| 4531 | + texname = this.GetBumpTexture(); |
---|
| 4532 | + |
---|
| 4533 | + if (texname.startsWith("sov")) |
---|
| 4534 | + { |
---|
| 4535 | + String[] s = texname.split("/"); |
---|
| 4536 | + |
---|
| 4537 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4538 | + |
---|
| 4539 | + texname = sname[0]; |
---|
| 4540 | + |
---|
| 4541 | + if (sname.length > 1) |
---|
| 4542 | + { |
---|
| 4543 | + texname += "Bump.jpg"; |
---|
| 4544 | + } |
---|
| 4545 | + |
---|
| 4546 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4547 | + } |
---|
| 4548 | + |
---|
| 4549 | + for (int i=0; i<Size(); i++) |
---|
| 4550 | + { |
---|
| 4551 | + blockloop = true; |
---|
| 4552 | + get(i).RepairSOV(); |
---|
4187 | 4553 | blockloop = false; |
---|
4188 | 4554 | } |
---|
4189 | 4555 | } |
---|
.. | .. |
---|
4678 | 5044 | |
---|
4679 | 5045 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4680 | 5046 | { |
---|
4681 | | - if (hide) |
---|
| 5047 | + if (hide || dontselect) |
---|
4682 | 5048 | return null; |
---|
4683 | 5049 | |
---|
4684 | 5050 | if (count <= 0) |
---|
.. | .. |
---|
4702 | 5068 | } |
---|
4703 | 5069 | } |
---|
4704 | 5070 | |
---|
| 5071 | + ObjEditor GetWindow() |
---|
| 5072 | + { |
---|
| 5073 | + if (editWindow != null) |
---|
| 5074 | + return editWindow; |
---|
| 5075 | + |
---|
| 5076 | + return manipWindow; |
---|
| 5077 | + } |
---|
| 5078 | + |
---|
4705 | 5079 | cTreePath Select(int indexcount, boolean deselect) |
---|
4706 | 5080 | { |
---|
4707 | | - if (hide) |
---|
| 5081 | + if (hide || dontselect) |
---|
4708 | 5082 | return null; |
---|
4709 | 5083 | |
---|
4710 | 5084 | if (count <= 0) |
---|
.. | .. |
---|
4738 | 5112 | if (leaf != null) |
---|
4739 | 5113 | { |
---|
4740 | 5114 | cTreePath tp = new cTreePath(this, leaf); |
---|
4741 | | - if (editWindow != null) |
---|
| 5115 | + ObjEditor window = GetWindow(); |
---|
| 5116 | + if (window != null) |
---|
4742 | 5117 | { |
---|
4743 | 5118 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4744 | | - editWindow.Select(tp, deselect, true); |
---|
| 5119 | + window.Select(tp, deselect, true); |
---|
4745 | 5120 | } |
---|
4746 | 5121 | |
---|
4747 | 5122 | return tp; |
---|
.. | .. |
---|
4758 | 5133 | |
---|
4759 | 5134 | if (child == null) |
---|
4760 | 5135 | continue; |
---|
| 5136 | + |
---|
4761 | 5137 | if (child.HasTransparency() && child.size() != 0) |
---|
4762 | 5138 | { |
---|
4763 | 5139 | cTreePath leaf = child.Select(indexcount, deselect); |
---|
.. | .. |
---|
4767 | 5143 | if (leaf != null) |
---|
4768 | 5144 | { |
---|
4769 | 5145 | cTreePath tp = new cTreePath(this, leaf); |
---|
4770 | | - if (editWindow != null) |
---|
| 5146 | + ObjEditor window = GetWindow(); |
---|
| 5147 | + if (window != null) |
---|
4771 | 5148 | { |
---|
4772 | | - editWindow.Select(tp, deselect, true); |
---|
| 5149 | + window.Select(tp, deselect, true); |
---|
4773 | 5150 | } |
---|
4774 | 5151 | |
---|
4775 | 5152 | return tp; |
---|
.. | .. |
---|
5094 | 5471 | blockloop = false; |
---|
5095 | 5472 | } |
---|
5096 | 5473 | |
---|
| 5474 | + void ResetSelectable() |
---|
| 5475 | + { |
---|
| 5476 | + if (blockloop) |
---|
| 5477 | + return; |
---|
| 5478 | + |
---|
| 5479 | + blockloop = true; |
---|
| 5480 | + |
---|
| 5481 | + keepdontselect = dontselect; |
---|
| 5482 | + dontselect = true; |
---|
| 5483 | + |
---|
| 5484 | + Object3D child; |
---|
| 5485 | + int nb = Size(); |
---|
| 5486 | + for (int i = 0; i < nb; i++) |
---|
| 5487 | + { |
---|
| 5488 | + child = (Object3D) get(i); |
---|
| 5489 | + if (child == null) |
---|
| 5490 | + continue; |
---|
| 5491 | + child.ResetSelectable(); |
---|
| 5492 | + } |
---|
| 5493 | + |
---|
| 5494 | + blockloop = false; |
---|
| 5495 | + } |
---|
| 5496 | + |
---|
| 5497 | + void RestoreSelectable() |
---|
| 5498 | + { |
---|
| 5499 | + if (blockloop) |
---|
| 5500 | + return; |
---|
| 5501 | + |
---|
| 5502 | + blockloop = true; |
---|
| 5503 | + |
---|
| 5504 | + dontselect = keepdontselect; |
---|
| 5505 | + |
---|
| 5506 | + Object3D child; |
---|
| 5507 | + int nb = Size(); |
---|
| 5508 | + for (int i = 0; i < nb; i++) |
---|
| 5509 | + { |
---|
| 5510 | + child = (Object3D) get(i); |
---|
| 5511 | + if (child == null) |
---|
| 5512 | + continue; |
---|
| 5513 | + child.RestoreSelectable(); |
---|
| 5514 | + } |
---|
| 5515 | + |
---|
| 5516 | + blockloop = false; |
---|
| 5517 | + } |
---|
| 5518 | + |
---|
5097 | 5519 | boolean IsSelected() |
---|
5098 | 5520 | { |
---|
5099 | 5521 | if (parent == null) |
---|
.. | .. |
---|
5154 | 5576 | if (fullname == null) |
---|
5155 | 5577 | return ""; |
---|
5156 | 5578 | |
---|
| 5579 | + if (fullname.pigment != null) |
---|
| 5580 | + { |
---|
| 5581 | + return fullname.pigment; |
---|
| 5582 | + } |
---|
| 5583 | + |
---|
5157 | 5584 | // System.out.println("Fullname = " + fullname); |
---|
5158 | 5585 | |
---|
5159 | | - if (fullname.name.indexOf(":") == -1) |
---|
5160 | | - return fullname.name; |
---|
| 5586 | + // Does not work on Windows due to C: |
---|
| 5587 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5588 | +// return fullname.name; |
---|
| 5589 | +// |
---|
| 5590 | +// return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
5161 | 5591 | |
---|
5162 | | - return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
| 5592 | + String[] split = fullname.name.split(":"); |
---|
| 5593 | + |
---|
| 5594 | + if (split.length == 0) |
---|
| 5595 | + { |
---|
| 5596 | + return fullname.pigment = ""; |
---|
| 5597 | + } |
---|
| 5598 | + |
---|
| 5599 | + if (split.length <= 2) |
---|
| 5600 | + { |
---|
| 5601 | + if (fullname.name.endsWith(":")) |
---|
| 5602 | + { |
---|
| 5603 | + // Windows |
---|
| 5604 | + return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5605 | + } |
---|
| 5606 | + |
---|
| 5607 | + return fullname.pigment = split[0]; |
---|
| 5608 | + } |
---|
| 5609 | + |
---|
| 5610 | + // Windows |
---|
| 5611 | + assert(split.length == 4); |
---|
| 5612 | + |
---|
| 5613 | + return fullname.pigment = split[0] + ":" + split[1]; |
---|
5163 | 5614 | } |
---|
5164 | 5615 | |
---|
5165 | 5616 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5167 | 5618 | if (fullname == null) |
---|
5168 | 5619 | return ""; |
---|
5169 | 5620 | |
---|
| 5621 | + if (fullname.bump != null) |
---|
| 5622 | + { |
---|
| 5623 | + return fullname.bump; |
---|
| 5624 | + } |
---|
| 5625 | + |
---|
5170 | 5626 | // System.out.println("Fullname = " + fullname); |
---|
5171 | | - if (fullname.name.indexOf(":") == -1) |
---|
5172 | | - return ""; |
---|
5173 | | - |
---|
5174 | | - return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5627 | + // Does not work on Windows due to C: |
---|
| 5628 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5629 | +// return ""; |
---|
| 5630 | +// |
---|
| 5631 | +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5632 | + String[] split = fullname.name.split(":"); |
---|
| 5633 | + |
---|
| 5634 | + if (split.length == 0) |
---|
| 5635 | + { |
---|
| 5636 | + return fullname.bump = ""; |
---|
| 5637 | + } |
---|
| 5638 | + |
---|
| 5639 | + if (split.length == 1) |
---|
| 5640 | + { |
---|
| 5641 | + return fullname.bump = ""; |
---|
| 5642 | + } |
---|
| 5643 | + |
---|
| 5644 | + if (split.length == 2) |
---|
| 5645 | + { |
---|
| 5646 | + if (fullname.name.endsWith(":")) |
---|
| 5647 | + { |
---|
| 5648 | + // Windows |
---|
| 5649 | + return fullname.bump = ""; |
---|
| 5650 | + } |
---|
| 5651 | + |
---|
| 5652 | + return fullname.bump = split[1]; |
---|
| 5653 | + } |
---|
| 5654 | + |
---|
| 5655 | + // Windows |
---|
| 5656 | + assert(split.length == 4); |
---|
| 5657 | + |
---|
| 5658 | + return fullname.bump = split[2] + ":" + split[3]; |
---|
5175 | 5659 | } |
---|
5176 | 5660 | |
---|
5177 | 5661 | String GetPigmentTexture() |
---|
.. | .. |
---|
5245 | 5729 | System.out.print("; textures = " + textures); |
---|
5246 | 5730 | System.out.println("; usedtextures = " + usedtextures); |
---|
5247 | 5731 | |
---|
5248 | | - if (GetTextures() == null) |
---|
| 5732 | + if (GetTextures() == null) // What is that?? |
---|
5249 | 5733 | GetTextures().name = ":"; |
---|
5250 | 5734 | |
---|
5251 | 5735 | String texname = tex; |
---|
.. | .. |
---|
5254 | 5738 | texname = ""; |
---|
5255 | 5739 | |
---|
5256 | 5740 | GetTextures().name = texname + ":" + GetBump(GetTextures()); |
---|
| 5741 | + |
---|
| 5742 | + GetTextures().pigment = null; |
---|
| 5743 | + |
---|
5257 | 5744 | Touch(); |
---|
5258 | 5745 | } |
---|
5259 | 5746 | |
---|
.. | .. |
---|
5278 | 5765 | } |
---|
5279 | 5766 | } |
---|
5280 | 5767 | |
---|
| 5768 | + UUID GetUUID() |
---|
| 5769 | + { |
---|
| 5770 | + if (uuid == null) |
---|
| 5771 | + { |
---|
| 5772 | + // Serial |
---|
| 5773 | + uuid = UUID.randomUUID(); |
---|
| 5774 | + } |
---|
| 5775 | + |
---|
| 5776 | + return uuid; |
---|
| 5777 | + } |
---|
| 5778 | + |
---|
| 5779 | + Object3D GetObject(UUID uid) |
---|
| 5780 | + { |
---|
| 5781 | + if (blockloop) |
---|
| 5782 | + return null; |
---|
| 5783 | + |
---|
| 5784 | + if (GetUUID().equals(uid)) |
---|
| 5785 | + return this; |
---|
| 5786 | + |
---|
| 5787 | + int nb = Size(); |
---|
| 5788 | + for (int i = 0; i < nb; i++) |
---|
| 5789 | + { |
---|
| 5790 | + Object3D child = (Object3D) get(i); |
---|
| 5791 | + |
---|
| 5792 | + if (child == null) |
---|
| 5793 | + continue; |
---|
| 5794 | + |
---|
| 5795 | + blockloop = true; |
---|
| 5796 | + Object3D obj = child.GetObject(uid); |
---|
| 5797 | + blockloop = false; |
---|
| 5798 | + if (obj != null) |
---|
| 5799 | + return obj; |
---|
| 5800 | + } |
---|
| 5801 | + |
---|
| 5802 | + return null; |
---|
| 5803 | + } |
---|
| 5804 | + |
---|
5281 | 5805 | void SetBumpTexture(String tex) |
---|
5282 | 5806 | { |
---|
5283 | 5807 | if (GetTextures() == null) |
---|
.. | .. |
---|
5289 | 5813 | texname = ""; |
---|
5290 | 5814 | |
---|
5291 | 5815 | GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname; |
---|
| 5816 | + |
---|
| 5817 | + GetTextures().bump = null; |
---|
5292 | 5818 | |
---|
5293 | 5819 | Touch(); |
---|
5294 | 5820 | } |
---|
.. | .. |
---|
5314 | 5840 | } |
---|
5315 | 5841 | } |
---|
5316 | 5842 | |
---|
| 5843 | + void EmbedTextures(boolean embed) |
---|
| 5844 | + { |
---|
| 5845 | + if (blockloop) |
---|
| 5846 | + return; |
---|
| 5847 | + |
---|
| 5848 | + //if (GetTextures() != null) |
---|
| 5849 | + if (embed) |
---|
| 5850 | + CameraPane.EmbedTextures(GetTextures()); |
---|
| 5851 | + else |
---|
| 5852 | + { |
---|
| 5853 | + GetTextures().pigmentdata = null; |
---|
| 5854 | + GetTextures().bumpdata = null; |
---|
| 5855 | + GetTextures().pw = 0; |
---|
| 5856 | + GetTextures().ph = 0; |
---|
| 5857 | + GetTextures().bw = 0; |
---|
| 5858 | + GetTextures().bh = 0; |
---|
| 5859 | + } |
---|
| 5860 | + |
---|
| 5861 | + int nb = Size(); |
---|
| 5862 | + for (int i = 0; i < nb; i++) |
---|
| 5863 | + { |
---|
| 5864 | + Object3D child = (Object3D) get(i); |
---|
| 5865 | + |
---|
| 5866 | + if (child == null) |
---|
| 5867 | + continue; |
---|
| 5868 | + |
---|
| 5869 | + blockloop = true; |
---|
| 5870 | + child.EmbedTextures(embed); |
---|
| 5871 | + blockloop = false; |
---|
| 5872 | + } |
---|
| 5873 | + } |
---|
| 5874 | + |
---|
5317 | 5875 | void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5318 | 5876 | { |
---|
5319 | 5877 | Draw(display, root, selected, blocked); |
---|
.. | .. |
---|
5322 | 5880 | boolean NeedSupport() |
---|
5323 | 5881 | { |
---|
5324 | 5882 | return |
---|
5325 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5883 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5326 | 5884 | // PROBLEM with CROWD!! |
---|
5327 | | - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); |
---|
| 5885 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5328 | 5886 | } |
---|
5329 | 5887 | |
---|
5330 | 5888 | static boolean DEBUG_SELECTION = false; |
---|
| 5889 | + |
---|
| 5890 | + boolean IsLive() |
---|
| 5891 | + { |
---|
| 5892 | + if (live) |
---|
| 5893 | + return true; |
---|
| 5894 | + |
---|
| 5895 | + if (parent == null) |
---|
| 5896 | + return false; |
---|
| 5897 | + |
---|
| 5898 | + return parent.IsLive(); |
---|
| 5899 | + } |
---|
5331 | 5900 | |
---|
5332 | 5901 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5333 | 5902 | { |
---|
.. | .. |
---|
5339 | 5908 | } |
---|
5340 | 5909 | |
---|
5341 | 5910 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5342 | | - hide) |
---|
| 5911 | + (hide || dontselect)) |
---|
5343 | 5912 | return; |
---|
5344 | 5913 | |
---|
5345 | 5914 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5371 | 5940 | return; |
---|
5372 | 5941 | } |
---|
5373 | 5942 | |
---|
5374 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 5943 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5375 | 5944 | |
---|
5376 | 5945 | /* |
---|
5377 | 5946 | if (touched) |
---|
.. | .. |
---|
5389 | 5958 | if (support != null) |
---|
5390 | 5959 | support = support; |
---|
5391 | 5960 | |
---|
5392 | | - //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5393 | | - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5961 | + boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5962 | + //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5963 | + |
---|
| 5964 | + //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
5394 | 5965 | |
---|
5395 | 5966 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5396 | 5967 | { |
---|
.. | .. |
---|
5400 | 5971 | // usecalllists &= !(parent instanceof RandomNode); |
---|
5401 | 5972 | // usecalllists = false; |
---|
5402 | 5973 | |
---|
5403 | | - if (GetBRep() != null) |
---|
5404 | | - usecalllists = usecalllists; |
---|
| 5974 | + if (display.DrawMode() == display.SHADOW) |
---|
| 5975 | + //GetBRep() != null) |
---|
| 5976 | + usecalllists = !!usecalllists; |
---|
5405 | 5977 | //System.out.println("draw " + this); |
---|
5406 | 5978 | //new Exception().printStackTrace(); |
---|
5407 | 5979 | |
---|
.. | .. |
---|
5410 | 5982 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5411 | 5983 | |
---|
5412 | 5984 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5413 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5985 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5986 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5414 | 5987 | { |
---|
5415 | 5988 | Globals.lighttouched = true; |
---|
5416 | 5989 | } // all panes... |
---|
| 5990 | + |
---|
5417 | 5991 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5418 | 5992 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5419 | 5993 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5421 | 5995 | if (!(this instanceof Composite)) |
---|
5422 | 5996 | touched = false; |
---|
5423 | 5997 | //if (displaylist == -1 && usecalllists) |
---|
5424 | | - if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
| 5998 | + if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013 |
---|
5425 | 5999 | { |
---|
5426 | | - bRep.displaylist = gl.glGenLists(1); |
---|
| 6000 | + bRep.displaylist = display.GenList(); |
---|
5427 | 6001 | assert(bRep.displaylist != 0); |
---|
5428 | 6002 | // System.err.println("glGenLists: " + bRep.displaylist + " for " + this); |
---|
5429 | 6003 | //System.out.println("\tgen list " + list); |
---|
.. | .. |
---|
5432 | 6006 | |
---|
5433 | 6007 | //System.out.println("\tnew list " + list); |
---|
5434 | 6008 | //gl.glDrawBuffer(gl.GL_NONE); |
---|
5435 | | - if (usecalllists) |
---|
| 6009 | + if (usecalllists && bRep.displaylist > 0) |
---|
5436 | 6010 | { |
---|
5437 | 6011 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5438 | | - gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 6012 | + display.NewList(bRep.displaylist); |
---|
5439 | 6013 | } |
---|
| 6014 | + |
---|
5440 | 6015 | CallList(display, root, selected, blocked); |
---|
| 6016 | + |
---|
5441 | 6017 | // compiled = true; |
---|
5442 | | - if (usecalllists) |
---|
| 6018 | + if (usecalllists && bRep.displaylist > 0) |
---|
5443 | 6019 | { |
---|
5444 | 6020 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5445 | | - gl.glEndList(); |
---|
| 6021 | + display.EndList(); |
---|
5446 | 6022 | } |
---|
5447 | 6023 | //gl.glDrawBuffer(gl.GL_BACK); |
---|
5448 | 6024 | // XXX touched = false; |
---|
.. | .. |
---|
5490 | 6066 | if (display.DrawMode() == iCameraPane.SHADOW) |
---|
5491 | 6067 | { |
---|
5492 | 6068 | if (!link2master // tricky to cull in shadow mode. |
---|
5493 | | - && GetBRep().FrustumCull(this, gl, display.LightCamera(), true)) |
---|
| 6069 | + && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
5494 | 6070 | { |
---|
5495 | 6071 | //System.out.print("CULLED"); |
---|
5496 | 6072 | culled = true; |
---|
.. | .. |
---|
5498 | 6074 | } |
---|
5499 | 6075 | else |
---|
5500 | 6076 | //GetBRep().getBounds(v0, v1, this); |
---|
5501 | | - if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false)) |
---|
| 6077 | + if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false)) |
---|
5502 | 6078 | culled = true; |
---|
5503 | 6079 | |
---|
5504 | 6080 | // LA.xformPos(v0, display.renderCamera.toScreen, v0); |
---|
.. | .. |
---|
5538 | 6114 | { |
---|
5539 | 6115 | if (GetBRep() != null) |
---|
5540 | 6116 | { |
---|
5541 | | - CameraPane.NextIndex(this, gl); |
---|
| 6117 | + display.NextIndex(); |
---|
| 6118 | + |
---|
5542 | 6119 | // vertex color conflict : gl.glCallList(list); |
---|
5543 | 6120 | DrawNode(display, root, selected); |
---|
5544 | 6121 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5579 | 6156 | tex = GetTextures(); |
---|
5580 | 6157 | } |
---|
5581 | 6158 | |
---|
5582 | | - display.BindTextures(tex, texres); |
---|
| 6159 | + boolean failedPigment = false; |
---|
| 6160 | + boolean failedBump = false; |
---|
| 6161 | + |
---|
| 6162 | + try |
---|
| 6163 | + { |
---|
| 6164 | + display.BindPigmentTexture(tex, texres); |
---|
| 6165 | + } |
---|
| 6166 | + catch (Exception e) |
---|
| 6167 | + { |
---|
| 6168 | + System.err.println("FAILED: " + this); |
---|
| 6169 | + failedPigment = true; |
---|
| 6170 | + } |
---|
| 6171 | + |
---|
| 6172 | + try |
---|
| 6173 | + { |
---|
| 6174 | + display.BindBumpTexture(tex, texres); |
---|
| 6175 | + } |
---|
| 6176 | + catch (Exception e) |
---|
| 6177 | + { |
---|
| 6178 | + //System.err.println("FAILED: " + this); |
---|
| 6179 | + failedBump = true; |
---|
| 6180 | + } |
---|
5583 | 6181 | |
---|
5584 | 6182 | if (!compiled) |
---|
5585 | 6183 | { |
---|
.. | .. |
---|
5595 | 6193 | |
---|
5596 | 6194 | // System.err.println("glCallList: " + bRep.displaylist + " for " + this); |
---|
5597 | 6195 | assert(bRep.displaylist != 0); |
---|
5598 | | - gl.glCallList(bRep.displaylist); |
---|
| 6196 | + display.CallList(bRep.displaylist); |
---|
5599 | 6197 | // june 2013 drawSelf(display, root, selected); |
---|
5600 | 6198 | } |
---|
5601 | 6199 | } |
---|
5602 | 6200 | } |
---|
5603 | 6201 | |
---|
5604 | | - display.ReleaseTextures(tex); |
---|
| 6202 | + if (!failedBump) |
---|
| 6203 | + display.ReleaseBumpTexture(tex); |
---|
| 6204 | + |
---|
| 6205 | + if (!failedPigment) |
---|
| 6206 | + display.ReleasePigmentTexture(tex); |
---|
5605 | 6207 | |
---|
5606 | 6208 | display.PopMaterial(this, selected); |
---|
5607 | 6209 | } |
---|
.. | .. |
---|
5730 | 6332 | |
---|
5731 | 6333 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5732 | 6334 | { |
---|
| 6335 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6336 | + return; |
---|
| 6337 | + |
---|
5733 | 6338 | if (hide) |
---|
5734 | 6339 | return; |
---|
5735 | 6340 | // shadow optimisation |
---|
.. | .. |
---|
5855 | 6460 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5856 | 6461 | return; // no shadow for transparent objects |
---|
5857 | 6462 | |
---|
| 6463 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6464 | + return; |
---|
| 6465 | + |
---|
5858 | 6466 | if (hide) |
---|
5859 | 6467 | return; |
---|
5860 | 6468 | |
---|
.. | .. |
---|
5895 | 6503 | return; |
---|
5896 | 6504 | } |
---|
5897 | 6505 | |
---|
| 6506 | + //bRep.GenUV(1/material.diffuseness); |
---|
5898 | 6507 | // bRep.lock = true; |
---|
5899 | 6508 | |
---|
5900 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 6509 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5901 | 6510 | |
---|
5902 | 6511 | if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
5903 | 6512 | { |
---|
.. | .. |
---|
5914 | 6523 | |
---|
5915 | 6524 | bRep.getMinMax(min, max, 100); |
---|
5916 | 6525 | |
---|
5917 | | - gl.glBegin(gl.GL_LINES); |
---|
5918 | | - |
---|
5919 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5920 | | - gl.glVertex3d(min.x, min.y, max.z); |
---|
5921 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5922 | | - gl.glVertex3d(min.x, max.y, min.z); |
---|
5923 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5924 | | - gl.glVertex3d(max.x, min.y, min.z); |
---|
5925 | | - |
---|
5926 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5927 | | - gl.glVertex3d(min.x, max.y, max.z); |
---|
5928 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5929 | | - gl.glVertex3d(max.x, min.y, max.z); |
---|
5930 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5931 | | - gl.glVertex3d(max.x, max.y, min.z); |
---|
5932 | | - |
---|
5933 | | - gl.glEnd(); |
---|
| 6526 | + display.DrawBox(min, max); |
---|
5934 | 6527 | |
---|
5935 | 6528 | return; |
---|
5936 | 6529 | } |
---|
.. | .. |
---|
5984 | 6577 | new Exception().printStackTrace(); |
---|
5985 | 6578 | return; |
---|
5986 | 6579 | } |
---|
5987 | | - |
---|
5988 | | - // TRIANGLE STRIP ARRAY |
---|
5989 | | - if (bRep.trimmed) |
---|
| 6580 | + |
---|
| 6581 | + if (dontselect) |
---|
5990 | 6582 | { |
---|
5991 | | - float[] v = bRep.getRawVertices(); |
---|
5992 | | - float[] n = bRep.getRawNormals(); |
---|
5993 | | - float[] c = bRep.getRawColors(); |
---|
5994 | | - float[] uv = bRep.getRawUVMap(); |
---|
5995 | | - |
---|
5996 | | - int count2 = 0; |
---|
5997 | | - int count3 = 0; |
---|
5998 | | - |
---|
5999 | | - if (n.length > 0) |
---|
6000 | | - { |
---|
6001 | | - for (int i = 0; i < strips.length; i++) |
---|
6002 | | - { |
---|
6003 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6004 | | - |
---|
6005 | | - /* |
---|
6006 | | - boolean locked = false; |
---|
6007 | | - float eps = 0.1f; |
---|
6008 | | - boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
6009 | | - |
---|
6010 | | - int dot = 0; |
---|
6011 | | - |
---|
6012 | | - if ((dot&1) == 0) |
---|
6013 | | - dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
6014 | | - |
---|
6015 | | - if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
6016 | | - gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
6017 | | - else |
---|
6018 | | - { |
---|
6019 | | - locked = true; |
---|
6020 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6021 | | - } |
---|
6022 | | - //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
6023 | | - gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
6024 | | - if (hasnorm) |
---|
6025 | | - { |
---|
6026 | | - //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
6027 | | - gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
6028 | | - } |
---|
6029 | | - |
---|
6030 | | - if ((dot&4) == 0) |
---|
6031 | | - dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
6032 | | - |
---|
6033 | | - if (wrap || !locked && (dot&8) != 0) |
---|
6034 | | - gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
6035 | | - else |
---|
6036 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6037 | | - |
---|
6038 | | - f.dot = dot; |
---|
6039 | | - */ |
---|
6040 | | - |
---|
6041 | | - if (!selectmode) |
---|
6042 | | - { |
---|
6043 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6044 | | - { |
---|
6045 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6046 | | - } else |
---|
6047 | | - { |
---|
6048 | | - gl.glNormal3f(0, 0, 1); |
---|
6049 | | - } |
---|
6050 | | - |
---|
6051 | | - if (c != null) |
---|
6052 | | - //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
6053 | | - { |
---|
6054 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6055 | | - } |
---|
6056 | | - } |
---|
6057 | | - if (flipV) |
---|
6058 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6059 | | - else |
---|
6060 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6061 | | - //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6062 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6063 | | - |
---|
6064 | | - count2 += 2; |
---|
6065 | | - count3 += 3; |
---|
6066 | | - if (!selectmode) |
---|
6067 | | - { |
---|
6068 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6069 | | - { |
---|
6070 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6071 | | - } else |
---|
6072 | | - { |
---|
6073 | | - gl.glNormal3f(0, 0, 1); |
---|
6074 | | - } |
---|
6075 | | - if (c != null) |
---|
6076 | | - { |
---|
6077 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6078 | | - } |
---|
6079 | | - } |
---|
6080 | | - if (flipV) |
---|
6081 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6082 | | - else |
---|
6083 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6084 | | - //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6085 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6086 | | - |
---|
6087 | | - count2 += 2; |
---|
6088 | | - count3 += 3; |
---|
6089 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6090 | | - { |
---|
6091 | | - //gl.glTexCoord2d(...); |
---|
6092 | | - if (!selectmode) |
---|
6093 | | - { |
---|
6094 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6095 | | - { |
---|
6096 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6097 | | - } else |
---|
6098 | | - { |
---|
6099 | | - gl.glNormal3f(0, 0, 1); |
---|
6100 | | - } |
---|
6101 | | - if (c != null) |
---|
6102 | | - { |
---|
6103 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6104 | | - } |
---|
6105 | | - } |
---|
6106 | | - |
---|
6107 | | - if (flipV) |
---|
6108 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6109 | | - else |
---|
6110 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6111 | | - //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
6112 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6113 | | - count2 += 2; |
---|
6114 | | - count3 += 3; |
---|
6115 | | - } |
---|
6116 | | - |
---|
6117 | | - gl.glEnd(); |
---|
6118 | | - } |
---|
6119 | | - } |
---|
6120 | | - |
---|
6121 | | - assert count3 == v.length; |
---|
| 6583 | + //bRep.GenerateNormalsMINE(); |
---|
6122 | 6584 | } |
---|
6123 | | - else // !trimmed |
---|
6124 | | - { |
---|
6125 | | - int count = 0; |
---|
6126 | | - for (int i = 0; i < strips.length; i++) |
---|
6127 | | - { |
---|
6128 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6129 | | - |
---|
6130 | | - Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
6131 | | - Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
6132 | | - |
---|
6133 | | - drawVertex(gl, p, selectmode); |
---|
6134 | | - drawVertex(gl, q, selectmode); |
---|
6135 | | - |
---|
6136 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6137 | | - { |
---|
6138 | | - Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
6139 | | - |
---|
6140 | | -// if (j%2 == 0) |
---|
6141 | | -// drawFace(p, q, r, display, null); |
---|
6142 | | -// else |
---|
6143 | | -// drawFace(p, r, q, display, null); |
---|
6144 | | - |
---|
6145 | | -// p = q; |
---|
6146 | | -// q = r; |
---|
6147 | | - drawVertex(gl, r, selectmode); |
---|
6148 | | - } |
---|
6149 | | - |
---|
6150 | | - gl.glEnd(); |
---|
6151 | | - } |
---|
6152 | | - } |
---|
| 6585 | + |
---|
| 6586 | + display.DrawGeometry(bRep, flipV, selectmode); |
---|
6153 | 6587 | } else // catch (Error e) |
---|
6154 | 6588 | { |
---|
6155 | 6589 | // TRIANGLE ARRAY |
---|
6156 | 6590 | if (IsOpaque()) // Static()) |
---|
6157 | 6591 | { |
---|
6158 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6592 | + display.StartTriangles(); |
---|
6159 | 6593 | int facecount = bRep.FaceCount(); |
---|
6160 | 6594 | for (int i = 0; i < facecount; i++) |
---|
6161 | 6595 | { |
---|
.. | .. |
---|
6220 | 6654 | |
---|
6221 | 6655 | display.DrawFace(this, p, q, r, face); |
---|
6222 | 6656 | } |
---|
6223 | | - gl.glEnd(); |
---|
| 6657 | + display.EndTriangles(); |
---|
6224 | 6658 | } |
---|
6225 | 6659 | else |
---|
6226 | 6660 | { |
---|
.. | .. |
---|
6249 | 6683 | //System.out.println("SORT"); |
---|
6250 | 6684 | |
---|
6251 | 6685 | java.util.Arrays.sort(facescompare); |
---|
6252 | | - |
---|
6253 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6686 | + |
---|
| 6687 | + display.StartTriangles(); |
---|
6254 | 6688 | for (int i = 0; i < facecount; i++) |
---|
6255 | 6689 | { |
---|
6256 | 6690 | Face face = bRep.GetFace(facescompare[i].index); |
---|
.. | .. |
---|
6264 | 6698 | |
---|
6265 | 6699 | display.DrawFace(this, p, q, r, face); |
---|
6266 | 6700 | } |
---|
6267 | | - gl.glEnd(); |
---|
| 6701 | + display.EndTriangles(); |
---|
6268 | 6702 | } |
---|
6269 | 6703 | |
---|
6270 | 6704 | if (false) // live && support != null && support.bRep != null) // debug weights |
---|
6271 | 6705 | { |
---|
| 6706 | + /* |
---|
6272 | 6707 | gl.glDisable(gl.GL_LIGHTING); |
---|
6273 | 6708 | float[] colorV = new float[3]; |
---|
6274 | 6709 | |
---|
.. | .. |
---|
6347 | 6782 | // gl.glEnd(); |
---|
6348 | 6783 | } |
---|
6349 | 6784 | } |
---|
| 6785 | + */ |
---|
6350 | 6786 | } |
---|
6351 | 6787 | } |
---|
6352 | 6788 | |
---|
.. | .. |
---|
6391 | 6827 | center.add(r); |
---|
6392 | 6828 | center.mul(1.0/3); |
---|
6393 | 6829 | |
---|
6394 | | - center.sub(CameraPane.theRenderer.eyeCamera.location); |
---|
| 6830 | + center.sub(Globals.theRenderer.EyeCamera().location); |
---|
6395 | 6831 | |
---|
6396 | 6832 | distance = center.dot(center); |
---|
6397 | 6833 | } |
---|
.. | .. |
---|
6405 | 6841 | void Print(Vertex v) |
---|
6406 | 6842 | { |
---|
6407 | 6843 | //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")"); |
---|
6408 | | - } |
---|
6409 | | - |
---|
6410 | | - void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode) |
---|
6411 | | - { |
---|
6412 | | - if (!selectmode) |
---|
6413 | | - { |
---|
6414 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
6415 | | - gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
6416 | | - |
---|
6417 | | - if (flipV) |
---|
6418 | | - gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
6419 | | - else |
---|
6420 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6421 | | - } |
---|
6422 | | - |
---|
6423 | | - gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
6424 | 6844 | } |
---|
6425 | 6845 | |
---|
6426 | 6846 | void drawSelf(ClickInfo info, int level, boolean select) |
---|
.. | .. |
---|
6946 | 7366 | } |
---|
6947 | 7367 | } |
---|
6948 | 7368 | |
---|
6949 | | - protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec) |
---|
| 7369 | + static ClickInfo clickInfo = new ClickInfo(); |
---|
| 7370 | + |
---|
| 7371 | + protected void calcHotSpot(cVector in, //ClickInfo clickInfo, |
---|
| 7372 | + Point outPt, Rectangle outRec) |
---|
6950 | 7373 | { |
---|
6951 | | - int hc = info.bounds.x + info.bounds.width / 2; |
---|
6952 | | - int vc = info.bounds.y + info.bounds.height / 2; |
---|
6953 | | - double[][] toscreen = info.toScreen; |
---|
| 7374 | + int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2; |
---|
| 7375 | + int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2; |
---|
| 7376 | + double[][] toscreen = clickInfo.toScreen; |
---|
6954 | 7377 | if (toscreen == null) |
---|
6955 | 7378 | { |
---|
6956 | | - toscreen = new Camera(info.camera.viewCode).toScreen; |
---|
| 7379 | + toscreen = new Camera(clickInfo.camera.viewCode).toScreen; |
---|
6957 | 7380 | } |
---|
6958 | 7381 | cVector vec = in; |
---|
6959 | 7382 | LA.xformPos(in, toscreen, in); |
---|
6960 | 7383 | //System.out.println("Distance = " + info.camera.Distance()); |
---|
6961 | | - vec.x *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
6962 | | - vec.y *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
| 7384 | + vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
| 7385 | + vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
6963 | 7386 | outPt.x = hc + (int) vec.x; |
---|
6964 | 7387 | outPt.y = vc - (int) vec.y; |
---|
6965 | 7388 | outRec.x = outPt.x - 3; |
---|
.. | .. |
---|
6967 | 7390 | outRec.width = outRec.height = 6; |
---|
6968 | 7391 | } |
---|
6969 | 7392 | |
---|
6970 | | - protected Rectangle calcHotSpot(cVector in, ClickInfo info) |
---|
| 7393 | + protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo |
---|
| 7394 | + ) |
---|
6971 | 7395 | { |
---|
6972 | 7396 | Point pt = new Point(0, 0); |
---|
6973 | 7397 | Rectangle rec = new Rectangle(); |
---|
6974 | | - calcHotSpot(in, info, pt, rec); |
---|
| 7398 | + calcHotSpot(in, //clickInfo, |
---|
| 7399 | + pt, rec); |
---|
6975 | 7400 | return rec; |
---|
6976 | 7401 | } |
---|
6977 | 7402 | |
---|
6978 | | - void drawEditHandles0(ClickInfo info, int level) |
---|
| 7403 | + void drawEditHandles0(//ClickInfo clickInfo, |
---|
| 7404 | + int level) |
---|
6979 | 7405 | { |
---|
6980 | 7406 | if (level == 0) |
---|
6981 | 7407 | { |
---|
.. | .. |
---|
6984 | 7410 | { |
---|
6985 | 7411 | cVector origin = new cVector(); |
---|
6986 | 7412 | //LA.xformPos(origin, toParent, origin); |
---|
6987 | | - Rectangle spot = calcHotSpot(origin, info); |
---|
| 7413 | + if (this.clickInfo == null) |
---|
| 7414 | + this.clickInfo = new ClickInfo(); |
---|
| 7415 | + |
---|
| 7416 | + Rectangle spot = calcHotSpot(origin); //, clickInfo); |
---|
6988 | 7417 | Rectangle boundary = new Rectangle(); |
---|
6989 | 7418 | boundary.x = spot.x - 30; |
---|
6990 | 7419 | boundary.y = spot.y - 30; |
---|
6991 | 7420 | boundary.width = spot.width + 60; |
---|
6992 | 7421 | boundary.height = spot.height + 60; |
---|
6993 | | - info.g.setColor(Color.red); |
---|
| 7422 | + clickInfo.g.setColor(Color.white); |
---|
6994 | 7423 | int spotw = spot.x + spot.width; |
---|
6995 | 7424 | int spoth = spot.y + spot.height; |
---|
6996 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7425 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6997 | 7426 | // if (CameraPane.Xmin > spot.x) |
---|
6998 | 7427 | // { |
---|
6999 | 7428 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7010 | 7439 | // { |
---|
7011 | 7440 | // CameraPane.Ymax = spoth; |
---|
7012 | 7441 | // } |
---|
7013 | | - spot.translate(32, 32); |
---|
| 7442 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7443 | +// { |
---|
| 7444 | +// CameraPane.Xmin = spot.x; |
---|
| 7445 | +// } |
---|
| 7446 | +// if (CameraPane.Xmax < spotw) |
---|
| 7447 | +// { |
---|
| 7448 | +// CameraPane.Xmax = spotw; |
---|
| 7449 | +// } |
---|
| 7450 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7451 | +// { |
---|
| 7452 | +// CameraPane.Ymin = spot.y; |
---|
| 7453 | +// } |
---|
| 7454 | +// if (CameraPane.Ymax < spoth) |
---|
| 7455 | +// { |
---|
| 7456 | +// CameraPane.Ymax = spoth; |
---|
| 7457 | +// } |
---|
| 7458 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7459 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
| 7460 | + spot.translate(32, 0); |
---|
| 7461 | + clickInfo.g.setColor(Color.yellow); |
---|
| 7462 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7463 | + |
---|
| 7464 | + spot.translate(32, 64); |
---|
7014 | 7465 | spotw = spot.x + spot.width; |
---|
7015 | 7466 | spoth = spot.y + spot.height; |
---|
7016 | | - info.g.setColor(Color.blue); |
---|
7017 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7467 | + clickInfo.g.setColor(Color.cyan); |
---|
| 7468 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7018 | 7469 | // if (CameraPane.Xmin > spot.x) |
---|
7019 | 7470 | // { |
---|
7020 | 7471 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7031 | 7482 | // { |
---|
7032 | 7483 | // CameraPane.Ymax = spoth; |
---|
7033 | 7484 | // } |
---|
7034 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
7035 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
7036 | | - spot.translate(0, -32); |
---|
7037 | | - info.g.setColor(Color.green); |
---|
7038 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7039 | | -// if (CameraPane.Xmin > spot.x) |
---|
7040 | | -// { |
---|
7041 | | -// CameraPane.Xmin = spot.x; |
---|
7042 | | -// } |
---|
7043 | | -// if (CameraPane.Xmax < spotw) |
---|
7044 | | -// { |
---|
7045 | | -// CameraPane.Xmax = spotw; |
---|
7046 | | -// } |
---|
7047 | | -// if (CameraPane.Ymin > spot.y) |
---|
7048 | | -// { |
---|
7049 | | -// CameraPane.Ymin = spot.y; |
---|
7050 | | -// } |
---|
7051 | | -// if (CameraPane.Ymax < spoth) |
---|
7052 | | -// { |
---|
7053 | | -// CameraPane.Ymax = spoth; |
---|
7054 | | -// } |
---|
7055 | | - info.g.drawArc(boundary.x, boundary.y, |
---|
7056 | | - boundary.width, boundary.height, 0, 360); |
---|
| 7485 | + clickInfo.g.setColor(Color.green); |
---|
| 7486 | + clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, |
---|
| 7487 | + (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); |
---|
7057 | 7488 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
7058 | 7489 | // if (CameraPane.Xmin > boundary.x) |
---|
7059 | 7490 | // { |
---|
.. | .. |
---|
7075 | 7506 | } |
---|
7076 | 7507 | } |
---|
7077 | 7508 | |
---|
7078 | | - boolean doEditClick0(ClickInfo info, int level) |
---|
| 7509 | + boolean doEditClick0(//ClickInfo clickInfo, |
---|
| 7510 | + int level) |
---|
7079 | 7511 | { |
---|
7080 | 7512 | if (level == 0) |
---|
7081 | 7513 | { |
---|
.. | .. |
---|
7084 | 7516 | |
---|
7085 | 7517 | boolean retval = false; |
---|
7086 | 7518 | |
---|
7087 | | - startX = info.x; |
---|
7088 | | - startY = info.y; |
---|
| 7519 | + startX = clickInfo.x; |
---|
| 7520 | + startY = clickInfo.y; |
---|
7089 | 7521 | |
---|
7090 | | - hitSomething = 0; |
---|
| 7522 | + hitSomething = -1; |
---|
7091 | 7523 | cVector origin = new cVector(); |
---|
7092 | 7524 | //LA.xformPos(origin, toParent, origin); |
---|
7093 | 7525 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7095 | 7527 | { |
---|
7096 | 7528 | centerPt = new Point(0, 0); |
---|
7097 | 7529 | } |
---|
7098 | | - calcHotSpot(origin, info, centerPt, spot); |
---|
7099 | | - if (spot.contains(info.x, info.y)) |
---|
| 7530 | + calcHotSpot(origin, //info, |
---|
| 7531 | + centerPt, spot); |
---|
| 7532 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7100 | 7533 | { |
---|
7101 | 7534 | hitSomething = hitCenter; |
---|
7102 | 7535 | retval = true; |
---|
7103 | 7536 | } |
---|
7104 | 7537 | spot.translate(32, 0); |
---|
7105 | | - if (spot.contains(info.x, info.y)) |
---|
| 7538 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7106 | 7539 | { |
---|
7107 | 7540 | hitSomething = hitRotate; |
---|
7108 | 7541 | retval = true; |
---|
7109 | 7542 | } |
---|
7110 | 7543 | spot.translate(0, 32); |
---|
7111 | | - if (spot.contains(info.x, info.y)) |
---|
| 7544 | + spot.translate(32, 0); |
---|
| 7545 | + spot.translate(0, 32); |
---|
| 7546 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7112 | 7547 | { |
---|
7113 | 7548 | hitSomething = hitScale; |
---|
| 7549 | + |
---|
| 7550 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7551 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
| 7552 | + double sign = 1; |
---|
| 7553 | + if (hScale < 0) |
---|
| 7554 | + { |
---|
| 7555 | + sign = -1; |
---|
| 7556 | + } |
---|
| 7557 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
| 7558 | + if (hScale < 0.01) |
---|
| 7559 | + { |
---|
| 7560 | + //hScale = 0.01; |
---|
| 7561 | + } |
---|
| 7562 | + |
---|
| 7563 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
| 7564 | + sign = 1; |
---|
| 7565 | + if (vScale < 0) |
---|
| 7566 | + { |
---|
| 7567 | + sign = -1; |
---|
| 7568 | + } |
---|
| 7569 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
| 7570 | + if (vScale < 0.01) |
---|
| 7571 | + { |
---|
| 7572 | + //vScale = 0.01; |
---|
| 7573 | + } |
---|
| 7574 | + |
---|
| 7575 | + clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale); |
---|
| 7576 | + |
---|
7114 | 7577 | retval = true; |
---|
7115 | 7578 | } |
---|
7116 | 7579 | |
---|
.. | .. |
---|
7120 | 7583 | } |
---|
7121 | 7584 | |
---|
7122 | 7585 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7123 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7586 | + modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7124 | 7587 | //System.out.println("modified = " + modified); |
---|
7125 | 7588 | //new Exception().printStackTrace(); |
---|
7126 | 7589 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7148 | 7611 | return true; |
---|
7149 | 7612 | } |
---|
7150 | 7613 | |
---|
7151 | | - void doEditDrag0(ClickInfo info) |
---|
| 7614 | + void doEditDrag0(//ClickInfo info, |
---|
| 7615 | + boolean opposite) |
---|
7152 | 7616 | { |
---|
7153 | 7617 | if (hitSomething == 0) |
---|
7154 | 7618 | { |
---|
.. | .. |
---|
7162 | 7626 | |
---|
7163 | 7627 | //System.out.println("hitSomething = " + hitSomething); |
---|
7164 | 7628 | |
---|
7165 | | - double scale = 0.005f * info.camera.Distance(); |
---|
| 7629 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7630 | + |
---|
7166 | 7631 | cVector xlate = new cVector(); |
---|
7167 | 7632 | //cVector xlate2 = new cVector(); |
---|
7168 | 7633 | switch (hitSomething) |
---|
.. | .. |
---|
7173 | 7638 | |
---|
7174 | 7639 | case hitCenter: // Translate |
---|
7175 | 7640 | |
---|
7176 | | - scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance(); |
---|
| 7641 | + scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7177 | 7642 | |
---|
7178 | | - if (modified) |
---|
| 7643 | + if (modified || opposite) |
---|
7179 | 7644 | { |
---|
7180 | 7645 | //assert(false); |
---|
7181 | 7646 | /* |
---|
.. | .. |
---|
7195 | 7660 | toParent[3][i] = xlate.get(i); |
---|
7196 | 7661 | LA.matInvert(toParent, fromParent); |
---|
7197 | 7662 | */ |
---|
7198 | | - cVector delta = LA.newVector(0, 0, startY - info.y); |
---|
7199 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7663 | + cVector delta = LA.newVector(0, 0, startY - clickInfo.y); |
---|
| 7664 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7200 | 7665 | |
---|
7201 | 7666 | LA.matCopy(startMat, toParent); |
---|
7202 | 7667 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7205 | 7670 | } else |
---|
7206 | 7671 | { |
---|
7207 | 7672 | //LA.xformDir(delta, info.camera.fromScreen, delta); |
---|
7208 | | - cVector up = new cVector(info.camera.up); |
---|
| 7673 | + cVector up = new cVector(clickInfo.camera.up); |
---|
7209 | 7674 | cVector away = new cVector(); |
---|
7210 | 7675 | //cVector right2 = new cVector(); |
---|
7211 | 7676 | //LA.vecCross(up, cVector.Z, right); |
---|
.. | .. |
---|
7221 | 7686 | } |
---|
7222 | 7687 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7223 | 7688 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7224 | | - LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up); |
---|
7225 | | - LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
| 7689 | + LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
| 7690 | + LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away); |
---|
7226 | 7691 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7227 | | - LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away); |
---|
| 7692 | + LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7228 | 7693 | //LA.vecCross(up, cVector.Z, right2); |
---|
7229 | 7694 | |
---|
7230 | | - cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
| 7695 | + cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0); |
---|
7231 | 7696 | |
---|
7232 | 7697 | //System.out.println("DELTA0 = " + delta); |
---|
7233 | 7698 | //System.out.println("AWAY = " + info.camera.away); |
---|
7234 | 7699 | //System.out.println("UP = " + info.camera.up); |
---|
7235 | 7700 | if (away.z > 0) |
---|
7236 | 7701 | { |
---|
7237 | | - if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
| 7702 | + if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
7238 | 7703 | { |
---|
7239 | 7704 | delta.x = -delta.x; |
---|
7240 | 7705 | } else |
---|
.. | .. |
---|
7249 | 7714 | //System.out.println("DELTA1 = " + delta); |
---|
7250 | 7715 | LA.xformDir(delta, ClickInfo.matbuffer, delta); |
---|
7251 | 7716 | //System.out.println("DELTA2 = " + delta); |
---|
7252 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7717 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7253 | 7718 | LA.matCopy(startMat, toParent); |
---|
7254 | 7719 | //System.out.println("DELTA3 = " + delta); |
---|
7255 | 7720 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7259 | 7724 | break; |
---|
7260 | 7725 | |
---|
7261 | 7726 | case hitRotate: // rotate |
---|
7262 | | - int dx = info.x - centerPt.x; |
---|
7263 | | - int dy = -(info.y - centerPt.y); |
---|
| 7727 | + int dx = clickInfo.x - centerPt.x; |
---|
| 7728 | + int dy = -(clickInfo.y - centerPt.y); |
---|
7264 | 7729 | double angle = (double) Math.atan2(dx, dy); |
---|
7265 | 7730 | angle = -(1.570796 - angle); |
---|
7266 | 7731 | |
---|
.. | .. |
---|
7269 | 7734 | |
---|
7270 | 7735 | if (modified) |
---|
7271 | 7736 | { |
---|
| 7737 | + // Rotate 90 degrees |
---|
7272 | 7738 | angle /= (Math.PI / 4); |
---|
7273 | 7739 | angle = Math.floor(angle + 0.5); |
---|
7274 | 7740 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7282 | 7748 | } |
---|
7283 | 7749 | /**/ |
---|
7284 | 7750 | |
---|
7285 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7751 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7286 | 7752 | { |
---|
7287 | 7753 | case 1: // '\001' |
---|
7288 | 7754 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7309 | 7775 | break; |
---|
7310 | 7776 | |
---|
7311 | 7777 | case hitScale: // scale |
---|
7312 | | - double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7778 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
| 7779 | + double sign = 1; |
---|
| 7780 | + if (hScale < 0) |
---|
| 7781 | + { |
---|
| 7782 | + sign = -1; |
---|
| 7783 | + } |
---|
| 7784 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7313 | 7785 | if (hScale < 0.01) |
---|
7314 | 7786 | { |
---|
7315 | | - hScale = 0.01; |
---|
| 7787 | + //hScale = 0.01; |
---|
7316 | 7788 | } |
---|
7317 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7318 | | - if (hScale < 0.01) |
---|
| 7789 | + |
---|
| 7790 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
| 7791 | + sign = 1; |
---|
| 7792 | + if (vScale < 0) |
---|
7319 | 7793 | { |
---|
7320 | | - hScale = 0.01; |
---|
| 7794 | + sign = -1; |
---|
7321 | 7795 | } |
---|
7322 | | - double vScale = (double) (info.y - centerPt.y) / 32; |
---|
| 7796 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7323 | 7797 | if (vScale < 0.01) |
---|
7324 | 7798 | { |
---|
7325 | | - vScale = 0.01; |
---|
| 7799 | + //vScale = 0.01; |
---|
7326 | 7800 | } |
---|
7327 | | - vScale = Math.pow(vScale, scale * 50); |
---|
7328 | | - if (vScale < 0.01) |
---|
7329 | | - { |
---|
7330 | | - vScale = 0.01; |
---|
7331 | | - } |
---|
| 7801 | + |
---|
7332 | 7802 | LA.matCopy(startMat, toParent); |
---|
7333 | 7803 | /**/ |
---|
7334 | 7804 | for (int i = 0; i < 3; i++) |
---|
.. | .. |
---|
7338 | 7808 | } |
---|
7339 | 7809 | /**/ |
---|
7340 | 7810 | |
---|
7341 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7811 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale; |
---|
| 7812 | + |
---|
| 7813 | + if (totalScale < 0.01) |
---|
| 7814 | + { |
---|
| 7815 | + totalScale = 0.01; |
---|
| 7816 | + } |
---|
| 7817 | + |
---|
| 7818 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7342 | 7819 | { |
---|
7343 | 7820 | case 3: // '\001' |
---|
7344 | | - if (modified) |
---|
| 7821 | + if (modified || opposite) |
---|
7345 | 7822 | { |
---|
| 7823 | + if (modified && opposite) |
---|
| 7824 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 7825 | + else |
---|
7346 | 7826 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7347 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7827 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7348 | 7828 | } // vScale, 1); |
---|
7349 | 7829 | else |
---|
7350 | 7830 | { |
---|
7351 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7831 | + // EXCEPTION! |
---|
| 7832 | + LA.matScale(toParent, 1, totalScale, totalScale); |
---|
7352 | 7833 | } // vScale, 1); |
---|
7353 | 7834 | break; |
---|
7354 | 7835 | |
---|
7355 | 7836 | case 2: // '\002' |
---|
7356 | | - if (modified) |
---|
| 7837 | + if (modified || opposite) |
---|
7357 | 7838 | { |
---|
7358 | | - //LA.matScale(toParent, hScale, 1, vScale); |
---|
7359 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7839 | + if (modified && opposite) |
---|
| 7840 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 7841 | + else |
---|
| 7842 | + //LA.matScale(toParent, hScale, 1, vScale); |
---|
| 7843 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7360 | 7844 | } else |
---|
7361 | 7845 | { |
---|
7362 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7846 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7363 | 7847 | } |
---|
7364 | 7848 | break; |
---|
7365 | 7849 | |
---|
7366 | 7850 | case 1: // '\003' |
---|
7367 | | - if (modified) |
---|
| 7851 | + if (modified || opposite) |
---|
7368 | 7852 | { |
---|
7369 | | - //LA.matScale(toParent, hScale, vScale, 1); |
---|
7370 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7853 | + if (modified && opposite) |
---|
| 7854 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 7855 | + else |
---|
| 7856 | + //LA.matScale(toParent, hScale, vScale, 1); |
---|
| 7857 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7371 | 7858 | } else |
---|
7372 | 7859 | { |
---|
7373 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7860 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7374 | 7861 | } |
---|
7375 | 7862 | break; |
---|
7376 | 7863 | } |
---|
.. | .. |
---|
7404 | 7891 | } // NEW ... |
---|
7405 | 7892 | |
---|
7406 | 7893 | |
---|
7407 | | - info.pane.repaint(); |
---|
| 7894 | + clickInfo.pane.repaint(); |
---|
7408 | 7895 | } |
---|
7409 | 7896 | |
---|
7410 | 7897 | boolean overflow = false; |
---|
.. | .. |
---|
7503 | 7990 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7504 | 7991 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7505 | 7992 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7993 | + |
---|
| 7994 | + String objname; |
---|
| 7995 | + |
---|
7506 | 7996 | if (false) //parent != null) |
---|
7507 | 7997 | { |
---|
7508 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7998 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7509 | 7999 | } else |
---|
7510 | 8000 | { |
---|
7511 | | - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); |
---|
| 8001 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7512 | 8002 | } // + super.toString(); |
---|
7513 | 8003 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
| 8004 | + |
---|
| 8005 | + if (!Globals.ADVANCED) |
---|
| 8006 | + return objname; |
---|
| 8007 | + |
---|
| 8008 | + return objname + " " + System.identityHashCode(this); |
---|
7514 | 8009 | } |
---|
7515 | 8010 | |
---|
7516 | 8011 | public int hashCode() |
---|
.. | .. |
---|
7566 | 8061 | objectUI.closeUI(); |
---|
7567 | 8062 | if (editWindow != null) |
---|
7568 | 8063 | { |
---|
| 8064 | + editWindow.ctrlPanel.FlushUI(); |
---|
7569 | 8065 | editWindow.refreshContents(); |
---|
7570 | 8066 | } // ? new |
---|
7571 | 8067 | objectUI = null; |
---|
.. | .. |
---|
7574 | 8070 | { |
---|
7575 | 8071 | editWindow = null; |
---|
7576 | 8072 | } // ? |
---|
| 8073 | + } |
---|
| 8074 | + else |
---|
| 8075 | + { |
---|
| 8076 | + //editWindow.closeUI(); |
---|
7577 | 8077 | } |
---|
7578 | 8078 | } |
---|
7579 | 8079 | |
---|
.. | .. |
---|
7586 | 8086 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7587 | 8087 | |
---|
7588 | 8088 | Object3D /*Composite*/ parent; |
---|
7589 | | - Object3D /*Composite*/ fileparent; |
---|
| 8089 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7590 | 8090 | |
---|
7591 | 8091 | double[][] toParent; // dynamic matrix |
---|
7592 | 8092 | double[][] fromParent; |
---|
.. | .. |
---|
7701 | 8201 | { |
---|
7702 | 8202 | assert(bRep != null); |
---|
7703 | 8203 | if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
7704 | | - GrafreeD.Assert(support.bRep == bRep.support); |
---|
| 8204 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
7705 | 8205 | } |
---|
7706 | 8206 | else |
---|
7707 | 8207 | { |
---|
.. | .. |
---|
7732 | 8232 | } |
---|
7733 | 8233 | |
---|
7734 | 8234 | transient ObjEditor editWindow; |
---|
| 8235 | + transient ObjEditor manipWindow; |
---|
| 8236 | + |
---|
| 8237 | + transient boolean pinned; |
---|
| 8238 | + |
---|
7735 | 8239 | transient ObjectUI objectUI; |
---|
7736 | 8240 | public static int povDepth = 0; |
---|
7737 | 8241 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
7750 | 8254 | private static cVector edge2 = new cVector(); |
---|
7751 | 8255 | //private static cVector norm = new cVector(); |
---|
7752 | 8256 | /*transient private*/ int hitSomething; |
---|
7753 | | - private static final int hitCenter = 1; |
---|
7754 | | - private static final int hitScale = 2; |
---|
7755 | | - private static final int hitRotate = 3; |
---|
| 8257 | + static final int hitCenter = 1; |
---|
| 8258 | + static final int hitScale = 2; |
---|
| 8259 | + static final int hitRotate = 3; |
---|
7756 | 8260 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7757 | 8261 | /*transient*/ private Point centerPt; |
---|
7758 | 8262 | /*transient*/ private int startX; |
---|