.. | .. |
---|
5 | 5 | import java.util.Vector; |
---|
6 | 6 | |
---|
7 | 7 | import javax.media.j3d.Transform3D; |
---|
| 8 | +import javax.media.opengl.GL; |
---|
8 | 9 | import javax.vecmath.Vector3d; |
---|
9 | 10 | |
---|
10 | 11 | import javax.imageio.ImageIO; |
---|
.. | .. |
---|
13 | 14 | import //weka.core. |
---|
14 | 15 | matrix.Matrix; |
---|
15 | 16 | |
---|
| 17 | +import java.util.UUID; |
---|
| 18 | + |
---|
16 | 19 | //import net.sourceforge.sizeof.SizeOf; |
---|
17 | 20 | public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> |
---|
18 | 21 | { |
---|
19 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
20 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
| 24 | + |
---|
| 25 | + private UUID uuid = UUID.randomUUID(); |
---|
21 | 26 | |
---|
22 | 27 | ScriptNode scriptnode; |
---|
23 | 28 | |
---|
.. | .. |
---|
299 | 304 | } |
---|
300 | 305 | |
---|
301 | 306 | boolean live = false; |
---|
| 307 | + boolean dontselect = false; |
---|
302 | 308 | boolean hide = false; |
---|
303 | 309 | boolean link2master = false; // performs reset support/master at each frame |
---|
304 | 310 | boolean marked = false; // animation node |
---|
.. | .. |
---|
430 | 436 | { |
---|
431 | 437 | Object3D copy = this; |
---|
432 | 438 | |
---|
433 | | - Camera parentcam = CameraPane.theRenderer.manipCamera; |
---|
| 439 | + Camera parentcam = Globals.theRenderer.ManipCamera(); |
---|
434 | 440 | |
---|
435 | | - if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0]) |
---|
| 441 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0]) |
---|
436 | 442 | { |
---|
437 | | - parentcam = CameraPane.theRenderer.cameras[1]; |
---|
| 443 | + parentcam = Globals.theRenderer.Cameras()[1]; |
---|
438 | 444 | } |
---|
439 | 445 | |
---|
440 | | - if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1]) |
---|
| 446 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1]) |
---|
441 | 447 | { |
---|
442 | | - parentcam = CameraPane.theRenderer.cameras[0]; |
---|
| 448 | + parentcam = Globals.theRenderer.Cameras()[0]; |
---|
443 | 449 | } |
---|
444 | 450 | |
---|
445 | 451 | if (this == parentcam) |
---|
.. | .. |
---|
447 | 453 | //assert(this instanceof Camera); |
---|
448 | 454 | |
---|
449 | 455 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
450 | | - LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt); |
---|
| 456 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt()); |
---|
451 | 457 | } |
---|
452 | 458 | |
---|
453 | 459 | copy.marked ^= true; |
---|
.. | .. |
---|
467 | 473 | //assert(this instanceof Camera); |
---|
468 | 474 | |
---|
469 | 475 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
470 | | - LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt); |
---|
| 476 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt()); |
---|
471 | 477 | } |
---|
472 | 478 | |
---|
473 | 479 | copy.Touch(); // display list issue |
---|
.. | .. |
---|
602 | 608 | return; |
---|
603 | 609 | } |
---|
604 | 610 | |
---|
605 | | - if (CameraPane.fromscript) |
---|
| 611 | + if (Globals.fromscript) |
---|
606 | 612 | { |
---|
607 | 613 | transformcount = 0; |
---|
608 | 614 | return; |
---|
.. | .. |
---|
773 | 779 | if (step == 0) |
---|
774 | 780 | step = 1; |
---|
775 | 781 | if (maxcount == 0) |
---|
776 | | - maxcount = 2048; // 4; |
---|
| 782 | + maxcount = 128; // 2048; // 4; |
---|
777 | 783 | // if (acceleration == 0) |
---|
778 | 784 | // acceleration = 10; |
---|
779 | 785 | if (delay == 0) // serial |
---|
.. | .. |
---|
796 | 802 | |
---|
797 | 803 | if (marked && Globals.isLIVE() && live && |
---|
798 | 804 | //TEMP21aug2018 |
---|
799 | | - Globals.DrawMode() == iCameraPane.SHADOW && |
---|
| 805 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
800 | 806 | currentframe != Globals.framecount) |
---|
801 | 807 | { |
---|
802 | 808 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
911 | 917 | fromParent = null; // LA.newMatrix(); |
---|
912 | 918 | bRep = null; // new BoundaryRep(); |
---|
913 | 919 | |
---|
| 920 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 921 | + { |
---|
| 922 | + name = oname; |
---|
| 923 | + } |
---|
| 924 | + |
---|
914 | 925 | /* |
---|
915 | 926 | float hue = (float)Math.random(); |
---|
916 | 927 | Color col; |
---|
.. | .. |
---|
953 | 964 | |
---|
954 | 965 | public Object clone() |
---|
955 | 966 | { |
---|
956 | | - return GrafreeD.clone(this); |
---|
| 967 | + return Grafreed.clone(this); |
---|
957 | 968 | } |
---|
958 | 969 | |
---|
959 | 970 | Object3D copyExpand() |
---|
.. | .. |
---|
1469 | 1480 | BoundaryRep.SEUIL = other.material.cameralight; |
---|
1470 | 1481 | |
---|
1471 | 1482 | // Set default to 0.1 |
---|
1472 | | - BoundaryRep.SEUIL /= 2; |
---|
| 1483 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
1473 | 1484 | System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
1474 | 1485 | } |
---|
1475 | 1486 | |
---|
.. | .. |
---|
1728 | 1739 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1729 | 1740 | o.bRep = transientrep; |
---|
1730 | 1741 | if (clone) |
---|
1731 | | - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 1742 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1732 | 1743 | o.CreateMaterial(); |
---|
1733 | 1744 | o.SetAttributes(this, -1); |
---|
1734 | 1745 | //parent |
---|
.. | .. |
---|
1741 | 1752 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1742 | 1753 | o.bRep = bRep; |
---|
1743 | 1754 | if (clone) |
---|
1744 | | - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 1755 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1745 | 1756 | o.CreateMaterial(); |
---|
1746 | 1757 | //o.overwriteThis(this, -1); |
---|
1747 | 1758 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1828 | 1839 | if (obj.name == null) |
---|
1829 | 1840 | continue; // can't be a null one |
---|
1830 | 1841 | |
---|
| 1842 | + // Try perfect match first. |
---|
1831 | 1843 | if (n.equals(obj.name)) |
---|
1832 | 1844 | { |
---|
1833 | 1845 | theobj = obj; |
---|
1834 | 1846 | count++; |
---|
1835 | 1847 | } |
---|
1836 | 1848 | } |
---|
| 1849 | + |
---|
| 1850 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1837 | 1851 | |
---|
1838 | 1852 | if (count != 1) |
---|
1839 | 1853 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2299 | 2313 | { |
---|
2300 | 2314 | if (newWindow) |
---|
2301 | 2315 | { |
---|
| 2316 | + new Exception().printStackTrace(); |
---|
2302 | 2317 | System.exit(0); |
---|
2303 | 2318 | if (parent != null) |
---|
2304 | 2319 | { |
---|
.. | .. |
---|
2475 | 2490 | return retval; |
---|
2476 | 2491 | } |
---|
2477 | 2492 | |
---|
2478 | | - void doEditDrag(ClickInfo info) |
---|
| 2493 | + void doEditDrag(ClickInfo info, boolean opposite) |
---|
2479 | 2494 | { |
---|
2480 | 2495 | switch (doSomething) |
---|
2481 | 2496 | { |
---|
2482 | 2497 | case 1: // '\001' |
---|
2483 | 2498 | //super. |
---|
2484 | | - doEditDrag0(info); |
---|
| 2499 | + doEditDrag0(info, opposite); |
---|
2485 | 2500 | break; |
---|
2486 | 2501 | |
---|
2487 | 2502 | case 2: // '\002' |
---|
.. | .. |
---|
2494 | 2509 | { |
---|
2495 | 2510 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2496 | 2511 | //childToDrag.doEditDrag(info); |
---|
2497 | | - sel.doEditDrag(info); |
---|
| 2512 | + sel.doEditDrag(info, opposite); |
---|
2498 | 2513 | } else |
---|
2499 | 2514 | { |
---|
2500 | 2515 | //super. |
---|
2501 | | - doEditDrag0(info); |
---|
| 2516 | + doEditDrag0(info, opposite); |
---|
2502 | 2517 | } |
---|
2503 | 2518 | } |
---|
2504 | 2519 | break; |
---|
.. | .. |
---|
2905 | 2920 | { |
---|
2906 | 2921 | if (bRep != null) |
---|
2907 | 2922 | { |
---|
2908 | | - bRep.GenUV(); |
---|
| 2923 | + bRep.GenUV(); //1); |
---|
| 2924 | + //bRep.UnfoldUV(); |
---|
2909 | 2925 | Touch(); |
---|
2910 | 2926 | } |
---|
2911 | 2927 | } |
---|
.. | .. |
---|
2980 | 2996 | blockloop = false; |
---|
2981 | 2997 | } |
---|
2982 | 2998 | |
---|
| 2999 | + void TransformChildren() |
---|
| 3000 | + { |
---|
| 3001 | + if (toParent != null) |
---|
| 3002 | + { |
---|
| 3003 | + for (int i=Size(); --i>=0;) |
---|
| 3004 | + { |
---|
| 3005 | + Object3D v = get(i); |
---|
| 3006 | + |
---|
| 3007 | + if (v.toParent == null) |
---|
| 3008 | + { |
---|
| 3009 | + v.toParent = LA.newMatrix(); |
---|
| 3010 | + v.fromParent = LA.newMatrix(); |
---|
| 3011 | + } |
---|
| 3012 | + |
---|
| 3013 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3014 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3015 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3016 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
| 3017 | + } |
---|
| 3018 | + |
---|
| 3019 | + toParent = null; // LA.matIdentity(toParent); |
---|
| 3020 | + fromParent = null; // LA.matIdentity(fromParent); |
---|
| 3021 | + |
---|
| 3022 | + Touch(); |
---|
| 3023 | + } |
---|
| 3024 | + } |
---|
| 3025 | + |
---|
2983 | 3026 | void TransformGeometry() |
---|
2984 | 3027 | { |
---|
2985 | 3028 | Object3D obj = this; |
---|
.. | .. |
---|
3201 | 3244 | |
---|
3202 | 3245 | BoundaryRep sup = bRep.support; |
---|
3203 | 3246 | bRep.support = null; |
---|
3204 | | - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 3247 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3205 | 3248 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3206 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3249 | + |
---|
| 3250 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3251 | + |
---|
3207 | 3252 | bRep = temprep; |
---|
3208 | 3253 | bRep.support = sup; |
---|
3209 | 3254 | Touch(); |
---|
.. | .. |
---|
3725 | 3770 | if (child == null) |
---|
3726 | 3771 | continue; |
---|
3727 | 3772 | |
---|
3728 | | - if (GrafreeD.RENDERME > 0) |
---|
| 3773 | + if (Grafreed.RENDERME > 0) |
---|
3729 | 3774 | { |
---|
3730 | 3775 | if (child instanceof Merge) |
---|
3731 | 3776 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3876 | 3921 | if (child == null) |
---|
3877 | 3922 | continue; |
---|
3878 | 3923 | |
---|
3879 | | - if (GrafreeD.RENDERME > 0) |
---|
| 3924 | + if (Grafreed.RENDERME > 0) |
---|
3880 | 3925 | { |
---|
3881 | 3926 | if (child instanceof Merge) |
---|
3882 | 3927 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4071 | 4116 | if (child == null) |
---|
4072 | 4117 | continue; |
---|
4073 | 4118 | |
---|
4074 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4119 | + if (Grafreed.RENDERME > 0) |
---|
4075 | 4120 | { |
---|
4076 | 4121 | if (child instanceof Merge) |
---|
4077 | 4122 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4678 | 4723 | |
---|
4679 | 4724 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4680 | 4725 | { |
---|
4681 | | - if (hide) |
---|
| 4726 | + if (hide || dontselect) |
---|
4682 | 4727 | return null; |
---|
4683 | 4728 | |
---|
4684 | 4729 | if (count <= 0) |
---|
.. | .. |
---|
4704 | 4749 | |
---|
4705 | 4750 | cTreePath Select(int indexcount, boolean deselect) |
---|
4706 | 4751 | { |
---|
4707 | | - if (hide) |
---|
| 4752 | + if (hide || dontselect) |
---|
4708 | 4753 | return null; |
---|
4709 | 4754 | |
---|
4710 | 4755 | if (count <= 0) |
---|
.. | .. |
---|
4854 | 4899 | return globalTransform; |
---|
4855 | 4900 | } |
---|
4856 | 4901 | |
---|
4857 | | - void PreprocessOcclusion(CameraPane cp) |
---|
| 4902 | + void PreprocessOcclusion(iCameraPane cp) |
---|
4858 | 4903 | { |
---|
4859 | 4904 | /* |
---|
4860 | 4905 | if (AOdone) |
---|
.. | .. |
---|
5156 | 5201 | |
---|
5157 | 5202 | // System.out.println("Fullname = " + fullname); |
---|
5158 | 5203 | |
---|
5159 | | - if (fullname.name.indexOf(":") == -1) |
---|
5160 | | - return fullname.name; |
---|
| 5204 | + // Does not work on Windows due to C: |
---|
| 5205 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5206 | +// return fullname.name; |
---|
| 5207 | +// |
---|
| 5208 | +// return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
5161 | 5209 | |
---|
5162 | | - return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
| 5210 | + String[] split = fullname.name.split(":"); |
---|
| 5211 | + |
---|
| 5212 | + if (split.length == 0) |
---|
| 5213 | + { |
---|
| 5214 | + return ""; |
---|
| 5215 | + } |
---|
| 5216 | + |
---|
| 5217 | + if (split.length <= 2) |
---|
| 5218 | + { |
---|
| 5219 | + if (fullname.name.endsWith(":")) |
---|
| 5220 | + { |
---|
| 5221 | + // Windows |
---|
| 5222 | + return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5223 | + } |
---|
| 5224 | + |
---|
| 5225 | + return split[0]; |
---|
| 5226 | + } |
---|
| 5227 | + |
---|
| 5228 | + // Windows |
---|
| 5229 | + assert(split.length == 4); |
---|
| 5230 | + |
---|
| 5231 | + return split[0] + ":" + split[1]; |
---|
5163 | 5232 | } |
---|
5164 | 5233 | |
---|
5165 | 5234 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5168 | 5237 | return ""; |
---|
5169 | 5238 | |
---|
5170 | 5239 | // System.out.println("Fullname = " + fullname); |
---|
5171 | | - if (fullname.name.indexOf(":") == -1) |
---|
5172 | | - return ""; |
---|
5173 | | - |
---|
5174 | | - return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5240 | + // Does not work on Windows due to C: |
---|
| 5241 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5242 | +// return ""; |
---|
| 5243 | +// |
---|
| 5244 | +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5245 | + String[] split = fullname.name.split(":"); |
---|
| 5246 | + |
---|
| 5247 | + if (split.length == 0) |
---|
| 5248 | + { |
---|
| 5249 | + return ""; |
---|
| 5250 | + } |
---|
| 5251 | + |
---|
| 5252 | + if (split.length == 1) |
---|
| 5253 | + { |
---|
| 5254 | + return ""; |
---|
| 5255 | + } |
---|
| 5256 | + |
---|
| 5257 | + if (split.length == 2) |
---|
| 5258 | + { |
---|
| 5259 | + if (fullname.name.endsWith(":")) |
---|
| 5260 | + { |
---|
| 5261 | + // Windows |
---|
| 5262 | + return ""; |
---|
| 5263 | + } |
---|
| 5264 | + |
---|
| 5265 | + return split[1]; |
---|
| 5266 | + } |
---|
| 5267 | + |
---|
| 5268 | + // Windows |
---|
| 5269 | + assert(split.length == 4); |
---|
| 5270 | + |
---|
| 5271 | + return split[2] + ":" + split[3]; |
---|
5175 | 5272 | } |
---|
5176 | 5273 | |
---|
5177 | 5274 | String GetPigmentTexture() |
---|
.. | .. |
---|
5245 | 5342 | System.out.print("; textures = " + textures); |
---|
5246 | 5343 | System.out.println("; usedtextures = " + usedtextures); |
---|
5247 | 5344 | |
---|
5248 | | - if (GetTextures() == null) |
---|
| 5345 | + if (GetTextures() == null) // What is that?? |
---|
5249 | 5346 | GetTextures().name = ":"; |
---|
5250 | 5347 | |
---|
5251 | 5348 | String texname = tex; |
---|
.. | .. |
---|
5276 | 5373 | child.ResetPigmentTexture(); |
---|
5277 | 5374 | blockloop = false; |
---|
5278 | 5375 | } |
---|
| 5376 | + } |
---|
| 5377 | + |
---|
| 5378 | + UUID GetUUID() |
---|
| 5379 | + { |
---|
| 5380 | + if (uuid == null) |
---|
| 5381 | + { |
---|
| 5382 | + // Serial |
---|
| 5383 | + uuid = UUID.randomUUID(); |
---|
| 5384 | + } |
---|
| 5385 | + |
---|
| 5386 | + return uuid; |
---|
| 5387 | + } |
---|
| 5388 | + |
---|
| 5389 | + Object3D GetObject(UUID uid) |
---|
| 5390 | + { |
---|
| 5391 | + if (blockloop) |
---|
| 5392 | + return null; |
---|
| 5393 | + |
---|
| 5394 | + if (GetUUID().equals(uid)) |
---|
| 5395 | + return this; |
---|
| 5396 | + |
---|
| 5397 | + int nb = Size(); |
---|
| 5398 | + for (int i = 0; i < nb; i++) |
---|
| 5399 | + { |
---|
| 5400 | + Object3D child = (Object3D) get(i); |
---|
| 5401 | + |
---|
| 5402 | + if (child == null) |
---|
| 5403 | + continue; |
---|
| 5404 | + |
---|
| 5405 | + blockloop = true; |
---|
| 5406 | + Object3D obj = child.GetObject(uid); |
---|
| 5407 | + blockloop = false; |
---|
| 5408 | + if (obj != null) |
---|
| 5409 | + return obj; |
---|
| 5410 | + } |
---|
| 5411 | + |
---|
| 5412 | + return null; |
---|
5279 | 5413 | } |
---|
5280 | 5414 | |
---|
5281 | 5415 | void SetBumpTexture(String tex) |
---|
.. | .. |
---|
5322 | 5456 | boolean NeedSupport() |
---|
5323 | 5457 | { |
---|
5324 | 5458 | return |
---|
5325 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5459 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
5326 | 5460 | // PROBLEM with CROWD!! |
---|
5327 | | - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); |
---|
| 5461 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5328 | 5462 | } |
---|
5329 | 5463 | |
---|
| 5464 | + static boolean DEBUG_SELECTION = false; |
---|
5330 | 5465 | |
---|
5331 | 5466 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5332 | 5467 | { |
---|
.. | .. |
---|
5338 | 5473 | } |
---|
5339 | 5474 | |
---|
5340 | 5475 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5341 | | - hide) |
---|
| 5476 | + (hide || dontselect)) |
---|
5342 | 5477 | return; |
---|
5343 | 5478 | |
---|
5344 | 5479 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5365 | 5500 | } |
---|
5366 | 5501 | |
---|
5367 | 5502 | if ((//display.DrawMode() == CameraPane.SHADOW || |
---|
5368 | | - display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency()) |
---|
| 5503 | + display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency()) |
---|
5369 | 5504 | { |
---|
5370 | 5505 | return; |
---|
5371 | 5506 | } |
---|
5372 | 5507 | |
---|
5373 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 5508 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5374 | 5509 | |
---|
5375 | 5510 | /* |
---|
5376 | 5511 | if (touched) |
---|
.. | .. |
---|
5406 | 5541 | |
---|
5407 | 5542 | boolean compiled = false; |
---|
5408 | 5543 | |
---|
5409 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 5544 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5410 | 5545 | |
---|
5411 | 5546 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5412 | 5547 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5422 | 5557 | //if (displaylist == -1 && usecalllists) |
---|
5423 | 5558 | if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
5424 | 5559 | { |
---|
5425 | | - bRep.displaylist = gl.glGenLists(1); |
---|
| 5560 | + bRep.displaylist = display.GenList(); |
---|
5426 | 5561 | assert(bRep.displaylist != 0); |
---|
5427 | 5562 | // System.err.println("glGenLists: " + bRep.displaylist + " for " + this); |
---|
5428 | 5563 | //System.out.println("\tgen list " + list); |
---|
.. | .. |
---|
5434 | 5569 | if (usecalllists) |
---|
5435 | 5570 | { |
---|
5436 | 5571 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5437 | | - gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 5572 | + display.NewList(bRep.displaylist); |
---|
5438 | 5573 | } |
---|
| 5574 | + |
---|
5439 | 5575 | CallList(display, root, selected, blocked); |
---|
| 5576 | + |
---|
5440 | 5577 | // compiled = true; |
---|
5441 | 5578 | if (usecalllists) |
---|
5442 | 5579 | { |
---|
5443 | 5580 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5444 | | - gl.glEndList(); |
---|
| 5581 | + display.EndList(); |
---|
5445 | 5582 | } |
---|
5446 | 5583 | //gl.glDrawBuffer(gl.GL_BACK); |
---|
5447 | 5584 | // XXX touched = false; |
---|
.. | .. |
---|
5484 | 5621 | |
---|
5485 | 5622 | // frustum culling |
---|
5486 | 5623 | if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid |
---|
5487 | | - && display.DrawMode() != CameraPane.SELECTION) |
---|
| 5624 | + && display.DrawMode() != iCameraPane.SELECTION) |
---|
5488 | 5625 | { |
---|
5489 | | - if (display.DrawMode() == CameraPane.SHADOW) |
---|
| 5626 | + if (display.DrawMode() == iCameraPane.SHADOW) |
---|
5490 | 5627 | { |
---|
5491 | 5628 | if (!link2master // tricky to cull in shadow mode. |
---|
5492 | | - && GetBRep().FrustumCull(this, gl, display.LightCamera(), true)) |
---|
| 5629 | + && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
5493 | 5630 | { |
---|
5494 | 5631 | //System.out.print("CULLED"); |
---|
5495 | 5632 | culled = true; |
---|
.. | .. |
---|
5497 | 5634 | } |
---|
5498 | 5635 | else |
---|
5499 | 5636 | //GetBRep().getBounds(v0, v1, this); |
---|
5500 | | - if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false)) |
---|
| 5637 | + if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false)) |
---|
5501 | 5638 | culled = true; |
---|
5502 | 5639 | |
---|
5503 | 5640 | // LA.xformPos(v0, display.renderCamera.toScreen, v0); |
---|
.. | .. |
---|
5533 | 5670 | |
---|
5534 | 5671 | |
---|
5535 | 5672 | if (!culled) |
---|
5536 | | - if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION) |
---|
| 5673 | + if (display.DrawMode() == display.SELECTION || display.IsDebugSelection()) |
---|
5537 | 5674 | { |
---|
5538 | 5675 | if (GetBRep() != null) |
---|
5539 | 5676 | { |
---|
5540 | | - CameraPane.NextIndex(this, gl); |
---|
| 5677 | + display.NextIndex(); |
---|
5541 | 5678 | // vertex color conflict : gl.glCallList(list); |
---|
5542 | 5679 | DrawNode(display, root, selected); |
---|
5543 | 5680 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5578 | 5715 | tex = GetTextures(); |
---|
5579 | 5716 | } |
---|
5580 | 5717 | |
---|
5581 | | - display.BindTextures(tex, texres); |
---|
| 5718 | + boolean failed = false; |
---|
| 5719 | + |
---|
| 5720 | + try |
---|
| 5721 | + { |
---|
| 5722 | + display.BindTextures(tex, texres); |
---|
| 5723 | + } |
---|
| 5724 | + catch (Exception e) |
---|
| 5725 | + { |
---|
| 5726 | + System.err.println("FAILED: " + this); |
---|
| 5727 | + failed = true; |
---|
| 5728 | + } |
---|
5582 | 5729 | |
---|
5583 | 5730 | if (!compiled) |
---|
5584 | 5731 | { |
---|
.. | .. |
---|
5594 | 5741 | |
---|
5595 | 5742 | // System.err.println("glCallList: " + bRep.displaylist + " for " + this); |
---|
5596 | 5743 | assert(bRep.displaylist != 0); |
---|
5597 | | - gl.glCallList(bRep.displaylist); |
---|
| 5744 | + display.CallList(bRep.displaylist); |
---|
5598 | 5745 | // june 2013 drawSelf(display, root, selected); |
---|
5599 | 5746 | } |
---|
5600 | 5747 | } |
---|
5601 | 5748 | } |
---|
5602 | 5749 | |
---|
5603 | | - display.ReleaseTextures(tex); |
---|
| 5750 | + if (!failed) |
---|
| 5751 | + display.ReleaseTextures(tex); |
---|
5604 | 5752 | |
---|
5605 | 5753 | display.PopMaterial(this, selected); |
---|
5606 | 5754 | } |
---|
.. | .. |
---|
5729 | 5877 | |
---|
5730 | 5878 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5731 | 5879 | { |
---|
| 5880 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 5881 | + return; |
---|
| 5882 | + |
---|
5732 | 5883 | if (hide) |
---|
5733 | 5884 | return; |
---|
5734 | 5885 | // shadow optimisation |
---|
.. | .. |
---|
5854 | 6005 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5855 | 6006 | return; // no shadow for transparent objects |
---|
5856 | 6007 | |
---|
| 6008 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6009 | + return; |
---|
| 6010 | + |
---|
5857 | 6011 | if (hide) |
---|
5858 | 6012 | return; |
---|
5859 | 6013 | |
---|
.. | .. |
---|
5894 | 6048 | return; |
---|
5895 | 6049 | } |
---|
5896 | 6050 | |
---|
| 6051 | + //bRep.GenUV(1/material.diffuseness); |
---|
5897 | 6052 | // bRep.lock = true; |
---|
5898 | 6053 | |
---|
5899 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 6054 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5900 | 6055 | |
---|
5901 | 6056 | if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
5902 | 6057 | { |
---|
.. | .. |
---|
5913 | 6068 | |
---|
5914 | 6069 | bRep.getMinMax(min, max, 100); |
---|
5915 | 6070 | |
---|
5916 | | - gl.glBegin(gl.GL_LINES); |
---|
5917 | | - |
---|
5918 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5919 | | - gl.glVertex3d(min.x, min.y, max.z); |
---|
5920 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5921 | | - gl.glVertex3d(min.x, max.y, min.z); |
---|
5922 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5923 | | - gl.glVertex3d(max.x, min.y, min.z); |
---|
5924 | | - |
---|
5925 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5926 | | - gl.glVertex3d(min.x, max.y, max.z); |
---|
5927 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5928 | | - gl.glVertex3d(max.x, min.y, max.z); |
---|
5929 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5930 | | - gl.glVertex3d(max.x, max.y, min.z); |
---|
5931 | | - |
---|
5932 | | - gl.glEnd(); |
---|
| 6071 | + display.DrawBox(min, max); |
---|
5933 | 6072 | |
---|
5934 | 6073 | return; |
---|
5935 | 6074 | } |
---|
.. | .. |
---|
5973 | 6112 | { |
---|
5974 | 6113 | //throw new Error(); |
---|
5975 | 6114 | |
---|
5976 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 6115 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5977 | 6116 | |
---|
5978 | 6117 | int[] strips = bRep.getRawIndices(); |
---|
5979 | 6118 | |
---|
.. | .. |
---|
5983 | 6122 | new Exception().printStackTrace(); |
---|
5984 | 6123 | return; |
---|
5985 | 6124 | } |
---|
5986 | | - |
---|
5987 | | - // TRIANGLE STRIP ARRAY |
---|
5988 | | - if (bRep.trimmed) |
---|
5989 | | - { |
---|
5990 | | - float[] v = bRep.getRawVertices(); |
---|
5991 | | - float[] n = bRep.getRawNormals(); |
---|
5992 | | - float[] c = bRep.getRawColors(); |
---|
5993 | | - float[] uv = bRep.getRawUVMap(); |
---|
5994 | | - |
---|
5995 | | - int count2 = 0; |
---|
5996 | | - int count3 = 0; |
---|
5997 | | - |
---|
5998 | | - if (n.length > 0) |
---|
5999 | | - { |
---|
6000 | | - for (int i = 0; i < strips.length; i++) |
---|
6001 | | - { |
---|
6002 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6003 | | - |
---|
6004 | | - /* |
---|
6005 | | - boolean locked = false; |
---|
6006 | | - float eps = 0.1f; |
---|
6007 | | - boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
6008 | | - |
---|
6009 | | - int dot = 0; |
---|
6010 | | - |
---|
6011 | | - if ((dot&1) == 0) |
---|
6012 | | - dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
6013 | | - |
---|
6014 | | - if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
6015 | | - gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
6016 | | - else |
---|
6017 | | - { |
---|
6018 | | - locked = true; |
---|
6019 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6020 | | - } |
---|
6021 | | - //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
6022 | | - gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
6023 | | - if (hasnorm) |
---|
6024 | | - { |
---|
6025 | | - //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
6026 | | - gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
6027 | | - } |
---|
6028 | | - |
---|
6029 | | - if ((dot&4) == 0) |
---|
6030 | | - dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
6031 | | - |
---|
6032 | | - if (wrap || !locked && (dot&8) != 0) |
---|
6033 | | - gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
6034 | | - else |
---|
6035 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6036 | | - |
---|
6037 | | - f.dot = dot; |
---|
6038 | | - */ |
---|
6039 | | - |
---|
6040 | | - if (!selectmode) |
---|
6041 | | - { |
---|
6042 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6043 | | - { |
---|
6044 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6045 | | - } else |
---|
6046 | | - { |
---|
6047 | | - gl.glNormal3f(0, 0, 1); |
---|
6048 | | - } |
---|
6049 | | - |
---|
6050 | | - if (c != null) |
---|
6051 | | - //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
6052 | | - { |
---|
6053 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6054 | | - } |
---|
6055 | | - } |
---|
6056 | | - if (flipV) |
---|
6057 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6058 | | - else |
---|
6059 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6060 | | - //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6061 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6062 | | - |
---|
6063 | | - count2 += 2; |
---|
6064 | | - count3 += 3; |
---|
6065 | | - if (!selectmode) |
---|
6066 | | - { |
---|
6067 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6068 | | - { |
---|
6069 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6070 | | - } else |
---|
6071 | | - { |
---|
6072 | | - gl.glNormal3f(0, 0, 1); |
---|
6073 | | - } |
---|
6074 | | - if (c != null) |
---|
6075 | | - { |
---|
6076 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6077 | | - } |
---|
6078 | | - } |
---|
6079 | | - if (flipV) |
---|
6080 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6081 | | - else |
---|
6082 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6083 | | - //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6084 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6085 | | - |
---|
6086 | | - count2 += 2; |
---|
6087 | | - count3 += 3; |
---|
6088 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6089 | | - { |
---|
6090 | | - //gl.glTexCoord2d(...); |
---|
6091 | | - if (!selectmode) |
---|
6092 | | - { |
---|
6093 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6094 | | - { |
---|
6095 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6096 | | - } else |
---|
6097 | | - { |
---|
6098 | | - gl.glNormal3f(0, 0, 1); |
---|
6099 | | - } |
---|
6100 | | - if (c != null) |
---|
6101 | | - { |
---|
6102 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6103 | | - } |
---|
6104 | | - } |
---|
6105 | | - |
---|
6106 | | - if (flipV) |
---|
6107 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6108 | | - else |
---|
6109 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6110 | | - //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
6111 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6112 | | - count2 += 2; |
---|
6113 | | - count3 += 3; |
---|
6114 | | - } |
---|
6115 | | - |
---|
6116 | | - gl.glEnd(); |
---|
6117 | | - } |
---|
6118 | | - } |
---|
6119 | | - |
---|
6120 | | - assert count3 == v.length; |
---|
6121 | | - } |
---|
6122 | | - else // !trimmed |
---|
6123 | | - { |
---|
6124 | | - int count = 0; |
---|
6125 | | - for (int i = 0; i < strips.length; i++) |
---|
6126 | | - { |
---|
6127 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6128 | | - |
---|
6129 | | - Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
6130 | | - Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
6131 | | - |
---|
6132 | | - drawVertex(gl, p, selectmode); |
---|
6133 | | - drawVertex(gl, q, selectmode); |
---|
6134 | | - |
---|
6135 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6136 | | - { |
---|
6137 | | - Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
6138 | | - |
---|
6139 | | -// if (j%2 == 0) |
---|
6140 | | -// drawFace(p, q, r, display, null); |
---|
6141 | | -// else |
---|
6142 | | -// drawFace(p, r, q, display, null); |
---|
6143 | | - |
---|
6144 | | -// p = q; |
---|
6145 | | -// q = r; |
---|
6146 | | - drawVertex(gl, r, selectmode); |
---|
6147 | | - } |
---|
6148 | | - |
---|
6149 | | - gl.glEnd(); |
---|
6150 | | - } |
---|
6151 | | - } |
---|
| 6125 | + |
---|
| 6126 | + display.DrawGeometry(bRep, flipV, selectmode); |
---|
6152 | 6127 | } else // catch (Error e) |
---|
6153 | 6128 | { |
---|
6154 | 6129 | // TRIANGLE ARRAY |
---|
6155 | 6130 | if (IsOpaque()) // Static()) |
---|
6156 | 6131 | { |
---|
6157 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6132 | + display.StartTriangles(); |
---|
6158 | 6133 | int facecount = bRep.FaceCount(); |
---|
6159 | 6134 | for (int i = 0; i < facecount; i++) |
---|
6160 | 6135 | { |
---|
.. | .. |
---|
6219 | 6194 | |
---|
6220 | 6195 | display.DrawFace(this, p, q, r, face); |
---|
6221 | 6196 | } |
---|
6222 | | - gl.glEnd(); |
---|
| 6197 | + display.EndTriangles(); |
---|
6223 | 6198 | } |
---|
6224 | 6199 | else |
---|
6225 | 6200 | { |
---|
.. | .. |
---|
6248 | 6223 | //System.out.println("SORT"); |
---|
6249 | 6224 | |
---|
6250 | 6225 | java.util.Arrays.sort(facescompare); |
---|
6251 | | - |
---|
6252 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6226 | + |
---|
| 6227 | + display.StartTriangles(); |
---|
6253 | 6228 | for (int i = 0; i < facecount; i++) |
---|
6254 | 6229 | { |
---|
6255 | 6230 | Face face = bRep.GetFace(facescompare[i].index); |
---|
.. | .. |
---|
6263 | 6238 | |
---|
6264 | 6239 | display.DrawFace(this, p, q, r, face); |
---|
6265 | 6240 | } |
---|
6266 | | - gl.glEnd(); |
---|
| 6241 | + display.EndTriangles(); |
---|
6267 | 6242 | } |
---|
6268 | 6243 | |
---|
6269 | 6244 | if (false) // live && support != null && support.bRep != null) // debug weights |
---|
6270 | 6245 | { |
---|
| 6246 | + /* |
---|
6271 | 6247 | gl.glDisable(gl.GL_LIGHTING); |
---|
6272 | 6248 | float[] colorV = new float[3]; |
---|
6273 | 6249 | |
---|
.. | .. |
---|
6346 | 6322 | // gl.glEnd(); |
---|
6347 | 6323 | } |
---|
6348 | 6324 | } |
---|
| 6325 | + */ |
---|
6349 | 6326 | } |
---|
6350 | 6327 | } |
---|
6351 | 6328 | |
---|
.. | .. |
---|
6390 | 6367 | center.add(r); |
---|
6391 | 6368 | center.mul(1.0/3); |
---|
6392 | 6369 | |
---|
6393 | | - center.sub(CameraPane.theRenderer.eyeCamera.location); |
---|
| 6370 | + center.sub(Globals.theRenderer.EyeCamera().location); |
---|
6394 | 6371 | |
---|
6395 | 6372 | distance = center.dot(center); |
---|
6396 | 6373 | } |
---|
.. | .. |
---|
6404 | 6381 | void Print(Vertex v) |
---|
6405 | 6382 | { |
---|
6406 | 6383 | //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")"); |
---|
6407 | | - } |
---|
6408 | | - |
---|
6409 | | - void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode) |
---|
6410 | | - { |
---|
6411 | | - if (!selectmode) |
---|
6412 | | - { |
---|
6413 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
6414 | | - gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
6415 | | - |
---|
6416 | | - if (flipV) |
---|
6417 | | - gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
6418 | | - else |
---|
6419 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6420 | | - } |
---|
6421 | | - |
---|
6422 | | - gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
6423 | 6384 | } |
---|
6424 | 6385 | |
---|
6425 | 6386 | void drawSelf(ClickInfo info, int level, boolean select) |
---|
.. | .. |
---|
6993 | 6954 | int spotw = spot.x + spot.width; |
---|
6994 | 6955 | int spoth = spot.y + spot.height; |
---|
6995 | 6956 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6996 | | - if (CameraPane.Xmin > spot.x) |
---|
6997 | | - { |
---|
6998 | | - CameraPane.Xmin = spot.x; |
---|
6999 | | - } |
---|
7000 | | - if (CameraPane.Xmax < spotw) |
---|
7001 | | - { |
---|
7002 | | - CameraPane.Xmax = spotw; |
---|
7003 | | - } |
---|
7004 | | - if (CameraPane.Ymin > spot.y) |
---|
7005 | | - { |
---|
7006 | | - CameraPane.Ymin = spot.y; |
---|
7007 | | - } |
---|
7008 | | - if (CameraPane.Ymax < spoth) |
---|
7009 | | - { |
---|
7010 | | - CameraPane.Ymax = spoth; |
---|
7011 | | - } |
---|
| 6957 | +// if (CameraPane.Xmin > spot.x) |
---|
| 6958 | +// { |
---|
| 6959 | +// CameraPane.Xmin = spot.x; |
---|
| 6960 | +// } |
---|
| 6961 | +// if (CameraPane.Xmax < spotw) |
---|
| 6962 | +// { |
---|
| 6963 | +// CameraPane.Xmax = spotw; |
---|
| 6964 | +// } |
---|
| 6965 | +// if (CameraPane.Ymin > spot.y) |
---|
| 6966 | +// { |
---|
| 6967 | +// CameraPane.Ymin = spot.y; |
---|
| 6968 | +// } |
---|
| 6969 | +// if (CameraPane.Ymax < spoth) |
---|
| 6970 | +// { |
---|
| 6971 | +// CameraPane.Ymax = spoth; |
---|
| 6972 | +// } |
---|
7012 | 6973 | spot.translate(32, 32); |
---|
7013 | 6974 | spotw = spot.x + spot.width; |
---|
7014 | 6975 | spoth = spot.y + spot.height; |
---|
7015 | 6976 | info.g.setColor(Color.blue); |
---|
7016 | 6977 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7017 | | - if (CameraPane.Xmin > spot.x) |
---|
7018 | | - { |
---|
7019 | | - CameraPane.Xmin = spot.x; |
---|
7020 | | - } |
---|
7021 | | - if (CameraPane.Xmax < spotw) |
---|
7022 | | - { |
---|
7023 | | - CameraPane.Xmax = spotw; |
---|
7024 | | - } |
---|
7025 | | - if (CameraPane.Ymin > spot.y) |
---|
7026 | | - { |
---|
7027 | | - CameraPane.Ymin = spot.y; |
---|
7028 | | - } |
---|
7029 | | - if (CameraPane.Ymax < spoth) |
---|
7030 | | - { |
---|
7031 | | - CameraPane.Ymax = spoth; |
---|
7032 | | - } |
---|
7033 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
7034 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 6978 | +// if (CameraPane.Xmin > spot.x) |
---|
| 6979 | +// { |
---|
| 6980 | +// CameraPane.Xmin = spot.x; |
---|
| 6981 | +// } |
---|
| 6982 | +// if (CameraPane.Xmax < spotw) |
---|
| 6983 | +// { |
---|
| 6984 | +// CameraPane.Xmax = spotw; |
---|
| 6985 | +// } |
---|
| 6986 | +// if (CameraPane.Ymin > spot.y) |
---|
| 6987 | +// { |
---|
| 6988 | +// CameraPane.Ymin = spot.y; |
---|
| 6989 | +// } |
---|
| 6990 | +// if (CameraPane.Ymax < spoth) |
---|
| 6991 | +// { |
---|
| 6992 | +// CameraPane.Ymax = spoth; |
---|
| 6993 | +// } |
---|
| 6994 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
| 6995 | + //info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
7035 | 6996 | spot.translate(0, -32); |
---|
7036 | 6997 | info.g.setColor(Color.green); |
---|
7037 | 6998 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
7038 | | - if (CameraPane.Xmin > spot.x) |
---|
7039 | | - { |
---|
7040 | | - CameraPane.Xmin = spot.x; |
---|
7041 | | - } |
---|
7042 | | - if (CameraPane.Xmax < spotw) |
---|
7043 | | - { |
---|
7044 | | - CameraPane.Xmax = spotw; |
---|
7045 | | - } |
---|
7046 | | - if (CameraPane.Ymin > spot.y) |
---|
7047 | | - { |
---|
7048 | | - CameraPane.Ymin = spot.y; |
---|
7049 | | - } |
---|
7050 | | - if (CameraPane.Ymax < spoth) |
---|
7051 | | - { |
---|
7052 | | - CameraPane.Ymax = spoth; |
---|
7053 | | - } |
---|
| 6999 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7000 | +// { |
---|
| 7001 | +// CameraPane.Xmin = spot.x; |
---|
| 7002 | +// } |
---|
| 7003 | +// if (CameraPane.Xmax < spotw) |
---|
| 7004 | +// { |
---|
| 7005 | +// CameraPane.Xmax = spotw; |
---|
| 7006 | +// } |
---|
| 7007 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7008 | +// { |
---|
| 7009 | +// CameraPane.Ymin = spot.y; |
---|
| 7010 | +// } |
---|
| 7011 | +// if (CameraPane.Ymax < spoth) |
---|
| 7012 | +// { |
---|
| 7013 | +// CameraPane.Ymax = spoth; |
---|
| 7014 | +// } |
---|
7054 | 7015 | info.g.drawArc(boundary.x, boundary.y, |
---|
7055 | 7016 | boundary.width, boundary.height, 0, 360); |
---|
7056 | 7017 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
7057 | | - if (CameraPane.Xmin > boundary.x) |
---|
7058 | | - { |
---|
7059 | | - CameraPane.Xmin = boundary.x; |
---|
7060 | | - } |
---|
7061 | | - if (CameraPane.Xmax < boundary.x + boundary.width) |
---|
7062 | | - { |
---|
7063 | | - CameraPane.Xmax = boundary.x + boundary.width; |
---|
7064 | | - } |
---|
7065 | | - if (CameraPane.Ymin > boundary.y) |
---|
7066 | | - { |
---|
7067 | | - CameraPane.Ymin = boundary.y; |
---|
7068 | | - } |
---|
7069 | | - if (CameraPane.Ymax < boundary.y + boundary.height) |
---|
7070 | | - { |
---|
7071 | | - CameraPane.Ymax = boundary.y + boundary.height; |
---|
7072 | | - } |
---|
| 7018 | +// if (CameraPane.Xmin > boundary.x) |
---|
| 7019 | +// { |
---|
| 7020 | +// CameraPane.Xmin = boundary.x; |
---|
| 7021 | +// } |
---|
| 7022 | +// if (CameraPane.Xmax < boundary.x + boundary.width) |
---|
| 7023 | +// { |
---|
| 7024 | +// CameraPane.Xmax = boundary.x + boundary.width; |
---|
| 7025 | +// } |
---|
| 7026 | +// if (CameraPane.Ymin > boundary.y) |
---|
| 7027 | +// { |
---|
| 7028 | +// CameraPane.Ymin = boundary.y; |
---|
| 7029 | +// } |
---|
| 7030 | +// if (CameraPane.Ymax < boundary.y + boundary.height) |
---|
| 7031 | +// { |
---|
| 7032 | +// CameraPane.Ymax = boundary.y + boundary.height; |
---|
| 7033 | +// } |
---|
7073 | 7034 | return; |
---|
7074 | 7035 | } |
---|
7075 | 7036 | } |
---|
.. | .. |
---|
7086 | 7047 | startX = info.x; |
---|
7087 | 7048 | startY = info.y; |
---|
7088 | 7049 | |
---|
7089 | | - hitSomething = 0; |
---|
| 7050 | + hitSomething = -1; |
---|
7090 | 7051 | cVector origin = new cVector(); |
---|
7091 | 7052 | //LA.xformPos(origin, toParent, origin); |
---|
7092 | 7053 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7119 | 7080 | } |
---|
7120 | 7081 | |
---|
7121 | 7082 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7122 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7083 | + modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7123 | 7084 | //System.out.println("modified = " + modified); |
---|
7124 | 7085 | //new Exception().printStackTrace(); |
---|
7125 | 7086 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7147 | 7108 | return true; |
---|
7148 | 7109 | } |
---|
7149 | 7110 | |
---|
7150 | | - void doEditDrag0(ClickInfo info) |
---|
| 7111 | + void doEditDrag0(ClickInfo info, boolean opposite) |
---|
7151 | 7112 | { |
---|
7152 | 7113 | if (hitSomething == 0) |
---|
7153 | 7114 | { |
---|
.. | .. |
---|
7162 | 7123 | //System.out.println("hitSomething = " + hitSomething); |
---|
7163 | 7124 | |
---|
7164 | 7125 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7126 | + |
---|
7165 | 7127 | cVector xlate = new cVector(); |
---|
7166 | 7128 | //cVector xlate2 = new cVector(); |
---|
7167 | 7129 | switch (hitSomething) |
---|
.. | .. |
---|
7172 | 7134 | |
---|
7173 | 7135 | case hitCenter: // Translate |
---|
7174 | 7136 | |
---|
7175 | | - scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance(); |
---|
| 7137 | + scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7176 | 7138 | |
---|
7177 | | - if (modified) |
---|
| 7139 | + if (modified || opposite) |
---|
7178 | 7140 | { |
---|
7179 | 7141 | //assert(false); |
---|
7180 | 7142 | /* |
---|
.. | .. |
---|
7220 | 7182 | } |
---|
7221 | 7183 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7222 | 7184 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7223 | | - LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up); |
---|
| 7185 | + LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7224 | 7186 | LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
7225 | 7187 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7226 | | - LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away); |
---|
| 7188 | + LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7227 | 7189 | //LA.vecCross(up, cVector.Z, right2); |
---|
7228 | 7190 | |
---|
7229 | 7191 | cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
.. | .. |
---|
7268 | 7230 | |
---|
7269 | 7231 | if (modified) |
---|
7270 | 7232 | { |
---|
| 7233 | + // Rotate 90 degrees |
---|
7271 | 7234 | angle /= (Math.PI / 4); |
---|
7272 | 7235 | angle = Math.floor(angle + 0.5); |
---|
7273 | 7236 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7281 | 7244 | } |
---|
7282 | 7245 | /**/ |
---|
7283 | 7246 | |
---|
7284 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7247 | + switch (info.pane.RenderCamera().viewCode) |
---|
7285 | 7248 | { |
---|
7286 | 7249 | case 1: // '\001' |
---|
7287 | 7250 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7309 | 7272 | |
---|
7310 | 7273 | case hitScale: // scale |
---|
7311 | 7274 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7275 | + double sign = 1; |
---|
| 7276 | + if (hScale < 0) |
---|
| 7277 | + { |
---|
| 7278 | + sign = -1; |
---|
| 7279 | + } |
---|
| 7280 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7312 | 7281 | if (hScale < 0.01) |
---|
7313 | 7282 | { |
---|
7314 | | - hScale = 0.01; |
---|
| 7283 | + //hScale = 0.01; |
---|
7315 | 7284 | } |
---|
7316 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7317 | | - if (hScale < 0.01) |
---|
7318 | | - { |
---|
7319 | | - hScale = 0.01; |
---|
7320 | | - } |
---|
| 7285 | + |
---|
7321 | 7286 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7322 | | - if (vScale < 0.01) |
---|
| 7287 | + sign = 1; |
---|
| 7288 | + if (vScale < 0) |
---|
7323 | 7289 | { |
---|
7324 | | - vScale = 0.01; |
---|
| 7290 | + sign = -1; |
---|
7325 | 7291 | } |
---|
7326 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7292 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7327 | 7293 | if (vScale < 0.01) |
---|
7328 | 7294 | { |
---|
7329 | | - vScale = 0.01; |
---|
| 7295 | + //vScale = 0.01; |
---|
7330 | 7296 | } |
---|
7331 | 7297 | LA.matCopy(startMat, toParent); |
---|
7332 | 7298 | /**/ |
---|
.. | .. |
---|
7337 | 7303 | } |
---|
7338 | 7304 | /**/ |
---|
7339 | 7305 | |
---|
7340 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7306 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7307 | + |
---|
| 7308 | + if (totalScale < 0.01) |
---|
| 7309 | + { |
---|
| 7310 | + totalScale = 0.01; |
---|
| 7311 | + } |
---|
| 7312 | + |
---|
| 7313 | + switch (info.pane.RenderCamera().viewCode) |
---|
7341 | 7314 | { |
---|
7342 | 7315 | case 3: // '\001' |
---|
7343 | 7316 | if (modified) |
---|
7344 | 7317 | { |
---|
7345 | 7318 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7346 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7319 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7347 | 7320 | } // vScale, 1); |
---|
7348 | 7321 | else |
---|
7349 | 7322 | { |
---|
7350 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7323 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7351 | 7324 | } // vScale, 1); |
---|
7352 | 7325 | break; |
---|
7353 | 7326 | |
---|
.. | .. |
---|
7355 | 7328 | if (modified) |
---|
7356 | 7329 | { |
---|
7357 | 7330 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7358 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7331 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7359 | 7332 | } else |
---|
7360 | 7333 | { |
---|
7361 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7334 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7362 | 7335 | } |
---|
7363 | 7336 | break; |
---|
7364 | 7337 | |
---|
.. | .. |
---|
7366 | 7339 | if (modified) |
---|
7367 | 7340 | { |
---|
7368 | 7341 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7369 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7342 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7370 | 7343 | } else |
---|
7371 | 7344 | { |
---|
7372 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7345 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7373 | 7346 | } |
---|
7374 | 7347 | break; |
---|
7375 | 7348 | } |
---|
.. | .. |
---|
7502 | 7475 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7503 | 7476 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7504 | 7477 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7478 | + |
---|
| 7479 | + String objname; |
---|
| 7480 | + |
---|
7505 | 7481 | if (false) //parent != null) |
---|
7506 | 7482 | { |
---|
7507 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7483 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7508 | 7484 | } else |
---|
7509 | 7485 | { |
---|
7510 | | - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); |
---|
| 7486 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7511 | 7487 | } // + super.toString(); |
---|
7512 | 7488 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
| 7489 | + |
---|
| 7490 | + if (!Globals.ADVANCED) |
---|
| 7491 | + return objname; |
---|
| 7492 | + |
---|
| 7493 | + return objname + " " + System.identityHashCode(this); |
---|
7513 | 7494 | } |
---|
7514 | 7495 | |
---|
7515 | 7496 | public int hashCode() |
---|
.. | .. |
---|
7565 | 7546 | objectUI.closeUI(); |
---|
7566 | 7547 | if (editWindow != null) |
---|
7567 | 7548 | { |
---|
| 7549 | + editWindow.ctrlPanel.FlushUI(); |
---|
7568 | 7550 | editWindow.refreshContents(); |
---|
7569 | 7551 | } // ? new |
---|
7570 | 7552 | objectUI = null; |
---|
.. | .. |
---|
7700 | 7682 | { |
---|
7701 | 7683 | assert(bRep != null); |
---|
7702 | 7684 | if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
7703 | | - GrafreeD.Assert(support.bRep == bRep.support); |
---|
| 7685 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
7704 | 7686 | } |
---|
7705 | 7687 | else |
---|
7706 | 7688 | { |
---|
.. | .. |
---|
7749 | 7731 | private static cVector edge2 = new cVector(); |
---|
7750 | 7732 | //private static cVector norm = new cVector(); |
---|
7751 | 7733 | /*transient private*/ int hitSomething; |
---|
7752 | | - private static final int hitCenter = 1; |
---|
7753 | | - private static final int hitScale = 2; |
---|
7754 | | - private static final int hitRotate = 3; |
---|
| 7734 | + static final int hitCenter = 1; |
---|
| 7735 | + static final int hitScale = 2; |
---|
| 7736 | + static final int hitRotate = 3; |
---|
7755 | 7737 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7756 | 7738 | /*transient*/ private Point centerPt; |
---|
7757 | 7739 | /*transient*/ private int startX; |
---|