.. | .. |
---|
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 | + private UUID uuid = UUID.randomUUID(); |
---|
| 26 | + |
---|
| 27 | + // TEMPORARY for mocap undo. No need to be transient. |
---|
| 28 | + mocap.reader.BVHReader.BVHResult savebvh; |
---|
| 29 | + Object3D saveskeleton; |
---|
| 30 | + // |
---|
| 31 | + |
---|
| 32 | + byte[] versions[]; |
---|
| 33 | + int versionindex = -1; |
---|
| 34 | + |
---|
23 | 35 | ScriptNode scriptnode; |
---|
24 | 36 | |
---|
25 | 37 | void InitOthers() |
---|
.. | .. |
---|
100 | 112 | |
---|
101 | 113 | // transient boolean reduced; // for morph reduction |
---|
102 | 114 | |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
104 | | -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
| 115 | + transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
| 116 | + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
105 | 117 | |
---|
106 | | -transient Object3D transientsupport; // for cloning |
---|
107 | | -transient boolean transientlink2master; |
---|
| 118 | + transient Object3D transientsupport; // for cloning |
---|
| 119 | + transient boolean transientlink2master; |
---|
108 | 120 | |
---|
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) |
---|
| 121 | + void SaveSupports() |
---|
121 | 122 | { |
---|
122 | | - bRep.SaveSupports(); |
---|
| 123 | + if (blockloop) |
---|
| 124 | + return; |
---|
| 125 | + |
---|
| 126 | + transientsupport = support; |
---|
| 127 | + transientlink2master = link2master; |
---|
| 128 | + |
---|
| 129 | + support = null; |
---|
| 130 | + link2master = false; |
---|
| 131 | + |
---|
| 132 | + if (bRep != null) |
---|
| 133 | + { |
---|
| 134 | + bRep.SaveSupports(); |
---|
| 135 | + } |
---|
| 136 | + |
---|
| 137 | + for (int i = 0; i < Size(); i++) |
---|
| 138 | + { |
---|
| 139 | + Object3D child = (Object3D) get(i); |
---|
| 140 | + if (child == null) |
---|
| 141 | + continue; |
---|
| 142 | + blockloop = true; |
---|
| 143 | + child.SaveSupports(); |
---|
| 144 | + blockloop = false; |
---|
| 145 | + } |
---|
123 | 146 | } |
---|
124 | | - |
---|
125 | | - for (int i = 0; i < Size(); i++) |
---|
| 147 | + |
---|
| 148 | + void RestoreSupports() |
---|
126 | 149 | { |
---|
127 | | - Object3D child = (Object3D) get(i); |
---|
128 | | - if (child == null) |
---|
129 | | - continue; |
---|
| 150 | + if (blockloop) |
---|
| 151 | + return; |
---|
| 152 | + |
---|
| 153 | + support = transientsupport; |
---|
| 154 | + link2master = transientlink2master; |
---|
| 155 | + transientsupport = null; |
---|
| 156 | + transientlink2master = false; |
---|
| 157 | + |
---|
| 158 | + if (bRep != null) |
---|
| 159 | + { |
---|
| 160 | + bRep.RestoreSupports(); |
---|
| 161 | + } |
---|
| 162 | + |
---|
| 163 | + for (int i = 0; i < Size(); i++) |
---|
| 164 | + { |
---|
| 165 | + Object3D child = (Object3D) get(i); |
---|
| 166 | + if (child == null) |
---|
| 167 | + continue; |
---|
| 168 | + blockloop = true; |
---|
| 169 | + child.RestoreSupports(); |
---|
| 170 | + blockloop = false; |
---|
| 171 | + } |
---|
| 172 | + } |
---|
| 173 | + |
---|
| 174 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 175 | + { |
---|
| 176 | + Object3D o; |
---|
| 177 | + |
---|
| 178 | + if (hashtable.containsKey(GetUUID())) |
---|
| 179 | + { |
---|
| 180 | + o = hashtable.get(GetUUID()); |
---|
| 181 | + |
---|
| 182 | + Grafreed.Assert(this.bRep == o.bRep); |
---|
| 183 | + //if (this.bRep != null) |
---|
| 184 | + // assert(this.bRep.support == o.transientrep); |
---|
| 185 | + if (this.support != null) |
---|
| 186 | + assert(this.support.bRep == o.transientrep); |
---|
| 187 | + } |
---|
| 188 | + else |
---|
| 189 | + { |
---|
| 190 | + o = new Object3D("copy of " + this.name); |
---|
| 191 | + |
---|
| 192 | + hashtable.put(GetUUID(), o); |
---|
| 193 | + } |
---|
| 194 | + |
---|
| 195 | + if (!blockloop) |
---|
| 196 | + { |
---|
| 197 | + blockloop = true; |
---|
| 198 | + |
---|
| 199 | + for (int i=0; i<Size(); i++) |
---|
| 200 | + { |
---|
| 201 | + get(i).ExtractBigData(hashtable); |
---|
| 202 | + } |
---|
| 203 | + |
---|
| 204 | + blockloop = false; |
---|
| 205 | + } |
---|
| 206 | + |
---|
| 207 | + ExtractBigData(o); |
---|
| 208 | + } |
---|
| 209 | + |
---|
| 210 | + void ExtractBigData(Object3D o) |
---|
| 211 | + { |
---|
| 212 | + if (o.bRep != null) |
---|
| 213 | + Grafreed.Assert(o.bRep == this.bRep); |
---|
| 214 | + |
---|
| 215 | + o.bRep = this.bRep; |
---|
| 216 | +// July 2019 if (this.bRep != null) |
---|
| 217 | +// { |
---|
| 218 | +// o.transientrep = this.bRep.support; |
---|
| 219 | +// o.bRep.support = null; |
---|
| 220 | +// } |
---|
| 221 | + o.selection = this.selection; |
---|
| 222 | + o.versions = this.versions; |
---|
| 223 | + o.versionindex = this.versionindex; |
---|
| 224 | + |
---|
| 225 | + if (this.support != null) |
---|
| 226 | + { |
---|
| 227 | + if (o.transientrep != null) |
---|
| 228 | + Grafreed.Assert(o.transientrep == this.support.bRep); |
---|
| 229 | + |
---|
| 230 | + o.transientrep = this.support.bRep; |
---|
| 231 | + this.support.bRep = null; |
---|
| 232 | + } |
---|
| 233 | + |
---|
| 234 | + // o.support = this.support; |
---|
| 235 | + // o.fileparent = this.fileparent; |
---|
| 236 | + // if (this.bRep != null) |
---|
| 237 | + // o.bRep = this.bRep.support; |
---|
| 238 | + |
---|
| 239 | + this.bRep = null; |
---|
| 240 | + // if (this.bRep != null) |
---|
| 241 | + // this.bRep.support = null; |
---|
| 242 | + // this.support = null; |
---|
| 243 | + // this.fileparent = null; |
---|
| 244 | + } |
---|
| 245 | + |
---|
| 246 | + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 247 | + { |
---|
| 248 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 249 | + return; |
---|
| 250 | + |
---|
| 251 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 252 | + |
---|
| 253 | + RestoreBigData(o); |
---|
| 254 | + |
---|
| 255 | + if (blockloop) |
---|
| 256 | + return; |
---|
| 257 | + |
---|
130 | 258 | blockloop = true; |
---|
131 | | - child.SaveSupports(); |
---|
| 259 | + |
---|
| 260 | + //hashtable.remove(GetUUID()); |
---|
| 261 | + |
---|
| 262 | + for (int i=0; i<Size(); i++) |
---|
| 263 | + { |
---|
| 264 | + get(i).RestoreBigData(hashtable); |
---|
| 265 | + } |
---|
| 266 | + |
---|
132 | 267 | blockloop = false; |
---|
133 | 268 | } |
---|
134 | | -} |
---|
135 | 269 | |
---|
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) |
---|
| 270 | + void RestoreBigData(Object3D o) |
---|
147 | 271 | { |
---|
148 | | - bRep.RestoreSupports(); |
---|
| 272 | + this.bRep = o.bRep; |
---|
| 273 | + if (this.support != null && o.transientrep != null) |
---|
| 274 | + { |
---|
| 275 | + this.support.bRep = o.transientrep; |
---|
| 276 | + } |
---|
| 277 | + |
---|
| 278 | + this.selection = o.selection; |
---|
| 279 | + |
---|
| 280 | + this.versions = o.versions; |
---|
| 281 | + this.versionindex = o.versionindex; |
---|
| 282 | +// July 2019 if (this.bRep != null) |
---|
| 283 | +// this.bRep.support = o.transientrep; |
---|
| 284 | + // this.support = o.support; |
---|
| 285 | + // this.fileparent = o.fileparent; |
---|
149 | 286 | } |
---|
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 | 287 | |
---|
162 | 288 | // MOCAP SUPPORT |
---|
163 | 289 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
300 | 426 | } |
---|
301 | 427 | |
---|
302 | 428 | boolean live = false; |
---|
| 429 | + transient boolean keepdontselect; |
---|
| 430 | + boolean dontselect = false; |
---|
303 | 431 | boolean hide = false; |
---|
304 | 432 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 433 | boolean marked = false; // animation node |
---|
.. | .. |
---|
481 | 609 | toParent = LA.newMatrix(); |
---|
482 | 610 | fromParent = LA.newMatrix(); |
---|
483 | 611 | } |
---|
| 612 | + |
---|
484 | 613 | if (toParentMarked == null) |
---|
485 | 614 | { |
---|
486 | 615 | if (maxcount != 1) |
---|
487 | 616 | { |
---|
488 | 617 | new Exception().printStackTrace(); |
---|
489 | 618 | } |
---|
| 619 | + |
---|
490 | 620 | toParentMarked = LA.newMatrix(); |
---|
491 | 621 | fromParentMarked = LA.newMatrix(); |
---|
492 | 622 | } |
---|
.. | .. |
---|
774 | 904 | if (step == 0) |
---|
775 | 905 | step = 1; |
---|
776 | 906 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 907 | + maxcount = 128; // 2048; // 4; |
---|
778 | 908 | // if (acceleration == 0) |
---|
779 | 909 | // acceleration = 10; |
---|
780 | 910 | if (delay == 0) // serial |
---|
.. | .. |
---|
797 | 927 | |
---|
798 | 928 | if (marked && Globals.isLIVE() && live && |
---|
799 | 929 | //TEMP21aug2018 |
---|
800 | | - Globals.DrawMode() == iCameraPane.SHADOW && |
---|
| 930 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
801 | 931 | currentframe != Globals.framecount) |
---|
802 | 932 | { |
---|
803 | 933 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
809 | 939 | |
---|
810 | 940 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
811 | 941 | |
---|
812 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 942 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 943 | + (step == 1 && changedir)) |
---|
813 | 944 | { |
---|
814 | 945 | countdown = 1; |
---|
815 | 946 | delay = speedup?8:1; |
---|
.. | .. |
---|
881 | 1012 | if (material == null || material.multiply) |
---|
882 | 1013 | return true; |
---|
883 | 1014 | |
---|
| 1015 | + // Transparent objects are dynamic because we have to sort the triangles. |
---|
884 | 1016 | return material.opacity > 0.99; |
---|
885 | 1017 | } |
---|
886 | 1018 | |
---|
.. | .. |
---|
912 | 1044 | fromParent = null; // LA.newMatrix(); |
---|
913 | 1045 | bRep = null; // new BoundaryRep(); |
---|
914 | 1046 | |
---|
| 1047 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 1048 | + { |
---|
| 1049 | + name = oname; |
---|
| 1050 | + } |
---|
| 1051 | + |
---|
915 | 1052 | /* |
---|
916 | 1053 | float hue = (float)Math.random(); |
---|
917 | 1054 | Color col; |
---|
.. | .. |
---|
954 | 1091 | |
---|
955 | 1092 | public Object clone() |
---|
956 | 1093 | { |
---|
957 | | - return GrafreeD.clone(this); |
---|
| 1094 | + return Grafreed.clone(this); |
---|
958 | 1095 | } |
---|
959 | 1096 | |
---|
960 | 1097 | Object3D copyExpand() |
---|
.. | .. |
---|
1276 | 1413 | toParent = LA.newMatrix(); |
---|
1277 | 1414 | fromParent = LA.newMatrix(); |
---|
1278 | 1415 | } |
---|
| 1416 | + |
---|
1279 | 1417 | LA.matCopy(other.toParent, toParent); |
---|
1280 | 1418 | LA.matCopy(other.fromParent, fromParent); |
---|
1281 | 1419 | |
---|
.. | .. |
---|
1470 | 1608 | BoundaryRep.SEUIL = other.material.cameralight; |
---|
1471 | 1609 | |
---|
1472 | 1610 | // Set default to 0.1 |
---|
1473 | | - BoundaryRep.SEUIL /= 2; |
---|
| 1611 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
1474 | 1612 | System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
1475 | 1613 | } |
---|
1476 | 1614 | |
---|
.. | .. |
---|
1729 | 1867 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1730 | 1868 | o.bRep = transientrep; |
---|
1731 | 1869 | if (clone) |
---|
1732 | | - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 1870 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1733 | 1871 | o.CreateMaterial(); |
---|
1734 | 1872 | o.SetAttributes(this, -1); |
---|
1735 | 1873 | //parent |
---|
.. | .. |
---|
1742 | 1880 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1743 | 1881 | o.bRep = bRep; |
---|
1744 | 1882 | if (clone) |
---|
1745 | | - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 1883 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1746 | 1884 | o.CreateMaterial(); |
---|
1747 | 1885 | //o.overwriteThis(this, -1); |
---|
1748 | 1886 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1829 | 1967 | if (obj.name == null) |
---|
1830 | 1968 | continue; // can't be a null one |
---|
1831 | 1969 | |
---|
| 1970 | + // Try perfect match first. |
---|
1832 | 1971 | if (n.equals(obj.name)) |
---|
1833 | 1972 | { |
---|
1834 | 1973 | theobj = obj; |
---|
1835 | 1974 | count++; |
---|
1836 | 1975 | } |
---|
1837 | 1976 | } |
---|
| 1977 | + |
---|
| 1978 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1838 | 1979 | |
---|
1839 | 1980 | if (count != 1) |
---|
1840 | 1981 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2294 | 2435 | } |
---|
2295 | 2436 | */ |
---|
2296 | 2437 | } |
---|
| 2438 | + else |
---|
| 2439 | + { |
---|
| 2440 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2441 | + } |
---|
2297 | 2442 | } |
---|
2298 | 2443 | |
---|
2299 | 2444 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
2300 | 2445 | { |
---|
2301 | 2446 | if (newWindow) |
---|
2302 | 2447 | { |
---|
| 2448 | + new Exception().printStackTrace(); |
---|
2303 | 2449 | System.exit(0); |
---|
2304 | 2450 | if (parent != null) |
---|
2305 | 2451 | { |
---|
.. | .. |
---|
2334 | 2480 | { |
---|
2335 | 2481 | editWindow.refreshContents(); |
---|
2336 | 2482 | } |
---|
| 2483 | + else |
---|
| 2484 | + { |
---|
| 2485 | + if (manipWindow != null) |
---|
| 2486 | + { |
---|
| 2487 | + manipWindow.refreshContents(); |
---|
| 2488 | + } |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2337 | 2491 | //if (parent != null) |
---|
2338 | 2492 | //parent.refreshEditWindow(); |
---|
2339 | 2493 | } |
---|
.. | .. |
---|
2413 | 2567 | private static final int editSelf = 1; |
---|
2414 | 2568 | private static final int editChild = 2; |
---|
2415 | 2569 | |
---|
2416 | | - void drawEditHandles(ClickInfo info, int level) |
---|
| 2570 | + void drawEditHandles(//ClickInfo info, |
---|
| 2571 | + int level) |
---|
2417 | 2572 | { |
---|
2418 | 2573 | if (level == 0) |
---|
2419 | 2574 | { |
---|
.. | .. |
---|
2421 | 2576 | return; |
---|
2422 | 2577 | |
---|
2423 | 2578 | Object3D selectee; |
---|
2424 | | - for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1)) |
---|
| 2579 | + for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info, |
---|
| 2580 | + level + 1)) |
---|
2425 | 2581 | { |
---|
2426 | 2582 | selectee = (Object3D) e.nextElement(); |
---|
2427 | 2583 | } |
---|
.. | .. |
---|
2429 | 2585 | } else |
---|
2430 | 2586 | { |
---|
2431 | 2587 | //super. |
---|
2432 | | - drawEditHandles0(info, level + 1); |
---|
| 2588 | + drawEditHandles0(//info, |
---|
| 2589 | + level + 1); |
---|
2433 | 2590 | } |
---|
2434 | 2591 | } |
---|
2435 | 2592 | |
---|
2436 | | - boolean doEditClick(ClickInfo info, int level) |
---|
| 2593 | + boolean doEditClick(//ClickInfo info, |
---|
| 2594 | + int level) |
---|
2437 | 2595 | { |
---|
2438 | 2596 | doSomething = 0; |
---|
2439 | 2597 | if (level == 0) |
---|
2440 | 2598 | { |
---|
2441 | | - return doParentClick(info); |
---|
| 2599 | + return doParentClick(); //info); |
---|
2442 | 2600 | } |
---|
2443 | 2601 | if (//super. |
---|
2444 | | - doEditClick0(info, level)) |
---|
| 2602 | + doEditClick0(//info, |
---|
| 2603 | + level)) |
---|
2445 | 2604 | { |
---|
2446 | 2605 | doSomething = 1; |
---|
2447 | 2606 | return true; |
---|
.. | .. |
---|
2451 | 2610 | } |
---|
2452 | 2611 | } |
---|
2453 | 2612 | |
---|
2454 | | - boolean doParentClick(ClickInfo info) |
---|
| 2613 | + boolean doParentClick() //ClickInfo info) |
---|
2455 | 2614 | { |
---|
2456 | 2615 | if (selection == null) |
---|
2457 | 2616 | { |
---|
.. | .. |
---|
2464 | 2623 | for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();) |
---|
2465 | 2624 | { |
---|
2466 | 2625 | Object3D selectee = (Object3D) e.nextElement(); |
---|
2467 | | - if (selectee.doEditClick(info, 1)) |
---|
| 2626 | + if (selectee.doEditClick(//info, |
---|
| 2627 | + 1)) |
---|
2468 | 2628 | { |
---|
2469 | 2629 | childToDrag = selectee; |
---|
2470 | 2630 | doSomething = 2; |
---|
.. | .. |
---|
2476 | 2636 | return retval; |
---|
2477 | 2637 | } |
---|
2478 | 2638 | |
---|
2479 | | - void doEditDrag(ClickInfo info) |
---|
| 2639 | + void doEditDrag(//ClickInfo clickInfo, |
---|
| 2640 | + boolean opposite) |
---|
2480 | 2641 | { |
---|
2481 | 2642 | switch (doSomething) |
---|
2482 | 2643 | { |
---|
2483 | 2644 | case 1: // '\001' |
---|
2484 | 2645 | //super. |
---|
2485 | | - doEditDrag0(info); |
---|
| 2646 | + doEditDrag0(//clickInfo, |
---|
| 2647 | + opposite); |
---|
2486 | 2648 | break; |
---|
2487 | 2649 | |
---|
2488 | 2650 | case 2: // '\002' |
---|
.. | .. |
---|
2495 | 2657 | { |
---|
2496 | 2658 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2497 | 2659 | //childToDrag.doEditDrag(info); |
---|
2498 | | - sel.doEditDrag(info); |
---|
| 2660 | + sel.doEditDrag(//clickInfo, |
---|
| 2661 | + opposite); |
---|
2499 | 2662 | } else |
---|
2500 | 2663 | { |
---|
2501 | 2664 | //super. |
---|
2502 | | - doEditDrag0(info); |
---|
| 2665 | + doEditDrag0(//clickInfo, |
---|
| 2666 | + opposite); |
---|
2503 | 2667 | } |
---|
2504 | 2668 | } |
---|
2505 | 2669 | break; |
---|
.. | .. |
---|
2517 | 2681 | { |
---|
2518 | 2682 | deselectAll(); |
---|
2519 | 2683 | } |
---|
| 2684 | + |
---|
| 2685 | + new Exception().printStackTrace(); |
---|
| 2686 | + |
---|
2520 | 2687 | ClickInfo newInfo = new ClickInfo(); |
---|
2521 | 2688 | newInfo.flags = info.flags; |
---|
2522 | 2689 | newInfo.bounds = info.bounds; |
---|
.. | .. |
---|
2609 | 2776 | void GenNormalsS(boolean crease) |
---|
2610 | 2777 | { |
---|
2611 | 2778 | selection.GenNormals(crease); |
---|
| 2779 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2780 | +// { |
---|
| 2781 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2782 | +// selectee.GenNormals(crease); |
---|
| 2783 | +// } |
---|
| 2784 | + |
---|
| 2785 | + //Touch(); |
---|
| 2786 | + } |
---|
| 2787 | + |
---|
| 2788 | + void GenNormalsMeshS() |
---|
| 2789 | + { |
---|
| 2790 | + selection.GenNormalsMesh(); |
---|
2612 | 2791 | // for (int i=0; i<selection.size(); i++) |
---|
2613 | 2792 | // { |
---|
2614 | 2793 | // Object3D selectee = (Object3D) selection.elementAt(i); |
---|
.. | .. |
---|
2749 | 2928 | if (child == null) |
---|
2750 | 2929 | continue; |
---|
2751 | 2930 | child.GenNormals(crease); |
---|
| 2931 | +// Children().release(i); |
---|
| 2932 | + } |
---|
| 2933 | + blockloop = false; |
---|
| 2934 | + } |
---|
| 2935 | + |
---|
| 2936 | + void GenNormalsMesh() |
---|
| 2937 | + { |
---|
| 2938 | + if (blockloop) |
---|
| 2939 | + return; |
---|
| 2940 | + |
---|
| 2941 | + blockloop = true; |
---|
| 2942 | + GenNormalsMesh0(); |
---|
| 2943 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2944 | + { |
---|
| 2945 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2946 | + if (child == null) |
---|
| 2947 | + continue; |
---|
| 2948 | + child.GenNormalsMesh(); |
---|
2752 | 2949 | // Children().release(i); |
---|
2753 | 2950 | } |
---|
2754 | 2951 | blockloop = false; |
---|
.. | .. |
---|
2906 | 3103 | { |
---|
2907 | 3104 | if (bRep != null) |
---|
2908 | 3105 | { |
---|
2909 | | - bRep.GenUV(); |
---|
| 3106 | + bRep.GenUV(); //1); |
---|
| 3107 | + //bRep.UnfoldUV(); |
---|
2910 | 3108 | Touch(); |
---|
2911 | 3109 | } |
---|
2912 | 3110 | } |
---|
.. | .. |
---|
2920 | 3118 | } |
---|
2921 | 3119 | } |
---|
2922 | 3120 | |
---|
| 3121 | + void GenNormalsMesh0() |
---|
| 3122 | + { |
---|
| 3123 | + if (bRep != null) |
---|
| 3124 | + { |
---|
| 3125 | + bRep.GenerateNormalsMesh(); |
---|
| 3126 | + Touch(); |
---|
| 3127 | + } |
---|
| 3128 | + } |
---|
| 3129 | + |
---|
2923 | 3130 | void GenNormalsMINE0() |
---|
2924 | 3131 | { |
---|
2925 | 3132 | if (bRep != null) |
---|
2926 | 3133 | { |
---|
2927 | | - bRep.GenerateNormalsMINE(); |
---|
| 3134 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
2928 | 3135 | Touch(); |
---|
2929 | 3136 | } |
---|
2930 | 3137 | } |
---|
.. | .. |
---|
2981 | 3188 | blockloop = false; |
---|
2982 | 3189 | } |
---|
2983 | 3190 | |
---|
| 3191 | + void TransformChildren() |
---|
| 3192 | + { |
---|
| 3193 | + if (toParent != null) |
---|
| 3194 | + { |
---|
| 3195 | + for (int i=Size(); --i>=0;) |
---|
| 3196 | + { |
---|
| 3197 | + Object3D v = get(i); |
---|
| 3198 | + |
---|
| 3199 | + if (v.toParent == null) |
---|
| 3200 | + { |
---|
| 3201 | + v.toParent = LA.newMatrix(); |
---|
| 3202 | + v.fromParent = LA.newMatrix(); |
---|
| 3203 | + } |
---|
| 3204 | + |
---|
| 3205 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3206 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3207 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3208 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
| 3209 | + } |
---|
| 3210 | + |
---|
| 3211 | + toParent = null; // LA.matIdentity(toParent); |
---|
| 3212 | + fromParent = null; // LA.matIdentity(fromParent); |
---|
| 3213 | + |
---|
| 3214 | + Touch(); |
---|
| 3215 | + } |
---|
| 3216 | + } |
---|
| 3217 | + |
---|
2984 | 3218 | void TransformGeometry() |
---|
2985 | 3219 | { |
---|
2986 | 3220 | Object3D obj = this; |
---|
.. | .. |
---|
3202 | 3436 | |
---|
3203 | 3437 | BoundaryRep sup = bRep.support; |
---|
3204 | 3438 | bRep.support = null; |
---|
3205 | | - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 3439 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3206 | 3440 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3207 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3441 | + |
---|
| 3442 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3443 | + |
---|
3208 | 3444 | bRep = temprep; |
---|
3209 | 3445 | bRep.support = sup; |
---|
3210 | 3446 | Touch(); |
---|
.. | .. |
---|
3341 | 3577 | if (blockloop) |
---|
3342 | 3578 | return; |
---|
3343 | 3579 | |
---|
3344 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3580 | + if (//marked || // does not make sense |
---|
| 3581 | + (bRep != null || material != null)) // borderline... |
---|
3345 | 3582 | live = h; |
---|
3346 | 3583 | |
---|
3347 | 3584 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3362 | 3599 | return; |
---|
3363 | 3600 | |
---|
3364 | 3601 | //if (bRep != null) |
---|
3365 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3602 | + if (//marked || // does not make sense |
---|
| 3603 | + (bRep != null || material != null)) // borderline... |
---|
3366 | 3604 | link2master = h; |
---|
3367 | 3605 | |
---|
3368 | 3606 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3382 | 3620 | if (blockloop) |
---|
3383 | 3621 | return; |
---|
3384 | 3622 | |
---|
3385 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3623 | + if (//marked || // does not make sense |
---|
| 3624 | + (bRep != null || material != null)) // borderline... |
---|
3386 | 3625 | hide = h; |
---|
3387 | 3626 | |
---|
3388 | 3627 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3402 | 3641 | if (blockloop) |
---|
3403 | 3642 | return; |
---|
3404 | 3643 | |
---|
3405 | | - if (bRep != null && material != null) // borderline... |
---|
| 3644 | + if (bRep != null || material != null) // borderline... |
---|
3406 | 3645 | marked = h; |
---|
3407 | 3646 | |
---|
3408 | 3647 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3412 | 3651 | continue; |
---|
3413 | 3652 | blockloop = true; |
---|
3414 | 3653 | child.MarkLeaves(h); |
---|
| 3654 | + blockloop = false; |
---|
| 3655 | + // release(i); |
---|
| 3656 | + } |
---|
| 3657 | + } |
---|
| 3658 | + |
---|
| 3659 | + void RewindLeaves(boolean h) |
---|
| 3660 | + { |
---|
| 3661 | + if (blockloop) |
---|
| 3662 | + return; |
---|
| 3663 | + |
---|
| 3664 | + if (bRep != null || material != null) // borderline... |
---|
| 3665 | + rewind = h; |
---|
| 3666 | + |
---|
| 3667 | + for (int i = 0; i < Size(); i++) |
---|
| 3668 | + { |
---|
| 3669 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3670 | + if (child == null) |
---|
| 3671 | + continue; |
---|
| 3672 | + blockloop = true; |
---|
| 3673 | + child.RewindLeaves(h); |
---|
| 3674 | + blockloop = false; |
---|
| 3675 | + // release(i); |
---|
| 3676 | + } |
---|
| 3677 | + } |
---|
| 3678 | + |
---|
| 3679 | + void RandomLeaves(boolean h) |
---|
| 3680 | + { |
---|
| 3681 | + if (blockloop) |
---|
| 3682 | + return; |
---|
| 3683 | + |
---|
| 3684 | + if (bRep != null || material != null) // borderline... |
---|
| 3685 | + random = h; |
---|
| 3686 | + |
---|
| 3687 | + for (int i = 0; i < Size(); i++) |
---|
| 3688 | + { |
---|
| 3689 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3690 | + if (child == null) |
---|
| 3691 | + continue; |
---|
| 3692 | + blockloop = true; |
---|
| 3693 | + child.RandomLeaves(h); |
---|
3415 | 3694 | blockloop = false; |
---|
3416 | 3695 | // release(i); |
---|
3417 | 3696 | } |
---|
.. | .. |
---|
3726 | 4005 | if (child == null) |
---|
3727 | 4006 | continue; |
---|
3728 | 4007 | |
---|
3729 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4008 | + if (Grafreed.RENDERME > 0) |
---|
3730 | 4009 | { |
---|
3731 | 4010 | if (child instanceof Merge) |
---|
3732 | 4011 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3877 | 4156 | if (child == null) |
---|
3878 | 4157 | continue; |
---|
3879 | 4158 | |
---|
3880 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4159 | + if (Grafreed.RENDERME > 0) |
---|
3881 | 4160 | { |
---|
3882 | 4161 | if (child instanceof Merge) |
---|
3883 | 4162 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4072 | 4351 | if (child == null) |
---|
4073 | 4352 | continue; |
---|
4074 | 4353 | |
---|
4075 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4354 | + if (Grafreed.RENDERME > 0) |
---|
4076 | 4355 | { |
---|
4077 | 4356 | if (child instanceof Merge) |
---|
4078 | 4357 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4185 | 4464 | { |
---|
4186 | 4465 | blockloop = true; |
---|
4187 | 4466 | get(i).RepairShadow(); |
---|
| 4467 | + blockloop = false; |
---|
| 4468 | + } |
---|
| 4469 | + } |
---|
| 4470 | + |
---|
| 4471 | + void RepairSOV() |
---|
| 4472 | + { |
---|
| 4473 | + if (blockloop) |
---|
| 4474 | + return; |
---|
| 4475 | + |
---|
| 4476 | + String texname = this.GetPigmentTexture(); |
---|
| 4477 | + |
---|
| 4478 | + if (texname.startsWith("sov")) |
---|
| 4479 | + { |
---|
| 4480 | + String[] s = texname.split("/"); |
---|
| 4481 | + |
---|
| 4482 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4483 | + |
---|
| 4484 | + texname = sname[0]; |
---|
| 4485 | + |
---|
| 4486 | + if (sname.length > 1) |
---|
| 4487 | + { |
---|
| 4488 | + texname += "Color.jpg"; |
---|
| 4489 | + } |
---|
| 4490 | + |
---|
| 4491 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4492 | + } |
---|
| 4493 | + |
---|
| 4494 | + texname = this.GetBumpTexture(); |
---|
| 4495 | + |
---|
| 4496 | + if (texname.startsWith("sov")) |
---|
| 4497 | + { |
---|
| 4498 | + String[] s = texname.split("/"); |
---|
| 4499 | + |
---|
| 4500 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4501 | + |
---|
| 4502 | + texname = sname[0]; |
---|
| 4503 | + |
---|
| 4504 | + if (sname.length > 1) |
---|
| 4505 | + { |
---|
| 4506 | + texname += "Bump.jpg"; |
---|
| 4507 | + } |
---|
| 4508 | + |
---|
| 4509 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4510 | + } |
---|
| 4511 | + |
---|
| 4512 | + for (int i=0; i<Size(); i++) |
---|
| 4513 | + { |
---|
| 4514 | + blockloop = true; |
---|
| 4515 | + get(i).RepairSOV(); |
---|
4188 | 4516 | blockloop = false; |
---|
4189 | 4517 | } |
---|
4190 | 4518 | } |
---|
.. | .. |
---|
4679 | 5007 | |
---|
4680 | 5008 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4681 | 5009 | { |
---|
4682 | | - if (hide) |
---|
| 5010 | + if (hide || dontselect) |
---|
4683 | 5011 | return null; |
---|
4684 | 5012 | |
---|
4685 | 5013 | if (count <= 0) |
---|
.. | .. |
---|
4703 | 5031 | } |
---|
4704 | 5032 | } |
---|
4705 | 5033 | |
---|
| 5034 | + ObjEditor GetWindow() |
---|
| 5035 | + { |
---|
| 5036 | + if (editWindow != null) |
---|
| 5037 | + return editWindow; |
---|
| 5038 | + |
---|
| 5039 | + return manipWindow; |
---|
| 5040 | + } |
---|
| 5041 | + |
---|
4706 | 5042 | cTreePath Select(int indexcount, boolean deselect) |
---|
4707 | 5043 | { |
---|
4708 | | - if (hide) |
---|
| 5044 | + if (hide || dontselect) |
---|
4709 | 5045 | return null; |
---|
4710 | 5046 | |
---|
4711 | 5047 | if (count <= 0) |
---|
.. | .. |
---|
4739 | 5075 | if (leaf != null) |
---|
4740 | 5076 | { |
---|
4741 | 5077 | cTreePath tp = new cTreePath(this, leaf); |
---|
4742 | | - if (editWindow != null) |
---|
| 5078 | + ObjEditor window = GetWindow(); |
---|
| 5079 | + if (window != null) |
---|
4743 | 5080 | { |
---|
4744 | 5081 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4745 | | - editWindow.Select(tp, deselect, true); |
---|
| 5082 | + window.Select(tp, deselect, true); |
---|
4746 | 5083 | } |
---|
4747 | 5084 | |
---|
4748 | 5085 | return tp; |
---|
.. | .. |
---|
4759 | 5096 | |
---|
4760 | 5097 | if (child == null) |
---|
4761 | 5098 | continue; |
---|
| 5099 | + |
---|
4762 | 5100 | if (child.HasTransparency() && child.size() != 0) |
---|
4763 | 5101 | { |
---|
4764 | 5102 | cTreePath leaf = child.Select(indexcount, deselect); |
---|
.. | .. |
---|
4768 | 5106 | if (leaf != null) |
---|
4769 | 5107 | { |
---|
4770 | 5108 | cTreePath tp = new cTreePath(this, leaf); |
---|
4771 | | - if (editWindow != null) |
---|
| 5109 | + ObjEditor window = GetWindow(); |
---|
| 5110 | + if (window != null) |
---|
4772 | 5111 | { |
---|
4773 | | - editWindow.Select(tp, deselect, true); |
---|
| 5112 | + window.Select(tp, deselect, true); |
---|
4774 | 5113 | } |
---|
4775 | 5114 | |
---|
4776 | 5115 | return tp; |
---|
.. | .. |
---|
5095 | 5434 | blockloop = false; |
---|
5096 | 5435 | } |
---|
5097 | 5436 | |
---|
| 5437 | + void ResetSelectable() |
---|
| 5438 | + { |
---|
| 5439 | + if (blockloop) |
---|
| 5440 | + return; |
---|
| 5441 | + |
---|
| 5442 | + blockloop = true; |
---|
| 5443 | + |
---|
| 5444 | + keepdontselect = dontselect; |
---|
| 5445 | + dontselect = true; |
---|
| 5446 | + |
---|
| 5447 | + Object3D child; |
---|
| 5448 | + int nb = Size(); |
---|
| 5449 | + for (int i = 0; i < nb; i++) |
---|
| 5450 | + { |
---|
| 5451 | + child = (Object3D) get(i); |
---|
| 5452 | + if (child == null) |
---|
| 5453 | + continue; |
---|
| 5454 | + child.ResetSelectable(); |
---|
| 5455 | + } |
---|
| 5456 | + |
---|
| 5457 | + blockloop = false; |
---|
| 5458 | + } |
---|
| 5459 | + |
---|
| 5460 | + void RestoreSelectable() |
---|
| 5461 | + { |
---|
| 5462 | + if (blockloop) |
---|
| 5463 | + return; |
---|
| 5464 | + |
---|
| 5465 | + blockloop = true; |
---|
| 5466 | + |
---|
| 5467 | + dontselect = keepdontselect; |
---|
| 5468 | + |
---|
| 5469 | + Object3D child; |
---|
| 5470 | + int nb = Size(); |
---|
| 5471 | + for (int i = 0; i < nb; i++) |
---|
| 5472 | + { |
---|
| 5473 | + child = (Object3D) get(i); |
---|
| 5474 | + if (child == null) |
---|
| 5475 | + continue; |
---|
| 5476 | + child.RestoreSelectable(); |
---|
| 5477 | + } |
---|
| 5478 | + |
---|
| 5479 | + blockloop = false; |
---|
| 5480 | + } |
---|
| 5481 | + |
---|
5098 | 5482 | boolean IsSelected() |
---|
5099 | 5483 | { |
---|
5100 | 5484 | if (parent == null) |
---|
.. | .. |
---|
5157 | 5541 | |
---|
5158 | 5542 | // System.out.println("Fullname = " + fullname); |
---|
5159 | 5543 | |
---|
5160 | | - if (fullname.name.indexOf(":") == -1) |
---|
5161 | | - return fullname.name; |
---|
| 5544 | + // Does not work on Windows due to C: |
---|
| 5545 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5546 | +// return fullname.name; |
---|
| 5547 | +// |
---|
| 5548 | +// return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
5162 | 5549 | |
---|
5163 | | - return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
| 5550 | + String[] split = fullname.name.split(":"); |
---|
| 5551 | + |
---|
| 5552 | + if (split.length == 0) |
---|
| 5553 | + { |
---|
| 5554 | + return ""; |
---|
| 5555 | + } |
---|
| 5556 | + |
---|
| 5557 | + if (split.length <= 2) |
---|
| 5558 | + { |
---|
| 5559 | + if (fullname.name.endsWith(":")) |
---|
| 5560 | + { |
---|
| 5561 | + // Windows |
---|
| 5562 | + return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5563 | + } |
---|
| 5564 | + |
---|
| 5565 | + return split[0]; |
---|
| 5566 | + } |
---|
| 5567 | + |
---|
| 5568 | + // Windows |
---|
| 5569 | + assert(split.length == 4); |
---|
| 5570 | + |
---|
| 5571 | + return split[0] + ":" + split[1]; |
---|
5164 | 5572 | } |
---|
5165 | 5573 | |
---|
5166 | 5574 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5169 | 5577 | return ""; |
---|
5170 | 5578 | |
---|
5171 | 5579 | // 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()); |
---|
| 5580 | + // Does not work on Windows due to C: |
---|
| 5581 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5582 | +// return ""; |
---|
| 5583 | +// |
---|
| 5584 | +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5585 | + String[] split = fullname.name.split(":"); |
---|
| 5586 | + |
---|
| 5587 | + if (split.length == 0) |
---|
| 5588 | + { |
---|
| 5589 | + return ""; |
---|
| 5590 | + } |
---|
| 5591 | + |
---|
| 5592 | + if (split.length == 1) |
---|
| 5593 | + { |
---|
| 5594 | + return ""; |
---|
| 5595 | + } |
---|
| 5596 | + |
---|
| 5597 | + if (split.length == 2) |
---|
| 5598 | + { |
---|
| 5599 | + if (fullname.name.endsWith(":")) |
---|
| 5600 | + { |
---|
| 5601 | + // Windows |
---|
| 5602 | + return ""; |
---|
| 5603 | + } |
---|
| 5604 | + |
---|
| 5605 | + return split[1]; |
---|
| 5606 | + } |
---|
| 5607 | + |
---|
| 5608 | + // Windows |
---|
| 5609 | + assert(split.length == 4); |
---|
| 5610 | + |
---|
| 5611 | + return split[2] + ":" + split[3]; |
---|
5176 | 5612 | } |
---|
5177 | 5613 | |
---|
5178 | 5614 | String GetPigmentTexture() |
---|
.. | .. |
---|
5246 | 5682 | System.out.print("; textures = " + textures); |
---|
5247 | 5683 | System.out.println("; usedtextures = " + usedtextures); |
---|
5248 | 5684 | |
---|
5249 | | - if (GetTextures() == null) |
---|
| 5685 | + if (GetTextures() == null) // What is that?? |
---|
5250 | 5686 | GetTextures().name = ":"; |
---|
5251 | 5687 | |
---|
5252 | 5688 | String texname = tex; |
---|
.. | .. |
---|
5277 | 5713 | child.ResetPigmentTexture(); |
---|
5278 | 5714 | blockloop = false; |
---|
5279 | 5715 | } |
---|
| 5716 | + } |
---|
| 5717 | + |
---|
| 5718 | + UUID GetUUID() |
---|
| 5719 | + { |
---|
| 5720 | + if (uuid == null) |
---|
| 5721 | + { |
---|
| 5722 | + // Serial |
---|
| 5723 | + uuid = UUID.randomUUID(); |
---|
| 5724 | + } |
---|
| 5725 | + |
---|
| 5726 | + return uuid; |
---|
| 5727 | + } |
---|
| 5728 | + |
---|
| 5729 | + Object3D GetObject(UUID uid) |
---|
| 5730 | + { |
---|
| 5731 | + if (blockloop) |
---|
| 5732 | + return null; |
---|
| 5733 | + |
---|
| 5734 | + if (GetUUID().equals(uid)) |
---|
| 5735 | + return this; |
---|
| 5736 | + |
---|
| 5737 | + int nb = Size(); |
---|
| 5738 | + for (int i = 0; i < nb; i++) |
---|
| 5739 | + { |
---|
| 5740 | + Object3D child = (Object3D) get(i); |
---|
| 5741 | + |
---|
| 5742 | + if (child == null) |
---|
| 5743 | + continue; |
---|
| 5744 | + |
---|
| 5745 | + blockloop = true; |
---|
| 5746 | + Object3D obj = child.GetObject(uid); |
---|
| 5747 | + blockloop = false; |
---|
| 5748 | + if (obj != null) |
---|
| 5749 | + return obj; |
---|
| 5750 | + } |
---|
| 5751 | + |
---|
| 5752 | + return null; |
---|
5280 | 5753 | } |
---|
5281 | 5754 | |
---|
5282 | 5755 | void SetBumpTexture(String tex) |
---|
.. | .. |
---|
5315 | 5788 | } |
---|
5316 | 5789 | } |
---|
5317 | 5790 | |
---|
| 5791 | + void EmbedTextures(boolean embed) |
---|
| 5792 | + { |
---|
| 5793 | + if (blockloop) |
---|
| 5794 | + return; |
---|
| 5795 | + |
---|
| 5796 | + //if (GetTextures() != null) |
---|
| 5797 | + if (embed) |
---|
| 5798 | + CameraPane.EmbedTextures(GetTextures()); |
---|
| 5799 | + else |
---|
| 5800 | + { |
---|
| 5801 | + GetTextures().pigmentdata = null; |
---|
| 5802 | + GetTextures().bumpdata = null; |
---|
| 5803 | + GetTextures().pw = 0; |
---|
| 5804 | + GetTextures().ph = 0; |
---|
| 5805 | + GetTextures().bw = 0; |
---|
| 5806 | + GetTextures().bh = 0; |
---|
| 5807 | + } |
---|
| 5808 | + |
---|
| 5809 | + int nb = Size(); |
---|
| 5810 | + for (int i = 0; i < nb; i++) |
---|
| 5811 | + { |
---|
| 5812 | + Object3D child = (Object3D) get(i); |
---|
| 5813 | + |
---|
| 5814 | + if (child == null) |
---|
| 5815 | + continue; |
---|
| 5816 | + |
---|
| 5817 | + blockloop = true; |
---|
| 5818 | + child.EmbedTextures(embed); |
---|
| 5819 | + blockloop = false; |
---|
| 5820 | + } |
---|
| 5821 | + } |
---|
| 5822 | + |
---|
5318 | 5823 | void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5319 | 5824 | { |
---|
5320 | 5825 | Draw(display, root, selected, blocked); |
---|
.. | .. |
---|
5323 | 5828 | boolean NeedSupport() |
---|
5324 | 5829 | { |
---|
5325 | 5830 | return |
---|
5326 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5831 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5327 | 5832 | // PROBLEM with CROWD!! |
---|
5328 | | - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); |
---|
| 5833 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5329 | 5834 | } |
---|
5330 | 5835 | |
---|
5331 | 5836 | static boolean DEBUG_SELECTION = false; |
---|
| 5837 | + |
---|
| 5838 | + boolean IsLive() |
---|
| 5839 | + { |
---|
| 5840 | + if (live) |
---|
| 5841 | + return true; |
---|
| 5842 | + |
---|
| 5843 | + if (parent == null) |
---|
| 5844 | + return false; |
---|
| 5845 | + |
---|
| 5846 | + return parent.IsLive(); |
---|
| 5847 | + } |
---|
5332 | 5848 | |
---|
5333 | 5849 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5334 | 5850 | { |
---|
.. | .. |
---|
5340 | 5856 | } |
---|
5341 | 5857 | |
---|
5342 | 5858 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5343 | | - hide) |
---|
| 5859 | + (hide || dontselect)) |
---|
5344 | 5860 | return; |
---|
5345 | 5861 | |
---|
5346 | 5862 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5391 | 5907 | support = support; |
---|
5392 | 5908 | |
---|
5393 | 5909 | //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); |
---|
| 5910 | + boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5395 | 5911 | |
---|
5396 | 5912 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5397 | 5913 | { |
---|
.. | .. |
---|
5411 | 5927 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5412 | 5928 | |
---|
5413 | 5929 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5414 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5930 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5931 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5415 | 5932 | { |
---|
5416 | 5933 | Globals.lighttouched = true; |
---|
5417 | 5934 | } // all panes... |
---|
| 5935 | + |
---|
5418 | 5936 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5419 | 5937 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5420 | 5938 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5542 | 6060 | if (GetBRep() != null) |
---|
5543 | 6061 | { |
---|
5544 | 6062 | display.NextIndex(); |
---|
| 6063 | + |
---|
5545 | 6064 | // vertex color conflict : gl.glCallList(list); |
---|
5546 | 6065 | DrawNode(display, root, selected); |
---|
5547 | 6066 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5582 | 6101 | tex = GetTextures(); |
---|
5583 | 6102 | } |
---|
5584 | 6103 | |
---|
5585 | | - display.BindTextures(tex, texres); |
---|
| 6104 | + boolean failedPigment = false; |
---|
| 6105 | + boolean failedBump = false; |
---|
| 6106 | + |
---|
| 6107 | + try |
---|
| 6108 | + { |
---|
| 6109 | + display.BindPigmentTexture(tex, texres); |
---|
| 6110 | + } |
---|
| 6111 | + catch (Exception e) |
---|
| 6112 | + { |
---|
| 6113 | + System.err.println("FAILED: " + this); |
---|
| 6114 | + failedPigment = true; |
---|
| 6115 | + } |
---|
| 6116 | + |
---|
| 6117 | + try |
---|
| 6118 | + { |
---|
| 6119 | + display.BindBumpTexture(tex, texres); |
---|
| 6120 | + } |
---|
| 6121 | + catch (Exception e) |
---|
| 6122 | + { |
---|
| 6123 | + //System.err.println("FAILED: " + this); |
---|
| 6124 | + failedBump = true; |
---|
| 6125 | + } |
---|
5586 | 6126 | |
---|
5587 | 6127 | if (!compiled) |
---|
5588 | 6128 | { |
---|
.. | .. |
---|
5604 | 6144 | } |
---|
5605 | 6145 | } |
---|
5606 | 6146 | |
---|
5607 | | - display.ReleaseTextures(tex); |
---|
| 6147 | + if (!failedBump) |
---|
| 6148 | + display.ReleaseBumpTexture(tex); |
---|
| 6149 | + |
---|
| 6150 | + if (!failedPigment) |
---|
| 6151 | + display.ReleasePigmentTexture(tex); |
---|
5608 | 6152 | |
---|
5609 | 6153 | display.PopMaterial(this, selected); |
---|
5610 | 6154 | } |
---|
.. | .. |
---|
5733 | 6277 | |
---|
5734 | 6278 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5735 | 6279 | { |
---|
| 6280 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6281 | + return; |
---|
| 6282 | + |
---|
5736 | 6283 | if (hide) |
---|
5737 | 6284 | return; |
---|
5738 | 6285 | // shadow optimisation |
---|
.. | .. |
---|
5858 | 6405 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5859 | 6406 | return; // no shadow for transparent objects |
---|
5860 | 6407 | |
---|
| 6408 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6409 | + return; |
---|
| 6410 | + |
---|
5861 | 6411 | if (hide) |
---|
5862 | 6412 | return; |
---|
5863 | 6413 | |
---|
.. | .. |
---|
5898 | 6448 | return; |
---|
5899 | 6449 | } |
---|
5900 | 6450 | |
---|
| 6451 | + //bRep.GenUV(1/material.diffuseness); |
---|
5901 | 6452 | // bRep.lock = true; |
---|
5902 | 6453 | |
---|
5903 | 6454 | //javax.media.opengl.GL gl = display.GetGL(); |
---|
.. | .. |
---|
5970 | 6521 | // dec 2012 |
---|
5971 | 6522 | new Exception().printStackTrace(); |
---|
5972 | 6523 | return; |
---|
| 6524 | + } |
---|
| 6525 | + |
---|
| 6526 | + if (dontselect) |
---|
| 6527 | + { |
---|
| 6528 | + //bRep.GenerateNormalsMINE(); |
---|
5973 | 6529 | } |
---|
5974 | 6530 | |
---|
5975 | 6531 | display.DrawGeometry(bRep, flipV, selectmode); |
---|
.. | .. |
---|
6755 | 7311 | } |
---|
6756 | 7312 | } |
---|
6757 | 7313 | |
---|
6758 | | - protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec) |
---|
| 7314 | + static ClickInfo clickInfo = new ClickInfo(); |
---|
| 7315 | + |
---|
| 7316 | + protected void calcHotSpot(cVector in, //ClickInfo clickInfo, |
---|
| 7317 | + Point outPt, Rectangle outRec) |
---|
6759 | 7318 | { |
---|
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; |
---|
| 7319 | + int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2; |
---|
| 7320 | + int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2; |
---|
| 7321 | + double[][] toscreen = clickInfo.toScreen; |
---|
6763 | 7322 | if (toscreen == null) |
---|
6764 | 7323 | { |
---|
6765 | | - toscreen = new Camera(info.camera.viewCode).toScreen; |
---|
| 7324 | + toscreen = new Camera(clickInfo.camera.viewCode).toScreen; |
---|
6766 | 7325 | } |
---|
6767 | 7326 | cVector vec = in; |
---|
6768 | 7327 | LA.xformPos(in, toscreen, in); |
---|
6769 | 7328 | //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(); |
---|
| 7329 | + vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
| 7330 | + vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
6772 | 7331 | outPt.x = hc + (int) vec.x; |
---|
6773 | 7332 | outPt.y = vc - (int) vec.y; |
---|
6774 | 7333 | outRec.x = outPt.x - 3; |
---|
.. | .. |
---|
6776 | 7335 | outRec.width = outRec.height = 6; |
---|
6777 | 7336 | } |
---|
6778 | 7337 | |
---|
6779 | | - protected Rectangle calcHotSpot(cVector in, ClickInfo info) |
---|
| 7338 | + protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo |
---|
| 7339 | + ) |
---|
6780 | 7340 | { |
---|
6781 | 7341 | Point pt = new Point(0, 0); |
---|
6782 | 7342 | Rectangle rec = new Rectangle(); |
---|
6783 | | - calcHotSpot(in, info, pt, rec); |
---|
| 7343 | + calcHotSpot(in, //clickInfo, |
---|
| 7344 | + pt, rec); |
---|
6784 | 7345 | return rec; |
---|
6785 | 7346 | } |
---|
6786 | 7347 | |
---|
6787 | | - void drawEditHandles0(ClickInfo info, int level) |
---|
| 7348 | + void drawEditHandles0(//ClickInfo clickInfo, |
---|
| 7349 | + int level) |
---|
6788 | 7350 | { |
---|
6789 | 7351 | if (level == 0) |
---|
6790 | 7352 | { |
---|
.. | .. |
---|
6793 | 7355 | { |
---|
6794 | 7356 | cVector origin = new cVector(); |
---|
6795 | 7357 | //LA.xformPos(origin, toParent, origin); |
---|
6796 | | - Rectangle spot = calcHotSpot(origin, info); |
---|
| 7358 | + if (this.clickInfo == null) |
---|
| 7359 | + this.clickInfo = new ClickInfo(); |
---|
| 7360 | + |
---|
| 7361 | + Rectangle spot = calcHotSpot(origin); //, clickInfo); |
---|
6797 | 7362 | Rectangle boundary = new Rectangle(); |
---|
6798 | 7363 | boundary.x = spot.x - 30; |
---|
6799 | 7364 | boundary.y = spot.y - 30; |
---|
6800 | 7365 | boundary.width = spot.width + 60; |
---|
6801 | 7366 | boundary.height = spot.height + 60; |
---|
6802 | | - info.g.setColor(Color.red); |
---|
| 7367 | + clickInfo.g.setColor(Color.red); |
---|
6803 | 7368 | int spotw = spot.x + spot.width; |
---|
6804 | 7369 | int spoth = spot.y + spot.height; |
---|
6805 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7370 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6806 | 7371 | // if (CameraPane.Xmin > spot.x) |
---|
6807 | 7372 | // { |
---|
6808 | 7373 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6822 | 7387 | spot.translate(32, 32); |
---|
6823 | 7388 | spotw = spot.x + spot.width; |
---|
6824 | 7389 | spoth = spot.y + spot.height; |
---|
6825 | | - info.g.setColor(Color.blue); |
---|
6826 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7390 | + clickInfo.g.setColor(Color.cyan); |
---|
| 7391 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6827 | 7392 | // if (CameraPane.Xmin > spot.x) |
---|
6828 | 7393 | // { |
---|
6829 | 7394 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6840 | 7405 | // { |
---|
6841 | 7406 | // CameraPane.Ymax = spoth; |
---|
6842 | 7407 | // } |
---|
6843 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6844 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7408 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7409 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
6845 | 7410 | spot.translate(0, -32); |
---|
6846 | | - info.g.setColor(Color.green); |
---|
6847 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7411 | + clickInfo.g.setColor(Color.yellow); |
---|
| 7412 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7413 | + clickInfo.g.setColor(Color.green); |
---|
6848 | 7414 | // if (CameraPane.Xmin > spot.x) |
---|
6849 | 7415 | // { |
---|
6850 | 7416 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6861 | 7427 | // { |
---|
6862 | 7428 | // CameraPane.Ymax = spoth; |
---|
6863 | 7429 | // } |
---|
6864 | | - info.g.drawArc(boundary.x, boundary.y, |
---|
6865 | | - boundary.width, boundary.height, 0, 360); |
---|
| 7430 | + clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, |
---|
| 7431 | + (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); |
---|
6866 | 7432 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
6867 | 7433 | // if (CameraPane.Xmin > boundary.x) |
---|
6868 | 7434 | // { |
---|
.. | .. |
---|
6884 | 7450 | } |
---|
6885 | 7451 | } |
---|
6886 | 7452 | |
---|
6887 | | - boolean doEditClick0(ClickInfo info, int level) |
---|
| 7453 | + boolean doEditClick0(//ClickInfo clickInfo, |
---|
| 7454 | + int level) |
---|
6888 | 7455 | { |
---|
6889 | 7456 | if (level == 0) |
---|
6890 | 7457 | { |
---|
.. | .. |
---|
6893 | 7460 | |
---|
6894 | 7461 | boolean retval = false; |
---|
6895 | 7462 | |
---|
6896 | | - startX = info.x; |
---|
6897 | | - startY = info.y; |
---|
| 7463 | + startX = clickInfo.x; |
---|
| 7464 | + startY = clickInfo.y; |
---|
6898 | 7465 | |
---|
6899 | | - hitSomething = 0; |
---|
| 7466 | + hitSomething = -1; |
---|
6900 | 7467 | cVector origin = new cVector(); |
---|
6901 | 7468 | //LA.xformPos(origin, toParent, origin); |
---|
6902 | 7469 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
6904 | 7471 | { |
---|
6905 | 7472 | centerPt = new Point(0, 0); |
---|
6906 | 7473 | } |
---|
6907 | | - calcHotSpot(origin, info, centerPt, spot); |
---|
6908 | | - if (spot.contains(info.x, info.y)) |
---|
| 7474 | + calcHotSpot(origin, //info, |
---|
| 7475 | + centerPt, spot); |
---|
| 7476 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
6909 | 7477 | { |
---|
6910 | 7478 | hitSomething = hitCenter; |
---|
6911 | 7479 | retval = true; |
---|
6912 | 7480 | } |
---|
6913 | 7481 | spot.translate(32, 0); |
---|
6914 | | - if (spot.contains(info.x, info.y)) |
---|
| 7482 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
6915 | 7483 | { |
---|
6916 | 7484 | hitSomething = hitRotate; |
---|
6917 | 7485 | retval = true; |
---|
6918 | 7486 | } |
---|
6919 | 7487 | spot.translate(0, 32); |
---|
6920 | | - if (spot.contains(info.x, info.y)) |
---|
| 7488 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
6921 | 7489 | { |
---|
6922 | 7490 | hitSomething = hitScale; |
---|
| 7491 | + |
---|
| 7492 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7493 | + double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32; |
---|
| 7494 | + double sign = 1; |
---|
| 7495 | + if (hScale < 0) |
---|
| 7496 | + { |
---|
| 7497 | + sign = -1; |
---|
| 7498 | + } |
---|
| 7499 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
| 7500 | + if (hScale < 0.01) |
---|
| 7501 | + { |
---|
| 7502 | + //hScale = 0.01; |
---|
| 7503 | + } |
---|
| 7504 | + |
---|
| 7505 | + double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32; |
---|
| 7506 | + sign = 1; |
---|
| 7507 | + if (vScale < 0) |
---|
| 7508 | + { |
---|
| 7509 | + sign = -1; |
---|
| 7510 | + } |
---|
| 7511 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
| 7512 | + if (vScale < 0.01) |
---|
| 7513 | + { |
---|
| 7514 | + //vScale = 0.01; |
---|
| 7515 | + } |
---|
| 7516 | + |
---|
| 7517 | + clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale); |
---|
| 7518 | + |
---|
6923 | 7519 | retval = true; |
---|
6924 | 7520 | } |
---|
6925 | 7521 | |
---|
.. | .. |
---|
6929 | 7525 | } |
---|
6930 | 7526 | |
---|
6931 | 7527 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
6932 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7528 | + modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
6933 | 7529 | //System.out.println("modified = " + modified); |
---|
6934 | 7530 | //new Exception().printStackTrace(); |
---|
6935 | 7531 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
6957 | 7553 | return true; |
---|
6958 | 7554 | } |
---|
6959 | 7555 | |
---|
6960 | | - void doEditDrag0(ClickInfo info) |
---|
| 7556 | + void doEditDrag0(//ClickInfo info, |
---|
| 7557 | + boolean opposite) |
---|
6961 | 7558 | { |
---|
6962 | 7559 | if (hitSomething == 0) |
---|
6963 | 7560 | { |
---|
.. | .. |
---|
6971 | 7568 | |
---|
6972 | 7569 | //System.out.println("hitSomething = " + hitSomething); |
---|
6973 | 7570 | |
---|
6974 | | - double scale = 0.005f * info.camera.Distance(); |
---|
| 7571 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7572 | + |
---|
6975 | 7573 | cVector xlate = new cVector(); |
---|
6976 | 7574 | //cVector xlate2 = new cVector(); |
---|
6977 | 7575 | switch (hitSomething) |
---|
.. | .. |
---|
6984 | 7582 | |
---|
6985 | 7583 | scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
6986 | 7584 | |
---|
6987 | | - if (modified) |
---|
| 7585 | + if (modified || opposite) |
---|
6988 | 7586 | { |
---|
6989 | 7587 | //assert(false); |
---|
6990 | 7588 | /* |
---|
.. | .. |
---|
7004 | 7602 | toParent[3][i] = xlate.get(i); |
---|
7005 | 7603 | LA.matInvert(toParent, fromParent); |
---|
7006 | 7604 | */ |
---|
7007 | | - cVector delta = LA.newVector(0, 0, startY - info.y); |
---|
7008 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7605 | + cVector delta = LA.newVector(0, 0, startY - clickInfo.y); |
---|
| 7606 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7009 | 7607 | |
---|
7010 | 7608 | LA.matCopy(startMat, toParent); |
---|
7011 | 7609 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7014 | 7612 | } else |
---|
7015 | 7613 | { |
---|
7016 | 7614 | //LA.xformDir(delta, info.camera.fromScreen, delta); |
---|
7017 | | - cVector up = new cVector(info.camera.up); |
---|
| 7615 | + cVector up = new cVector(clickInfo.camera.up); |
---|
7018 | 7616 | cVector away = new cVector(); |
---|
7019 | 7617 | //cVector right2 = new cVector(); |
---|
7020 | 7618 | //LA.vecCross(up, cVector.Z, right); |
---|
.. | .. |
---|
7031 | 7629 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7032 | 7630 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7033 | 7631 | LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7034 | | - LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
| 7632 | + LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away); |
---|
7035 | 7633 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7036 | 7634 | LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7037 | 7635 | //LA.vecCross(up, cVector.Z, right2); |
---|
7038 | 7636 | |
---|
7039 | | - cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
| 7637 | + cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0); |
---|
7040 | 7638 | |
---|
7041 | 7639 | //System.out.println("DELTA0 = " + delta); |
---|
7042 | 7640 | //System.out.println("AWAY = " + info.camera.away); |
---|
7043 | 7641 | //System.out.println("UP = " + info.camera.up); |
---|
7044 | 7642 | if (away.z > 0) |
---|
7045 | 7643 | { |
---|
7046 | | - if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
| 7644 | + if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
7047 | 7645 | { |
---|
7048 | 7646 | delta.x = -delta.x; |
---|
7049 | 7647 | } else |
---|
.. | .. |
---|
7058 | 7656 | //System.out.println("DELTA1 = " + delta); |
---|
7059 | 7657 | LA.xformDir(delta, ClickInfo.matbuffer, delta); |
---|
7060 | 7658 | //System.out.println("DELTA2 = " + delta); |
---|
7061 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7659 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7062 | 7660 | LA.matCopy(startMat, toParent); |
---|
7063 | 7661 | //System.out.println("DELTA3 = " + delta); |
---|
7064 | 7662 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7068 | 7666 | break; |
---|
7069 | 7667 | |
---|
7070 | 7668 | case hitRotate: // rotate |
---|
7071 | | - int dx = info.x - centerPt.x; |
---|
7072 | | - int dy = -(info.y - centerPt.y); |
---|
| 7669 | + int dx = clickInfo.x - centerPt.x; |
---|
| 7670 | + int dy = -(clickInfo.y - centerPt.y); |
---|
7073 | 7671 | double angle = (double) Math.atan2(dx, dy); |
---|
7074 | 7672 | angle = -(1.570796 - angle); |
---|
7075 | 7673 | |
---|
.. | .. |
---|
7078 | 7676 | |
---|
7079 | 7677 | if (modified) |
---|
7080 | 7678 | { |
---|
| 7679 | + // Rotate 90 degrees |
---|
7081 | 7680 | angle /= (Math.PI / 4); |
---|
7082 | 7681 | angle = Math.floor(angle + 0.5); |
---|
7083 | 7682 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7091 | 7690 | } |
---|
7092 | 7691 | /**/ |
---|
7093 | 7692 | |
---|
7094 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7693 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7095 | 7694 | { |
---|
7096 | 7695 | case 1: // '\001' |
---|
7097 | 7696 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7118 | 7717 | break; |
---|
7119 | 7718 | |
---|
7120 | 7719 | case hitScale: // scale |
---|
7121 | | - double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7720 | + double hScale = (double) (clickInfo.x /*- centerPt.x*/) / 32; |
---|
| 7721 | + double sign = 1; |
---|
| 7722 | + if (hScale < 0) |
---|
| 7723 | + { |
---|
| 7724 | + sign = -1; |
---|
| 7725 | + } |
---|
| 7726 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7122 | 7727 | if (hScale < 0.01) |
---|
7123 | 7728 | { |
---|
7124 | | - hScale = 0.01; |
---|
| 7729 | + //hScale = 0.01; |
---|
7125 | 7730 | } |
---|
7126 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7127 | | - if (hScale < 0.01) |
---|
| 7731 | + |
---|
| 7732 | + double vScale = (double) (clickInfo.y /*- centerPt.y*/) / 32; |
---|
| 7733 | + sign = 1; |
---|
| 7734 | + if (vScale < 0) |
---|
7128 | 7735 | { |
---|
7129 | | - hScale = 0.01; |
---|
| 7736 | + sign = -1; |
---|
7130 | 7737 | } |
---|
7131 | | - double vScale = (double) (info.y - centerPt.y) / 32; |
---|
| 7738 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7132 | 7739 | if (vScale < 0.01) |
---|
7133 | 7740 | { |
---|
7134 | | - vScale = 0.01; |
---|
| 7741 | + //vScale = 0.01; |
---|
7135 | 7742 | } |
---|
7136 | | - vScale = Math.pow(vScale, scale * 50); |
---|
7137 | | - if (vScale < 0.01) |
---|
7138 | | - { |
---|
7139 | | - vScale = 0.01; |
---|
7140 | | - } |
---|
| 7743 | + |
---|
7141 | 7744 | LA.matCopy(startMat, toParent); |
---|
7142 | 7745 | /**/ |
---|
7143 | 7746 | for (int i = 0; i < 3; i++) |
---|
.. | .. |
---|
7147 | 7750 | } |
---|
7148 | 7751 | /**/ |
---|
7149 | 7752 | |
---|
7150 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 7753 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale; |
---|
| 7754 | + |
---|
| 7755 | + if (totalScale < 0.01) |
---|
| 7756 | + { |
---|
| 7757 | + totalScale = 0.01; |
---|
| 7758 | + } |
---|
| 7759 | + |
---|
| 7760 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7151 | 7761 | { |
---|
7152 | 7762 | case 3: // '\001' |
---|
7153 | | - if (modified) |
---|
| 7763 | + if (modified || opposite) |
---|
7154 | 7764 | { |
---|
7155 | 7765 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7156 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7766 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7157 | 7767 | } // vScale, 1); |
---|
7158 | 7768 | else |
---|
7159 | 7769 | { |
---|
7160 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7770 | + // EXCEPTION! |
---|
| 7771 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7161 | 7772 | } // vScale, 1); |
---|
7162 | 7773 | break; |
---|
7163 | 7774 | |
---|
7164 | 7775 | case 2: // '\002' |
---|
7165 | | - if (modified) |
---|
| 7776 | + if (modified || opposite) |
---|
7166 | 7777 | { |
---|
7167 | 7778 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7168 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7779 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7169 | 7780 | } else |
---|
7170 | 7781 | { |
---|
7171 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7782 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7172 | 7783 | } |
---|
7173 | 7784 | break; |
---|
7174 | 7785 | |
---|
7175 | 7786 | case 1: // '\003' |
---|
7176 | | - if (modified) |
---|
| 7787 | + if (modified || opposite) |
---|
7177 | 7788 | { |
---|
7178 | 7789 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7179 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7790 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7180 | 7791 | } else |
---|
7181 | 7792 | { |
---|
7182 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7793 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7183 | 7794 | } |
---|
7184 | 7795 | break; |
---|
7185 | 7796 | } |
---|
.. | .. |
---|
7213 | 7824 | } // NEW ... |
---|
7214 | 7825 | |
---|
7215 | 7826 | |
---|
7216 | | - info.pane.repaint(); |
---|
| 7827 | + clickInfo.pane.repaint(); |
---|
7217 | 7828 | } |
---|
7218 | 7829 | |
---|
7219 | 7830 | boolean overflow = false; |
---|
.. | .. |
---|
7312 | 7923 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7313 | 7924 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7314 | 7925 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7926 | + |
---|
| 7927 | + String objname; |
---|
| 7928 | + |
---|
7315 | 7929 | if (false) //parent != null) |
---|
7316 | 7930 | { |
---|
7317 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7931 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7318 | 7932 | } else |
---|
7319 | 7933 | { |
---|
7320 | | - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); |
---|
| 7934 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7321 | 7935 | } // + super.toString(); |
---|
7322 | 7936 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
| 7937 | + |
---|
| 7938 | + if (!Globals.ADVANCED) |
---|
| 7939 | + return objname; |
---|
| 7940 | + |
---|
| 7941 | + return objname + " " + System.identityHashCode(this); |
---|
7323 | 7942 | } |
---|
7324 | 7943 | |
---|
7325 | 7944 | public int hashCode() |
---|
.. | .. |
---|
7375 | 7994 | objectUI.closeUI(); |
---|
7376 | 7995 | if (editWindow != null) |
---|
7377 | 7996 | { |
---|
| 7997 | + editWindow.ctrlPanel.FlushUI(); |
---|
7378 | 7998 | editWindow.refreshContents(); |
---|
7379 | 7999 | } // ? new |
---|
7380 | 8000 | objectUI = null; |
---|
.. | .. |
---|
7383 | 8003 | { |
---|
7384 | 8004 | editWindow = null; |
---|
7385 | 8005 | } // ? |
---|
| 8006 | + } |
---|
| 8007 | + else |
---|
| 8008 | + { |
---|
| 8009 | + //editWindow.closeUI(); |
---|
7386 | 8010 | } |
---|
7387 | 8011 | } |
---|
7388 | 8012 | |
---|
.. | .. |
---|
7395 | 8019 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7396 | 8020 | |
---|
7397 | 8021 | Object3D /*Composite*/ parent; |
---|
7398 | | - Object3D /*Composite*/ fileparent; |
---|
| 8022 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7399 | 8023 | |
---|
7400 | 8024 | double[][] toParent; // dynamic matrix |
---|
7401 | 8025 | double[][] fromParent; |
---|
.. | .. |
---|
7510 | 8134 | { |
---|
7511 | 8135 | assert(bRep != null); |
---|
7512 | 8136 | if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
7513 | | - GrafreeD.Assert(support.bRep == bRep.support); |
---|
| 8137 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
7514 | 8138 | } |
---|
7515 | 8139 | else |
---|
7516 | 8140 | { |
---|
.. | .. |
---|
7541 | 8165 | } |
---|
7542 | 8166 | |
---|
7543 | 8167 | transient ObjEditor editWindow; |
---|
| 8168 | + transient ObjEditor manipWindow; |
---|
| 8169 | + |
---|
| 8170 | + transient boolean pinned; |
---|
| 8171 | + |
---|
7544 | 8172 | transient ObjectUI objectUI; |
---|
7545 | 8173 | public static int povDepth = 0; |
---|
7546 | 8174 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
7559 | 8187 | private static cVector edge2 = new cVector(); |
---|
7560 | 8188 | //private static cVector norm = new cVector(); |
---|
7561 | 8189 | /*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; |
---|
| 8190 | + static final int hitCenter = 1; |
---|
| 8191 | + static final int hitScale = 2; |
---|
| 8192 | + static final int hitRotate = 3; |
---|
7565 | 8193 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7566 | 8194 | /*transient*/ private Point centerPt; |
---|
7567 | 8195 | /*transient*/ private int startX; |
---|