BoundaryRep.java | ●●●●● patch | view | raw | blame | history | |
CameraPane.java | ●●●●● patch | view | raw | blame | history | |
Composite.java | ●●●●● patch | view | raw | blame | history | |
Face.java | ●●●●● patch | view | raw | blame | history | |
GenericJoint.java | ●●●●● patch | view | raw | blame | history | |
Globals.java | ●●●●● patch | view | raw | blame | history | |
Grafreed.java | ●●●●● patch | view | raw | blame | history | |
Grid.java | ●●●●● patch | view | raw | blame | history | |
GroupEditor.java | ●●●●● patch | view | raw | blame | history | |
LA.java | ●●●●● patch | view | raw | blame | history | |
Merge.java | ●●●●● patch | view | raw | blame | history | |
ObjEditor.java | ●●●●● patch | view | raw | blame | history | |
Object3D.java | ●●●●● patch | view | raw | blame | history | |
Vertex.java | ●●●●● patch | view | raw | blame | history | |
cVector.java | ●●●●● patch | view | raw | blame | history | |
iCameraPane.java | ●●●●● patch | view | raw | blame | history |
BoundaryRep.java
.. .. @@ -161,6 +161,7 @@ 161 161 || FaceCount() != other.FaceCount() 162 162 || !(indices == null ^ other.indices != null)) // july 2014 163 163 { 164 + // The meshes have different structures.164 165 //new Exception().printStackTrace(); 165 166 trimmed = other.trimmed; 166 167 stripified = other.stripified; .. .. @@ -239,9 +240,16 @@ 239 240 } 240 241 } 241 242 242 - Support[] InitConnections(BoundaryRep other)243 + transient Support[] cachesupports = null;244 +245 + Support[] InitConnections()243 246 { 244 - int n = other.startvertices.length-1;247 + if (cachesupports != null)248 + {249 + return cachesupports;250 + }251 +252 + int n = this.startvertices.length-1;245 253 246 254 Support[] supports = new Support[n]; 247 255 .. .. @@ -253,38 +261,60 @@ 253 261 254 262 for (int object=1; object<=n; object++) 255 263 { 256 - int start = other.startvertices[object-1];257 - int end = other.startvertices[object];264 + int start = this.startvertices[object-1];265 + int end = this.startvertices[object];258 266 259 267 if (start == end) 260 268 continue; // ?? 261 269 270 + /**271 + Vertex v2 = vertextemp;272 + v2.x = averagepoints[object*3];273 + v2.y = averagepoints[object*3+1];274 + v2.z = averagepoints[object*3+2];275 +276 + //v2.set(GetVertex(this.startvertices[subsupport]));277 +278 + // projected point279 + Vertex v3 = vertextemp2;280 + //GetVertex(this.startvertices[subsupport]);281 + v3.x = extremepoints[object*3];282 + v3.y = extremepoints[object*3+1];283 + v3.z = extremepoints[object*3+2];284 +285 + vect3.set(v3); // "X" axis apex286 + vect3.sub(v2); // origin (center)287 + vect3.normalize();288 + /**/289 +262 290 int linkcount = 0; 263 291 264 292 int objectinlist = -1; 293 +294 + Support subsupport = supports[object-1];265 295 266 296 for (int object2=1; object2<=n; object2++) 267 297 { 268 298 for (int i = start; i < end; i++) 269 299 { 270 - Vertex v = other.GetVertex(i);300 + Vertex v = this.GetVertex(i);271 301 272 - //273 - if (other.Contains(v, object2))302 + // Check if v is close enough from any vertex of the given subobject.303 + if (this.Contains(v, object2))274 304 { 275 - if (linkcount == supports[object-1].links.length)305 + if (linkcount == subsupport.links.length)276 306 break; 277 307 278 308 if (object2 == object) 279 309 objectinlist = linkcount; 280 310 281 - supports[object-1].links[linkcount++] = object2;311 + subsupport.links[linkcount++] = object2;282 312 break; 283 313 } 284 314 } 285 315 } 286 316 287 - supports[object-1].links[linkcount] = -1;317 + subsupport.links[linkcount] = -1;288 318 289 319 if (objectinlist == -1) 290 320 assert(objectinlist != -1); .. .. @@ -293,9 +323,9 @@ 293 323 // assert(linkcount > 1); 294 324 295 325 // show main support as blue 296 - int first = supports[object-1].links[0];297 - supports[object-1].links[0] = supports[object-1].links[objectinlist];298 - supports[object-1].links[objectinlist] = first;326 + int first = subsupport.links[0];327 + subsupport.links[0] = subsupport.links[objectinlist];328 + subsupport.links[objectinlist] = first;299 329 } 300 330 301 331 for (int loop = 0; --loop>=0;) .. .. @@ -353,7 +383,7 @@ 353 383 supports = supports2; 354 384 } 355 385 356 - return supports;386 + return cachesupports = supports;357 387 } 358 388 359 389 double Distance2(Vertex v, Vertex v2, double dist2beat, double[][] toRoot, int k) .. .. @@ -598,7 +628,7 @@ 598 628 // ; 599 629 // 600 630 601 - supportsize = supportsizes[subsupport];631 + supportsize = supportminsize[subsupport];602 632 603 633 double K = supportsize / distmax; 604 634 .. .. @@ -650,7 +680,8 @@ 650 680 // if (supportsize * fadefactor > 1) 651 681 // return 1; 652 682 653 - return supportsize * fadefactor;683 + return //supportsize *684 + supportsize * fadefactor;654 685 } 655 686 656 687 void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v) .. .. @@ -952,7 +983,7 @@ 952 983 953 984 // sept 2017 SEUIL = 0.1; // aout 2013 954 985 955 - supports = InitConnections(other);986 + supports = other.InitConnections();956 987 957 988 other.supports = supports; // should be the other way around... 958 989 .. .. @@ -1895,7 +1926,7 @@ 1895 1926 return; 1896 1927 } 1897 1928 1898 - // System.exit(0);1929 + // System.exit(0);1899 1930 1900 1931 cVector vect = new cVector(); 1901 1932 cVector normal = new cVector(); .. .. @@ -1966,7 +1997,7 @@ 1966 1997 if (v.vertexlinks == null) 1967 1998 continue; 1968 1999 1969 - if (v.weights != null && v.weights[j] == 0) // < 0.01 * v.totalweight) // == 0)2000 + if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0)1970 2001 { 1971 2002 //testweight += v.weights[j-1]; 1972 2003 continue; .. .. @@ -2247,6 +2278,8 @@ 2247 2278 2248 2279 transient int lastsoundtime; 2249 2280 2281 + transient boolean once = false;2282 +2250 2283 void setMasterThis0(BoundaryRep other, double[][] toRoot, boolean smooth, boolean marked) 2251 2284 { 2252 2285 if (LA.isIdentity(toRoot)) .. .. @@ -2302,7 +2335,11 @@ 2302 2335 2303 2336 if (v.totalweight == 0) 2304 2337 { 2305 - System.err.println("v.totalweight == 0! --> " + this + " : " + other);2338 + if (!once)2339 + {2340 + System.err.println("v.totalweight == 0! --> " + this + " : " + other);2341 + once = true;2342 + }2306 2343 continue; 2307 2344 } 2308 2345 .. .. @@ -3098,6 +3135,7 @@ 3098 3135 // 3099 3136 // transient VertexCompare[] vertexcompare = null; 3100 3137 3138 + // Check if v0 is close enough from any vertex of the given subobject of this.3101 3139 boolean Contains(Vertex v0, int object) 3102 3140 { 3103 3141 int start = startvertices[object-1]; .. .. @@ -3696,6 +3734,111 @@ 3696 3734 */ 3697 3735 } 3698 3736 3737 + void GenerateNormals2(boolean crease)3738 + {3739 + cVector tempVector = new cVector();3740 +3741 +// java.util.HashMap<cVector, cVector> tableBase = new java.util.HashMap<cVector, cVector>();3742 +//3743 +//3744 +// for (int i=0; i<this.VertexCount(); i++)3745 +// {3746 +// Vertex v = this.GetVertex(i);3747 +//3748 +// tempVector.set(v);3749 +//3750 +// cVector n = tableBase.get(tempVector.ToFloat());3751 +//3752 +// if (n != null)3753 +// {3754 +// continue;3755 +// }3756 +//3757 +// tableBase.put(new cVector(tempVector), new cVector(v.norm));3758 +// }3759 +3760 + BoundaryRep tempSupport = this.support;3761 +3762 + this.support = null;3763 +3764 + BoundaryRep tempRep = (BoundaryRep)Grafreed.clone(this);3765 +3766 + this.support = tempSupport;3767 +3768 + //tempRep.Unstripify();3769 +3770 + tempRep.GenerateNormals2(crease);3771 +3772 + boolean keepnormal = Vertex.normalmode;3773 + boolean epsequal = Grafreed.epsequal;3774 +3775 + Vertex.normalmode = false;3776 + Grafreed.epsequal = false; // A bit strange3777 +3778 + // No need to have a match for vertex counts.3779 +3780 + java.util.HashMap<cVector, cVector> table = new java.util.HashMap<cVector, cVector>();3781 +3782 + for (int i=0; i<tempRep.VertexCount(); i++)3783 + {3784 + Vertex v = tempRep.GetVertex(i);3785 +3786 + cVector n = table.get(tempVector.ToFloat());3787 +3788 + if (v.norm.x == 1 && v.norm.y == 0 && v.norm.z == 0)3789 + {3790 + //continue;3791 + }3792 +3793 + tempVector.set(v);3794 +3795 + //cVector nBase = tableBase.get(tempVector);3796 +3797 + //if (v.norm.dot(nBase) < 0.9)3798 + //{3799 + // continue;3800 + //}3801 +3802 + if (n != null && n.x == 1 && n.y == 0 && n.z == 0)3803 + {3804 + //continue;3805 + }3806 +3807 + if (n != null)3808 + {3809 +// if (n.dot(v.norm) < 0)3810 +// n.sub(v.norm);3811 +// else3812 +// n.add(v.norm);3813 +//3814 +// n.normalize();3815 + continue;3816 + }3817 +3818 + table.put(new cVector(tempVector), new cVector(v.norm));3819 + }3820 +3821 + for (int i=0; i<this.VertexCount(); i++)3822 + {3823 + Vertex v = this.GetVertex(i);3824 +3825 + tempVector.set(v);3826 +3827 + cVector n = table.get(tempVector.ToFloat());3828 +3829 + //if (n.dot(v.norm) < 0)3830 + if (n == null)3831 + continue;3832 +3833 + LA.vecCopy(n, v.norm);3834 +3835 + this.SetVertex(v, i);3836 + }3837 +3838 + Grafreed.epsequal = epsequal;3839 + Vertex.normalmode = keepnormal;3840 + }3841 +3699 3842 void GenerateNormals(boolean crease) 3700 3843 { 3701 3844 boolean wastrim = trimmed; .. .. @@ -3869,6 +4012,9 @@ 3869 4012 { 3870 4013 triangles[i] = i; 3871 4014 } 4015 +4016 + Untrim();4017 + MergeNormals();3872 4018 } 3873 4019 } 3874 4020 .. .. @@ -3929,6 +4075,9 @@ 3929 4075 triangles = new int[1]; 3930 4076 triangles[0] = 3; 3931 4077 } 4078 +4079 + Untrim();4080 + MergeNormals();3932 4081 } 3933 4082 3934 4083 /* .. .. @@ -3978,6 +4127,40 @@ 3978 4127 } 3979 4128 3980 4129 Vertex.normalmode = false; 4130 + }4131 +4132 + void MergeNormals()4133 + {4134 + boolean smooth = Grafreed.smoothmode;4135 + boolean link = Grafreed.linkUV;4136 + Grafreed.smoothmode = true;4137 + Grafreed.linkUV = true;4138 +4139 + System.out.println("#Vertex = " + VertexCount());4140 + System.out.println("#Face = " + FaceCount());4141 +4142 + java.util.HashSet<Vertex> table = new java.util.HashSet<Vertex>();4143 +4144 + for (int i = 0; i < VertexCount(); i++)4145 + {4146 + Vertex v = GetVertex(i);4147 +4148 + if (!table.contains(v))4149 + {4150 + table.add(v);4151 + }4152 + }4153 +4154 + Grafreed.smoothmode = smooth;4155 + Grafreed.linkUV = link;4156 +4157 +// for (int i = 0; i < VertexCount(); i++)4158 +// {4159 +// Vertex v = GetVertex(i);4160 +//4161 +// table.add(v);4162 +// }4163 +3981 4164 } 3982 4165 3983 4166 static cVector temp1 = new cVector(); .. .. @@ -4752,7 +4935,7 @@ 4752 4935 { 4753 4936 i3 = positions.length-3; 4754 4937 i2 = uvmap.length - 2; 4755 - new Exception().printStackTrace();4938 + //new Exception().printStackTrace();4756 4939 } 4757 4940 4758 4941 v./*pos.*/x = positions[i3]; .. .. @@ -5476,17 +5659,27 @@ 5476 5659 5477 5660 transient int nbbadfaces; // ?? = 1000000; 5478 5661 5479 - int ChooseTriangle()5662 + /*5663 + */5664 + int ChooseTriangle(boolean firstEquilateral)5480 5665 { 5481 5666 int chosen = -1; 5482 5667 5483 5668 double minweight = 1E10; 5484 5669 5670 + int step = 8; // ?5671 +5672 + if (firstEquilateral)5673 + step = 1;5674 +5485 5675 nbbadfaces = 0; 5486 - for (int i=0; i<faces.size(); i+=8)5676 + for (int i=0; i<faces.size(); i+=step)5487 5677 // for (int i=faces.size(); (i-=8)>=0;) 5488 5678 { 5489 5679 Face face = (Face) faces.get(i); 5680 +5681 + if (face.used)5682 + continue;5490 5683 5491 5684 if (!Valid(face)) 5492 5685 { .. .. @@ -5496,6 +5689,15 @@ 5496 5689 5497 5690 if (Boundary(face)) 5498 5691 continue; 5692 +5693 +// if (Boundary(face.p))5694 +// continue;5695 +//5696 +// if (Boundary(face.q))5697 +// continue;5698 +//5699 +// if (Boundary(face.r))5700 +// continue;5499 5701 5500 5702 if (!ValidValence(face)) 5501 5703 continue; .. .. @@ -5508,22 +5710,55 @@ 5508 5710 //?? if (face.weight < 0) 5509 5711 // continue; 5510 5712 5511 - double K = 1; // 0.01; // .25;5512 -5513 - double factor = (1-K)*face.nbiterations + K; //*face.weight;5514 -5515 - double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;5516 -5517 - if (minweight > weight)5713 + if (firstEquilateral)5518 5714 { 5519 - minweight = weight;5715 + if (OneFaceUsed(links.get(face.p)))5716 + continue;5717 +5718 + if (OneFaceUsed(links.get(face.q)))5719 + continue;5720 +5721 + if (OneFaceUsed(links.get(face.r)))5722 + continue;5723 +5520 5724 chosen = i; 5521 - if (minweight == 0)5522 - break;5725 + break;5726 + }5727 + else5728 + {5729 + double K = 1; // 0.01; // .25;5730 +5731 + double factor = (1-K)*face.nbiterations + K; //*face.weight;5732 +5733 + double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor;5734 +5735 + if (minweight > weight)5736 + {5737 + minweight = weight;5738 + chosen = i;5739 + if (minweight == 0)5740 + break;5741 + }5523 5742 } 5524 5743 } 5525 5744 5526 5745 return chosen; 5746 + }5747 +5748 + private boolean OneFaceUsed(Vector<Face> faces)5749 + {5750 + if (faces.size() != 6)5751 + return true;5752 +5753 + for (int i=0; i<6; i+=1)5754 + {5755 + if (faces.get(i).used)5756 + {5757 + return true;5758 + }5759 + }5760 +5761 + return false;5527 5762 } 5528 5763 5529 5764 static boolean remove3valence = true; .. .. @@ -5559,7 +5794,7 @@ 5559 5794 } 5560 5795 else 5561 5796 { 5562 - assert(links.size() == vertices.size());5797 + // TODO Grafreed.Assert(links.size() == vertices.size());5563 5798 5564 5799 links.setSize(vertices.size()); 5565 5800 for (int i=vertices.size(); --i>=0;) .. .. @@ -5567,6 +5802,7 @@ 5567 5802 // linkstouched[i] = false; 5568 5803 if (links.get(i) == null) // ?? 5569 5804 { 5805 + new Exception().printStackTrace();5570 5806 links.set(i, new Vector(8)); 5571 5807 // linkstouched[i] = true; 5572 5808 } .. .. @@ -5577,6 +5813,8 @@ 5577 5813 } 5578 5814 } 5579 5815 5816 + boolean once = false;5817 +5580 5818 for (int i=faces.size(); --i>=0;) 5581 5819 { 5582 5820 Face face = (Face) faces.get(i); .. .. @@ -5588,6 +5826,9 @@ 5588 5826 //if (linkstouched[face.r]) 5589 5827 links.get(face.r).add(face); 5590 5828 5829 + if (face.used)5830 + once = true;5831 +5591 5832 face.good = 1; 5592 5833 face.boundary = -1; 5593 5834 } .. .. @@ -6953,6 +7194,10 @@ 6953 7194 return (face.boundary = 1) == 1; 6954 7195 } 6955 7196 7197 + // June 20197198 + if (true)7199 + return (face.boundary = 0) == 1;7200 +6956 7201 // reverse triangle test 6957 7202 q1.set(p); 6958 7203 q2.set(q); .. .. @@ -7402,7 +7647,7 @@ 7402 7647 //InitWeights(); 7403 7648 } 7404 7649 7405 - int chosen = ChooseTriangle(); // Best is slow and not really better7650 + int chosen = ChooseTriangle(true); // Best is slow and not really better7406 7651 7407 7652 if (chosen == -1) 7408 7653 { .. .. @@ -7416,7 +7661,7 @@ 7416 7661 //remove3valence = false; 7417 7662 // InitWeights(); 7418 7663 7419 - chosen = ChooseTriangle();7664 + chosen = ChooseTriangle(true);7420 7665 } 7421 7666 } 7422 7667 .. .. @@ -7692,7 +7937,7 @@ 7692 7937 7693 7938 // boolean lock; 7694 7939 7695 - void SplitInTwo(boolean reduction34, boolean onlyone)7940 + boolean SplitInTwo(boolean reduction34, boolean onlyone)7696 7941 { 7697 7942 if (stripified) 7698 7943 { .. .. @@ -7729,12 +7974,12 @@ 7729 7974 { 7730 7975 System.err.println("EXCEPTION CAUGHT"); 7731 7976 e.printStackTrace(); 7732 - return;7977 + return false;7733 7978 } catch (Error e) 7734 7979 { 7735 7980 System.err.println("ERROR CAUGHT"); 7736 7981 e.printStackTrace(); 7737 - return;7982 + return false;7738 7983 } 7739 7984 7740 7985 System.out.println("# faces = " + faces.size()); .. .. @@ -7744,6 +7989,7 @@ 7744 7989 { 7745 7990 Face face = (Face) faces.get(i); 7746 7991 7992 + face.used = false;7747 7993 face.nbiterations = 1; 7748 7994 face.weight = -1; 7749 7995 face.boundary = -1; .. .. @@ -7795,6 +8041,11 @@ 7795 8041 nbbadfaces = faces.size(); 7796 8042 //remove3valence = true; 7797 8043 8044 + int count = 2;8045 +8046 + if (onlyone)8047 + count = 1;8048 +7798 8049 firstpass = true; 7799 8050 7800 8051 int n = faces.size(); .. .. @@ -7810,8 +8061,9 @@ 7810 8061 System.out.print('.'); 7811 8062 } 7812 8063 System.out.println(); 8064 + boolean atleastone = false;7813 8065 int i = 0; 7814 - while (reduction34 || faces.size() > n/2)8066 + while (true) // reduction34 || faces.size() > n/2)7815 8067 { 7816 8068 if (i++%100 == 0) 7817 8069 { .. .. @@ -7833,6 +8085,8 @@ 7833 8085 { 7834 8086 if (!RemoveOneTriangle()) 7835 8087 break; 8088 +8089 + atleastone = true;7836 8090 } 7837 8091 // if (iterationcount == 0) 7838 8092 // break; .. .. @@ -7843,8 +8097,8 @@ 7843 8097 break; 7844 8098 } 7845 8099 firstpass = false; 7846 - if (onlyone)7847 - break; // one triangle only8100 +// if (--count<0 && !reduction34)8101 +// break; // one triangle only7848 8102 } 7849 8103 7850 8104 InitLinks(false); // for further display .. .. @@ -7860,6 +8114,8 @@ 7860 8114 Trim(true,false,false,false,false); 7861 8115 7862 8116 Globals.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); 8117 +8118 + return atleastone;7863 8119 } 7864 8120 7865 8121 void UpdateIndices(Face face, Face minface) .. .. @@ -7872,18 +8128,21 @@ 7872 8128 face.p = minface.p; 7873 8129 //if (leafweights) 7874 8130 face.good = 0; // false; 8131 + face.used = true;7875 8132 } 7876 8133 if (face.q == minface.p || face.q == minface.q || face.q == minface.r) 7877 8134 { 7878 8135 face.q = minface.p; 7879 8136 //if (leafweights) 7880 8137 face.good = 0; // false; 8138 + face.used = true;7881 8139 } 7882 8140 if (face.r == minface.p || face.r == minface.q || face.r == minface.r) 7883 8141 { 7884 8142 face.r = minface.p; 7885 8143 //if (leafweights) 7886 8144 face.good = 0; // false; 8145 + face.used = true;7887 8146 } 7888 8147 7889 8148 if (face.p >/*=*/ minface.q && face.p < minface.r) .. .. @@ -7943,50 +8202,50 @@ 7943 8202 if (v == 2) 7944 8203 vert = minface.r; 7945 8204 // Face face = (Face) faces.get(i); 7946 - Vector<Face> vertfaces = links.get(vert);7947 - for (int i=vertfaces.size(); --i>=0;)7948 - {7949 - Face face = (Face) vertfaces.get(i);7950 -7951 - // if (face.weight == 10000)7952 - // continue;7953 -7954 - if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||7955 - face.p == minface.q || face.q == minface.q || face.r == minface.q ||7956 - face.p == minface.r || face.q == minface.r || face.r == minface.r)8205 + Vector<Face> vertfaces = links.get(vert);8206 + for (int i=vertfaces.size(); --i>=0;)7957 8207 { 7958 - if (!leafweights)8208 + Face face = (Face) vertfaces.get(i);8209 +8210 + // if (face.weight == 10000)8211 + // continue;8212 +8213 + if (face.p == minface.p || face.q == minface.p || face.r == minface.p ||8214 + face.p == minface.q || face.q == minface.q || face.r == minface.q ||8215 + face.p == minface.r || face.q == minface.r || face.r == minface.r)7959 8216 { 7960 -// if(minfaceweight <= 0)7961 -// assert(minfaceweight > 0);7962 -//7963 -// //FaceWeight(face);7964 -// if(face.weight < 0)7965 -// assert(face.weight >= 0);7966 -7967 - face.weight += minfaceweight;7968 -7969 -// if (face.weight >= 10000)7970 -// assert(face.weight < 10000);8217 + if (!leafweights)8218 + {8219 + // if(minfaceweight <= 0)8220 + // assert(minfaceweight > 0);8221 + //8222 + // //FaceWeight(face);8223 + // if(face.weight < 0)8224 + // assert(face.weight >= 0);8225 +8226 + face.weight += minfaceweight;8227 +8228 + // if (face.weight >= 10000)8229 + // assert(face.weight < 10000);8230 + }8231 + else8232 + face.weight = -1;8233 +8234 + face.nbiterations += 1;8235 + face.boundary = -1;8236 +8237 + Vertex p = (Vertex)vertices.get(face.p);8238 + Vertex q = (Vertex)vertices.get(face.q);8239 + Vertex r = (Vertex)vertices.get(face.r);8240 +8241 + p.boundary = -1;8242 + q.boundary = -1;8243 + r.boundary = -1;7971 8244 } 7972 8245 else 7973 - face.weight = -1;7974 -7975 - face.nbiterations += 1;7976 - face.boundary = -1;7977 -7978 - Vertex p = (Vertex)vertices.get(face.p);7979 - Vertex q = (Vertex)vertices.get(face.q);7980 - Vertex r = (Vertex)vertices.get(face.r);7981 -7982 - p.boundary = -1;7983 - q.boundary = -1;7984 - r.boundary = -1;8246 + assert(false);7985 8247 } 7986 - else7987 - assert(false);7988 8248 } 7989 - }7990 8249 7991 8250 // TouchVertex(minface.p); 7992 8251 // TouchVertex(minface.q); .. .. @@ -8187,6 +8446,7 @@ 8187 8446 for (int i=vertfaces.size(); --i>=0;) 8188 8447 { 8189 8448 Face face = (Face) vertfaces.get(i); 8449 + face.used = true;8190 8450 face.good = 0; // false; 8191 8451 if (leafweights) 8192 8452 face.weight = -1; .. .. @@ -8465,7 +8725,8 @@ 8465 8725 int[] startvertices; 8466 8726 float[] averagepoints; 8467 8727 float[] extremepoints; 8468 - float[] supportsizes; // distance of closest point8728 + float[] supportminsize; // distance of closest point8729 + float[] supportmaxsize; // distance of fartest point8469 8730 8470 8731 transient Hashtable vertextable; 8471 8732 /*transient*/ private Vertex[] verticesCopy; CameraPane.java
.. .. @@ -8022,7 +8022,7 @@ 8022 8022 } 8023 8023 } 8024 8024 8025 - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE8025 + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE8026 8026 { 8027 8027 if (// DrawMode() != 0 || /*tex == null ||*/ 8028 8028 ambientOcclusion ) // || !textureon) .. .. @@ -8067,7 +8067,7 @@ 8067 8067 return; // true; 8068 8068 } 8069 8069 8070 - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)8070 + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception8071 8071 { 8072 8072 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; 8073 8073 .. .. @@ -8184,7 +8184,9 @@ 8184 8184 texturedata = GetFileTexture(cachename, processbump, resolution); 8185 8185 8186 8186 8187 - if (texturedata != null)8187 + if (texturedata == null)8188 + throw new Exception();8189 +8188 8190 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); 8189 8191 //texture = GetTexture(tex, bump); 8190 8192 } .. .. @@ -8306,7 +8308,7 @@ 8306 8308 return texture; 8307 8309 } 8308 8310 8309 - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)8311 + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception8310 8312 { 8311 8313 CacheTexture texture = GetCacheTexture(tex, bump, resolution); 8312 8314 .. .. @@ -8324,14 +8326,14 @@ 8324 8326 return texture!=null?texture.texture:null; 8325 8327 } 8326 8328 8327 - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)8329 + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception8328 8330 { 8329 8331 CacheTexture texture = GetCacheTexture(tex, bump, resolution); 8330 8332 8331 8333 return texture!=null?texture.texturedata:null; 8332 8334 } 8333 8335 8334 - boolean BindTexture(String tex, boolean bump, int resolution)8336 + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception8335 8337 { 8336 8338 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) 8337 8339 { .. .. @@ -10798,7 +10800,16 @@ 10798 10800 // Bump noise 10799 10801 gl.glActiveTexture(GL.GL_TEXTURE6); 10800 10802 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); 10801 - BindTexture(NOISE_TEXTURE, false, 2);10803 +10804 + try10805 + {10806 + BindTexture(NOISE_TEXTURE, false, 2);10807 + }10808 + catch (Exception e)10809 + {10810 + System.err.println("FAILED: " + NOISE_TEXTURE);10811 + }10812 +10802 10813 10803 10814 gl.glActiveTexture(GL.GL_TEXTURE0); 10804 10815 gl.glEnable(GL.GL_TEXTURE_2D); .. .. @@ -11354,7 +11365,14 @@ 11354 11365 11355 11366 usedtextures.clear(); 11356 11367 11357 - BindTextures(DEFAULT_TEXTURES, 2);11368 + try11369 + {11370 + BindTextures(DEFAULT_TEXTURES, 2);11371 + }11372 + catch (Exception e)11373 + {11374 + System.err.println("FAILED: " + DEFAULT_TEXTURES);11375 + }11358 11376 } 11359 11377 //System.out.println("--> " + stackdepth); 11360 11378 // GrafreeD.traceon(); .. .. @@ -11445,7 +11463,14 @@ 11445 11463 if (checker != null && DrawMode() == DEFAULT) 11446 11464 { 11447 11465 //BindTexture(IMMORTAL_TEXTURE); 11448 - BindTextures(checker.GetTextures(), checker.texres);11466 + try11467 + {11468 + BindTextures(checker.GetTextures(), checker.texres);11469 + }11470 + catch (Exception e)11471 + {11472 + System.err.println("FAILED: " + checker.GetTextures());11473 + }11449 11474 // NEAREST 11450 11475 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); 11451 11476 DrawChecker(gl); .. .. @@ -16602,7 +16627,7 @@ 16602 16627 //gl.glColorMask(false, false, false, false); 16603 16628 16604 16629 //render_scene_from_light_view(gl, drawable, 0, 0); 16605 - if (Globals.RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())16630 + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())16606 16631 { 16607 16632 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); 16608 16633 Composite.java
.. .. @@ -866,7 +866,14 @@ 866 866 tex = GetTextures(); 867 867 } 868 868 869 - display.BindTextures(tex, texres);869 + try870 + {871 + display.BindTextures(tex, texres);872 + }873 + catch (Exception e)874 + {875 + System.err.println("FAILED: " + this);876 + }870 877 871 878 if (//true) // new NORMAND 872 879 touched || softtouched) Face.java
.. .. @@ -31,6 +31,8 @@ 31 31 //cVector norm; 32 32 //short flags; 33 33 34 + transient boolean used;35 +34 36 transient float weight; // face weight using normals if leaf or maximum of all recursive elements 35 37 transient int good; // vertex links broken 36 38 transient int boundary; GenericJoint.java
.. .. @@ -557,7 +557,8 @@ 557 557 bRep.startvertices = new int[numObjects]; 558 558 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3]; 559 559 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3]; 560 - bRep.supportsizes = new float[(bRep.startvertices.length-1)];560 + bRep.supportminsize = new float[(bRep.startvertices.length-1)];561 + bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];561 562 buildrep = true; 562 563 563 564 initialmatrices = new ObjectArrayList<Transform>(); .. .. @@ -1225,11 +1226,12 @@ 1225 1226 } 1226 1227 else 1227 1228 { 1228 - if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportsizes == null)1229 + if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportminsize == null || bRep.supportmaxsize == null)1229 1230 { 1230 1231 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3]; 1231 1232 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3]; 1232 - bRep.supportsizes = new float[(bRep.startvertices.length-1)];1233 + bRep.supportminsize = new float[(bRep.startvertices.length-1)];1234 + bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];1233 1235 } 1234 1236 1235 1237 float averagex = 0; .. .. @@ -1299,7 +1301,8 @@ 1299 1301 } 1300 1302 } 1301 1303 1302 - bRep.supportsizes[currentobject-1] = (float)Math.sqrt(mindist2);1304 + bRep.supportminsize[currentobject-1] = (float)Math.sqrt(mindist2);1305 + bRep.supportmaxsize[currentobject-1] = (float)Math.sqrt(maxdist2);1303 1306 } 1304 1307 1305 1308 // if (hull.numTriangles() > 0) Globals.java
.. .. @@ -1,12 +1,13 @@ 1 1 2 2 public class Globals 3 3 { 4 - public static boolean ADVANCED = false;4 + public static boolean ADVANCED = true; //false;5 5 6 6 static iCameraPane theRenderer; 7 7 8 8 private static boolean LIVE = false; 9 9 public static boolean RENDERSHADOW = true; 10 + public static boolean FREEZEONMOVE = false; // true;10 11 11 12 static boolean CROWD = false; 12 13 static public int drawMode = iCameraPane.DEFAULT; // WARNING Grafreed.java
.. .. @@ -23,6 +23,8 @@ 23 23 static float epsvertex2 = 0.001f; 24 24 static boolean linkUV = false; // not uniform at load time 25 25 26 + static boolean smoothmode = false;27 +26 28 static Wav wav = new Wav("/Users/nbriere/0ut/wavs/monoformat"); // output"); 27 29 static boolean hassound = false; 28 30 static boolean savesound = false; Grid.java
.. .. @@ -4,7 +4,7 @@ 4 4 5 5 Grid() 6 6 { 7 - this(35, 34);7 + this(36, 36);8 8 } 9 9 10 10 Grid(int u, int v) GroupEditor.java
.. .. @@ -210,10 +210,6 @@ 210 210 oe.menuBar.add(menu = new Menu("Setting")); 211 211 if (Globals.ADVANCED) 212 212 { 213 - resetMeshItem = menu.add(new MenuItem("Reset All"));214 - resetMeshItem.addActionListener(this);215 - stepAllItem = menu.add(new MenuItem("Step All"));216 - stepAllItem.addActionListener(this);217 213 revertMeshItem = menu.add(new MenuItem("Revert Meshes")); 218 214 revertMeshItem.addActionListener(this); 219 215 resetreferencesItem = menu.add(new MenuItem("Reset Mesh References")); .. .. @@ -372,6 +368,10 @@ 372 368 oe.menuBar.add(menu = new Menu("Attributes")); 373 369 clearMaterialsItem = menu.add(new MenuItem("Clear Materials")); 374 370 clearMaterialsItem.addActionListener(this); 371 + resetAllItem = menu.add(new MenuItem("Reset All"));372 + resetAllItem.addActionListener(this);373 + stepAllItem = menu.add(new MenuItem("Step All"));374 + stepAllItem.addActionListener(this);375 375 menu.add("-"); 376 376 liveleavesItem = menu.add(new MenuItem("Live Leaves")); 377 377 liveleavesItem.addActionListener(this); .. .. @@ -493,7 +493,7 @@ 493 493 //this.AddOptions(oe.toolbarPanel, oe.aConstraints); 494 494 495 495 oe.toolbarPanel.add(liveCB = new cCheckBox("Live", Globals.isLIVE())); //, oe.aConstraints); 496 - liveCB.setToolTipText("Enabled animation");496 + liveCB.setToolTipText("Enable animation");497 497 liveCB.addItemListener(this); 498 498 499 499 oe.toolbarPanel.add(oneStepButton = new cButton("Step", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); .. .. @@ -2281,7 +2281,7 @@ 2281 2281 { 2282 2282 RevertMeshes(); 2283 2283 } else 2284 - if (source == resetMeshItem)2284 + if (source == resetAllItem)2285 2285 { 2286 2286 ResetAll(); 2287 2287 } else .. .. @@ -3652,7 +3652,16 @@ 3652 3652 String pigment = Object3D.GetPigment(tex); 3653 3653 //String bump = Object3D.GetBump(tex); 3654 3654 3655 - com.sun.opengl.util.texture.TextureData texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);3655 + com.sun.opengl.util.texture.TextureData texturedata = null;3656 +3657 + try3658 + {3659 + texturedata = Globals.theRenderer.GetTextureData(pigment, false, node.texres);3660 + }3661 + catch (Exception e)3662 + {3663 + System.err.println("FAIL: " + node);3664 + }3656 3665 3657 3666 double s = v.s; 3658 3667 .. .. @@ -5131,7 +5140,7 @@ 5131 5140 private MenuItem linkverticesItem; 5132 5141 private MenuItem relinkverticesItem; 5133 5142 private MenuItem setMasterItem; 5134 - private MenuItem resetMeshItem;5143 + private MenuItem resetAllItem;5135 5144 private MenuItem stepAllItem; 5136 5145 private MenuItem revertMeshItem; 5137 5146 private MenuItem poseMeshItem; LA.java
.. .. @@ -88,6 +88,9 @@ 88 88 89 89 static void vecCopy(cVector a, cVector b) 90 90 { 91 + Grafreed.Assert (a != null);92 + assert (b != null);93 +91 94 b.x = a.x; 92 95 b.y = a.y; 93 96 b.z = a.z; Merge.java
.. .. @@ -134,6 +134,7 @@ 134 134 transient cVector maxima = new cVector(); 135 135 136 136 // ObjectArrayList<Transform> initialmatrices; 137 + transient boolean rendered = false;137 138 138 139 void DrawNode(iCameraPane display, Object3D /*Composite*/ root, boolean selected) // ?? 139 140 { .. .. @@ -153,6 +154,8 @@ 153 154 { 154 155 e.printStackTrace(); 155 156 } 157 +158 + rendered = true;156 159 } 157 160 158 161 super.DrawNode(display, root, selected); .. .. @@ -260,7 +263,8 @@ 260 263 bRep.startvertices = new int[NumGeometries(GetObject()) + 1]; 261 264 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3]; 262 265 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3]; 263 - bRep.supportsizes = new float[(bRep.startvertices.length-1)];266 + bRep.supportminsize = new float[(bRep.startvertices.length-1)];267 + bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];264 268 buildrep = true; 265 269 266 270 // initialmatrices = new ObjectArrayList<Transform>(); .. .. @@ -686,11 +690,12 @@ 686 690 } 687 691 else 688 692 { 689 - if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportsizes == null)693 + if (bRep.averagepoints == null || bRep.extremepoints == null || bRep.supportminsize == null || bRep.supportmaxsize == null)690 694 { 691 695 bRep.averagepoints = new float[(bRep.startvertices.length-1) * 3]; 692 696 bRep.extremepoints = new float[(bRep.startvertices.length-1) * 3]; 693 - bRep.supportsizes = new float[(bRep.startvertices.length-1)];697 + bRep.supportminsize = new float[(bRep.startvertices.length-1)];698 + bRep.supportmaxsize = new float[(bRep.startvertices.length-1)];694 699 } 695 700 696 701 float averagex = 0; .. .. @@ -731,42 +736,47 @@ 731 736 v.norm.normalize(); 732 737 } 733 738 734 - int index3 = currentobject-1;735 - index3 *= 3;736 -737 - bRep.averagepoints[index3] = averagex/count;738 - bRep.averagepoints[index3+1] = averagey/count;739 - bRep.averagepoints[index3+2] = averagez/count;740 -741 - double mindist2 = 1E10f;742 - double maxdist2 = -1E10f;743 -744 - for (int i=bRep.startvertices[currentobject-1]; i<bRep.startvertices[currentobject]; i++)739 + if (!rendered)745 740 { 746 - Vertex v = bRep.GetVertex(i);747 -748 - double x = v.x - bRep.averagepoints[index3];749 - double y = v.y - bRep.averagepoints[index3+1];750 - double z = v.z - bRep.averagepoints[index3+2];751 -752 - double dist2 = x*x + y*y + z*z;753 -754 - if (mindist2 > dist2)755 - mindist2 = dist2;756 - if (maxdist2 < dist2)741 + int index3 = currentobject-1;742 + index3 *= 3;743 +744 + bRep.averagepoints[index3] = averagex/count;745 + bRep.averagepoints[index3+1] = averagey/count;746 + bRep.averagepoints[index3+2] = averagez/count;747 +748 + double mindist2 = 1E10f;749 + double maxdist2 = -1E10f;750 +751 + for (int i=bRep.startvertices[currentobject-1]; i<bRep.startvertices[currentobject]; i++)757 752 { 758 - maxdist2 = dist2;759 - bRep.extremepoints[index3] = (float)v.x;760 - bRep.extremepoints[index3+1] = (float)v.y;761 - bRep.extremepoints[index3+2] = (float)v.z;753 + Vertex v = bRep.GetVertex(i);754 +755 + double x = v.x - bRep.averagepoints[index3];756 + double y = v.y - bRep.averagepoints[index3+1];757 + double z = v.z - bRep.averagepoints[index3+2];758 +759 + double dist2 = x*x + y*y + z*z;760 +761 + if (mindist2 > dist2)762 + mindist2 = dist2;763 +764 + if (maxdist2 < dist2)765 + {766 + maxdist2 = dist2;767 + bRep.extremepoints[index3] = (float)v.x;768 + bRep.extremepoints[index3+1] = (float)v.y;769 + bRep.extremepoints[index3+2] = (float)v.z;770 + }762 771 } 772 +773 + bRep.supportminsize[currentobject-1] = (float)Math.sqrt(mindist2);774 + bRep.supportmaxsize[currentobject-1] = (float)Math.sqrt(maxdist2);775 + // for (int i = 0; i < hull.numVertices(); i++)776 + // {777 + //778 + // }763 779 } 764 -765 - bRep.supportsizes[currentobject-1] = (float)Math.sqrt(mindist2);766 -// for (int i = 0; i < hull.numVertices(); i++)767 -// {768 -//769 -// }770 780 } 771 781 772 782 // if (hull.numTriangles() > 0) ObjEditor.java
.. .. @@ -784,6 +784,7 @@ 784 784 // NumberSlider vDivsField; 785 785 // JCheckBox endcaps; 786 786 JCheckBox liveCB; 787 + JCheckBox selectCB;787 788 JCheckBox hideCB; 788 789 JCheckBox link2masterCB; 789 790 JCheckBox markCB; .. .. @@ -986,9 +987,11 @@ 986 987 987 988 liveCB = AddCheckBox(setupPanel, "Live", copy.live); 988 989 liveCB.setToolTipText("Animate object"); 990 + selectCB = AddCheckBox(setupPanel, "Select", !copy.dontselect);991 + selectCB.setToolTipText("Make object selectable");992 +// Return();989 993 hideCB = AddCheckBox(setupPanel, "Hide", copy.hide); 990 994 hideCB.setToolTipText("Hide object"); 991 -// Return();992 995 markCB = AddCheckBox(setupPanel, "Mark", copy.marked); 993 996 markCB.setToolTipText("Set the animation target transform"); 994 997 .. .. @@ -1028,7 +1031,7 @@ 1028 1031 oe.ctrlPanel.add(commandsPanel); 1029 1032 oe.ctrlPanel.Return(); 1030 1033 1031 - pushPanel = AddSlider(oe.ctrlPanel, "Push", -10, 10, 0, 1);1034 + pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons1032 1035 normalpushField = (cNumberSlider)pushPanel.getComponent(1); 1033 1036 //Return(); 1034 1037 .. .. @@ -3007,6 +3010,10 @@ 3007 3010 { 3008 3011 copy.live ^= true; 3009 3012 return; 3013 + } else if (event.getSource() == selectCB)3014 + {3015 + copy.dontselect ^= true;3016 + return;3010 3017 } else if (event.getSource() == hideCB) 3011 3018 { 3012 3019 copy.hide ^= true; .. .. @@ -3588,7 +3595,7 @@ 3588 3595 } 3589 3596 3590 3597 if (normalpushField != null) 3591 - copy.NORMALPUSH = (float)normalpushField.getFloat()/1000;3598 + copy.NORMALPUSH = (float)normalpushField.getFloat()/100;3592 3599 } 3593 3600 3594 3601 void SnapObject() Object3D.java
.. .. @@ -300,6 +300,7 @@ 300 300 } 301 301 302 302 boolean live = false; 303 + boolean dontselect = false;303 304 boolean hide = false; 304 305 boolean link2master = false; // performs reset support/master at each frame 305 306 boolean marked = false; // animation node .. .. @@ -1834,12 +1835,15 @@ 1834 1835 if (obj.name == null) 1835 1836 continue; // can't be a null one 1836 1837 1838 + // Try perfect match first.1837 1839 if (n.equals(obj.name)) 1838 1840 { 1839 1841 theobj = obj; 1840 1842 count++; 1841 1843 } 1842 1844 } 1845 +1846 + // not needed: n = n.split(":")[0]; // Poser generates a count1843 1847 1844 1848 if (count != 1) 1845 1849 for (int i=Size(); --i>=0;) .. .. @@ -3002,8 +3006,10 @@ 3002 3006 v.fromParent = LA.newMatrix(); 3003 3007 } 3004 3008 3005 - LA.matConcat(v.toParent, toParent, v.toParent);3006 - LA.matConcat(fromParent, v.fromParent, v.fromParent);3009 +// LA.matConcat(v.toParent, toParent, v.toParent);3010 +// LA.matConcat(fromParent, v.fromParent, v.fromParent);3011 + LA.matConcat(toParent, v.toParent, v.toParent);3012 + LA.matConcat(v.fromParent, fromParent, v.fromParent);3007 3013 } 3008 3014 3009 3015 toParent = null; // LA.matIdentity(toParent); .. .. @@ -3236,7 +3242,9 @@ 3236 3242 bRep.support = null; 3237 3243 BoundaryRep temprep = (BoundaryRep) Grafreed.clone(bRep); 3238 3244 // bRep.SplitInTwo(onlyone); // thread... 3239 - temprep.SplitInTwo(reduction34, onlyone);3245 +3246 + while(temprep.SplitInTwo(reduction34, onlyone));3247 +3240 3248 bRep = temprep; 3241 3249 bRep.support = sup; 3242 3250 Touch(); .. .. @@ -4711,7 +4719,7 @@ 4711 4719 4712 4720 cTreePath SelectLeaf(int indexcount, boolean deselect) 4713 4721 { 4714 - if (hide)4722 + if (hide || dontselect)4715 4723 return null; 4716 4724 4717 4725 if (count <= 0) .. .. @@ -4737,7 +4745,7 @@ 4737 4745 4738 4746 cTreePath Select(int indexcount, boolean deselect) 4739 4747 { 4740 - if (hide)4748 + if (hide || dontselect)4741 4749 return null; 4742 4750 4743 4751 if (count <= 0) .. .. @@ -5407,7 +5415,7 @@ 5407 5415 boolean NeedSupport() 5408 5416 { 5409 5417 return 5410 - CameraPane.SUPPORT && !CameraPane.movingcamera && link2master && /*live &&*/ support != null5418 + CameraPane.SUPPORT && (!CameraPane.movingcamera || !Globals.FREEZEONMOVE) && link2master && /*live &&*/ support != null5411 5419 // PROBLEM with CROWD!! 5412 5420 && (Globals.DrawMode() == iCameraPane.SHADOW || !Globals.RENDERSHADOW || Globals.CROWD); 5413 5421 } .. .. @@ -5424,7 +5432,7 @@ 5424 5432 } 5425 5433 5426 5434 if (display.DrawMode() == iCameraPane.SELECTION && 5427 - hide)5435 + (hide || dontselect))5428 5436 return; 5429 5437 5430 5438 if (name != null && name.contains("sclera")) .. .. @@ -5666,7 +5674,17 @@ 5666 5674 tex = GetTextures(); 5667 5675 } 5668 5676 5669 - display.BindTextures(tex, texres);5677 + boolean failed = false;5678 +5679 + try5680 + {5681 + display.BindTextures(tex, texres);5682 + }5683 + catch (Exception e)5684 + {5685 + System.err.println("FAILED: " + this);5686 + failed = true;5687 + }5670 5688 5671 5689 if (!compiled) 5672 5690 { .. .. @@ -5688,7 +5706,8 @@ 5688 5706 } 5689 5707 } 5690 5708 5691 - display.ReleaseTextures(tex);5709 + if (!failed)5710 + display.ReleaseTextures(tex);5692 5711 5693 5712 display.PopMaterial(this, selected); 5694 5713 } .. .. @@ -5817,6 +5836,9 @@ 5817 5836 5818 5837 void drawSelf(iCameraPane display, Object3D /*Composite*/ root, boolean selected, boolean blocked) 5819 5838 { 5839 + if (display.DrawMode() == iCameraPane.SELECTION && dontselect)5840 + return;5841 +5820 5842 if (hide) 5821 5843 return; 5822 5844 // shadow optimisation .. .. @@ -5942,6 +5964,9 @@ 5942 5964 if (display.DrawMode() == display.SHADOW && projectedVertices != null && projectedVertices.length > 2 && projectedVertices[2].y >= 10000) 5943 5965 return; // no shadow for transparent objects 5944 5966 5967 + if (display.DrawMode() == iCameraPane.SELECTION && dontselect)5968 + return;5969 +5945 5970 if (hide) 5946 5971 return; 5947 5972 Vertex.java
.. .. @@ -112,7 +112,6 @@ 112 112 { 113 113 //if (normalmode) // pos == null) 114 114 // return 0; 115 -116 115 if (norm == null || !normalmode) 117 116 { 118 117 return /*pos.*/ super.hashCode(); .. .. @@ -129,12 +128,26 @@ 129 128 Vertex vert = (Vertex) o; 130 129 131 130 //System.out.println("pos = " + pos + "; vert.pos = " + vert/*.pos*/); 131 +132 + double tolerance = 0.00001;133 +134 + if (!Grafreed.epsequal)135 + tolerance = 0;132 136 133 - return Math.abs(/*pos.*/x - vert./*pos.*/x) +134 - Math.abs(/*pos.*/y - vert./*pos.*/y) +135 - Math.abs(/*pos.*/z - vert./*pos.*/z) < 0.00001 && // GrafreeD.epsvertex2 && // WARNING: USE 0.0001 for serial issues136 - (Grafreed.linkUV || Math.abs(s - vert.s) + Math.abs(t - vert.t) < 0.00001)137 - ; // GrafreeD.epsvertex2;137 + boolean samepos = Math.abs(/*pos.*/x - vert./*pos.*/x) +138 + Math.abs(/*pos.*/y - vert./*pos.*/y) +139 + Math.abs(/*pos.*/z - vert./*pos.*/z) <= tolerance && // GrafreeD.epsvertex2 && // WARNING: USE 0.0001 for serial issues140 + (Grafreed.linkUV || Math.abs(s - vert.s) + Math.abs(t - vert.t) <= tolerance)141 + ; // GrafreeD.epsvertex2;142 +143 + if (samepos && Grafreed.smoothmode)144 + {145 + norm.add(vert.norm);146 + norm.normalize();147 + vert.norm.set(norm);148 + }149 +150 + return samepos;138 151 } 139 152 /* 140 153 public boolean isSame(Object o) cVector.java
.. .. @@ -63,6 +63,15 @@ 63 63 } 64 64 } 65 65 66 + cVector ToFloat()67 + {68 + x = (float)x;69 + y = (float)y;70 + z = (float)z;71 +72 + return this;73 + }74 +66 75 void set(cVector v) 67 76 { 68 77 x = v.x; .. .. @@ -247,18 +256,21 @@ 247 256 return "[" + x0 + ", " + y0 + ", " + z0 + "]"; 248 257 } 249 258 250 - /*251 259 public boolean equals(Object o) 252 260 { 253 261 //if (true) return false; 254 262 255 263 cVector vert = (cVector) o; 256 264 265 + double tolerance = 0.00001;266 +267 + if (!Grafreed.epsequal)268 + tolerance = 0;269 +257 270 return Math.abs(x - vert.x) + 258 271 Math.abs(y - vert.y) + 259 - Math.abs(z - vert.z) < 0.01;272 + Math.abs(z - vert.z) <= tolerance;260 273 } 261 - */262 274 263 275 public int hashCode() 264 276 { iCameraPane.java
.. .. @@ -55,7 +55,7 @@ 55 55 56 56 void DrawString(Object3D obj); 57 57 58 - void BindTextures(cTexture tex, int resolution);58 + void BindTextures(cTexture tex, int resolution) throws Exception;59 59 void ReleaseTextures(cTexture tex); 60 60 61 61 void DrawFace(Object3D obj, Vertex pv, Vertex qv, Vertex rv, Face face); .. .. @@ -82,7 +82,7 @@ 82 82 83 83 void setCursor(java.awt.Cursor cursor); 84 84 85 - com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution);85 + com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception;86 86 87 87 void repaint(); 88 88