.. | .. |
---|
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 | + 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 |
---|
.. | .. |
---|
773 | 856 | if (step == 0) |
---|
774 | 857 | step = 1; |
---|
775 | 858 | if (maxcount == 0) |
---|
776 | | - maxcount = 2048; // 4; |
---|
| 859 | + maxcount = 128; // 2048; // 4; |
---|
777 | 860 | // if (acceleration == 0) |
---|
778 | 861 | // acceleration = 10; |
---|
779 | 862 | if (delay == 0) // serial |
---|
.. | .. |
---|
796 | 879 | |
---|
797 | 880 | if (marked && Globals.isLIVE() && live && |
---|
798 | 881 | //TEMP21aug2018 |
---|
799 | | - Globals.DrawMode() == iCameraPane.SHADOW && |
---|
| 882 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
800 | 883 | currentframe != Globals.framecount) |
---|
801 | 884 | { |
---|
802 | 885 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
911 | 994 | fromParent = null; // LA.newMatrix(); |
---|
912 | 995 | bRep = null; // new BoundaryRep(); |
---|
913 | 996 | |
---|
| 997 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 998 | + { |
---|
| 999 | + name = oname; |
---|
| 1000 | + } |
---|
| 1001 | + |
---|
914 | 1002 | /* |
---|
915 | 1003 | float hue = (float)Math.random(); |
---|
916 | 1004 | Color col; |
---|
.. | .. |
---|
953 | 1041 | |
---|
954 | 1042 | public Object clone() |
---|
955 | 1043 | { |
---|
956 | | - return GrafreeD.clone(this); |
---|
| 1044 | + return Grafreed.clone(this); |
---|
957 | 1045 | } |
---|
958 | 1046 | |
---|
959 | 1047 | Object3D copyExpand() |
---|
.. | .. |
---|
1469 | 1557 | BoundaryRep.SEUIL = other.material.cameralight; |
---|
1470 | 1558 | |
---|
1471 | 1559 | // Set default to 0.1 |
---|
1472 | | - BoundaryRep.SEUIL /= 2; |
---|
| 1560 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
1473 | 1561 | System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
1474 | 1562 | } |
---|
1475 | 1563 | |
---|
.. | .. |
---|
1728 | 1816 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1729 | 1817 | o.bRep = transientrep; |
---|
1730 | 1818 | if (clone) |
---|
1731 | | - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 1819 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1732 | 1820 | o.CreateMaterial(); |
---|
1733 | 1821 | o.SetAttributes(this, -1); |
---|
1734 | 1822 | //parent |
---|
.. | .. |
---|
1741 | 1829 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1742 | 1830 | o.bRep = bRep; |
---|
1743 | 1831 | if (clone) |
---|
1744 | | - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 1832 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1745 | 1833 | o.CreateMaterial(); |
---|
1746 | 1834 | //o.overwriteThis(this, -1); |
---|
1747 | 1835 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1828 | 1916 | if (obj.name == null) |
---|
1829 | 1917 | continue; // can't be a null one |
---|
1830 | 1918 | |
---|
| 1919 | + // Try perfect match first. |
---|
1831 | 1920 | if (n.equals(obj.name)) |
---|
1832 | 1921 | { |
---|
1833 | 1922 | theobj = obj; |
---|
1834 | 1923 | count++; |
---|
1835 | 1924 | } |
---|
1836 | 1925 | } |
---|
| 1926 | + |
---|
| 1927 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1837 | 1928 | |
---|
1838 | 1929 | if (count != 1) |
---|
1839 | 1930 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2299 | 2390 | { |
---|
2300 | 2391 | if (newWindow) |
---|
2301 | 2392 | { |
---|
| 2393 | + new Exception().printStackTrace(); |
---|
2302 | 2394 | System.exit(0); |
---|
2303 | 2395 | if (parent != null) |
---|
2304 | 2396 | { |
---|
.. | .. |
---|
2475 | 2567 | return retval; |
---|
2476 | 2568 | } |
---|
2477 | 2569 | |
---|
2478 | | - void doEditDrag(ClickInfo info) |
---|
| 2570 | + void doEditDrag(ClickInfo info, boolean opposite) |
---|
2479 | 2571 | { |
---|
2480 | 2572 | switch (doSomething) |
---|
2481 | 2573 | { |
---|
2482 | 2574 | case 1: // '\001' |
---|
2483 | 2575 | //super. |
---|
2484 | | - doEditDrag0(info); |
---|
| 2576 | + doEditDrag0(info, opposite); |
---|
2485 | 2577 | break; |
---|
2486 | 2578 | |
---|
2487 | 2579 | case 2: // '\002' |
---|
.. | .. |
---|
2494 | 2586 | { |
---|
2495 | 2587 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2496 | 2588 | //childToDrag.doEditDrag(info); |
---|
2497 | | - sel.doEditDrag(info); |
---|
| 2589 | + sel.doEditDrag(info, opposite); |
---|
2498 | 2590 | } else |
---|
2499 | 2591 | { |
---|
2500 | 2592 | //super. |
---|
2501 | | - doEditDrag0(info); |
---|
| 2593 | + doEditDrag0(info, opposite); |
---|
2502 | 2594 | } |
---|
2503 | 2595 | } |
---|
2504 | 2596 | break; |
---|
.. | .. |
---|
2608 | 2700 | void GenNormalsS(boolean crease) |
---|
2609 | 2701 | { |
---|
2610 | 2702 | selection.GenNormals(crease); |
---|
| 2703 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2704 | +// { |
---|
| 2705 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2706 | +// selectee.GenNormals(crease); |
---|
| 2707 | +// } |
---|
| 2708 | + |
---|
| 2709 | + //Touch(); |
---|
| 2710 | + } |
---|
| 2711 | + |
---|
| 2712 | + void GenNormalsMeshS() |
---|
| 2713 | + { |
---|
| 2714 | + selection.GenNormalsMesh(); |
---|
2611 | 2715 | // for (int i=0; i<selection.size(); i++) |
---|
2612 | 2716 | // { |
---|
2613 | 2717 | // Object3D selectee = (Object3D) selection.elementAt(i); |
---|
.. | .. |
---|
2748 | 2852 | if (child == null) |
---|
2749 | 2853 | continue; |
---|
2750 | 2854 | child.GenNormals(crease); |
---|
| 2855 | +// Children().release(i); |
---|
| 2856 | + } |
---|
| 2857 | + blockloop = false; |
---|
| 2858 | + } |
---|
| 2859 | + |
---|
| 2860 | + void GenNormalsMesh() |
---|
| 2861 | + { |
---|
| 2862 | + if (blockloop) |
---|
| 2863 | + return; |
---|
| 2864 | + |
---|
| 2865 | + blockloop = true; |
---|
| 2866 | + GenNormalsMesh0(); |
---|
| 2867 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2868 | + { |
---|
| 2869 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2870 | + if (child == null) |
---|
| 2871 | + continue; |
---|
| 2872 | + child.GenNormalsMesh(); |
---|
2751 | 2873 | // Children().release(i); |
---|
2752 | 2874 | } |
---|
2753 | 2875 | blockloop = false; |
---|
.. | .. |
---|
2905 | 3027 | { |
---|
2906 | 3028 | if (bRep != null) |
---|
2907 | 3029 | { |
---|
2908 | | - bRep.GenUV(); |
---|
| 3030 | + bRep.GenUV(); //1); |
---|
| 3031 | + //bRep.UnfoldUV(); |
---|
2909 | 3032 | Touch(); |
---|
2910 | 3033 | } |
---|
2911 | 3034 | } |
---|
.. | .. |
---|
2915 | 3038 | if (bRep != null) |
---|
2916 | 3039 | { |
---|
2917 | 3040 | bRep.GenerateNormals(crease); |
---|
| 3041 | + Touch(); |
---|
| 3042 | + } |
---|
| 3043 | + } |
---|
| 3044 | + |
---|
| 3045 | + void GenNormalsMesh0() |
---|
| 3046 | + { |
---|
| 3047 | + if (bRep != null) |
---|
| 3048 | + { |
---|
| 3049 | + bRep.GenerateNormalsMesh(); |
---|
2918 | 3050 | Touch(); |
---|
2919 | 3051 | } |
---|
2920 | 3052 | } |
---|
.. | .. |
---|
2980 | 3112 | blockloop = false; |
---|
2981 | 3113 | } |
---|
2982 | 3114 | |
---|
| 3115 | + void TransformChildren() |
---|
| 3116 | + { |
---|
| 3117 | + if (toParent != null) |
---|
| 3118 | + { |
---|
| 3119 | + for (int i=Size(); --i>=0;) |
---|
| 3120 | + { |
---|
| 3121 | + Object3D v = get(i); |
---|
| 3122 | + |
---|
| 3123 | + if (v.toParent == null) |
---|
| 3124 | + { |
---|
| 3125 | + v.toParent = LA.newMatrix(); |
---|
| 3126 | + v.fromParent = LA.newMatrix(); |
---|
| 3127 | + } |
---|
| 3128 | + |
---|
| 3129 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3130 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3131 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3132 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
| 3133 | + } |
---|
| 3134 | + |
---|
| 3135 | + toParent = null; // LA.matIdentity(toParent); |
---|
| 3136 | + fromParent = null; // LA.matIdentity(fromParent); |
---|
| 3137 | + |
---|
| 3138 | + Touch(); |
---|
| 3139 | + } |
---|
| 3140 | + } |
---|
| 3141 | + |
---|
2983 | 3142 | void TransformGeometry() |
---|
2984 | 3143 | { |
---|
2985 | 3144 | Object3D obj = this; |
---|
.. | .. |
---|
3201 | 3360 | |
---|
3202 | 3361 | BoundaryRep sup = bRep.support; |
---|
3203 | 3362 | bRep.support = null; |
---|
3204 | | - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 3363 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3205 | 3364 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3206 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3365 | + |
---|
| 3366 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3367 | + |
---|
3207 | 3368 | bRep = temprep; |
---|
3208 | 3369 | bRep.support = sup; |
---|
3209 | 3370 | Touch(); |
---|
.. | .. |
---|
3725 | 3886 | if (child == null) |
---|
3726 | 3887 | continue; |
---|
3727 | 3888 | |
---|
3728 | | - if (GrafreeD.RENDERME > 0) |
---|
| 3889 | + if (Grafreed.RENDERME > 0) |
---|
3729 | 3890 | { |
---|
3730 | 3891 | if (child instanceof Merge) |
---|
3731 | 3892 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3876 | 4037 | if (child == null) |
---|
3877 | 4038 | continue; |
---|
3878 | 4039 | |
---|
3879 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4040 | + if (Grafreed.RENDERME > 0) |
---|
3880 | 4041 | { |
---|
3881 | 4042 | if (child instanceof Merge) |
---|
3882 | 4043 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4071 | 4232 | if (child == null) |
---|
4072 | 4233 | continue; |
---|
4073 | 4234 | |
---|
4074 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4235 | + if (Grafreed.RENDERME > 0) |
---|
4075 | 4236 | { |
---|
4076 | 4237 | if (child instanceof Merge) |
---|
4077 | 4238 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4678 | 4839 | |
---|
4679 | 4840 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4680 | 4841 | { |
---|
4681 | | - if (hide) |
---|
| 4842 | + if (hide || dontselect) |
---|
4682 | 4843 | return null; |
---|
4683 | 4844 | |
---|
4684 | 4845 | if (count <= 0) |
---|
.. | .. |
---|
4704 | 4865 | |
---|
4705 | 4866 | cTreePath Select(int indexcount, boolean deselect) |
---|
4706 | 4867 | { |
---|
4707 | | - if (hide) |
---|
| 4868 | + if (hide || dontselect) |
---|
4708 | 4869 | return null; |
---|
4709 | 4870 | |
---|
4710 | 4871 | if (count <= 0) |
---|
.. | .. |
---|
5156 | 5317 | |
---|
5157 | 5318 | // System.out.println("Fullname = " + fullname); |
---|
5158 | 5319 | |
---|
5159 | | - if (fullname.name.indexOf(":") == -1) |
---|
5160 | | - return fullname.name; |
---|
| 5320 | + // Does not work on Windows due to C: |
---|
| 5321 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5322 | +// return fullname.name; |
---|
| 5323 | +// |
---|
| 5324 | +// return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
5161 | 5325 | |
---|
5162 | | - return fullname.name.substring(0,fullname.name.indexOf(":")); |
---|
| 5326 | + String[] split = fullname.name.split(":"); |
---|
| 5327 | + |
---|
| 5328 | + if (split.length == 0) |
---|
| 5329 | + { |
---|
| 5330 | + return ""; |
---|
| 5331 | + } |
---|
| 5332 | + |
---|
| 5333 | + if (split.length <= 2) |
---|
| 5334 | + { |
---|
| 5335 | + if (fullname.name.endsWith(":")) |
---|
| 5336 | + { |
---|
| 5337 | + // Windows |
---|
| 5338 | + return fullname.name.substring(0, fullname.name.length()-1); |
---|
| 5339 | + } |
---|
| 5340 | + |
---|
| 5341 | + return split[0]; |
---|
| 5342 | + } |
---|
| 5343 | + |
---|
| 5344 | + // Windows |
---|
| 5345 | + assert(split.length == 4); |
---|
| 5346 | + |
---|
| 5347 | + return split[0] + ":" + split[1]; |
---|
5163 | 5348 | } |
---|
5164 | 5349 | |
---|
5165 | 5350 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5168 | 5353 | return ""; |
---|
5169 | 5354 | |
---|
5170 | 5355 | // 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()); |
---|
| 5356 | + // Does not work on Windows due to C: |
---|
| 5357 | +// if (fullname.name.indexOf(":") == -1) |
---|
| 5358 | +// return ""; |
---|
| 5359 | +// |
---|
| 5360 | +// return fullname.name.substring(fullname.name.indexOf(":")+1,fullname.name.length()); |
---|
| 5361 | + String[] split = fullname.name.split(":"); |
---|
| 5362 | + |
---|
| 5363 | + if (split.length == 0) |
---|
| 5364 | + { |
---|
| 5365 | + return ""; |
---|
| 5366 | + } |
---|
| 5367 | + |
---|
| 5368 | + if (split.length == 1) |
---|
| 5369 | + { |
---|
| 5370 | + return ""; |
---|
| 5371 | + } |
---|
| 5372 | + |
---|
| 5373 | + if (split.length == 2) |
---|
| 5374 | + { |
---|
| 5375 | + if (fullname.name.endsWith(":")) |
---|
| 5376 | + { |
---|
| 5377 | + // Windows |
---|
| 5378 | + return ""; |
---|
| 5379 | + } |
---|
| 5380 | + |
---|
| 5381 | + return split[1]; |
---|
| 5382 | + } |
---|
| 5383 | + |
---|
| 5384 | + // Windows |
---|
| 5385 | + assert(split.length == 4); |
---|
| 5386 | + |
---|
| 5387 | + return split[2] + ":" + split[3]; |
---|
5175 | 5388 | } |
---|
5176 | 5389 | |
---|
5177 | 5390 | String GetPigmentTexture() |
---|
.. | .. |
---|
5245 | 5458 | System.out.print("; textures = " + textures); |
---|
5246 | 5459 | System.out.println("; usedtextures = " + usedtextures); |
---|
5247 | 5460 | |
---|
5248 | | - if (GetTextures() == null) |
---|
| 5461 | + if (GetTextures() == null) // What is that?? |
---|
5249 | 5462 | GetTextures().name = ":"; |
---|
5250 | 5463 | |
---|
5251 | 5464 | String texname = tex; |
---|
.. | .. |
---|
5276 | 5489 | child.ResetPigmentTexture(); |
---|
5277 | 5490 | blockloop = false; |
---|
5278 | 5491 | } |
---|
| 5492 | + } |
---|
| 5493 | + |
---|
| 5494 | + UUID GetUUID() |
---|
| 5495 | + { |
---|
| 5496 | + if (uuid == null) |
---|
| 5497 | + { |
---|
| 5498 | + // Serial |
---|
| 5499 | + uuid = UUID.randomUUID(); |
---|
| 5500 | + } |
---|
| 5501 | + |
---|
| 5502 | + return uuid; |
---|
| 5503 | + } |
---|
| 5504 | + |
---|
| 5505 | + Object3D GetObject(UUID uid) |
---|
| 5506 | + { |
---|
| 5507 | + if (blockloop) |
---|
| 5508 | + return null; |
---|
| 5509 | + |
---|
| 5510 | + if (GetUUID().equals(uid)) |
---|
| 5511 | + return this; |
---|
| 5512 | + |
---|
| 5513 | + int nb = Size(); |
---|
| 5514 | + for (int i = 0; i < nb; i++) |
---|
| 5515 | + { |
---|
| 5516 | + Object3D child = (Object3D) get(i); |
---|
| 5517 | + |
---|
| 5518 | + if (child == null) |
---|
| 5519 | + continue; |
---|
| 5520 | + |
---|
| 5521 | + blockloop = true; |
---|
| 5522 | + Object3D obj = child.GetObject(uid); |
---|
| 5523 | + blockloop = false; |
---|
| 5524 | + if (obj != null) |
---|
| 5525 | + return obj; |
---|
| 5526 | + } |
---|
| 5527 | + |
---|
| 5528 | + return null; |
---|
5279 | 5529 | } |
---|
5280 | 5530 | |
---|
5281 | 5531 | void SetBumpTexture(String tex) |
---|
.. | .. |
---|
5322 | 5572 | boolean NeedSupport() |
---|
5323 | 5573 | { |
---|
5324 | 5574 | return |
---|
5325 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5575 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
5326 | 5576 | // PROBLEM with CROWD!! |
---|
5327 | | - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); |
---|
| 5577 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5328 | 5578 | } |
---|
5329 | 5579 | |
---|
5330 | 5580 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
5339 | 5589 | } |
---|
5340 | 5590 | |
---|
5341 | 5591 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5342 | | - hide) |
---|
| 5592 | + (hide || dontselect)) |
---|
5343 | 5593 | return; |
---|
5344 | 5594 | |
---|
5345 | 5595 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5371 | 5621 | return; |
---|
5372 | 5622 | } |
---|
5373 | 5623 | |
---|
5374 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 5624 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5375 | 5625 | |
---|
5376 | 5626 | /* |
---|
5377 | 5627 | if (touched) |
---|
.. | .. |
---|
5423 | 5673 | //if (displaylist == -1 && usecalllists) |
---|
5424 | 5674 | if ((bRep != null && bRep.displaylist <= 0) && usecalllists) // june 2013 |
---|
5425 | 5675 | { |
---|
5426 | | - bRep.displaylist = gl.glGenLists(1); |
---|
| 5676 | + bRep.displaylist = display.GenList(); |
---|
5427 | 5677 | assert(bRep.displaylist != 0); |
---|
5428 | 5678 | // System.err.println("glGenLists: " + bRep.displaylist + " for " + this); |
---|
5429 | 5679 | //System.out.println("\tgen list " + list); |
---|
.. | .. |
---|
5435 | 5685 | if (usecalllists) |
---|
5436 | 5686 | { |
---|
5437 | 5687 | // System.err.println("new list " + bRep.displaylist + " for " + this); |
---|
5438 | | - gl.glNewList(bRep.displaylist, gl.GL_COMPILE); //_AND_EXECUTE); |
---|
| 5688 | + display.NewList(bRep.displaylist); |
---|
5439 | 5689 | } |
---|
| 5690 | + |
---|
5440 | 5691 | CallList(display, root, selected, blocked); |
---|
| 5692 | + |
---|
5441 | 5693 | // compiled = true; |
---|
5442 | 5694 | if (usecalllists) |
---|
5443 | 5695 | { |
---|
5444 | 5696 | // System.err.println("end list " + bRep.displaylist + " for " + this); |
---|
5445 | | - gl.glEndList(); |
---|
| 5697 | + display.EndList(); |
---|
5446 | 5698 | } |
---|
5447 | 5699 | //gl.glDrawBuffer(gl.GL_BACK); |
---|
5448 | 5700 | // XXX touched = false; |
---|
.. | .. |
---|
5490 | 5742 | if (display.DrawMode() == iCameraPane.SHADOW) |
---|
5491 | 5743 | { |
---|
5492 | 5744 | if (!link2master // tricky to cull in shadow mode. |
---|
5493 | | - && GetBRep().FrustumCull(this, gl, display.LightCamera(), true)) |
---|
| 5745 | + && GetBRep().FrustumCull(this, null, display.LightCamera(), true)) |
---|
5494 | 5746 | { |
---|
5495 | 5747 | //System.out.print("CULLED"); |
---|
5496 | 5748 | culled = true; |
---|
.. | .. |
---|
5498 | 5750 | } |
---|
5499 | 5751 | else |
---|
5500 | 5752 | //GetBRep().getBounds(v0, v1, this); |
---|
5501 | | - if (GetBRep().FrustumCull(this, gl, display.RenderCamera(), false)) |
---|
| 5753 | + if (GetBRep().FrustumCull(this, null, display.RenderCamera(), false)) |
---|
5502 | 5754 | culled = true; |
---|
5503 | 5755 | |
---|
5504 | 5756 | // LA.xformPos(v0, display.renderCamera.toScreen, v0); |
---|
.. | .. |
---|
5538 | 5790 | { |
---|
5539 | 5791 | if (GetBRep() != null) |
---|
5540 | 5792 | { |
---|
5541 | | - CameraPane.NextIndex(this, gl); |
---|
| 5793 | + display.NextIndex(); |
---|
5542 | 5794 | // vertex color conflict : gl.glCallList(list); |
---|
5543 | 5795 | DrawNode(display, root, selected); |
---|
5544 | 5796 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5579 | 5831 | tex = GetTextures(); |
---|
5580 | 5832 | } |
---|
5581 | 5833 | |
---|
5582 | | - display.BindTextures(tex, texres); |
---|
| 5834 | + boolean failed = false; |
---|
| 5835 | + |
---|
| 5836 | + try |
---|
| 5837 | + { |
---|
| 5838 | + display.BindTextures(tex, texres); |
---|
| 5839 | + } |
---|
| 5840 | + catch (Exception e) |
---|
| 5841 | + { |
---|
| 5842 | + System.err.println("FAILED: " + this); |
---|
| 5843 | + failed = true; |
---|
| 5844 | + } |
---|
5583 | 5845 | |
---|
5584 | 5846 | if (!compiled) |
---|
5585 | 5847 | { |
---|
.. | .. |
---|
5595 | 5857 | |
---|
5596 | 5858 | // System.err.println("glCallList: " + bRep.displaylist + " for " + this); |
---|
5597 | 5859 | assert(bRep.displaylist != 0); |
---|
5598 | | - gl.glCallList(bRep.displaylist); |
---|
| 5860 | + display.CallList(bRep.displaylist); |
---|
5599 | 5861 | // june 2013 drawSelf(display, root, selected); |
---|
5600 | 5862 | } |
---|
5601 | 5863 | } |
---|
5602 | 5864 | } |
---|
5603 | 5865 | |
---|
5604 | | - display.ReleaseTextures(tex); |
---|
| 5866 | + if (!failed) |
---|
| 5867 | + display.ReleaseTextures(tex); |
---|
5605 | 5868 | |
---|
5606 | 5869 | display.PopMaterial(this, selected); |
---|
5607 | 5870 | } |
---|
.. | .. |
---|
5730 | 5993 | |
---|
5731 | 5994 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5732 | 5995 | { |
---|
| 5996 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 5997 | + return; |
---|
| 5998 | + |
---|
5733 | 5999 | if (hide) |
---|
5734 | 6000 | return; |
---|
5735 | 6001 | // shadow optimisation |
---|
.. | .. |
---|
5855 | 6121 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5856 | 6122 | return; // no shadow for transparent objects |
---|
5857 | 6123 | |
---|
| 6124 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6125 | + return; |
---|
| 6126 | + |
---|
5858 | 6127 | if (hide) |
---|
5859 | 6128 | return; |
---|
5860 | 6129 | |
---|
.. | .. |
---|
5895 | 6164 | return; |
---|
5896 | 6165 | } |
---|
5897 | 6166 | |
---|
| 6167 | + //bRep.GenUV(1/material.diffuseness); |
---|
5898 | 6168 | // bRep.lock = true; |
---|
5899 | 6169 | |
---|
5900 | | - javax.media.opengl.GL gl = display.GetGL(); |
---|
| 6170 | + //javax.media.opengl.GL gl = display.GetGL(); |
---|
5901 | 6171 | |
---|
5902 | 6172 | if (CameraPane.BOXMODE && !selected) // || CameraPane.movingcamera) |
---|
5903 | 6173 | { |
---|
.. | .. |
---|
5914 | 6184 | |
---|
5915 | 6185 | bRep.getMinMax(min, max, 100); |
---|
5916 | 6186 | |
---|
5917 | | - gl.glBegin(gl.GL_LINES); |
---|
5918 | | - |
---|
5919 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5920 | | - gl.glVertex3d(min.x, min.y, max.z); |
---|
5921 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5922 | | - gl.glVertex3d(min.x, max.y, min.z); |
---|
5923 | | - gl.glVertex3d(min.x, min.y, min.z); |
---|
5924 | | - gl.glVertex3d(max.x, min.y, min.z); |
---|
5925 | | - |
---|
5926 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5927 | | - gl.glVertex3d(min.x, max.y, max.z); |
---|
5928 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5929 | | - gl.glVertex3d(max.x, min.y, max.z); |
---|
5930 | | - gl.glVertex3d(max.x, max.y, max.z); |
---|
5931 | | - gl.glVertex3d(max.x, max.y, min.z); |
---|
5932 | | - |
---|
5933 | | - gl.glEnd(); |
---|
| 6187 | + display.DrawBox(min, max); |
---|
5934 | 6188 | |
---|
5935 | 6189 | return; |
---|
5936 | 6190 | } |
---|
.. | .. |
---|
5984 | 6238 | new Exception().printStackTrace(); |
---|
5985 | 6239 | return; |
---|
5986 | 6240 | } |
---|
5987 | | - |
---|
5988 | | - // TRIANGLE STRIP ARRAY |
---|
5989 | | - if (bRep.trimmed) |
---|
5990 | | - { |
---|
5991 | | - float[] v = bRep.getRawVertices(); |
---|
5992 | | - float[] n = bRep.getRawNormals(); |
---|
5993 | | - float[] c = bRep.getRawColors(); |
---|
5994 | | - float[] uv = bRep.getRawUVMap(); |
---|
5995 | | - |
---|
5996 | | - int count2 = 0; |
---|
5997 | | - int count3 = 0; |
---|
5998 | | - |
---|
5999 | | - if (n.length > 0) |
---|
6000 | | - { |
---|
6001 | | - for (int i = 0; i < strips.length; i++) |
---|
6002 | | - { |
---|
6003 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6004 | | - |
---|
6005 | | - /* |
---|
6006 | | - boolean locked = false; |
---|
6007 | | - float eps = 0.1f; |
---|
6008 | | - boolean wrap = CameraPane.UVWRAP; // true; // UV WRAP TEXTURE ISSUE: true = artifacts, false = nice |
---|
6009 | | - |
---|
6010 | | - int dot = 0; |
---|
6011 | | - |
---|
6012 | | - if ((dot&1) == 0) |
---|
6013 | | - dot |= (Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) ? 3 : 1; |
---|
6014 | | - |
---|
6015 | | - if (wrap || (dot&2) != 0) // Math.abs(qv.s - pv.s) < eps && Math.abs(qv.t - pv.t) < eps) |
---|
6016 | | - gl.glTexCoord2f((float) qv.s, (float) qv.t); |
---|
6017 | | - else |
---|
6018 | | - { |
---|
6019 | | - locked = true; |
---|
6020 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6021 | | - } |
---|
6022 | | - //System.out.println("vertexq = " + qv.x + ", " + qv.y + ", " + qv.z); |
---|
6023 | | - gl.glVertex3f((float) qv.x, (float) qv.y, (float) qv.z); |
---|
6024 | | - if (hasnorm) |
---|
6025 | | - { |
---|
6026 | | - //System.out.println("normalr = " + rv.norm.x + ", " + rv.norm.y + ", " + rv.norm.z); |
---|
6027 | | - gl.glNormal3f((float) rv.norm.x, (float) rv.norm.y, (float) rv.norm.z); |
---|
6028 | | - } |
---|
6029 | | - |
---|
6030 | | - if ((dot&4) == 0) |
---|
6031 | | - dot |= (Math.abs(rv.s - pv.s) < eps && Math.abs(rv.t - pv.t) < eps) ? 12 : 4; |
---|
6032 | | - |
---|
6033 | | - if (wrap || !locked && (dot&8) != 0) |
---|
6034 | | - gl.glTexCoord2f((float) rv.s, (float) rv.t); |
---|
6035 | | - else |
---|
6036 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6037 | | - |
---|
6038 | | - f.dot = dot; |
---|
6039 | | - */ |
---|
6040 | | - |
---|
6041 | | - if (!selectmode) |
---|
6042 | | - { |
---|
6043 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6044 | | - { |
---|
6045 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6046 | | - } else |
---|
6047 | | - { |
---|
6048 | | - gl.glNormal3f(0, 0, 1); |
---|
6049 | | - } |
---|
6050 | | - |
---|
6051 | | - if (c != null) |
---|
6052 | | - //System.out.println("glcolor = " + c[count3] + ", " + c[count3+1] + ", " + c[count3+2]); |
---|
6053 | | - { |
---|
6054 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6055 | | - } |
---|
6056 | | - } |
---|
6057 | | - if (flipV) |
---|
6058 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6059 | | - else |
---|
6060 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6061 | | - //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6062 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6063 | | - |
---|
6064 | | - count2 += 2; |
---|
6065 | | - count3 += 3; |
---|
6066 | | - if (!selectmode) |
---|
6067 | | - { |
---|
6068 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6069 | | - { |
---|
6070 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6071 | | - } else |
---|
6072 | | - { |
---|
6073 | | - gl.glNormal3f(0, 0, 1); |
---|
6074 | | - } |
---|
6075 | | - if (c != null) |
---|
6076 | | - { |
---|
6077 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6078 | | - } |
---|
6079 | | - } |
---|
6080 | | - if (flipV) |
---|
6081 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6082 | | - else |
---|
6083 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6084 | | - //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
6085 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6086 | | - |
---|
6087 | | - count2 += 2; |
---|
6088 | | - count3 += 3; |
---|
6089 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6090 | | - { |
---|
6091 | | - //gl.glTexCoord2d(...); |
---|
6092 | | - if (!selectmode) |
---|
6093 | | - { |
---|
6094 | | - if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
6095 | | - { |
---|
6096 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
6097 | | - } else |
---|
6098 | | - { |
---|
6099 | | - gl.glNormal3f(0, 0, 1); |
---|
6100 | | - } |
---|
6101 | | - if (c != null) |
---|
6102 | | - { |
---|
6103 | | - gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
6104 | | - } |
---|
6105 | | - } |
---|
6106 | | - |
---|
6107 | | - if (flipV) |
---|
6108 | | - gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
6109 | | - else |
---|
6110 | | - gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
6111 | | - //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
6112 | | - gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
6113 | | - count2 += 2; |
---|
6114 | | - count3 += 3; |
---|
6115 | | - } |
---|
6116 | | - |
---|
6117 | | - gl.glEnd(); |
---|
6118 | | - } |
---|
6119 | | - } |
---|
6120 | | - |
---|
6121 | | - assert count3 == v.length; |
---|
6122 | | - } |
---|
6123 | | - else // !trimmed |
---|
6124 | | - { |
---|
6125 | | - int count = 0; |
---|
6126 | | - for (int i = 0; i < strips.length; i++) |
---|
6127 | | - { |
---|
6128 | | - gl.glBegin(gl.GL_TRIANGLE_STRIP); |
---|
6129 | | - |
---|
6130 | | - Vertex p = bRep.GetVertex(bRep.indices[count++]); |
---|
6131 | | - Vertex q = bRep.GetVertex(bRep.indices[count++]); |
---|
6132 | | - |
---|
6133 | | - drawVertex(gl, p, selectmode); |
---|
6134 | | - drawVertex(gl, q, selectmode); |
---|
6135 | | - |
---|
6136 | | - for (int j = 0; j < strips[i] - 2; j++) |
---|
6137 | | - { |
---|
6138 | | - Vertex r = bRep.GetVertex(bRep.indices[count++]); |
---|
6139 | | - |
---|
6140 | | -// if (j%2 == 0) |
---|
6141 | | -// drawFace(p, q, r, display, null); |
---|
6142 | | -// else |
---|
6143 | | -// drawFace(p, r, q, display, null); |
---|
6144 | | - |
---|
6145 | | -// p = q; |
---|
6146 | | -// q = r; |
---|
6147 | | - drawVertex(gl, r, selectmode); |
---|
6148 | | - } |
---|
6149 | | - |
---|
6150 | | - gl.glEnd(); |
---|
6151 | | - } |
---|
6152 | | - } |
---|
| 6241 | + |
---|
| 6242 | + display.DrawGeometry(bRep, flipV, selectmode); |
---|
6153 | 6243 | } else // catch (Error e) |
---|
6154 | 6244 | { |
---|
6155 | 6245 | // TRIANGLE ARRAY |
---|
6156 | 6246 | if (IsOpaque()) // Static()) |
---|
6157 | 6247 | { |
---|
6158 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6248 | + display.StartTriangles(); |
---|
6159 | 6249 | int facecount = bRep.FaceCount(); |
---|
6160 | 6250 | for (int i = 0; i < facecount; i++) |
---|
6161 | 6251 | { |
---|
.. | .. |
---|
6220 | 6310 | |
---|
6221 | 6311 | display.DrawFace(this, p, q, r, face); |
---|
6222 | 6312 | } |
---|
6223 | | - gl.glEnd(); |
---|
| 6313 | + display.EndTriangles(); |
---|
6224 | 6314 | } |
---|
6225 | 6315 | else |
---|
6226 | 6316 | { |
---|
.. | .. |
---|
6249 | 6339 | //System.out.println("SORT"); |
---|
6250 | 6340 | |
---|
6251 | 6341 | java.util.Arrays.sort(facescompare); |
---|
6252 | | - |
---|
6253 | | - gl.glBegin(gl.GL_TRIANGLES); |
---|
| 6342 | + |
---|
| 6343 | + display.StartTriangles(); |
---|
6254 | 6344 | for (int i = 0; i < facecount; i++) |
---|
6255 | 6345 | { |
---|
6256 | 6346 | Face face = bRep.GetFace(facescompare[i].index); |
---|
.. | .. |
---|
6264 | 6354 | |
---|
6265 | 6355 | display.DrawFace(this, p, q, r, face); |
---|
6266 | 6356 | } |
---|
6267 | | - gl.glEnd(); |
---|
| 6357 | + display.EndTriangles(); |
---|
6268 | 6358 | } |
---|
6269 | 6359 | |
---|
6270 | 6360 | if (false) // live && support != null && support.bRep != null) // debug weights |
---|
6271 | 6361 | { |
---|
| 6362 | + /* |
---|
6272 | 6363 | gl.glDisable(gl.GL_LIGHTING); |
---|
6273 | 6364 | float[] colorV = new float[3]; |
---|
6274 | 6365 | |
---|
.. | .. |
---|
6347 | 6438 | // gl.glEnd(); |
---|
6348 | 6439 | } |
---|
6349 | 6440 | } |
---|
| 6441 | + */ |
---|
6350 | 6442 | } |
---|
6351 | 6443 | } |
---|
6352 | 6444 | |
---|
.. | .. |
---|
6391 | 6483 | center.add(r); |
---|
6392 | 6484 | center.mul(1.0/3); |
---|
6393 | 6485 | |
---|
6394 | | - center.sub(CameraPane.theRenderer.eyeCamera.location); |
---|
| 6486 | + center.sub(Globals.theRenderer.EyeCamera().location); |
---|
6395 | 6487 | |
---|
6396 | 6488 | distance = center.dot(center); |
---|
6397 | 6489 | } |
---|
.. | .. |
---|
6405 | 6497 | void Print(Vertex v) |
---|
6406 | 6498 | { |
---|
6407 | 6499 | //System.err.println("(" + v.x + ", " + v.y + ", " + v.z + ")"); |
---|
6408 | | - } |
---|
6409 | | - |
---|
6410 | | - void drawVertex(javax.media.opengl.GL gl, Vertex pv, boolean selectmode) |
---|
6411 | | - { |
---|
6412 | | - if (!selectmode) |
---|
6413 | | - { |
---|
6414 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
6415 | | - gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
6416 | | - |
---|
6417 | | - if (flipV) |
---|
6418 | | - gl.glTexCoord2f((float) pv.s, 1-(float) pv.t); |
---|
6419 | | - else |
---|
6420 | | - gl.glTexCoord2f((float) pv.s, (float) pv.t); |
---|
6421 | | - } |
---|
6422 | | - |
---|
6423 | | - gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
6424 | 6500 | } |
---|
6425 | 6501 | |
---|
6426 | 6502 | void drawSelf(ClickInfo info, int level, boolean select) |
---|
.. | .. |
---|
7031 | 7107 | // { |
---|
7032 | 7108 | // CameraPane.Ymax = spoth; |
---|
7033 | 7109 | // } |
---|
7034 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
7035 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7110 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
| 7111 | + //info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
7036 | 7112 | spot.translate(0, -32); |
---|
7037 | 7113 | info.g.setColor(Color.green); |
---|
7038 | 7114 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
7087 | 7163 | startX = info.x; |
---|
7088 | 7164 | startY = info.y; |
---|
7089 | 7165 | |
---|
7090 | | - hitSomething = 0; |
---|
| 7166 | + hitSomething = -1; |
---|
7091 | 7167 | cVector origin = new cVector(); |
---|
7092 | 7168 | //LA.xformPos(origin, toParent, origin); |
---|
7093 | 7169 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7120 | 7196 | } |
---|
7121 | 7197 | |
---|
7122 | 7198 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
7123 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7199 | + modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
7124 | 7200 | //System.out.println("modified = " + modified); |
---|
7125 | 7201 | //new Exception().printStackTrace(); |
---|
7126 | 7202 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
7148 | 7224 | return true; |
---|
7149 | 7225 | } |
---|
7150 | 7226 | |
---|
7151 | | - void doEditDrag0(ClickInfo info) |
---|
| 7227 | + void doEditDrag0(ClickInfo info, boolean opposite) |
---|
7152 | 7228 | { |
---|
7153 | 7229 | if (hitSomething == 0) |
---|
7154 | 7230 | { |
---|
.. | .. |
---|
7163 | 7239 | //System.out.println("hitSomething = " + hitSomething); |
---|
7164 | 7240 | |
---|
7165 | 7241 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7242 | + |
---|
7166 | 7243 | cVector xlate = new cVector(); |
---|
7167 | 7244 | //cVector xlate2 = new cVector(); |
---|
7168 | 7245 | switch (hitSomething) |
---|
.. | .. |
---|
7173 | 7250 | |
---|
7174 | 7251 | case hitCenter: // Translate |
---|
7175 | 7252 | |
---|
7176 | | - scale *= 0.05f * info.pane.theRenderer.renderCamera.Distance(); |
---|
| 7253 | + scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
7177 | 7254 | |
---|
7178 | | - if (modified) |
---|
| 7255 | + if (modified || opposite) |
---|
7179 | 7256 | { |
---|
7180 | 7257 | //assert(false); |
---|
7181 | 7258 | /* |
---|
.. | .. |
---|
7221 | 7298 | } |
---|
7222 | 7299 | LA.xformDir(up, ClickInfo.matbuffer, up); |
---|
7223 | 7300 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7224 | | - LA.xformDir(up, info.pane.theRenderer.renderCamera.toScreen, up); |
---|
| 7301 | + LA.xformDir(up, Globals.theRenderer.RenderCamera().toScreen, up); |
---|
7225 | 7302 | LA.xformDir(info.camera.away, ClickInfo.matbuffer, away); |
---|
7226 | 7303 | // if (!CameraPane.LOCALTRANSFORM) |
---|
7227 | | - LA.xformDir(away, info.pane.theRenderer.renderCamera.toScreen, away); |
---|
| 7304 | + LA.xformDir(away, Globals.theRenderer.RenderCamera().toScreen, away); |
---|
7228 | 7305 | //LA.vecCross(up, cVector.Z, right2); |
---|
7229 | 7306 | |
---|
7230 | 7307 | cVector delta = LA.newVector(info.x - startX, startY - info.y, 0); |
---|
.. | .. |
---|
7269 | 7346 | |
---|
7270 | 7347 | if (modified) |
---|
7271 | 7348 | { |
---|
| 7349 | + // Rotate 90 degrees |
---|
7272 | 7350 | angle /= (Math.PI / 4); |
---|
7273 | 7351 | angle = Math.floor(angle + 0.5); |
---|
7274 | 7352 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7282 | 7360 | } |
---|
7283 | 7361 | /**/ |
---|
7284 | 7362 | |
---|
7285 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7363 | + switch (info.pane.RenderCamera().viewCode) |
---|
7286 | 7364 | { |
---|
7287 | 7365 | case 1: // '\001' |
---|
7288 | 7366 | LA.matZRotate(toParent, angle); |
---|
.. | .. |
---|
7310 | 7388 | |
---|
7311 | 7389 | case hitScale: // scale |
---|
7312 | 7390 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7391 | + double sign = 1; |
---|
| 7392 | + if (hScale < 0) |
---|
| 7393 | + { |
---|
| 7394 | + sign = -1; |
---|
| 7395 | + } |
---|
| 7396 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7313 | 7397 | if (hScale < 0.01) |
---|
7314 | 7398 | { |
---|
7315 | | - hScale = 0.01; |
---|
| 7399 | + //hScale = 0.01; |
---|
7316 | 7400 | } |
---|
7317 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7318 | | - if (hScale < 0.01) |
---|
7319 | | - { |
---|
7320 | | - hScale = 0.01; |
---|
7321 | | - } |
---|
| 7401 | + |
---|
7322 | 7402 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7323 | | - if (vScale < 0.01) |
---|
| 7403 | + sign = 1; |
---|
| 7404 | + if (vScale < 0) |
---|
7324 | 7405 | { |
---|
7325 | | - vScale = 0.01; |
---|
| 7406 | + sign = -1; |
---|
7326 | 7407 | } |
---|
7327 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7408 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7328 | 7409 | if (vScale < 0.01) |
---|
7329 | 7410 | { |
---|
7330 | | - vScale = 0.01; |
---|
| 7411 | + //vScale = 0.01; |
---|
7331 | 7412 | } |
---|
7332 | 7413 | LA.matCopy(startMat, toParent); |
---|
7333 | 7414 | /**/ |
---|
.. | .. |
---|
7338 | 7419 | } |
---|
7339 | 7420 | /**/ |
---|
7340 | 7421 | |
---|
7341 | | - switch (info.pane.renderCamera.viewCode) |
---|
| 7422 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7423 | + |
---|
| 7424 | + if (totalScale < 0.01) |
---|
| 7425 | + { |
---|
| 7426 | + totalScale = 0.01; |
---|
| 7427 | + } |
---|
| 7428 | + |
---|
| 7429 | + switch (info.pane.RenderCamera().viewCode) |
---|
7342 | 7430 | { |
---|
7343 | 7431 | case 3: // '\001' |
---|
7344 | 7432 | if (modified) |
---|
7345 | 7433 | { |
---|
7346 | 7434 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7347 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7435 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7348 | 7436 | } // vScale, 1); |
---|
7349 | 7437 | else |
---|
7350 | 7438 | { |
---|
7351 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7439 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7352 | 7440 | } // vScale, 1); |
---|
7353 | 7441 | break; |
---|
7354 | 7442 | |
---|
.. | .. |
---|
7356 | 7444 | if (modified) |
---|
7357 | 7445 | { |
---|
7358 | 7446 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7359 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7447 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7360 | 7448 | } else |
---|
7361 | 7449 | { |
---|
7362 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7450 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7363 | 7451 | } |
---|
7364 | 7452 | break; |
---|
7365 | 7453 | |
---|
.. | .. |
---|
7367 | 7455 | if (modified) |
---|
7368 | 7456 | { |
---|
7369 | 7457 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7370 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7458 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7371 | 7459 | } else |
---|
7372 | 7460 | { |
---|
7373 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7461 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7374 | 7462 | } |
---|
7375 | 7463 | break; |
---|
7376 | 7464 | } |
---|
.. | .. |
---|
7503 | 7591 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7504 | 7592 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7505 | 7593 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7594 | + |
---|
| 7595 | + String objname; |
---|
| 7596 | + |
---|
7506 | 7597 | if (false) //parent != null) |
---|
7507 | 7598 | { |
---|
7508 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7599 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7509 | 7600 | } else |
---|
7510 | 7601 | { |
---|
7511 | | - return GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ") ")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ +System.identityHashCode(this); |
---|
| 7602 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7512 | 7603 | } // + super.toString(); |
---|
7513 | 7604 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
| 7605 | + |
---|
| 7606 | + if (!Globals.ADVANCED) |
---|
| 7607 | + return objname; |
---|
| 7608 | + |
---|
| 7609 | + return objname + " " + System.identityHashCode(this); |
---|
7514 | 7610 | } |
---|
7515 | 7611 | |
---|
7516 | 7612 | public int hashCode() |
---|
.. | .. |
---|
7566 | 7662 | objectUI.closeUI(); |
---|
7567 | 7663 | if (editWindow != null) |
---|
7568 | 7664 | { |
---|
| 7665 | + editWindow.ctrlPanel.FlushUI(); |
---|
7569 | 7666 | editWindow.refreshContents(); |
---|
7570 | 7667 | } // ? new |
---|
7571 | 7668 | objectUI = null; |
---|
.. | .. |
---|
7586 | 7683 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7587 | 7684 | |
---|
7588 | 7685 | Object3D /*Composite*/ parent; |
---|
7589 | | - Object3D /*Composite*/ fileparent; |
---|
| 7686 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7590 | 7687 | |
---|
7591 | 7688 | double[][] toParent; // dynamic matrix |
---|
7592 | 7689 | double[][] fromParent; |
---|
.. | .. |
---|
7701 | 7798 | { |
---|
7702 | 7799 | assert(bRep != null); |
---|
7703 | 7800 | if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
7704 | | - GrafreeD.Assert(support.bRep == bRep.support); |
---|
| 7801 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
7705 | 7802 | } |
---|
7706 | 7803 | else |
---|
7707 | 7804 | { |
---|
.. | .. |
---|
7750 | 7847 | private static cVector edge2 = new cVector(); |
---|
7751 | 7848 | //private static cVector norm = new cVector(); |
---|
7752 | 7849 | /*transient private*/ int hitSomething; |
---|
7753 | | - private static final int hitCenter = 1; |
---|
7754 | | - private static final int hitScale = 2; |
---|
7755 | | - private static final int hitRotate = 3; |
---|
| 7850 | + static final int hitCenter = 1; |
---|
| 7851 | + static final int hitScale = 2; |
---|
| 7852 | + static final int hitRotate = 3; |
---|
7756 | 7853 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7757 | 7854 | /*transient*/ private Point centerPt; |
---|
7758 | 7855 | /*transient*/ private int startX; |
---|