.. | .. |
---|
14 | 14 | import //weka.core. |
---|
15 | 15 | matrix.Matrix; |
---|
16 | 16 | |
---|
| 17 | +import java.util.UUID; |
---|
| 18 | + |
---|
17 | 19 | //import net.sourceforge.sizeof.SizeOf; |
---|
18 | 20 | public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> |
---|
19 | 21 | { |
---|
20 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
21 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
22 | 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 | + |
---|
23 | 39 | ScriptNode scriptnode; |
---|
24 | 40 | |
---|
25 | 41 | void InitOthers() |
---|
.. | .. |
---|
100 | 116 | |
---|
101 | 117 | // transient boolean reduced; // for morph reduction |
---|
102 | 118 | |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
104 | | -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
| 119 | + transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
| 120 | + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
105 | 121 | |
---|
106 | | -transient Object3D transientsupport; // for cloning |
---|
107 | | -transient boolean transientlink2master; |
---|
| 122 | + transient Object3D transientsupport; // for cloning |
---|
| 123 | + transient boolean transientlink2master; |
---|
108 | 124 | |
---|
109 | | -void SaveSupports() |
---|
110 | | -{ |
---|
111 | | - if (blockloop) |
---|
112 | | - return; |
---|
113 | | - |
---|
114 | | - transientsupport = support; |
---|
115 | | - transientlink2master = link2master; |
---|
116 | | - |
---|
117 | | - support = null; |
---|
118 | | - link2master = false; |
---|
119 | | - |
---|
120 | | - if (bRep != null) |
---|
| 125 | + void SaveSupports() |
---|
121 | 126 | { |
---|
122 | | - bRep.SaveSupports(); |
---|
| 127 | + if (blockloop) |
---|
| 128 | + return; |
---|
| 129 | + |
---|
| 130 | + transientsupport = support; |
---|
| 131 | + transientlink2master = link2master; |
---|
| 132 | + |
---|
| 133 | + support = null; |
---|
| 134 | + link2master = false; |
---|
| 135 | + |
---|
| 136 | + if (bRep != null) |
---|
| 137 | + { |
---|
| 138 | + bRep.SaveSupports(); |
---|
| 139 | + } |
---|
| 140 | + |
---|
| 141 | + for (int i = 0; i < Size(); i++) |
---|
| 142 | + { |
---|
| 143 | + Object3D child = (Object3D) get(i); |
---|
| 144 | + if (child == null) |
---|
| 145 | + continue; |
---|
| 146 | + blockloop = true; |
---|
| 147 | + child.SaveSupports(); |
---|
| 148 | + blockloop = false; |
---|
| 149 | + } |
---|
123 | 150 | } |
---|
124 | | - |
---|
125 | | - for (int i = 0; i < Size(); i++) |
---|
| 151 | + |
---|
| 152 | + void RestoreSupports() |
---|
126 | 153 | { |
---|
127 | | - Object3D child = (Object3D) get(i); |
---|
128 | | - if (child == null) |
---|
129 | | - continue; |
---|
| 154 | + if (blockloop) |
---|
| 155 | + return; |
---|
| 156 | + |
---|
| 157 | + support = transientsupport; |
---|
| 158 | + link2master = transientlink2master; |
---|
| 159 | + transientsupport = null; |
---|
| 160 | + transientlink2master = false; |
---|
| 161 | + |
---|
| 162 | + if (bRep != null) |
---|
| 163 | + { |
---|
| 164 | + bRep.RestoreSupports(); |
---|
| 165 | + } |
---|
| 166 | + |
---|
| 167 | + for (int i = 0; i < Size(); i++) |
---|
| 168 | + { |
---|
| 169 | + Object3D child = (Object3D) get(i); |
---|
| 170 | + if (child == null) |
---|
| 171 | + continue; |
---|
| 172 | + blockloop = true; |
---|
| 173 | + child.RestoreSupports(); |
---|
| 174 | + blockloop = false; |
---|
| 175 | + } |
---|
| 176 | + } |
---|
| 177 | + |
---|
| 178 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 179 | + { |
---|
| 180 | + Object3D o; |
---|
| 181 | + |
---|
| 182 | + if (hashtable.containsKey(GetUUID())) |
---|
| 183 | + { |
---|
| 184 | + o = hashtable.get(GetUUID()); |
---|
| 185 | + |
---|
| 186 | + Grafreed.Assert(this.bRep == o.bRep); |
---|
| 187 | + //if (this.bRep != null) |
---|
| 188 | + // assert(this.bRep.support == o.transientrep); |
---|
| 189 | + if (this.support != null) |
---|
| 190 | + assert(this.support.bRep == o.transientrep); |
---|
| 191 | + } |
---|
| 192 | + else |
---|
| 193 | + { |
---|
| 194 | + o = new Object3D("copy of " + this.name); |
---|
| 195 | + |
---|
| 196 | + hashtable.put(GetUUID(), o); |
---|
| 197 | + } |
---|
| 198 | + |
---|
| 199 | + if (!blockloop) |
---|
| 200 | + { |
---|
| 201 | + blockloop = true; |
---|
| 202 | + |
---|
| 203 | + for (int i=0; i<Size(); i++) |
---|
| 204 | + { |
---|
| 205 | + get(i).ExtractBigData(hashtable); |
---|
| 206 | + } |
---|
| 207 | + |
---|
| 208 | + blockloop = false; |
---|
| 209 | + } |
---|
| 210 | + |
---|
| 211 | + ExtractBigData(o); |
---|
| 212 | + } |
---|
| 213 | + |
---|
| 214 | + void ExtractBigData(Object3D o) |
---|
| 215 | + { |
---|
| 216 | + if (o.bRep != null) |
---|
| 217 | + Grafreed.Assert(o.bRep == this.bRep); |
---|
| 218 | + |
---|
| 219 | + o.bRep = this.bRep; |
---|
| 220 | +// July 2019 if (this.bRep != null) |
---|
| 221 | +// { |
---|
| 222 | +// o.transientrep = this.bRep.support; |
---|
| 223 | +// o.bRep.support = null; |
---|
| 224 | +// } |
---|
| 225 | + o.selection = this.selection; |
---|
| 226 | + o.versionlist = this.versionlist; |
---|
| 227 | + o.versionindex = this.versionindex; |
---|
| 228 | + |
---|
| 229 | + if (this.support != null) |
---|
| 230 | + { |
---|
| 231 | + if (o.transientrep != null) |
---|
| 232 | + Grafreed.Assert(o.transientrep == this.support.bRep); |
---|
| 233 | + |
---|
| 234 | + o.transientrep = this.support.bRep; |
---|
| 235 | + this.support.bRep = null; |
---|
| 236 | + } |
---|
| 237 | + |
---|
| 238 | + // o.support = this.support; |
---|
| 239 | + // o.fileparent = this.fileparent; |
---|
| 240 | + // if (this.bRep != null) |
---|
| 241 | + // o.bRep = this.bRep.support; |
---|
| 242 | + |
---|
| 243 | + this.bRep = null; |
---|
| 244 | + // if (this.bRep != null) |
---|
| 245 | + // this.bRep.support = null; |
---|
| 246 | + // this.support = null; |
---|
| 247 | + // this.fileparent = null; |
---|
| 248 | + } |
---|
| 249 | + |
---|
| 250 | +// Object3D GetObject(java.util.UUID uuid) |
---|
| 251 | +// { |
---|
| 252 | +// if (this.uuid.equals(uuid)) |
---|
| 253 | +// return this; |
---|
| 254 | +// |
---|
| 255 | +// if (blockloop) |
---|
| 256 | +// return null; |
---|
| 257 | +// |
---|
| 258 | +// blockloop = true; |
---|
| 259 | +// |
---|
| 260 | +// for (int i=0; i<Size(); i++) |
---|
| 261 | +// { |
---|
| 262 | +// Object3D o = get(i).GetObject(uuid); |
---|
| 263 | +// |
---|
| 264 | +// if (o != null) |
---|
| 265 | +// return o; |
---|
| 266 | +// } |
---|
| 267 | +// |
---|
| 268 | +// blockloop = false; |
---|
| 269 | +// |
---|
| 270 | +// return null; |
---|
| 271 | +// } |
---|
| 272 | + |
---|
| 273 | + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 274 | + { |
---|
| 275 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 276 | + return; |
---|
| 277 | + |
---|
| 278 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 279 | + |
---|
| 280 | + RestoreBigData(o); |
---|
| 281 | + |
---|
| 282 | + if (blockloop) |
---|
| 283 | + return; |
---|
| 284 | + |
---|
130 | 285 | blockloop = true; |
---|
131 | | - child.SaveSupports(); |
---|
| 286 | + |
---|
| 287 | + //hashtable.remove(GetUUID()); |
---|
| 288 | + |
---|
| 289 | + for (int i=0; i<Size(); i++) |
---|
| 290 | + { |
---|
| 291 | + get(i).RestoreBigData(hashtable); |
---|
| 292 | + } |
---|
| 293 | + |
---|
132 | 294 | blockloop = false; |
---|
133 | 295 | } |
---|
134 | | -} |
---|
135 | 296 | |
---|
136 | | -void RestoreSupports() |
---|
137 | | -{ |
---|
138 | | - if (blockloop) |
---|
139 | | - return; |
---|
140 | | - |
---|
141 | | - support = transientsupport; |
---|
142 | | - link2master = transientlink2master; |
---|
143 | | - transientsupport = null; |
---|
144 | | - transientlink2master = false; |
---|
145 | | - |
---|
146 | | - if (bRep != null) |
---|
| 297 | + void RestoreBigData(Object3D o) |
---|
147 | 298 | { |
---|
148 | | - bRep.RestoreSupports(); |
---|
| 299 | + this.bRep = o.bRep; |
---|
| 300 | + if (this.support != null && o.transientrep != null) |
---|
| 301 | + { |
---|
| 302 | + this.support.bRep = o.transientrep; |
---|
| 303 | + } |
---|
| 304 | + |
---|
| 305 | + this.selection = o.selection; |
---|
| 306 | + |
---|
| 307 | + this.versionlist = o.versionlist; |
---|
| 308 | + this.versionindex = o.versionindex; |
---|
| 309 | +// July 2019 if (this.bRep != null) |
---|
| 310 | +// this.bRep.support = o.transientrep; |
---|
| 311 | + // this.support = o.support; |
---|
| 312 | + // this.fileparent = o.fileparent; |
---|
149 | 313 | } |
---|
150 | | - |
---|
151 | | - for (int i = 0; i < Size(); i++) |
---|
152 | | - { |
---|
153 | | - Object3D child = (Object3D) get(i); |
---|
154 | | - if (child == null) |
---|
155 | | - continue; |
---|
156 | | - blockloop = true; |
---|
157 | | - child.RestoreSupports(); |
---|
158 | | - blockloop = false; |
---|
159 | | - } |
---|
160 | | -} |
---|
161 | 314 | |
---|
162 | 315 | // MOCAP SUPPORT |
---|
163 | 316 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
300 | 453 | } |
---|
301 | 454 | |
---|
302 | 455 | boolean live = false; |
---|
| 456 | + transient boolean keepdontselect; |
---|
| 457 | + boolean dontselect = false; |
---|
303 | 458 | boolean hide = false; |
---|
304 | 459 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 460 | boolean marked = false; // animation node |
---|
.. | .. |
---|
481 | 636 | toParent = LA.newMatrix(); |
---|
482 | 637 | fromParent = LA.newMatrix(); |
---|
483 | 638 | } |
---|
| 639 | + |
---|
484 | 640 | if (toParentMarked == null) |
---|
485 | 641 | { |
---|
486 | 642 | if (maxcount != 1) |
---|
487 | 643 | { |
---|
488 | 644 | new Exception().printStackTrace(); |
---|
489 | 645 | } |
---|
| 646 | + |
---|
490 | 647 | toParentMarked = LA.newMatrix(); |
---|
491 | 648 | fromParentMarked = LA.newMatrix(); |
---|
492 | 649 | } |
---|
.. | .. |
---|
774 | 931 | if (step == 0) |
---|
775 | 932 | step = 1; |
---|
776 | 933 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 934 | + maxcount = 128; // 2048; // 4; |
---|
778 | 935 | // if (acceleration == 0) |
---|
779 | 936 | // acceleration = 10; |
---|
780 | 937 | if (delay == 0) // serial |
---|
.. | .. |
---|
797 | 954 | |
---|
798 | 955 | if (marked && Globals.isLIVE() && live && |
---|
799 | 956 | //TEMP21aug2018 |
---|
800 | | - Globals.DrawMode() == iCameraPane.SHADOW && |
---|
| 957 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
801 | 958 | currentframe != Globals.framecount) |
---|
802 | 959 | { |
---|
803 | 960 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
809 | 966 | |
---|
810 | 967 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
811 | 968 | |
---|
812 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 969 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 970 | + (step == 1 && changedir)) |
---|
813 | 971 | { |
---|
814 | 972 | countdown = 1; |
---|
815 | 973 | delay = speedup?8:1; |
---|
.. | .. |
---|
881 | 1039 | if (material == null || material.multiply) |
---|
882 | 1040 | return true; |
---|
883 | 1041 | |
---|
| 1042 | + if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
| 1043 | + return false; |
---|
| 1044 | + |
---|
| 1045 | + // Transparent objects are dynamic because we have to sort the triangles. |
---|
884 | 1046 | return material.opacity > 0.99; |
---|
885 | 1047 | } |
---|
886 | 1048 | |
---|
.. | .. |
---|
912 | 1074 | fromParent = null; // LA.newMatrix(); |
---|
913 | 1075 | bRep = null; // new BoundaryRep(); |
---|
914 | 1076 | |
---|
| 1077 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 1078 | + { |
---|
| 1079 | + name = oname; |
---|
| 1080 | + } |
---|
| 1081 | + |
---|
915 | 1082 | /* |
---|
916 | 1083 | float hue = (float)Math.random(); |
---|
917 | 1084 | Color col; |
---|
.. | .. |
---|
954 | 1121 | |
---|
955 | 1122 | public Object clone() |
---|
956 | 1123 | { |
---|
957 | | - return GrafreeD.clone(this); |
---|
| 1124 | + return Grafreed.clone(this); |
---|
958 | 1125 | } |
---|
959 | 1126 | |
---|
960 | 1127 | Object3D copyExpand() |
---|
.. | .. |
---|
1276 | 1443 | toParent = LA.newMatrix(); |
---|
1277 | 1444 | fromParent = LA.newMatrix(); |
---|
1278 | 1445 | } |
---|
| 1446 | + |
---|
1279 | 1447 | LA.matCopy(other.toParent, toParent); |
---|
1280 | 1448 | LA.matCopy(other.fromParent, fromParent); |
---|
1281 | 1449 | |
---|
.. | .. |
---|
1470 | 1638 | BoundaryRep.SEUIL = other.material.cameralight; |
---|
1471 | 1639 | |
---|
1472 | 1640 | // Set default to 0.1 |
---|
1473 | | - BoundaryRep.SEUIL /= 2; |
---|
| 1641 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
1474 | 1642 | System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
1475 | 1643 | } |
---|
1476 | 1644 | |
---|
.. | .. |
---|
1729 | 1897 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1730 | 1898 | o.bRep = transientrep; |
---|
1731 | 1899 | if (clone) |
---|
1732 | | - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 1900 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1733 | 1901 | o.CreateMaterial(); |
---|
1734 | 1902 | o.SetAttributes(this, -1); |
---|
1735 | 1903 | //parent |
---|
.. | .. |
---|
1742 | 1910 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1743 | 1911 | o.bRep = bRep; |
---|
1744 | 1912 | if (clone) |
---|
1745 | | - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 1913 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1746 | 1914 | o.CreateMaterial(); |
---|
1747 | 1915 | //o.overwriteThis(this, -1); |
---|
1748 | 1916 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1829 | 1997 | if (obj.name == null) |
---|
1830 | 1998 | continue; // can't be a null one |
---|
1831 | 1999 | |
---|
| 2000 | + // Try perfect match first. |
---|
1832 | 2001 | if (n.equals(obj.name)) |
---|
1833 | 2002 | { |
---|
1834 | 2003 | theobj = obj; |
---|
1835 | 2004 | count++; |
---|
1836 | 2005 | } |
---|
1837 | 2006 | } |
---|
| 2007 | + |
---|
| 2008 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1838 | 2009 | |
---|
1839 | 2010 | if (count != 1) |
---|
1840 | 2011 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2294 | 2465 | } |
---|
2295 | 2466 | */ |
---|
2296 | 2467 | } |
---|
| 2468 | + else |
---|
| 2469 | + { |
---|
| 2470 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2471 | + } |
---|
2297 | 2472 | } |
---|
2298 | 2473 | |
---|
2299 | 2474 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
2300 | 2475 | { |
---|
2301 | 2476 | if (newWindow) |
---|
2302 | 2477 | { |
---|
| 2478 | + new Exception().printStackTrace(); |
---|
2303 | 2479 | System.exit(0); |
---|
2304 | 2480 | if (parent != null) |
---|
2305 | 2481 | { |
---|
.. | .. |
---|
2334 | 2510 | { |
---|
2335 | 2511 | editWindow.refreshContents(); |
---|
2336 | 2512 | } |
---|
| 2513 | + else |
---|
| 2514 | + { |
---|
| 2515 | + if (manipWindow != null) |
---|
| 2516 | + { |
---|
| 2517 | + manipWindow.refreshContents(); |
---|
| 2518 | + } |
---|
| 2519 | + } |
---|
| 2520 | + |
---|
2337 | 2521 | //if (parent != null) |
---|
2338 | 2522 | //parent.refreshEditWindow(); |
---|
2339 | 2523 | } |
---|
.. | .. |
---|
2413 | 2597 | private static final int editSelf = 1; |
---|
2414 | 2598 | private static final int editChild = 2; |
---|
2415 | 2599 | |
---|
2416 | | - void drawEditHandles(ClickInfo info, int level) |
---|
| 2600 | + void drawEditHandles(//ClickInfo info, |
---|
| 2601 | + int level) |
---|
2417 | 2602 | { |
---|
2418 | 2603 | if (level == 0) |
---|
2419 | 2604 | { |
---|
.. | .. |
---|
2421 | 2606 | return; |
---|
2422 | 2607 | |
---|
2423 | 2608 | Object3D selectee; |
---|
2424 | | - for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1)) |
---|
| 2609 | + for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info, |
---|
| 2610 | + level + 1)) |
---|
2425 | 2611 | { |
---|
2426 | 2612 | selectee = (Object3D) e.nextElement(); |
---|
2427 | 2613 | } |
---|
.. | .. |
---|
2429 | 2615 | } else |
---|
2430 | 2616 | { |
---|
2431 | 2617 | //super. |
---|
2432 | | - drawEditHandles0(info, level + 1); |
---|
| 2618 | + drawEditHandles0(//info, |
---|
| 2619 | + level + 1); |
---|
2433 | 2620 | } |
---|
2434 | 2621 | } |
---|
2435 | 2622 | |
---|
2436 | | - boolean doEditClick(ClickInfo info, int level) |
---|
| 2623 | + boolean doEditClick(//ClickInfo info, |
---|
| 2624 | + int level) |
---|
2437 | 2625 | { |
---|
2438 | 2626 | doSomething = 0; |
---|
2439 | 2627 | if (level == 0) |
---|
2440 | 2628 | { |
---|
2441 | | - return doParentClick(info); |
---|
| 2629 | + return doParentClick(); //info); |
---|
2442 | 2630 | } |
---|
2443 | 2631 | if (//super. |
---|
2444 | | - doEditClick0(info, level)) |
---|
| 2632 | + doEditClick0(//info, |
---|
| 2633 | + level)) |
---|
2445 | 2634 | { |
---|
2446 | 2635 | doSomething = 1; |
---|
2447 | 2636 | return true; |
---|
.. | .. |
---|
2451 | 2640 | } |
---|
2452 | 2641 | } |
---|
2453 | 2642 | |
---|
2454 | | - boolean doParentClick(ClickInfo info) |
---|
| 2643 | + boolean doParentClick() //ClickInfo info) |
---|
2455 | 2644 | { |
---|
2456 | 2645 | if (selection == null) |
---|
2457 | 2646 | { |
---|
.. | .. |
---|
2464 | 2653 | for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();) |
---|
2465 | 2654 | { |
---|
2466 | 2655 | Object3D selectee = (Object3D) e.nextElement(); |
---|
2467 | | - if (selectee.doEditClick(info, 1)) |
---|
| 2656 | + if (selectee.doEditClick(//info, |
---|
| 2657 | + 1)) |
---|
2468 | 2658 | { |
---|
2469 | 2659 | childToDrag = selectee; |
---|
2470 | 2660 | doSomething = 2; |
---|
.. | .. |
---|
2476 | 2666 | return retval; |
---|
2477 | 2667 | } |
---|
2478 | 2668 | |
---|
2479 | | - void doEditDrag(ClickInfo info) |
---|
| 2669 | + void doEditDrag(//ClickInfo clickInfo, |
---|
| 2670 | + boolean opposite) |
---|
2480 | 2671 | { |
---|
2481 | 2672 | switch (doSomething) |
---|
2482 | 2673 | { |
---|
2483 | 2674 | case 1: // '\001' |
---|
2484 | 2675 | //super. |
---|
2485 | | - doEditDrag0(info); |
---|
| 2676 | + doEditDrag0(//clickInfo, |
---|
| 2677 | + opposite); |
---|
2486 | 2678 | break; |
---|
2487 | 2679 | |
---|
2488 | 2680 | case 2: // '\002' |
---|
.. | .. |
---|
2495 | 2687 | { |
---|
2496 | 2688 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2497 | 2689 | //childToDrag.doEditDrag(info); |
---|
2498 | | - sel.doEditDrag(info); |
---|
| 2690 | + sel.doEditDrag(//clickInfo, |
---|
| 2691 | + opposite); |
---|
2499 | 2692 | } else |
---|
2500 | 2693 | { |
---|
2501 | 2694 | //super. |
---|
2502 | | - doEditDrag0(info); |
---|
| 2695 | + doEditDrag0(//clickInfo, |
---|
| 2696 | + opposite); |
---|
2503 | 2697 | } |
---|
2504 | 2698 | } |
---|
2505 | 2699 | break; |
---|
.. | .. |
---|
2517 | 2711 | { |
---|
2518 | 2712 | deselectAll(); |
---|
2519 | 2713 | } |
---|
| 2714 | + |
---|
| 2715 | + new Exception().printStackTrace(); |
---|
| 2716 | + |
---|
2520 | 2717 | ClickInfo newInfo = new ClickInfo(); |
---|
2521 | 2718 | newInfo.flags = info.flags; |
---|
2522 | 2719 | newInfo.bounds = info.bounds; |
---|
.. | .. |
---|
2609 | 2806 | void GenNormalsS(boolean crease) |
---|
2610 | 2807 | { |
---|
2611 | 2808 | selection.GenNormals(crease); |
---|
| 2809 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2810 | +// { |
---|
| 2811 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2812 | +// selectee.GenNormals(crease); |
---|
| 2813 | +// } |
---|
| 2814 | + |
---|
| 2815 | + //Touch(); |
---|
| 2816 | + } |
---|
| 2817 | + |
---|
| 2818 | + void GenNormalsMeshS() |
---|
| 2819 | + { |
---|
| 2820 | + selection.GenNormalsMesh(); |
---|
2612 | 2821 | // for (int i=0; i<selection.size(); i++) |
---|
2613 | 2822 | // { |
---|
2614 | 2823 | // Object3D selectee = (Object3D) selection.elementAt(i); |
---|
.. | .. |
---|
2749 | 2958 | if (child == null) |
---|
2750 | 2959 | continue; |
---|
2751 | 2960 | child.GenNormals(crease); |
---|
| 2961 | +// Children().release(i); |
---|
| 2962 | + } |
---|
| 2963 | + blockloop = false; |
---|
| 2964 | + } |
---|
| 2965 | + |
---|
| 2966 | + void GenNormalsMesh() |
---|
| 2967 | + { |
---|
| 2968 | + if (blockloop) |
---|
| 2969 | + return; |
---|
| 2970 | + |
---|
| 2971 | + blockloop = true; |
---|
| 2972 | + GenNormalsMesh0(); |
---|
| 2973 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2974 | + { |
---|
| 2975 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2976 | + if (child == null) |
---|
| 2977 | + continue; |
---|
| 2978 | + child.GenNormalsMesh(); |
---|
2752 | 2979 | // Children().release(i); |
---|
2753 | 2980 | } |
---|
2754 | 2981 | blockloop = false; |
---|
.. | .. |
---|
2906 | 3133 | { |
---|
2907 | 3134 | if (bRep != null) |
---|
2908 | 3135 | { |
---|
2909 | | - bRep.GenUV(); |
---|
| 3136 | + bRep.GenUV(); //1); |
---|
| 3137 | + //bRep.UnfoldUV(); |
---|
2910 | 3138 | Touch(); |
---|
2911 | 3139 | } |
---|
2912 | 3140 | } |
---|
.. | .. |
---|
2920 | 3148 | } |
---|
2921 | 3149 | } |
---|
2922 | 3150 | |
---|
| 3151 | + void GenNormalsMesh0() |
---|
| 3152 | + { |
---|
| 3153 | + if (bRep != null) |
---|
| 3154 | + { |
---|
| 3155 | + bRep.GenerateNormalsMesh(); |
---|
| 3156 | + Touch(); |
---|
| 3157 | + } |
---|
| 3158 | + } |
---|
| 3159 | + |
---|
2923 | 3160 | void GenNormalsMINE0() |
---|
2924 | 3161 | { |
---|
2925 | 3162 | if (bRep != null) |
---|
2926 | 3163 | { |
---|
2927 | | - bRep.GenerateNormalsMINE(); |
---|
| 3164 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
2928 | 3165 | Touch(); |
---|
2929 | 3166 | } |
---|
2930 | 3167 | } |
---|
.. | .. |
---|
2981 | 3218 | blockloop = false; |
---|
2982 | 3219 | } |
---|
2983 | 3220 | |
---|
| 3221 | + void TransformChildren() |
---|
| 3222 | + { |
---|
| 3223 | + if (toParent != null) |
---|
| 3224 | + { |
---|
| 3225 | + for (int i=Size(); --i>=0;) |
---|
| 3226 | + { |
---|
| 3227 | + Object3D v = get(i); |
---|
| 3228 | + |
---|
| 3229 | + if (v.toParent == null) |
---|
| 3230 | + { |
---|
| 3231 | + v.toParent = LA.newMatrix(); |
---|
| 3232 | + v.fromParent = LA.newMatrix(); |
---|
| 3233 | + } |
---|
| 3234 | + |
---|
| 3235 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3236 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3237 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3238 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
| 3239 | + } |
---|
| 3240 | + |
---|
| 3241 | + toParent = null; // LA.matIdentity(toParent); |
---|
| 3242 | + fromParent = null; // LA.matIdentity(fromParent); |
---|
| 3243 | + |
---|
| 3244 | + Touch(); |
---|
| 3245 | + } |
---|
| 3246 | + } |
---|
| 3247 | + |
---|
2984 | 3248 | void TransformGeometry() |
---|
2985 | 3249 | { |
---|
2986 | 3250 | Object3D obj = this; |
---|
.. | .. |
---|
3202 | 3466 | |
---|
3203 | 3467 | BoundaryRep sup = bRep.support; |
---|
3204 | 3468 | bRep.support = null; |
---|
3205 | | - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 3469 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3206 | 3470 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3207 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3471 | + |
---|
| 3472 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3473 | + |
---|
3208 | 3474 | bRep = temprep; |
---|
3209 | 3475 | bRep.support = sup; |
---|
3210 | 3476 | Touch(); |
---|
.. | .. |
---|
3341 | 3607 | if (blockloop) |
---|
3342 | 3608 | return; |
---|
3343 | 3609 | |
---|
3344 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3610 | + if (//marked || // does not make sense |
---|
| 3611 | + (bRep != null || material != null)) // borderline... |
---|
3345 | 3612 | live = h; |
---|
3346 | 3613 | |
---|
3347 | 3614 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3362 | 3629 | return; |
---|
3363 | 3630 | |
---|
3364 | 3631 | //if (bRep != null) |
---|
3365 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3632 | + if (//marked || // does not make sense |
---|
| 3633 | + (bRep != null || material != null)) // borderline... |
---|
3366 | 3634 | link2master = h; |
---|
3367 | 3635 | |
---|
3368 | 3636 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3382 | 3650 | if (blockloop) |
---|
3383 | 3651 | return; |
---|
3384 | 3652 | |
---|
3385 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3653 | + if (//marked || // does not make sense |
---|
| 3654 | + (bRep != null || material != null)) // borderline... |
---|
3386 | 3655 | hide = h; |
---|
3387 | 3656 | |
---|
3388 | 3657 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3402 | 3671 | if (blockloop) |
---|
3403 | 3672 | return; |
---|
3404 | 3673 | |
---|
3405 | | - if (bRep != null && material != null) // borderline... |
---|
| 3674 | + if (bRep != null || material != null) // borderline... |
---|
3406 | 3675 | marked = h; |
---|
3407 | 3676 | |
---|
3408 | 3677 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3412 | 3681 | continue; |
---|
3413 | 3682 | blockloop = true; |
---|
3414 | 3683 | child.MarkLeaves(h); |
---|
| 3684 | + blockloop = false; |
---|
| 3685 | + // release(i); |
---|
| 3686 | + } |
---|
| 3687 | + } |
---|
| 3688 | + |
---|
| 3689 | + void RewindLeaves(boolean h) |
---|
| 3690 | + { |
---|
| 3691 | + if (blockloop) |
---|
| 3692 | + return; |
---|
| 3693 | + |
---|
| 3694 | + if (bRep != null || material != null) // borderline... |
---|
| 3695 | + rewind = h; |
---|
| 3696 | + |
---|
| 3697 | + for (int i = 0; i < Size(); i++) |
---|
| 3698 | + { |
---|
| 3699 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3700 | + if (child == null) |
---|
| 3701 | + continue; |
---|
| 3702 | + blockloop = true; |
---|
| 3703 | + child.RewindLeaves(h); |
---|
| 3704 | + blockloop = false; |
---|
| 3705 | + // release(i); |
---|
| 3706 | + } |
---|
| 3707 | + } |
---|
| 3708 | + |
---|
| 3709 | + void RandomLeaves(boolean h) |
---|
| 3710 | + { |
---|
| 3711 | + if (blockloop) |
---|
| 3712 | + return; |
---|
| 3713 | + |
---|
| 3714 | + if (bRep != null || material != null) // borderline... |
---|
| 3715 | + random = h; |
---|
| 3716 | + |
---|
| 3717 | + for (int i = 0; i < Size(); i++) |
---|
| 3718 | + { |
---|
| 3719 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3720 | + if (child == null) |
---|
| 3721 | + continue; |
---|
| 3722 | + blockloop = true; |
---|
| 3723 | + child.RandomLeaves(h); |
---|
3415 | 3724 | blockloop = false; |
---|
3416 | 3725 | // release(i); |
---|
3417 | 3726 | } |
---|
.. | .. |
---|
3726 | 4035 | if (child == null) |
---|
3727 | 4036 | continue; |
---|
3728 | 4037 | |
---|
3729 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4038 | + if (Grafreed.RENDERME > 0) |
---|
3730 | 4039 | { |
---|
3731 | 4040 | if (child instanceof Merge) |
---|
3732 | 4041 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3877 | 4186 | if (child == null) |
---|
3878 | 4187 | continue; |
---|
3879 | 4188 | |
---|
3880 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4189 | + if (Grafreed.RENDERME > 0) |
---|
3881 | 4190 | { |
---|
3882 | 4191 | if (child instanceof Merge) |
---|
3883 | 4192 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4072 | 4381 | if (child == null) |
---|
4073 | 4382 | continue; |
---|
4074 | 4383 | |
---|
4075 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4384 | + if (Grafreed.RENDERME > 0) |
---|
4076 | 4385 | { |
---|
4077 | 4386 | if (child instanceof Merge) |
---|
4078 | 4387 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4185 | 4494 | { |
---|
4186 | 4495 | blockloop = true; |
---|
4187 | 4496 | get(i).RepairShadow(); |
---|
| 4497 | + blockloop = false; |
---|
| 4498 | + } |
---|
| 4499 | + } |
---|
| 4500 | + |
---|
| 4501 | + void RepairSOV() |
---|
| 4502 | + { |
---|
| 4503 | + if (blockloop) |
---|
| 4504 | + return; |
---|
| 4505 | + |
---|
| 4506 | + String texname = this.GetPigmentTexture(); |
---|
| 4507 | + |
---|
| 4508 | + if (texname.startsWith("sov")) |
---|
| 4509 | + { |
---|
| 4510 | + String[] s = texname.split("/"); |
---|
| 4511 | + |
---|
| 4512 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4513 | + |
---|
| 4514 | + texname = sname[0]; |
---|
| 4515 | + |
---|
| 4516 | + if (sname.length > 1) |
---|
| 4517 | + { |
---|
| 4518 | + texname += "Color.jpg"; |
---|
| 4519 | + } |
---|
| 4520 | + |
---|
| 4521 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4522 | + } |
---|
| 4523 | + |
---|
| 4524 | + texname = this.GetBumpTexture(); |
---|
| 4525 | + |
---|
| 4526 | + if (texname.startsWith("sov")) |
---|
| 4527 | + { |
---|
| 4528 | + String[] s = texname.split("/"); |
---|
| 4529 | + |
---|
| 4530 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4531 | + |
---|
| 4532 | + texname = sname[0]; |
---|
| 4533 | + |
---|
| 4534 | + if (sname.length > 1) |
---|
| 4535 | + { |
---|
| 4536 | + texname += "Bump.jpg"; |
---|
| 4537 | + } |
---|
| 4538 | + |
---|
| 4539 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4540 | + } |
---|
| 4541 | + |
---|
| 4542 | + for (int i=0; i<Size(); i++) |
---|
| 4543 | + { |
---|
| 4544 | + blockloop = true; |
---|
| 4545 | + get(i).RepairSOV(); |
---|
4188 | 4546 | blockloop = false; |
---|
4189 | 4547 | } |
---|
4190 | 4548 | } |
---|
.. | .. |
---|
4679 | 5037 | |
---|
4680 | 5038 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4681 | 5039 | { |
---|
4682 | | - if (hide) |
---|
| 5040 | + if (hide || dontselect) |
---|
4683 | 5041 | return null; |
---|
4684 | 5042 | |
---|
4685 | 5043 | if (count <= 0) |
---|
.. | .. |
---|
4703 | 5061 | } |
---|
4704 | 5062 | } |
---|
4705 | 5063 | |
---|
| 5064 | + ObjEditor GetWindow() |
---|
| 5065 | + { |
---|
| 5066 | + if (editWindow != null) |
---|
| 5067 | + return editWindow; |
---|
| 5068 | + |
---|
| 5069 | + return manipWindow; |
---|
| 5070 | + } |
---|
| 5071 | + |
---|
4706 | 5072 | cTreePath Select(int indexcount, boolean deselect) |
---|
4707 | 5073 | { |
---|
4708 | | - if (hide) |
---|
| 5074 | + if (hide || dontselect) |
---|
4709 | 5075 | return null; |
---|
4710 | 5076 | |
---|
4711 | 5077 | if (count <= 0) |
---|
.. | .. |
---|
4739 | 5105 | if (leaf != null) |
---|
4740 | 5106 | { |
---|
4741 | 5107 | cTreePath tp = new cTreePath(this, leaf); |
---|
4742 | | - if (editWindow != null) |
---|
| 5108 | + ObjEditor window = GetWindow(); |
---|
| 5109 | + if (window != null) |
---|
4743 | 5110 | { |
---|
4744 | 5111 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4745 | | - editWindow.Select(tp, deselect, true); |
---|
| 5112 | + window.Select(tp, deselect, true); |
---|
4746 | 5113 | } |
---|
4747 | 5114 | |
---|
4748 | 5115 | return tp; |
---|
.. | .. |
---|
4759 | 5126 | |
---|
4760 | 5127 | if (child == null) |
---|
4761 | 5128 | continue; |
---|
| 5129 | + |
---|
4762 | 5130 | if (child.HasTransparency() && child.size() != 0) |
---|
4763 | 5131 | { |
---|
4764 | 5132 | cTreePath leaf = child.Select(indexcount, deselect); |
---|
.. | .. |
---|
4768 | 5136 | if (leaf != null) |
---|
4769 | 5137 | { |
---|
4770 | 5138 | cTreePath tp = new cTreePath(this, leaf); |
---|
4771 | | - if (editWindow != null) |
---|
| 5139 | + ObjEditor window = GetWindow(); |
---|
| 5140 | + if (window != null) |
---|
4772 | 5141 | { |
---|
4773 | | - editWindow.Select(tp, deselect, true); |
---|
| 5142 | + window.Select(tp, deselect, true); |
---|
4774 | 5143 | } |
---|
4775 | 5144 | |
---|
4776 | 5145 | return tp; |
---|
.. | .. |
---|
5095 | 5464 | blockloop = false; |
---|
5096 | 5465 | } |
---|
5097 | 5466 | |
---|
| 5467 | + void ResetSelectable() |
---|
| 5468 | + { |
---|
| 5469 | + if (blockloop) |
---|
| 5470 | + return; |
---|
| 5471 | + |
---|
| 5472 | + blockloop = true; |
---|
| 5473 | + |
---|
| 5474 | + keepdontselect = dontselect; |
---|
| 5475 | + dontselect = true; |
---|
| 5476 | + |
---|
| 5477 | + Object3D child; |
---|
| 5478 | + int nb = Size(); |
---|
| 5479 | + for (int i = 0; i < nb; i++) |
---|
| 5480 | + { |
---|
| 5481 | + child = (Object3D) get(i); |
---|
| 5482 | + if (child == null) |
---|
| 5483 | + continue; |
---|
| 5484 | + child.ResetSelectable(); |
---|
| 5485 | + } |
---|
| 5486 | + |
---|
| 5487 | + blockloop = false; |
---|
| 5488 | + } |
---|
| 5489 | + |
---|
| 5490 | + void RestoreSelectable() |
---|
| 5491 | + { |
---|
| 5492 | + if (blockloop) |
---|
| 5493 | + return; |
---|
| 5494 | + |
---|
| 5495 | + blockloop = true; |
---|
| 5496 | + |
---|
| 5497 | + dontselect = keepdontselect; |
---|
| 5498 | + |
---|
| 5499 | + Object3D child; |
---|
| 5500 | + int nb = Size(); |
---|
| 5501 | + for (int i = 0; i < nb; i++) |
---|
| 5502 | + { |
---|
| 5503 | + child = (Object3D) get(i); |
---|
| 5504 | + if (child == null) |
---|
| 5505 | + continue; |
---|
| 5506 | + child.RestoreSelectable(); |
---|
| 5507 | + } |
---|
| 5508 | + |
---|
| 5509 | + blockloop = false; |
---|
| 5510 | + } |
---|
| 5511 | + |
---|
5098 | 5512 | boolean IsSelected() |
---|
5099 | 5513 | { |
---|
5100 | 5514 | if (parent == null) |
---|
.. | .. |
---|
5157 | 5571 | |
---|
5158 | 5572 | // System.out.println("Fullname = " + fullname); |
---|
5159 | 5573 | |
---|
5160 | | - if (fullname.name.indexOf(":") == -1) |
---|
5161 | | - return fullname.name; |
---|
| 5574 | + // Does not work on Windows due to C: |
---|
| 5575 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5576 | +// return fullname.name; |
---|
| 5577 | +// |
---|
| 5578 | +// return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
5162 | 5579 | |
---|
5163 | | - return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
| 5580 | + String[] split = fullname.name.split(":"); |
---|
| 5581 | + |
---|
| 5582 | + if (split.length == 0) |
---|
| 5583 | + { |
---|
| 5584 | + return ""; |
---|
| 5585 | + } |
---|
| 5586 | + |
---|
| 5587 | + if (split.length <= 2) |
---|
| 5588 | + { |
---|
| 5589 | + if (fullname.name.endsWith(":")) |
---|
| 5590 | + { |
---|
| 5591 | + // Windows |
---|
| 5592 | + return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5593 | + } |
---|
| 5594 | + |
---|
| 5595 | + return split[0]; |
---|
| 5596 | + } |
---|
| 5597 | + |
---|
| 5598 | + // Windows |
---|
| 5599 | + assert(split.length == 4); |
---|
| 5600 | + |
---|
| 5601 | + return split[0] + ":" + split[1]; |
---|
5164 | 5602 | } |
---|
5165 | 5603 | |
---|
5166 | 5604 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5169 | 5607 | return ""; |
---|
5170 | 5608 | |
---|
5171 | 5609 | // System.out.println("Fullname = " + fullname); |
---|
5172 | | - if (fullname.name.indexOf(":") == -1) |
---|
5173 | | - return ""; |
---|
5174 | | - |
---|
5175 | | - return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5610 | + // Does not work on Windows due to C: |
---|
| 5611 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5612 | +// return ""; |
---|
| 5613 | +// |
---|
| 5614 | +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5615 | + String[] split = fullname.name.split(":"); |
---|
| 5616 | + |
---|
| 5617 | + if (split.length == 0) |
---|
| 5618 | + { |
---|
| 5619 | + return ""; |
---|
| 5620 | + } |
---|
| 5621 | + |
---|
| 5622 | + if (split.length == 1) |
---|
| 5623 | + { |
---|
| 5624 | + return ""; |
---|
| 5625 | + } |
---|
| 5626 | + |
---|
| 5627 | + if (split.length == 2) |
---|
| 5628 | + { |
---|
| 5629 | + if (fullname.name.endsWith(":")) |
---|
| 5630 | + { |
---|
| 5631 | + // Windows |
---|
| 5632 | + return ""; |
---|
| 5633 | + } |
---|
| 5634 | + |
---|
| 5635 | + return split[1]; |
---|
| 5636 | + } |
---|
| 5637 | + |
---|
| 5638 | + // Windows |
---|
| 5639 | + assert(split.length == 4); |
---|
| 5640 | + |
---|
| 5641 | + return split[2] + ":" + split[3]; |
---|
5176 | 5642 | } |
---|
5177 | 5643 | |
---|
5178 | 5644 | String GetPigmentTexture() |
---|
.. | .. |
---|
5246 | 5712 | System.out.print("; textures = " + textures); |
---|
5247 | 5713 | System.out.println("; usedtextures = " + usedtextures); |
---|
5248 | 5714 | |
---|
5249 | | - if (GetTextures() == null) |
---|
| 5715 | + if (GetTextures() == null) // What is that?? |
---|
5250 | 5716 | GetTextures().name = ":"; |
---|
5251 | 5717 | |
---|
5252 | 5718 | String texname = tex; |
---|
.. | .. |
---|
5277 | 5743 | child.ResetPigmentTexture(); |
---|
5278 | 5744 | blockloop = false; |
---|
5279 | 5745 | } |
---|
| 5746 | + } |
---|
| 5747 | + |
---|
| 5748 | + UUID GetUUID() |
---|
| 5749 | + { |
---|
| 5750 | + if (uuid == null) |
---|
| 5751 | + { |
---|
| 5752 | + // Serial |
---|
| 5753 | + uuid = UUID.randomUUID(); |
---|
| 5754 | + } |
---|
| 5755 | + |
---|
| 5756 | + return uuid; |
---|
| 5757 | + } |
---|
| 5758 | + |
---|
| 5759 | + Object3D GetObject(UUID uid) |
---|
| 5760 | + { |
---|
| 5761 | + if (blockloop) |
---|
| 5762 | + return null; |
---|
| 5763 | + |
---|
| 5764 | + if (GetUUID().equals(uid)) |
---|
| 5765 | + return this; |
---|
| 5766 | + |
---|
| 5767 | + int nb = Size(); |
---|
| 5768 | + for (int i = 0; i < nb; i++) |
---|
| 5769 | + { |
---|
| 5770 | + Object3D child = (Object3D) get(i); |
---|
| 5771 | + |
---|
| 5772 | + if (child == null) |
---|
| 5773 | + continue; |
---|
| 5774 | + |
---|
| 5775 | + blockloop = true; |
---|
| 5776 | + Object3D obj = child.GetObject(uid); |
---|
| 5777 | + blockloop = false; |
---|
| 5778 | + if (obj != null) |
---|
| 5779 | + return obj; |
---|
| 5780 | + } |
---|
| 5781 | + |
---|
| 5782 | + return null; |
---|
5280 | 5783 | } |
---|
5281 | 5784 | |
---|
5282 | 5785 | void SetBumpTexture(String tex) |
---|
.. | .. |
---|
5315 | 5818 | } |
---|
5316 | 5819 | } |
---|
5317 | 5820 | |
---|
| 5821 | + void EmbedTextures(boolean embed) |
---|
| 5822 | + { |
---|
| 5823 | + if (blockloop) |
---|
| 5824 | + return; |
---|
| 5825 | + |
---|
| 5826 | + //if (GetTextures() != null) |
---|
| 5827 | + if (embed) |
---|
| 5828 | + CameraPane.EmbedTextures(GetTextures()); |
---|
| 5829 | + else |
---|
| 5830 | + { |
---|
| 5831 | + GetTextures().pigmentdata = null; |
---|
| 5832 | + GetTextures().bumpdata = null; |
---|
| 5833 | + GetTextures().pw = 0; |
---|
| 5834 | + GetTextures().ph = 0; |
---|
| 5835 | + GetTextures().bw = 0; |
---|
| 5836 | + GetTextures().bh = 0; |
---|
| 5837 | + } |
---|
| 5838 | + |
---|
| 5839 | + int nb = Size(); |
---|
| 5840 | + for (int i = 0; i < nb; i++) |
---|
| 5841 | + { |
---|
| 5842 | + Object3D child = (Object3D) get(i); |
---|
| 5843 | + |
---|
| 5844 | + if (child == null) |
---|
| 5845 | + continue; |
---|
| 5846 | + |
---|
| 5847 | + blockloop = true; |
---|
| 5848 | + child.EmbedTextures(embed); |
---|
| 5849 | + blockloop = false; |
---|
| 5850 | + } |
---|
| 5851 | + } |
---|
| 5852 | + |
---|
5318 | 5853 | void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5319 | 5854 | { |
---|
5320 | 5855 | Draw(display, root, selected, blocked); |
---|
.. | .. |
---|
5323 | 5858 | boolean NeedSupport() |
---|
5324 | 5859 | { |
---|
5325 | 5860 | return |
---|
5326 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5861 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5327 | 5862 | // PROBLEM with CROWD!! |
---|
5328 | | - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); |
---|
| 5863 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5329 | 5864 | } |
---|
5330 | 5865 | |
---|
5331 | 5866 | static boolean DEBUG_SELECTION = false; |
---|
| 5867 | + |
---|
| 5868 | + boolean IsLive() |
---|
| 5869 | + { |
---|
| 5870 | + if (live) |
---|
| 5871 | + return true; |
---|
| 5872 | + |
---|
| 5873 | + if (parent == null) |
---|
| 5874 | + return false; |
---|
| 5875 | + |
---|
| 5876 | + return parent.IsLive(); |
---|
| 5877 | + } |
---|
5332 | 5878 | |
---|
5333 | 5879 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5334 | 5880 | { |
---|
.. | .. |
---|
5340 | 5886 | } |
---|
5341 | 5887 | |
---|
5342 | 5888 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5343 | | - hide) |
---|
| 5889 | + (hide || dontselect)) |
---|
5344 | 5890 | return; |
---|
5345 | 5891 | |
---|
5346 | 5892 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5390 | 5936 | if (support != null) |
---|
5391 | 5937 | support = support; |
---|
5392 | 5938 | |
---|
5393 | | - //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5394 | | - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5939 | + boolean usecalllists = !IsLive() && IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5940 | + //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5941 | + |
---|
| 5942 | + //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
5395 | 5943 | |
---|
5396 | 5944 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5397 | 5945 | { |
---|
.. | .. |
---|
5401 | 5949 | // usecalllists &= !(parent instanceof RandomNode); |
---|
5402 | 5950 | // usecalllists = false; |
---|
5403 | 5951 | |
---|
5404 | | - if (GetBRep() != null) |
---|
5405 | | - usecalllists = usecalllists; |
---|
| 5952 | + if (display.DrawMode() == display.SHADOW) |
---|
| 5953 | + //GetBRep() != null) |
---|
| 5954 | + usecalllists = !!usecalllists; |
---|
5406 | 5955 | //System.out.println("draw " + this); |
---|
5407 | 5956 | //new Exception().printStackTrace(); |
---|
5408 | 5957 | |
---|
.. | .. |
---|
5411 | 5960 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5412 | 5961 | |
---|
5413 | 5962 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5414 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5963 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5964 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5415 | 5965 | { |
---|
5416 | 5966 | Globals.lighttouched = true; |
---|
5417 | 5967 | } // all panes... |
---|
| 5968 | + |
---|
5418 | 5969 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5419 | 5970 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5420 | 5971 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5422 | 5973 | if (!(this instanceof Composite)) |
---|
5423 | 5974 | touched = false; |
---|
5424 | 5975 | //if (displaylist == -1 && usecalllists) |
---|
5425 | | - if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
| 5976 | + if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013 |
---|
5426 | 5977 | { |
---|
5427 | 5978 | bRep.displaylist = display.GenList(); |
---|
5428 | 5979 | assert(bRep.displaylist != 0); |
---|
.. | .. |
---|
5433 | 5984 | |
---|
5434 | 5985 | //System.out.println("\tnew list " + list); |
---|
5435 | 5986 | //gl.glDrawBuffer(gl.GL_NONE); |
---|
5436 | | - if (usecalllists) |
---|
| 5987 | + if (usecalllists && bRep.displaylist > 0) |
---|
5437 | 5988 | { |
---|
5438 | 5989 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5439 | 5990 | display.NewList(bRep.displaylist); |
---|
.. | .. |
---|
5442 | 5993 | CallList(display, root, selected, blocked); |
---|
5443 | 5994 | |
---|
5444 | 5995 | // compiled = true; |
---|
5445 | | - if (usecalllists) |
---|
| 5996 | + if (usecalllists && bRep.displaylist > 0) |
---|
5446 | 5997 | { |
---|
5447 | 5998 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5448 | 5999 | display.EndList(); |
---|
.. | .. |
---|
5542 | 6093 | if (GetBRep() != null) |
---|
5543 | 6094 | { |
---|
5544 | 6095 | display.NextIndex(); |
---|
| 6096 | + |
---|
5545 | 6097 | // vertex color conflict : gl.glCallList(list); |
---|
5546 | 6098 | DrawNode(display, root, selected); |
---|
5547 | 6099 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5582 | 6134 | tex = GetTextures(); |
---|
5583 | 6135 | } |
---|
5584 | 6136 | |
---|
5585 | | - display.BindTextures(tex, texres); |
---|
| 6137 | + boolean failedPigment = false; |
---|
| 6138 | + boolean failedBump = false; |
---|
| 6139 | + |
---|
| 6140 | + try |
---|
| 6141 | + { |
---|
| 6142 | + display.BindPigmentTexture(tex, texres); |
---|
| 6143 | + } |
---|
| 6144 | + catch (Exception e) |
---|
| 6145 | + { |
---|
| 6146 | + System.err.println("FAILED: " + this); |
---|
| 6147 | + failedPigment = true; |
---|
| 6148 | + } |
---|
| 6149 | + |
---|
| 6150 | + try |
---|
| 6151 | + { |
---|
| 6152 | + display.BindBumpTexture(tex, texres); |
---|
| 6153 | + } |
---|
| 6154 | + catch (Exception e) |
---|
| 6155 | + { |
---|
| 6156 | + //System.err.println("FAILED: " + this); |
---|
| 6157 | + failedBump = true; |
---|
| 6158 | + } |
---|
5586 | 6159 | |
---|
5587 | 6160 | if (!compiled) |
---|
5588 | 6161 | { |
---|
.. | .. |
---|
5604 | 6177 | } |
---|
5605 | 6178 | } |
---|
5606 | 6179 | |
---|
5607 | | - display.ReleaseTextures(tex); |
---|
| 6180 | + if (!failedBump) |
---|
| 6181 | + display.ReleaseBumpTexture(tex); |
---|
| 6182 | + |
---|
| 6183 | + if (!failedPigment) |
---|
| 6184 | + display.ReleasePigmentTexture(tex); |
---|
5608 | 6185 | |
---|
5609 | 6186 | display.PopMaterial(this, selected); |
---|
5610 | 6187 | } |
---|
.. | .. |
---|
5733 | 6310 | |
---|
5734 | 6311 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5735 | 6312 | { |
---|
| 6313 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6314 | + return; |
---|
| 6315 | + |
---|
5736 | 6316 | if (hide) |
---|
5737 | 6317 | return; |
---|
5738 | 6318 | // shadow optimisation |
---|
.. | .. |
---|
5858 | 6438 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5859 | 6439 | return; // no shadow for transparent objects |
---|
5860 | 6440 | |
---|
| 6441 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6442 | + return; |
---|
| 6443 | + |
---|
5861 | 6444 | if (hide) |
---|
5862 | 6445 | return; |
---|
5863 | 6446 | |
---|
.. | .. |
---|
5898 | 6481 | return; |
---|
5899 | 6482 | } |
---|
5900 | 6483 | |
---|
| 6484 | + //bRep.GenUV(1/material.diffuseness); |
---|
5901 | 6485 | // bRep.lock = true; |
---|
5902 | 6486 | |
---|
5903 | 6487 | //javax.media.opengl.GL gl = display.GetGL(); |
---|
.. | .. |
---|
5970 | 6554 | // dec 2012 |
---|
5971 | 6555 | new Exception().printStackTrace(); |
---|
5972 | 6556 | return; |
---|
| 6557 | + } |
---|
| 6558 | + |
---|
| 6559 | + if (dontselect) |
---|
| 6560 | + { |
---|
| 6561 | + //bRep.GenerateNormalsMINE(); |
---|
5973 | 6562 | } |
---|
5974 | 6563 | |
---|
5975 | 6564 | display.DrawGeometry(bRep, flipV, selectmode); |
---|
.. | .. |
---|
6755 | 7344 | } |
---|
6756 | 7345 | } |
---|
6757 | 7346 | |
---|
6758 | | - protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec) |
---|
| 7347 | + static ClickInfo clickInfo = new ClickInfo(); |
---|
| 7348 | + |
---|
| 7349 | + protected void calcHotSpot(cVector in, //ClickInfo clickInfo, |
---|
| 7350 | + Point outPt, Rectangle outRec) |
---|
6759 | 7351 | { |
---|
6760 | | - int hc = info.bounds.x + info.bounds.width / 2; |
---|
6761 | | - int vc = info.bounds.y + info.bounds.height / 2; |
---|
6762 | | - double[][] toscreen = info.toScreen; |
---|
| 7352 | + int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2; |
---|
| 7353 | + int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2; |
---|
| 7354 | + double[][] toscreen = clickInfo.toScreen; |
---|
6763 | 7355 | if (toscreen == null) |
---|
6764 | 7356 | { |
---|
6765 | | - toscreen = new Camera(info.camera.viewCode).toScreen; |
---|
| 7357 | + toscreen = new Camera(clickInfo.camera.viewCode).toScreen; |
---|
6766 | 7358 | } |
---|
6767 | 7359 | cVector vec = in; |
---|
6768 | 7360 | LA.xformPos(in, toscreen, in); |
---|
6769 | 7361 | //System.out.println("Distance = " + info.camera.Distance()); |
---|
6770 | | - vec.x *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
6771 | | - vec.y *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
| 7362 | + vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
| 7363 | + vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
6772 | 7364 | outPt.x = hc + (int) vec.x; |
---|
6773 | 7365 | outPt.y = vc - (int) vec.y; |
---|
6774 | 7366 | outRec.x = outPt.x - 3; |
---|
.. | .. |
---|
6776 | 7368 | outRec.width = outRec.height = 6; |
---|
6777 | 7369 | } |
---|
6778 | 7370 | |
---|
6779 | | - protected Rectangle calcHotSpot(cVector in, ClickInfo info) |
---|
| 7371 | + protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo |
---|
| 7372 | + ) |
---|
6780 | 7373 | { |
---|
6781 | 7374 | Point pt = new Point(0, 0); |
---|
6782 | 7375 | Rectangle rec = new Rectangle(); |
---|
6783 | | - calcHotSpot(in, info, pt, rec); |
---|
| 7376 | + calcHotSpot(in, //clickInfo, |
---|
| 7377 | + pt, rec); |
---|
6784 | 7378 | return rec; |
---|
6785 | 7379 | } |
---|
6786 | 7380 | |
---|
6787 | | - void drawEditHandles0(ClickInfo info, int level) |
---|
| 7381 | + void drawEditHandles0(//ClickInfo clickInfo, |
---|
| 7382 | + int level) |
---|
6788 | 7383 | { |
---|
6789 | 7384 | if (level == 0) |
---|
6790 | 7385 | { |
---|
.. | .. |
---|
6793 | 7388 | { |
---|
6794 | 7389 | cVector origin = new cVector(); |
---|
6795 | 7390 | //LA.xformPos(origin, toParent, origin); |
---|
6796 | | - Rectangle spot = calcHotSpot(origin, info); |
---|
| 7391 | + if (this.clickInfo == null) |
---|
| 7392 | + this.clickInfo = new ClickInfo(); |
---|
| 7393 | + |
---|
| 7394 | + Rectangle spot = calcHotSpot(origin); //, clickInfo); |
---|
6797 | 7395 | Rectangle boundary = new Rectangle(); |
---|
6798 | 7396 | boundary.x = spot.x - 30; |
---|
6799 | 7397 | boundary.y = spot.y - 30; |
---|
6800 | 7398 | boundary.width = spot.width + 60; |
---|
6801 | 7399 | boundary.height = spot.height + 60; |
---|
6802 | | - info.g.setColor(Color.red); |
---|
| 7400 | + clickInfo.g.setColor(Color.red); |
---|
6803 | 7401 | int spotw = spot.x + spot.width; |
---|
6804 | 7402 | int spoth = spot.y + spot.height; |
---|
6805 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7403 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6806 | 7404 | // if (CameraPane.Xmin > spot.x) |
---|
6807 | 7405 | // { |
---|
6808 | 7406 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6822 | 7420 | spot.translate(32, 32); |
---|
6823 | 7421 | spotw = spot.x + spot.width; |
---|
6824 | 7422 | spoth = spot.y + spot.height; |
---|
6825 | | - info.g.setColor(Color.blue); |
---|
6826 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7423 | + clickInfo.g.setColor(Color.cyan); |
---|
| 7424 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6827 | 7425 | // if (CameraPane.Xmin > spot.x) |
---|
6828 | 7426 | // { |
---|
6829 | 7427 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6840 | 7438 | // { |
---|
6841 | 7439 | // CameraPane.Ymax = spoth; |
---|
6842 | 7440 | // } |
---|
6843 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6844 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7441 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7442 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
6845 | 7443 | spot.translate(0, -32); |
---|
6846 | | - info.g.setColor(Color.green); |
---|
6847 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7444 | + clickInfo.g.setColor(Color.yellow); |
---|
| 7445 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7446 | + clickInfo.g.setColor(Color.green); |
---|
6848 | 7447 | // if (CameraPane.Xmin > spot.x) |
---|
6849 | 7448 | // { |
---|
6850 | 7449 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6861 | 7460 | // { |
---|
6862 | 7461 | // CameraPane.Ymax = spoth; |
---|
6863 | 7462 | // } |
---|
6864 | | - info.g.drawArc(boundary.x, boundary.y, |
---|
6865 | | - boundary.width, boundary.height, 0, 360); |
---|
| 7463 | + clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, |
---|
| 7464 | + (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); |
---|
6866 | 7465 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
6867 | 7466 | // if (CameraPane.Xmin > boundary.x) |
---|
6868 | 7467 | // { |
---|
.. | .. |
---|
6884 | 7483 | } |
---|
6885 | 7484 | } |
---|
6886 | 7485 | |
---|
6887 | | - boolean doEditClick0(ClickInfo info, int level) |
---|
| 7486 | + boolean doEditClick0(//ClickInfo clickInfo, |
---|
| 7487 | + int level) |
---|
6888 | 7488 | { |
---|
6889 | 7489 | if (level == 0) |
---|
6890 | 7490 | { |
---|
.. | .. |
---|
6893 | 7493 | |
---|
6894 | 7494 | boolean retval = false; |
---|
6895 | 7495 | |
---|
6896 | | - startX = info.x; |
---|
6897 | | - startY = info.y; |
---|
| 7496 | + startX = clickInfo.x; |
---|
| 7497 | + startY = clickInfo.y; |
---|
6898 | 7498 | |
---|
6899 | | - hitSomething = 0; |
---|
| 7499 | + hitSomething = -1; |
---|
6900 | 7500 | cVector origin = new cVector(); |
---|
6901 | 7501 | //LA.xformPos(origin, toParent, origin); |
---|
6902 | 7502 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
6904 | 7504 | { |
---|
6905 | 7505 | centerPt = new Point(0, 0); |
---|
6906 | 7506 | } |
---|
6907 | | - calcHotSpot(origin, info, centerPt, spot); |
---|
6908 | | - if (spot.contains(info.x, info.y)) |
---|
| 7507 | + calcHotSpot(origin, //info, |
---|
| 7508 | + centerPt, spot); |
---|
| 7509 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
6909 | 7510 | { |
---|
6910 | 7511 | hitSomething = hitCenter; |
---|
6911 | 7512 | retval = true; |
---|
6912 | 7513 | } |
---|
6913 | 7514 | spot.translate(32, 0); |
---|
6914 | | - if (spot.contains(info.x, info.y)) |
---|
| 7515 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
6915 | 7516 | { |
---|
6916 | 7517 | hitSomething = hitRotate; |
---|
6917 | 7518 | retval = true; |
---|
6918 | 7519 | } |
---|
6919 | 7520 | spot.translate(0, 32); |
---|
6920 | | - if (spot.contains(info.x, info.y)) |
---|
| 7521 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
6921 | 7522 | { |
---|
6922 | 7523 | hitSomething = hitScale; |
---|
| 7524 | + |
---|
| 7525 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7526 | + double hScale = (double) (clickInfo.x - centerPt.x) / 32; |
---|
| 7527 | + double sign = 1; |
---|
| 7528 | + if (hScale < 0) |
---|
| 7529 | + { |
---|
| 7530 | + sign = -1; |
---|
| 7531 | + } |
---|
| 7532 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
| 7533 | + if (hScale < 0.01) |
---|
| 7534 | + { |
---|
| 7535 | + //hScale = 0.01; |
---|
| 7536 | + } |
---|
| 7537 | + |
---|
| 7538 | + double vScale = (double) (clickInfo.y - centerPt.y) / 32; |
---|
| 7539 | + sign = 1; |
---|
| 7540 | + if (vScale < 0) |
---|
| 7541 | + { |
---|
| 7542 | + sign = -1; |
---|
| 7543 | + } |
---|
| 7544 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
| 7545 | + if (vScale < 0.01) |
---|
| 7546 | + { |
---|
| 7547 | + //vScale = 0.01; |
---|
| 7548 | + } |
---|
| 7549 | + |
---|
| 7550 | + clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale); |
---|
| 7551 | + |
---|
6923 | 7552 | retval = true; |
---|
6924 | 7553 | } |
---|
6925 | 7554 | |
---|
.. | .. |
---|
6929 | 7558 | } |
---|
6930 | 7559 | |
---|
6931 | 7560 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
6932 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7561 | + modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
6933 | 7562 | //System.out.println("modified = " + modified); |
---|
6934 | 7563 | //new Exception().printStackTrace(); |
---|
6935 | 7564 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
6957 | 7586 | return true; |
---|
6958 | 7587 | } |
---|
6959 | 7588 | |
---|
6960 | | - void doEditDrag0(ClickInfo info) |
---|
| 7589 | + void doEditDrag0(//ClickInfo info, |
---|
| 7590 | + boolean opposite) |
---|
6961 | 7591 | { |
---|
6962 | 7592 | if (hitSomething == 0) |
---|
6963 | 7593 | { |
---|
.. | .. |
---|
6971 | 7601 | |
---|
6972 | 7602 | //System.out.println("hitSomething = " + hitSomething); |
---|
6973 | 7603 | |
---|
6974 | | - double scale = 0.005f * info.camera.Distance(); |
---|
| 7604 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7605 | + |
---|
6975 | 7606 | cVector xlate = new cVector(); |
---|
6976 | 7607 | //cVector xlate2 = new cVector(); |
---|
6977 | 7608 | switch (hitSomething) |
---|
.. | .. |
---|
6984 | 7615 | |
---|
6985 | 7616 | scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
6986 | 7617 | |
---|
6987 | | - if (modified) |
---|
| 7618 | + if (modified || opposite) |
---|
6988 | 7619 | { |
---|
6989 | 7620 | //assert(false); |
---|
6990 | 7621 | /* |
---|
.. | .. |
---|
7004 | 7635 | toParent[3][i] = xlate.get(i); |
---|
7005 | 7636 | LA.matInvert(toParent, fromParent); |
---|
7006 | 7637 | */ |
---|
7007 | | - cVector delta = LA.newVector(0, 0, startY - info.y); |
---|
7008 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7638 | + cVector delta = LA.newVector(0, 0, startY - clickInfo.y); |
---|
| 7639 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7009 | 7640 | |
---|
7010 | 7641 | LA.matCopy(startMat, toParent); |
---|
7011 | 7642 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7014 | 7645 | } else |
---|
7015 | 7646 | { |
---|
7016 | 7647 | //LA.xformDir(delta, info.camera.fromScreen, delta); |
---|
7017 | | - cVector up = new cVector(info.camera.up); |
---|
| 7648 | + cVector up = new cVector(clickInfo.camera.up); |
---|
7018 | 7649 | cVector away = new cVector(); |
---|
7019 | 7650 | //cVector right2 = new cVector(); |
---|
7020 | 7651 | //LA.vecCross(up, cVector.Z, right); |
---|
.. | .. |
---|
7031 | 7662 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7032 | 7663 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7033 | 7664 | LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7034 | | - LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
| 7665 | + LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away); |
---|
7035 | 7666 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7036 | 7667 | LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7037 | 7668 | //LA.vecCross(up, cVector.Z, right2); |
---|
7038 | 7669 | |
---|
7039 | | - cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
| 7670 | + cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0); |
---|
7040 | 7671 | |
---|
7041 | 7672 | //System.out.println("DELTA0 = " + delta); |
---|
7042 | 7673 | //System.out.println("AWAY = " + info.camera.away); |
---|
7043 | 7674 | //System.out.println("UP = " + info.camera.up); |
---|
7044 | 7675 | if (away.z > 0) |
---|
7045 | 7676 | { |
---|
7046 | | - if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
| 7677 | + if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
7047 | 7678 | { |
---|
7048 | 7679 | delta.x = -delta.x; |
---|
7049 | 7680 | } else |
---|
.. | .. |
---|
7058 | 7689 | //System.out.println("DELTA1 = " + delta); |
---|
7059 | 7690 | LA.xformDir(delta, ClickInfo.matbuffer, delta); |
---|
7060 | 7691 | //System.out.println("DELTA2 = " + delta); |
---|
7061 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7692 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7062 | 7693 | LA.matCopy(startMat, toParent); |
---|
7063 | 7694 | //System.out.println("DELTA3 = " + delta); |
---|
7064 | 7695 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7068 | 7699 | break; |
---|
7069 | 7700 | |
---|
7070 | 7701 | case hitRotate: // rotate |
---|
7071 | | - int dx = info.x - centerPt.x; |
---|
7072 | | - int dy = -(info.y - centerPt.y); |
---|
| 7702 | + int dx = clickInfo.x - centerPt.x; |
---|
| 7703 | + int dy = -(clickInfo.y - centerPt.y); |
---|
7073 | 7704 | double angle = (double) Math.atan2(dx, dy); |
---|
7074 | 7705 | angle = -(1.570796 - angle); |
---|
7075 | 7706 | |
---|
.. | .. |
---|
7078 | 7709 | |
---|
7079 | 7710 | if (modified) |
---|
7080 | 7711 | { |
---|
| 7712 | + // Rotate 90 degrees |
---|
7081 | 7713 | angle /= (Math.PI / 4); |
---|
7082 | 7714 | angle = Math.floor(angle + 0.5); |
---|
7083 | 7715 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7091 | 7723 | } |
---|
7092 | 7724 | /**/ |
---|
7093 | 7725 | |
---|
7094 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7726 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7095 | 7727 | { |
---|
7096 | 7728 | case 1: // '\001' |
---|
7097 | 7729 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7118 | 7750 | break; |
---|
7119 | 7751 | |
---|
7120 | 7752 | case hitScale: // scale |
---|
7121 | | - double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7753 | + double hScale = (double) (clickInfo.x - centerPt.x) / 32; |
---|
| 7754 | + double sign = 1; |
---|
| 7755 | + if (hScale < 0) |
---|
| 7756 | + { |
---|
| 7757 | + sign = -1; |
---|
| 7758 | + } |
---|
| 7759 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7122 | 7760 | if (hScale < 0.01) |
---|
7123 | 7761 | { |
---|
7124 | | - hScale = 0.01; |
---|
| 7762 | + //hScale = 0.01; |
---|
7125 | 7763 | } |
---|
7126 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7127 | | - if (hScale < 0.01) |
---|
| 7764 | + |
---|
| 7765 | + double vScale = (double) (clickInfo.y - centerPt.y) / 32; |
---|
| 7766 | + sign = 1; |
---|
| 7767 | + if (vScale < 0) |
---|
7128 | 7768 | { |
---|
7129 | | - hScale = 0.01; |
---|
| 7769 | + sign = -1; |
---|
7130 | 7770 | } |
---|
7131 | | - double vScale = (double) (info.y - centerPt.y) / 32; |
---|
| 7771 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7132 | 7772 | if (vScale < 0.01) |
---|
7133 | 7773 | { |
---|
7134 | | - vScale = 0.01; |
---|
| 7774 | + //vScale = 0.01; |
---|
7135 | 7775 | } |
---|
7136 | | - vScale = Math.pow(vScale, scale * 50); |
---|
7137 | | - if (vScale < 0.01) |
---|
7138 | | - { |
---|
7139 | | - vScale = 0.01; |
---|
7140 | | - } |
---|
| 7776 | + |
---|
7141 | 7777 | LA.matCopy(startMat, toParent); |
---|
7142 | 7778 | /**/ |
---|
7143 | 7779 | for (int i = 0; i < 3; i++) |
---|
.. | .. |
---|
7147 | 7783 | } |
---|
7148 | 7784 | /**/ |
---|
7149 | 7785 | |
---|
7150 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7786 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale; |
---|
| 7787 | + |
---|
| 7788 | + if (totalScale < 0.01) |
---|
| 7789 | + { |
---|
| 7790 | + totalScale = 0.01; |
---|
| 7791 | + } |
---|
| 7792 | + |
---|
| 7793 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7151 | 7794 | { |
---|
7152 | 7795 | case 3: // '\001' |
---|
7153 | | - if (modified) |
---|
| 7796 | + if (modified || opposite) |
---|
7154 | 7797 | { |
---|
7155 | 7798 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7156 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7799 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7157 | 7800 | } // vScale, 1); |
---|
7158 | 7801 | else |
---|
7159 | 7802 | { |
---|
7160 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7803 | + // EXCEPTION! |
---|
| 7804 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7161 | 7805 | } // vScale, 1); |
---|
7162 | 7806 | break; |
---|
7163 | 7807 | |
---|
7164 | 7808 | case 2: // '\002' |
---|
7165 | | - if (modified) |
---|
| 7809 | + if (modified || opposite) |
---|
7166 | 7810 | { |
---|
7167 | 7811 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7168 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7812 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7169 | 7813 | } else |
---|
7170 | 7814 | { |
---|
7171 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7815 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7172 | 7816 | } |
---|
7173 | 7817 | break; |
---|
7174 | 7818 | |
---|
7175 | 7819 | case 1: // '\003' |
---|
7176 | | - if (modified) |
---|
| 7820 | + if (modified || opposite) |
---|
7177 | 7821 | { |
---|
7178 | 7822 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7179 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7823 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7180 | 7824 | } else |
---|
7181 | 7825 | { |
---|
7182 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7826 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7183 | 7827 | } |
---|
7184 | 7828 | break; |
---|
7185 | 7829 | } |
---|
.. | .. |
---|
7213 | 7857 | } // NEW ... |
---|
7214 | 7858 | |
---|
7215 | 7859 | |
---|
7216 | | - info.pane.repaint(); |
---|
| 7860 | + clickInfo.pane.repaint(); |
---|
7217 | 7861 | } |
---|
7218 | 7862 | |
---|
7219 | 7863 | boolean overflow = false; |
---|
.. | .. |
---|
7312 | 7956 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7313 | 7957 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7314 | 7958 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7959 | + |
---|
| 7960 | + String objname; |
---|
| 7961 | + |
---|
7315 | 7962 | if (false) //parent != null) |
---|
7316 | 7963 | { |
---|
7317 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7964 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7318 | 7965 | } else |
---|
7319 | 7966 | { |
---|
7320 | | - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); |
---|
| 7967 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7321 | 7968 | } // + super.toString(); |
---|
7322 | 7969 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
| 7970 | + |
---|
| 7971 | + if (!Globals.ADVANCED) |
---|
| 7972 | + return objname; |
---|
| 7973 | + |
---|
| 7974 | + return objname + " " + System.identityHashCode(this); |
---|
7323 | 7975 | } |
---|
7324 | 7976 | |
---|
7325 | 7977 | public int hashCode() |
---|
.. | .. |
---|
7375 | 8027 | objectUI.closeUI(); |
---|
7376 | 8028 | if (editWindow != null) |
---|
7377 | 8029 | { |
---|
| 8030 | + editWindow.ctrlPanel.FlushUI(); |
---|
7378 | 8031 | editWindow.refreshContents(); |
---|
7379 | 8032 | } // ? new |
---|
7380 | 8033 | objectUI = null; |
---|
.. | .. |
---|
7383 | 8036 | { |
---|
7384 | 8037 | editWindow = null; |
---|
7385 | 8038 | } // ? |
---|
| 8039 | + } |
---|
| 8040 | + else |
---|
| 8041 | + { |
---|
| 8042 | + //editWindow.closeUI(); |
---|
7386 | 8043 | } |
---|
7387 | 8044 | } |
---|
7388 | 8045 | |
---|
.. | .. |
---|
7395 | 8052 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7396 | 8053 | |
---|
7397 | 8054 | Object3D /*Composite*/ parent; |
---|
7398 | | - Object3D /*Composite*/ fileparent; |
---|
| 8055 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7399 | 8056 | |
---|
7400 | 8057 | double[][] toParent; // dynamic matrix |
---|
7401 | 8058 | double[][] fromParent; |
---|
.. | .. |
---|
7510 | 8167 | { |
---|
7511 | 8168 | assert(bRep != null); |
---|
7512 | 8169 | if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
7513 | | - GrafreeD.Assert(support.bRep == bRep.support); |
---|
| 8170 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
7514 | 8171 | } |
---|
7515 | 8172 | else |
---|
7516 | 8173 | { |
---|
.. | .. |
---|
7541 | 8198 | } |
---|
7542 | 8199 | |
---|
7543 | 8200 | transient ObjEditor editWindow; |
---|
| 8201 | + transient ObjEditor manipWindow; |
---|
| 8202 | + |
---|
| 8203 | + transient boolean pinned; |
---|
| 8204 | + |
---|
7544 | 8205 | transient ObjectUI objectUI; |
---|
7545 | 8206 | public static int povDepth = 0; |
---|
7546 | 8207 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
7559 | 8220 | private static cVector edge2 = new cVector(); |
---|
7560 | 8221 | //private static cVector norm = new cVector(); |
---|
7561 | 8222 | /*transient private*/ int hitSomething; |
---|
7562 | | - private static final int hitCenter = 1; |
---|
7563 | | - private static final int hitScale = 2; |
---|
7564 | | - private static final int hitRotate = 3; |
---|
| 8223 | + static final int hitCenter = 1; |
---|
| 8224 | + static final int hitScale = 2; |
---|
| 8225 | + static final int hitRotate = 3; |
---|
7565 | 8226 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7566 | 8227 | /*transient*/ private Point centerPt; |
---|
7567 | 8228 | /*transient*/ private int startX; |
---|