.. | .. |
---|
22 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
23 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
24 | 24 | |
---|
| 25 | + // Use GetUUID for backward compatibility with null. |
---|
25 | 26 | private UUID uuid = UUID.randomUUID(); |
---|
26 | 27 | |
---|
27 | | - // TEMPORARY for mocap undo |
---|
28 | | - mocap.reader.BVHReader.BVHResult bvh; |
---|
29 | | - Object3D skeleton; |
---|
| 28 | + // TEMPORARY for versions. No need to be transient. |
---|
| 29 | + mocap.reader.BVHReader.BVHResult savebvh; |
---|
| 30 | + Object3D saveskeleton; |
---|
| 31 | + |
---|
| 32 | + // FileObject |
---|
| 33 | + Object3D savefilecontent; |
---|
30 | 34 | // |
---|
| 35 | + |
---|
| 36 | + String skyboxname; |
---|
| 37 | + String skyboxext; |
---|
| 38 | + |
---|
| 39 | + Object3D[] versionlist; |
---|
| 40 | + int versionindex = -1; |
---|
| 41 | + |
---|
| 42 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable; // = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
31 | 43 | |
---|
32 | 44 | ScriptNode scriptnode; |
---|
33 | 45 | |
---|
| 46 | + void deepCopyNode(Object3D other) |
---|
| 47 | + { |
---|
| 48 | + other.skyboxname = skyboxname; |
---|
| 49 | + other.skyboxext = skyboxext; |
---|
| 50 | + |
---|
| 51 | + if (toParent != null) |
---|
| 52 | + { |
---|
| 53 | + other.toParent = LA.newMatrix(); |
---|
| 54 | + other.fromParent = LA.newMatrix(); |
---|
| 55 | + LA.matCopy(toParent, other.toParent); |
---|
| 56 | + LA.matCopy(fromParent, other.fromParent); |
---|
| 57 | + if (toParentMarked != null) |
---|
| 58 | + { |
---|
| 59 | + other.toParentMarked = LA.newMatrix(); |
---|
| 60 | + other.fromParentMarked = LA.newMatrix(); |
---|
| 61 | + LA.matCopy(toParentMarked, other.toParentMarked); |
---|
| 62 | + LA.matCopy(fromParentMarked, other.fromParentMarked); |
---|
| 63 | + } |
---|
| 64 | + } |
---|
| 65 | + else |
---|
| 66 | + { |
---|
| 67 | + if (other.toParent == null) |
---|
| 68 | +// assert(other.toParent == null); |
---|
| 69 | +// new Exception().printStackTrace(); |
---|
| 70 | + System.err.println("null parent: " + other); |
---|
| 71 | + } |
---|
| 72 | + |
---|
| 73 | + /* |
---|
| 74 | + double ident[][] = LA.newMatrix(); |
---|
| 75 | + if (bRep == null) |
---|
| 76 | + other.bRep = null; |
---|
| 77 | + else |
---|
| 78 | + other.bRep = new BoundaryRep(bRep, ident); |
---|
| 79 | + */ |
---|
| 80 | + // Really new... |
---|
| 81 | + //other.editWindow = null; |
---|
| 82 | + if (name == null) |
---|
| 83 | + other.name = null; |
---|
| 84 | + else |
---|
| 85 | + other.name = new String(name); |
---|
| 86 | + |
---|
| 87 | + if (material != null) |
---|
| 88 | + { |
---|
| 89 | + other.material = new cMaterial(material); |
---|
| 90 | + } else |
---|
| 91 | + { |
---|
| 92 | + other.material = null; |
---|
| 93 | + } |
---|
| 94 | + |
---|
| 95 | + other.GetTextures().name = GetTextures().name; |
---|
| 96 | + |
---|
| 97 | + CopyExtraMaterial(other); |
---|
| 98 | + |
---|
| 99 | + other.touched = touched; |
---|
| 100 | + other.softtouched = softtouched; |
---|
| 101 | + |
---|
| 102 | + other.random = random; |
---|
| 103 | + other.link2master = link2master; |
---|
| 104 | + other.transformcount = transformcount; |
---|
| 105 | + other.marked = marked; |
---|
| 106 | + other.skip = skip; |
---|
| 107 | + other.count = count; |
---|
| 108 | + other.flipV = flipV; |
---|
| 109 | + other.live = live; |
---|
| 110 | + other.rewind = rewind; |
---|
| 111 | + other.hide = hide; |
---|
| 112 | + other.texres = texres; |
---|
| 113 | + other.speedup = speedup; |
---|
| 114 | + other.height = height; |
---|
| 115 | + other.depth = depth; |
---|
| 116 | + } |
---|
| 117 | + |
---|
| 118 | + int VersionCount() |
---|
| 119 | + { |
---|
| 120 | + int count = 0; |
---|
| 121 | + |
---|
| 122 | + if (versionlist != null) |
---|
| 123 | + for (int i = versionlist.length; --i >= 0;) |
---|
| 124 | + { |
---|
| 125 | + if (versionlist[i] != null) |
---|
| 126 | + count++; |
---|
| 127 | + } |
---|
| 128 | + |
---|
| 129 | + return count; |
---|
| 130 | + } |
---|
| 131 | + |
---|
34 | 132 | void InitOthers() |
---|
35 | 133 | { |
---|
36 | 134 | if (projectedVertices == null || projectedVertices.length <= 2) |
---|
.. | .. |
---|
42 | 140 | projectedVertices[i] = new cVector2(); // Others |
---|
43 | 141 | } |
---|
44 | 142 | projectedVertices[0].x = 100; // bump |
---|
| 143 | + projectedVertices[1].y = 1000; // punchthrough. only for png |
---|
45 | 144 | } |
---|
46 | 145 | |
---|
47 | 146 | void MinMax(cVector minima, cVector maxima) |
---|
.. | .. |
---|
168 | 267 | } |
---|
169 | 268 | } |
---|
170 | 269 | |
---|
171 | | - void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 270 | + boolean HasBigData() |
---|
172 | 271 | { |
---|
173 | | - if (hashtable.containsKey(GetUUID())) |
---|
| 272 | + if (blockloop) |
---|
| 273 | + return false; |
---|
| 274 | + |
---|
| 275 | + if (bRep != null) |
---|
174 | 276 | { |
---|
175 | | - Object3D o = hashtable.get(GetUUID()); |
---|
176 | | - |
---|
177 | | - Grafreed.Assert(this.bRep == o.bRep); |
---|
178 | | - if (this.bRep != null) |
---|
179 | | - assert(this.bRep.support == o.transientrep); |
---|
180 | | - |
---|
181 | | - return; |
---|
182 | | - } |
---|
183 | | - |
---|
184 | | - Object3D o = new Object3D(); |
---|
185 | | - |
---|
186 | | - hashtable.put(GetUUID(), o); |
---|
187 | | - |
---|
188 | | - for (int i=0; i<Size(); i++) |
---|
189 | | - { |
---|
190 | | - get(i).ExtractBigData(hashtable); |
---|
| 277 | + return true; |
---|
191 | 278 | } |
---|
192 | 279 | |
---|
193 | | - ExtractBigData(o); |
---|
| 280 | + blockloop = true; |
---|
| 281 | + |
---|
| 282 | + for (int i = 0; i < Size(); i++) |
---|
| 283 | + { |
---|
| 284 | + Object3D child = (Object3D) get(i); |
---|
| 285 | + if (child == null) |
---|
| 286 | + continue; |
---|
| 287 | + if (child.HasBigData()) |
---|
| 288 | + { |
---|
| 289 | + blockloop = false; |
---|
| 290 | + return true; |
---|
| 291 | + } |
---|
| 292 | + } |
---|
| 293 | + |
---|
| 294 | + blockloop = false; |
---|
| 295 | + return false; |
---|
| 296 | + } |
---|
| 297 | + |
---|
| 298 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 299 | + { |
---|
| 300 | + if (blockloop) |
---|
| 301 | + return; |
---|
| 302 | + |
---|
| 303 | + Object3D o; |
---|
| 304 | + |
---|
| 305 | + boolean isnew = false; |
---|
| 306 | + |
---|
| 307 | + if (hashtable.containsKey(GetUUID())) |
---|
| 308 | + { |
---|
| 309 | + o = hashtable.get(GetUUID()); |
---|
| 310 | + |
---|
| 311 | + Grafreed.Assert(this.bRep == o.bRep); |
---|
| 312 | + //if (this.bRep != null) |
---|
| 313 | + // assert(this.bRep.support == o.transientrep); |
---|
| 314 | + if (this.support != null) |
---|
| 315 | + assert(this.support.bRep == o.transientrep); |
---|
| 316 | + } |
---|
| 317 | + else |
---|
| 318 | + { |
---|
| 319 | + isnew = true; |
---|
| 320 | + |
---|
| 321 | + o = new Object3D("copy of " + this.name); |
---|
| 322 | + |
---|
| 323 | + hashtable.put(GetUUID(), o); |
---|
| 324 | + } |
---|
| 325 | + |
---|
| 326 | + //if (!blockloop) |
---|
| 327 | + { |
---|
| 328 | + blockloop = true; |
---|
| 329 | + |
---|
| 330 | + for (int i=0; i<Size(); i++) |
---|
| 331 | + { |
---|
| 332 | + get(i).ExtractBigData(hashtable); |
---|
| 333 | + } |
---|
| 334 | + |
---|
| 335 | + blockloop = false; |
---|
| 336 | + } |
---|
| 337 | + |
---|
| 338 | + //if (isnew) |
---|
| 339 | + ExtractBigData(o); |
---|
194 | 340 | } |
---|
195 | 341 | |
---|
196 | 342 | void ExtractBigData(Object3D o) |
---|
197 | 343 | { |
---|
| 344 | + //System.err.println("ExtractBigData : " + this + " --> " + o); |
---|
| 345 | + |
---|
| 346 | + if (o.bRep != null) |
---|
| 347 | + Grafreed.Assert(o.bRep == this.bRep); |
---|
| 348 | + |
---|
198 | 349 | o.bRep = this.bRep; |
---|
199 | | - if (this.bRep != null) |
---|
| 350 | +// July 2019 if (this.bRep != null) |
---|
| 351 | +// { |
---|
| 352 | +// o.transientrep = this.bRep.support; |
---|
| 353 | +// o.bRep.support = null; |
---|
| 354 | +// } |
---|
| 355 | + o.selection = this.selection; |
---|
| 356 | + //o.versionlist = this.versionlist; |
---|
| 357 | + //o.versionindex = this.versionindex; |
---|
| 358 | + |
---|
| 359 | + if (this.support != null) |
---|
200 | 360 | { |
---|
201 | | - o.transientrep = this.bRep.support; |
---|
202 | | - o.bRep.support = null; |
---|
| 361 | + if (o.transientrep != null) |
---|
| 362 | + Grafreed.Assert(o.transientrep == this.support.bRep); |
---|
| 363 | + |
---|
| 364 | + o.transientrep = this.support.bRep; |
---|
| 365 | + this.support.bRep = null; |
---|
203 | 366 | } |
---|
204 | 367 | |
---|
205 | 368 | // o.support = this.support; |
---|
.. | .. |
---|
214 | 377 | // this.fileparent = null; |
---|
215 | 378 | } |
---|
216 | 379 | |
---|
| 380 | +// Object3D GetObject(java.util.UUID uuid) |
---|
| 381 | +// { |
---|
| 382 | +// if (this.uuid.equals(uuid)) |
---|
| 383 | +// return this; |
---|
| 384 | +// |
---|
| 385 | +// if (blockloop) |
---|
| 386 | +// return null; |
---|
| 387 | +// |
---|
| 388 | +// blockloop = true; |
---|
| 389 | +// |
---|
| 390 | +// for (int i=0; i<Size(); i++) |
---|
| 391 | +// { |
---|
| 392 | +// Object3D o = get(i).GetObject(uuid); |
---|
| 393 | +// |
---|
| 394 | +// if (o != null) |
---|
| 395 | +// return o; |
---|
| 396 | +// } |
---|
| 397 | +// |
---|
| 398 | +// blockloop = false; |
---|
| 399 | +// |
---|
| 400 | +// return null; |
---|
| 401 | +// } |
---|
| 402 | + |
---|
| 403 | + transient boolean tag; |
---|
| 404 | + |
---|
| 405 | + void TagObjects(Object3D o, boolean tag) |
---|
| 406 | + { |
---|
| 407 | + if (blockloop) |
---|
| 408 | + return; |
---|
| 409 | + |
---|
| 410 | + o.tag = tag; |
---|
| 411 | + |
---|
| 412 | + if (o == this) |
---|
| 413 | + return; |
---|
| 414 | + |
---|
| 415 | + blockloop = true; |
---|
| 416 | + |
---|
| 417 | + for (int i=0; i<Size(); i++) |
---|
| 418 | + { |
---|
| 419 | + get(i).TagObjects(o, tag); |
---|
| 420 | + } |
---|
| 421 | + |
---|
| 422 | + blockloop = false; |
---|
| 423 | + } |
---|
| 424 | + |
---|
| 425 | + boolean HasTags() |
---|
| 426 | + { |
---|
| 427 | + if (blockloop) |
---|
| 428 | + return false; |
---|
| 429 | + |
---|
| 430 | + blockloop = true; |
---|
| 431 | + |
---|
| 432 | + boolean hasTags = false; |
---|
| 433 | + |
---|
| 434 | + for (int i=0; i<Size(); i++) |
---|
| 435 | + { |
---|
| 436 | + hasTags |= get(i).tag || get(i).HasTags(); |
---|
| 437 | + |
---|
| 438 | + if (hasTags) |
---|
| 439 | + break; |
---|
| 440 | + } |
---|
| 441 | + |
---|
| 442 | + blockloop = false; |
---|
| 443 | + |
---|
| 444 | + return hasTags; |
---|
| 445 | + } |
---|
| 446 | + |
---|
217 | 447 | void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
218 | 448 | { |
---|
| 449 | + if (blockloop) |
---|
| 450 | + return; |
---|
| 451 | + |
---|
219 | 452 | if (!hashtable.containsKey(GetUUID())) |
---|
220 | 453 | return; |
---|
221 | 454 | |
---|
.. | .. |
---|
223 | 456 | |
---|
224 | 457 | RestoreBigData(o); |
---|
225 | 458 | |
---|
226 | | - hashtable.remove(GetUUID()); |
---|
| 459 | + blockloop = true; |
---|
| 460 | + |
---|
| 461 | + //hashtable.remove(GetUUID()); |
---|
227 | 462 | |
---|
228 | 463 | for (int i=0; i<Size(); i++) |
---|
229 | 464 | { |
---|
230 | 465 | get(i).RestoreBigData(hashtable); |
---|
231 | 466 | } |
---|
| 467 | + |
---|
| 468 | + blockloop = false; |
---|
232 | 469 | } |
---|
233 | 470 | |
---|
234 | 471 | void RestoreBigData(Object3D o) |
---|
235 | 472 | { |
---|
| 473 | + //System.err.println("RestoreBigData : " + this + " <-- " + o); |
---|
| 474 | + Grafreed.Assert(this.bRep == null); |
---|
| 475 | + |
---|
236 | 476 | this.bRep = o.bRep; |
---|
237 | | - if (this.bRep != null) |
---|
238 | | - this.bRep.support = o.transientrep; |
---|
| 477 | + if (this.support != null && o.transientrep != null) |
---|
| 478 | + { |
---|
| 479 | + this.support.bRep = o.transientrep; |
---|
| 480 | + } |
---|
| 481 | + |
---|
| 482 | + this.selection = o.selection; |
---|
| 483 | + |
---|
| 484 | + //this.versionlist = o.versionlist; |
---|
| 485 | + //this.versionindex = o.versionindex; |
---|
| 486 | +// July 2019 if (this.bRep != null) |
---|
| 487 | +// this.bRep.support = o.transientrep; |
---|
239 | 488 | // this.support = o.support; |
---|
240 | 489 | // this.fileparent = o.fileparent; |
---|
241 | 490 | } |
---|
.. | .. |
---|
381 | 630 | } |
---|
382 | 631 | |
---|
383 | 632 | boolean live = false; |
---|
| 633 | + transient boolean keepdontselect; |
---|
384 | 634 | boolean dontselect = false; |
---|
385 | 635 | boolean hide = false; |
---|
386 | 636 | boolean link2master = false; // performs reset support/master at each frame |
---|
.. | .. |
---|
391 | 641 | boolean random = false; |
---|
392 | 642 | boolean speedup = false; |
---|
393 | 643 | boolean rewind = false; |
---|
| 644 | + |
---|
| 645 | + // Option to sort triangles, e.g. for transparency. |
---|
| 646 | + boolean sort = false; |
---|
394 | 647 | |
---|
395 | 648 | float NORMALPUSH = 0; |
---|
396 | 649 | |
---|
.. | .. |
---|
409 | 662 | { |
---|
410 | 663 | sorted = true; |
---|
411 | 664 | |
---|
412 | | - for (int i=0; i<size()-1; i++) |
---|
| 665 | + for (int i=0; i<Size()-1; i++) |
---|
413 | 666 | { |
---|
414 | 667 | Object3D obji = get(i); |
---|
415 | 668 | Object3D objj = get(i+1); |
---|
.. | .. |
---|
433 | 686 | { |
---|
434 | 687 | sorted = true; |
---|
435 | 688 | |
---|
436 | | - for (int i=0; i<size()-1; i++) |
---|
| 689 | + for (int i=0; i<Size()-1; i++) |
---|
437 | 690 | { |
---|
438 | 691 | Object3D obji = get(i); |
---|
439 | 692 | Object3D objj = get(i+1); |
---|
.. | .. |
---|
449 | 702 | } |
---|
450 | 703 | } |
---|
451 | 704 | |
---|
452 | | - int memorysize; |
---|
| 705 | + transient int memorysize; // needs to be transient, dunno why |
---|
453 | 706 | |
---|
454 | 707 | int MemorySize() |
---|
455 | 708 | { |
---|
456 | | - if (true) // memorysize == 0) |
---|
| 709 | + if (memorysize == 0) |
---|
457 | 710 | { |
---|
458 | 711 | try |
---|
459 | 712 | { |
---|
.. | .. |
---|
568 | 821 | { |
---|
569 | 822 | if (maxcount != 1) |
---|
570 | 823 | { |
---|
571 | | - new Exception().printStackTrace(); |
---|
| 824 | + //new Exception().printStackTrace(); |
---|
572 | 825 | } |
---|
573 | 826 | |
---|
574 | 827 | toParentMarked = LA.newMatrix(); |
---|
.. | .. |
---|
881 | 1134 | |
---|
882 | 1135 | if (marked && Globals.isLIVE() && live && |
---|
883 | 1136 | //TEMP21aug2018 |
---|
884 | | - (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
| 1137 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
885 | 1138 | currentframe != Globals.framecount) |
---|
886 | 1139 | { |
---|
887 | 1140 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
893 | 1146 | |
---|
894 | 1147 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
895 | 1148 | |
---|
896 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 1149 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 1150 | + (step == 1 && changedir)) |
---|
897 | 1151 | { |
---|
898 | 1152 | countdown = 1; |
---|
899 | 1153 | delay = speedup?8:1; |
---|
.. | .. |
---|
962 | 1216 | { |
---|
963 | 1217 | // return true; |
---|
964 | 1218 | |
---|
965 | | - if (material == null || material.multiply) |
---|
966 | | - return true; |
---|
| 1219 | +// if (material == null || material.multiply) |
---|
| 1220 | +// return true; |
---|
| 1221 | +// |
---|
| 1222 | +// if (projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
| 1223 | +// return false; |
---|
| 1224 | +// |
---|
| 1225 | +// // Transparent objects are dynamic because we have to sort the triangles. |
---|
| 1226 | +// return material.opacity > 0.99; |
---|
967 | 1227 | |
---|
968 | | - return material.opacity > 0.99; |
---|
| 1228 | + return !sort; |
---|
969 | 1229 | } |
---|
970 | 1230 | |
---|
971 | 1231 | boolean IsOpaque() |
---|
972 | 1232 | { |
---|
973 | 1233 | // return true; |
---|
974 | 1234 | |
---|
975 | | - if (material == null || material.multiply) |
---|
976 | | - return true; |
---|
| 1235 | +// if (material == null || material.multiply) |
---|
| 1236 | +// return true; |
---|
| 1237 | +// |
---|
| 1238 | +// return material.opacity > 0.99; |
---|
977 | 1239 | |
---|
978 | | - return material.opacity > 0.99; |
---|
| 1240 | + return !sort; |
---|
979 | 1241 | } |
---|
980 | 1242 | |
---|
981 | 1243 | Object3D() |
---|
.. | .. |
---|
1053 | 1315 | |
---|
1054 | 1316 | // will share the geometry |
---|
1055 | 1317 | assert (!(this instanceof Composite)); |
---|
1056 | | - return deepCopy(); // Never called for Composite |
---|
1057 | | - |
---|
| 1318 | + |
---|
| 1319 | + Object3D obj = deepCopy(); // Never called for Composite |
---|
| 1320 | + obj.count = 2; |
---|
| 1321 | + return obj; |
---|
1058 | 1322 | } |
---|
1059 | 1323 | |
---|
1060 | 1324 | boolean HasLoops() |
---|
.. | .. |
---|
1062 | 1326 | return false; |
---|
1063 | 1327 | } |
---|
1064 | 1328 | |
---|
| 1329 | + void ResetUUIDs() |
---|
| 1330 | + { |
---|
| 1331 | + if (blockloop) |
---|
| 1332 | + { |
---|
| 1333 | + return; |
---|
| 1334 | + } |
---|
| 1335 | + |
---|
| 1336 | + this.uuid = null; |
---|
| 1337 | + |
---|
| 1338 | + blockloop = true; |
---|
| 1339 | + |
---|
| 1340 | + for (int i = 0; i < Size(); i++) |
---|
| 1341 | + { |
---|
| 1342 | + Object3D obj = (Object3D) Children().get(i); |
---|
| 1343 | + |
---|
| 1344 | + if (obj != null) |
---|
| 1345 | + { |
---|
| 1346 | + obj.ResetUUIDs(); |
---|
| 1347 | + } |
---|
| 1348 | + } |
---|
| 1349 | + |
---|
| 1350 | + blockloop = false; |
---|
| 1351 | + } |
---|
| 1352 | + |
---|
1065 | 1353 | boolean IsInfinite() |
---|
1066 | 1354 | { |
---|
1067 | 1355 | if (blockloop) |
---|
.. | .. |
---|
1132 | 1420 | return; |
---|
1133 | 1421 | |
---|
1134 | 1422 | blockloop = true; |
---|
| 1423 | + |
---|
| 1424 | + other.parent = parent; |
---|
| 1425 | + |
---|
1135 | 1426 | //System.out.println("COPY " + this + " to " + other); |
---|
1136 | 1427 | //new Exception().printStackTrace(); |
---|
| 1428 | + deepCopyNode(other); |
---|
1137 | 1429 | |
---|
1138 | | - other.parent = parent; |
---|
1139 | | - if (toParent != null) |
---|
1140 | | - { |
---|
1141 | | - other.toParent = LA.newMatrix(); |
---|
1142 | | - other.fromParent = LA.newMatrix(); |
---|
1143 | | - LA.matCopy(toParent, other.toParent); |
---|
1144 | | - LA.matCopy(fromParent, other.fromParent); |
---|
1145 | | - if (toParentMarked != null) |
---|
1146 | | - { |
---|
1147 | | - other.toParentMarked = LA.newMatrix(); |
---|
1148 | | - other.fromParentMarked = LA.newMatrix(); |
---|
1149 | | - LA.matCopy(toParentMarked, other.toParentMarked); |
---|
1150 | | - LA.matCopy(fromParentMarked, other.fromParentMarked); |
---|
1151 | | - } |
---|
1152 | | - } |
---|
1153 | | - else |
---|
1154 | | - { |
---|
1155 | | - if (other.toParent == null) |
---|
1156 | | -// assert(other.toParent == null); |
---|
1157 | | -// new Exception().printStackTrace(); |
---|
1158 | | - System.err.println("null parent: " + other); |
---|
1159 | | - } |
---|
1160 | | - /* |
---|
1161 | | - double ident[][] = LA.newMatrix(); |
---|
1162 | | - if (bRep == null) |
---|
1163 | | - other.bRep = null; |
---|
1164 | | - else |
---|
1165 | | - other.bRep = new BoundaryRep(bRep, ident); |
---|
1166 | | - */ |
---|
1167 | | - // Really new... |
---|
1168 | 1430 | other.bRep = bRep; // Share the geometry |
---|
1169 | 1431 | |
---|
1170 | 1432 | other.support = support; // Share the support |
---|
1171 | | - |
---|
1172 | | - //other.editWindow = null; |
---|
1173 | | - if (name == null) |
---|
1174 | | - other.name = null; |
---|
1175 | | - else |
---|
1176 | | - other.name = new String(name); |
---|
1177 | | - |
---|
1178 | | - if (material != null) |
---|
1179 | | - { |
---|
1180 | | - other.material = new cMaterial(material); |
---|
1181 | | - } else |
---|
1182 | | - { |
---|
1183 | | - other.material = null; |
---|
1184 | | - } |
---|
1185 | | - |
---|
1186 | | - other.GetTextures().name = GetTextures().name; |
---|
1187 | | - |
---|
1188 | | - CopyExtraMaterial(other); |
---|
1189 | | - |
---|
1190 | | - other.touched = touched; |
---|
1191 | | - other.softtouched = softtouched; |
---|
1192 | | - |
---|
1193 | | - other.random = random; |
---|
1194 | | - other.link2master = link2master; |
---|
1195 | | - other.transformcount = transformcount; |
---|
1196 | | - other.marked = marked; |
---|
1197 | | - other.skip = skip; |
---|
1198 | | - other.count = count; |
---|
1199 | | - other.flipV = flipV; |
---|
1200 | | - other.live = live; |
---|
1201 | | - other.rewind = rewind; |
---|
1202 | | - other.hide = hide; |
---|
1203 | | - other.texres = texres; |
---|
1204 | | - other.speedup = speedup; |
---|
1205 | | - other.height = height; |
---|
1206 | | - other.depth = depth; |
---|
1207 | 1433 | |
---|
1208 | 1434 | // aout 2013 if (/*displaylist != -1 &&*/other.displaylist != displaylist) |
---|
1209 | 1435 | // { |
---|
.. | .. |
---|
1259 | 1485 | if ((mask & GEOMETRY) != 0) |
---|
1260 | 1486 | { |
---|
1261 | 1487 | if (bRep != null) |
---|
1262 | | - bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep); |
---|
1263 | | - else |
---|
1264 | | - assert(other.bRep == null); |
---|
1265 | | - |
---|
1266 | | - if (bRep != null) |
---|
1267 | 1488 | { |
---|
| 1489 | + bRep.overwriteThis(other.bRep==null?other.transientrep:other.bRep); |
---|
1268 | 1490 | CameraPane.RemoveList(bRep.displaylist); |
---|
1269 | 1491 | bRep.displaylist = 0; // june 2013 -1; |
---|
1270 | 1492 | } |
---|
1271 | 1493 | else |
---|
1272 | | - bRep = bRep; |
---|
| 1494 | + { |
---|
| 1495 | + //assert(other.bRep == null); |
---|
| 1496 | + bRep = other.bRep; |
---|
| 1497 | + } |
---|
| 1498 | + |
---|
| 1499 | +// if (bRep != null) |
---|
| 1500 | +// { |
---|
| 1501 | +// CameraPane.RemoveList(bRep.displaylist); |
---|
| 1502 | +// bRep.displaylist = 0; // june 2013 -1; |
---|
| 1503 | +// } |
---|
| 1504 | +// else |
---|
| 1505 | +// bRep = bRep; |
---|
1273 | 1506 | } |
---|
1274 | 1507 | |
---|
1275 | 1508 | /* Use a MASK = GEO/MAT |
---|
.. | .. |
---|
1365 | 1598 | toParent = LA.newMatrix(); |
---|
1366 | 1599 | fromParent = LA.newMatrix(); |
---|
1367 | 1600 | } |
---|
| 1601 | + |
---|
1368 | 1602 | LA.matCopy(other.toParent, toParent); |
---|
1369 | 1603 | LA.matCopy(other.fromParent, fromParent); |
---|
1370 | 1604 | |
---|
.. | .. |
---|
2244 | 2478 | |
---|
2245 | 2479 | InitOthers(); |
---|
2246 | 2480 | |
---|
2247 | | - if (this instanceof Camera) |
---|
2248 | | - { |
---|
2249 | | - material.shift = 90; |
---|
2250 | | - } |
---|
2251 | | - |
---|
2252 | 2481 | material.multiply = multiply; |
---|
2253 | 2482 | |
---|
2254 | 2483 | if (multiply) |
---|
.. | .. |
---|
2386 | 2615 | } |
---|
2387 | 2616 | */ |
---|
2388 | 2617 | } |
---|
| 2618 | + else |
---|
| 2619 | + { |
---|
| 2620 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2621 | + if (objectUI != null) |
---|
| 2622 | + ((ObjEditor)objectUI).pinButton.setSelected(pinned); |
---|
| 2623 | + else |
---|
| 2624 | + //new Exception().printStackTrace(); |
---|
| 2625 | + System.err.println("objectUI is null"); |
---|
| 2626 | + } |
---|
2389 | 2627 | } |
---|
2390 | 2628 | |
---|
2391 | 2629 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
.. | .. |
---|
2427 | 2665 | { |
---|
2428 | 2666 | editWindow.refreshContents(); |
---|
2429 | 2667 | } |
---|
| 2668 | + else |
---|
| 2669 | + { |
---|
| 2670 | + if (manipWindow != null) |
---|
| 2671 | + { |
---|
| 2672 | + manipWindow.refreshContents(); |
---|
| 2673 | + } |
---|
| 2674 | + } |
---|
| 2675 | + |
---|
2430 | 2676 | //if (parent != null) |
---|
2431 | 2677 | //parent.refreshEditWindow(); |
---|
2432 | 2678 | } |
---|
.. | .. |
---|
2506 | 2752 | private static final int editSelf = 1; |
---|
2507 | 2753 | private static final int editChild = 2; |
---|
2508 | 2754 | |
---|
2509 | | - void drawEditHandles(ClickInfo info, int level) |
---|
| 2755 | + void drawEditHandles(//ClickInfo info, |
---|
| 2756 | + int level) |
---|
2510 | 2757 | { |
---|
2511 | 2758 | if (level == 0) |
---|
2512 | 2759 | { |
---|
.. | .. |
---|
2514 | 2761 | return; |
---|
2515 | 2762 | |
---|
2516 | 2763 | Object3D selectee; |
---|
2517 | | - for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(info, level + 1)) |
---|
| 2764 | + for (java.util.Enumeration e = selection.elements(); e.hasMoreElements(); selectee.drawEditHandles(//info, |
---|
| 2765 | + level + 1)) |
---|
2518 | 2766 | { |
---|
2519 | 2767 | selectee = (Object3D) e.nextElement(); |
---|
2520 | 2768 | } |
---|
.. | .. |
---|
2522 | 2770 | } else |
---|
2523 | 2771 | { |
---|
2524 | 2772 | //super. |
---|
2525 | | - drawEditHandles0(info, level + 1); |
---|
| 2773 | + drawEditHandles0(//info, |
---|
| 2774 | + level + 1); |
---|
2526 | 2775 | } |
---|
2527 | 2776 | } |
---|
2528 | 2777 | |
---|
2529 | | - boolean doEditClick(ClickInfo info, int level) |
---|
| 2778 | + boolean doEditClick(//ClickInfo info, |
---|
| 2779 | + int level) |
---|
2530 | 2780 | { |
---|
2531 | 2781 | doSomething = 0; |
---|
2532 | 2782 | if (level == 0) |
---|
2533 | 2783 | { |
---|
2534 | | - return doParentClick(info); |
---|
| 2784 | + return doParentClick(); //info); |
---|
2535 | 2785 | } |
---|
2536 | 2786 | if (//super. |
---|
2537 | | - doEditClick0(info, level)) |
---|
| 2787 | + doEditClick0(//info, |
---|
| 2788 | + level)) |
---|
2538 | 2789 | { |
---|
2539 | 2790 | doSomething = 1; |
---|
2540 | 2791 | return true; |
---|
.. | .. |
---|
2544 | 2795 | } |
---|
2545 | 2796 | } |
---|
2546 | 2797 | |
---|
2547 | | - boolean doParentClick(ClickInfo info) |
---|
| 2798 | + boolean doParentClick() //ClickInfo info) |
---|
2548 | 2799 | { |
---|
2549 | 2800 | if (selection == null) |
---|
2550 | 2801 | { |
---|
.. | .. |
---|
2557 | 2808 | for (java.util.Enumeration e = selection.elements(); e.hasMoreElements();) |
---|
2558 | 2809 | { |
---|
2559 | 2810 | Object3D selectee = (Object3D) e.nextElement(); |
---|
2560 | | - if (selectee.doEditClick(info, 1)) |
---|
| 2811 | + if (selectee.doEditClick(//info, |
---|
| 2812 | + 1)) |
---|
2561 | 2813 | { |
---|
2562 | 2814 | childToDrag = selectee; |
---|
2563 | 2815 | doSomething = 2; |
---|
.. | .. |
---|
2569 | 2821 | return retval; |
---|
2570 | 2822 | } |
---|
2571 | 2823 | |
---|
2572 | | - void doEditDrag(ClickInfo info, boolean opposite) |
---|
| 2824 | + void doEditDrag(//ClickInfo clickInfo, |
---|
| 2825 | + boolean opposite) |
---|
2573 | 2826 | { |
---|
2574 | 2827 | switch (doSomething) |
---|
2575 | 2828 | { |
---|
2576 | 2829 | case 1: // '\001' |
---|
2577 | 2830 | //super. |
---|
2578 | | - doEditDrag0(info, opposite); |
---|
| 2831 | + doEditDrag0(//clickInfo, |
---|
| 2832 | + opposite); |
---|
2579 | 2833 | break; |
---|
2580 | 2834 | |
---|
2581 | 2835 | case 2: // '\002' |
---|
.. | .. |
---|
2588 | 2842 | { |
---|
2589 | 2843 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2590 | 2844 | //childToDrag.doEditDrag(info); |
---|
2591 | | - sel.doEditDrag(info, opposite); |
---|
| 2845 | + sel.doEditDrag(//clickInfo, |
---|
| 2846 | + opposite); |
---|
2592 | 2847 | } else |
---|
2593 | 2848 | { |
---|
2594 | 2849 | //super. |
---|
2595 | | - doEditDrag0(info, opposite); |
---|
| 2850 | + doEditDrag0(//clickInfo, |
---|
| 2851 | + opposite); |
---|
2596 | 2852 | } |
---|
2597 | 2853 | } |
---|
2598 | 2854 | break; |
---|
.. | .. |
---|
2610 | 2866 | { |
---|
2611 | 2867 | deselectAll(); |
---|
2612 | 2868 | } |
---|
| 2869 | + |
---|
| 2870 | + new Exception().printStackTrace(); |
---|
| 2871 | + |
---|
2613 | 2872 | ClickInfo newInfo = new ClickInfo(); |
---|
2614 | 2873 | newInfo.flags = info.flags; |
---|
2615 | 2874 | newInfo.bounds = info.bounds; |
---|
.. | .. |
---|
3039 | 3298 | { |
---|
3040 | 3299 | if (bRep != null) |
---|
3041 | 3300 | { |
---|
| 3301 | + //bRep.GenerateNormals2(crease); // in-place doesn't work. it gives wrong normals (diamond artifact). |
---|
3042 | 3302 | bRep.GenerateNormals(crease); |
---|
| 3303 | + if (!bRep.trimmed) |
---|
| 3304 | + bRep.MergeNormals(); |
---|
3043 | 3305 | Touch(); |
---|
3044 | 3306 | } |
---|
3045 | 3307 | } |
---|
.. | .. |
---|
3057 | 3319 | { |
---|
3058 | 3320 | if (bRep != null) |
---|
3059 | 3321 | { |
---|
3060 | | - bRep.GenerateNormalsMINE(); |
---|
| 3322 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
3061 | 3323 | Touch(); |
---|
3062 | 3324 | } |
---|
3063 | 3325 | } |
---|
.. | .. |
---|
3114 | 3376 | blockloop = false; |
---|
3115 | 3377 | } |
---|
3116 | 3378 | |
---|
| 3379 | + public void ResetTransform(int mask) |
---|
| 3380 | + { |
---|
| 3381 | + Object3D obj = this; |
---|
| 3382 | + |
---|
| 3383 | + if (mask == -1) |
---|
| 3384 | + { |
---|
| 3385 | + if (obj instanceof Camera) // jan 2014 |
---|
| 3386 | + { |
---|
| 3387 | + LA.matIdentity(obj.toParent); |
---|
| 3388 | + LA.matIdentity(obj.fromParent); |
---|
| 3389 | + } |
---|
| 3390 | + else |
---|
| 3391 | + { |
---|
| 3392 | + obj.toParent = null; // jan 2014 LA.matIdentity(obj.toParent); |
---|
| 3393 | + obj.fromParent = null; // LA.matIdentity(obj.fromParent); |
---|
| 3394 | + } |
---|
| 3395 | + return; |
---|
| 3396 | + } |
---|
| 3397 | + |
---|
| 3398 | + if ((mask&2) != 0) // Scale/rotation |
---|
| 3399 | + { |
---|
| 3400 | + obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = 1; |
---|
| 3401 | + obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0; |
---|
| 3402 | + obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0; |
---|
| 3403 | + obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1; |
---|
| 3404 | + obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0; |
---|
| 3405 | + obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0; |
---|
| 3406 | + } |
---|
| 3407 | + if ((mask&1) != 0) // Translation |
---|
| 3408 | + { |
---|
| 3409 | + if (obj.toParent != null) |
---|
| 3410 | + { |
---|
| 3411 | + obj.toParent[3][0] = obj.toParent[3][1] = obj.toParent[3][2] = 0; |
---|
| 3412 | + obj.fromParent[3][0] = obj.fromParent[3][1] = obj.fromParent[3][2] = 0; |
---|
| 3413 | + } |
---|
| 3414 | + } |
---|
| 3415 | + } |
---|
| 3416 | + |
---|
| 3417 | + public void Scale(int scale) |
---|
| 3418 | + { |
---|
| 3419 | + Object3D obj = this; |
---|
| 3420 | + |
---|
| 3421 | + obj.toParent[0][0] = obj.toParent[1][1] = obj.toParent[2][2] = scale; |
---|
| 3422 | + obj.toParent[0][1] = obj.toParent[1][0] = obj.toParent[2][0] = 0; |
---|
| 3423 | + obj.toParent[0][2] = obj.toParent[1][2] = obj.toParent[2][1] = 0; |
---|
| 3424 | + obj.fromParent[0][0] = obj.fromParent[1][1] = obj.fromParent[2][2] = 1/scale; |
---|
| 3425 | + obj.fromParent[0][1] = obj.fromParent[1][0] = obj.fromParent[2][0] = 0; |
---|
| 3426 | + obj.fromParent[0][2] = obj.fromParent[1][2] = obj.fromParent[2][1] = 0; |
---|
| 3427 | + } |
---|
| 3428 | + |
---|
| 3429 | + public void TextureRatioTransform(int axis) |
---|
| 3430 | + { |
---|
| 3431 | + cTexture tex = GetTextures(); |
---|
| 3432 | + |
---|
| 3433 | + com.sun.opengl.util.texture.TextureData texturedata = null; |
---|
| 3434 | + |
---|
| 3435 | + try |
---|
| 3436 | + { |
---|
| 3437 | + texturedata = Globals.theRenderer.GetTextureData(tex, false, texres); |
---|
| 3438 | + } |
---|
| 3439 | + catch (Exception e) |
---|
| 3440 | + { |
---|
| 3441 | + System.err.println("FAIL TextureRatio: " + this); |
---|
| 3442 | + } |
---|
| 3443 | + |
---|
| 3444 | + LA.matIdentity(Object3D.mat); |
---|
| 3445 | + Object3D.mat[axis][axis] = (double)texturedata.getWidth() / texturedata.getHeight(); |
---|
| 3446 | + |
---|
| 3447 | + if (toParent == null) |
---|
| 3448 | + { |
---|
| 3449 | + toParent = LA.newMatrix(); |
---|
| 3450 | + fromParent = LA.newMatrix(); |
---|
| 3451 | + } |
---|
| 3452 | + |
---|
| 3453 | + ResetTransform(2); |
---|
| 3454 | + |
---|
| 3455 | + LA.matConcat(Object3D.mat, fromParent, fromParent); |
---|
| 3456 | + LA.matInvert(fromParent, toParent); |
---|
| 3457 | + } |
---|
| 3458 | + |
---|
| 3459 | + void TextureRatio(int axis) |
---|
| 3460 | + { |
---|
| 3461 | + if (blockloop) |
---|
| 3462 | + return; |
---|
| 3463 | + |
---|
| 3464 | + blockloop = true; |
---|
| 3465 | + |
---|
| 3466 | + TextureRatioTransform(axis); |
---|
| 3467 | + |
---|
| 3468 | + for (int i=Size(); --i>=0;) |
---|
| 3469 | + { |
---|
| 3470 | + Object3D v = get(i); |
---|
| 3471 | + |
---|
| 3472 | + v.TextureRatio(axis); |
---|
| 3473 | + } |
---|
| 3474 | + |
---|
| 3475 | + blockloop = false; |
---|
| 3476 | + } |
---|
| 3477 | + |
---|
3117 | 3478 | void TransformChildren() |
---|
3118 | 3479 | { |
---|
3119 | 3480 | if (toParent != null) |
---|
.. | .. |
---|
3356 | 3717 | if (bRep != null) |
---|
3357 | 3718 | { |
---|
3358 | 3719 | //bRep.RemoveOneTriangle(); |
---|
| 3720 | + System.out.println(); |
---|
3359 | 3721 | System.out.println("Reducing " + this); |
---|
3360 | 3722 | if (name != null && name.contains("lockpickstraps")) |
---|
3361 | 3723 | name = name; |
---|
.. | .. |
---|
3467 | 3829 | |
---|
3468 | 3830 | void ClearMaterials() |
---|
3469 | 3831 | { |
---|
| 3832 | + if (blockloop) |
---|
| 3833 | + return; |
---|
| 3834 | + |
---|
| 3835 | + blockloop = true; |
---|
| 3836 | + |
---|
3470 | 3837 | ClearMaterial(); |
---|
3471 | | - for (int i = 0; i < size(); i++) |
---|
| 3838 | + for (int i = 0; i < Size(); i++) |
---|
3472 | 3839 | { |
---|
3473 | | - Object3D child = (Object3D) reserve(i); |
---|
| 3840 | + Object3D child = (Object3D) get(i); |
---|
3474 | 3841 | if (child == null) |
---|
3475 | 3842 | continue; |
---|
3476 | 3843 | child.ClearMaterials(); |
---|
3477 | | - release(i); |
---|
3478 | 3844 | } |
---|
| 3845 | + |
---|
| 3846 | + blockloop = false; |
---|
| 3847 | + } |
---|
| 3848 | + |
---|
| 3849 | + void ClearVersionList() |
---|
| 3850 | + { |
---|
| 3851 | + this.versionlist = null; |
---|
| 3852 | + this.versionindex = -1; |
---|
| 3853 | + this.versiontable = null; |
---|
| 3854 | + } |
---|
| 3855 | + |
---|
| 3856 | + void ClearVersions() |
---|
| 3857 | + { |
---|
| 3858 | + if (blockloop) |
---|
| 3859 | + return; |
---|
| 3860 | + |
---|
| 3861 | + blockloop = true; |
---|
| 3862 | + |
---|
| 3863 | + ClearVersionList(); |
---|
| 3864 | + for (int i = 0; i < Size(); i++) |
---|
| 3865 | + { |
---|
| 3866 | + Object3D child = (Object3D) get(i); |
---|
| 3867 | + if (child == null) |
---|
| 3868 | + continue; |
---|
| 3869 | + child.ClearVersions(); |
---|
| 3870 | + } |
---|
| 3871 | + |
---|
| 3872 | + blockloop = false; |
---|
3479 | 3873 | } |
---|
3480 | 3874 | |
---|
3481 | 3875 | void FlipV(boolean flip) |
---|
.. | .. |
---|
3503 | 3897 | if (blockloop) |
---|
3504 | 3898 | return; |
---|
3505 | 3899 | |
---|
3506 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3900 | + if (//marked || // does not make sense |
---|
| 3901 | + (bRep != null || material != null)) // borderline... |
---|
3507 | 3902 | live = h; |
---|
3508 | 3903 | |
---|
3509 | 3904 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3524 | 3919 | return; |
---|
3525 | 3920 | |
---|
3526 | 3921 | //if (bRep != null) |
---|
3527 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3922 | + if (//marked || // does not make sense |
---|
| 3923 | + (bRep != null || material != null)) // borderline... |
---|
3528 | 3924 | link2master = h; |
---|
3529 | 3925 | |
---|
3530 | 3926 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3544 | 3940 | if (blockloop) |
---|
3545 | 3941 | return; |
---|
3546 | 3942 | |
---|
3547 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3943 | + if (//marked || // does not make sense |
---|
| 3944 | + (bRep != null || material != null)) // borderline... |
---|
3548 | 3945 | hide = h; |
---|
3549 | 3946 | |
---|
3550 | 3947 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3564 | 3961 | if (blockloop) |
---|
3565 | 3962 | return; |
---|
3566 | 3963 | |
---|
3567 | | - if (bRep != null && material != null) // borderline... |
---|
| 3964 | + if (bRep != null || material != null) // borderline... |
---|
3568 | 3965 | marked = h; |
---|
3569 | 3966 | |
---|
3570 | 3967 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3574 | 3971 | continue; |
---|
3575 | 3972 | blockloop = true; |
---|
3576 | 3973 | child.MarkLeaves(h); |
---|
| 3974 | + blockloop = false; |
---|
| 3975 | + // release(i); |
---|
| 3976 | + } |
---|
| 3977 | + } |
---|
| 3978 | + |
---|
| 3979 | + void RewindLeaves(boolean h) |
---|
| 3980 | + { |
---|
| 3981 | + if (blockloop) |
---|
| 3982 | + return; |
---|
| 3983 | + |
---|
| 3984 | + if (bRep != null || material != null) // borderline... |
---|
| 3985 | + rewind = h; |
---|
| 3986 | + |
---|
| 3987 | + for (int i = 0; i < Size(); i++) |
---|
| 3988 | + { |
---|
| 3989 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3990 | + if (child == null) |
---|
| 3991 | + continue; |
---|
| 3992 | + blockloop = true; |
---|
| 3993 | + child.RewindLeaves(h); |
---|
| 3994 | + blockloop = false; |
---|
| 3995 | + // release(i); |
---|
| 3996 | + } |
---|
| 3997 | + } |
---|
| 3998 | + |
---|
| 3999 | + void RandomLeaves(boolean h) |
---|
| 4000 | + { |
---|
| 4001 | + if (blockloop) |
---|
| 4002 | + return; |
---|
| 4003 | + |
---|
| 4004 | + if (bRep != null || material != null) // borderline... |
---|
| 4005 | + random = h; |
---|
| 4006 | + |
---|
| 4007 | + for (int i = 0; i < Size(); i++) |
---|
| 4008 | + { |
---|
| 4009 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 4010 | + if (child == null) |
---|
| 4011 | + continue; |
---|
| 4012 | + blockloop = true; |
---|
| 4013 | + child.RandomLeaves(h); |
---|
3577 | 4014 | blockloop = false; |
---|
3578 | 4015 | // release(i); |
---|
3579 | 4016 | } |
---|
.. | .. |
---|
3611 | 4048 | |
---|
3612 | 4049 | void RevertMeshes() |
---|
3613 | 4050 | { |
---|
| 4051 | + // BLOCKLOOP |
---|
3614 | 4052 | if (this instanceof cMesh) |
---|
3615 | 4053 | { |
---|
3616 | 4054 | ((cMesh)this).Revert(); |
---|
.. | .. |
---|
3641 | 4079 | Touch(); |
---|
3642 | 4080 | } |
---|
3643 | 4081 | |
---|
3644 | | - ResetRecur(); |
---|
3645 | | - } |
---|
3646 | | - |
---|
3647 | | - void ResetRecur() |
---|
3648 | | - { |
---|
3649 | 4082 | for (int i = 0; i < size(); i++) |
---|
3650 | 4083 | { |
---|
3651 | 4084 | Object3D child = (Object3D) get(i); // reserve(i); |
---|
.. | .. |
---|
3859 | 4292 | Touch(); |
---|
3860 | 4293 | } |
---|
3861 | 4294 | |
---|
3862 | | - transient cVector min = new cVector(); |
---|
3863 | | - transient cVector max = new cVector(); |
---|
| 4295 | + transient cVector min; |
---|
| 4296 | + transient cVector max; |
---|
3864 | 4297 | |
---|
3865 | 4298 | void getBounds(cVector minima, cVector maxima, boolean xform) |
---|
3866 | 4299 | { |
---|
.. | .. |
---|
3876 | 4309 | if (blockloop) |
---|
3877 | 4310 | return; |
---|
3878 | 4311 | |
---|
3879 | | - if (min == null) // ??? |
---|
| 4312 | + if (min == null) |
---|
3880 | 4313 | { |
---|
3881 | 4314 | min = new cVector(); |
---|
3882 | 4315 | max = new cVector(); |
---|
3883 | 4316 | } |
---|
3884 | 4317 | |
---|
3885 | | - for (int i = 0; i<size(); i++) |
---|
| 4318 | + for (int i = 0; i<Size(); i++) |
---|
3886 | 4319 | { |
---|
3887 | | - Object3D child = (Object3D) reserve(i); |
---|
| 4320 | + Object3D child = (Object3D) get(i); //reserve(i); |
---|
3888 | 4321 | if (child == null) |
---|
3889 | 4322 | continue; |
---|
3890 | 4323 | |
---|
.. | .. |
---|
3903 | 4336 | if (child.hide && !(child instanceof Merge) || child.skip) |
---|
3904 | 4337 | //if (child.hide) |
---|
3905 | 4338 | { |
---|
3906 | | - release(i); |
---|
| 4339 | + //release(i); |
---|
3907 | 4340 | continue; |
---|
3908 | 4341 | } |
---|
3909 | 4342 | |
---|
3910 | 4343 | blockloop = true; |
---|
3911 | 4344 | child.getBounds(min, max, true); // xform); |
---|
3912 | 4345 | blockloop = false; |
---|
3913 | | - release(i); |
---|
| 4346 | + //release(i); |
---|
3914 | 4347 | |
---|
3915 | 4348 | MinMax(minima, maxima); |
---|
3916 | 4349 | } |
---|
3917 | 4350 | |
---|
3918 | 4351 | if (bRep != null) |
---|
3919 | 4352 | { |
---|
3920 | | - bRep.getBounds(minima,maxima,this); |
---|
| 4353 | + bRep.getBounds(minima, maxima, xform?this:null); |
---|
3921 | 4354 | } |
---|
3922 | 4355 | |
---|
3923 | 4356 | if (false) // xform) |
---|
.. | .. |
---|
4347 | 4780 | { |
---|
4348 | 4781 | blockloop = true; |
---|
4349 | 4782 | get(i).RepairShadow(); |
---|
| 4783 | + blockloop = false; |
---|
| 4784 | + } |
---|
| 4785 | + } |
---|
| 4786 | + |
---|
| 4787 | + void RepairSOV() |
---|
| 4788 | + { |
---|
| 4789 | + if (blockloop) |
---|
| 4790 | + return; |
---|
| 4791 | + |
---|
| 4792 | + String texname = this.GetPigmentTexture(); |
---|
| 4793 | + |
---|
| 4794 | + if (texname.startsWith("sov")) |
---|
| 4795 | + { |
---|
| 4796 | + String[] s = texname.split("/"); |
---|
| 4797 | + |
---|
| 4798 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4799 | + |
---|
| 4800 | + texname = sname[0]; |
---|
| 4801 | + |
---|
| 4802 | + if (sname.length > 1) |
---|
| 4803 | + { |
---|
| 4804 | + texname += "Color.jpg"; |
---|
| 4805 | + } |
---|
| 4806 | + |
---|
| 4807 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4808 | + } |
---|
| 4809 | + |
---|
| 4810 | + texname = this.GetBumpTexture(); |
---|
| 4811 | + |
---|
| 4812 | + if (texname.startsWith("sov")) |
---|
| 4813 | + { |
---|
| 4814 | + String[] s = texname.split("/"); |
---|
| 4815 | + |
---|
| 4816 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4817 | + |
---|
| 4818 | + texname = sname[0]; |
---|
| 4819 | + |
---|
| 4820 | + if (sname.length > 1) |
---|
| 4821 | + { |
---|
| 4822 | + texname += "Bump.jpg"; |
---|
| 4823 | + } |
---|
| 4824 | + |
---|
| 4825 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4826 | + } |
---|
| 4827 | + |
---|
| 4828 | + for (int i=0; i<Size(); i++) |
---|
| 4829 | + { |
---|
| 4830 | + blockloop = true; |
---|
| 4831 | + get(i).RepairSOV(); |
---|
4350 | 4832 | blockloop = false; |
---|
4351 | 4833 | } |
---|
4352 | 4834 | } |
---|
.. | .. |
---|
4865 | 5347 | } |
---|
4866 | 5348 | } |
---|
4867 | 5349 | |
---|
| 5350 | + ObjEditor GetWindow() |
---|
| 5351 | + { |
---|
| 5352 | + if (editWindow != null) |
---|
| 5353 | + return editWindow; |
---|
| 5354 | + |
---|
| 5355 | + return manipWindow; |
---|
| 5356 | + } |
---|
| 5357 | + |
---|
4868 | 5358 | cTreePath Select(int indexcount, boolean deselect) |
---|
4869 | 5359 | { |
---|
4870 | 5360 | if (hide || dontselect) |
---|
.. | .. |
---|
4901 | 5391 | if (leaf != null) |
---|
4902 | 5392 | { |
---|
4903 | 5393 | cTreePath tp = new cTreePath(this, leaf); |
---|
4904 | | - if (editWindow != null) |
---|
| 5394 | + ObjEditor window = GetWindow(); |
---|
| 5395 | + if (window != null) |
---|
4905 | 5396 | { |
---|
4906 | 5397 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4907 | | - editWindow.Select(tp, deselect, true); |
---|
| 5398 | + window.Select(tp, deselect, true); |
---|
4908 | 5399 | } |
---|
4909 | 5400 | |
---|
4910 | 5401 | return tp; |
---|
.. | .. |
---|
4921 | 5412 | |
---|
4922 | 5413 | if (child == null) |
---|
4923 | 5414 | continue; |
---|
| 5415 | + |
---|
4924 | 5416 | if (child.HasTransparency() && child.size() != 0) |
---|
4925 | 5417 | { |
---|
4926 | 5418 | cTreePath leaf = child.Select(indexcount, deselect); |
---|
.. | .. |
---|
4930 | 5422 | if (leaf != null) |
---|
4931 | 5423 | { |
---|
4932 | 5424 | cTreePath tp = new cTreePath(this, leaf); |
---|
4933 | | - if (editWindow != null) |
---|
| 5425 | + ObjEditor window = GetWindow(); |
---|
| 5426 | + if (window != null) |
---|
4934 | 5427 | { |
---|
4935 | | - editWindow.Select(tp, deselect, true); |
---|
| 5428 | + window.Select(tp, deselect, true); |
---|
4936 | 5429 | } |
---|
4937 | 5430 | |
---|
4938 | 5431 | return tp; |
---|
.. | .. |
---|
5257 | 5750 | blockloop = false; |
---|
5258 | 5751 | } |
---|
5259 | 5752 | |
---|
| 5753 | + void ResetSelectable() |
---|
| 5754 | + { |
---|
| 5755 | + if (blockloop) |
---|
| 5756 | + return; |
---|
| 5757 | + |
---|
| 5758 | + blockloop = true; |
---|
| 5759 | + |
---|
| 5760 | + keepdontselect = dontselect; |
---|
| 5761 | + dontselect = true; |
---|
| 5762 | + |
---|
| 5763 | + Object3D child; |
---|
| 5764 | + int nb = Size(); |
---|
| 5765 | + for (int i = 0; i < nb; i++) |
---|
| 5766 | + { |
---|
| 5767 | + child = (Object3D) get(i); |
---|
| 5768 | + if (child == null) |
---|
| 5769 | + continue; |
---|
| 5770 | + child.ResetSelectable(); |
---|
| 5771 | + } |
---|
| 5772 | + |
---|
| 5773 | + blockloop = false; |
---|
| 5774 | + } |
---|
| 5775 | + |
---|
| 5776 | + void RestoreSelectable() |
---|
| 5777 | + { |
---|
| 5778 | + if (blockloop) |
---|
| 5779 | + return; |
---|
| 5780 | + |
---|
| 5781 | + blockloop = true; |
---|
| 5782 | + |
---|
| 5783 | + dontselect = keepdontselect; |
---|
| 5784 | + |
---|
| 5785 | + Object3D child; |
---|
| 5786 | + int nb = Size(); |
---|
| 5787 | + for (int i = 0; i < nb; i++) |
---|
| 5788 | + { |
---|
| 5789 | + child = (Object3D) get(i); |
---|
| 5790 | + if (child == null) |
---|
| 5791 | + continue; |
---|
| 5792 | + child.RestoreSelectable(); |
---|
| 5793 | + } |
---|
| 5794 | + |
---|
| 5795 | + blockloop = false; |
---|
| 5796 | + } |
---|
| 5797 | + |
---|
5260 | 5798 | boolean IsSelected() |
---|
5261 | 5799 | { |
---|
5262 | 5800 | if (parent == null) |
---|
.. | .. |
---|
5317 | 5855 | if (fullname == null) |
---|
5318 | 5856 | return ""; |
---|
5319 | 5857 | |
---|
| 5858 | + if (fullname.pigment != null) |
---|
| 5859 | + { |
---|
| 5860 | + return fullname.pigment; |
---|
| 5861 | + } |
---|
| 5862 | + |
---|
5320 | 5863 | // System.out.println("Fullname = " + fullname); |
---|
5321 | 5864 | |
---|
5322 | 5865 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5329 | 5872 | |
---|
5330 | 5873 | if (split.length == 0) |
---|
5331 | 5874 | { |
---|
5332 | | - return ""; |
---|
| 5875 | + return fullname.pigment = ""; |
---|
5333 | 5876 | } |
---|
5334 | 5877 | |
---|
5335 | 5878 | if (split.length <= 2) |
---|
.. | .. |
---|
5337 | 5880 | if (fullname.name.endsWith(":")) |
---|
5338 | 5881 | { |
---|
5339 | 5882 | // Windows |
---|
5340 | | - return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5883 | + return fullname.pigment = fullname.name.substring(0, fullname.name.length()-1); |
---|
5341 | 5884 | } |
---|
5342 | 5885 | |
---|
5343 | | - return split[0]; |
---|
| 5886 | + return fullname.pigment = split[0]; |
---|
5344 | 5887 | } |
---|
5345 | 5888 | |
---|
5346 | 5889 | // Windows |
---|
5347 | 5890 | assert(split.length == 4); |
---|
5348 | 5891 | |
---|
5349 | | - return split[0] + ":" + split[1]; |
---|
| 5892 | + return fullname.pigment = split[0] + ":" + split[1]; |
---|
5350 | 5893 | } |
---|
5351 | 5894 | |
---|
5352 | 5895 | static String GetBump(cTexture fullname) |
---|
5353 | 5896 | { |
---|
5354 | 5897 | if (fullname == null) |
---|
5355 | 5898 | return ""; |
---|
| 5899 | + |
---|
| 5900 | + if (fullname.bump != null) |
---|
| 5901 | + { |
---|
| 5902 | + return fullname.bump; |
---|
| 5903 | + } |
---|
5356 | 5904 | |
---|
5357 | 5905 | // System.out.println("Fullname = " + fullname); |
---|
5358 | 5906 | // Does not work on Windows due to C: |
---|
.. | .. |
---|
5364 | 5912 | |
---|
5365 | 5913 | if (split.length == 0) |
---|
5366 | 5914 | { |
---|
5367 | | - return ""; |
---|
| 5915 | + return fullname.bump = ""; |
---|
5368 | 5916 | } |
---|
5369 | 5917 | |
---|
5370 | 5918 | if (split.length == 1) |
---|
5371 | 5919 | { |
---|
5372 | | - return ""; |
---|
| 5920 | + return fullname.bump = ""; |
---|
5373 | 5921 | } |
---|
5374 | 5922 | |
---|
5375 | 5923 | if (split.length == 2) |
---|
.. | .. |
---|
5377 | 5925 | if (fullname.name.endsWith(":")) |
---|
5378 | 5926 | { |
---|
5379 | 5927 | // Windows |
---|
5380 | | - return ""; |
---|
| 5928 | + return fullname.bump = ""; |
---|
5381 | 5929 | } |
---|
5382 | 5930 | |
---|
5383 | | - return split[1]; |
---|
| 5931 | + return fullname.bump = split[1]; |
---|
5384 | 5932 | } |
---|
5385 | 5933 | |
---|
5386 | 5934 | // Windows |
---|
5387 | 5935 | assert(split.length == 4); |
---|
5388 | 5936 | |
---|
5389 | | - return split[2] + ":" + split[3]; |
---|
| 5937 | + return fullname.bump = split[2] + ":" + split[3]; |
---|
5390 | 5938 | } |
---|
5391 | 5939 | |
---|
5392 | 5940 | String GetPigmentTexture() |
---|
.. | .. |
---|
5469 | 6017 | texname = ""; |
---|
5470 | 6018 | |
---|
5471 | 6019 | GetTextures().name = texname + ":" + GetBump(GetTextures()); |
---|
| 6020 | + |
---|
| 6021 | + GetTextures().pigment = null; |
---|
| 6022 | + |
---|
5472 | 6023 | Touch(); |
---|
5473 | 6024 | } |
---|
5474 | 6025 | |
---|
.. | .. |
---|
5542 | 6093 | |
---|
5543 | 6094 | GetTextures().name = Object3D.GetPigment(GetTextures()) + ":" + texname; |
---|
5544 | 6095 | |
---|
| 6096 | + GetTextures().bump = null; |
---|
| 6097 | + |
---|
5545 | 6098 | Touch(); |
---|
5546 | 6099 | } |
---|
5547 | 6100 | |
---|
.. | .. |
---|
5562 | 6115 | |
---|
5563 | 6116 | blockloop = true; |
---|
5564 | 6117 | child.ResetBumpTexture(); |
---|
| 6118 | + blockloop = false; |
---|
| 6119 | + } |
---|
| 6120 | + } |
---|
| 6121 | + |
---|
| 6122 | + void EmbedTextures(boolean embed) |
---|
| 6123 | + { |
---|
| 6124 | + if (blockloop) |
---|
| 6125 | + return; |
---|
| 6126 | + |
---|
| 6127 | + //if (GetTextures() != null) |
---|
| 6128 | + if (embed) |
---|
| 6129 | + CameraPane.EmbedTextures(GetTextures()); |
---|
| 6130 | + else |
---|
| 6131 | + { |
---|
| 6132 | + GetTextures().pigmentdata = null; |
---|
| 6133 | + GetTextures().bumpdata = null; |
---|
| 6134 | + GetTextures().pw = 0; |
---|
| 6135 | + GetTextures().ph = 0; |
---|
| 6136 | + GetTextures().bw = 0; |
---|
| 6137 | + GetTextures().bh = 0; |
---|
| 6138 | + } |
---|
| 6139 | + |
---|
| 6140 | + int nb = Size(); |
---|
| 6141 | + for (int i = 0; i < nb; i++) |
---|
| 6142 | + { |
---|
| 6143 | + Object3D child = (Object3D) get(i); |
---|
| 6144 | + |
---|
| 6145 | + if (child == null) |
---|
| 6146 | + continue; |
---|
| 6147 | + |
---|
| 6148 | + blockloop = true; |
---|
| 6149 | + child.EmbedTextures(embed); |
---|
5565 | 6150 | blockloop = false; |
---|
5566 | 6151 | } |
---|
5567 | 6152 | } |
---|
.. | .. |
---|
5590 | 6175 | return false; |
---|
5591 | 6176 | |
---|
5592 | 6177 | return parent.IsLive(); |
---|
| 6178 | + } |
---|
| 6179 | + |
---|
| 6180 | + boolean IsDynamic() |
---|
| 6181 | + { |
---|
| 6182 | + return live && bRep != null; |
---|
5593 | 6183 | } |
---|
5594 | 6184 | |
---|
5595 | 6185 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
.. | .. |
---|
5652 | 6242 | if (support != null) |
---|
5653 | 6243 | support = support; |
---|
5654 | 6244 | |
---|
5655 | | - //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5656 | | - boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 6245 | + boolean usecalllists = !IsDynamic() && |
---|
| 6246 | + IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 6247 | + //boolean usecalllists = false; //!IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 6248 | + |
---|
| 6249 | + //usecalllists &= display.DrawMode() == display.DEFAULT; // Don't compute list in shadow pass. |
---|
5657 | 6250 | |
---|
5658 | 6251 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5659 | 6252 | { |
---|
.. | .. |
---|
5663 | 6256 | // usecalllists &= !(parent instanceof RandomNode); |
---|
5664 | 6257 | // usecalllists = false; |
---|
5665 | 6258 | |
---|
5666 | | - if (GetBRep() != null) |
---|
5667 | | - usecalllists = usecalllists; |
---|
| 6259 | + if (display.DrawMode() == display.SHADOW) |
---|
| 6260 | + //GetBRep() != null) |
---|
| 6261 | + usecalllists = !!usecalllists; |
---|
5668 | 6262 | //System.out.println("draw " + this); |
---|
5669 | 6263 | //new Exception().printStackTrace(); |
---|
5670 | 6264 | |
---|
.. | .. |
---|
5673 | 6267 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5674 | 6268 | |
---|
5675 | 6269 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5676 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 6270 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 6271 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5677 | 6272 | { |
---|
5678 | 6273 | Globals.lighttouched = true; |
---|
5679 | 6274 | } // all panes... |
---|
| 6275 | + |
---|
5680 | 6276 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5681 | 6277 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5682 | 6278 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5684 | 6280 | if (!(this instanceof Composite)) |
---|
5685 | 6281 | touched = false; |
---|
5686 | 6282 | //if (displaylist == -1 && usecalllists) |
---|
5687 | | - if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
| 6283 | + if (bRep.displaylist <= 0 && usecalllists) // && display.DrawMode() == display.DEFAULT) // june 2013 |
---|
5688 | 6284 | { |
---|
5689 | 6285 | bRep.displaylist = display.GenList(); |
---|
5690 | 6286 | assert(bRep.displaylist != 0); |
---|
.. | .. |
---|
5695 | 6291 | |
---|
5696 | 6292 | //System.out.println("\tnew list " + list); |
---|
5697 | 6293 | //gl.glDrawBuffer(gl.GL_NONE); |
---|
5698 | | - if (usecalllists) |
---|
| 6294 | + if (usecalllists && bRep.displaylist > 0) |
---|
5699 | 6295 | { |
---|
5700 | 6296 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5701 | 6297 | display.NewList(bRep.displaylist); |
---|
.. | .. |
---|
5704 | 6300 | CallList(display, root, selected, blocked); |
---|
5705 | 6301 | |
---|
5706 | 6302 | // compiled = true; |
---|
5707 | | - if (usecalllists) |
---|
| 6303 | + if (usecalllists && bRep.displaylist > 0) |
---|
5708 | 6304 | { |
---|
5709 | 6305 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5710 | 6306 | display.EndList(); |
---|
.. | .. |
---|
5714 | 6310 | Globals.lighttouched = true; // all panes... |
---|
5715 | 6311 | } |
---|
5716 | 6312 | |
---|
5717 | | - touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; |
---|
5718 | | - //touched = false; |
---|
| 6313 | + //touched = GetBRep() == null; // this instanceof Composite || this instanceof FileObject; // false; |
---|
| 6314 | + touched = false; |
---|
5719 | 6315 | |
---|
5720 | 6316 | if (this instanceof Texture || this instanceof TextureNode) |
---|
5721 | 6317 | { |
---|
.. | .. |
---|
5804 | 6400 | if (GetBRep() != null) |
---|
5805 | 6401 | { |
---|
5806 | 6402 | display.NextIndex(); |
---|
| 6403 | + |
---|
5807 | 6404 | // vertex color conflict : gl.glCallList(list); |
---|
5808 | 6405 | DrawNode(display, root, selected); |
---|
5809 | 6406 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5815 | 6412 | { |
---|
5816 | 6413 | drawSelf(display, root, selected, blocked); |
---|
5817 | 6414 | } |
---|
| 6415 | + |
---|
| 6416 | +// if (!(this instanceof Composite)) |
---|
| 6417 | +// { |
---|
| 6418 | +// for (int i = 0; i < size(); i++) |
---|
| 6419 | +// { |
---|
| 6420 | +// Object3D child = (Object3D) reserve(i); |
---|
| 6421 | +// if (child == null) |
---|
| 6422 | +// continue; |
---|
| 6423 | +// |
---|
| 6424 | +// child.draw(display, root, selected, blocked); |
---|
| 6425 | +// |
---|
| 6426 | +// release(i); |
---|
| 6427 | +// } |
---|
| 6428 | +// } |
---|
5818 | 6429 | } else |
---|
5819 | 6430 | { |
---|
5820 | 6431 | /* |
---|
.. | .. |
---|
5844 | 6455 | tex = GetTextures(); |
---|
5845 | 6456 | } |
---|
5846 | 6457 | |
---|
5847 | | - boolean failed = false; |
---|
| 6458 | + boolean failedPigment = false; |
---|
| 6459 | + boolean failedBump = false; |
---|
5848 | 6460 | |
---|
| 6461 | + CameraPane.lastObject = this; |
---|
5849 | 6462 | try |
---|
5850 | 6463 | { |
---|
5851 | | - display.BindTextures(tex, texres); |
---|
| 6464 | + display.BindPigmentTexture(tex, texres); |
---|
5852 | 6465 | } |
---|
5853 | 6466 | catch (Exception e) |
---|
5854 | 6467 | { |
---|
5855 | | - System.err.println("FAILED: " + this); |
---|
5856 | | - failed = true; |
---|
| 6468 | + // System.err.println("FAILED: " + this); |
---|
| 6469 | + failedPigment = true; |
---|
| 6470 | + } |
---|
| 6471 | + |
---|
| 6472 | + try |
---|
| 6473 | + { |
---|
| 6474 | + display.BindBumpTexture(tex, texres); |
---|
| 6475 | + } |
---|
| 6476 | + catch (Exception e) |
---|
| 6477 | + { |
---|
| 6478 | + //System.err.println("FAILED: " + this); |
---|
| 6479 | + failedBump = true; |
---|
5857 | 6480 | } |
---|
5858 | 6481 | |
---|
5859 | 6482 | if (!compiled) |
---|
.. | .. |
---|
5874 | 6497 | // june 2013 drawSelf(display, root, selected); |
---|
5875 | 6498 | } |
---|
5876 | 6499 | } |
---|
| 6500 | + |
---|
| 6501 | + assert (!(this instanceof Composite)); |
---|
| 6502 | + { |
---|
| 6503 | +// CRASH MOCAP!! for (int i = 0; i < size(); i++) |
---|
| 6504 | +// { |
---|
| 6505 | +// Object3D child = (Object3D) reserve(i); |
---|
| 6506 | +// if (child == null) |
---|
| 6507 | +// continue; |
---|
| 6508 | +// |
---|
| 6509 | +// child.draw(display, root, selected, blocked); |
---|
| 6510 | +// |
---|
| 6511 | +// release(i); |
---|
| 6512 | +// } |
---|
| 6513 | + } |
---|
5877 | 6514 | } |
---|
5878 | 6515 | |
---|
5879 | | - if (!failed) |
---|
5880 | | - display.ReleaseTextures(tex); |
---|
| 6516 | + if (!failedBump) |
---|
| 6517 | + display.ReleaseBumpTexture(tex); |
---|
| 6518 | + |
---|
| 6519 | + if (!failedPigment) |
---|
| 6520 | + display.ReleasePigmentTexture(tex); |
---|
5881 | 6521 | |
---|
5882 | 6522 | display.PopMaterial(this, selected); |
---|
5883 | 6523 | } |
---|
.. | .. |
---|
5923 | 6563 | |
---|
5924 | 6564 | void CallList(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5925 | 6565 | { |
---|
5926 | | - if (GetBRep() == null) |
---|
5927 | | - { |
---|
5928 | | - drawSelf(display, root, selected, blocked); |
---|
5929 | | - } else |
---|
| 6566 | + if (GetBRep() != null) |
---|
5930 | 6567 | { |
---|
5931 | 6568 | DrawNode(display, root, selected); |
---|
5932 | 6569 | if (this instanceof BezierPatch) |
---|
5933 | 6570 | { |
---|
5934 | 6571 | //drawSelf(display, root, selected); |
---|
5935 | 6572 | } |
---|
| 6573 | + } |
---|
| 6574 | + else |
---|
| 6575 | + { |
---|
| 6576 | + drawSelf(display, root, selected, blocked); |
---|
5936 | 6577 | } |
---|
5937 | 6578 | } |
---|
5938 | 6579 | |
---|
.. | .. |
---|
6250 | 6891 | // dec 2012 |
---|
6251 | 6892 | new Exception().printStackTrace(); |
---|
6252 | 6893 | return; |
---|
| 6894 | + } |
---|
| 6895 | + |
---|
| 6896 | + if (dontselect) |
---|
| 6897 | + { |
---|
| 6898 | + //bRep.GenerateNormalsMINE(); |
---|
6253 | 6899 | } |
---|
6254 | 6900 | |
---|
6255 | 6901 | display.DrawGeometry(bRep, flipV, selectmode); |
---|
.. | .. |
---|
7035 | 7681 | } |
---|
7036 | 7682 | } |
---|
7037 | 7683 | |
---|
7038 | | - protected void calcHotSpot(cVector in, ClickInfo info, Point outPt, Rectangle outRec) |
---|
| 7684 | + static ClickInfo clickInfo = new ClickInfo(); |
---|
| 7685 | + |
---|
| 7686 | + protected void calcHotSpot(cVector in, //ClickInfo clickInfo, |
---|
| 7687 | + Point outPt, Rectangle outRec) |
---|
7039 | 7688 | { |
---|
7040 | | - int hc = info.bounds.x + info.bounds.width / 2; |
---|
7041 | | - int vc = info.bounds.y + info.bounds.height / 2; |
---|
7042 | | - double[][] toscreen = info.toScreen; |
---|
| 7689 | + int hc = clickInfo.bounds.x + clickInfo.bounds.width / 2; |
---|
| 7690 | + int vc = clickInfo.bounds.y + clickInfo.bounds.height / 2; |
---|
| 7691 | + double[][] toscreen = clickInfo.toScreen; |
---|
7043 | 7692 | if (toscreen == null) |
---|
7044 | 7693 | { |
---|
7045 | | - toscreen = new Camera(info.camera.viewCode).toScreen; |
---|
| 7694 | + toscreen = new Camera(clickInfo.camera.viewCode).toScreen; |
---|
7046 | 7695 | } |
---|
7047 | 7696 | cVector vec = in; |
---|
7048 | 7697 | LA.xformPos(in, toscreen, in); |
---|
7049 | 7698 | //System.out.println("Distance = " + info.camera.Distance()); |
---|
7050 | | - vec.x *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
7051 | | - vec.y *= 100 * info.camera.SCALE / info.camera.Distance(); |
---|
| 7699 | + vec.x *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
| 7700 | + vec.y *= 100 * clickInfo.camera.SCALE / clickInfo.camera.Distance(); |
---|
7052 | 7701 | outPt.x = hc + (int) vec.x; |
---|
7053 | 7702 | outPt.y = vc - (int) vec.y; |
---|
7054 | 7703 | outRec.x = outPt.x - 3; |
---|
.. | .. |
---|
7056 | 7705 | outRec.width = outRec.height = 6; |
---|
7057 | 7706 | } |
---|
7058 | 7707 | |
---|
7059 | | - protected Rectangle calcHotSpot(cVector in, ClickInfo info) |
---|
| 7708 | + protected Rectangle calcHotSpot(cVector in//, ClickInfo clickInfo |
---|
| 7709 | + ) |
---|
7060 | 7710 | { |
---|
7061 | 7711 | Point pt = new Point(0, 0); |
---|
7062 | 7712 | Rectangle rec = new Rectangle(); |
---|
7063 | | - calcHotSpot(in, info, pt, rec); |
---|
| 7713 | + calcHotSpot(in, //clickInfo, |
---|
| 7714 | + pt, rec); |
---|
7064 | 7715 | return rec; |
---|
7065 | 7716 | } |
---|
7066 | 7717 | |
---|
7067 | | - void drawEditHandles0(ClickInfo info, int level) |
---|
| 7718 | + void drawEditHandles0(//ClickInfo clickInfo, |
---|
| 7719 | + int level) |
---|
7068 | 7720 | { |
---|
7069 | 7721 | if (level == 0) |
---|
7070 | 7722 | { |
---|
.. | .. |
---|
7073 | 7725 | { |
---|
7074 | 7726 | cVector origin = new cVector(); |
---|
7075 | 7727 | //LA.xformPos(origin, toParent, origin); |
---|
7076 | | - Rectangle spot = calcHotSpot(origin, info); |
---|
| 7728 | + if (this.clickInfo == null) |
---|
| 7729 | + this.clickInfo = new ClickInfo(); |
---|
| 7730 | + |
---|
| 7731 | + Rectangle spot = calcHotSpot(origin); //, clickInfo); |
---|
7077 | 7732 | Rectangle boundary = new Rectangle(); |
---|
7078 | 7733 | boundary.x = spot.x - 30; |
---|
7079 | 7734 | boundary.y = spot.y - 30; |
---|
7080 | 7735 | boundary.width = spot.width + 60; |
---|
7081 | 7736 | boundary.height = spot.height + 60; |
---|
7082 | | - info.g.setColor(Color.red); |
---|
| 7737 | + clickInfo.g.setColor(Color.white); |
---|
7083 | 7738 | int spotw = spot.x + spot.width; |
---|
7084 | 7739 | int spoth = spot.y + spot.height; |
---|
7085 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7740 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7086 | 7741 | // if (CameraPane.Xmin > spot.x) |
---|
7087 | 7742 | // { |
---|
7088 | 7743 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7099 | 7754 | // { |
---|
7100 | 7755 | // CameraPane.Ymax = spoth; |
---|
7101 | 7756 | // } |
---|
7102 | | - spot.translate(32, 32); |
---|
7103 | | - spotw = spot.x + spot.width; |
---|
7104 | | - spoth = spot.y + spot.height; |
---|
7105 | | - info.g.setColor(Color.cyan); |
---|
7106 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7107 | 7757 | // if (CameraPane.Xmin > spot.x) |
---|
7108 | 7758 | // { |
---|
7109 | 7759 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7122 | 7772 | // } |
---|
7123 | 7773 | // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
7124 | 7774 | //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
7125 | | - spot.translate(0, -32); |
---|
7126 | | - info.g.setColor(Color.yellow); |
---|
7127 | | - info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7128 | | - info.g.setColor(Color.green); |
---|
| 7775 | + spot.translate(32, 0); |
---|
| 7776 | + clickInfo.g.setColor(Color.yellow); |
---|
| 7777 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7778 | + |
---|
| 7779 | + spot.translate(32, 64); |
---|
| 7780 | + spotw = spot.x + spot.width; |
---|
| 7781 | + spoth = spot.y + spot.height; |
---|
| 7782 | + clickInfo.g.setColor(Color.cyan); |
---|
| 7783 | + clickInfo.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7129 | 7784 | // if (CameraPane.Xmin > spot.x) |
---|
7130 | 7785 | // { |
---|
7131 | 7786 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7142 | 7797 | // { |
---|
7143 | 7798 | // CameraPane.Ymax = spoth; |
---|
7144 | 7799 | // } |
---|
7145 | | - info.g.drawArc(boundary.x, boundary.y, |
---|
7146 | | - boundary.width, boundary.height, 0, 360); |
---|
| 7800 | + clickInfo.g.setColor(Color.green); |
---|
| 7801 | + clickInfo.g.drawArc(boundary.x + clickInfo.DX, boundary.y + clickInfo.DY, |
---|
| 7802 | + (int)(boundary.width * clickInfo.W), (int)(boundary.height * clickInfo.W), 0, 360); |
---|
7147 | 7803 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
7148 | 7804 | // if (CameraPane.Xmin > boundary.x) |
---|
7149 | 7805 | // { |
---|
.. | .. |
---|
7165 | 7821 | } |
---|
7166 | 7822 | } |
---|
7167 | 7823 | |
---|
7168 | | - boolean doEditClick0(ClickInfo info, int level) |
---|
| 7824 | + boolean doEditClick0(//ClickInfo clickInfo, |
---|
| 7825 | + int level) |
---|
7169 | 7826 | { |
---|
7170 | 7827 | if (level == 0) |
---|
7171 | 7828 | { |
---|
.. | .. |
---|
7174 | 7831 | |
---|
7175 | 7832 | boolean retval = false; |
---|
7176 | 7833 | |
---|
7177 | | - startX = info.x; |
---|
7178 | | - startY = info.y; |
---|
| 7834 | + startX = clickInfo.x; |
---|
| 7835 | + startY = clickInfo.y; |
---|
7179 | 7836 | |
---|
7180 | 7837 | hitSomething = -1; |
---|
7181 | 7838 | cVector origin = new cVector(); |
---|
.. | .. |
---|
7185 | 7842 | { |
---|
7186 | 7843 | centerPt = new Point(0, 0); |
---|
7187 | 7844 | } |
---|
7188 | | - calcHotSpot(origin, info, centerPt, spot); |
---|
7189 | | - if (spot.contains(info.x, info.y)) |
---|
| 7845 | + calcHotSpot(origin, //info, |
---|
| 7846 | + centerPt, spot); |
---|
| 7847 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7190 | 7848 | { |
---|
7191 | 7849 | hitSomething = hitCenter; |
---|
7192 | 7850 | retval = true; |
---|
7193 | 7851 | } |
---|
7194 | 7852 | spot.translate(32, 0); |
---|
7195 | | - if (spot.contains(info.x, info.y)) |
---|
| 7853 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7196 | 7854 | { |
---|
7197 | 7855 | hitSomething = hitRotate; |
---|
7198 | 7856 | retval = true; |
---|
7199 | 7857 | } |
---|
7200 | 7858 | spot.translate(0, 32); |
---|
7201 | | - if (spot.contains(info.x, info.y)) |
---|
| 7859 | + spot.translate(32, 0); |
---|
| 7860 | + spot.translate(0, 32); |
---|
| 7861 | + if (spot.contains(clickInfo.x, clickInfo.y)) |
---|
7202 | 7862 | { |
---|
7203 | 7863 | hitSomething = hitScale; |
---|
| 7864 | + |
---|
| 7865 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
| 7866 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
| 7867 | + double sign = 1; |
---|
| 7868 | + if (hScale < 0) |
---|
| 7869 | + { |
---|
| 7870 | + sign = -1; |
---|
| 7871 | + } |
---|
| 7872 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
| 7873 | + if (hScale < 0.01) |
---|
| 7874 | + { |
---|
| 7875 | + //hScale = 0.01; |
---|
| 7876 | + } |
---|
| 7877 | + |
---|
| 7878 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
| 7879 | + sign = 1; |
---|
| 7880 | + if (vScale < 0) |
---|
| 7881 | + { |
---|
| 7882 | + sign = -1; |
---|
| 7883 | + } |
---|
| 7884 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
| 7885 | + if (vScale < 0.01) |
---|
| 7886 | + { |
---|
| 7887 | + //vScale = 0.01; |
---|
| 7888 | + } |
---|
| 7889 | + |
---|
| 7890 | + clickInfo.scale = Math.sqrt(hScale*hScale + vScale*vScale); |
---|
| 7891 | + |
---|
7204 | 7892 | retval = true; |
---|
7205 | 7893 | } |
---|
7206 | 7894 | |
---|
.. | .. |
---|
7210 | 7898 | } |
---|
7211 | 7899 | |
---|
7212 | 7900 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7213 | | - modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
| 7901 | + modified = (clickInfo.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7214 | 7902 | //System.out.println("modified = " + modified); |
---|
7215 | 7903 | //new Exception().printStackTrace(); |
---|
7216 | 7904 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7238 | 7926 | return true; |
---|
7239 | 7927 | } |
---|
7240 | 7928 | |
---|
7241 | | - void doEditDrag0(ClickInfo info, boolean opposite) |
---|
| 7929 | + void doEditDrag0(//ClickInfo info, |
---|
| 7930 | + boolean opposite) |
---|
7242 | 7931 | { |
---|
7243 | 7932 | if (hitSomething == 0) |
---|
7244 | 7933 | { |
---|
.. | .. |
---|
7252 | 7941 | |
---|
7253 | 7942 | //System.out.println("hitSomething = " + hitSomething); |
---|
7254 | 7943 | |
---|
7255 | | - double scale = 0.005f * info.camera.Distance(); |
---|
| 7944 | + double scale = 0.005f * clickInfo.camera.Distance(); |
---|
7256 | 7945 | |
---|
7257 | 7946 | cVector xlate = new cVector(); |
---|
7258 | 7947 | //cVector xlate2 = new cVector(); |
---|
.. | .. |
---|
7266 | 7955 | |
---|
7267 | 7956 | scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7268 | 7957 | |
---|
7269 | | - if (modified || opposite) |
---|
| 7958 | + // Modified could snap |
---|
| 7959 | + if (//modified || |
---|
| 7960 | + opposite) |
---|
7270 | 7961 | { |
---|
7271 | 7962 | //assert(false); |
---|
7272 | 7963 | /* |
---|
.. | .. |
---|
7286 | 7977 | toParent[3][i] = xlate.get(i); |
---|
7287 | 7978 | LA.matInvert(toParent, fromParent); |
---|
7288 | 7979 | */ |
---|
7289 | | - cVector delta = LA.newVector(0, 0, startY - info.y); |
---|
7290 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 7980 | + cVector delta = LA.newVector(0, 0, startY - clickInfo.y); |
---|
| 7981 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7291 | 7982 | |
---|
7292 | 7983 | LA.matCopy(startMat, toParent); |
---|
7293 | 7984 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7296 | 7987 | } else |
---|
7297 | 7988 | { |
---|
7298 | 7989 | //LA.xformDir(delta, info.camera.fromScreen, delta); |
---|
7299 | | - cVector up = new cVector(info.camera.up); |
---|
| 7990 | + cVector up = new cVector(clickInfo.camera.up); |
---|
7300 | 7991 | cVector away = new cVector(); |
---|
7301 | 7992 | //cVector right2 = new cVector(); |
---|
7302 | 7993 | //LA.vecCross(up, cVector.Z, right); |
---|
.. | .. |
---|
7313 | 8004 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7314 | 8005 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7315 | 8006 | LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7316 | | - LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
| 8007 | + LA.xformDir(clickInfo.camera.away, ClickInfo.matbuffer, away); |
---|
7317 | 8008 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7318 | 8009 | LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7319 | 8010 | //LA.vecCross(up, cVector.Z, right2); |
---|
7320 | 8011 | |
---|
7321 | | - cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
| 8012 | + cVector delta = LA.newVector(clickInfo.x - startX, startY - clickInfo.y, 0); |
---|
7322 | 8013 | |
---|
7323 | 8014 | //System.out.println("DELTA0 = " + delta); |
---|
7324 | 8015 | //System.out.println("AWAY = " + info.camera.away); |
---|
7325 | 8016 | //System.out.println("UP = " + info.camera.up); |
---|
7326 | 8017 | if (away.z > 0) |
---|
7327 | 8018 | { |
---|
7328 | | - if (info.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
| 8019 | + if (clickInfo.camera.up.x == 0) // LA.vecDot(right, right2)<0) |
---|
7329 | 8020 | { |
---|
7330 | 8021 | delta.x = -delta.x; |
---|
7331 | 8022 | } else |
---|
.. | .. |
---|
7340 | 8031 | //System.out.println("DELTA1 = " + delta); |
---|
7341 | 8032 | LA.xformDir(delta, ClickInfo.matbuffer, delta); |
---|
7342 | 8033 | //System.out.println("DELTA2 = " + delta); |
---|
7343 | | - LA.xformDir(delta, new Camera(info.camera.viewCode).fromScreen, delta); |
---|
| 8034 | + LA.xformDir(delta, new Camera(clickInfo.camera.viewCode).fromScreen, delta); |
---|
7344 | 8035 | LA.matCopy(startMat, toParent); |
---|
7345 | 8036 | //System.out.println("DELTA3 = " + delta); |
---|
7346 | 8037 | LA.matTranslate(toParent, delta.x * scale, delta.y * scale, delta.z * scale); |
---|
.. | .. |
---|
7350 | 8041 | break; |
---|
7351 | 8042 | |
---|
7352 | 8043 | case hitRotate: // rotate |
---|
7353 | | - int dx = info.x - centerPt.x; |
---|
7354 | | - int dy = -(info.y - centerPt.y); |
---|
| 8044 | + int dx = clickInfo.x - centerPt.x; |
---|
| 8045 | + int dy = -(clickInfo.y - centerPt.y); |
---|
7355 | 8046 | double angle = (double) Math.atan2(dx, dy); |
---|
7356 | 8047 | angle = -(1.570796 - angle); |
---|
7357 | 8048 | |
---|
.. | .. |
---|
7360 | 8051 | |
---|
7361 | 8052 | if (modified) |
---|
7362 | 8053 | { |
---|
7363 | | - // Rotate 90 degrees |
---|
| 8054 | + // Rotate 45 degrees |
---|
7364 | 8055 | angle /= (Math.PI / 4); |
---|
7365 | 8056 | angle = Math.floor(angle + 0.5); |
---|
7366 | 8057 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7374 | 8065 | } |
---|
7375 | 8066 | /**/ |
---|
7376 | 8067 | |
---|
7377 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 8068 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7378 | 8069 | { |
---|
7379 | 8070 | case 1: // '\001' |
---|
7380 | 8071 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7401 | 8092 | break; |
---|
7402 | 8093 | |
---|
7403 | 8094 | case hitScale: // scale |
---|
7404 | | - double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 8095 | + double hScale = (double) (clickInfo.x - centerPt.x) / 64; |
---|
7405 | 8096 | double sign = 1; |
---|
7406 | 8097 | if (hScale < 0) |
---|
7407 | 8098 | { |
---|
.. | .. |
---|
7413 | 8104 | //hScale = 0.01; |
---|
7414 | 8105 | } |
---|
7415 | 8106 | |
---|
7416 | | - double vScale = (double) (info.y - centerPt.y) / 32; |
---|
| 8107 | + double vScale = (double) (clickInfo.y - centerPt.y) / 64; |
---|
7417 | 8108 | sign = 1; |
---|
7418 | 8109 | if (vScale < 0) |
---|
7419 | 8110 | { |
---|
.. | .. |
---|
7424 | 8115 | { |
---|
7425 | 8116 | //vScale = 0.01; |
---|
7426 | 8117 | } |
---|
| 8118 | + |
---|
7427 | 8119 | LA.matCopy(startMat, toParent); |
---|
7428 | 8120 | /**/ |
---|
7429 | 8121 | for (int i = 0; i < 3; i++) |
---|
.. | .. |
---|
7433 | 8125 | } |
---|
7434 | 8126 | /**/ |
---|
7435 | 8127 | |
---|
7436 | | - double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 8128 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / clickInfo.scale; |
---|
7437 | 8129 | |
---|
7438 | 8130 | if (totalScale < 0.01) |
---|
7439 | 8131 | { |
---|
7440 | 8132 | totalScale = 0.01; |
---|
7441 | 8133 | } |
---|
7442 | 8134 | |
---|
7443 | | - switch (info.pane.RenderCamera().viewCode) |
---|
| 8135 | + switch (clickInfo.pane.RenderCamera().viewCode) |
---|
7444 | 8136 | { |
---|
7445 | 8137 | case 3: // '\001' |
---|
7446 | 8138 | if (modified || opposite) |
---|
7447 | 8139 | { |
---|
| 8140 | + if (modified) // && opposite) |
---|
| 8141 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 8142 | + else |
---|
7448 | 8143 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7449 | | - LA.matScale(toParent, totalScale, 1, 1); |
---|
| 8144 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7450 | 8145 | } // vScale, 1); |
---|
7451 | 8146 | else |
---|
7452 | 8147 | { |
---|
| 8148 | + // EXCEPTION! |
---|
7453 | 8149 | LA.matScale(toParent, 1, totalScale, totalScale); |
---|
7454 | 8150 | } // vScale, 1); |
---|
7455 | 8151 | break; |
---|
.. | .. |
---|
7457 | 8153 | case 2: // '\002' |
---|
7458 | 8154 | if (modified || opposite) |
---|
7459 | 8155 | { |
---|
7460 | | - //LA.matScale(toParent, hScale, 1, vScale); |
---|
7461 | | - LA.matScale(toParent, 1, totalScale, 1); |
---|
| 8156 | + if (modified) // && opposite) |
---|
| 8157 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 8158 | + else |
---|
| 8159 | + //LA.matScale(toParent, hScale, 1, vScale); |
---|
| 8160 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7462 | 8161 | } else |
---|
7463 | 8162 | { |
---|
7464 | 8163 | LA.matScale(toParent, totalScale, 1, totalScale); |
---|
.. | .. |
---|
7468 | 8167 | case 1: // '\003' |
---|
7469 | 8168 | if (modified || opposite) |
---|
7470 | 8169 | { |
---|
7471 | | - //LA.matScale(toParent, hScale, vScale, 1); |
---|
7472 | | - LA.matScale(toParent, 1, 1, totalScale); |
---|
| 8170 | + if (modified) // && opposite) |
---|
| 8171 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
| 8172 | + else |
---|
| 8173 | + //LA.matScale(toParent, hScale, vScale, 1); |
---|
| 8174 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7473 | 8175 | } else |
---|
7474 | 8176 | { |
---|
7475 | 8177 | LA.matScale(toParent, totalScale, totalScale, 1); |
---|
.. | .. |
---|
7506 | 8208 | } // NEW ... |
---|
7507 | 8209 | |
---|
7508 | 8210 | |
---|
7509 | | - info.pane.repaint(); |
---|
| 8211 | + clickInfo.pane.repaint(); |
---|
7510 | 8212 | } |
---|
7511 | 8213 | |
---|
7512 | 8214 | boolean overflow = false; |
---|
.. | .. |
---|
7620 | 8322 | if (!Globals.ADVANCED) |
---|
7621 | 8323 | return objname; |
---|
7622 | 8324 | |
---|
7623 | | - return objname + " " + System.identityHashCode(this); |
---|
| 8325 | + return objname + " " + System.identityHashCode(this) + " " + GetUUID(); |
---|
7624 | 8326 | } |
---|
7625 | 8327 | |
---|
7626 | 8328 | public int hashCode() |
---|
.. | .. |
---|
7685 | 8387 | { |
---|
7686 | 8388 | editWindow = null; |
---|
7687 | 8389 | } // ? |
---|
| 8390 | + } |
---|
| 8391 | + else |
---|
| 8392 | + { |
---|
| 8393 | + //editWindow.closeUI(); |
---|
7688 | 8394 | } |
---|
7689 | 8395 | } |
---|
7690 | 8396 | |
---|
.. | .. |
---|
7843 | 8549 | } |
---|
7844 | 8550 | |
---|
7845 | 8551 | transient ObjEditor editWindow; |
---|
| 8552 | + transient ObjEditor manipWindow; |
---|
| 8553 | + |
---|
| 8554 | + transient boolean pinned; |
---|
| 8555 | + |
---|
7846 | 8556 | transient ObjectUI objectUI; |
---|
7847 | 8557 | public static int povDepth = 0; |
---|
7848 | 8558 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
7857 | 8567 | private static cVector2 qq2 = new cVector2(); |
---|
7858 | 8568 | private static cVector2 rr2 = new cVector2(); |
---|
7859 | 8569 | private static cVector2 ss2 = new cVector2(); |
---|
7860 | | - private static cVector edge1 = new cVector(); |
---|
7861 | | - private static cVector edge2 = new cVector(); |
---|
| 8570 | +// private static cVector edge1 = new cVector(); |
---|
| 8571 | +// private static cVector edge2 = new cVector(); |
---|
7862 | 8572 | //private static cVector norm = new cVector(); |
---|
7863 | 8573 | /*transient private*/ int hitSomething; |
---|
7864 | 8574 | static final int hitCenter = 1; |
---|
.. | .. |
---|
8056 | 8766 | |
---|
8057 | 8767 | Touch(); |
---|
8058 | 8768 | } |
---|
| 8769 | + |
---|
| 8770 | + static Vertex s1 = new Vertex(); |
---|
| 8771 | + static Vertex s2 = new Vertex(); |
---|
| 8772 | + static Vertex s3 = new Vertex(); |
---|
8059 | 8773 | |
---|
| 8774 | + boolean intersectMesh(Ray ray, IntersectResult result) |
---|
| 8775 | + { |
---|
| 8776 | + boolean success = false; |
---|
| 8777 | + |
---|
| 8778 | + if (bRep.stripified) |
---|
| 8779 | + { |
---|
| 8780 | + int[] strips = bRep.getRawIndices(); |
---|
| 8781 | + |
---|
| 8782 | + // TRIANGLE STRIP ARRAY |
---|
| 8783 | + if (bRep.trimmed) |
---|
| 8784 | + { |
---|
| 8785 | + float[] v = bRep.getRawVertices(); |
---|
| 8786 | + |
---|
| 8787 | + int count3 = 0; |
---|
| 8788 | + |
---|
| 8789 | + if (v.length > 0) |
---|
| 8790 | + { |
---|
| 8791 | + for (int i = 0; i < strips.length; i++) |
---|
| 8792 | + { |
---|
| 8793 | + s1.set(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 8794 | + count3 += 3; |
---|
| 8795 | + |
---|
| 8796 | + s2.set(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 8797 | + count3 += 3; |
---|
| 8798 | + |
---|
| 8799 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 8800 | + { |
---|
| 8801 | + s3.set(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 8802 | + count3 += 3; |
---|
| 8803 | + |
---|
| 8804 | + if (j%2 == 0) |
---|
| 8805 | + success |= intersectTriangle(ray, result, s1, s2, s3); |
---|
| 8806 | + else |
---|
| 8807 | + success |= intersectTriangle(ray, result, s1, s3, s2); |
---|
| 8808 | + |
---|
| 8809 | + s1.set(s2); |
---|
| 8810 | + s2.set(s3); |
---|
| 8811 | + } |
---|
| 8812 | + } |
---|
| 8813 | + } |
---|
| 8814 | + |
---|
| 8815 | + assert count3 == v.length; |
---|
| 8816 | + } |
---|
| 8817 | + else // !trimmed |
---|
| 8818 | + { |
---|
| 8819 | + int count = 0; |
---|
| 8820 | + for (int i = 0; i < strips.length; i++) |
---|
| 8821 | + { |
---|
| 8822 | + Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
| 8823 | + Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
| 8824 | + |
---|
| 8825 | + for (int j = 0; j < strips[i] - 2; j++) |
---|
| 8826 | + { |
---|
| 8827 | + Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
| 8828 | + |
---|
| 8829 | + if (j%2 == 0) |
---|
| 8830 | + success |= intersectTriangle(ray, result, p, q, r); |
---|
| 8831 | + else |
---|
| 8832 | + success |= intersectTriangle(ray, result, p, r, q); |
---|
| 8833 | + |
---|
| 8834 | + p = q; |
---|
| 8835 | + q = r; |
---|
| 8836 | + } |
---|
| 8837 | + } |
---|
| 8838 | + } |
---|
| 8839 | + } else // catch (Error e) |
---|
| 8840 | + { |
---|
| 8841 | + int facecount = bRep.FaceCount(); |
---|
| 8842 | + for (int i = 0; i < facecount; i++) |
---|
| 8843 | + { |
---|
| 8844 | + Face face = bRep.GetFace(i); |
---|
| 8845 | + |
---|
| 8846 | + Vertex p = bRep.GetVertex(face.p); |
---|
| 8847 | + Vertex q = bRep.GetVertex(face.q); |
---|
| 8848 | + Vertex r = bRep.GetVertex(face.r); |
---|
| 8849 | + |
---|
| 8850 | + success |= intersectTriangle(ray, result, p, q, r); |
---|
| 8851 | + } |
---|
| 8852 | + } |
---|
| 8853 | + |
---|
| 8854 | + return success; |
---|
| 8855 | + } |
---|
| 8856 | + |
---|
| 8857 | + static cVector eye = new cVector(); |
---|
| 8858 | + static cVector dir = new cVector(); |
---|
| 8859 | + |
---|
| 8860 | + transient BBox bbox = null; |
---|
| 8861 | + |
---|
| 8862 | + boolean intersect(Ray ray, IntersectResult result) |
---|
| 8863 | + { |
---|
| 8864 | + double eyex = ray.eyePoint.x; |
---|
| 8865 | + double eyey = ray.eyePoint.y; |
---|
| 8866 | + double eyez = ray.eyePoint.z; |
---|
| 8867 | + |
---|
| 8868 | + double dirx = ray.viewDirection.x; |
---|
| 8869 | + double diry = ray.viewDirection.y; |
---|
| 8870 | + double dirz = ray.viewDirection.z; |
---|
| 8871 | + |
---|
| 8872 | + if (this.fromParent != null) |
---|
| 8873 | + { |
---|
| 8874 | + eye.x = eyex; |
---|
| 8875 | + eye.y = eyey; |
---|
| 8876 | + eye.z = eyez; |
---|
| 8877 | + dir.x = dirx; |
---|
| 8878 | + dir.y = diry; |
---|
| 8879 | + dir.z = dirz; |
---|
| 8880 | + |
---|
| 8881 | + LA.xformPos(eye, this.fromParent, eye); |
---|
| 8882 | + LA.xformDir(dir, this.fromParent, dir); |
---|
| 8883 | + |
---|
| 8884 | + ray.eyePoint.x = eye.x; |
---|
| 8885 | + ray.eyePoint.y = eye.y; |
---|
| 8886 | + ray.eyePoint.z = eye.z; |
---|
| 8887 | + |
---|
| 8888 | + ray.viewDirection.x = dir.x; |
---|
| 8889 | + ray.viewDirection.y = dir.y; |
---|
| 8890 | + ray.viewDirection.z = dir.z; |
---|
| 8891 | + } |
---|
| 8892 | + |
---|
| 8893 | + boolean success = false; |
---|
| 8894 | + |
---|
| 8895 | + boolean touch = false; |
---|
| 8896 | + |
---|
| 8897 | + if (bRep != null) |
---|
| 8898 | + { |
---|
| 8899 | + if (bbox == null) |
---|
| 8900 | + { |
---|
| 8901 | + bbox = new BBox(); |
---|
| 8902 | + |
---|
| 8903 | + cVector min = new cVector(); |
---|
| 8904 | + cVector max = new cVector(); |
---|
| 8905 | + |
---|
| 8906 | + this.getBounds(min, max, false); |
---|
| 8907 | + |
---|
| 8908 | + bbox.min.x = min.x; |
---|
| 8909 | + bbox.min.y = min.y; |
---|
| 8910 | + bbox.min.z = min.z; |
---|
| 8911 | + |
---|
| 8912 | + bbox.max.x = max.x; |
---|
| 8913 | + bbox.max.y = max.y; |
---|
| 8914 | + bbox.max.z = max.z; |
---|
| 8915 | + } |
---|
| 8916 | + |
---|
| 8917 | + if (bbox.intersect(ray, result)) |
---|
| 8918 | + { |
---|
| 8919 | + success |= intersectMesh(ray, result); |
---|
| 8920 | + } |
---|
| 8921 | + else |
---|
| 8922 | + { |
---|
| 8923 | + //this.hide = true; |
---|
| 8924 | + touch = true; |
---|
| 8925 | + } |
---|
| 8926 | + } |
---|
| 8927 | + |
---|
| 8928 | + for (int i=0; i<size(); i++) |
---|
| 8929 | + { |
---|
| 8930 | + Object3D child = (Object3D) reserve(i); |
---|
| 8931 | + |
---|
| 8932 | + if (child == null) |
---|
| 8933 | + continue; |
---|
| 8934 | + |
---|
| 8935 | + success |= child.intersect(ray, result); |
---|
| 8936 | + release(i); |
---|
| 8937 | + } |
---|
| 8938 | + |
---|
| 8939 | + ray.eyePoint.x = eyex; |
---|
| 8940 | + ray.eyePoint.y = eyey; |
---|
| 8941 | + ray.eyePoint.z = eyez; |
---|
| 8942 | + |
---|
| 8943 | + ray.viewDirection.x = dirx; |
---|
| 8944 | + ray.viewDirection.y = diry; |
---|
| 8945 | + ray.viewDirection.z = dirz; |
---|
| 8946 | + |
---|
| 8947 | +// if (touch) |
---|
| 8948 | +// this.Touch(); // refresh display list |
---|
| 8949 | + |
---|
| 8950 | + return success; |
---|
| 8951 | + } |
---|
| 8952 | + |
---|
| 8953 | + static Vector3d edge1 = new Vector3d(); |
---|
| 8954 | + static Vector3d edge2 = new Vector3d(); |
---|
| 8955 | + static Vector3d P = new Vector3d(); |
---|
| 8956 | + static Vector3d T = new Vector3d(); |
---|
| 8957 | + static Vector3d Q = new Vector3d(); |
---|
| 8958 | + |
---|
| 8959 | + private boolean intersectTriangle(Ray ray, IntersectResult result, Vertex v1, Vertex v2, Vertex v3) |
---|
| 8960 | + { |
---|
| 8961 | + /* |
---|
| 8962 | + Fast, Minimum Storage Ray/Triangle Intersection, Moller et al. |
---|
| 8963 | + |
---|
| 8964 | + Reference: http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf |
---|
| 8965 | + */ |
---|
| 8966 | + |
---|
| 8967 | + // Calculate edges of the triangle |
---|
| 8968 | + edge1.set(v2.x - v1.x, v2.y - v1.y, v2.z - v1.z); |
---|
| 8969 | + edge2.set(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z); |
---|
| 8970 | + |
---|
| 8971 | + // Calculate the determinant (U parameter) |
---|
| 8972 | + P.cross(ray.viewDirection, edge2); |
---|
| 8973 | + double det = edge1.dot(P); |
---|
| 8974 | + |
---|
| 8975 | + if (det > -1e-9 && det < 1e-9) |
---|
| 8976 | + { |
---|
| 8977 | + return false; |
---|
| 8978 | + } // Ray lies in plane of triangle |
---|
| 8979 | + |
---|
| 8980 | + double invDet = 1 / det; |
---|
| 8981 | + |
---|
| 8982 | + // Calculate distance from vertex1 to ray origin |
---|
| 8983 | + T.set(ray.eyePoint.x - v1.x, ray.eyePoint.y - v1.y, ray.eyePoint.z - v1.z); |
---|
| 8984 | + |
---|
| 8985 | + double U = (T.dot(P)) * invDet; // Calculate U parameter |
---|
| 8986 | + |
---|
| 8987 | + if (U < 0.f || U > 1.f) |
---|
| 8988 | + { |
---|
| 8989 | + return false; |
---|
| 8990 | + } // Intersection lies outside of the triangle |
---|
| 8991 | + |
---|
| 8992 | + // Calculate V parameter |
---|
| 8993 | + Q.cross(T, edge1); |
---|
| 8994 | + |
---|
| 8995 | + double V = ray.viewDirection.dot(Q) * invDet; |
---|
| 8996 | + |
---|
| 8997 | + if (V < 0.f || (U + V) > 1.f) |
---|
| 8998 | + { |
---|
| 8999 | + return false; |
---|
| 9000 | + } // Intersection lies outside of the triangle |
---|
| 9001 | + |
---|
| 9002 | + double t = edge2.dot(Q) * invDet; |
---|
| 9003 | + |
---|
| 9004 | + if (t > 1e-9) // Triangle and ray intersects |
---|
| 9005 | + { |
---|
| 9006 | + //result.isIntersected = true; |
---|
| 9007 | + //result.id = id; |
---|
| 9008 | + |
---|
| 9009 | + if (false) // isShadow) |
---|
| 9010 | + { |
---|
| 9011 | + result.t = t; |
---|
| 9012 | + return true; |
---|
| 9013 | + } else if (t < result.t) |
---|
| 9014 | + { |
---|
| 9015 | + result.object = this; |
---|
| 9016 | + |
---|
| 9017 | + result.t = t; |
---|
| 9018 | + |
---|
| 9019 | + //result.p.x = ray.eyePoint.x + ray.viewDirection.x * t; |
---|
| 9020 | + //result.p.y = ray.eyePoint.y + ray.viewDirection.y * t; |
---|
| 9021 | + //result.p.z = ray.eyePoint.z + ray.viewDirection.z * t; |
---|
| 9022 | + |
---|
| 9023 | + result.n.cross(edge1, edge2); |
---|
| 9024 | + result.n.normalize(); |
---|
| 9025 | + } |
---|
| 9026 | + |
---|
| 9027 | + return true; |
---|
| 9028 | + } |
---|
| 9029 | + |
---|
| 9030 | + return false; |
---|
| 9031 | + } |
---|
8060 | 9032 | |
---|
8061 | 9033 | public int Size() |
---|
8062 | 9034 | { |
---|