.. | .. |
---|
14 | 14 | import //weka.core. |
---|
15 | 15 | matrix.Matrix; |
---|
16 | 16 | |
---|
| 17 | +import java.util.UUID; |
---|
| 18 | + |
---|
17 | 19 | //import net.sourceforge.sizeof.SizeOf; |
---|
18 | 20 | public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> |
---|
19 | 21 | { |
---|
20 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
21 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
| 24 | + |
---|
| 25 | + private UUID uuid = UUID.randomUUID(); |
---|
| 26 | + |
---|
| 27 | + // TEMPORARY for mocap undo |
---|
| 28 | + mocap.reader.BVHReader.BVHResult bvh; |
---|
| 29 | + Object3D skeleton; |
---|
| 30 | + // |
---|
22 | 31 | |
---|
23 | 32 | ScriptNode scriptnode; |
---|
24 | 33 | |
---|
.. | .. |
---|
100 | 109 | |
---|
101 | 110 | // transient boolean reduced; // for morph reduction |
---|
102 | 111 | |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
104 | | -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 |
---|
105 | 114 | |
---|
106 | | -transient Object3D transientsupport; // for cloning |
---|
107 | | -transient boolean transientlink2master; |
---|
| 115 | + transient Object3D transientsupport; // for cloning |
---|
| 116 | + transient boolean transientlink2master; |
---|
108 | 117 | |
---|
109 | | -void SaveSupports() |
---|
110 | | -{ |
---|
111 | | - if (blockloop) |
---|
112 | | - return; |
---|
113 | | - |
---|
114 | | - transientsupport = support; |
---|
115 | | - transientlink2master = link2master; |
---|
116 | | - |
---|
117 | | - support = null; |
---|
118 | | - link2master = false; |
---|
119 | | - |
---|
120 | | - if (bRep != null) |
---|
| 118 | + void SaveSupports() |
---|
121 | 119 | { |
---|
122 | | - bRep.SaveSupports(); |
---|
123 | | - } |
---|
124 | | - |
---|
125 | | - for (int i = 0; i < Size(); i++) |
---|
126 | | - { |
---|
127 | | - Object3D child = (Object3D) get(i); |
---|
128 | | - if (child == null) |
---|
129 | | - continue; |
---|
130 | | - blockloop = true; |
---|
131 | | - child.SaveSupports(); |
---|
132 | | - blockloop = false; |
---|
133 | | - } |
---|
134 | | -} |
---|
| 120 | + if (blockloop) |
---|
| 121 | + return; |
---|
135 | 122 | |
---|
136 | | -void RestoreSupports() |
---|
137 | | -{ |
---|
138 | | - if (blockloop) |
---|
139 | | - return; |
---|
| 123 | + transientsupport = support; |
---|
| 124 | + transientlink2master = link2master; |
---|
140 | 125 | |
---|
141 | | - support = transientsupport; |
---|
142 | | - link2master = transientlink2master; |
---|
143 | | - transientsupport = null; |
---|
144 | | - transientlink2master = false; |
---|
145 | | - |
---|
146 | | - if (bRep != null) |
---|
147 | | - { |
---|
148 | | - 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 | + } |
---|
149 | 143 | } |
---|
150 | | - |
---|
151 | | - for (int i = 0; i < Size(); i++) |
---|
| 144 | + |
---|
| 145 | + void RestoreSupports() |
---|
152 | 146 | { |
---|
153 | | - Object3D child = (Object3D) get(i); |
---|
154 | | - if (child == null) |
---|
155 | | - continue; |
---|
156 | | - blockloop = true; |
---|
157 | | - child.RestoreSupports(); |
---|
158 | | - 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 | + } |
---|
159 | 169 | } |
---|
160 | | -} |
---|
| 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 | + } |
---|
161 | 242 | |
---|
162 | 243 | // MOCAP SUPPORT |
---|
163 | 244 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
300 | 381 | } |
---|
301 | 382 | |
---|
302 | 383 | boolean live = false; |
---|
| 384 | + boolean dontselect = false; |
---|
303 | 385 | boolean hide = false; |
---|
304 | 386 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 387 | boolean marked = false; // animation node |
---|
.. | .. |
---|
774 | 856 | if (step == 0) |
---|
775 | 857 | step = 1; |
---|
776 | 858 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 859 | + maxcount = 128; // 2048; // 4; |
---|
778 | 860 | // if (acceleration == 0) |
---|
779 | 861 | // acceleration = 10; |
---|
780 | 862 | if (delay == 0) // serial |
---|
.. | .. |
---|
797 | 879 | |
---|
798 | 880 | if (marked && Globals.isLIVE() && live && |
---|
799 | 881 | //TEMP21aug2018 |
---|
800 | | - Globals.DrawMode() == iCameraPane.SHADOW && |
---|
| 882 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
801 | 883 | currentframe != Globals.framecount) |
---|
802 | 884 | { |
---|
803 | 885 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
912 | 994 | fromParent = null; // LA.newMatrix(); |
---|
913 | 995 | bRep = null; // new BoundaryRep(); |
---|
914 | 996 | |
---|
| 997 | + if (oname != null && oname.equals("LeftHand")) |
---|
| 998 | + { |
---|
| 999 | + name = oname; |
---|
| 1000 | + } |
---|
| 1001 | + |
---|
915 | 1002 | /* |
---|
916 | 1003 | float hue = (float)Math.random(); |
---|
917 | 1004 | Color col; |
---|
.. | .. |
---|
954 | 1041 | |
---|
955 | 1042 | public Object clone() |
---|
956 | 1043 | { |
---|
957 | | - return GrafreeD.clone(this); |
---|
| 1044 | + return Grafreed.clone(this); |
---|
958 | 1045 | } |
---|
959 | 1046 | |
---|
960 | 1047 | Object3D copyExpand() |
---|
.. | .. |
---|
1470 | 1557 | BoundaryRep.SEUIL = other.material.cameralight; |
---|
1471 | 1558 | |
---|
1472 | 1559 | // Set default to 0.1 |
---|
1473 | | - BoundaryRep.SEUIL /= 2; |
---|
| 1560 | + BoundaryRep.SEUIL /= 4; // 2; |
---|
1474 | 1561 | System.out.println("SEUIL = " + BoundaryRep.SEUIL); |
---|
1475 | 1562 | } |
---|
1476 | 1563 | |
---|
.. | .. |
---|
1729 | 1816 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1730 | 1817 | o.bRep = transientrep; |
---|
1731 | 1818 | if (clone) |
---|
1732 | | - o.bRep = (BoundaryRep) GrafreeD.clone(transientrep); |
---|
| 1819 | + o.bRep = (BoundaryRep) Grafreed.clone(transientrep); |
---|
1733 | 1820 | o.CreateMaterial(); |
---|
1734 | 1821 | o.SetAttributes(this, -1); |
---|
1735 | 1822 | //parent |
---|
.. | .. |
---|
1742 | 1829 | Object3D o = new Object3D((clone?"Ge:":"Li:") + this.name); |
---|
1743 | 1830 | o.bRep = bRep; |
---|
1744 | 1831 | if (clone) |
---|
1745 | | - o.bRep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 1832 | + o.bRep = (BoundaryRep) Grafreed.clone(bRep); |
---|
1746 | 1833 | o.CreateMaterial(); |
---|
1747 | 1834 | //o.overwriteThis(this, -1); |
---|
1748 | 1835 | o.SetAttributes(this, -1); |
---|
.. | .. |
---|
1829 | 1916 | if (obj.name == null) |
---|
1830 | 1917 | continue; // can't be a null one |
---|
1831 | 1918 | |
---|
| 1919 | + // Try perfect match first. |
---|
1832 | 1920 | if (n.equals(obj.name)) |
---|
1833 | 1921 | { |
---|
1834 | 1922 | theobj = obj; |
---|
1835 | 1923 | count++; |
---|
1836 | 1924 | } |
---|
1837 | 1925 | } |
---|
| 1926 | + |
---|
| 1927 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1838 | 1928 | |
---|
1839 | 1929 | if (count != 1) |
---|
1840 | 1930 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2477 | 2567 | return retval; |
---|
2478 | 2568 | } |
---|
2479 | 2569 | |
---|
2480 | | - void doEditDrag(ClickInfo info) |
---|
| 2570 | + void doEditDrag(ClickInfo info, boolean opposite) |
---|
2481 | 2571 | { |
---|
2482 | 2572 | switch (doSomething) |
---|
2483 | 2573 | { |
---|
2484 | 2574 | case 1: // '\001' |
---|
2485 | 2575 | //super. |
---|
2486 | | - doEditDrag0(info); |
---|
| 2576 | + doEditDrag0(info, opposite); |
---|
2487 | 2577 | break; |
---|
2488 | 2578 | |
---|
2489 | 2579 | case 2: // '\002' |
---|
.. | .. |
---|
2496 | 2586 | { |
---|
2497 | 2587 | //sel.hitSomething = childToDrag.hitSomething; |
---|
2498 | 2588 | //childToDrag.doEditDrag(info); |
---|
2499 | | - sel.doEditDrag(info); |
---|
| 2589 | + sel.doEditDrag(info, opposite); |
---|
2500 | 2590 | } else |
---|
2501 | 2591 | { |
---|
2502 | 2592 | //super. |
---|
2503 | | - doEditDrag0(info); |
---|
| 2593 | + doEditDrag0(info, opposite); |
---|
2504 | 2594 | } |
---|
2505 | 2595 | } |
---|
2506 | 2596 | break; |
---|
.. | .. |
---|
2610 | 2700 | void GenNormalsS(boolean crease) |
---|
2611 | 2701 | { |
---|
2612 | 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(); |
---|
2613 | 2715 | // for (int i=0; i<selection.size(); i++) |
---|
2614 | 2716 | // { |
---|
2615 | 2717 | // Object3D selectee = (Object3D) selection.elementAt(i); |
---|
.. | .. |
---|
2750 | 2852 | if (child == null) |
---|
2751 | 2853 | continue; |
---|
2752 | 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(); |
---|
2753 | 2873 | // Children().release(i); |
---|
2754 | 2874 | } |
---|
2755 | 2875 | blockloop = false; |
---|
.. | .. |
---|
2922 | 3042 | } |
---|
2923 | 3043 | } |
---|
2924 | 3044 | |
---|
| 3045 | + void GenNormalsMesh0() |
---|
| 3046 | + { |
---|
| 3047 | + if (bRep != null) |
---|
| 3048 | + { |
---|
| 3049 | + bRep.GenerateNormalsMesh(); |
---|
| 3050 | + Touch(); |
---|
| 3051 | + } |
---|
| 3052 | + } |
---|
| 3053 | + |
---|
2925 | 3054 | void GenNormalsMINE0() |
---|
2926 | 3055 | { |
---|
2927 | 3056 | if (bRep != null) |
---|
.. | .. |
---|
2983 | 3112 | blockloop = false; |
---|
2984 | 3113 | } |
---|
2985 | 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 | + |
---|
2986 | 3142 | void TransformGeometry() |
---|
2987 | 3143 | { |
---|
2988 | 3144 | Object3D obj = this; |
---|
.. | .. |
---|
3204 | 3360 | |
---|
3205 | 3361 | BoundaryRep sup = bRep.support; |
---|
3206 | 3362 | bRep.support = null; |
---|
3207 | | - BoundaryRep temprep = (BoundaryRep) GrafreeD.clone(bRep); |
---|
| 3363 | + BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3208 | 3364 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3209 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3365 | + |
---|
| 3366 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3367 | + |
---|
3210 | 3368 | bRep = temprep; |
---|
3211 | 3369 | bRep.support = sup; |
---|
3212 | 3370 | Touch(); |
---|
.. | .. |
---|
3728 | 3886 | if (child == null) |
---|
3729 | 3887 | continue; |
---|
3730 | 3888 | |
---|
3731 | | - if (GrafreeD.RENDERME > 0) |
---|
| 3889 | + if (Grafreed.RENDERME > 0) |
---|
3732 | 3890 | { |
---|
3733 | 3891 | if (child instanceof Merge) |
---|
3734 | 3892 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
3879 | 4037 | if (child == null) |
---|
3880 | 4038 | continue; |
---|
3881 | 4039 | |
---|
3882 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4040 | + if (Grafreed.RENDERME > 0) |
---|
3883 | 4041 | { |
---|
3884 | 4042 | if (child instanceof Merge) |
---|
3885 | 4043 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4074 | 4232 | if (child == null) |
---|
4075 | 4233 | continue; |
---|
4076 | 4234 | |
---|
4077 | | - if (GrafreeD.RENDERME > 0) |
---|
| 4235 | + if (Grafreed.RENDERME > 0) |
---|
4078 | 4236 | { |
---|
4079 | 4237 | if (child instanceof Merge) |
---|
4080 | 4238 | ((Merge)child).renderme(); |
---|
.. | .. |
---|
4681 | 4839 | |
---|
4682 | 4840 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4683 | 4841 | { |
---|
4684 | | - if (hide) |
---|
| 4842 | + if (hide || dontselect) |
---|
4685 | 4843 | return null; |
---|
4686 | 4844 | |
---|
4687 | 4845 | if (count <= 0) |
---|
.. | .. |
---|
4707 | 4865 | |
---|
4708 | 4866 | cTreePath Select(int indexcount, boolean deselect) |
---|
4709 | 4867 | { |
---|
4710 | | - if (hide) |
---|
| 4868 | + if (hide || dontselect) |
---|
4711 | 4869 | return null; |
---|
4712 | 4870 | |
---|
4713 | 4871 | if (count <= 0) |
---|
.. | .. |
---|
5159 | 5317 | |
---|
5160 | 5318 | // System.out.println("Fullname = " + fullname); |
---|
5161 | 5319 | |
---|
5162 | | - if (fullname.name.indexOf(":") == -1) |
---|
5163 | | - 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(":")); |
---|
5164 | 5325 | |
---|
5165 | | - 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]; |
---|
5166 | 5348 | } |
---|
5167 | 5349 | |
---|
5168 | 5350 | static String GetBump(cTexture fullname) |
---|
.. | .. |
---|
5171 | 5353 | return ""; |
---|
5172 | 5354 | |
---|
5173 | 5355 | // System.out.println("Fullname = " + fullname); |
---|
5174 | | - if (fullname.name.indexOf(":") == -1) |
---|
5175 | | - return ""; |
---|
5176 | | - |
---|
5177 | | - 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]; |
---|
5178 | 5388 | } |
---|
5179 | 5389 | |
---|
5180 | 5390 | String GetPigmentTexture() |
---|
.. | .. |
---|
5248 | 5458 | System.out.print("; textures = " + textures); |
---|
5249 | 5459 | System.out.println("; usedtextures = " + usedtextures); |
---|
5250 | 5460 | |
---|
5251 | | - if (GetTextures() == null) |
---|
| 5461 | + if (GetTextures() == null) // What is that?? |
---|
5252 | 5462 | GetTextures().name = ":"; |
---|
5253 | 5463 | |
---|
5254 | 5464 | String texname = tex; |
---|
.. | .. |
---|
5279 | 5489 | child.ResetPigmentTexture(); |
---|
5280 | 5490 | blockloop = false; |
---|
5281 | 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; |
---|
5282 | 5529 | } |
---|
5283 | 5530 | |
---|
5284 | 5531 | void SetBumpTexture(String tex) |
---|
.. | .. |
---|
5325 | 5572 | boolean NeedSupport() |
---|
5326 | 5573 | { |
---|
5327 | 5574 | return |
---|
5328 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5575 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
5329 | 5576 | // PROBLEM with CROWD!! |
---|
5330 | | - && (Globals.DrawMode() == iCameraPane.SHADOW || Globals.CROWD); |
---|
| 5577 | + && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5331 | 5578 | } |
---|
5332 | 5579 | |
---|
5333 | 5580 | static boolean DEBUG_SELECTION = false; |
---|
.. | .. |
---|
5342 | 5589 | } |
---|
5343 | 5590 | |
---|
5344 | 5591 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5345 | | - hide) |
---|
| 5592 | + (hide || dontselect)) |
---|
5346 | 5593 | return; |
---|
5347 | 5594 | |
---|
5348 | 5595 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5584 | 5831 | tex = GetTextures(); |
---|
5585 | 5832 | } |
---|
5586 | 5833 | |
---|
5587 | | - 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 | + } |
---|
5588 | 5845 | |
---|
5589 | 5846 | if (!compiled) |
---|
5590 | 5847 | { |
---|
.. | .. |
---|
5606 | 5863 | } |
---|
5607 | 5864 | } |
---|
5608 | 5865 | |
---|
5609 | | - display.ReleaseTextures(tex); |
---|
| 5866 | + if (!failed) |
---|
| 5867 | + display.ReleaseTextures(tex); |
---|
5610 | 5868 | |
---|
5611 | 5869 | display.PopMaterial(this, selected); |
---|
5612 | 5870 | } |
---|
.. | .. |
---|
5735 | 5993 | |
---|
5736 | 5994 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5737 | 5995 | { |
---|
| 5996 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 5997 | + return; |
---|
| 5998 | + |
---|
5738 | 5999 | if (hide) |
---|
5739 | 6000 | return; |
---|
5740 | 6001 | // shadow optimisation |
---|
.. | .. |
---|
5859 | 6120 | { |
---|
5860 | 6121 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5861 | 6122 | return; // no shadow for transparent objects |
---|
| 6123 | + |
---|
| 6124 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6125 | + return; |
---|
5862 | 6126 | |
---|
5863 | 6127 | if (hide) |
---|
5864 | 6128 | return; |
---|
.. | .. |
---|
6843 | 7107 | // { |
---|
6844 | 7108 | // CameraPane.Ymax = spoth; |
---|
6845 | 7109 | // } |
---|
6846 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6847 | | - 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); |
---|
6848 | 7112 | spot.translate(0, -32); |
---|
6849 | 7113 | info.g.setColor(Color.green); |
---|
6850 | 7114 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
.. | .. |
---|
6899 | 7163 | startX = info.x; |
---|
6900 | 7164 | startY = info.y; |
---|
6901 | 7165 | |
---|
6902 | | - hitSomething = 0; |
---|
| 7166 | + hitSomething = -1; |
---|
6903 | 7167 | cVector origin = new cVector(); |
---|
6904 | 7168 | //LA.xformPos(origin, toParent, origin); |
---|
6905 | 7169 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
6932 | 7196 | } |
---|
6933 | 7197 | |
---|
6934 | 7198 | //System.out.println("info.modifiers = " + info.modifiers); |
---|
6935 | | - modified = (info.modifiers & CameraPane.META) != 0; |
---|
| 7199 | + modified = (info.modifiers & CameraPane.SHIFT) != 0; // Was META |
---|
6936 | 7200 | //System.out.println("modified = " + modified); |
---|
6937 | 7201 | //new Exception().printStackTrace(); |
---|
6938 | 7202 | //viewCode = info.pane.renderCamera.viewCode; |
---|
.. | .. |
---|
6960 | 7224 | return true; |
---|
6961 | 7225 | } |
---|
6962 | 7226 | |
---|
6963 | | - void doEditDrag0(ClickInfo info) |
---|
| 7227 | + void doEditDrag0(ClickInfo info, boolean opposite) |
---|
6964 | 7228 | { |
---|
6965 | 7229 | if (hitSomething == 0) |
---|
6966 | 7230 | { |
---|
.. | .. |
---|
6975 | 7239 | //System.out.println("hitSomething = " + hitSomething); |
---|
6976 | 7240 | |
---|
6977 | 7241 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7242 | + |
---|
6978 | 7243 | cVector xlate = new cVector(); |
---|
6979 | 7244 | //cVector xlate2 = new cVector(); |
---|
6980 | 7245 | switch (hitSomething) |
---|
.. | .. |
---|
6987 | 7252 | |
---|
6988 | 7253 | scale *= 0.05f * Globals.theRenderer.RenderCamera().Distance(); |
---|
6989 | 7254 | |
---|
6990 | | - if (modified) |
---|
| 7255 | + if (modified || opposite) |
---|
6991 | 7256 | { |
---|
6992 | 7257 | //assert(false); |
---|
6993 | 7258 | /* |
---|
.. | .. |
---|
7081 | 7346 | |
---|
7082 | 7347 | if (modified) |
---|
7083 | 7348 | { |
---|
| 7349 | + // Rotate 90 degrees |
---|
7084 | 7350 | angle /= (Math.PI / 4); |
---|
7085 | 7351 | angle = Math.floor(angle + 0.5); |
---|
7086 | 7352 | angle *= (Math.PI / 4); |
---|
.. | .. |
---|
7122 | 7388 | |
---|
7123 | 7389 | case hitScale: // scale |
---|
7124 | 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); |
---|
7125 | 7397 | if (hScale < 0.01) |
---|
7126 | 7398 | { |
---|
7127 | | - hScale = 0.01; |
---|
| 7399 | + //hScale = 0.01; |
---|
7128 | 7400 | } |
---|
7129 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7130 | | - if (hScale < 0.01) |
---|
7131 | | - { |
---|
7132 | | - hScale = 0.01; |
---|
7133 | | - } |
---|
| 7401 | + |
---|
7134 | 7402 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7135 | | - if (vScale < 0.01) |
---|
| 7403 | + sign = 1; |
---|
| 7404 | + if (vScale < 0) |
---|
7136 | 7405 | { |
---|
7137 | | - vScale = 0.01; |
---|
| 7406 | + sign = -1; |
---|
7138 | 7407 | } |
---|
7139 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7408 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7140 | 7409 | if (vScale < 0.01) |
---|
7141 | 7410 | { |
---|
7142 | | - vScale = 0.01; |
---|
| 7411 | + //vScale = 0.01; |
---|
7143 | 7412 | } |
---|
7144 | 7413 | LA.matCopy(startMat, toParent); |
---|
7145 | 7414 | /**/ |
---|
.. | .. |
---|
7150 | 7419 | } |
---|
7151 | 7420 | /**/ |
---|
7152 | 7421 | |
---|
| 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 | + |
---|
7153 | 7429 | switch (info.pane.RenderCamera().viewCode) |
---|
7154 | 7430 | { |
---|
7155 | 7431 | case 3: // '\001' |
---|
7156 | 7432 | if (modified) |
---|
7157 | 7433 | { |
---|
7158 | 7434 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7159 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7435 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7160 | 7436 | } // vScale, 1); |
---|
7161 | 7437 | else |
---|
7162 | 7438 | { |
---|
7163 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7439 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7164 | 7440 | } // vScale, 1); |
---|
7165 | 7441 | break; |
---|
7166 | 7442 | |
---|
.. | .. |
---|
7168 | 7444 | if (modified) |
---|
7169 | 7445 | { |
---|
7170 | 7446 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7171 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7447 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7172 | 7448 | } else |
---|
7173 | 7449 | { |
---|
7174 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7450 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7175 | 7451 | } |
---|
7176 | 7452 | break; |
---|
7177 | 7453 | |
---|
.. | .. |
---|
7179 | 7455 | if (modified) |
---|
7180 | 7456 | { |
---|
7181 | 7457 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7182 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7458 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7183 | 7459 | } else |
---|
7184 | 7460 | { |
---|
7185 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7461 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7186 | 7462 | } |
---|
7187 | 7463 | break; |
---|
7188 | 7464 | } |
---|
.. | .. |
---|
7315 | 7591 | //return super.toString() + " (id=" + list + ")" + " (brep=" + bRep + ")"; |
---|
7316 | 7592 | //return name + " (id=" + list + ")" + " (brep=" + bRep + ") " + super.toString(); |
---|
7317 | 7593 | //return name + " (#tri = " + (bRep==null?0:bRep.VertexCount()) + ") " + super.toString(); |
---|
| 7594 | + |
---|
| 7595 | + String objname; |
---|
| 7596 | + |
---|
7318 | 7597 | if (false) //parent != null) |
---|
7319 | 7598 | { |
---|
7320 | | - return name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
| 7599 | + objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7321 | 7600 | } else |
---|
7322 | 7601 | { |
---|
7323 | | - 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) ":"") */ ""; |
---|
7324 | 7603 | } // + super.toString(); |
---|
7325 | 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); |
---|
7326 | 7610 | } |
---|
7327 | 7611 | |
---|
7328 | 7612 | public int hashCode() |
---|
.. | .. |
---|
7378 | 7662 | objectUI.closeUI(); |
---|
7379 | 7663 | if (editWindow != null) |
---|
7380 | 7664 | { |
---|
| 7665 | + editWindow.ctrlPanel.FlushUI(); |
---|
7381 | 7666 | editWindow.refreshContents(); |
---|
7382 | 7667 | } // ? new |
---|
7383 | 7668 | objectUI = null; |
---|
.. | .. |
---|
7398 | 7683 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7399 | 7684 | |
---|
7400 | 7685 | Object3D /*Composite*/ parent; |
---|
7401 | | - Object3D /*Composite*/ fileparent; |
---|
| 7686 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7402 | 7687 | |
---|
7403 | 7688 | double[][] toParent; // dynamic matrix |
---|
7404 | 7689 | double[][] fromParent; |
---|
.. | .. |
---|
7513 | 7798 | { |
---|
7514 | 7799 | assert(bRep != null); |
---|
7515 | 7800 | if (!(support instanceof GenericJoint)) // support.bRep != null) |
---|
7516 | | - GrafreeD.Assert(support.bRep == bRep.support); |
---|
| 7801 | + Grafreed.Assert(support.bRep == bRep.support); |
---|
7517 | 7802 | } |
---|
7518 | 7803 | else |
---|
7519 | 7804 | { |
---|
.. | .. |
---|
7562 | 7847 | private static cVector edge2 = new cVector(); |
---|
7563 | 7848 | //private static cVector norm = new cVector(); |
---|
7564 | 7849 | /*transient private*/ int hitSomething; |
---|
7565 | | - private static final int hitCenter = 1; |
---|
7566 | | - private static final int hitScale = 2; |
---|
7567 | | - private static final int hitRotate = 3; |
---|
| 7850 | + static final int hitCenter = 1; |
---|
| 7851 | + static final int hitScale = 2; |
---|
| 7852 | + static final int hitRotate = 3; |
---|
7568 | 7853 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7569 | 7854 | /*transient*/ private Point centerPt; |
---|
7570 | 7855 | /*transient*/ private int startX; |
---|