.. | .. |
---|
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; |
---|
.. | .. |
---|
482 | 570 | toParent = LA.newMatrix(); |
---|
483 | 571 | fromParent = LA.newMatrix(); |
---|
484 | 572 | } |
---|
| 573 | + |
---|
485 | 574 | if (toParentMarked == null) |
---|
486 | 575 | { |
---|
487 | 576 | if (maxcount != 1) |
---|
488 | 577 | { |
---|
489 | 578 | new Exception().printStackTrace(); |
---|
490 | 579 | } |
---|
| 580 | + |
---|
491 | 581 | toParentMarked = LA.newMatrix(); |
---|
492 | 582 | fromParentMarked = LA.newMatrix(); |
---|
493 | 583 | } |
---|
.. | .. |
---|
775 | 865 | if (step == 0) |
---|
776 | 866 | step = 1; |
---|
777 | 867 | if (maxcount == 0) |
---|
778 | | - maxcount = 2048; // 4; |
---|
| 868 | + maxcount = 128; // 2048; // 4; |
---|
779 | 869 | // if (acceleration == 0) |
---|
780 | 870 | // acceleration = 10; |
---|
781 | 871 | if (delay == 0) // serial |
---|
.. | .. |
---|
798 | 888 | |
---|
799 | 889 | if (marked && Globals.isLIVE() && live && |
---|
800 | 890 | //TEMP21aug2018 |
---|
801 | | - (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW) && |
---|
| 891 | + (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || !Globals.COMPUTESHADOWWHENLIVE) && |
---|
802 | 892 | currentframe != Globals.framecount) |
---|
803 | 893 | { |
---|
804 | 894 | currentframe = Globals.framecount; |
---|
.. | .. |
---|
810 | 900 | |
---|
811 | 901 | boolean changedir = random && Math.random() < 0.01; // && !link2master; |
---|
812 | 902 | |
---|
813 | | - if (transformcount*factor > maxcount || (step == 1 && changedir)) |
---|
| 903 | + if (transformcount*factor >= maxcount && (rewind || random) || |
---|
| 904 | + (step == 1 && changedir)) |
---|
814 | 905 | { |
---|
815 | 906 | countdown = 1; |
---|
816 | 907 | delay = speedup?8:1; |
---|
.. | .. |
---|
882 | 973 | if (material == null || material.multiply) |
---|
883 | 974 | return true; |
---|
884 | 975 | |
---|
| 976 | + // Transparent objects are dynamic because we have to sort the triangles. |
---|
885 | 977 | return material.opacity > 0.99; |
---|
886 | 978 | } |
---|
887 | 979 | |
---|
.. | .. |
---|
2303 | 2395 | } |
---|
2304 | 2396 | */ |
---|
2305 | 2397 | } |
---|
| 2398 | + else |
---|
| 2399 | + { |
---|
| 2400 | + //((ObjEditor)editWindow).SetupUI2(null); |
---|
| 2401 | + } |
---|
2306 | 2402 | } |
---|
2307 | 2403 | |
---|
2308 | 2404 | void createEditWindow(GroupEditor callee, boolean newWindow) //, boolean root) |
---|
.. | .. |
---|
2344 | 2440 | { |
---|
2345 | 2441 | editWindow.refreshContents(); |
---|
2346 | 2442 | } |
---|
| 2443 | + else |
---|
| 2444 | + { |
---|
| 2445 | + if (manipWindow != null) |
---|
| 2446 | + { |
---|
| 2447 | + manipWindow.refreshContents(); |
---|
| 2448 | + } |
---|
| 2449 | + } |
---|
| 2450 | + |
---|
2347 | 2451 | //if (parent != null) |
---|
2348 | 2452 | //parent.refreshEditWindow(); |
---|
2349 | 2453 | } |
---|
.. | .. |
---|
2628 | 2732 | //Touch(); |
---|
2629 | 2733 | } |
---|
2630 | 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 | + |
---|
2631 | 2747 | void ClearColorsS() |
---|
2632 | 2748 | { |
---|
2633 | 2749 | selection.ClearColors(); |
---|
.. | .. |
---|
2759 | 2875 | if (child == null) |
---|
2760 | 2876 | continue; |
---|
2761 | 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(); |
---|
2762 | 2896 | // Children().release(i); |
---|
2763 | 2897 | } |
---|
2764 | 2898 | blockloop = false; |
---|
.. | .. |
---|
2927 | 3061 | if (bRep != null) |
---|
2928 | 3062 | { |
---|
2929 | 3063 | bRep.GenerateNormals(crease); |
---|
| 3064 | + Touch(); |
---|
| 3065 | + } |
---|
| 3066 | + } |
---|
| 3067 | + |
---|
| 3068 | + void GenNormalsMesh0() |
---|
| 3069 | + { |
---|
| 3070 | + if (bRep != null) |
---|
| 3071 | + { |
---|
| 3072 | + bRep.GenerateNormalsMesh(); |
---|
2930 | 3073 | Touch(); |
---|
2931 | 3074 | } |
---|
2932 | 3075 | } |
---|
.. | .. |
---|
3381 | 3524 | if (blockloop) |
---|
3382 | 3525 | return; |
---|
3383 | 3526 | |
---|
3384 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3527 | + if (//marked || // does not make sense |
---|
| 3528 | + (bRep != null || material != null)) // borderline... |
---|
3385 | 3529 | live = h; |
---|
3386 | 3530 | |
---|
3387 | 3531 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3402 | 3546 | return; |
---|
3403 | 3547 | |
---|
3404 | 3548 | //if (bRep != null) |
---|
3405 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3549 | + if (//marked || // does not make sense |
---|
| 3550 | + (bRep != null || material != null)) // borderline... |
---|
3406 | 3551 | link2master = h; |
---|
3407 | 3552 | |
---|
3408 | 3553 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3422 | 3567 | if (blockloop) |
---|
3423 | 3568 | return; |
---|
3424 | 3569 | |
---|
3425 | | - if (marked || (bRep != null && material != null)) // borderline... |
---|
| 3570 | + if (//marked || // does not make sense |
---|
| 3571 | + (bRep != null || material != null)) // borderline... |
---|
3426 | 3572 | hide = h; |
---|
3427 | 3573 | |
---|
3428 | 3574 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3442 | 3588 | if (blockloop) |
---|
3443 | 3589 | return; |
---|
3444 | 3590 | |
---|
3445 | | - if (bRep != null && material != null) // borderline... |
---|
| 3591 | + if (bRep != null || material != null) // borderline... |
---|
3446 | 3592 | marked = h; |
---|
3447 | 3593 | |
---|
3448 | 3594 | for (int i = 0; i < Size(); i++) |
---|
.. | .. |
---|
3452 | 3598 | continue; |
---|
3453 | 3599 | blockloop = true; |
---|
3454 | 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); |
---|
3455 | 3641 | blockloop = false; |
---|
3456 | 3642 | // release(i); |
---|
3457 | 3643 | } |
---|
.. | .. |
---|
4229 | 4415 | } |
---|
4230 | 4416 | } |
---|
4231 | 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 | + |
---|
4232 | 4467 | void RepairTexture() |
---|
4233 | 4468 | { |
---|
4234 | 4469 | if (this instanceof FileObject || blockloop) |
---|
.. | .. |
---|
4743 | 4978 | } |
---|
4744 | 4979 | } |
---|
4745 | 4980 | |
---|
| 4981 | + ObjEditor GetWindow() |
---|
| 4982 | + { |
---|
| 4983 | + if (editWindow != null) |
---|
| 4984 | + return editWindow; |
---|
| 4985 | + |
---|
| 4986 | + return manipWindow; |
---|
| 4987 | + } |
---|
| 4988 | + |
---|
4746 | 4989 | cTreePath Select(int indexcount, boolean deselect) |
---|
4747 | 4990 | { |
---|
4748 | 4991 | if (hide || dontselect) |
---|
.. | .. |
---|
4779 | 5022 | if (leaf != null) |
---|
4780 | 5023 | { |
---|
4781 | 5024 | cTreePath tp = new cTreePath(this, leaf); |
---|
4782 | | - if (editWindow != null) |
---|
| 5025 | + ObjEditor window = GetWindow(); |
---|
| 5026 | + if (window != null) |
---|
4783 | 5027 | { |
---|
4784 | 5028 | //System.out.println("editWindow = " + editWindow + " vs " + this); |
---|
4785 | | - editWindow.Select(tp, deselect, true); |
---|
| 5029 | + window.Select(tp, deselect, true); |
---|
4786 | 5030 | } |
---|
4787 | 5031 | |
---|
4788 | 5032 | return tp; |
---|
.. | .. |
---|
4808 | 5052 | if (leaf != null) |
---|
4809 | 5053 | { |
---|
4810 | 5054 | cTreePath tp = new cTreePath(this, leaf); |
---|
4811 | | - if (editWindow != null) |
---|
| 5055 | + ObjEditor window = GetWindow(); |
---|
| 5056 | + if (window != null) |
---|
4812 | 5057 | { |
---|
4813 | | - editWindow.Select(tp, deselect, true); |
---|
| 5058 | + window.Select(tp, deselect, true); |
---|
4814 | 5059 | } |
---|
4815 | 5060 | |
---|
4816 | 5061 | return tp; |
---|
.. | .. |
---|
5371 | 5616 | } |
---|
5372 | 5617 | } |
---|
5373 | 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 | + |
---|
5374 | 5656 | void SetBumpTexture(String tex) |
---|
5375 | 5657 | { |
---|
5376 | 5658 | if (GetTextures() == null) |
---|
.. | .. |
---|
5415 | 5697 | boolean NeedSupport() |
---|
5416 | 5698 | { |
---|
5417 | 5699 | return |
---|
5418 | | - CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
| 5700 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5419 | 5701 | // PROBLEM with CROWD!! |
---|
5420 | 5702 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5421 | 5703 | } |
---|
5422 | 5704 | |
---|
5423 | 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 | + } |
---|
5424 | 5717 | |
---|
5425 | 5718 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5426 | 5719 | { |
---|
.. | .. |
---|
5483 | 5776 | support = support; |
---|
5484 | 5777 | |
---|
5485 | 5778 | //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); |
---|
| 5779 | + boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5487 | 5780 | |
---|
5488 | 5781 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5489 | 5782 | { |
---|
.. | .. |
---|
5503 | 5796 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5504 | 5797 | |
---|
5505 | 5798 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5506 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5799 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5800 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched || (bRep != null && bRep.displaylist <= 0))) |
---|
5507 | 5801 | { |
---|
5508 | 5802 | Globals.lighttouched = true; |
---|
5509 | 5803 | } // all panes... |
---|
| 5804 | + |
---|
5510 | 5805 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5511 | 5806 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5512 | 5807 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5674 | 5969 | tex = GetTextures(); |
---|
5675 | 5970 | } |
---|
5676 | 5971 | |
---|
5677 | | - boolean failed = false; |
---|
| 5972 | + boolean failedPigment = false; |
---|
| 5973 | + boolean failedBump = false; |
---|
5678 | 5974 | |
---|
5679 | 5975 | try |
---|
5680 | 5976 | { |
---|
5681 | | - display.BindTextures(tex, texres); |
---|
| 5977 | + display.BindPigmentTexture(tex, texres); |
---|
5682 | 5978 | } |
---|
5683 | 5979 | catch (Exception e) |
---|
5684 | 5980 | { |
---|
5685 | 5981 | System.err.println("FAILED: " + this); |
---|
5686 | | - failed = true; |
---|
| 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; |
---|
5687 | 5993 | } |
---|
5688 | 5994 | |
---|
5689 | 5995 | if (!compiled) |
---|
.. | .. |
---|
5706 | 6012 | } |
---|
5707 | 6013 | } |
---|
5708 | 6014 | |
---|
5709 | | - if (!failed) |
---|
5710 | | - display.ReleaseTextures(tex); |
---|
| 6015 | + if (!failedBump) |
---|
| 6016 | + display.ReleaseBumpTexture(tex); |
---|
| 6017 | + |
---|
| 6018 | + if (!failedPigment) |
---|
| 6019 | + display.ReleasePigmentTexture(tex); |
---|
5711 | 6020 | |
---|
5712 | 6021 | display.PopMaterial(this, selected); |
---|
5713 | 6022 | } |
---|
.. | .. |
---|
6080 | 6389 | // dec 2012 |
---|
6081 | 6390 | new Exception().printStackTrace(); |
---|
6082 | 6391 | return; |
---|
| 6392 | + } |
---|
| 6393 | + |
---|
| 6394 | + if (dontselect) |
---|
| 6395 | + { |
---|
| 6396 | + //bRep.GenerateNormalsMINE(); |
---|
6083 | 6397 | } |
---|
6084 | 6398 | |
---|
6085 | 6399 | display.DrawGeometry(bRep, flipV, selectmode); |
---|
.. | .. |
---|
6932 | 7246 | spot.translate(32, 32); |
---|
6933 | 7247 | spotw = spot.x + spot.width; |
---|
6934 | 7248 | spoth = spot.y + spot.height; |
---|
6935 | | - info.g.setColor(Color.blue); |
---|
| 7249 | + info.g.setColor(Color.cyan); |
---|
6936 | 7250 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6937 | 7251 | // if (CameraPane.Xmin > spot.x) |
---|
6938 | 7252 | // { |
---|
.. | .. |
---|
6950 | 7264 | // { |
---|
6951 | 7265 | // CameraPane.Ymax = spoth; |
---|
6952 | 7266 | // } |
---|
6953 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6954 | | - 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 |
---|
6955 | 7269 | spot.translate(0, -32); |
---|
6956 | | - info.g.setColor(Color.green); |
---|
| 7270 | + info.g.setColor(Color.yellow); |
---|
6957 | 7271 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7272 | + info.g.setColor(Color.green); |
---|
6958 | 7273 | // if (CameraPane.Xmin > spot.x) |
---|
6959 | 7274 | // { |
---|
6960 | 7275 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7006 | 7321 | startX = info.x; |
---|
7007 | 7322 | startY = info.y; |
---|
7008 | 7323 | |
---|
7009 | | - hitSomething = 0; |
---|
| 7324 | + hitSomething = -1; |
---|
7010 | 7325 | cVector origin = new cVector(); |
---|
7011 | 7326 | //LA.xformPos(origin, toParent, origin); |
---|
7012 | 7327 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7082 | 7397 | //System.out.println("hitSomething = " + hitSomething); |
---|
7083 | 7398 | |
---|
7084 | 7399 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7400 | + |
---|
7085 | 7401 | cVector xlate = new cVector(); |
---|
7086 | 7402 | //cVector xlate2 = new cVector(); |
---|
7087 | 7403 | switch (hitSomething) |
---|
.. | .. |
---|
7230 | 7546 | |
---|
7231 | 7547 | case hitScale: // scale |
---|
7232 | 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); |
---|
7233 | 7555 | if (hScale < 0.01) |
---|
7234 | 7556 | { |
---|
7235 | | - hScale = 0.01; |
---|
| 7557 | + //hScale = 0.01; |
---|
7236 | 7558 | } |
---|
7237 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7238 | | - if (hScale < 0.01) |
---|
7239 | | - { |
---|
7240 | | - hScale = 0.01; |
---|
7241 | | - } |
---|
| 7559 | + |
---|
7242 | 7560 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7243 | | - if (vScale < 0.01) |
---|
| 7561 | + sign = 1; |
---|
| 7562 | + if (vScale < 0) |
---|
7244 | 7563 | { |
---|
7245 | | - vScale = 0.01; |
---|
| 7564 | + sign = -1; |
---|
7246 | 7565 | } |
---|
7247 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7566 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7248 | 7567 | if (vScale < 0.01) |
---|
7249 | 7568 | { |
---|
7250 | | - vScale = 0.01; |
---|
| 7569 | + //vScale = 0.01; |
---|
7251 | 7570 | } |
---|
7252 | 7571 | LA.matCopy(startMat, toParent); |
---|
7253 | 7572 | /**/ |
---|
.. | .. |
---|
7258 | 7577 | } |
---|
7259 | 7578 | /**/ |
---|
7260 | 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 | + |
---|
7261 | 7587 | switch (info.pane.RenderCamera().viewCode) |
---|
7262 | 7588 | { |
---|
7263 | 7589 | case 3: // '\001' |
---|
7264 | | - if (modified) |
---|
| 7590 | + if (modified || opposite) |
---|
7265 | 7591 | { |
---|
7266 | 7592 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7267 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7593 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7268 | 7594 | } // vScale, 1); |
---|
7269 | 7595 | else |
---|
7270 | 7596 | { |
---|
7271 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7597 | + // EXCEPTION! |
---|
| 7598 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7272 | 7599 | } // vScale, 1); |
---|
7273 | 7600 | break; |
---|
7274 | 7601 | |
---|
7275 | 7602 | case 2: // '\002' |
---|
7276 | | - if (modified) |
---|
| 7603 | + if (modified || opposite) |
---|
7277 | 7604 | { |
---|
7278 | 7605 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7279 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7606 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7280 | 7607 | } else |
---|
7281 | 7608 | { |
---|
7282 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7609 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7283 | 7610 | } |
---|
7284 | 7611 | break; |
---|
7285 | 7612 | |
---|
7286 | 7613 | case 1: // '\003' |
---|
7287 | | - if (modified) |
---|
| 7614 | + if (modified || opposite) |
---|
7288 | 7615 | { |
---|
7289 | 7616 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7290 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7617 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7291 | 7618 | } else |
---|
7292 | 7619 | { |
---|
7293 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7620 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7294 | 7621 | } |
---|
7295 | 7622 | break; |
---|
7296 | 7623 | } |
---|
.. | .. |
---|
7431 | 7758 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7432 | 7759 | } else |
---|
7433 | 7760 | { |
---|
7434 | | - 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) ":"") */ ""; |
---|
7435 | 7762 | } // + super.toString(); |
---|
7436 | 7763 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7437 | 7764 | |
---|
.. | .. |
---|
7504 | 7831 | editWindow = null; |
---|
7505 | 7832 | } // ? |
---|
7506 | 7833 | } |
---|
| 7834 | + else |
---|
| 7835 | + { |
---|
| 7836 | + //editWindow.closeUI(); |
---|
| 7837 | + } |
---|
7507 | 7838 | } |
---|
7508 | 7839 | |
---|
7509 | 7840 | boolean root; // patch for edit windows |
---|
.. | .. |
---|
7515 | 7846 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7516 | 7847 | |
---|
7517 | 7848 | Object3D /*Composite*/ parent; |
---|
7518 | | - Object3D /*Composite*/ fileparent; |
---|
| 7849 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7519 | 7850 | |
---|
7520 | 7851 | double[][] toParent; // dynamic matrix |
---|
7521 | 7852 | double[][] fromParent; |
---|
.. | .. |
---|
7661 | 7992 | } |
---|
7662 | 7993 | |
---|
7663 | 7994 | transient ObjEditor editWindow; |
---|
| 7995 | + transient ObjEditor manipWindow; |
---|
| 7996 | + |
---|
| 7997 | + transient boolean pinned; |
---|
| 7998 | + |
---|
7664 | 7999 | transient ObjectUI objectUI; |
---|
7665 | 8000 | public static int povDepth = 0; |
---|
7666 | 8001 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
7679 | 8014 | private static cVector edge2 = new cVector(); |
---|
7680 | 8015 | //private static cVector norm = new cVector(); |
---|
7681 | 8016 | /*transient private*/ int hitSomething; |
---|
7682 | | - private static final int hitCenter = 1; |
---|
7683 | | - private static final int hitScale = 2; |
---|
7684 | | - private static final int hitRotate = 3; |
---|
| 8017 | + static final int hitCenter = 1; |
---|
| 8018 | + static final int hitScale = 2; |
---|
| 8019 | + static final int hitRotate = 3; |
---|
7685 | 8020 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7686 | 8021 | /*transient*/ private Point centerPt; |
---|
7687 | 8022 | /*transient*/ private int startX; |
---|