.. | .. |
---|
14 | 14 | import //weka.core. |
---|
15 | 15 | matrix.Matrix; |
---|
16 | 16 | |
---|
| 17 | +import java.util.UUID; |
---|
| 18 | + |
---|
17 | 19 | //import net.sourceforge.sizeof.SizeOf; |
---|
18 | 20 | public class Object3D extends Vector<Object3D> implements java.io.Serializable, iSendInfo //, aurelienribon.tweenengine.TweenAccessor<Object3D> |
---|
19 | 21 | { |
---|
20 | 22 | //static final long serialVersionUID = -607422624994562685L; |
---|
21 | 23 | static final long serialVersionUID = 5022536242724664900L; |
---|
| 24 | + |
---|
| 25 | + private UUID uuid = UUID.randomUUID(); |
---|
| 26 | + |
---|
| 27 | + // TEMPORARY for mocap undo |
---|
| 28 | + mocap.reader.BVHReader.BVHResult bvh; |
---|
| 29 | + Object3D skeleton; |
---|
| 30 | + // |
---|
22 | 31 | |
---|
23 | 32 | ScriptNode scriptnode; |
---|
24 | 33 | |
---|
.. | .. |
---|
100 | 109 | |
---|
101 | 110 | // transient boolean reduced; // for morph reduction |
---|
102 | 111 | |
---|
103 | | -transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
104 | | -transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
| 112 | + transient com.bulletphysics.linearmath.Transform cache; // for fast merge |
---|
| 113 | + transient com.bulletphysics.linearmath.Transform cache_1; // for fast merge |
---|
105 | 114 | |
---|
106 | | -transient Object3D transientsupport; // for cloning |
---|
107 | | -transient boolean transientlink2master; |
---|
| 115 | + transient Object3D transientsupport; // for cloning |
---|
| 116 | + transient boolean transientlink2master; |
---|
108 | 117 | |
---|
109 | | -void SaveSupports() |
---|
110 | | -{ |
---|
111 | | - if (blockloop) |
---|
112 | | - return; |
---|
113 | | - |
---|
114 | | - transientsupport = support; |
---|
115 | | - transientlink2master = link2master; |
---|
116 | | - |
---|
117 | | - support = null; |
---|
118 | | - link2master = false; |
---|
119 | | - |
---|
120 | | - if (bRep != null) |
---|
| 118 | + void SaveSupports() |
---|
121 | 119 | { |
---|
122 | | - bRep.SaveSupports(); |
---|
123 | | - } |
---|
124 | | - |
---|
125 | | - for (int i = 0; i < Size(); i++) |
---|
126 | | - { |
---|
127 | | - Object3D child = (Object3D) get(i); |
---|
128 | | - if (child == null) |
---|
129 | | - continue; |
---|
130 | | - blockloop = true; |
---|
131 | | - child.SaveSupports(); |
---|
132 | | - blockloop = false; |
---|
133 | | - } |
---|
134 | | -} |
---|
| 120 | + if (blockloop) |
---|
| 121 | + return; |
---|
135 | 122 | |
---|
136 | | -void RestoreSupports() |
---|
137 | | -{ |
---|
138 | | - if (blockloop) |
---|
139 | | - return; |
---|
| 123 | + transientsupport = support; |
---|
| 124 | + transientlink2master = link2master; |
---|
140 | 125 | |
---|
141 | | - support = transientsupport; |
---|
142 | | - link2master = transientlink2master; |
---|
143 | | - transientsupport = null; |
---|
144 | | - transientlink2master = false; |
---|
145 | | - |
---|
146 | | - if (bRep != null) |
---|
147 | | - { |
---|
148 | | - bRep.RestoreSupports(); |
---|
| 126 | + support = null; |
---|
| 127 | + link2master = false; |
---|
| 128 | + |
---|
| 129 | + if (bRep != null) |
---|
| 130 | + { |
---|
| 131 | + bRep.SaveSupports(); |
---|
| 132 | + } |
---|
| 133 | + |
---|
| 134 | + for (int i = 0; i < Size(); i++) |
---|
| 135 | + { |
---|
| 136 | + Object3D child = (Object3D) get(i); |
---|
| 137 | + if (child == null) |
---|
| 138 | + continue; |
---|
| 139 | + blockloop = true; |
---|
| 140 | + child.SaveSupports(); |
---|
| 141 | + blockloop = false; |
---|
| 142 | + } |
---|
149 | 143 | } |
---|
150 | | - |
---|
151 | | - for (int i = 0; i < Size(); i++) |
---|
| 144 | + |
---|
| 145 | + void RestoreSupports() |
---|
152 | 146 | { |
---|
153 | | - Object3D child = (Object3D) get(i); |
---|
154 | | - if (child == null) |
---|
155 | | - continue; |
---|
156 | | - blockloop = true; |
---|
157 | | - child.RestoreSupports(); |
---|
158 | | - blockloop = false; |
---|
| 147 | + if (blockloop) |
---|
| 148 | + return; |
---|
| 149 | + |
---|
| 150 | + support = transientsupport; |
---|
| 151 | + link2master = transientlink2master; |
---|
| 152 | + transientsupport = null; |
---|
| 153 | + transientlink2master = false; |
---|
| 154 | + |
---|
| 155 | + if (bRep != null) |
---|
| 156 | + { |
---|
| 157 | + bRep.RestoreSupports(); |
---|
| 158 | + } |
---|
| 159 | + |
---|
| 160 | + for (int i = 0; i < Size(); i++) |
---|
| 161 | + { |
---|
| 162 | + Object3D child = (Object3D) get(i); |
---|
| 163 | + if (child == null) |
---|
| 164 | + continue; |
---|
| 165 | + blockloop = true; |
---|
| 166 | + child.RestoreSupports(); |
---|
| 167 | + blockloop = false; |
---|
| 168 | + } |
---|
159 | 169 | } |
---|
160 | | -} |
---|
| 170 | + |
---|
| 171 | + void ExtractBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 172 | + { |
---|
| 173 | + if (hashtable.containsKey(GetUUID())) |
---|
| 174 | + { |
---|
| 175 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 176 | + |
---|
| 177 | + 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(); |
---|
| 185 | + |
---|
| 186 | + hashtable.put(GetUUID(), o); |
---|
| 187 | + |
---|
| 188 | + for (int i=0; i<Size(); i++) |
---|
| 189 | + { |
---|
| 190 | + get(i).ExtractBigData(hashtable); |
---|
| 191 | + } |
---|
| 192 | + |
---|
| 193 | + ExtractBigData(o); |
---|
| 194 | + } |
---|
| 195 | + |
---|
| 196 | + void ExtractBigData(Object3D o) |
---|
| 197 | + { |
---|
| 198 | + o.bRep = this.bRep; |
---|
| 199 | + if (this.bRep != null) |
---|
| 200 | + { |
---|
| 201 | + o.transientrep = this.bRep.support; |
---|
| 202 | + o.bRep.support = null; |
---|
| 203 | + } |
---|
| 204 | + |
---|
| 205 | + // o.support = this.support; |
---|
| 206 | + // o.fileparent = this.fileparent; |
---|
| 207 | + // if (this.bRep != null) |
---|
| 208 | + // o.bRep = this.bRep.support; |
---|
| 209 | + |
---|
| 210 | + this.bRep = null; |
---|
| 211 | + // if (this.bRep != null) |
---|
| 212 | + // this.bRep.support = null; |
---|
| 213 | + // this.support = null; |
---|
| 214 | + // this.fileparent = null; |
---|
| 215 | + } |
---|
| 216 | + |
---|
| 217 | + void RestoreBigData(java.util.Hashtable<java.util.UUID, Object3D> hashtable) |
---|
| 218 | + { |
---|
| 219 | + if (!hashtable.containsKey(GetUUID())) |
---|
| 220 | + return; |
---|
| 221 | + |
---|
| 222 | + Object3D o = hashtable.get(GetUUID()); |
---|
| 223 | + |
---|
| 224 | + RestoreBigData(o); |
---|
| 225 | + |
---|
| 226 | + hashtable.remove(GetUUID()); |
---|
| 227 | + |
---|
| 228 | + for (int i=0; i<Size(); i++) |
---|
| 229 | + { |
---|
| 230 | + get(i).RestoreBigData(hashtable); |
---|
| 231 | + } |
---|
| 232 | + } |
---|
| 233 | + |
---|
| 234 | + void RestoreBigData(Object3D o) |
---|
| 235 | + { |
---|
| 236 | + this.bRep = o.bRep; |
---|
| 237 | + if (this.bRep != null) |
---|
| 238 | + this.bRep.support = o.transientrep; |
---|
| 239 | + // this.support = o.support; |
---|
| 240 | + // this.fileparent = o.fileparent; |
---|
| 241 | + } |
---|
161 | 242 | |
---|
162 | 243 | // MOCAP SUPPORT |
---|
163 | 244 | double tx,ty,tz,rx,ry,rz; |
---|
.. | .. |
---|
300 | 381 | } |
---|
301 | 382 | |
---|
302 | 383 | boolean live = false; |
---|
| 384 | + boolean dontselect = false; |
---|
303 | 385 | boolean hide = false; |
---|
304 | 386 | boolean link2master = false; // performs reset support/master at each frame |
---|
305 | 387 | boolean marked = false; // animation node |
---|
.. | .. |
---|
481 | 563 | toParent = LA.newMatrix(); |
---|
482 | 564 | fromParent = LA.newMatrix(); |
---|
483 | 565 | } |
---|
| 566 | + |
---|
484 | 567 | if (toParentMarked == null) |
---|
485 | 568 | { |
---|
486 | 569 | if (maxcount != 1) |
---|
487 | 570 | { |
---|
488 | 571 | new Exception().printStackTrace(); |
---|
489 | 572 | } |
---|
| 573 | + |
---|
490 | 574 | toParentMarked = LA.newMatrix(); |
---|
491 | 575 | fromParentMarked = LA.newMatrix(); |
---|
492 | 576 | } |
---|
.. | .. |
---|
774 | 858 | if (step == 0) |
---|
775 | 859 | step = 1; |
---|
776 | 860 | if (maxcount == 0) |
---|
777 | | - maxcount = 2048; // 4; |
---|
| 861 | + maxcount = 128; // 2048; // 4; |
---|
778 | 862 | // if (acceleration == 0) |
---|
779 | 863 | // acceleration = 10; |
---|
780 | 864 | if (delay == 0) // serial |
---|
.. | .. |
---|
1834 | 1918 | if (obj.name == null) |
---|
1835 | 1919 | continue; // can't be a null one |
---|
1836 | 1920 | |
---|
| 1921 | + // Try perfect match first. |
---|
1837 | 1922 | if (n.equals(obj.name)) |
---|
1838 | 1923 | { |
---|
1839 | 1924 | theobj = obj; |
---|
1840 | 1925 | count++; |
---|
1841 | 1926 | } |
---|
1842 | 1927 | } |
---|
| 1928 | + |
---|
| 1929 | + // not needed: n = n.split(":")[0]; // Poser generates a count |
---|
1843 | 1930 | |
---|
1844 | 1931 | if (count != 1) |
---|
1845 | 1932 | for (int i=Size(); --i>=0;) |
---|
.. | .. |
---|
2624 | 2711 | //Touch(); |
---|
2625 | 2712 | } |
---|
2626 | 2713 | |
---|
| 2714 | + void GenNormalsMeshS() |
---|
| 2715 | + { |
---|
| 2716 | + selection.GenNormalsMesh(); |
---|
| 2717 | +// for (int i=0; i<selection.size(); i++) |
---|
| 2718 | +// { |
---|
| 2719 | +// Object3D selectee = (Object3D) selection.elementAt(i); |
---|
| 2720 | +// selectee.GenNormals(crease); |
---|
| 2721 | +// } |
---|
| 2722 | + |
---|
| 2723 | + //Touch(); |
---|
| 2724 | + } |
---|
| 2725 | + |
---|
2627 | 2726 | void ClearColorsS() |
---|
2628 | 2727 | { |
---|
2629 | 2728 | selection.ClearColors(); |
---|
.. | .. |
---|
2755 | 2854 | if (child == null) |
---|
2756 | 2855 | continue; |
---|
2757 | 2856 | child.GenNormals(crease); |
---|
| 2857 | +// Children().release(i); |
---|
| 2858 | + } |
---|
| 2859 | + blockloop = false; |
---|
| 2860 | + } |
---|
| 2861 | + |
---|
| 2862 | + void GenNormalsMesh() |
---|
| 2863 | + { |
---|
| 2864 | + if (blockloop) |
---|
| 2865 | + return; |
---|
| 2866 | + |
---|
| 2867 | + blockloop = true; |
---|
| 2868 | + GenNormalsMesh0(); |
---|
| 2869 | + for (int i = 0; i < Children().Size(); i++) |
---|
| 2870 | + { |
---|
| 2871 | + Object3D child = (Object3D) Children().get(i); // reserve(i); |
---|
| 2872 | + if (child == null) |
---|
| 2873 | + continue; |
---|
| 2874 | + child.GenNormalsMesh(); |
---|
2758 | 2875 | // Children().release(i); |
---|
2759 | 2876 | } |
---|
2760 | 2877 | blockloop = false; |
---|
.. | .. |
---|
2927 | 3044 | } |
---|
2928 | 3045 | } |
---|
2929 | 3046 | |
---|
| 3047 | + void GenNormalsMesh0() |
---|
| 3048 | + { |
---|
| 3049 | + if (bRep != null) |
---|
| 3050 | + { |
---|
| 3051 | + bRep.GenerateNormalsMesh(); |
---|
| 3052 | + Touch(); |
---|
| 3053 | + } |
---|
| 3054 | + } |
---|
| 3055 | + |
---|
2930 | 3056 | void GenNormalsMINE0() |
---|
2931 | 3057 | { |
---|
2932 | 3058 | if (bRep != null) |
---|
.. | .. |
---|
3002 | 3128 | v.fromParent = LA.newMatrix(); |
---|
3003 | 3129 | } |
---|
3004 | 3130 | |
---|
3005 | | - LA.matConcat(v.toParent, toParent, v.toParent); |
---|
3006 | | - LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3131 | +// LA.matConcat(v.toParent, toParent, v.toParent); |
---|
| 3132 | +// LA.matConcat(fromParent, v.fromParent, v.fromParent); |
---|
| 3133 | + LA.matConcat(toParent, v.toParent, v.toParent); |
---|
| 3134 | + LA.matConcat(v.fromParent, fromParent, v.fromParent); |
---|
3007 | 3135 | } |
---|
3008 | 3136 | |
---|
3009 | 3137 | toParent = null; // LA.matIdentity(toParent); |
---|
.. | .. |
---|
3236 | 3364 | bRep.support = null; |
---|
3237 | 3365 | BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); |
---|
3238 | 3366 | // bRep.SplitInTwo(onlyone); // thread... |
---|
3239 | | - temprep.SplitInTwo(reduction34, onlyone); |
---|
| 3367 | + |
---|
| 3368 | + while(temprep.SplitInTwo(reduction34, onlyone)); |
---|
| 3369 | + |
---|
3240 | 3370 | bRep = temprep; |
---|
3241 | 3371 | bRep.support = sup; |
---|
3242 | 3372 | Touch(); |
---|
.. | .. |
---|
4221 | 4351 | } |
---|
4222 | 4352 | } |
---|
4223 | 4353 | |
---|
| 4354 | + void RepairSOV() |
---|
| 4355 | + { |
---|
| 4356 | + if (blockloop) |
---|
| 4357 | + return; |
---|
| 4358 | + |
---|
| 4359 | + String texname = this.GetPigmentTexture(); |
---|
| 4360 | + |
---|
| 4361 | + if (texname.startsWith("sov")) |
---|
| 4362 | + { |
---|
| 4363 | + String[] s = texname.split("/"); |
---|
| 4364 | + |
---|
| 4365 | + String[] sname = s[1].split("Color.pn"); |
---|
| 4366 | + |
---|
| 4367 | + texname = sname[0]; |
---|
| 4368 | + |
---|
| 4369 | + if (sname.length > 1) |
---|
| 4370 | + { |
---|
| 4371 | + texname += "Color.jpg"; |
---|
| 4372 | + } |
---|
| 4373 | + |
---|
| 4374 | + this.SetPigmentTexture("sov/" + texname); |
---|
| 4375 | + } |
---|
| 4376 | + |
---|
| 4377 | + texname = this.GetBumpTexture(); |
---|
| 4378 | + |
---|
| 4379 | + if (texname.startsWith("sov")) |
---|
| 4380 | + { |
---|
| 4381 | + String[] s = texname.split("/"); |
---|
| 4382 | + |
---|
| 4383 | + String[] sname = s[1].split("Bump.pn"); |
---|
| 4384 | + |
---|
| 4385 | + texname = sname[0]; |
---|
| 4386 | + |
---|
| 4387 | + if (sname.length > 1) |
---|
| 4388 | + { |
---|
| 4389 | + texname += "Bump.jpg"; |
---|
| 4390 | + } |
---|
| 4391 | + |
---|
| 4392 | + this.SetBumpTexture("sov/" + texname); |
---|
| 4393 | + } |
---|
| 4394 | + |
---|
| 4395 | + for (int i=0; i<Size(); i++) |
---|
| 4396 | + { |
---|
| 4397 | + blockloop = true; |
---|
| 4398 | + get(i).RepairSOV(); |
---|
| 4399 | + blockloop = false; |
---|
| 4400 | + } |
---|
| 4401 | + } |
---|
| 4402 | + |
---|
4224 | 4403 | void RepairTexture() |
---|
4225 | 4404 | { |
---|
4226 | 4405 | if (this instanceof FileObject || blockloop) |
---|
.. | .. |
---|
4711 | 4890 | |
---|
4712 | 4891 | cTreePath SelectLeaf(int indexcount, boolean deselect) |
---|
4713 | 4892 | { |
---|
4714 | | - if (hide) |
---|
| 4893 | + if (hide || dontselect) |
---|
4715 | 4894 | return null; |
---|
4716 | 4895 | |
---|
4717 | 4896 | if (count <= 0) |
---|
.. | .. |
---|
4737 | 4916 | |
---|
4738 | 4917 | cTreePath Select(int indexcount, boolean deselect) |
---|
4739 | 4918 | { |
---|
4740 | | - if (hide) |
---|
| 4919 | + if (hide || dontselect) |
---|
4741 | 4920 | return null; |
---|
4742 | 4921 | |
---|
4743 | 4922 | if (count <= 0) |
---|
.. | .. |
---|
5363 | 5542 | } |
---|
5364 | 5543 | } |
---|
5365 | 5544 | |
---|
| 5545 | + UUID GetUUID() |
---|
| 5546 | + { |
---|
| 5547 | + if (uuid == null) |
---|
| 5548 | + { |
---|
| 5549 | + // Serial |
---|
| 5550 | + uuid = UUID.randomUUID(); |
---|
| 5551 | + } |
---|
| 5552 | + |
---|
| 5553 | + return uuid; |
---|
| 5554 | + } |
---|
| 5555 | + |
---|
| 5556 | + Object3D GetObject(UUID uid) |
---|
| 5557 | + { |
---|
| 5558 | + if (blockloop) |
---|
| 5559 | + return null; |
---|
| 5560 | + |
---|
| 5561 | + if (GetUUID().equals(uid)) |
---|
| 5562 | + return this; |
---|
| 5563 | + |
---|
| 5564 | + int nb = Size(); |
---|
| 5565 | + for (int i = 0; i < nb; i++) |
---|
| 5566 | + { |
---|
| 5567 | + Object3D child = (Object3D) get(i); |
---|
| 5568 | + |
---|
| 5569 | + if (child == null) |
---|
| 5570 | + continue; |
---|
| 5571 | + |
---|
| 5572 | + blockloop = true; |
---|
| 5573 | + Object3D obj = child.GetObject(uid); |
---|
| 5574 | + blockloop = false; |
---|
| 5575 | + if (obj != null) |
---|
| 5576 | + return obj; |
---|
| 5577 | + } |
---|
| 5578 | + |
---|
| 5579 | + return null; |
---|
| 5580 | + } |
---|
| 5581 | + |
---|
5366 | 5582 | void SetBumpTexture(String tex) |
---|
5367 | 5583 | { |
---|
5368 | 5584 | if (GetTextures() == null) |
---|
.. | .. |
---|
5407 | 5623 | boolean NeedSupport() |
---|
5408 | 5624 | { |
---|
5409 | 5625 | return |
---|
5410 | | - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null |
---|
| 5626 | + CameraPane.SUPPORT && (!CameraPane.movingcamera || (!Globals.FREEZEONMOVE && Globals.isLIVE())) && link2master && /*live &&*/ support != null |
---|
5411 | 5627 | // PROBLEM with CROWD!! |
---|
5412 | 5628 | && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); |
---|
5413 | 5629 | } |
---|
5414 | 5630 | |
---|
5415 | 5631 | static boolean DEBUG_SELECTION = false; |
---|
| 5632 | + |
---|
| 5633 | + boolean IsLive() |
---|
| 5634 | + { |
---|
| 5635 | + if (live) |
---|
| 5636 | + return true; |
---|
| 5637 | + |
---|
| 5638 | + if (parent == null) |
---|
| 5639 | + return false; |
---|
| 5640 | + |
---|
| 5641 | + return parent.IsLive(); |
---|
| 5642 | + } |
---|
5416 | 5643 | |
---|
5417 | 5644 | void Draw(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5418 | 5645 | { |
---|
.. | .. |
---|
5424 | 5651 | } |
---|
5425 | 5652 | |
---|
5426 | 5653 | if (display.DrawMode() == iCameraPane.SELECTION && |
---|
5427 | | - hide) |
---|
| 5654 | + (hide || dontselect)) |
---|
5428 | 5655 | return; |
---|
5429 | 5656 | |
---|
5430 | 5657 | if (name != null && name.contains("sclera")) |
---|
.. | .. |
---|
5475 | 5702 | support = support; |
---|
5476 | 5703 | |
---|
5477 | 5704 | //boolean usecalllists = IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null || !link2master); // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5478 | | - boolean usecalllists = false; // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
| 5705 | + boolean usecalllists = IsLive(); // IsStatic() && GetBRep() != null && (!CameraPane.SUPPORT || support == null) && !link2master; // !(this instanceof cSpring) && !(this instanceof BezierPatch); |
---|
5479 | 5706 | |
---|
5480 | 5707 | if (!usecalllists && bRep != null && bRep.displaylist > 0) |
---|
5481 | 5708 | { |
---|
.. | .. |
---|
5495 | 5722 | boolean selectmode = display.DrawMode() == display.SELECTION || display.IsDebugSelection(); |
---|
5496 | 5723 | |
---|
5497 | 5724 | if (!selectmode && //display.DrawMode() != display.SELECTION && |
---|
5498 | | - (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5725 | + //(touched || (bRep != null && bRep.displaylist <= 0))) |
---|
| 5726 | + (Globals.isLIVE() || touched && (bRep != null && bRep.displaylist <= 0))) |
---|
5499 | 5727 | { |
---|
5500 | 5728 | Globals.lighttouched = true; |
---|
5501 | 5729 | } // all panes... |
---|
| 5730 | + |
---|
5502 | 5731 | //if (usecalllists && display.DrawMode() != display.SELECTION && display.DrawMode() != display.SHADOW && |
---|
5503 | 5732 | if (bRep != null && usecalllists && !selectmode && // june 2013 display.DrawMode() != display.SHADOW && |
---|
5504 | 5733 | (touched || (bRep != null && bRep.displaylist <= 0))) |
---|
.. | .. |
---|
5666 | 5895 | tex = GetTextures(); |
---|
5667 | 5896 | } |
---|
5668 | 5897 | |
---|
5669 | | - display.BindTextures(tex, texres); |
---|
| 5898 | + boolean failedPigment = false; |
---|
| 5899 | + boolean failedBump = false; |
---|
| 5900 | + |
---|
| 5901 | + try |
---|
| 5902 | + { |
---|
| 5903 | + display.BindPigmentTexture(tex, texres); |
---|
| 5904 | + } |
---|
| 5905 | + catch (Exception e) |
---|
| 5906 | + { |
---|
| 5907 | + System.err.println("FAILED: " + this); |
---|
| 5908 | + failedPigment = true; |
---|
| 5909 | + } |
---|
| 5910 | + |
---|
| 5911 | + try |
---|
| 5912 | + { |
---|
| 5913 | + display.BindBumpTexture(tex, texres); |
---|
| 5914 | + } |
---|
| 5915 | + catch (Exception e) |
---|
| 5916 | + { |
---|
| 5917 | + //System.err.println("FAILED: " + this); |
---|
| 5918 | + failedBump = true; |
---|
| 5919 | + } |
---|
5670 | 5920 | |
---|
5671 | 5921 | if (!compiled) |
---|
5672 | 5922 | { |
---|
.. | .. |
---|
5688 | 5938 | } |
---|
5689 | 5939 | } |
---|
5690 | 5940 | |
---|
5691 | | - display.ReleaseTextures(tex); |
---|
| 5941 | + if (!failedBump) |
---|
| 5942 | + display.ReleaseBumpTexture(tex); |
---|
| 5943 | + |
---|
| 5944 | + if (!failedPigment) |
---|
| 5945 | + display.ReleasePigmentTexture(tex); |
---|
5692 | 5946 | |
---|
5693 | 5947 | display.PopMaterial(this, selected); |
---|
5694 | 5948 | } |
---|
.. | .. |
---|
5817 | 6071 | |
---|
5818 | 6072 | void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) |
---|
5819 | 6073 | { |
---|
| 6074 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6075 | + return; |
---|
| 6076 | + |
---|
5820 | 6077 | if (hide) |
---|
5821 | 6078 | return; |
---|
5822 | 6079 | // shadow optimisation |
---|
.. | .. |
---|
5941 | 6198 | { |
---|
5942 | 6199 | if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) |
---|
5943 | 6200 | return; // no shadow for transparent objects |
---|
| 6201 | + |
---|
| 6202 | + if (display.DrawMode() == iCameraPane.SELECTION && dontselect) |
---|
| 6203 | + return; |
---|
5944 | 6204 | |
---|
5945 | 6205 | if (hide) |
---|
5946 | 6206 | return; |
---|
.. | .. |
---|
6907 | 7167 | spot.translate(32, 32); |
---|
6908 | 7168 | spotw = spot.x + spot.width; |
---|
6909 | 7169 | spoth = spot.y + spot.height; |
---|
6910 | | - info.g.setColor(Color.blue); |
---|
| 7170 | + info.g.setColor(Color.cyan); |
---|
6911 | 7171 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
6912 | 7172 | // if (CameraPane.Xmin > spot.x) |
---|
6913 | 7173 | // { |
---|
.. | .. |
---|
6925 | 7185 | // { |
---|
6926 | 7186 | // CameraPane.Ymax = spoth; |
---|
6927 | 7187 | // } |
---|
6928 | | - info.g.drawLine(spotw, spoth, spotw, spoth - 15); |
---|
6929 | | - info.g.drawLine(spotw, spoth, spotw - 15, spoth); |
---|
| 7188 | + // bonhommes info.g.drawLine(spotw, spoth, spotw, spoth - boundary.height/2); // 15 |
---|
| 7189 | + //info.g.drawLine(spotw, spoth, spotw - boundary.width/2, spoth); // 15 |
---|
6930 | 7190 | spot.translate(0, -32); |
---|
6931 | | - info.g.setColor(Color.green); |
---|
| 7191 | + info.g.setColor(Color.yellow); |
---|
6932 | 7192 | info.g.fillRect(spot.x, spot.y, spot.width, spot.height); |
---|
| 7193 | + info.g.setColor(Color.green); |
---|
6933 | 7194 | // if (CameraPane.Xmin > spot.x) |
---|
6934 | 7195 | // { |
---|
6935 | 7196 | // CameraPane.Xmin = spot.x; |
---|
.. | .. |
---|
6981 | 7242 | startX = info.x; |
---|
6982 | 7243 | startY = info.y; |
---|
6983 | 7244 | |
---|
6984 | | - hitSomething = 0; |
---|
| 7245 | + hitSomething = -1; |
---|
6985 | 7246 | cVector origin = new cVector(); |
---|
6986 | 7247 | //LA.xformPos(origin, toParent, origin); |
---|
6987 | 7248 | Rectangle spot = new Rectangle(); |
---|
.. | .. |
---|
7057 | 7318 | //System.out.println("hitSomething = " + hitSomething); |
---|
7058 | 7319 | |
---|
7059 | 7320 | double scale = 0.005f * info.camera.Distance(); |
---|
| 7321 | + |
---|
7060 | 7322 | cVector xlate = new cVector(); |
---|
7061 | 7323 | //cVector xlate2 = new cVector(); |
---|
7062 | 7324 | switch (hitSomething) |
---|
.. | .. |
---|
7205 | 7467 | |
---|
7206 | 7468 | case hitScale: // scale |
---|
7207 | 7469 | double hScale = (double) (info.x - centerPt.x) / 32; |
---|
| 7470 | + double sign = 1; |
---|
| 7471 | + if (hScale < 0) |
---|
| 7472 | + { |
---|
| 7473 | + sign = -1; |
---|
| 7474 | + } |
---|
| 7475 | + hScale = sign*Math.pow(sign*hScale, scale * 50); |
---|
7208 | 7476 | if (hScale < 0.01) |
---|
7209 | 7477 | { |
---|
7210 | | - hScale = 0.01; |
---|
| 7478 | + //hScale = 0.01; |
---|
7211 | 7479 | } |
---|
7212 | | - hScale = Math.pow(hScale, scale * 50); |
---|
7213 | | - if (hScale < 0.01) |
---|
7214 | | - { |
---|
7215 | | - hScale = 0.01; |
---|
7216 | | - } |
---|
| 7480 | + |
---|
7217 | 7481 | double vScale = (double) (info.y - centerPt.y) / 32; |
---|
7218 | | - if (vScale < 0.01) |
---|
| 7482 | + sign = 1; |
---|
| 7483 | + if (vScale < 0) |
---|
7219 | 7484 | { |
---|
7220 | | - vScale = 0.01; |
---|
| 7485 | + sign = -1; |
---|
7221 | 7486 | } |
---|
7222 | | - vScale = Math.pow(vScale, scale * 50); |
---|
| 7487 | + vScale = sign*Math.pow(sign*vScale, scale * 50); |
---|
7223 | 7488 | if (vScale < 0.01) |
---|
7224 | 7489 | { |
---|
7225 | | - vScale = 0.01; |
---|
| 7490 | + //vScale = 0.01; |
---|
7226 | 7491 | } |
---|
7227 | 7492 | LA.matCopy(startMat, toParent); |
---|
7228 | 7493 | /**/ |
---|
.. | .. |
---|
7233 | 7498 | } |
---|
7234 | 7499 | /**/ |
---|
7235 | 7500 | |
---|
| 7501 | + double totalScale = Math.sqrt(hScale*hScale + vScale*vScale) / Math.sqrt(2); |
---|
| 7502 | + |
---|
| 7503 | + if (totalScale < 0.01) |
---|
| 7504 | + { |
---|
| 7505 | + totalScale = 0.01; |
---|
| 7506 | + } |
---|
| 7507 | + |
---|
7236 | 7508 | switch (info.pane.RenderCamera().viewCode) |
---|
7237 | 7509 | { |
---|
7238 | 7510 | case 3: // '\001' |
---|
7239 | | - if (modified) |
---|
| 7511 | + if (modified || opposite) |
---|
7240 | 7512 | { |
---|
7241 | 7513 | //LA.matScale(toParent, 1, hScale, vScale); |
---|
7242 | | - LA.matScale(toParent, vScale, 1, 1); |
---|
| 7514 | + LA.matScale(toParent, totalScale, 1, 1); |
---|
7243 | 7515 | } // vScale, 1); |
---|
7244 | 7516 | else |
---|
7245 | 7517 | { |
---|
7246 | | - LA.matScale(toParent, vScale, vScale, vScale); |
---|
| 7518 | + // EXCEPTION! |
---|
| 7519 | + LA.matScale(toParent, totalScale, totalScale, totalScale); |
---|
7247 | 7520 | } // vScale, 1); |
---|
7248 | 7521 | break; |
---|
7249 | 7522 | |
---|
7250 | 7523 | case 2: // '\002' |
---|
7251 | | - if (modified) |
---|
| 7524 | + if (modified || opposite) |
---|
7252 | 7525 | { |
---|
7253 | 7526 | //LA.matScale(toParent, hScale, 1, vScale); |
---|
7254 | | - LA.matScale(toParent, 1, vScale, 1); |
---|
| 7527 | + LA.matScale(toParent, 1, totalScale, 1); |
---|
7255 | 7528 | } else |
---|
7256 | 7529 | { |
---|
7257 | | - LA.matScale(toParent, vScale, 1, vScale); |
---|
| 7530 | + LA.matScale(toParent, totalScale, 1, totalScale); |
---|
7258 | 7531 | } |
---|
7259 | 7532 | break; |
---|
7260 | 7533 | |
---|
7261 | 7534 | case 1: // '\003' |
---|
7262 | | - if (modified) |
---|
| 7535 | + if (modified || opposite) |
---|
7263 | 7536 | { |
---|
7264 | 7537 | //LA.matScale(toParent, hScale, vScale, 1); |
---|
7265 | | - LA.matScale(toParent, 1, 1, vScale); |
---|
| 7538 | + LA.matScale(toParent, 1, 1, totalScale); |
---|
7266 | 7539 | } else |
---|
7267 | 7540 | { |
---|
7268 | | - LA.matScale(toParent, vScale, vScale, 1); |
---|
| 7541 | + LA.matScale(toParent, totalScale, totalScale, 1); |
---|
7269 | 7542 | } |
---|
7270 | 7543 | break; |
---|
7271 | 7544 | } |
---|
.. | .. |
---|
7406 | 7679 | objname = name + " " + System.identityHashCode(this) + " (" + parent.name + " " + System.identityHashCode(parent) + ")"; |
---|
7407 | 7680 | } else |
---|
7408 | 7681 | { |
---|
7409 | | - objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count /*- 1*/) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
| 7682 | + objname = GetName() + (Math.abs(count) == 1000 ? (count == 1000 ? " " : " * ") : (" (" + (count - 1) + ")")) + /*(IsSelected()?"(selected) ":"") + (touched?"(touched) ":"") */ ""; |
---|
7410 | 7683 | } // + super.toString(); |
---|
7411 | 7684 | //return name + " (" + (SizeOf.deepSizeOf(this)/1024) + "K) " + this.getClass().getName(); |
---|
7412 | 7685 | |
---|
.. | .. |
---|
7490 | 7763 | /*transient*/ cVector2[] projectedVertices = new cVector2[0]; |
---|
7491 | 7764 | |
---|
7492 | 7765 | Object3D /*Composite*/ parent; |
---|
7493 | | - Object3D /*Composite*/ fileparent; |
---|
| 7766 | + Object3D /*Composite*/ fileparent; // In the case of FileObject |
---|
7494 | 7767 | |
---|
7495 | 7768 | double[][] toParent; // dynamic matrix |
---|
7496 | 7769 | double[][] fromParent; |
---|
.. | .. |
---|
7654 | 7927 | private static cVector edge2 = new cVector(); |
---|
7655 | 7928 | //private static cVector norm = new cVector(); |
---|
7656 | 7929 | /*transient private*/ int hitSomething; |
---|
7657 | | - private static final int hitCenter = 1; |
---|
7658 | | - private static final int hitScale = 2; |
---|
7659 | | - private static final int hitRotate = 3; |
---|
| 7930 | + static final int hitCenter = 1; |
---|
| 7931 | + static final int hitScale = 2; |
---|
| 7932 | + static final int hitRotate = 3; |
---|
7660 | 7933 | /*transient*/ /*private*/ int viewCode; // Now used for transparency cache flag |
---|
7661 | 7934 | /*transient*/ private Point centerPt; |
---|
7662 | 7935 | /*transient*/ private int startX; |
---|