.. | .. |
---|
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(); |
---|
| 120 | + if (blockloop) |
---|
| 121 | + return; |
---|
| 122 | + |
---|
| 123 | + transientsupport = support; |
---|
| 124 | + transientlink2master = link2master; |
---|
| 125 | + |
---|
| 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 | + } |
---|
123 | 143 | } |
---|
124 | | - |
---|
125 | | - for (int i = 0; i < Size(); i++) |
---|
| 144 | + |
---|
| 145 | + void RestoreSupports() |
---|
126 | 146 | { |
---|
127 | | - Object3D child = (Object3D) get(i); |
---|
128 | | - if (child == null) |
---|
129 | | - continue; |
---|
| 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 | + } |
---|
| 169 | + } |
---|
| 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("copy of " + this.name); |
---|
| 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 | + if (blockloop) |
---|
| 223 | + return; |
---|
| 224 | + |
---|
130 | 225 | blockloop = true; |
---|
131 | | - child.SaveSupports(); |
---|
| 226 | + |
---|
| 227 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 228 | + |
---|
| 229 | + RestoreBigData(o); |
---|
| 230 | + |
---|
| 231 | + //hashtable.remove(GetUUID()); |
---|
| 232 | + |
---|
| 233 | + for (int i=0; i<Size(); i++) |
---|
| 234 | + { |
---|
| 235 | + get(i).RestoreBigData(hashtable); |
---|
| 236 | + } |
---|
| 237 | + |
---|
132 | 238 | blockloop = false; |
---|
133 | 239 | } |
---|
134 | | -} |
---|
135 | 240 | |
---|
136 | | -void RestoreSupports() |
---|
137 | | -{ |
---|
138 | | - if (blockloop) |
---|
139 | | - return; |
---|
140 | | - |
---|
141 | | - support = transientsupport; |
---|
142 | | - link2master = transientlink2master; |
---|
143 | | - transientsupport = null; |
---|
144 | | - transientlink2master = false; |
---|
145 | | - |
---|
146 | | - if (bRep != null) |
---|
| 241 | + void RestoreBigData(Object3D o) |
---|
147 | 242 | { |
---|
148 | | - bRep.RestoreSupports(); |
---|
| 243 | + this.bRep = o.bRep; |
---|
| 244 | + if (this.bRep != null) |
---|
| 245 | + this.bRep.support = o.transientrep; |
---|
| 246 | + // this.support = o.support; |
---|
| 247 | + // this.fileparent = o.fileparent; |
---|
149 | 248 | } |
---|
150 | | - |
---|
151 | | - for (int i = 0; i < Size(); i++) |
---|
152 | | - { |
---|
153 | | - Object3D child = (Object3D) get(i); |
---|
154 | | - if (child == null) |
---|
155 | | - continue; |
---|
156 | | - blockloop = true; |
---|
157 | | - child.RestoreSupports(); |
---|
158 | | - blockloop = false; |
---|
159 | | - } |
---|
160 | | -} |
---|
161 | 249 | |
---|
162 | 250 | // MOCAP SUPPORT |
---|
163 | 251 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
300 | 388 | } |
---|
301 | 389 | |
---|
302 | 390 | boolean live = false; |
---|
| 391 | + boolean dontselect = false; |
---|
303 | 392 | boolean hide = false; |
---|
304 | 393 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 394 | boolean marked = false; // animation node |
---|
.. | .. |
---|
481 | 570 | toParent = LA.newMatrix(); |
---|
482 | 571 | fromParent = LA.newMatrix(); |
---|
483 | 572 | } |
---|
| 573 | + |
---|
484 | 574 | if (toParentMarked == null) |
---|
485 | 575 | { |
---|
486 | 576 | if (maxcount != 1) |
---|
487 | 577 | { |
---|
488 | 578 | new Exception().printStackTrace(); |
---|
489 | 579 | } |
---|
| 580 | + |
---|
490 | 581 | toParentMarked = LA.newMatrix(); |
---|
491 | 582 | fromParentMarked = LA.newMatrix(); |
---|
492 | 583 | } |
---|
.. | .. |
---|
774 | 865 | if (step == 0) |
---|
775 | 866 | step = 1; |
---|
776 | 867 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 868 | + maxcount = 128; // 2048; // 4; |
---|
778 | 869 | // if (acceleration == 0) |
---|
779 | 870 | // acceleration = 10; |
---|
780 | 871 | if (delay == 0) // serial |
---|
.. | .. |
---|
797 | 888 | |
---|
798 | 889 | if (marked && Globals.isLIVE() && live && |
---|
799 | 890 | //TEMP21aug2018 |
---|
800 | | - (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
| 891 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
801 | 892 | currentframe != Globals.framecount) |
---|
802 | 893 | { |
---|
803 | 894 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
809 | 900 | |
---|
810 | 901 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
811 | 902 | |
---|
812 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 903 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 904 | + (step == 1 && changedir)) |
---|
813 | 905 | { |
---|
814 | 906 | countdown = 1; |
---|
815 | 907 | delay = speedup?8:1; |
---|
.. | .. |
---|
881 | 973 | if (material == null || material.multiply) |
---|
882 | 974 | return true; |
---|
883 | 975 | |
---|
| 976 | + // Transparent objects are dynamic because we have to sort the triangles. |
---|
884 | 977 | return material.opacity > 0.99; |
---|
885 | 978 | } |
---|
886 | 979 | |
---|
.. | .. |
---|
1834 | 1927 | if (obj.name == null) |
---|
1835 | 1928 | continue; // can't be a null one |
---|
1836 | 1929 | |
---|
| 1930 | + // Try perfect match first. |
---|
1837 | 1931 | if (n.equals(obj.name)) |
---|
1838 | 1932 | { |
---|
1839 | 1933 | theobj = obj; |
---|
1840 | 1934 | count++; |
---|
1841 | 1935 | } |
---|
1842 | 1936 | } |
---|
| 1937 | + |
---|
| 1938 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1843 | 1939 | |
---|
1844 | 1940 | if (count != 1) |
---|
1845 | 1941 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2299 | 2395 | } |
---|
2300 | 2396 | */ |
---|
2301 | 2397 | } |
---|
| 2398 | + else |
---|
| 2399 | + { |
---|
| 2400 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2401 | + } |
---|
2302 | 2402 | } |
---|
2303 | 2403 | |
---|
2304 | 2404 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
.. | .. |
---|
2340 | 2440 | { |
---|
2341 | 2441 | editWindow.refreshContents(); |
---|
2342 | 2442 | } |
---|
| 2443 | + else |
---|
| 2444 | + { |
---|
| 2445 | + if (manipWindow != null) |
---|
| 2446 | + { |
---|
| 2447 | + manipWindow.refreshContents(); |
---|
| 2448 | + } |
---|
| 2449 | + } |
---|
| 2450 | + |
---|
2343 | 2451 | //if (parent != null) |
---|
2344 | 2452 | //parent.refreshEditWindow(); |
---|
2345 | 2453 | } |
---|
.. | .. |
---|
2624 | 2732 | //Touch(); |
---|
2625 | 2733 | } |
---|
2626 | 2734 | |
---|
| 2735 | + void GenNormalsMeshS() |
---|
| 2736 | + { |
---|
| 2737 | + selection.GenNormalsMesh(); |
---|
| 2738 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2739 | +// { |
---|
| 2740 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2741 | +// selectee.GenNormals(crease); |
---|
| 2742 | +// } |
---|
| 2743 | + |
---|
| 2744 | + //Touch(); |
---|
| 2745 | + } |
---|
| 2746 | + |
---|
2627 | 2747 | void ClearColorsS() |
---|
2628 | 2748 | { |
---|
2629 | 2749 | selection.ClearColors(); |
---|
.. | .. |
---|
2755 | 2875 | if (child == null) |
---|
2756 | 2876 | continue; |
---|
2757 | 2877 | child.GenNormals(crease); |
---|
| 2878 | +// Children().release(i); |
---|
| 2879 | + } |
---|
| 2880 | + blockloop = false; |
---|
| 2881 | + } |
---|
| 2882 | + |
---|
| 2883 | + void GenNormalsMesh() |
---|
| 2884 | + { |
---|
| 2885 | + if (blockloop) |
---|
| 2886 | + return; |
---|
| 2887 | + |
---|
| 2888 | + blockloop = true; |
---|
| 2889 | + GenNormalsMesh0(); |
---|
| 2890 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2891 | + { |
---|
| 2892 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2893 | + if (child == null) |
---|
| 2894 | + continue; |
---|
| 2895 | + child.GenNormalsMesh(); |
---|
2758 | 2896 | // Children().release(i); |
---|
2759 | 2897 | } |
---|
2760 | 2898 | blockloop = false; |
---|
.. | .. |
---|
2927 | 3065 | } |
---|
2928 | 3066 | } |
---|
2929 | 3067 | |
---|
| 3068 | + void GenNormalsMesh0() |
---|
| 3069 | + { |
---|
| 3070 | + if (bRep != null) |
---|
| 3071 | + { |
---|
| 3072 | + bRep.GenerateNormalsMesh(); |
---|
| 3073 | + Touch(); |
---|
| 3074 | + } |
---|
| 3075 | + } |
---|
| 3076 | + |
---|
2930 | 3077 | void GenNormalsMINE0() |
---|
2931 | 3078 | { |
---|
2932 | 3079 | if (bRep != null) |
---|
.. | .. |
---|
3002 | 3149 | v.fromParent = LA.newMatrix(); |
---|
3003 | 3150 | } |
---|
3004 | 3151 | |
---|
3005 | | - LA.matConcat(v.toParent, toParent, v.toParent); |
---|
3006 | | - LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3152 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3153 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3154 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3155 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
3007 | 3156 | } |
---|
3008 | 3157 | |
---|
3009 | 3158 | toParent = null; // LA.matIdentity(toParent); |
---|
.. | .. |
---|
3236 | 3385 | bRep.support = null; |
---|
3237 | 3386 | BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3238 | 3387 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3239 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3388 | + |
---|
| 3389 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3390 | + |
---|
3240 | 3391 | bRep = temprep; |
---|
3241 | 3392 | bRep.support = sup; |
---|
3242 | 3393 | Touch(); |
---|
.. | .. |
---|
3373 | 3524 | if (blockloop) |
---|
3374 | 3525 | return; |
---|
3375 | 3526 | |
---|
3376 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3527 | + if (//marked || // does not make sense |
---|
| 3528 | + (bRep != null || material != null)) // borderline... |
---|
3377 | 3529 | live = h; |
---|
3378 | 3530 | |
---|
3379 | 3531 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3394 | 3546 | return; |
---|
3395 | 3547 | |
---|
3396 | 3548 | //if (bRep != null) |
---|
3397 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3549 | + if (//marked || // does not make sense |
---|
| 3550 | + (bRep != null || material != null)) // borderline... |
---|
3398 | 3551 | link2master = h; |
---|
3399 | 3552 | |
---|
3400 | 3553 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3414 | 3567 | if (blockloop) |
---|
3415 | 3568 | return; |
---|
3416 | 3569 | |
---|
3417 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3570 | + if (//marked || // does not make sense |
---|
| 3571 | + (bRep != null || material != null)) // borderline... |
---|
3418 | 3572 | hide = h; |
---|
3419 | 3573 | |
---|
3420 | 3574 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3434 | 3588 | if (blockloop) |
---|
3435 | 3589 | return; |
---|
3436 | 3590 | |
---|
3437 | | - if (bRep != null && material != null) // borderline... |
---|
| 3591 | + if (bRep != null || material != null) // borderline... |
---|
3438 | 3592 | marked = h; |
---|
3439 | 3593 | |
---|
3440 | 3594 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3444 | 3598 | continue; |
---|
3445 | 3599 | blockloop = true; |
---|
3446 | 3600 | child.MarkLeaves(h); |
---|
| 3601 | + blockloop = false; |
---|
| 3602 | + // release(i); |
---|
| 3603 | + } |
---|
| 3604 | + } |
---|
| 3605 | + |
---|
| 3606 | + void RewindLeaves(boolean h) |
---|
| 3607 | + { |
---|
| 3608 | + if (blockloop) |
---|
| 3609 | + return; |
---|
| 3610 | + |
---|
| 3611 | + if (bRep != null || material != null) // borderline... |
---|
| 3612 | + rewind = h; |
---|
| 3613 | + |
---|
| 3614 | + for (int i = 0; i < Size(); i++) |
---|
| 3615 | + { |
---|
| 3616 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3617 | + if (child == null) |
---|
| 3618 | + continue; |
---|
| 3619 | + blockloop = true; |
---|
| 3620 | + child.RewindLeaves(h); |
---|
| 3621 | + blockloop = false; |
---|
| 3622 | + // release(i); |
---|
| 3623 | + } |
---|
| 3624 | + } |
---|
| 3625 | + |
---|
| 3626 | + void RandomLeaves(boolean h) |
---|
| 3627 | + { |
---|
| 3628 | + if (blockloop) |
---|
| 3629 | + return; |
---|
| 3630 | + |
---|
| 3631 | + if (bRep != null || material != null) // borderline... |
---|
| 3632 | + random = h; |
---|
| 3633 | + |
---|
| 3634 | + for (int i = 0; i < Size(); i++) |
---|
| 3635 | + { |
---|
| 3636 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3637 | + if (child == null) |
---|
| 3638 | + continue; |
---|
| 3639 | + blockloop = true; |
---|
| 3640 | + child.RandomLeaves(h); |
---|
3447 | 3641 | blockloop = false; |
---|
3448 | 3642 | // release(i); |
---|
3449 | 3643 | } |
---|
.. | .. |
---|
4221 | 4415 | } |
---|
4222 | 4416 | } |
---|
4223 | 4417 | |
---|
| 4418 | + void RepairSOV() |
---|
| 4419 | + { |
---|
| 4420 | + if (blockloop) |
---|
| 4421 | + return; |
---|
| 4422 | + |
---|
| 4423 | + String texname = this.GetPigmentTexture(); |
---|
| 4424 | + |
---|
| 4425 | + if (texname.startsWith("sov")) |
---|
| 4426 | + { |
---|
| 4427 | + String[] s = texname.split("/"); |
---|
| 4428 | + |
---|
| 4429 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4430 | + |
---|
| 4431 | + texname = sname[0]; |
---|
| 4432 | + |
---|
| 4433 | + if (sname.length > 1) |
---|
| 4434 | + { |
---|
| 4435 | + texname += "Color.jpg"; |
---|
| 4436 | + } |
---|
| 4437 | + |
---|
| 4438 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4439 | + } |
---|
| 4440 | + |
---|
| 4441 | + texname = this.GetBumpTexture(); |
---|
| 4442 | + |
---|
| 4443 | + if (texname.startsWith("sov")) |
---|
| 4444 | + { |
---|
| 4445 | + String[] s = texname.split("/"); |
---|
| 4446 | + |
---|
| 4447 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4448 | + |
---|
| 4449 | + texname = sname[0]; |
---|
| 4450 | + |
---|
| 4451 | + if (sname.length > 1) |
---|
| 4452 | + { |
---|
| 4453 | + texname += "Bump.jpg"; |
---|
| 4454 | + } |
---|
| 4455 | + |
---|
| 4456 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4457 | + } |
---|
| 4458 | + |
---|
| 4459 | + for (int i=0; i<Size(); i++) |
---|
| 4460 | + { |
---|
| 4461 | + blockloop = true; |
---|
| 4462 | + get(i).RepairSOV(); |
---|
| 4463 | + blockloop = false; |
---|
| 4464 | + } |
---|
| 4465 | + } |
---|
| 4466 | + |
---|
4224 | 4467 | void RepairTexture() |
---|
4225 | 4468 | { |
---|
4226 | 4469 | if (this instanceof FileObject || blockloop) |
---|
.. | .. |
---|
4711 | 4954 | |
---|
4712 | 4955 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4713 | 4956 | { |
---|
4714 | | - if (hide) |
---|
| 4957 | + if (hide || dontselect) |
---|
4715 | 4958 | return null; |
---|
4716 | 4959 | |
---|
4717 | 4960 | if (count <= 0) |
---|
.. | .. |
---|
4735 | 4978 | } |
---|
4736 | 4979 | } |
---|
4737 | 4980 | |
---|
| 4981 | + ObjEditor GetWindow() |
---|
| 4982 | + { |
---|
| 4983 | + if (editWindow != null) |
---|
| 4984 | + return editWindow; |
---|
| 4985 | + |
---|
| 4986 | + return manipWindow; |
---|
| 4987 | + } |
---|
| 4988 | + |
---|
4738 | 4989 | cTreePath Select(int indexcount, boolean deselect) |
---|
4739 | 4990 | { |
---|
4740 | | - if (hide) |
---|
| 4991 | + if (hide || dontselect) |
---|
4741 | 4992 | return null; |
---|
4742 | 4993 | |
---|
4743 | 4994 | if (count <= 0) |
---|
.. | .. |
---|
4771 | 5022 | if (leaf != null) |
---|
4772 | 5023 | { |
---|
4773 | 5024 | cTreePath tp = new cTreePath(this, leaf); |
---|
4774 | | - if (editWindow != null) |
---|
| 5025 | + ObjEditor window = GetWindow(); |
---|
| 5026 | + if (window != null) |
---|
4775 | 5027 | { |
---|
4776 | 5028 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4777 | | - editWindow.Select(tp, deselect, true); |
---|
| 5029 | + window.Select(tp, deselect, true); |
---|
4778 | 5030 | } |
---|
4779 | 5031 | |
---|
4780 | 5032 | return tp; |
---|
.. | .. |
---|
4800 | 5052 | if (leaf != null) |
---|
4801 | 5053 | { |
---|
4802 | 5054 | cTreePath tp = new cTreePath(this, leaf); |
---|
4803 | | - if (editWindow != null) |
---|
| 5055 | + ObjEditor window = GetWindow(); |
---|
| 5056 | + if (window != null) |
---|
4804 | 5057 | { |
---|
4805 | | - editWindow.Select(tp, deselect, true); |
---|
| 5058 | + window.Select(tp, deselect, true); |
---|
4806 | 5059 | } |
---|
4807 | 5060 | |
---|
4808 | 5061 | return tp; |
---|
.. | .. |
---|
5363 | 5616 | } |
---|
5364 | 5617 | } |
---|
5365 | 5618 | |
---|
| 5619 | + UUID GetUUID() |
---|
| 5620 | + { |
---|
| 5621 | + if (uuid == null) |
---|
| 5622 | + { |
---|
| 5623 | + // Serial |
---|
| 5624 | + uuid = UUID.randomUUID(); |
---|
| 5625 | + } |
---|
| 5626 | + |
---|
| 5627 | + return uuid; |
---|
| 5628 | + } |
---|
| 5629 | + |
---|
| 5630 | + Object3D GetObject(UUID uid) |
---|
| 5631 | + { |
---|
| 5632 | + if (blockloop) |
---|
| 5633 | + return null; |
---|
| 5634 | + |
---|
| 5635 | + if (GetUUID().equals(uid)) |
---|
| 5636 | + return this; |
---|
| 5637 | + |
---|
| 5638 | + int nb = Size(); |
---|
| 5639 | + for (int i = 0; i < nb; i++) |
---|
| 5640 | + { |
---|
| 5641 | + Object3D child = (Object3D) get(i); |
---|
| 5642 | + |
---|
| 5643 | + if (child == null) |
---|
| 5644 | + continue; |
---|
| 5645 | + |
---|
| 5646 | + blockloop = true; |
---|
| 5647 | + Object3D obj = child.GetObject(uid); |
---|
| 5648 | + blockloop = false; |
---|
| 5649 | + if (obj != null) |
---|
| 5650 | + return obj; |
---|
| 5651 | + } |
---|
| 5652 | + |
---|
| 5653 | + return null; |
---|
| 5654 | + } |
---|
| 5655 | + |
---|
5366 | 5656 | void SetBumpTexture(String tex) |
---|
5367 | 5657 | { |
---|
5368 | 5658 | if (GetTextures() == null) |
---|
.. | .. |
---|
5407 | 5697 | boolean NeedSupport() |
---|
5408 | 5698 | { |
---|
5409 | 5699 | return |
---|
5410 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5700 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5411 | 5701 | // PROBLEM with CROWD!! |
---|
5412 | 5702 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5413 | 5703 | } |
---|
5414 | 5704 | |
---|
5415 | 5705 | static boolean DEBUG_SELECTION = false; |
---|
| 5706 | + |
---|
| 5707 | + boolean IsLive() |
---|
| 5708 | + { |
---|
| 5709 | + if (live) |
---|
| 5710 | + return true; |
---|
| 5711 | + |
---|
| 5712 | + if (parent == null) |
---|
| 5713 | + return false; |
---|
| 5714 | + |
---|
| 5715 | + return parent.IsLive(); |
---|
| 5716 | + } |
---|
5416 | 5717 | |
---|
5417 | 5718 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5418 | 5719 | { |
---|
.. | .. |
---|
5424 | 5725 | } |
---|
5425 | 5726 | |
---|
5426 | 5727 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5427 | | - hide) |
---|
| 5728 | + (hide || dontselect)) |
---|
5428 | 5729 | return; |
---|
5429 | 5730 | |
---|
5430 | 5731 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5475 | 5776 | support = support; |
---|
5476 | 5777 | |
---|
5477 | 5778 | //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5478 | | - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5779 | + boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5479 | 5780 | |
---|
5480 | 5781 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5481 | 5782 | { |
---|
.. | .. |
---|
5495 | 5796 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5496 | 5797 | |
---|
5497 | 5798 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5498 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5799 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5800 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && (bRep != null && bRep.displaylist <= 0))) |
---|
5499 | 5801 | { |
---|
5500 | 5802 | Globals.lighttouched = true; |
---|
5501 | 5803 | } // all panes... |
---|
| 5804 | + |
---|
5502 | 5805 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5503 | 5806 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5504 | 5807 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5666 | 5969 | tex = GetTextures(); |
---|
5667 | 5970 | } |
---|
5668 | 5971 | |
---|
5669 | | - display.BindTextures(tex, texres); |
---|
| 5972 | + boolean failedPigment = false; |
---|
| 5973 | + boolean failedBump = false; |
---|
| 5974 | + |
---|
| 5975 | + try |
---|
| 5976 | + { |
---|
| 5977 | + display.BindPigmentTexture(tex, texres); |
---|
| 5978 | + } |
---|
| 5979 | + catch (Exception e) |
---|
| 5980 | + { |
---|
| 5981 | + System.err.println("FAILED: " + this); |
---|
| 5982 | + failedPigment = true; |
---|
| 5983 | + } |
---|
| 5984 | + |
---|
| 5985 | + try |
---|
| 5986 | + { |
---|
| 5987 | + display.BindBumpTexture(tex, texres); |
---|
| 5988 | + } |
---|
| 5989 | + catch (Exception e) |
---|
| 5990 | + { |
---|
| 5991 | + //System.err.println("FAILED: " + this); |
---|
| 5992 | + failedBump = true; |
---|
| 5993 | + } |
---|
5670 | 5994 | |
---|
5671 | 5995 | if (!compiled) |
---|
5672 | 5996 | { |
---|
.. | .. |
---|
5688 | 6012 | } |
---|
5689 | 6013 | } |
---|
5690 | 6014 | |
---|
5691 | | - display.ReleaseTextures(tex); |
---|
| 6015 | + if (!failedBump) |
---|
| 6016 | + display.ReleaseBumpTexture(tex); |
---|
| 6017 | + |
---|
| 6018 | + if (!failedPigment) |
---|
| 6019 | + display.ReleasePigmentTexture(tex); |
---|
5692 | 6020 | |
---|
5693 | 6021 | display.PopMaterial(this, selected); |
---|
5694 | 6022 | } |
---|
.. | .. |
---|
5817 | 6145 | |
---|
5818 | 6146 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5819 | 6147 | { |
---|
| 6148 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6149 | + return; |
---|
| 6150 | + |
---|
5820 | 6151 | if (hide) |
---|
5821 | 6152 | return; |
---|
5822 | 6153 | // shadow optimisation |
---|
.. | .. |
---|
5942 | 6273 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5943 | 6274 | return; // no shadow for transparent objects |
---|
5944 | 6275 | |
---|
| 6276 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6277 | + return; |
---|
| 6278 | + |
---|
5945 | 6279 | if (hide) |
---|
5946 | 6280 | return; |
---|
5947 | 6281 | |
---|
.. | .. |
---|
6055 | 6389 | // dec 2012 |
---|
6056 | 6390 | new Exception().printStackTrace(); |
---|
6057 | 6391 | return; |
---|
| 6392 | + } |
---|
| 6393 | + |
---|
| 6394 | + if (dontselect) |
---|
| 6395 | + { |
---|
| 6396 | + //bRep.GenerateNormalsMINE(); |
---|
6058 | 6397 | } |
---|
6059 | 6398 | |
---|
6060 | 6399 | display.DrawGeometry(bRep, flipV, selectmode); |
---|
.. | .. |
---|
6907 | 7246 | spot.translate(32, 32); |
---|
6908 | 7247 | spotw = spot.x + spot.width; |
---|
6909 | 7248 | spoth = spot.y + spot.height; |
---|
6910 | | - info.g.setColor(Color.blue); |
---|
| 7249 | + info.g.setColor(Color.cyan); |
---|
6911 | 7250 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6912 | 7251 | // if (CameraPane.Xmin > spot.x) |
---|
6913 | 7252 | // { |
---|
.. | .. |
---|
6925 | 7264 | // { |
---|
6926 | 7265 | // CameraPane.Ymax = spoth; |
---|
6927 | 7266 | // } |
---|
6928 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6929 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7267 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7268 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
6930 | 7269 | spot.translate(0, -32); |
---|
6931 | | - info.g.setColor(Color.green); |
---|
| 7270 | + info.g.setColor(Color.yellow); |
---|
6932 | 7271 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7272 | + info.g.setColor(Color.green); |
---|
6933 | 7273 | // if (CameraPane.Xmin > spot.x) |
---|
6934 | 7274 | // { |
---|
6935 | 7275 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6981 | 7321 | startX = info.x; |
---|
6982 | 7322 | startY = info.y; |
---|
6983 | 7323 | |
---|
6984 | | - hitSomething = 0; |
---|
| 7324 | + hitSomething = -1; |
---|
6985 | 7325 | cVector origin = new cVector(); |
---|
6986 | 7326 | //LA.xformPos(origin, toParent, origin); |
---|
6987 | 7327 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7057 | 7397 | //System.out.println("hitSomething = " + hitSomething); |
---|
7058 | 7398 | |
---|
7059 | 7399 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7400 | + |
---|
7060 | 7401 | cVector xlate = new cVector(); |
---|
7061 | 7402 | //cVector xlate2 = new cVector(); |
---|
7062 | 7403 | switch (hitSomething) |
---|
.. | .. |
---|
7205 | 7546 | |
---|
7206 | 7547 | case hitScale: // scale |
---|
7207 | 7548 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7549 | + double sign = 1; |
---|
| 7550 | + if (hScale < 0) |
---|
| 7551 | + { |
---|
| 7552 | + sign = -1; |
---|
| 7553 | + } |
---|
| 7554 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7208 | 7555 | if (hScale < 0.01) |
---|
7209 | 7556 | { |
---|
7210 | | - hScale = 0.01; |
---|
| 7557 | + //hScale = 0.01; |
---|
7211 | 7558 | } |
---|
7212 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7213 | | - if (hScale < 0.01) |
---|
7214 | | - { |
---|
7215 | | - hScale = 0.01; |
---|
7216 | | - } |
---|
| 7559 | + |
---|
7217 | 7560 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7218 | | - if (vScale < 0.01) |
---|
| 7561 | + sign = 1; |
---|
| 7562 | + if (vScale < 0) |
---|
7219 | 7563 | { |
---|
7220 | | - vScale = 0.01; |
---|
| 7564 | + sign = -1; |
---|
7221 | 7565 | } |
---|
7222 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7566 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7223 | 7567 | if (vScale < 0.01) |
---|
7224 | 7568 | { |
---|
7225 | | - vScale = 0.01; |
---|
| 7569 | + //vScale = 0.01; |
---|
7226 | 7570 | } |
---|
7227 | 7571 | LA.matCopy(startMat, toParent); |
---|
7228 | 7572 | /**/ |
---|
.. | .. |
---|
7233 | 7577 | } |
---|
7234 | 7578 | /**/ |
---|
7235 | 7579 | |
---|
| 7580 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7581 | + |
---|
| 7582 | + if (totalScale < 0.01) |
---|
| 7583 | + { |
---|
| 7584 | + totalScale = 0.01; |
---|
| 7585 | + } |
---|
| 7586 | + |
---|
7236 | 7587 | switch (info.pane.RenderCamera().viewCode) |
---|
7237 | 7588 | { |
---|
7238 | 7589 | case 3: // '\001' |
---|
7239 | | - if (modified) |
---|
| 7590 | + if (modified || opposite) |
---|
7240 | 7591 | { |
---|
7241 | 7592 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7242 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7593 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7243 | 7594 | } // vScale, 1); |
---|
7244 | 7595 | else |
---|
7245 | 7596 | { |
---|
7246 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7597 | + // EXCEPTION! |
---|
| 7598 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7247 | 7599 | } // vScale, 1); |
---|
7248 | 7600 | break; |
---|
7249 | 7601 | |
---|
7250 | 7602 | case 2: // '\002' |
---|
7251 | | - if (modified) |
---|
| 7603 | + if (modified || opposite) |
---|
7252 | 7604 | { |
---|
7253 | 7605 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7254 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7606 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7255 | 7607 | } else |
---|
7256 | 7608 | { |
---|
7257 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7609 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7258 | 7610 | } |
---|
7259 | 7611 | break; |
---|
7260 | 7612 | |
---|
7261 | 7613 | case 1: // '\003' |
---|
7262 | | - if (modified) |
---|
| 7614 | + if (modified || opposite) |
---|
7263 | 7615 | { |
---|
7264 | 7616 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7265 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7617 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7266 | 7618 | } else |
---|
7267 | 7619 | { |
---|
7268 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7620 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7269 | 7621 | } |
---|
7270 | 7622 | break; |
---|
7271 | 7623 | } |
---|
.. | .. |
---|
7406 | 7758 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7407 | 7759 | } else |
---|
7408 | 7760 | { |
---|
7409 | | - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
| 7761 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7410 | 7762 | } // + super.toString(); |
---|
7411 | 7763 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7412 | 7764 | |
---|
.. | .. |
---|
7479 | 7831 | editWindow = null; |
---|
7480 | 7832 | } // ? |
---|
7481 | 7833 | } |
---|
| 7834 | + else |
---|
| 7835 | + { |
---|
| 7836 | + //editWindow.closeUI(); |
---|
| 7837 | + } |
---|
7482 | 7838 | } |
---|
7483 | 7839 | |
---|
7484 | 7840 | boolean root; // patch for edit windows |
---|
.. | .. |
---|
7490 | 7846 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7491 | 7847 | |
---|
7492 | 7848 | Object3D /*Composite*/ parent; |
---|
7493 | | - Object3D /*Composite*/ fileparent; |
---|
| 7849 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7494 | 7850 | |
---|
7495 | 7851 | double[][] toParent; // dynamic matrix |
---|
7496 | 7852 | double[][] fromParent; |
---|
.. | .. |
---|
7636 | 7992 | } |
---|
7637 | 7993 | |
---|
7638 | 7994 | transient ObjEditor editWindow; |
---|
| 7995 | + transient ObjEditor manipWindow; |
---|
| 7996 | + |
---|
7639 | 7997 | transient ObjectUI objectUI; |
---|
7640 | 7998 | public static int povDepth = 0; |
---|
7641 | 7999 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
7654 | 8012 | private static cVector edge2 = new cVector(); |
---|
7655 | 8013 | //private static cVector norm = new cVector(); |
---|
7656 | 8014 | /*transient private*/ int hitSomething; |
---|
7657 | | - private static final int hitCenter = 1; |
---|
7658 | | - private static final int hitScale = 2; |
---|
7659 | | - private static final int hitRotate = 3; |
---|
| 8015 | + static final int hitCenter = 1; |
---|
| 8016 | + static final int hitScale = 2; |
---|
| 8017 | + static final int hitRotate = 3; |
---|
7660 | 8018 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7661 | 8019 | /*transient*/ private Point centerPt; |
---|
7662 | 8020 | /*transient*/ private int startX; |
---|