.. | .. |
---|
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(); |
---|
| 26 | + |
---|
| 27 | + // TEMPORARY for mocap undo |
---|
| 28 | + mocap.reader.BVHReader.BVHResult bvh; |
---|
| 29 | + Object3D skeleton; |
---|
| 30 | + // |
---|
21 | 31 | |
---|
22 | 32 | ScriptNode scriptnode; |
---|
23 | 33 | |
---|
.. | .. |
---|
99 | 109 | |
---|
100 | 110 | // transient boolean reduced; // for morph reduction |
---|
101 | 111 | |
---|
102 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
| 112 | + transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
| 113 | + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
104 | 114 | |
---|
105 | | -transient Object3D transientsupport; // for cloning |
---|
106 | | -transient boolean transientlink2master; |
---|
| 115 | + transient Object3D transientsupport; // for cloning |
---|
| 116 | + transient boolean transientlink2master; |
---|
107 | 117 | |
---|
108 | | -void SaveSupports() |
---|
109 | | -{ |
---|
110 | | - if (blockloop) |
---|
111 | | - return; |
---|
112 | | - |
---|
113 | | - transientsupport = support; |
---|
114 | | - transientlink2master = link2master; |
---|
115 | | - |
---|
116 | | - support = null; |
---|
117 | | - link2master = false; |
---|
118 | | - |
---|
119 | | - if (bRep != null) |
---|
| 118 | + void SaveSupports() |
---|
120 | 119 | { |
---|
121 | | - bRep.SaveSupports(); |
---|
122 | | - } |
---|
123 | | - |
---|
124 | | - for (int i = 0; i < Size(); i++) |
---|
125 | | - { |
---|
126 | | - Object3D child = (Object3D) get(i); |
---|
127 | | - if (child == null) |
---|
128 | | - continue; |
---|
129 | | - blockloop = true; |
---|
130 | | - child.SaveSupports(); |
---|
131 | | - blockloop = false; |
---|
132 | | - } |
---|
133 | | -} |
---|
| 120 | + if (blockloop) |
---|
| 121 | + return; |
---|
134 | 122 | |
---|
135 | | -void RestoreSupports() |
---|
136 | | -{ |
---|
137 | | - if (blockloop) |
---|
138 | | - return; |
---|
| 123 | + transientsupport = support; |
---|
| 124 | + transientlink2master = link2master; |
---|
139 | 125 | |
---|
140 | | - support = transientsupport; |
---|
141 | | - link2master = transientlink2master; |
---|
142 | | - transientsupport = null; |
---|
143 | | - transientlink2master = false; |
---|
144 | | - |
---|
145 | | - if (bRep != null) |
---|
146 | | - { |
---|
147 | | - bRep.RestoreSupports(); |
---|
| 126 | + support = null; |
---|
| 127 | + link2master = false; |
---|
| 128 | + |
---|
| 129 | + if (bRep != null) |
---|
| 130 | + { |
---|
| 131 | + bRep.SaveSupports(); |
---|
| 132 | + } |
---|
| 133 | + |
---|
| 134 | + for (int i = 0; i < Size(); i++) |
---|
| 135 | + { |
---|
| 136 | + Object3D child = (Object3D) get(i); |
---|
| 137 | + if (child == null) |
---|
| 138 | + continue; |
---|
| 139 | + blockloop = true; |
---|
| 140 | + child.SaveSupports(); |
---|
| 141 | + blockloop = false; |
---|
| 142 | + } |
---|
148 | 143 | } |
---|
149 | | - |
---|
150 | | - for (int i = 0; i < Size(); i++) |
---|
| 144 | + |
---|
| 145 | + void RestoreSupports() |
---|
151 | 146 | { |
---|
152 | | - Object3D child = (Object3D) get(i); |
---|
153 | | - if (child == null) |
---|
154 | | - continue; |
---|
155 | | - blockloop = true; |
---|
156 | | - child.RestoreSupports(); |
---|
157 | | - blockloop = false; |
---|
| 147 | + if (blockloop) |
---|
| 148 | + return; |
---|
| 149 | + |
---|
| 150 | + support = transientsupport; |
---|
| 151 | + link2master = transientlink2master; |
---|
| 152 | + transientsupport = null; |
---|
| 153 | + transientlink2master = false; |
---|
| 154 | + |
---|
| 155 | + if (bRep != null) |
---|
| 156 | + { |
---|
| 157 | + bRep.RestoreSupports(); |
---|
| 158 | + } |
---|
| 159 | + |
---|
| 160 | + for (int i = 0; i < Size(); i++) |
---|
| 161 | + { |
---|
| 162 | + Object3D child = (Object3D) get(i); |
---|
| 163 | + if (child == null) |
---|
| 164 | + continue; |
---|
| 165 | + blockloop = true; |
---|
| 166 | + child.RestoreSupports(); |
---|
| 167 | + blockloop = false; |
---|
| 168 | + } |
---|
158 | 169 | } |
---|
159 | | -} |
---|
| 170 | + |
---|
| 171 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 172 | + { |
---|
| 173 | + if (hashtable.containsKey(GetUUID())) |
---|
| 174 | + { |
---|
| 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); |
---|
| 191 | + } |
---|
| 192 | + |
---|
| 193 | + ExtractBigData(o); |
---|
| 194 | + } |
---|
| 195 | + |
---|
| 196 | + void ExtractBigData(Object3D o) |
---|
| 197 | + { |
---|
| 198 | + o.bRep = this.bRep; |
---|
| 199 | + if (this.bRep != null) |
---|
| 200 | + { |
---|
| 201 | + o.transientrep = this.bRep.support; |
---|
| 202 | + o.bRep.support = null; |
---|
| 203 | + } |
---|
| 204 | + |
---|
| 205 | + // o.support = this.support; |
---|
| 206 | + // o.fileparent = this.fileparent; |
---|
| 207 | + // if (this.bRep != null) |
---|
| 208 | + // o.bRep = this.bRep.support; |
---|
| 209 | + |
---|
| 210 | + this.bRep = null; |
---|
| 211 | + // if (this.bRep != null) |
---|
| 212 | + // this.bRep.support = null; |
---|
| 213 | + // this.support = null; |
---|
| 214 | + // this.fileparent = null; |
---|
| 215 | + } |
---|
| 216 | + |
---|
| 217 | + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 218 | + { |
---|
| 219 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 220 | + return; |
---|
| 221 | + |
---|
| 222 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 223 | + |
---|
| 224 | + RestoreBigData(o); |
---|
| 225 | + |
---|
| 226 | + hashtable.remove(GetUUID()); |
---|
| 227 | + |
---|
| 228 | + for (int i=0; i<Size(); i++) |
---|
| 229 | + { |
---|
| 230 | + get(i).RestoreBigData(hashtable); |
---|
| 231 | + } |
---|
| 232 | + } |
---|
| 233 | + |
---|
| 234 | + void RestoreBigData(Object3D o) |
---|
| 235 | + { |
---|
| 236 | + this.bRep = o.bRep; |
---|
| 237 | + if (this.bRep != null) |
---|
| 238 | + this.bRep.support = o.transientrep; |
---|
| 239 | + // this.support = o.support; |
---|
| 240 | + // this.fileparent = o.fileparent; |
---|
| 241 | + } |
---|
160 | 242 | |
---|
161 | 243 | // MOCAP SUPPORT |
---|
162 | 244 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
299 | 381 | } |
---|
300 | 382 | |
---|
301 | 383 | boolean live = false; |
---|
| 384 | + boolean dontselect = false; |
---|
302 | 385 | boolean hide = false; |
---|
303 | 386 | boolean link2master = false; // performs reset support/master at each frame |
---|
304 | 387 | boolean marked = false; // animation node |
---|
.. | .. |
---|
430 | 513 | { |
---|
431 | 514 | Object3D copy = this; |
---|
432 | 515 | |
---|
433 | | - Camera parentcam = CameraPane.theRenderer.manipCamera; |
---|
| 516 | + Camera parentcam = Globals.theRenderer.ManipCamera(); |
---|
434 | 517 | |
---|
435 | | - if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[0]) |
---|
| 518 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[0]) |
---|
436 | 519 | { |
---|
437 | | - parentcam = CameraPane.theRenderer.cameras[1]; |
---|
| 520 | + parentcam = Globals.theRenderer.Cameras()[1]; |
---|
438 | 521 | } |
---|
439 | 522 | |
---|
440 | | - if (CameraPane.theRenderer.manipCamera == CameraPane.theRenderer.cameras[1]) |
---|
| 523 | + if (Globals.theRenderer.ManipCamera() == Globals.theRenderer.Cameras()[1]) |
---|
441 | 524 | { |
---|
442 | | - parentcam = CameraPane.theRenderer.cameras[0]; |
---|
| 525 | + parentcam = Globals.theRenderer.Cameras()[0]; |
---|
443 | 526 | } |
---|
444 | 527 | |
---|
445 | 528 | if (this == parentcam) |
---|
.. | .. |
---|
447 | 530 | //assert(this instanceof Camera); |
---|
448 | 531 | |
---|
449 | 532 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
450 | | - LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.toParent, CameraPane.theRenderer.targetLookAt); |
---|
| 533 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.toParent, Globals.theRenderer.TargetLookAt()); |
---|
451 | 534 | } |
---|
452 | 535 | |
---|
453 | 536 | copy.marked ^= true; |
---|
.. | .. |
---|
467 | 550 | //assert(this instanceof Camera); |
---|
468 | 551 | |
---|
469 | 552 | for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
470 | | - LA.xformPos(CameraPane.theRenderer.targetLookAt, parentcam.fromParent, CameraPane.theRenderer.targetLookAt); |
---|
| 553 | + LA.xformPos(Globals.theRenderer.TargetLookAt(), parentcam.fromParent, Globals.theRenderer.TargetLookAt()); |
---|
471 | 554 | } |
---|
472 | 555 | |
---|
473 | 556 | copy.Touch(); // display list issue |
---|
.. | .. |
---|
480 | 563 | toParent = LA.newMatrix(); |
---|
481 | 564 | fromParent = LA.newMatrix(); |
---|
482 | 565 | } |
---|
| 566 | + |
---|
483 | 567 | if (toParentMarked == null) |
---|
484 | 568 | { |
---|
485 | 569 | if (maxcount != 1) |
---|
486 | 570 | { |
---|
487 | 571 | new Exception().printStackTrace(); |
---|
488 | 572 | } |
---|
| 573 | + |
---|
489 | 574 | toParentMarked = LA.newMatrix(); |
---|
490 | 575 | fromParentMarked = LA.newMatrix(); |
---|
491 | 576 | } |
---|
.. | .. |
---|
602 | 687 | return; |
---|
603 | 688 | } |
---|
604 | 689 | |
---|
605 | | - if (CameraPane.fromscript) |
---|
| 690 | + if (Globals.fromscript) |
---|
606 | 691 | { |
---|
607 | 692 | transformcount = 0; |
---|
608 | 693 | return; |
---|
.. | .. |
---|
773 | 858 | if (step == 0) |
---|
774 | 859 | step = 1; |
---|
775 | 860 | if (maxcount == 0) |
---|
776 | | - maxcount = 2048; // 4; |
---|
| 861 | + maxcount = 128; // 2048; // 4; |
---|
777 | 862 | // if (acceleration == 0) |
---|
778 | 863 | // acceleration = 10; |
---|
779 | 864 | if (delay == 0) // serial |
---|
.. | .. |
---|
796 | 881 | |
---|
797 | 882 | if (marked && Globals.isLIVE() && live && |
---|
798 | 883 | //TEMP21aug2018 |
---|
799 | | - Globals.DrawMode() == iCameraPane.SHADOW && |
---|
| 884 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
800 | 885 | currentframe != Globals.framecount) |
---|
801 | 886 | { |
---|
802 | 887 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
911 | 996 | fromParent = null; // LA.newMatrix(); |
---|
912 | 997 | bRep = null; // new BoundaryRep(); |
---|
913 | 998 | |
---|
| 999 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 1000 | + { |
---|
| 1001 | + name = oname; |
---|
| 1002 | + } |
---|
| 1003 | + |
---|
914 | 1004 | /* |
---|
915 | 1005 | float hue = (float)Math.random(); |
---|
916 | 1006 | Color col; |
---|
.. | .. |
---|
953 | 1043 | |
---|
954 | 1044 | public Object clone() |
---|
955 | 1045 | { |
---|
956 | | - return GrafreeD.clone(this); |
---|
| 1046 | + return Grafreed.clone(this); |
---|
957 | 1047 | } |
---|
958 | 1048 | |
---|
959 | 1049 | Object3D copyExpand() |
---|
.. | .. |
---|
1469 | 1559 | BoundaryRep.SEUIL = other.material.cameralight; |
---|
1470 | 1560 | |
---|
1471 | 1561 | // Set default to 0.1 |
---|
1472 | | - BoundaryRep.SEUIL /= 2; |
---|
| 1562 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
1473 | 1563 | System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
1474 | 1564 | } |
---|
1475 | 1565 | |
---|
.. | .. |
---|
1728 | 1818 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1729 | 1819 | o.bRep = transientrep; |
---|
1730 | 1820 | if (clone) |
---|
1731 | | - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 1821 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1732 | 1822 | o.CreateMaterial(); |
---|
1733 | 1823 | o.SetAttributes(this, -1); |
---|
1734 | 1824 | //parent |
---|
.. | .. |
---|
1741 | 1831 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1742 | 1832 | o.bRep = bRep; |
---|
1743 | 1833 | if (clone) |
---|
1744 | | - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 1834 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1745 | 1835 | o.CreateMaterial(); |
---|
1746 | 1836 | //o.overwriteThis(this, -1); |
---|
1747 | 1837 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1828 | 1918 | if (obj.name == null) |
---|
1829 | 1919 | continue; // can't be a null one |
---|
1830 | 1920 | |
---|
| 1921 | + // Try perfect match first. |
---|
1831 | 1922 | if (n.equals(obj.name)) |
---|
1832 | 1923 | { |
---|
1833 | 1924 | theobj = obj; |
---|
1834 | 1925 | count++; |
---|
1835 | 1926 | } |
---|
1836 | 1927 | } |
---|
| 1928 | + |
---|
| 1929 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1837 | 1930 | |
---|
1838 | 1931 | if (count != 1) |
---|
1839 | 1932 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2299 | 2392 | { |
---|
2300 | 2393 | if (newWindow) |
---|
2301 | 2394 | { |
---|
| 2395 | + new Exception().printStackTrace(); |
---|
2302 | 2396 | System.exit(0); |
---|
2303 | 2397 | if (parent != null) |
---|
2304 | 2398 | { |
---|
.. | .. |
---|
2475 | 2569 | return retval; |
---|
2476 | 2570 | } |
---|
2477 | 2571 | |
---|
2478 | | - void doEditDrag(ClickInfo info) |
---|
| 2572 | + void doEditDrag(ClickInfo info, boolean opposite) |
---|
2479 | 2573 | { |
---|
2480 | 2574 | switch (doSomething) |
---|
2481 | 2575 | { |
---|
2482 | 2576 | case 1: // '\001' |
---|
2483 | 2577 | //super. |
---|
2484 | | - doEditDrag0(info); |
---|
| 2578 | + doEditDrag0(info, opposite); |
---|
2485 | 2579 | break; |
---|
2486 | 2580 | |
---|
2487 | 2581 | case 2: // '\002' |
---|
.. | .. |
---|
2494 | 2588 | { |
---|
2495 | 2589 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2496 | 2590 | //childToDrag.doEditDrag(info); |
---|
2497 | | - sel.doEditDrag(info); |
---|
| 2591 | + sel.doEditDrag(info, opposite); |
---|
2498 | 2592 | } else |
---|
2499 | 2593 | { |
---|
2500 | 2594 | //super. |
---|
2501 | | - doEditDrag0(info); |
---|
| 2595 | + doEditDrag0(info, opposite); |
---|
2502 | 2596 | } |
---|
2503 | 2597 | } |
---|
2504 | 2598 | break; |
---|
.. | .. |
---|
2608 | 2702 | void GenNormalsS(boolean crease) |
---|
2609 | 2703 | { |
---|
2610 | 2704 | selection.GenNormals(crease); |
---|
| 2705 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2706 | +// { |
---|
| 2707 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2708 | +// selectee.GenNormals(crease); |
---|
| 2709 | +// } |
---|
| 2710 | + |
---|
| 2711 | + //Touch(); |
---|
| 2712 | + } |
---|
| 2713 | + |
---|
| 2714 | + void GenNormalsMeshS() |
---|
| 2715 | + { |
---|
| 2716 | + selection.GenNormalsMesh(); |
---|
2611 | 2717 | // for (int i=0; i<selection.size(); i++) |
---|
2612 | 2718 | // { |
---|
2613 | 2719 | // Object3D selectee = (Object3D) selection.elementAt(i); |
---|
.. | .. |
---|
2748 | 2854 | if (child == null) |
---|
2749 | 2855 | continue; |
---|
2750 | 2856 | child.GenNormals(crease); |
---|
| 2857 | +// Children().release(i); |
---|
| 2858 | + } |
---|
| 2859 | + blockloop = false; |
---|
| 2860 | + } |
---|
| 2861 | + |
---|
| 2862 | + void GenNormalsMesh() |
---|
| 2863 | + { |
---|
| 2864 | + if (blockloop) |
---|
| 2865 | + return; |
---|
| 2866 | + |
---|
| 2867 | + blockloop = true; |
---|
| 2868 | + GenNormalsMesh0(); |
---|
| 2869 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2870 | + { |
---|
| 2871 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2872 | + if (child == null) |
---|
| 2873 | + continue; |
---|
| 2874 | + child.GenNormalsMesh(); |
---|
2751 | 2875 | // Children().release(i); |
---|
2752 | 2876 | } |
---|
2753 | 2877 | blockloop = false; |
---|
.. | .. |
---|
2905 | 3029 | { |
---|
2906 | 3030 | if (bRep != null) |
---|
2907 | 3031 | { |
---|
2908 | | - bRep.GenUV(); |
---|
| 3032 | + bRep.GenUV(); //1); |
---|
| 3033 | + //bRep.UnfoldUV(); |
---|
2909 | 3034 | Touch(); |
---|
2910 | 3035 | } |
---|
2911 | 3036 | } |
---|
.. | .. |
---|
2915 | 3040 | if (bRep != null) |
---|
2916 | 3041 | { |
---|
2917 | 3042 | bRep.GenerateNormals(crease); |
---|
| 3043 | + Touch(); |
---|
| 3044 | + } |
---|
| 3045 | + } |
---|
| 3046 | + |
---|
| 3047 | + void GenNormalsMesh0() |
---|
| 3048 | + { |
---|
| 3049 | + if (bRep != null) |
---|
| 3050 | + { |
---|
| 3051 | + bRep.GenerateNormalsMesh(); |
---|
2918 | 3052 | Touch(); |
---|
2919 | 3053 | } |
---|
2920 | 3054 | } |
---|
.. | .. |
---|
2980 | 3114 | blockloop = false; |
---|
2981 | 3115 | } |
---|
2982 | 3116 | |
---|
| 3117 | + void TransformChildren() |
---|
| 3118 | + { |
---|
| 3119 | + if (toParent != null) |
---|
| 3120 | + { |
---|
| 3121 | + for (int i=Size(); --i>=0;) |
---|
| 3122 | + { |
---|
| 3123 | + Object3D v = get(i); |
---|
| 3124 | + |
---|
| 3125 | + if (v.toParent == null) |
---|
| 3126 | + { |
---|
| 3127 | + v.toParent = LA.newMatrix(); |
---|
| 3128 | + v.fromParent = LA.newMatrix(); |
---|
| 3129 | + } |
---|
| 3130 | + |
---|
| 3131 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3132 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3133 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3134 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
| 3135 | + } |
---|
| 3136 | + |
---|
| 3137 | + toParent = null; // LA.matIdentity(toParent); |
---|
| 3138 | + fromParent = null; // LA.matIdentity(fromParent); |
---|
| 3139 | + |
---|
| 3140 | + Touch(); |
---|
| 3141 | + } |
---|
| 3142 | + } |
---|
| 3143 | + |
---|
2983 | 3144 | void TransformGeometry() |
---|
2984 | 3145 | { |
---|
2985 | 3146 | Object3D obj = this; |
---|
.. | .. |
---|
3201 | 3362 | |
---|
3202 | 3363 | BoundaryRep sup = bRep.support; |
---|
3203 | 3364 | bRep.support = null; |
---|
3204 | | - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 3365 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3205 | 3366 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3206 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3367 | + |
---|
| 3368 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3369 | + |
---|
3207 | 3370 | bRep = temprep; |
---|
3208 | 3371 | bRep.support = sup; |
---|
3209 | 3372 | Touch(); |
---|
.. | .. |
---|
3725 | 3888 | if (child == null) |
---|
3726 | 3889 | continue; |
---|
3727 | 3890 | |
---|
3728 | | - if (GrafreeD.RENDERME > 0) |
---|
| 3891 | + if (Grafreed.RENDERME > 0) |
---|
3729 | 3892 | { |
---|
3730 | 3893 | if (child instanceof Merge) |
---|
3731 | 3894 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3876 | 4039 | if (child == null) |
---|
3877 | 4040 | continue; |
---|
3878 | 4041 | |
---|
3879 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4042 | + if (Grafreed.RENDERME > 0) |
---|
3880 | 4043 | { |
---|
3881 | 4044 | if (child instanceof Merge) |
---|
3882 | 4045 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4071 | 4234 | if (child == null) |
---|
4072 | 4235 | continue; |
---|
4073 | 4236 | |
---|
4074 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4237 | + if (Grafreed.RENDERME > 0) |
---|
4075 | 4238 | { |
---|
4076 | 4239 | if (child instanceof Merge) |
---|
4077 | 4240 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4184 | 4347 | { |
---|
4185 | 4348 | blockloop = true; |
---|
4186 | 4349 | get(i).RepairShadow(); |
---|
| 4350 | + blockloop = false; |
---|
| 4351 | + } |
---|
| 4352 | + } |
---|
| 4353 | + |
---|
| 4354 | + void RepairSOV() |
---|
| 4355 | + { |
---|
| 4356 | + if (blockloop) |
---|
| 4357 | + return; |
---|
| 4358 | + |
---|
| 4359 | + String texname = this.GetPigmentTexture(); |
---|
| 4360 | + |
---|
| 4361 | + if (texname.startsWith("sov")) |
---|
| 4362 | + { |
---|
| 4363 | + String[] s = texname.split("/"); |
---|
| 4364 | + |
---|
| 4365 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4366 | + |
---|
| 4367 | + texname = sname[0]; |
---|
| 4368 | + |
---|
| 4369 | + if (sname.length > 1) |
---|
| 4370 | + { |
---|
| 4371 | + texname += "Color.jpg"; |
---|
| 4372 | + } |
---|
| 4373 | + |
---|
| 4374 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4375 | + } |
---|
| 4376 | + |
---|
| 4377 | + texname = this.GetBumpTexture(); |
---|
| 4378 | + |
---|
| 4379 | + if (texname.startsWith("sov")) |
---|
| 4380 | + { |
---|
| 4381 | + String[] s = texname.split("/"); |
---|
| 4382 | + |
---|
| 4383 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4384 | + |
---|
| 4385 | + texname = sname[0]; |
---|
| 4386 | + |
---|
| 4387 | + if (sname.length > 1) |
---|
| 4388 | + { |
---|
| 4389 | + texname += "Bump.jpg"; |
---|
| 4390 | + } |
---|
| 4391 | + |
---|
| 4392 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4393 | + } |
---|
| 4394 | + |
---|
| 4395 | + for (int i=0; i<Size(); i++) |
---|
| 4396 | + { |
---|
| 4397 | + blockloop = true; |
---|
| 4398 | + get(i).RepairSOV(); |
---|
4187 | 4399 | blockloop = false; |
---|
4188 | 4400 | } |
---|
4189 | 4401 | } |
---|
.. | .. |
---|
4678 | 4890 | |
---|
4679 | 4891 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4680 | 4892 | { |
---|
4681 | | - if (hide) |
---|
| 4893 | + if (hide || dontselect) |
---|
4682 | 4894 | return null; |
---|
4683 | 4895 | |
---|
4684 | 4896 | if (count <= 0) |
---|
.. | .. |
---|
4704 | 4916 | |
---|
4705 | 4917 | cTreePath Select(int indexcount, boolean deselect) |
---|
4706 | 4918 | { |
---|
4707 | | - if (hide) |
---|
| 4919 | + if (hide || dontselect) |
---|
4708 | 4920 | return null; |
---|
4709 | 4921 | |
---|
4710 | 4922 | if (count <= 0) |
---|
.. | .. |
---|
4854 | 5066 | return globalTransform; |
---|
4855 | 5067 | } |
---|
4856 | 5068 | |
---|
4857 | | - void PreprocessOcclusion(CameraPane cp) |
---|
| 5069 | + void PreprocessOcclusion(iCameraPane cp) |
---|
4858 | 5070 | { |
---|
4859 | 5071 | /* |
---|
4860 | 5072 | if (AOdone) |
---|
.. | .. |
---|
5156 | 5368 | |
---|
5157 | 5369 | // System.out.println("Fullname = " + fullname); |
---|
5158 | 5370 | |
---|
5159 | | - if (fullname.name.indexOf(":") == -1) |
---|
5160 | | - return fullname.name; |
---|
| 5371 | + // Does not work on Windows due to C: |
---|
| 5372 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5373 | +// return fullname.name; |
---|
| 5374 | +// |
---|
| 5375 | +// return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
5161 | 5376 | |
---|
5162 | | - return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
| 5377 | + String[] split = fullname.name.split(":"); |
---|
| 5378 | + |
---|
| 5379 | + if (split.length == 0) |
---|
| 5380 | + { |
---|
| 5381 | + return ""; |
---|
| 5382 | + } |
---|
| 5383 | + |
---|
| 5384 | + if (split.length <= 2) |
---|
| 5385 | + { |
---|
| 5386 | + if (fullname.name.endsWith(":")) |
---|
| 5387 | + { |
---|
| 5388 | + // Windows |
---|
| 5389 | + return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5390 | + } |
---|
| 5391 | + |
---|
| 5392 | + return split[0]; |
---|
| 5393 | + } |
---|
| 5394 | + |
---|
| 5395 | + // Windows |
---|
| 5396 | + assert(split.length == 4); |
---|
| 5397 | + |
---|
| 5398 | + return split[0] + ":" + split[1]; |
---|
5163 | 5399 | } |
---|
5164 | 5400 | |
---|
5165 | 5401 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5168 | 5404 | return ""; |
---|
5169 | 5405 | |
---|
5170 | 5406 | // 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()); |
---|
| 5407 | + // Does not work on Windows due to C: |
---|
| 5408 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5409 | +// return ""; |
---|
| 5410 | +// |
---|
| 5411 | +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5412 | + String[] split = fullname.name.split(":"); |
---|
| 5413 | + |
---|
| 5414 | + if (split.length == 0) |
---|
| 5415 | + { |
---|
| 5416 | + return ""; |
---|
| 5417 | + } |
---|
| 5418 | + |
---|
| 5419 | + if (split.length == 1) |
---|
| 5420 | + { |
---|
| 5421 | + return ""; |
---|
| 5422 | + } |
---|
| 5423 | + |
---|
| 5424 | + if (split.length == 2) |
---|
| 5425 | + { |
---|
| 5426 | + if (fullname.name.endsWith(":")) |
---|
| 5427 | + { |
---|
| 5428 | + // Windows |
---|
| 5429 | + return ""; |
---|
| 5430 | + } |
---|
| 5431 | + |
---|
| 5432 | + return split[1]; |
---|
| 5433 | + } |
---|
| 5434 | + |
---|
| 5435 | + // Windows |
---|
| 5436 | + assert(split.length == 4); |
---|
| 5437 | + |
---|
| 5438 | + return split[2] + ":" + split[3]; |
---|
5175 | 5439 | } |
---|
5176 | 5440 | |
---|
5177 | 5441 | String GetPigmentTexture() |
---|
.. | .. |
---|
5245 | 5509 | System.out.print("; textures = " + textures); |
---|
5246 | 5510 | System.out.println("; usedtextures = " + usedtextures); |
---|
5247 | 5511 | |
---|
5248 | | - if (GetTextures() == null) |
---|
| 5512 | + if (GetTextures() == null) // What is that?? |
---|
5249 | 5513 | GetTextures().name = ":"; |
---|
5250 | 5514 | |
---|
5251 | 5515 | String texname = tex; |
---|
.. | .. |
---|
5276 | 5540 | child.ResetPigmentTexture(); |
---|
5277 | 5541 | blockloop = false; |
---|
5278 | 5542 | } |
---|
| 5543 | + } |
---|
| 5544 | + |
---|
| 5545 | + UUID GetUUID() |
---|
| 5546 | + { |
---|
| 5547 | + if (uuid == null) |
---|
| 5548 | + { |
---|
| 5549 | + // Serial |
---|
| 5550 | + uuid = UUID.randomUUID(); |
---|
| 5551 | + } |
---|
| 5552 | + |
---|
| 5553 | + return uuid; |
---|
| 5554 | + } |
---|
| 5555 | + |
---|
| 5556 | + Object3D GetObject(UUID uid) |
---|
| 5557 | + { |
---|
| 5558 | + if (blockloop) |
---|
| 5559 | + return null; |
---|
| 5560 | + |
---|
| 5561 | + if (GetUUID().equals(uid)) |
---|
| 5562 | + return this; |
---|
| 5563 | + |
---|
| 5564 | + int nb = Size(); |
---|
| 5565 | + for (int i = 0; i < nb; i++) |
---|
| 5566 | + { |
---|
| 5567 | + Object3D child = (Object3D) get(i); |
---|
| 5568 | + |
---|
| 5569 | + if (child == null) |
---|
| 5570 | + continue; |
---|
| 5571 | + |
---|
| 5572 | + blockloop = true; |
---|
| 5573 | + Object3D obj = child.GetObject(uid); |
---|
| 5574 | + blockloop = false; |
---|
| 5575 | + if (obj != null) |
---|
| 5576 | + return obj; |
---|
| 5577 | + } |
---|
| 5578 | + |
---|
| 5579 | + return null; |
---|
5279 | 5580 | } |
---|
5280 | 5581 | |
---|
5281 | 5582 | void SetBumpTexture(String tex) |
---|
.. | .. |
---|
5322 | 5623 | boolean NeedSupport() |
---|
5323 | 5624 | { |
---|
5324 | 5625 | return |
---|
5325 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5626 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5326 | 5627 | // PROBLEM with CROWD!! |
---|
5327 | | - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); |
---|
| 5628 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5328 | 5629 | } |
---|
5329 | 5630 | |
---|
| 5631 | + static boolean DEBUG_SELECTION = false; |
---|
| 5632 | + |
---|
| 5633 | + boolean IsLive() |
---|
| 5634 | + { |
---|
| 5635 | + if (live) |
---|
| 5636 | + return true; |
---|
| 5637 | + |
---|
| 5638 | + if (parent == null) |
---|
| 5639 | + return false; |
---|
| 5640 | + |
---|
| 5641 | + return parent.IsLive(); |
---|
| 5642 | + } |
---|
5330 | 5643 | |
---|
5331 | 5644 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5332 | 5645 | { |
---|
.. | .. |
---|
5338 | 5651 | } |
---|
5339 | 5652 | |
---|
5340 | 5653 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5341 | | - hide) |
---|
| 5654 | + (hide || dontselect)) |
---|
5342 | 5655 | return; |
---|
5343 | 5656 | |
---|
5344 | 5657 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5365 | 5678 | } |
---|
5366 | 5679 | |
---|
5367 | 5680 | if ((//display.DrawMode() == CameraPane.SHADOW || |
---|
5368 | | - display.DrawMode() == CameraPane.SELECTION || CameraPane.DEBUG_SELECTION) && HasTransparency()) |
---|
| 5681 | + display.DrawMode() == iCameraPane.SELECTION || display.IsDebugSelection()) && HasTransparency()) |
---|
5369 | 5682 | { |
---|
5370 | 5683 | return; |
---|
5371 | 5684 | } |
---|
5372 | 5685 | |
---|
5373 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 5686 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5374 | 5687 | |
---|
5375 | 5688 | /* |
---|
5376 | 5689 | if (touched) |
---|
.. | .. |
---|
5389 | 5702 | support = support; |
---|
5390 | 5703 | |
---|
5391 | 5704 | //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5392 | | - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5705 | + boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5393 | 5706 | |
---|
5394 | 5707 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5395 | 5708 | { |
---|
.. | .. |
---|
5406 | 5719 | |
---|
5407 | 5720 | boolean compiled = false; |
---|
5408 | 5721 | |
---|
5409 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 5722 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5410 | 5723 | |
---|
5411 | 5724 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5412 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5725 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5726 | + (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0))) |
---|
5413 | 5727 | { |
---|
5414 | 5728 | Globals.lighttouched = true; |
---|
5415 | 5729 | } // all panes... |
---|
| 5730 | + |
---|
5416 | 5731 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5417 | 5732 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5418 | 5733 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5422 | 5737 | //if (displaylist == -1 && usecalllists) |
---|
5423 | 5738 | if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
5424 | 5739 | { |
---|
5425 | | - bRep.displaylist = gl.glGenLists(1); |
---|
| 5740 | + bRep.displaylist = display.GenList(); |
---|
5426 | 5741 | assert(bRep.displaylist != 0); |
---|
5427 | 5742 | // System.err.println("glGenLists: " + bRep.displaylist + " for " + this); |
---|
5428 | 5743 | //System.out.println("\tgen list " + list); |
---|
.. | .. |
---|
5434 | 5749 | if (usecalllists) |
---|
5435 | 5750 | { |
---|
5436 | 5751 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5437 | | - gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 5752 | + display.NewList(bRep.displaylist); |
---|
5438 | 5753 | } |
---|
| 5754 | + |
---|
5439 | 5755 | CallList(display, root, selected, blocked); |
---|
| 5756 | + |
---|
5440 | 5757 | // compiled = true; |
---|
5441 | 5758 | if (usecalllists) |
---|
5442 | 5759 | { |
---|
5443 | 5760 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5444 | | - gl.glEndList(); |
---|
| 5761 | + display.EndList(); |
---|
5445 | 5762 | } |
---|
5446 | 5763 | //gl.glDrawBuffer(gl.GL_BACK); |
---|
5447 | 5764 | // XXX touched = false; |
---|
.. | .. |
---|
5484 | 5801 | |
---|
5485 | 5802 | // frustum culling |
---|
5486 | 5803 | if (CameraPane.FRUSTUM && !blocked && !IsInfinite() && GetBRep() != null // && GetBRep().VertexCount() != 1260 // default grid |
---|
5487 | | - && display.DrawMode() != CameraPane.SELECTION) |
---|
| 5804 | + && display.DrawMode() != iCameraPane.SELECTION) |
---|
5488 | 5805 | { |
---|
5489 | | - if (display.DrawMode() == CameraPane.SHADOW) |
---|
| 5806 | + if (display.DrawMode() == iCameraPane.SHADOW) |
---|
5490 | 5807 | { |
---|
5491 | 5808 | if (!link2master // tricky to cull in shadow mode. |
---|
5492 | | - && GetBRep().FrustumCull(this, gl, display.LightCamera(), true)) |
---|
| 5809 | + && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
5493 | 5810 | { |
---|
5494 | 5811 | //System.out.print("CULLED"); |
---|
5495 | 5812 | culled = true; |
---|
.. | .. |
---|
5497 | 5814 | } |
---|
5498 | 5815 | else |
---|
5499 | 5816 | //GetBRep().getBounds(v0, v1, this); |
---|
5500 | | - if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false)) |
---|
| 5817 | + if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false)) |
---|
5501 | 5818 | culled = true; |
---|
5502 | 5819 | |
---|
5503 | 5820 | // LA.xformPos(v0, display.renderCamera.toScreen, v0); |
---|
.. | .. |
---|
5533 | 5850 | |
---|
5534 | 5851 | |
---|
5535 | 5852 | if (!culled) |
---|
5536 | | - if (display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION) |
---|
| 5853 | + if (display.DrawMode() == display.SELECTION || display.IsDebugSelection()) |
---|
5537 | 5854 | { |
---|
5538 | 5855 | if (GetBRep() != null) |
---|
5539 | 5856 | { |
---|
5540 | | - CameraPane.NextIndex(this, gl); |
---|
| 5857 | + display.NextIndex(); |
---|
5541 | 5858 | // vertex color conflict : gl.glCallList(list); |
---|
5542 | 5859 | DrawNode(display, root, selected); |
---|
5543 | 5860 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5578 | 5895 | tex = GetTextures(); |
---|
5579 | 5896 | } |
---|
5580 | 5897 | |
---|
5581 | | - display.BindTextures(tex, texres); |
---|
| 5898 | + boolean failedPigment = false; |
---|
| 5899 | + boolean failedBump = false; |
---|
| 5900 | + |
---|
| 5901 | + try |
---|
| 5902 | + { |
---|
| 5903 | + display.BindPigmentTexture(tex, texres); |
---|
| 5904 | + } |
---|
| 5905 | + catch (Exception e) |
---|
| 5906 | + { |
---|
| 5907 | + System.err.println("FAILED: " + this); |
---|
| 5908 | + failedPigment = true; |
---|
| 5909 | + } |
---|
| 5910 | + |
---|
| 5911 | + try |
---|
| 5912 | + { |
---|
| 5913 | + display.BindBumpTexture(tex, texres); |
---|
| 5914 | + } |
---|
| 5915 | + catch (Exception e) |
---|
| 5916 | + { |
---|
| 5917 | + //System.err.println("FAILED: " + this); |
---|
| 5918 | + failedBump = true; |
---|
| 5919 | + } |
---|
5582 | 5920 | |
---|
5583 | 5921 | if (!compiled) |
---|
5584 | 5922 | { |
---|
.. | .. |
---|
5594 | 5932 | |
---|
5595 | 5933 | // System.err.println("glCallList: " + bRep.displaylist + " for " + this); |
---|
5596 | 5934 | assert(bRep.displaylist != 0); |
---|
5597 | | - gl.glCallList(bRep.displaylist); |
---|
| 5935 | + display.CallList(bRep.displaylist); |
---|
5598 | 5936 | // june 2013 drawSelf(display, root, selected); |
---|
5599 | 5937 | } |
---|
5600 | 5938 | } |
---|
5601 | 5939 | } |
---|
5602 | 5940 | |
---|
5603 | | - display.ReleaseTextures(tex); |
---|
| 5941 | + if (!failedBump) |
---|
| 5942 | + display.ReleaseBumpTexture(tex); |
---|
| 5943 | + |
---|
| 5944 | + if (!failedPigment) |
---|
| 5945 | + display.ReleasePigmentTexture(tex); |
---|
5604 | 5946 | |
---|
5605 | 5947 | display.PopMaterial(this, selected); |
---|
5606 | 5948 | } |
---|
.. | .. |
---|
5729 | 6071 | |
---|
5730 | 6072 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5731 | 6073 | { |
---|
| 6074 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6075 | + return; |
---|
| 6076 | + |
---|
5732 | 6077 | if (hide) |
---|
5733 | 6078 | return; |
---|
5734 | 6079 | // shadow optimisation |
---|
.. | .. |
---|
5854 | 6199 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5855 | 6200 | return; // no shadow for transparent objects |
---|
5856 | 6201 | |
---|
| 6202 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6203 | + return; |
---|
| 6204 | + |
---|
5857 | 6205 | if (hide) |
---|
5858 | 6206 | return; |
---|
5859 | 6207 | |
---|
.. | .. |
---|
5894 | 6242 | return; |
---|
5895 | 6243 | } |
---|
5896 | 6244 | |
---|
| 6245 | + //bRep.GenUV(1/material.diffuseness); |
---|
5897 | 6246 | // bRep.lock = true; |
---|
5898 | 6247 | |
---|
5899 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 6248 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5900 | 6249 | |
---|
5901 | 6250 | if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
5902 | 6251 | { |
---|
.. | .. |
---|
5913 | 6262 | |
---|
5914 | 6263 | bRep.getMinMax(min, max, 100); |
---|
5915 | 6264 | |
---|
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(); |
---|
| 6265 | + display.DrawBox(min, max); |
---|
5933 | 6266 | |
---|
5934 | 6267 | return; |
---|
5935 | 6268 | } |
---|
.. | .. |
---|
5973 | 6306 | { |
---|
5974 | 6307 | //throw new Error(); |
---|
5975 | 6308 | |
---|
5976 | | - boolean selectmode = display.DrawMode() == display.SELECTION || CameraPane.DEBUG_SELECTION; |
---|
| 6309 | + boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5977 | 6310 | |
---|
5978 | 6311 | int[] strips = bRep.getRawIndices(); |
---|
5979 | 6312 | |
---|
.. | .. |
---|
5983 | 6316 | new Exception().printStackTrace(); |
---|
5984 | 6317 | return; |
---|
5985 | 6318 | } |
---|
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 | | - } |
---|
| 6319 | + |
---|
| 6320 | + display.DrawGeometry(bRep, flipV, selectmode); |
---|
6152 | 6321 | } else // catch (Error e) |
---|
6153 | 6322 | { |
---|
6154 | 6323 | // TRIANGLE ARRAY |
---|
6155 | 6324 | if (IsOpaque()) // Static()) |
---|
6156 | 6325 | { |
---|
6157 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6326 | + display.StartTriangles(); |
---|
6158 | 6327 | int facecount = bRep.FaceCount(); |
---|
6159 | 6328 | for (int i = 0; i < facecount; i++) |
---|
6160 | 6329 | { |
---|
.. | .. |
---|
6219 | 6388 | |
---|
6220 | 6389 | display.DrawFace(this, p, q, r, face); |
---|
6221 | 6390 | } |
---|
6222 | | - gl.glEnd(); |
---|
| 6391 | + display.EndTriangles(); |
---|
6223 | 6392 | } |
---|
6224 | 6393 | else |
---|
6225 | 6394 | { |
---|
.. | .. |
---|
6248 | 6417 | //System.out.println("SORT"); |
---|
6249 | 6418 | |
---|
6250 | 6419 | java.util.Arrays.sort(facescompare); |
---|
6251 | | - |
---|
6252 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6420 | + |
---|
| 6421 | + display.StartTriangles(); |
---|
6253 | 6422 | for (int i = 0; i < facecount; i++) |
---|
6254 | 6423 | { |
---|
6255 | 6424 | Face face = bRep.GetFace(facescompare[i].index); |
---|
.. | .. |
---|
6263 | 6432 | |
---|
6264 | 6433 | display.DrawFace(this, p, q, r, face); |
---|
6265 | 6434 | } |
---|
6266 | | - gl.glEnd(); |
---|
| 6435 | + display.EndTriangles(); |
---|
6267 | 6436 | } |
---|
6268 | 6437 | |
---|
6269 | 6438 | if (false) // live && support != null && support.bRep != null) // debug weights |
---|
6270 | 6439 | { |
---|
| 6440 | + /* |
---|
6271 | 6441 | gl.glDisable(gl.GL_LIGHTING); |
---|
6272 | 6442 | float[] colorV = new float[3]; |
---|
6273 | 6443 | |
---|
.. | .. |
---|
6346 | 6516 | // gl.glEnd(); |
---|
6347 | 6517 | } |
---|
6348 | 6518 | } |
---|
| 6519 | + */ |
---|
6349 | 6520 | } |
---|
6350 | 6521 | } |
---|
6351 | 6522 | |
---|
.. | .. |
---|
6390 | 6561 | center.add(r); |
---|
6391 | 6562 | center.mul(1.0/3); |
---|
6392 | 6563 | |
---|
6393 | | - center.sub(CameraPane.theRenderer.eyeCamera.location); |
---|
| 6564 | + center.sub(Globals.theRenderer.EyeCamera().location); |
---|
6394 | 6565 | |
---|
6395 | 6566 | distance = center.dot(center); |
---|
6396 | 6567 | } |
---|
.. | .. |
---|
6404 | 6575 | void Print(Vertex v) |
---|
6405 | 6576 | { |
---|
6406 | 6577 | //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 | 6578 | } |
---|
6424 | 6579 | |
---|
6425 | 6580 | void drawSelf(ClickInfo info, int level, boolean select) |
---|
.. | .. |
---|
6993 | 7148 | int spotw = spot.x + spot.width; |
---|
6994 | 7149 | int spoth = spot.y + spot.height; |
---|
6995 | 7150 | 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 | | - } |
---|
| 7151 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7152 | +// { |
---|
| 7153 | +// CameraPane.Xmin = spot.x; |
---|
| 7154 | +// } |
---|
| 7155 | +// if (CameraPane.Xmax < spotw) |
---|
| 7156 | +// { |
---|
| 7157 | +// CameraPane.Xmax = spotw; |
---|
| 7158 | +// } |
---|
| 7159 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7160 | +// { |
---|
| 7161 | +// CameraPane.Ymin = spot.y; |
---|
| 7162 | +// } |
---|
| 7163 | +// if (CameraPane.Ymax < spoth) |
---|
| 7164 | +// { |
---|
| 7165 | +// CameraPane.Ymax = spoth; |
---|
| 7166 | +// } |
---|
7012 | 7167 | spot.translate(32, 32); |
---|
7013 | 7168 | spotw = spot.x + spot.width; |
---|
7014 | 7169 | spoth = spot.y + spot.height; |
---|
7015 | | - info.g.setColor(Color.blue); |
---|
| 7170 | + info.g.setColor(Color.cyan); |
---|
7016 | 7171 | 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); |
---|
| 7172 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7173 | +// { |
---|
| 7174 | +// CameraPane.Xmin = spot.x; |
---|
| 7175 | +// } |
---|
| 7176 | +// if (CameraPane.Xmax < spotw) |
---|
| 7177 | +// { |
---|
| 7178 | +// CameraPane.Xmax = spotw; |
---|
| 7179 | +// } |
---|
| 7180 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7181 | +// { |
---|
| 7182 | +// CameraPane.Ymin = spot.y; |
---|
| 7183 | +// } |
---|
| 7184 | +// if (CameraPane.Ymax < spoth) |
---|
| 7185 | +// { |
---|
| 7186 | +// CameraPane.Ymax = spoth; |
---|
| 7187 | +// } |
---|
| 7188 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7189 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
7035 | 7190 | spot.translate(0, -32); |
---|
7036 | | - info.g.setColor(Color.green); |
---|
| 7191 | + info.g.setColor(Color.yellow); |
---|
7037 | 7192 | 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 | | - } |
---|
| 7193 | + info.g.setColor(Color.green); |
---|
| 7194 | +// if (CameraPane.Xmin > spot.x) |
---|
| 7195 | +// { |
---|
| 7196 | +// CameraPane.Xmin = spot.x; |
---|
| 7197 | +// } |
---|
| 7198 | +// if (CameraPane.Xmax < spotw) |
---|
| 7199 | +// { |
---|
| 7200 | +// CameraPane.Xmax = spotw; |
---|
| 7201 | +// } |
---|
| 7202 | +// if (CameraPane.Ymin > spot.y) |
---|
| 7203 | +// { |
---|
| 7204 | +// CameraPane.Ymin = spot.y; |
---|
| 7205 | +// } |
---|
| 7206 | +// if (CameraPane.Ymax < spoth) |
---|
| 7207 | +// { |
---|
| 7208 | +// CameraPane.Ymax = spoth; |
---|
| 7209 | +// } |
---|
7054 | 7210 | info.g.drawArc(boundary.x, boundary.y, |
---|
7055 | 7211 | boundary.width, boundary.height, 0, 360); |
---|
7056 | 7212 | //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 | | - } |
---|
| 7213 | +// if (CameraPane.Xmin > boundary.x) |
---|
| 7214 | +// { |
---|
| 7215 | +// CameraPane.Xmin = boundary.x; |
---|
| 7216 | +// } |
---|
| 7217 | +// if (CameraPane.Xmax < boundary.x + boundary.width) |
---|
| 7218 | +// { |
---|
| 7219 | +// CameraPane.Xmax = boundary.x + boundary.width; |
---|
| 7220 | +// } |
---|
| 7221 | +// if (CameraPane.Ymin > boundary.y) |
---|
| 7222 | +// { |
---|
| 7223 | +// CameraPane.Ymin = boundary.y; |
---|
| 7224 | +// } |
---|
| 7225 | +// if (CameraPane.Ymax < boundary.y + boundary.height) |
---|
| 7226 | +// { |
---|
| 7227 | +// CameraPane.Ymax = boundary.y + boundary.height; |
---|
| 7228 | +// } |
---|
7073 | 7229 | return; |
---|
7074 | 7230 | } |
---|
7075 | 7231 | } |
---|
.. | .. |
---|
7086 | 7242 | startX = info.x; |
---|
7087 | 7243 | startY = info.y; |
---|
7088 | 7244 | |
---|
7089 | | - hitSomething = 0; |
---|
| 7245 | + hitSomething = -1; |
---|
7090 | 7246 | cVector origin = new cVector(); |
---|
7091 | 7247 | //LA.xformPos(origin, toParent, origin); |
---|
7092 | 7248 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7119 | 7275 | } |
---|
7120 | 7276 | |
---|
7121 | 7277 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7122 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7278 | + modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7123 | 7279 | //System.out.println("modified = " + modified); |
---|
7124 | 7280 | //new Exception().printStackTrace(); |
---|
7125 | 7281 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7147 | 7303 | return true; |
---|
7148 | 7304 | } |
---|
7149 | 7305 | |
---|
7150 | | - void doEditDrag0(ClickInfo info) |
---|
| 7306 | + void doEditDrag0(ClickInfo info, boolean opposite) |
---|
7151 | 7307 | { |
---|
7152 | 7308 | if (hitSomething == 0) |
---|
7153 | 7309 | { |
---|
.. | .. |
---|
7162 | 7318 | //System.out.println("hitSomething = " + hitSomething); |
---|
7163 | 7319 | |
---|
7164 | 7320 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7321 | + |
---|
7165 | 7322 | cVector xlate = new cVector(); |
---|
7166 | 7323 | //cVector xlate2 = new cVector(); |
---|
7167 | 7324 | switch (hitSomething) |
---|
.. | .. |
---|
7172 | 7329 | |
---|
7173 | 7330 | case hitCenter: // Translate |
---|
7174 | 7331 | |
---|
7175 | | - scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance(); |
---|
| 7332 | + scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7176 | 7333 | |
---|
7177 | | - if (modified) |
---|
| 7334 | + if (modified || opposite) |
---|
7178 | 7335 | { |
---|
7179 | 7336 | //assert(false); |
---|
7180 | 7337 | /* |
---|
.. | .. |
---|
7220 | 7377 | } |
---|
7221 | 7378 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7222 | 7379 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7223 | | - LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up); |
---|
| 7380 | + LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7224 | 7381 | LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
7225 | 7382 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7226 | | - LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away); |
---|
| 7383 | + LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7227 | 7384 | //LA.vecCross(up, cVector.Z, right2); |
---|
7228 | 7385 | |
---|
7229 | 7386 | cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
.. | .. |
---|
7268 | 7425 | |
---|
7269 | 7426 | if (modified) |
---|
7270 | 7427 | { |
---|
| 7428 | + // Rotate 90 degrees |
---|
7271 | 7429 | angle /= (Math.PI / 4); |
---|
7272 | 7430 | angle = Math.floor(angle + 0.5); |
---|
7273 | 7431 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7281 | 7439 | } |
---|
7282 | 7440 | /**/ |
---|
7283 | 7441 | |
---|
7284 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7442 | + switch (info.pane.RenderCamera().viewCode) |
---|
7285 | 7443 | { |
---|
7286 | 7444 | case 1: // '\001' |
---|
7287 | 7445 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7309 | 7467 | |
---|
7310 | 7468 | case hitScale: // scale |
---|
7311 | 7469 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7470 | + double sign = 1; |
---|
| 7471 | + if (hScale < 0) |
---|
| 7472 | + { |
---|
| 7473 | + sign = -1; |
---|
| 7474 | + } |
---|
| 7475 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7312 | 7476 | if (hScale < 0.01) |
---|
7313 | 7477 | { |
---|
7314 | | - hScale = 0.01; |
---|
| 7478 | + //hScale = 0.01; |
---|
7315 | 7479 | } |
---|
7316 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7317 | | - if (hScale < 0.01) |
---|
7318 | | - { |
---|
7319 | | - hScale = 0.01; |
---|
7320 | | - } |
---|
| 7480 | + |
---|
7321 | 7481 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7322 | | - if (vScale < 0.01) |
---|
| 7482 | + sign = 1; |
---|
| 7483 | + if (vScale < 0) |
---|
7323 | 7484 | { |
---|
7324 | | - vScale = 0.01; |
---|
| 7485 | + sign = -1; |
---|
7325 | 7486 | } |
---|
7326 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7487 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7327 | 7488 | if (vScale < 0.01) |
---|
7328 | 7489 | { |
---|
7329 | | - vScale = 0.01; |
---|
| 7490 | + //vScale = 0.01; |
---|
7330 | 7491 | } |
---|
7331 | 7492 | LA.matCopy(startMat, toParent); |
---|
7332 | 7493 | /**/ |
---|
.. | .. |
---|
7337 | 7498 | } |
---|
7338 | 7499 | /**/ |
---|
7339 | 7500 | |
---|
7340 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7501 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7502 | + |
---|
| 7503 | + if (totalScale < 0.01) |
---|
| 7504 | + { |
---|
| 7505 | + totalScale = 0.01; |
---|
| 7506 | + } |
---|
| 7507 | + |
---|
| 7508 | + switch (info.pane.RenderCamera().viewCode) |
---|
7341 | 7509 | { |
---|
7342 | 7510 | case 3: // '\001' |
---|
7343 | | - if (modified) |
---|
| 7511 | + if (modified || opposite) |
---|
7344 | 7512 | { |
---|
7345 | 7513 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7346 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7514 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7347 | 7515 | } // vScale, 1); |
---|
7348 | 7516 | else |
---|
7349 | 7517 | { |
---|
7350 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7518 | + // EXCEPTION! |
---|
| 7519 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7351 | 7520 | } // vScale, 1); |
---|
7352 | 7521 | break; |
---|
7353 | 7522 | |
---|
7354 | 7523 | case 2: // '\002' |
---|
7355 | | - if (modified) |
---|
| 7524 | + if (modified || opposite) |
---|
7356 | 7525 | { |
---|
7357 | 7526 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7358 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7527 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7359 | 7528 | } else |
---|
7360 | 7529 | { |
---|
7361 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7530 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7362 | 7531 | } |
---|
7363 | 7532 | break; |
---|
7364 | 7533 | |
---|
7365 | 7534 | case 1: // '\003' |
---|
7366 | | - if (modified) |
---|
| 7535 | + if (modified || opposite) |
---|
7367 | 7536 | { |
---|
7368 | 7537 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7369 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7538 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7370 | 7539 | } else |
---|
7371 | 7540 | { |
---|
7372 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7541 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7373 | 7542 | } |
---|
7374 | 7543 | break; |
---|
7375 | 7544 | } |
---|
.. | .. |
---|
7502 | 7671 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7503 | 7672 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7504 | 7673 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7674 | + |
---|
| 7675 | + String objname; |
---|
| 7676 | + |
---|
7505 | 7677 | if (false) //parent != null) |
---|
7506 | 7678 | { |
---|
7507 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7679 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7508 | 7680 | } else |
---|
7509 | 7681 | { |
---|
7510 | | - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); |
---|
| 7682 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7511 | 7683 | } // + super.toString(); |
---|
7512 | 7684 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
| 7685 | + |
---|
| 7686 | + if (!Globals.ADVANCED) |
---|
| 7687 | + return objname; |
---|
| 7688 | + |
---|
| 7689 | + return objname + " " + System.identityHashCode(this); |
---|
7513 | 7690 | } |
---|
7514 | 7691 | |
---|
7515 | 7692 | public int hashCode() |
---|
.. | .. |
---|
7565 | 7742 | objectUI.closeUI(); |
---|
7566 | 7743 | if (editWindow != null) |
---|
7567 | 7744 | { |
---|
| 7745 | + editWindow.ctrlPanel.FlushUI(); |
---|
7568 | 7746 | editWindow.refreshContents(); |
---|
7569 | 7747 | } // ? new |
---|
7570 | 7748 | objectUI = null; |
---|
.. | .. |
---|
7585 | 7763 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7586 | 7764 | |
---|
7587 | 7765 | Object3D /*Composite*/ parent; |
---|
7588 | | - Object3D /*Composite*/ fileparent; |
---|
| 7766 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7589 | 7767 | |
---|
7590 | 7768 | double[][] toParent; // dynamic matrix |
---|
7591 | 7769 | double[][] fromParent; |
---|
.. | .. |
---|
7700 | 7878 | { |
---|
7701 | 7879 | assert(bRep != null); |
---|
7702 | 7880 | if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
7703 | | - GrafreeD.Assert(support.bRep == bRep.support); |
---|
| 7881 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
7704 | 7882 | } |
---|
7705 | 7883 | else |
---|
7706 | 7884 | { |
---|
.. | .. |
---|
7749 | 7927 | private static cVector edge2 = new cVector(); |
---|
7750 | 7928 | //private static cVector norm = new cVector(); |
---|
7751 | 7929 | /*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; |
---|
| 7930 | + static final int hitCenter = 1; |
---|
| 7931 | + static final int hitScale = 2; |
---|
| 7932 | + static final int hitRotate = 3; |
---|
7755 | 7933 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7756 | 7934 | /*transient*/ private Point centerPt; |
---|
7757 | 7935 | /*transient*/ private int startX; |
---|