.. | .. |
---|
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; |
---|
.. | .. |
---|
4799 | 5043 | |
---|
4800 | 5044 | if (child == null) |
---|
4801 | 5045 | continue; |
---|
| 5046 | + |
---|
4802 | 5047 | if (child.HasTransparency() && child.size() != 0) |
---|
4803 | 5048 | { |
---|
4804 | 5049 | cTreePath leaf = child.Select(indexcount, deselect); |
---|
.. | .. |
---|
4808 | 5053 | if (leaf != null) |
---|
4809 | 5054 | { |
---|
4810 | 5055 | cTreePath tp = new cTreePath(this, leaf); |
---|
4811 | | - if (editWindow != null) |
---|
| 5056 | + ObjEditor window = GetWindow(); |
---|
| 5057 | + if (window != null) |
---|
4812 | 5058 | { |
---|
4813 | | - editWindow.Select(tp, deselect, true); |
---|
| 5059 | + window.Select(tp, deselect, true); |
---|
4814 | 5060 | } |
---|
4815 | 5061 | |
---|
4816 | 5062 | return tp; |
---|
.. | .. |
---|
5371 | 5617 | } |
---|
5372 | 5618 | } |
---|
5373 | 5619 | |
---|
| 5620 | + UUID GetUUID() |
---|
| 5621 | + { |
---|
| 5622 | + if (uuid == null) |
---|
| 5623 | + { |
---|
| 5624 | + // Serial |
---|
| 5625 | + uuid = UUID.randomUUID(); |
---|
| 5626 | + } |
---|
| 5627 | + |
---|
| 5628 | + return uuid; |
---|
| 5629 | + } |
---|
| 5630 | + |
---|
| 5631 | + Object3D GetObject(UUID uid) |
---|
| 5632 | + { |
---|
| 5633 | + if (blockloop) |
---|
| 5634 | + return null; |
---|
| 5635 | + |
---|
| 5636 | + if (GetUUID().equals(uid)) |
---|
| 5637 | + return this; |
---|
| 5638 | + |
---|
| 5639 | + int nb = Size(); |
---|
| 5640 | + for (int i = 0; i < nb; i++) |
---|
| 5641 | + { |
---|
| 5642 | + Object3D child = (Object3D) get(i); |
---|
| 5643 | + |
---|
| 5644 | + if (child == null) |
---|
| 5645 | + continue; |
---|
| 5646 | + |
---|
| 5647 | + blockloop = true; |
---|
| 5648 | + Object3D obj = child.GetObject(uid); |
---|
| 5649 | + blockloop = false; |
---|
| 5650 | + if (obj != null) |
---|
| 5651 | + return obj; |
---|
| 5652 | + } |
---|
| 5653 | + |
---|
| 5654 | + return null; |
---|
| 5655 | + } |
---|
| 5656 | + |
---|
5374 | 5657 | void SetBumpTexture(String tex) |
---|
5375 | 5658 | { |
---|
5376 | 5659 | if (GetTextures() == null) |
---|
.. | .. |
---|
5415 | 5698 | boolean NeedSupport() |
---|
5416 | 5699 | { |
---|
5417 | 5700 | return |
---|
5418 | | - CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null |
---|
| 5701 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5419 | 5702 | // PROBLEM with CROWD!! |
---|
5420 | 5703 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5421 | 5704 | } |
---|
5422 | 5705 | |
---|
5423 | 5706 | static boolean DEBUG_SELECTION = false; |
---|
| 5707 | + |
---|
| 5708 | + boolean IsLive() |
---|
| 5709 | + { |
---|
| 5710 | + if (live) |
---|
| 5711 | + return true; |
---|
| 5712 | + |
---|
| 5713 | + if (parent == null) |
---|
| 5714 | + return false; |
---|
| 5715 | + |
---|
| 5716 | + return parent.IsLive(); |
---|
| 5717 | + } |
---|
5424 | 5718 | |
---|
5425 | 5719 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5426 | 5720 | { |
---|
.. | .. |
---|
5483 | 5777 | support = support; |
---|
5484 | 5778 | |
---|
5485 | 5779 | //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); |
---|
| 5780 | + boolean usecalllists = !IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5487 | 5781 | |
---|
5488 | 5782 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5489 | 5783 | { |
---|
.. | .. |
---|
5503 | 5797 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5504 | 5798 | |
---|
5505 | 5799 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5506 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5800 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5801 | + (Globals.isLIVE() && Globals.COMPUTESHADOWWHENLIVE || touched && Globals.COMPUTESHADOWWHENLIVE)) // || (bRep != null && bRep.displaylist <= 0))) |
---|
5507 | 5802 | { |
---|
5508 | 5803 | Globals.lighttouched = true; |
---|
5509 | 5804 | } // all panes... |
---|
| 5805 | + |
---|
5510 | 5806 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5511 | 5807 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5512 | 5808 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5634 | 5930 | if (GetBRep() != null) |
---|
5635 | 5931 | { |
---|
5636 | 5932 | display.NextIndex(); |
---|
| 5933 | + |
---|
5637 | 5934 | // vertex color conflict : gl.glCallList(list); |
---|
5638 | 5935 | DrawNode(display, root, selected); |
---|
5639 | 5936 | if (this instanceof BezierPatch) |
---|
.. | .. |
---|
5674 | 5971 | tex = GetTextures(); |
---|
5675 | 5972 | } |
---|
5676 | 5973 | |
---|
5677 | | - boolean failed = false; |
---|
| 5974 | + boolean failedPigment = false; |
---|
| 5975 | + boolean failedBump = false; |
---|
5678 | 5976 | |
---|
5679 | 5977 | try |
---|
5680 | 5978 | { |
---|
5681 | | - display.BindTextures(tex, texres); |
---|
| 5979 | + display.BindPigmentTexture(tex, texres); |
---|
5682 | 5980 | } |
---|
5683 | 5981 | catch (Exception e) |
---|
5684 | 5982 | { |
---|
5685 | 5983 | System.err.println("FAILED: " + this); |
---|
5686 | | - failed = true; |
---|
| 5984 | + failedPigment = true; |
---|
| 5985 | + } |
---|
| 5986 | + |
---|
| 5987 | + try |
---|
| 5988 | + { |
---|
| 5989 | + display.BindBumpTexture(tex, texres); |
---|
| 5990 | + } |
---|
| 5991 | + catch (Exception e) |
---|
| 5992 | + { |
---|
| 5993 | + //System.err.println("FAILED: " + this); |
---|
| 5994 | + failedBump = true; |
---|
5687 | 5995 | } |
---|
5688 | 5996 | |
---|
5689 | 5997 | if (!compiled) |
---|
.. | .. |
---|
5706 | 6014 | } |
---|
5707 | 6015 | } |
---|
5708 | 6016 | |
---|
5709 | | - if (!failed) |
---|
5710 | | - display.ReleaseTextures(tex); |
---|
| 6017 | + if (!failedBump) |
---|
| 6018 | + display.ReleaseBumpTexture(tex); |
---|
| 6019 | + |
---|
| 6020 | + if (!failedPigment) |
---|
| 6021 | + display.ReleasePigmentTexture(tex); |
---|
5711 | 6022 | |
---|
5712 | 6023 | display.PopMaterial(this, selected); |
---|
5713 | 6024 | } |
---|
.. | .. |
---|
6080 | 6391 | // dec 2012 |
---|
6081 | 6392 | new Exception().printStackTrace(); |
---|
6082 | 6393 | return; |
---|
| 6394 | + } |
---|
| 6395 | + |
---|
| 6396 | + if (dontselect) |
---|
| 6397 | + { |
---|
| 6398 | + //bRep.GenerateNormalsMINE(); |
---|
6083 | 6399 | } |
---|
6084 | 6400 | |
---|
6085 | 6401 | display.DrawGeometry(bRep, flipV, selectmode); |
---|
.. | .. |
---|
6932 | 7248 | spot.translate(32, 32); |
---|
6933 | 7249 | spotw = spot.x + spot.width; |
---|
6934 | 7250 | spoth = spot.y + spot.height; |
---|
6935 | | - info.g.setColor(Color.blue); |
---|
| 7251 | + info.g.setColor(Color.cyan); |
---|
6936 | 7252 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6937 | 7253 | // if (CameraPane.Xmin > spot.x) |
---|
6938 | 7254 | // { |
---|
.. | .. |
---|
6950 | 7266 | // { |
---|
6951 | 7267 | // CameraPane.Ymax = spoth; |
---|
6952 | 7268 | // } |
---|
6953 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6954 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7269 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7270 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
6955 | 7271 | spot.translate(0, -32); |
---|
6956 | | - info.g.setColor(Color.green); |
---|
| 7272 | + info.g.setColor(Color.yellow); |
---|
6957 | 7273 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7274 | + info.g.setColor(Color.green); |
---|
6958 | 7275 | // if (CameraPane.Xmin > spot.x) |
---|
6959 | 7276 | // { |
---|
6960 | 7277 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
7006 | 7323 | startX = info.x; |
---|
7007 | 7324 | startY = info.y; |
---|
7008 | 7325 | |
---|
7009 | | - hitSomething = 0; |
---|
| 7326 | + hitSomething = -1; |
---|
7010 | 7327 | cVector origin = new cVector(); |
---|
7011 | 7328 | //LA.xformPos(origin, toParent, origin); |
---|
7012 | 7329 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7082 | 7399 | //System.out.println("hitSomething = " + hitSomething); |
---|
7083 | 7400 | |
---|
7084 | 7401 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7402 | + |
---|
7085 | 7403 | cVector xlate = new cVector(); |
---|
7086 | 7404 | //cVector xlate2 = new cVector(); |
---|
7087 | 7405 | switch (hitSomething) |
---|
.. | .. |
---|
7230 | 7548 | |
---|
7231 | 7549 | case hitScale: // scale |
---|
7232 | 7550 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7551 | + double sign = 1; |
---|
| 7552 | + if (hScale < 0) |
---|
| 7553 | + { |
---|
| 7554 | + sign = -1; |
---|
| 7555 | + } |
---|
| 7556 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7233 | 7557 | if (hScale < 0.01) |
---|
7234 | 7558 | { |
---|
7235 | | - hScale = 0.01; |
---|
| 7559 | + //hScale = 0.01; |
---|
7236 | 7560 | } |
---|
7237 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7238 | | - if (hScale < 0.01) |
---|
7239 | | - { |
---|
7240 | | - hScale = 0.01; |
---|
7241 | | - } |
---|
| 7561 | + |
---|
7242 | 7562 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7243 | | - if (vScale < 0.01) |
---|
| 7563 | + sign = 1; |
---|
| 7564 | + if (vScale < 0) |
---|
7244 | 7565 | { |
---|
7245 | | - vScale = 0.01; |
---|
| 7566 | + sign = -1; |
---|
7246 | 7567 | } |
---|
7247 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7568 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7248 | 7569 | if (vScale < 0.01) |
---|
7249 | 7570 | { |
---|
7250 | | - vScale = 0.01; |
---|
| 7571 | + //vScale = 0.01; |
---|
7251 | 7572 | } |
---|
7252 | 7573 | LA.matCopy(startMat, toParent); |
---|
7253 | 7574 | /**/ |
---|
.. | .. |
---|
7258 | 7579 | } |
---|
7259 | 7580 | /**/ |
---|
7260 | 7581 | |
---|
| 7582 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7583 | + |
---|
| 7584 | + if (totalScale < 0.01) |
---|
| 7585 | + { |
---|
| 7586 | + totalScale = 0.01; |
---|
| 7587 | + } |
---|
| 7588 | + |
---|
7261 | 7589 | switch (info.pane.RenderCamera().viewCode) |
---|
7262 | 7590 | { |
---|
7263 | 7591 | case 3: // '\001' |
---|
7264 | | - if (modified) |
---|
| 7592 | + if (modified || opposite) |
---|
7265 | 7593 | { |
---|
7266 | 7594 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7267 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7595 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7268 | 7596 | } // vScale, 1); |
---|
7269 | 7597 | else |
---|
7270 | 7598 | { |
---|
7271 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7599 | + // EXCEPTION! |
---|
| 7600 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7272 | 7601 | } // vScale, 1); |
---|
7273 | 7602 | break; |
---|
7274 | 7603 | |
---|
7275 | 7604 | case 2: // '\002' |
---|
7276 | | - if (modified) |
---|
| 7605 | + if (modified || opposite) |
---|
7277 | 7606 | { |
---|
7278 | 7607 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7279 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7608 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7280 | 7609 | } else |
---|
7281 | 7610 | { |
---|
7282 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7611 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7283 | 7612 | } |
---|
7284 | 7613 | break; |
---|
7285 | 7614 | |
---|
7286 | 7615 | case 1: // '\003' |
---|
7287 | | - if (modified) |
---|
| 7616 | + if (modified || opposite) |
---|
7288 | 7617 | { |
---|
7289 | 7618 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7290 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7619 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7291 | 7620 | } else |
---|
7292 | 7621 | { |
---|
7293 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7622 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7294 | 7623 | } |
---|
7295 | 7624 | break; |
---|
7296 | 7625 | } |
---|
.. | .. |
---|
7431 | 7760 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7432 | 7761 | } else |
---|
7433 | 7762 | { |
---|
7434 | | - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
| 7763 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7435 | 7764 | } // + super.toString(); |
---|
7436 | 7765 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7437 | 7766 | |
---|
.. | .. |
---|
7504 | 7833 | editWindow = null; |
---|
7505 | 7834 | } // ? |
---|
7506 | 7835 | } |
---|
| 7836 | + else |
---|
| 7837 | + { |
---|
| 7838 | + //editWindow.closeUI(); |
---|
| 7839 | + } |
---|
7507 | 7840 | } |
---|
7508 | 7841 | |
---|
7509 | 7842 | boolean root; // patch for edit windows |
---|
.. | .. |
---|
7515 | 7848 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7516 | 7849 | |
---|
7517 | 7850 | Object3D /*Composite*/ parent; |
---|
7518 | | - Object3D /*Composite*/ fileparent; |
---|
| 7851 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7519 | 7852 | |
---|
7520 | 7853 | double[][] toParent; // dynamic matrix |
---|
7521 | 7854 | double[][] fromParent; |
---|
.. | .. |
---|
7661 | 7994 | } |
---|
7662 | 7995 | |
---|
7663 | 7996 | transient ObjEditor editWindow; |
---|
| 7997 | + transient ObjEditor manipWindow; |
---|
| 7998 | + |
---|
| 7999 | + transient boolean pinned; |
---|
| 8000 | + |
---|
7664 | 8001 | transient ObjectUI objectUI; |
---|
7665 | 8002 | public static int povDepth = 0; |
---|
7666 | 8003 | private static cVector tbMin = new cVector(); |
---|
.. | .. |
---|
7679 | 8016 | private static cVector edge2 = new cVector(); |
---|
7680 | 8017 | //private static cVector norm = new cVector(); |
---|
7681 | 8018 | /*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; |
---|
| 8019 | + static final int hitCenter = 1; |
---|
| 8020 | + static final int hitScale = 2; |
---|
| 8021 | + static final int hitRotate = 3; |
---|
7685 | 8022 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7686 | 8023 | /*transient*/ private Point centerPt; |
---|
7687 | 8024 | /*transient*/ private int startX; |
---|