.. | .. |
---|
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; |
---|
22 | 24 | |
---|
| 25 | + private UUID uuid = UUID.randomUUID(); |
---|
| 26 | + |
---|
| 27 | + // TEMPORARY for mocap undo. No need to be transient. |
---|
| 28 | + mocap.reader.BVHReader.BVHResult savebvh; |
---|
| 29 | + Object3D saveskeleton; |
---|
| 30 | + // |
---|
| 31 | + |
---|
| 32 | + byte[] versions[]; |
---|
| 33 | + int versionindex = -1; |
---|
| 34 | + |
---|
23 | 35 | ScriptNode scriptnode; |
---|
24 | 36 | |
---|
25 | 37 | void InitOthers() |
---|
.. | .. |
---|
100 | 112 | |
---|
101 | 113 | // transient boolean reduced; // for morph reduction |
---|
102 | 114 | |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
104 | | -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
| 115 | + transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
| 116 | + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
105 | 117 | |
---|
106 | | -transient Object3D transientsupport; // for cloning |
---|
107 | | -transient boolean transientlink2master; |
---|
| 118 | + transient Object3D transientsupport; // for cloning |
---|
| 119 | + transient boolean transientlink2master; |
---|
108 | 120 | |
---|
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) |
---|
| 121 | + void SaveSupports() |
---|
121 | 122 | { |
---|
122 | | - bRep.SaveSupports(); |
---|
| 123 | + if (blockloop) |
---|
| 124 | + return; |
---|
| 125 | + |
---|
| 126 | + transientsupport = support; |
---|
| 127 | + transientlink2master = link2master; |
---|
| 128 | + |
---|
| 129 | + support = null; |
---|
| 130 | + link2master = false; |
---|
| 131 | + |
---|
| 132 | + if (bRep != null) |
---|
| 133 | + { |
---|
| 134 | + bRep.SaveSupports(); |
---|
| 135 | + } |
---|
| 136 | + |
---|
| 137 | + for (int i = 0; i < Size(); i++) |
---|
| 138 | + { |
---|
| 139 | + Object3D child = (Object3D) get(i); |
---|
| 140 | + if (child == null) |
---|
| 141 | + continue; |
---|
| 142 | + blockloop = true; |
---|
| 143 | + child.SaveSupports(); |
---|
| 144 | + blockloop = false; |
---|
| 145 | + } |
---|
123 | 146 | } |
---|
124 | | - |
---|
125 | | - for (int i = 0; i < Size(); i++) |
---|
| 147 | + |
---|
| 148 | + void RestoreSupports() |
---|
126 | 149 | { |
---|
127 | | - Object3D child = (Object3D) get(i); |
---|
128 | | - if (child == null) |
---|
129 | | - continue; |
---|
| 150 | + if (blockloop) |
---|
| 151 | + return; |
---|
| 152 | + |
---|
| 153 | + support = transientsupport; |
---|
| 154 | + link2master = transientlink2master; |
---|
| 155 | + transientsupport = null; |
---|
| 156 | + transientlink2master = false; |
---|
| 157 | + |
---|
| 158 | + if (bRep != null) |
---|
| 159 | + { |
---|
| 160 | + bRep.RestoreSupports(); |
---|
| 161 | + } |
---|
| 162 | + |
---|
| 163 | + for (int i = 0; i < Size(); i++) |
---|
| 164 | + { |
---|
| 165 | + Object3D child = (Object3D) get(i); |
---|
| 166 | + if (child == null) |
---|
| 167 | + continue; |
---|
| 168 | + blockloop = true; |
---|
| 169 | + child.RestoreSupports(); |
---|
| 170 | + blockloop = false; |
---|
| 171 | + } |
---|
| 172 | + } |
---|
| 173 | + |
---|
| 174 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 175 | + { |
---|
| 176 | + Object3D o; |
---|
| 177 | + |
---|
| 178 | + if (hashtable.containsKey(GetUUID())) |
---|
| 179 | + { |
---|
| 180 | + o = hashtable.get(GetUUID()); |
---|
| 181 | + |
---|
| 182 | + Grafreed.Assert(this.bRep == o.bRep); |
---|
| 183 | + //if (this.bRep != null) |
---|
| 184 | + // assert(this.bRep.support == o.transientrep); |
---|
| 185 | + if (this.support != null) |
---|
| 186 | + assert(this.support.bRep == o.transientrep); |
---|
| 187 | + } |
---|
| 188 | + else |
---|
| 189 | + { |
---|
| 190 | + o = new Object3D("copy of " + this.name); |
---|
| 191 | + |
---|
| 192 | + hashtable.put(GetUUID(), o); |
---|
| 193 | + } |
---|
| 194 | + |
---|
| 195 | + if (!blockloop) |
---|
| 196 | + { |
---|
| 197 | + blockloop = true; |
---|
| 198 | + |
---|
| 199 | + for (int i=0; i<Size(); i++) |
---|
| 200 | + { |
---|
| 201 | + get(i).ExtractBigData(hashtable); |
---|
| 202 | + } |
---|
| 203 | + |
---|
| 204 | + blockloop = false; |
---|
| 205 | + } |
---|
| 206 | + |
---|
| 207 | + ExtractBigData(o); |
---|
| 208 | + } |
---|
| 209 | + |
---|
| 210 | + void ExtractBigData(Object3D o) |
---|
| 211 | + { |
---|
| 212 | + if (o.bRep != null) |
---|
| 213 | + Grafreed.Assert(o.bRep == this.bRep); |
---|
| 214 | + |
---|
| 215 | + o.bRep = this.bRep; |
---|
| 216 | +// July 2019 if (this.bRep != null) |
---|
| 217 | +// { |
---|
| 218 | +// o.transientrep = this.bRep.support; |
---|
| 219 | +// o.bRep.support = null; |
---|
| 220 | +// } |
---|
| 221 | + o.selection = this.selection; |
---|
| 222 | + o.versions = this.versions; |
---|
| 223 | + o.versionindex = this.versionindex; |
---|
| 224 | + |
---|
| 225 | + if (this.support != null) |
---|
| 226 | + { |
---|
| 227 | + if (o.transientrep != null) |
---|
| 228 | + Grafreed.Assert(o.transientrep == this.support.bRep); |
---|
| 229 | + |
---|
| 230 | + o.transientrep = this.support.bRep; |
---|
| 231 | + this.support.bRep = null; |
---|
| 232 | + } |
---|
| 233 | + |
---|
| 234 | + // o.support = this.support; |
---|
| 235 | + // o.fileparent = this.fileparent; |
---|
| 236 | + // if (this.bRep != null) |
---|
| 237 | + // o.bRep = this.bRep.support; |
---|
| 238 | + |
---|
| 239 | + this.bRep = null; |
---|
| 240 | + // if (this.bRep != null) |
---|
| 241 | + // this.bRep.support = null; |
---|
| 242 | + // this.support = null; |
---|
| 243 | + // this.fileparent = null; |
---|
| 244 | + } |
---|
| 245 | + |
---|
| 246 | + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 247 | + { |
---|
| 248 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 249 | + return; |
---|
| 250 | + |
---|
| 251 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 252 | + |
---|
| 253 | + RestoreBigData(o); |
---|
| 254 | + |
---|
| 255 | + if (blockloop) |
---|
| 256 | + return; |
---|
| 257 | + |
---|
130 | 258 | blockloop = true; |
---|
131 | | - child.SaveSupports(); |
---|
| 259 | + |
---|
| 260 | + //hashtable.remove(GetUUID()); |
---|
| 261 | + |
---|
| 262 | + for (int i=0; i<Size(); i++) |
---|
| 263 | + { |
---|
| 264 | + get(i).RestoreBigData(hashtable); |
---|
| 265 | + } |
---|
| 266 | + |
---|
132 | 267 | blockloop = false; |
---|
133 | 268 | } |
---|
134 | | -} |
---|
135 | 269 | |
---|
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) |
---|
| 270 | + void RestoreBigData(Object3D o) |
---|
147 | 271 | { |
---|
148 | | - bRep.RestoreSupports(); |
---|
| 272 | + this.bRep = o.bRep; |
---|
| 273 | + if (this.support != null && o.transientrep != null) |
---|
| 274 | + { |
---|
| 275 | + this.support.bRep = o.transientrep; |
---|
| 276 | + } |
---|
| 277 | + |
---|
| 278 | + this.selection = o.selection; |
---|
| 279 | + |
---|
| 280 | + this.versions = o.versions; |
---|
| 281 | + this.versionindex = o.versionindex; |
---|
| 282 | +// July 2019 if (this.bRep != null) |
---|
| 283 | +// this.bRep.support = o.transientrep; |
---|
| 284 | + // this.support = o.support; |
---|
| 285 | + // this.fileparent = o.fileparent; |
---|
149 | 286 | } |
---|
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 | 287 | |
---|
162 | 288 | // MOCAP SUPPORT |
---|
163 | 289 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
300 | 426 | } |
---|
301 | 427 | |
---|
302 | 428 | boolean live = false; |
---|
| 429 | + transient boolean keepdontselect; |
---|
303 | 430 | boolean dontselect = false; |
---|
304 | 431 | boolean hide = false; |
---|
305 | 432 | boolean link2master = false; // performs reset support/master at each frame |
---|
.. | .. |
---|
482 | 609 | toParent = LA.newMatrix(); |
---|
483 | 610 | fromParent = LA.newMatrix(); |
---|
484 | 611 | } |
---|
| 612 | + |
---|
485 | 613 | if (toParentMarked == null) |
---|
486 | 614 | { |
---|
487 | 615 | if (maxcount != 1) |
---|
488 | 616 | { |
---|
489 | 617 | new Exception().printStackTrace(); |
---|
490 | 618 | } |
---|
| 619 | + |
---|
491 | 620 | toParentMarked = LA.newMatrix(); |
---|
492 | 621 | fromParentMarked = LA.newMatrix(); |
---|
493 | 622 | } |
---|
.. | .. |
---|
798 | 927 | |
---|
799 | 928 | if (marked && Globals.isLIVE() && live && |
---|
800 | 929 | //TEMP21aug2018 |
---|
801 | | - (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
| 930 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
802 | 931 | currentframe != Globals.framecount) |
---|
803 | 932 | { |
---|
804 | 933 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
810 | 939 | |
---|
811 | 940 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
812 | 941 | |
---|
813 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 942 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 943 | + (step == 1 && changedir)) |
---|
814 | 944 | { |
---|
815 | 945 | countdown = 1; |
---|
816 | 946 | delay = speedup?8:1; |
---|
.. | .. |
---|
882 | 1012 | if (material == null || material.multiply) |
---|
883 | 1013 | return true; |
---|
884 | 1014 | |
---|
| 1015 | + // Transparent objects are dynamic because we have to sort the triangles. |
---|
885 | 1016 | return material.opacity > 0.99; |
---|
886 | 1017 | } |
---|
887 | 1018 | |
---|
.. | .. |
---|
1282 | 1413 | toParent = LA.newMatrix(); |
---|
1283 | 1414 | fromParent = LA.newMatrix(); |
---|
1284 | 1415 | } |
---|
| 1416 | + |
---|
1285 | 1417 | LA.matCopy(other.toParent, toParent); |
---|
1286 | 1418 | LA.matCopy(other.fromParent, fromParent); |
---|
1287 | 1419 | |
---|
.. | .. |
---|
2303 | 2435 | } |
---|
2304 | 2436 | */ |
---|
2305 | 2437 | } |
---|
| 2438 | + else |
---|
| 2439 | + { |
---|
| 2440 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2441 | + } |
---|
2306 | 2442 | } |
---|
2307 | 2443 | |
---|
2308 | 2444 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
.. | .. |
---|
2344 | 2480 | { |
---|
2345 | 2481 | editWindow.refreshContents(); |
---|
2346 | 2482 | } |
---|
| 2483 | + else |
---|
| 2484 | + { |
---|
| 2485 | + if (manipWindow != null) |
---|
| 2486 | + { |
---|
| 2487 | + manipWindow.refreshContents(); |
---|
| 2488 | + } |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2347 | 2491 | //if (parent != null) |
---|
2348 | 2492 | //parent.refreshEditWindow(); |
---|
2349 | 2493 | } |
---|
.. | .. |
---|
2628 | 2772 | //Touch(); |
---|
2629 | 2773 | } |
---|
2630 | 2774 | |
---|
| 2775 | + void GenNormalsMeshS() |
---|
| 2776 | + { |
---|
| 2777 | + selection.GenNormalsMesh(); |
---|
| 2778 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2779 | +// { |
---|
| 2780 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2781 | +// selectee.GenNormals(crease); |
---|
| 2782 | +// } |
---|
| 2783 | + |
---|
| 2784 | + //Touch(); |
---|
| 2785 | + } |
---|
| 2786 | + |
---|
2631 | 2787 | void ClearColorsS() |
---|
2632 | 2788 | { |
---|
2633 | 2789 | selection.ClearColors(); |
---|
.. | .. |
---|
2759 | 2915 | if (child == null) |
---|
2760 | 2916 | continue; |
---|
2761 | 2917 | child.GenNormals(crease); |
---|
| 2918 | +// Children().release(i); |
---|
| 2919 | + } |
---|
| 2920 | + blockloop = false; |
---|
| 2921 | + } |
---|
| 2922 | + |
---|
| 2923 | + void GenNormalsMesh() |
---|
| 2924 | + { |
---|
| 2925 | + if (blockloop) |
---|
| 2926 | + return; |
---|
| 2927 | + |
---|
| 2928 | + blockloop = true; |
---|
| 2929 | + GenNormalsMesh0(); |
---|
| 2930 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2931 | + { |
---|
| 2932 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2933 | + if (child == null) |
---|
| 2934 | + continue; |
---|
| 2935 | + child.GenNormalsMesh(); |
---|
2762 | 2936 | // Children().release(i); |
---|
2763 | 2937 | } |
---|
2764 | 2938 | blockloop = false; |
---|
.. | .. |
---|
2931 | 3105 | } |
---|
2932 | 3106 | } |
---|
2933 | 3107 | |
---|
| 3108 | + void GenNormalsMesh0() |
---|
| 3109 | + { |
---|
| 3110 | + if (bRep != null) |
---|
| 3111 | + { |
---|
| 3112 | + bRep.GenerateNormalsMesh(); |
---|
| 3113 | + Touch(); |
---|
| 3114 | + } |
---|
| 3115 | + } |
---|
| 3116 | + |
---|
2934 | 3117 | void GenNormalsMINE0() |
---|
2935 | 3118 | { |
---|
2936 | 3119 | if (bRep != null) |
---|
2937 | 3120 | { |
---|
2938 | | - bRep.GenerateNormalsMINE(); |
---|
| 3121 | + bRep.MergeNormals(); //.GenerateNormalsMINE(); |
---|
2939 | 3122 | Touch(); |
---|
2940 | 3123 | } |
---|
2941 | 3124 | } |
---|
.. | .. |
---|
3381 | 3564 | if (blockloop) |
---|
3382 | 3565 | return; |
---|
3383 | 3566 | |
---|
3384 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3567 | + if (//marked || // does not make sense |
---|
| 3568 | + (bRep != null || material != null)) // borderline... |
---|
3385 | 3569 | live = h; |
---|
3386 | 3570 | |
---|
3387 | 3571 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3402 | 3586 | return; |
---|
3403 | 3587 | |
---|
3404 | 3588 | //if (bRep != null) |
---|
3405 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3589 | + if (//marked || // does not make sense |
---|
| 3590 | + (bRep != null || material != null)) // borderline... |
---|
3406 | 3591 | link2master = h; |
---|
3407 | 3592 | |
---|
3408 | 3593 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3422 | 3607 | if (blockloop) |
---|
3423 | 3608 | return; |
---|
3424 | 3609 | |
---|
3425 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3610 | + if (//marked || // does not make sense |
---|
| 3611 | + (bRep != null || material != null)) // borderline... |
---|
3426 | 3612 | hide = h; |
---|
3427 | 3613 | |
---|
3428 | 3614 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3442 | 3628 | if (blockloop) |
---|
3443 | 3629 | return; |
---|
3444 | 3630 | |
---|
3445 | | - if (bRep != null && material != null) // borderline... |
---|
| 3631 | + if (bRep != null || material != null) // borderline... |
---|
3446 | 3632 | marked = h; |
---|
3447 | 3633 | |
---|
3448 | 3634 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3452 | 3638 | continue; |
---|
3453 | 3639 | blockloop = true; |
---|
3454 | 3640 | child.MarkLeaves(h); |
---|
| 3641 | + blockloop = false; |
---|
| 3642 | + // release(i); |
---|
| 3643 | + } |
---|
| 3644 | + } |
---|
| 3645 | + |
---|
| 3646 | + void RewindLeaves(boolean h) |
---|
| 3647 | + { |
---|
| 3648 | + if (blockloop) |
---|
| 3649 | + return; |
---|
| 3650 | + |
---|
| 3651 | + if (bRep != null || material != null) // borderline... |
---|
| 3652 | + rewind = h; |
---|
| 3653 | + |
---|
| 3654 | + for (int i = 0; i < Size(); i++) |
---|
| 3655 | + { |
---|
| 3656 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3657 | + if (child == null) |
---|
| 3658 | + continue; |
---|
| 3659 | + blockloop = true; |
---|
| 3660 | + child.RewindLeaves(h); |
---|
| 3661 | + blockloop = false; |
---|
| 3662 | + // release(i); |
---|
| 3663 | + } |
---|
| 3664 | + } |
---|
| 3665 | + |
---|
| 3666 | + void RandomLeaves(boolean h) |
---|
| 3667 | + { |
---|
| 3668 | + if (blockloop) |
---|
| 3669 | + return; |
---|
| 3670 | + |
---|
| 3671 | + if (bRep != null || material != null) // borderline... |
---|
| 3672 | + random = h; |
---|
| 3673 | + |
---|
| 3674 | + for (int i = 0; i < Size(); i++) |
---|
| 3675 | + { |
---|
| 3676 | + Object3D child = (Object3D) get(i); // reserve(i); |
---|
| 3677 | + if (child == null) |
---|
| 3678 | + continue; |
---|
| 3679 | + blockloop = true; |
---|
| 3680 | + child.RandomLeaves(h); |
---|
3455 | 3681 | blockloop = false; |
---|
3456 | 3682 | // release(i); |
---|
3457 | 3683 | } |
---|
.. | .. |
---|
4229 | 4455 | } |
---|
4230 | 4456 | } |
---|
4231 | 4457 | |
---|
| 4458 | + void RepairSOV() |
---|
| 4459 | + { |
---|
| 4460 | + if (blockloop) |
---|
| 4461 | + return; |
---|
| 4462 | + |
---|
| 4463 | + String texname = this.GetPigmentTexture(); |
---|
| 4464 | + |
---|
| 4465 | + if (texname.startsWith("sov")) |
---|
| 4466 | + { |
---|
| 4467 | + String[] s = texname.split("/"); |
---|
| 4468 | + |
---|
| 4469 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4470 | + |
---|
| 4471 | + texname = sname[0]; |
---|
| 4472 | + |
---|
| 4473 | + if (sname.length > 1) |
---|
| 4474 | + { |
---|
| 4475 | + texname += "Color.jpg"; |
---|
| 4476 | + } |
---|
| 4477 | + |
---|
| 4478 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4479 | + } |
---|
| 4480 | + |
---|
| 4481 | + texname = this.GetBumpTexture(); |
---|
| 4482 | + |
---|
| 4483 | + if (texname.startsWith("sov")) |
---|
| 4484 | + { |
---|
| 4485 | + String[] s = texname.split("/"); |
---|
| 4486 | + |
---|
| 4487 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4488 | + |
---|
| 4489 | + texname = sname[0]; |
---|
| 4490 | + |
---|
| 4491 | + if (sname.length > 1) |
---|
| 4492 | + { |
---|
| 4493 | + texname += "Bump.jpg"; |
---|
| 4494 | + } |
---|
| 4495 | + |
---|
| 4496 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4497 | + } |
---|
| 4498 | + |
---|
| 4499 | + for (int i=0; i<Size(); i++) |
---|
| 4500 | + { |
---|
| 4501 | + blockloop = true; |
---|
| 4502 | + get(i).RepairSOV(); |
---|
| 4503 | + blockloop = false; |
---|
| 4504 | + } |
---|
| 4505 | + } |
---|
| 4506 | + |
---|
4232 | 4507 | void RepairTexture() |
---|
4233 | 4508 | { |
---|
4234 | 4509 | if (this instanceof FileObject || blockloop) |
---|
.. | .. |
---|
4743 | 5018 | } |
---|
4744 | 5019 | } |
---|
4745 | 5020 | |
---|
| 5021 | + ObjEditor GetWindow() |
---|
| 5022 | + { |
---|
| 5023 | + if (editWindow != null) |
---|
| 5024 | + return editWindow; |
---|
| 5025 | + |
---|
| 5026 | + return manipWindow; |
---|
| 5027 | + } |
---|
| 5028 | + |
---|
4746 | 5029 | cTreePath Select(int indexcount, boolean deselect) |
---|
4747 | 5030 | { |
---|
4748 | 5031 | if (hide || dontselect) |
---|
.. | .. |
---|
4779 | 5062 | if (leaf != null) |
---|
4780 | 5063 | { |
---|
4781 | 5064 | cTreePath tp = new cTreePath(this, leaf); |
---|
4782 | | - if (editWindow != null) |
---|
| 5065 | + ObjEditor window = GetWindow(); |
---|
| 5066 | + if (window != null) |
---|
4783 | 5067 | { |
---|
4784 | 5068 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4785 | | - editWindow.Select(tp, deselect, true); |
---|
| 5069 | + window.Select(tp, deselect, true); |
---|
4786 | 5070 | } |
---|
4787 | 5071 | |
---|
4788 | 5072 | return tp; |
---|
.. | .. |
---|
4799 | 5083 | |
---|
4800 | 5084 | if (child == null) |
---|
4801 | 5085 | continue; |
---|
| 5086 | + |
---|
4802 | 5087 | if (child.HasTransparency() && child.size() != 0) |
---|
4803 | 5088 | { |
---|
4804 | 5089 | cTreePath leaf = child.Select(indexcount, deselect); |
---|
.. | .. |
---|
4808 | 5093 | if (leaf != null) |
---|
4809 | 5094 | { |
---|
4810 | 5095 | cTreePath tp = new cTreePath(this, leaf); |
---|
4811 | | - if (editWindow != null) |
---|
| 5096 | + ObjEditor window = GetWindow(); |
---|
| 5097 | + if (window != null) |
---|
4812 | 5098 | { |
---|
4813 | | - editWindow.Select(tp, deselect, true); |
---|
| 5099 | + window.Select(tp, deselect, true); |
---|
4814 | 5100 | } |
---|
4815 | 5101 | |
---|
4816 | 5102 | return tp; |
---|
.. | .. |
---|
5135 | 5421 | blockloop = false; |
---|
5136 | 5422 | } |
---|
5137 | 5423 | |
---|
| 5424 | + void ResetSelectable() |
---|
| 5425 | + { |
---|
| 5426 | + if (blockloop) |
---|
| 5427 | + return; |
---|
| 5428 | + |
---|
| 5429 | + blockloop = true; |
---|
| 5430 | + |
---|
| 5431 | + keepdontselect = dontselect; |
---|
| 5432 | + dontselect = true; |
---|
| 5433 | + |
---|
| 5434 | + Object3D child; |
---|
| 5435 | + int nb = Size(); |
---|
| 5436 | + for (int i = 0; i < nb; i++) |
---|
| 5437 | + { |
---|
| 5438 | + child = (Object3D) get(i); |
---|
| 5439 | + if (child == null) |
---|
| 5440 | + continue; |
---|
| 5441 | + child.ResetSelectable(); |
---|
| 5442 | + } |
---|
| 5443 | + |
---|
| 5444 | + blockloop = false; |
---|
| 5445 | + } |
---|
| 5446 | + |
---|
| 5447 | + void RestoreSelectable() |
---|
| 5448 | + { |
---|
| 5449 | + if (blockloop) |
---|
| 5450 | + return; |
---|
| 5451 | + |
---|
| 5452 | + blockloop = true; |
---|
| 5453 | + |
---|
| 5454 | + dontselect = keepdontselect; |
---|
| 5455 | + |
---|
| 5456 | + Object3D child; |
---|
| 5457 | + int nb = Size(); |
---|
| 5458 | + for (int i = 0; i < nb; i++) |
---|
| 5459 | + { |
---|
| 5460 | + child = (Object3D) get(i); |
---|
| 5461 | + if (child == null) |
---|
| 5462 | + continue; |
---|
| 5463 | + child.RestoreSelectable(); |
---|
| 5464 | + } |
---|
| 5465 | + |
---|
| 5466 | + blockloop = false; |
---|
| 5467 | + } |
---|
| 5468 | + |
---|
5138 | 5469 | boolean IsSelected() |
---|
5139 | 5470 | { |
---|
5140 | 5471 | if (parent == null) |
---|
.. | .. |
---|
5371 | 5702 | } |
---|
5372 | 5703 | } |
---|
5373 | 5704 | |
---|
| 5705 | + UUID GetUUID() |
---|
| 5706 | + { |
---|
| 5707 | + if (uuid == null) |
---|
| 5708 | + { |
---|
| 5709 | + // Serial |
---|
| 5710 | + uuid = UUID.randomUUID(); |
---|
| 5711 | + } |
---|
| 5712 | + |
---|
| 5713 | + return uuid; |
---|
| 5714 | + } |
---|
| 5715 | + |
---|
| 5716 | + Object3D GetObject(UUID uid) |
---|
| 5717 | + { |
---|
| 5718 | + if (blockloop) |
---|
| 5719 | + return null; |
---|
| 5720 | + |
---|
| 5721 | + if (GetUUID().equals(uid)) |
---|
| 5722 | + return this; |
---|
| 5723 | + |
---|
| 5724 | + int nb = Size(); |
---|
| 5725 | + for (int i = 0; i < nb; i++) |
---|
| 5726 | + { |
---|
| 5727 | + Object3D child = (Object3D) get(i); |
---|
| 5728 | + |
---|
| 5729 | + if (child == null) |
---|
| 5730 | + continue; |
---|
| 5731 | + |
---|
| 5732 | + blockloop = true; |
---|
| 5733 | + Object3D obj = child.GetObject(uid); |
---|
| 5734 | + blockloop = false; |
---|
| 5735 | + if (obj != null) |
---|
| 5736 | + return obj; |
---|
| 5737 | + } |
---|
| 5738 | + |
---|
| 5739 | + return null; |
---|
| 5740 | + } |
---|
| 5741 | + |
---|
5374 | 5742 | void SetBumpTexture(String tex) |
---|
5375 | 5743 | { |
---|
5376 | 5744 | if (GetTextures() == null) |
---|
.. | .. |
---|
5407 | 5775 | } |
---|
5408 | 5776 | } |
---|
5409 | 5777 | |
---|
| 5778 | + void EmbedTextures() |
---|
| 5779 | + { |
---|
| 5780 | + if (blockloop) |
---|
| 5781 | + return; |
---|
| 5782 | + |
---|
| 5783 | + CameraPane.EmbedTextures(texture); |
---|
| 5784 | + |
---|
| 5785 | + int nb = Size(); |
---|
| 5786 | + for (int i = 0; i < nb; i++) |
---|
| 5787 | + { |
---|
| 5788 | + Object3D child = (Object3D) get(i); |
---|
| 5789 | + |
---|
| 5790 | + if (child == null) |
---|
| 5791 | + continue; |
---|
| 5792 | + |
---|
| 5793 | + blockloop = true; |
---|
| 5794 | + child.EmbedTextures(); |
---|
| 5795 | + blockloop = false; |
---|
| 5796 | + } |
---|
| 5797 | + } |
---|
| 5798 | + |
---|
5410 | 5799 | void draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5411 | 5800 | { |
---|
5412 | 5801 | Draw(display, root, selected, blocked); |
---|
.. | .. |
---|
5415 | 5804 | boolean NeedSupport() |
---|
5416 | 5805 | { |
---|
5417 | 5806 | return |
---|
5418 | | - CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
| 5807 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5419 | 5808 | // PROBLEM with CROWD!! |
---|
5420 | 5809 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5421 | 5810 | } |
---|
5422 | 5811 | |
---|
5423 | 5812 | static boolean DEBUG_SELECTION = false; |
---|
| 5813 | + |
---|
| 5814 | + boolean IsLive() |
---|
| 5815 | + { |
---|
| 5816 | + if (live) |
---|
| 5817 | + return true; |
---|
| 5818 | + |
---|
| 5819 | + if (parent == null) |
---|
| 5820 | + return false; |
---|
| 5821 | + |
---|
| 5822 | + return parent.IsLive(); |
---|
| 5823 | + } |
---|
5424 | 5824 | |
---|
5425 | 5825 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5426 | 5826 | { |
---|
.. | .. |
---|
5483 | 5883 | support = support; |
---|
5484 | 5884 | |
---|
5485 | 5885 | //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5486 | | - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5886 | + boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5487 | 5887 | |
---|
5488 | 5888 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5489 | 5889 | { |
---|
.. | .. |
---|
5503 | 5903 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5504 | 5904 | |
---|
5505 | 5905 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5506 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5906 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5907 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5507 | 5908 | { |
---|
5508 | 5909 | Globals.lighttouched = true; |
---|
5509 | 5910 | } // all panes... |
---|
| 5911 | + |
---|
5510 | 5912 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5511 | 5913 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5512 | 5914 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5634 | 6036 | if (GetBRep() != null) |
---|
5635 | 6037 | { |
---|
5636 | 6038 | display.NextIndex(); |
---|
| 6039 | + |
---|
5637 | 6040 | // vertex color conflict : gl.glCallList(list); |
---|
5638 | 6041 | DrawNode(display, root, selected); |
---|
5639 | 6042 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5674 | 6077 | tex = GetTextures(); |
---|
5675 | 6078 | } |
---|
5676 | 6079 | |
---|
5677 | | - boolean failed = false; |
---|
| 6080 | + boolean failedPigment = false; |
---|
| 6081 | + boolean failedBump = false; |
---|
5678 | 6082 | |
---|
5679 | 6083 | try |
---|
5680 | 6084 | { |
---|
5681 | | - display.BindTextures(tex, texres); |
---|
| 6085 | + display.BindPigmentTexture(tex, texres); |
---|
5682 | 6086 | } |
---|
5683 | 6087 | catch (Exception e) |
---|
5684 | 6088 | { |
---|
5685 | 6089 | System.err.println("FAILED: " + this); |
---|
5686 | | - failed = true; |
---|
| 6090 | + failedPigment = true; |
---|
| 6091 | + } |
---|
| 6092 | + |
---|
| 6093 | + try |
---|
| 6094 | + { |
---|
| 6095 | + display.BindBumpTexture(tex, texres); |
---|
| 6096 | + } |
---|
| 6097 | + catch (Exception e) |
---|
| 6098 | + { |
---|
| 6099 | + //System.err.println("FAILED: " + this); |
---|
| 6100 | + failedBump = true; |
---|
5687 | 6101 | } |
---|
5688 | 6102 | |
---|
5689 | 6103 | if (!compiled) |
---|
.. | .. |
---|
5706 | 6120 | } |
---|
5707 | 6121 | } |
---|
5708 | 6122 | |
---|
5709 | | - if (!failed) |
---|
5710 | | - display.ReleaseTextures(tex); |
---|
| 6123 | + if (!failedBump) |
---|
| 6124 | + display.ReleaseBumpTexture(tex); |
---|
| 6125 | + |
---|
| 6126 | + if (!failedPigment) |
---|
| 6127 | + display.ReleasePigmentTexture(tex); |
---|
5711 | 6128 | |
---|
5712 | 6129 | display.PopMaterial(this, selected); |
---|
5713 | 6130 | } |
---|
.. | .. |
---|
6080 | 6497 | // dec 2012 |
---|
6081 | 6498 | new Exception().printStackTrace(); |
---|
6082 | 6499 | return; |
---|
| 6500 | + } |
---|
| 6501 | + |
---|
| 6502 | + if (dontselect) |
---|
| 6503 | + { |
---|
| 6504 | + //bRep.GenerateNormalsMINE(); |
---|
6083 | 6505 | } |
---|
6084 | 6506 | |
---|
6085 | 6507 | display.DrawGeometry(bRep, flipV, selectmode); |
---|
.. | .. |
---|
6932 | 7354 | spot.translate(32, 32); |
---|
6933 | 7355 | spotw = spot.x + spot.width; |
---|
6934 | 7356 | spoth = spot.y + spot.height; |
---|
6935 | | - info.g.setColor(Color.blue); |
---|
| 7357 | + info.g.setColor(Color.cyan); |
---|
6936 | 7358 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6937 | 7359 | // if (CameraPane.Xmin > spot.x) |
---|
6938 | 7360 | // { |
---|
.. | .. |
---|
6950 | 7372 | // { |
---|
6951 | 7373 | // CameraPane.Ymax = spoth; |
---|
6952 | 7374 | // } |
---|
6953 | | - // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6954 | | - //info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7375 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7376 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
6955 | 7377 | spot.translate(0, -32); |
---|
6956 | | - info.g.setColor(Color.green); |
---|
| 7378 | + info.g.setColor(Color.yellow); |
---|
6957 | 7379 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7380 | + info.g.setColor(Color.green); |
---|
6958 | 7381 | // if (CameraPane.Xmin > spot.x) |
---|
6959 | 7382 | // { |
---|
6960 | 7383 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6971 | 7394 | // { |
---|
6972 | 7395 | // CameraPane.Ymax = spoth; |
---|
6973 | 7396 | // } |
---|
6974 | | - info.g.drawArc(boundary.x, boundary.y, |
---|
6975 | | - boundary.width, boundary.height, 0, 360); |
---|
| 7397 | + info.g.drawArc(boundary.x + info.DX, boundary.y + info.DY, |
---|
| 7398 | + (int)(boundary.width * info.W), (int)(boundary.height * info.W), 0, 360); |
---|
6976 | 7399 | //info.g.drawArc(spot.x, spotw, spot.width/2, boundary.height/2, 0, 360); |
---|
6977 | 7400 | // if (CameraPane.Xmin > boundary.x) |
---|
6978 | 7401 | // { |
---|
.. | .. |
---|
7272 | 7695 | switch (info.pane.RenderCamera().viewCode) |
---|
7273 | 7696 | { |
---|
7274 | 7697 | case 3: // '\001' |
---|
7275 | | - if (modified) |
---|
| 7698 | + if (modified || opposite) |
---|
7276 | 7699 | { |
---|
7277 | 7700 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7278 | 7701 | LA.matScale(toParent, totalScale, 1, 1); |
---|
7279 | 7702 | } // vScale, 1); |
---|
7280 | 7703 | else |
---|
7281 | 7704 | { |
---|
| 7705 | + // EXCEPTION! |
---|
7282 | 7706 | LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7283 | 7707 | } // vScale, 1); |
---|
7284 | 7708 | break; |
---|
7285 | 7709 | |
---|
7286 | 7710 | case 2: // '\002' |
---|
7287 | | - if (modified) |
---|
| 7711 | + if (modified || opposite) |
---|
7288 | 7712 | { |
---|
7289 | 7713 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7290 | 7714 | LA.matScale(toParent, 1, totalScale, 1); |
---|
.. | .. |
---|
7295 | 7719 | break; |
---|
7296 | 7720 | |
---|
7297 | 7721 | case 1: // '\003' |
---|
7298 | | - if (modified) |
---|
| 7722 | + if (modified || opposite) |
---|
7299 | 7723 | { |
---|
7300 | 7724 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7301 | 7725 | LA.matScale(toParent, 1, 1, totalScale); |
---|
.. | .. |
---|
7515 | 7939 | editWindow = null; |
---|
7516 | 7940 | } // ? |
---|
7517 | 7941 | } |
---|
| 7942 | + else |
---|
| 7943 | + { |
---|
| 7944 | + //editWindow.closeUI(); |
---|
| 7945 | + } |
---|
7518 | 7946 | } |
---|
7519 | 7947 | |
---|
7520 | 7948 | boolean root; // patch for edit windows |
---|
.. | .. |
---|
7526 | 7954 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7527 | 7955 | |
---|
7528 | 7956 | Object3D /*Composite*/ parent; |
---|
7529 | | - Object3D /*Composite*/ fileparent; |
---|
| 7957 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7530 | 7958 | |
---|
7531 | 7959 | double[][] toParent; // dynamic matrix |
---|
7532 | 7960 | double[][] fromParent; |
---|
.. | .. |
---|
7672 | 8100 | } |
---|
7673 | 8101 | |
---|
7674 | 8102 | transient ObjEditor editWindow; |
---|
| 8103 | + transient ObjEditor manipWindow; |
---|
| 8104 | + |
---|
| 8105 | + transient boolean pinned; |
---|
| 8106 | + |
---|
7675 | 8107 | transient ObjectUI objectUI; |
---|
7676 | 8108 | public static int povDepth = 0; |
---|
7677 | 8109 | private static cVector tbMin = new cVector(); |
---|