.. | .. |
---|
15 | 15 | { |
---|
16 | 16 | this(0, 0); |
---|
17 | 17 | } |
---|
18 | | - |
---|
| 18 | + |
---|
19 | 19 | void SaveSupports() |
---|
20 | 20 | { |
---|
21 | 21 | transientsupport = support; |
---|
.. | .. |
---|
172 | 172 | bufV = other.bufV; |
---|
173 | 173 | bufF = other.bufF; |
---|
174 | 174 | |
---|
175 | | - positions = (float[]) GraphreeD.clone(other.positions); |
---|
176 | | - normals = (float[]) GraphreeD.clone(other.normals); |
---|
177 | | - colors = (float[]) GraphreeD.clone(other.colors); |
---|
178 | | - uvmap = (float[]) GraphreeD.clone(other.uvmap); |
---|
179 | | - triangles = (int[]) GraphreeD.clone(other.triangles); |
---|
| 175 | + positions = (float[]) GrafreeD.clone(other.positions); |
---|
| 176 | + normals = (float[]) GrafreeD.clone(other.normals); |
---|
| 177 | + colors = (float[]) GrafreeD.clone(other.colors); |
---|
| 178 | + uvmap = (float[]) GrafreeD.clone(other.uvmap); |
---|
| 179 | + triangles = (int[]) GrafreeD.clone(other.triangles); |
---|
180 | 180 | |
---|
181 | | - indices = (int[]) GraphreeD.clone(other.indices); |
---|
| 181 | + indices = (int[]) GrafreeD.clone(other.indices); |
---|
182 | 182 | |
---|
183 | | - vertices = (Vector<Vertex>) GraphreeD.clone(other.vertices); |
---|
184 | | - faces = (Vector<Face>) GraphreeD.clone(other.faces); |
---|
| 183 | + vertices = (Vector<Vertex>) GrafreeD.clone(other.vertices); |
---|
| 184 | + faces = (Vector<Face>) GrafreeD.clone(other.faces); |
---|
185 | 185 | } |
---|
186 | 186 | else |
---|
187 | 187 | { |
---|
.. | .. |
---|
497 | 497 | return dist2; |
---|
498 | 498 | } |
---|
499 | 499 | |
---|
500 | | - static Vertex vertextemp = new Vertex(); |
---|
501 | | - static Vertex vertextemp2 = new Vertex(); |
---|
| 500 | + static Vertex vertextemp = new Vertex(true); |
---|
| 501 | + static Vertex vertextemp2 = new Vertex(true); |
---|
502 | 502 | |
---|
503 | | - static double SEUIL = 0.1; // 0.1 for rag doll; 0.07; |
---|
| 503 | + static double SEUIL = 0.1f; // 0.1 for rag doll; 0.07; |
---|
504 | 504 | |
---|
505 | 505 | // Compute weight of point w/r to this |
---|
506 | 506 | float ComputeWeight(Vertex v, double[][] toRoot, int k) |
---|
.. | .. |
---|
570 | 570 | |
---|
571 | 571 | if (dot > distmax) |
---|
572 | 572 | dot = distmax; |
---|
| 573 | + //return 0; // patch for strange behavior |
---|
573 | 574 | if (dot < -distmax) |
---|
574 | 575 | dot = -distmax; |
---|
| 576 | + //return 0; // patch for strange behavior |
---|
575 | 577 | |
---|
576 | 578 | // v3 = GetVertex(this.startvertices[subsupport] + 16); |
---|
577 | 579 | // |
---|
.. | .. |
---|
609 | 611 | |
---|
610 | 612 | float dist2 = (float)Distance2(v, v2, 1E10, toRoot, k); |
---|
611 | 613 | |
---|
612 | | - if (dist2 >= 2 * SEUIL*SEUIL) // && !CameraPane.CROWD) // weightmode |
---|
| 614 | + double seuil = SEUIL * 2; |
---|
| 615 | + |
---|
| 616 | + if (dist2 >= 2 * seuil*seuil) // && !CameraPane.CROWD) // weightmode |
---|
613 | 617 | return 0; |
---|
614 | 618 | |
---|
615 | | - dist2 /= 2 * SEUIL*SEUIL; // multiplied by two because center of support |
---|
| 619 | + dist2 /= 2 * seuil*seuil; // multiplied by two because center of support |
---|
616 | 620 | // could be far from closest point |
---|
617 | 621 | |
---|
618 | 622 | // dist2 = Math.pow(dist2, 2); |
---|
.. | .. |
---|
786 | 790 | v.weights[k] = other.ComputeWeight(v, toRoot, k); // (float)(supportsize * normalweight * nz / Math.pow(tx*tx+ty*ty+tz*tz, 1)); |
---|
787 | 791 | v.totalweight += v.weights[k]; |
---|
788 | 792 | |
---|
789 | | - if (CameraPane.CROWD) |
---|
| 793 | + if (Globals.CROWD) |
---|
790 | 794 | { |
---|
791 | 795 | // System.out.print("weight = " + v.weights[k]); |
---|
792 | 796 | // System.out.println("; totalweight = " + v.totalweight); |
---|
.. | .. |
---|
946 | 950 | |
---|
947 | 951 | int nbsupports; |
---|
948 | 952 | |
---|
949 | | - SEUIL = 0.1; // aout 2013 |
---|
| 953 | + // sept 2017 SEUIL = 0.1; // aout 2013 |
---|
950 | 954 | |
---|
951 | 955 | supports = InitConnections(other); |
---|
952 | 956 | |
---|
.. | .. |
---|
982 | 986 | |
---|
983 | 987 | int subsupports = 0; |
---|
984 | 988 | |
---|
985 | | - SEUIL = 0.1; // aout 2013 |
---|
| 989 | + // sept 2017 SEUIL = 0.1; // aout 2013 |
---|
986 | 990 | |
---|
987 | 991 | while (subsupports == 0) |
---|
988 | 992 | { |
---|
.. | .. |
---|
1006 | 1010 | |
---|
1007 | 1011 | vect.set(v); |
---|
1008 | 1012 | vect.sub(vect2); |
---|
| 1013 | + |
---|
| 1014 | +// vertextemp.x = other.averagepoints[c*3]; |
---|
| 1015 | +// vertextemp.y = other.averagepoints[c*3+1]; |
---|
| 1016 | +// vertextemp.z = other.averagepoints[c*3+2]; |
---|
| 1017 | +// |
---|
| 1018 | +// Vertex v3 = vertextemp2; |
---|
| 1019 | +// v3.x = other.extremepoints[c*3]; |
---|
| 1020 | +// v3.y = other.extremepoints[c*3+1]; |
---|
| 1021 | +// v3.z = other.extremepoints[c*3+2]; |
---|
| 1022 | +// |
---|
| 1023 | +// vect3.set(v3); // "X" axis apex |
---|
| 1024 | +// vect3.sub(vertextemp); // origin (center) |
---|
| 1025 | +// |
---|
| 1026 | +// double distmax = vect3.length(); |
---|
| 1027 | +// |
---|
| 1028 | +// vect3.set(v2); // "X" axis apex |
---|
| 1029 | +// vect3.sub(vertextemp); // origin (center) |
---|
| 1030 | +// |
---|
| 1031 | +// if (vect3.length() >= distmax) |
---|
| 1032 | +// continue; |
---|
1009 | 1033 | |
---|
1010 | 1034 | if (mindistance > vect.dot(vect)) |
---|
1011 | 1035 | { |
---|
.. | .. |
---|
1017 | 1041 | |
---|
1018 | 1042 | subsupports = v.closestsupport==-1 ? 0 : supports[v.closestsupport].Length(); |
---|
1019 | 1043 | |
---|
1020 | | - SEUIL *= 2; |
---|
| 1044 | + // previously for "contains", now for weights. |
---|
| 1045 | + assert(subsupports > 0); |
---|
| 1046 | + //SEUIL *= 2; |
---|
1021 | 1047 | } |
---|
1022 | 1048 | |
---|
1023 | 1049 | assert(subsupports > 0); |
---|
.. | .. |
---|
1492 | 1518 | InitFaceIndices(); |
---|
1493 | 1519 | } |
---|
1494 | 1520 | |
---|
1495 | | - BoundaryRep rep = (BoundaryRep) GraphreeD.clone(this); |
---|
| 1521 | + BoundaryRep rep = (BoundaryRep) GrafreeD.clone(this); |
---|
1496 | 1522 | //float[] v = new float[100]; |
---|
1497 | 1523 | |
---|
1498 | 1524 | for (int loops=1; --loops>=0;) |
---|
.. | .. |
---|
1522 | 1548 | InitFaceIndices(); |
---|
1523 | 1549 | } |
---|
1524 | 1550 | |
---|
1525 | | - BoundaryRep rep = (BoundaryRep) GraphreeD.clone(this); |
---|
| 1551 | + BoundaryRep rep = (BoundaryRep) GrafreeD.clone(this); |
---|
1526 | 1552 | //float[] v = new float[100]; |
---|
1527 | 1553 | |
---|
1528 | 1554 | for (int loops=10; --loops>=0;) |
---|
.. | .. |
---|
2163 | 2189 | // if (slow) |
---|
2164 | 2190 | // aout 2013 |
---|
2165 | 2191 | // sept 2013 merde... |
---|
2166 | | - W = 13; |
---|
| 2192 | + W = 3; // 13; |
---|
2167 | 2193 | |
---|
2168 | 2194 | // POSERATE |
---|
2169 | 2195 | if (CameraPane.tickcount > 0 || CameraPane.SLOWPOSE) |
---|
.. | .. |
---|
2600 | 2626 | // if (stepout && !playedonce) |
---|
2601 | 2627 | // { |
---|
2602 | 2628 | // // sound |
---|
2603 | | -// GraphreeD.wav.play(); |
---|
| 2629 | +// GrafreeD.wav.play(); |
---|
2604 | 2630 | // playedonce = true; |
---|
2605 | 2631 | // } |
---|
2606 | 2632 | // |
---|
.. | .. |
---|
2642 | 2668 | tmp.set(v); |
---|
2643 | 2669 | tmp.sub(eye); |
---|
2644 | 2670 | |
---|
2645 | | - if (CameraPane.framecount - lastsoundtime > 30) // 0.25 secs |
---|
| 2671 | + if (Globals.framecount - lastsoundtime > 30) // 0.25 secs |
---|
2646 | 2672 | { |
---|
2647 | | - GraphreeD.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1); |
---|
| 2673 | + GrafreeD.wav.play((Math.random()+0.5)/Math.max(tmp.length2(),0.2)); //, 1); |
---|
2648 | 2674 | |
---|
2649 | | - lastsoundtime = CameraPane.framecount; |
---|
| 2675 | + lastsoundtime = Globals.framecount; |
---|
2650 | 2676 | } |
---|
2651 | 2677 | |
---|
2652 | 2678 | stepout = false; |
---|
.. | .. |
---|
3229 | 3255 | k /= x*x + y*y; |
---|
3230 | 3256 | } |
---|
3231 | 3257 | else |
---|
3232 | | - GraphreeD.Assert(z == 1); |
---|
| 3258 | + GrafreeD.Assert(z == 1); |
---|
3233 | 3259 | |
---|
3234 | 3260 | if (k < 0) |
---|
3235 | 3261 | k = 0; |
---|
.. | .. |
---|
3531 | 3557 | e.printStackTrace(); |
---|
3532 | 3558 | } |
---|
3533 | 3559 | |
---|
3534 | | - Trim(wastrim,true,crease,wasstrip,false); |
---|
| 3560 | + Trim(true/*wastrim*/,true,crease,wasstrip,false); |
---|
3535 | 3561 | } |
---|
3536 | 3562 | |
---|
3537 | 3563 | void GenNormalsJME() |
---|
.. | .. |
---|
3776 | 3802 | for (int i = 0; i < VertexCount(); i++) |
---|
3777 | 3803 | { |
---|
3778 | 3804 | Vertex v = GetVertex(i); |
---|
| 3805 | + |
---|
| 3806 | + vertextemp.set(v); |
---|
| 3807 | + |
---|
3779 | 3808 | //if (v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
3780 | 3809 | { |
---|
3781 | | - GenerateNormal(i, v); |
---|
3782 | | - SetVertex(v, i); |
---|
| 3810 | + if (!GenerateNormal(i, vertextemp)) |
---|
| 3811 | + continue; |
---|
| 3812 | + |
---|
| 3813 | + if (v.norm.dot(vertextemp.norm) < 0) |
---|
| 3814 | + vertextemp.norm.mul(-1); |
---|
| 3815 | + |
---|
| 3816 | + if (v.norm.dot(vertextemp.norm) < 0.9) |
---|
| 3817 | + SetVertex(vertextemp, i); |
---|
3783 | 3818 | } |
---|
3784 | 3819 | } |
---|
3785 | 3820 | |
---|
.. | .. |
---|
3790 | 3825 | static cVector temp2 = new cVector(); |
---|
3791 | 3826 | static cVector temp3 = new cVector(); |
---|
3792 | 3827 | |
---|
3793 | | - void GenerateNormal(int index, Vertex v) |
---|
| 3828 | + boolean GenerateNormal(int index, Vertex v) |
---|
3794 | 3829 | { |
---|
3795 | 3830 | //System.out.println("Old normal = " + v.norm); |
---|
3796 | 3831 | LA.setVector(v.norm, 0, 0, 0); |
---|
.. | .. |
---|
3819 | 3854 | LA.vecSub(p/*.pos*/, v/*.pos*/, temp1); |
---|
3820 | 3855 | LA.vecSub(q/*.pos*/, v/*.pos*/, temp2); |
---|
3821 | 3856 | } |
---|
| 3857 | + else |
---|
| 3858 | + { |
---|
| 3859 | + continue; |
---|
| 3860 | + } |
---|
3822 | 3861 | |
---|
3823 | 3862 | //LA.vecNormalize(temp1); |
---|
3824 | 3863 | //LA.vecNormalize(temp2); |
---|
.. | .. |
---|
3829 | 3868 | double s = temp3.length(); |
---|
3830 | 3869 | //double c = temp2.dot(temp1); |
---|
3831 | 3870 | |
---|
| 3871 | + if (s == 0) |
---|
| 3872 | + return false; |
---|
| 3873 | + |
---|
3832 | 3874 | float angle = 1; // (float) Math.atan2(s, c); |
---|
3833 | 3875 | //if(angle < 0) angle = -angle; |
---|
3834 | 3876 | |
---|
3835 | 3877 | //LA.vecNormalize(temp3); |
---|
3836 | 3878 | LA.vecScale(temp3, angle / s); |
---|
3837 | 3879 | |
---|
| 3880 | +// if (temp3.dot(v.norm) < 0) |
---|
| 3881 | +// assert(temp3.dot(v.norm) >= 0); |
---|
| 3882 | + |
---|
3838 | 3883 | LA.vecAdd(temp3, v.norm, v.norm); |
---|
3839 | 3884 | } |
---|
3840 | 3885 | |
---|
3841 | 3886 | LA.vecNormalize(v.norm); |
---|
3842 | 3887 | //System.out.println("New normal = " + v.norm); |
---|
| 3888 | + |
---|
| 3889 | + return true; |
---|
3843 | 3890 | } |
---|
3844 | 3891 | |
---|
3845 | 3892 | double Arccos(double x) |
---|
.. | .. |
---|
4233 | 4280 | int count = VertexCount(); |
---|
4234 | 4281 | |
---|
4235 | 4282 | // mars 2014 |
---|
4236 | | - while (step >= count) |
---|
| 4283 | + while (step > count) |
---|
4237 | 4284 | step /= 10; |
---|
4238 | 4285 | |
---|
4239 | 4286 | for (int i = 0; i < count; i+=step) |
---|
.. | .. |
---|
4846 | 4893 | return verticesCopy; |
---|
4847 | 4894 | } |
---|
4848 | 4895 | |
---|
4849 | | - void PreprocessOcclusion(CameraPane cp, double[][] transform) |
---|
| 4896 | + void PreprocessOcclusion(iCameraPane cp, double[][] transform) |
---|
4850 | 4897 | { |
---|
4851 | 4898 | if (//!trimmed || |
---|
4852 | 4899 | AOdone) |
---|
.. | .. |
---|
4855 | 4902 | return; |
---|
4856 | 4903 | } |
---|
4857 | 4904 | |
---|
4858 | | - Camera keep = cp.renderCamera; |
---|
4859 | | - cp.renderCamera = localcamera; |
---|
4860 | | - |
---|
4861 | | - if (trimmed) |
---|
4862 | | - { |
---|
4863 | | - float[] colors = new float[positions.length / 3]; |
---|
4864 | | - |
---|
4865 | | - int i3 = 0; |
---|
4866 | | - for (int i = 0; i < positions.length / 3; i++, i3 += 3) |
---|
4867 | | - { |
---|
4868 | | - if (normals[i3] == 0 && normals[i3+1] == 0 && normals[i3+2] == 0) |
---|
4869 | | - continue; |
---|
4870 | | - |
---|
4871 | | - from.set(positions[i3], positions[i3 + 1], positions[i3 + 2]); |
---|
4872 | | - to.set(positions[i3] + normals[i3], |
---|
4873 | | - positions[i3 + 1] + normals[i3 + 1], |
---|
4874 | | - positions[i3 + 2] + normals[i3 + 2]); |
---|
4875 | | - LA.xformPos(from, transform, from); |
---|
4876 | | - LA.xformPos(to, transform, to); // RIGID ONLY |
---|
4877 | | - localcamera.setAim(from, to); |
---|
4878 | | - |
---|
4879 | | - CameraPane.occlusionbuffer.display(); |
---|
4880 | | - |
---|
4881 | | - if (CameraPane.DEBUG_OCCLUSION) |
---|
4882 | | - cp.display(); // debug |
---|
4883 | | - |
---|
4884 | | - colors[i] = cp.vertexOcclusion.r; |
---|
4885 | | - //colors[i3 + 1] = cp.vertexOcclusion.g; |
---|
4886 | | - //colors[i3 + 2] = cp.vertexOcclusion.b; |
---|
4887 | | - |
---|
4888 | | - if ((i % 1000) == 0 && i != 0) |
---|
4889 | | - { |
---|
4890 | | - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
4891 | | - //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
4892 | | - System.out.println((int) (100.0 * i / (positions.length / 3)) + "% (" + i + " of " + (positions.length / 3) + ")"); |
---|
4893 | | - } |
---|
4894 | | - } |
---|
4895 | | - |
---|
4896 | | - this.colors = colors; |
---|
4897 | | - } |
---|
4898 | | - else |
---|
4899 | | - { |
---|
4900 | | - for (int i = 0; i < VertexCount(); i++) |
---|
4901 | | - { |
---|
4902 | | - Vertex v = GetVertex(i); |
---|
4903 | | - |
---|
4904 | | - if (v.norm.x == 0 && v.norm.y == 0 && v.norm.z == 0) |
---|
4905 | | - continue; |
---|
4906 | | - |
---|
4907 | | - from.set(v.x, v.y, v.z); |
---|
4908 | | - to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
4909 | | - LA.xformPos(from, transform, from); |
---|
4910 | | - LA.xformPos(to, transform, to); // RIGID ONLY |
---|
4911 | | - localcamera.setAim(from, to); |
---|
4912 | | - |
---|
4913 | | - CameraPane.occlusionbuffer.display(); |
---|
4914 | | - |
---|
4915 | | - if (CameraPane.DEBUG_OCCLUSION) |
---|
4916 | | - cp.display(); // debug |
---|
4917 | | - |
---|
4918 | | - v.AO = cp.vertexOcclusion.r; |
---|
4919 | | - |
---|
4920 | | - if ((i % 1000) == 0 && i != 0) |
---|
4921 | | - { |
---|
4922 | | - CameraPane.theRenderer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); |
---|
4923 | | - //System.out.println("Color = " + cp.vertexOcclusion.r + ", " + cp.vertexOcclusion.g + ", " + cp.vertexOcclusion.b + "; " + (int)(100.0*i/(positions.length/3)) + "% done"); |
---|
4924 | | - System.out.println((int) (100.0 * i / VertexCount()) + "% (" + i + " of " + VertexCount() + ")"); |
---|
4925 | | - } |
---|
4926 | | - } |
---|
4927 | | - } |
---|
4928 | | - |
---|
4929 | | - System.out.println("done."); |
---|
4930 | | - |
---|
4931 | | - cp.renderCamera = keep; |
---|
| 4905 | + cp.PrepOcclusion(this, transform); |
---|
4932 | 4906 | |
---|
4933 | 4907 | AOdone = true; |
---|
4934 | 4908 | } |
---|
.. | .. |
---|
5036 | 5010 | } |
---|
5037 | 5011 | } |
---|
5038 | 5012 | colors = null; |
---|
| 5013 | + } |
---|
| 5014 | + |
---|
| 5015 | + void CreateMesh(iHeightField hf, int x, int y) |
---|
| 5016 | + { |
---|
| 5017 | + BoundaryRep tmp = new BoundaryRep(); |
---|
| 5018 | + |
---|
| 5019 | + int vc = 0; |
---|
| 5020 | + |
---|
| 5021 | + Vertex v = new Vertex(true); |
---|
| 5022 | + |
---|
| 5023 | + for (int i=0; i<x; i++) |
---|
| 5024 | + { |
---|
| 5025 | + for (int j=0; j<y; j++) |
---|
| 5026 | + { |
---|
| 5027 | +// Vertex v = tmp.GetVertex(vc++); |
---|
| 5028 | + |
---|
| 5029 | + v.s = v.x = i; |
---|
| 5030 | + v.t = v.z = j; |
---|
| 5031 | + v.s /= x; v.t /= y; |
---|
| 5032 | + v.y = hf.f(i,j); |
---|
| 5033 | + |
---|
| 5034 | + int iu = tmp.AddTableVertex(v); |
---|
| 5035 | + |
---|
| 5036 | + v.s = v.x = i+1; |
---|
| 5037 | + v.t = v.z = j; |
---|
| 5038 | + v.s /= x; v.t /= y; |
---|
| 5039 | + v.y = hf.f(i+1,j); |
---|
| 5040 | + |
---|
| 5041 | + int iv = tmp.AddTableVertex(v); |
---|
| 5042 | + |
---|
| 5043 | + v.s = v.x = i+1; |
---|
| 5044 | + v.t = v.z = j+1; |
---|
| 5045 | + v.s /= x; v.t /= y; |
---|
| 5046 | + v.y = hf.f(i+1,j+1); |
---|
| 5047 | + |
---|
| 5048 | + int iw = tmp.AddTableVertex(v); |
---|
| 5049 | + |
---|
| 5050 | + v.s = v.x = i; |
---|
| 5051 | + v.t = v.z = j+1; |
---|
| 5052 | + v.s /= x; v.t /= y; |
---|
| 5053 | + v.y = hf.f(i,j+1); |
---|
| 5054 | + |
---|
| 5055 | + int ix = tmp.AddTableVertex(v); |
---|
| 5056 | + |
---|
| 5057 | + tmp.AddFace(iu,iw,iv); |
---|
| 5058 | + tmp.AddFace(iu,ix,iw); |
---|
| 5059 | + } |
---|
| 5060 | + } |
---|
| 5061 | + |
---|
| 5062 | + Set(tmp); |
---|
| 5063 | + |
---|
| 5064 | + Trim(true,false,true); |
---|
| 5065 | + ClearColors(); |
---|
5039 | 5066 | } |
---|
5040 | 5067 | |
---|
5041 | 5068 | void Stripify() |
---|
.. | .. |
---|
5297 | 5324 | double minweight = 1E10; |
---|
5298 | 5325 | |
---|
5299 | 5326 | nbbadfaces = 0; |
---|
5300 | | - for (int i=faces.size(); (i-=8)>=0;) |
---|
| 5327 | + for (int i=0; i<faces.size(); i+=8) |
---|
| 5328 | +// for (int i=faces.size(); (i-=8)>=0;) |
---|
5301 | 5329 | { |
---|
5302 | 5330 | Face face = (Face) faces.get(i); |
---|
5303 | | - |
---|
5304 | | - //?? if (face.weight < 0) |
---|
5305 | | - // continue; |
---|
5306 | | - |
---|
5307 | | - double K = 1; // 0.01; // .25; |
---|
5308 | | - |
---|
5309 | | - double factor = (1-K)*face.nbiterations + K; //*face.weight; |
---|
5310 | | - |
---|
5311 | | - double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor; |
---|
5312 | 5331 | |
---|
5313 | 5332 | if (!Valid(face)) |
---|
5314 | 5333 | { |
---|
.. | .. |
---|
5327 | 5346 | !ValidValence(face.r)) |
---|
5328 | 5347 | continue; |
---|
5329 | 5348 | |
---|
| 5349 | + //?? if (face.weight < 0) |
---|
| 5350 | + // continue; |
---|
| 5351 | + |
---|
| 5352 | + double K = 1; // 0.01; // .25; |
---|
| 5353 | + |
---|
| 5354 | + double factor = (1-K)*face.nbiterations + K; //*face.weight; |
---|
| 5355 | + |
---|
| 5356 | + double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor; |
---|
| 5357 | + |
---|
5330 | 5358 | if (minweight > weight) |
---|
5331 | 5359 | { |
---|
5332 | 5360 | minweight = weight; |
---|
5333 | 5361 | chosen = i; |
---|
| 5362 | + if (minweight == 0) |
---|
| 5363 | + break; |
---|
5334 | 5364 | } |
---|
5335 | 5365 | } |
---|
5336 | 5366 | |
---|
.. | .. |
---|
7019 | 7049 | assert(f2.contains(i)); |
---|
7020 | 7050 | assert(f3.contains(i)); |
---|
7021 | 7051 | |
---|
| 7052 | + // when r is the "center", p is along the boundary |
---|
7022 | 7053 | while (f0.r != i) |
---|
7023 | 7054 | { |
---|
7024 | 7055 | int t = f0.p; |
---|
.. | .. |
---|
7075 | 7106 | f0 = f3; |
---|
7076 | 7107 | f3 = t; |
---|
7077 | 7108 | } |
---|
7078 | | - atleastone = true; |
---|
7079 | 7109 | |
---|
| 7110 | + int va = f0.q; |
---|
| 7111 | + int vb = f0.r; |
---|
| 7112 | + int vc = -1; |
---|
| 7113 | + |
---|
| 7114 | + Face toremove1 = null; |
---|
| 7115 | + Face toremove2 = null; |
---|
| 7116 | + |
---|
| 7117 | + // f0 is the buffer for the first new triangle, |
---|
| 7118 | + // and otherf is the other upper one. |
---|
7080 | 7119 | Face otherf = null; |
---|
7081 | 7120 | |
---|
7082 | 7121 | if (f1.contains(f0.p)) |
---|
7083 | 7122 | { |
---|
7084 | 7123 | if (f1.p == f0.p) |
---|
7085 | 7124 | { |
---|
| 7125 | + assert(false); |
---|
7086 | 7126 | f0.r = f1.q; |
---|
7087 | 7127 | } |
---|
7088 | 7128 | else |
---|
7089 | 7129 | { |
---|
7090 | 7130 | assert(f1.q == f0.p); |
---|
7091 | | - f0.r = f1.p; |
---|
| 7131 | + vc = f1.p; |
---|
7092 | 7132 | } |
---|
7093 | 7133 | |
---|
7094 | 7134 | otherf = f2; |
---|
7095 | | - faces.remove(f1); |
---|
7096 | | - faces.remove(f3); |
---|
| 7135 | + toremove1 = f1; |
---|
| 7136 | + toremove2 = f3; |
---|
7097 | 7137 | } |
---|
7098 | 7138 | else |
---|
7099 | 7139 | if (f2.contains(f0.p)) |
---|
7100 | 7140 | { |
---|
7101 | 7141 | if (f2.p == f0.p) |
---|
7102 | 7142 | { |
---|
| 7143 | + assert(false); |
---|
7103 | 7144 | f0.r = f2.q; |
---|
7104 | 7145 | } |
---|
7105 | 7146 | else |
---|
7106 | 7147 | { |
---|
7107 | 7148 | assert(f2.q == f0.p); |
---|
7108 | | - f0.r = f2.p; |
---|
| 7149 | + vc = f2.p; |
---|
7109 | 7150 | } |
---|
7110 | 7151 | |
---|
7111 | 7152 | otherf = f3; |
---|
7112 | | - faces.remove(f1); |
---|
7113 | | - faces.remove(f2); |
---|
| 7153 | + toremove1 = f1; |
---|
| 7154 | + toremove2 = f2; |
---|
7114 | 7155 | } |
---|
7115 | 7156 | if (f3.contains(f0.p)) |
---|
7116 | 7157 | { |
---|
7117 | 7158 | if (f3.p == f0.p) |
---|
7118 | 7159 | { |
---|
| 7160 | +// assert(false); |
---|
| 7161 | + new Exception().printStackTrace(); |
---|
7119 | 7162 | f0.r = f3.q; |
---|
7120 | 7163 | } |
---|
7121 | 7164 | else |
---|
7122 | 7165 | { |
---|
7123 | 7166 | assert(f3.q == f0.p); |
---|
7124 | | - f0.r = f3.p; |
---|
| 7167 | + vc = f3.p; |
---|
7125 | 7168 | } |
---|
7126 | 7169 | |
---|
7127 | 7170 | otherf = f1; |
---|
7128 | | - faces.remove(f2); |
---|
7129 | | - faces.remove(f3); |
---|
| 7171 | + toremove1 = f2; |
---|
| 7172 | + toremove2 = f3; |
---|
7130 | 7173 | } |
---|
| 7174 | + |
---|
| 7175 | + vertextemp.set(vertices.get(va)); |
---|
| 7176 | + vertextemp.sub(vertices.get(vb)); |
---|
| 7177 | + vertextemp.normalize(); |
---|
| 7178 | + vertextemp2.set(vertices.get(vc)); |
---|
| 7179 | + vertextemp2.sub(vertices.get(vb)); |
---|
| 7180 | + vertextemp2.normalize(); |
---|
| 7181 | + |
---|
| 7182 | + if (vertextemp.dot(vertextemp2) > -0.95) |
---|
| 7183 | + { |
---|
| 7184 | + continue; |
---|
| 7185 | + } |
---|
| 7186 | + |
---|
| 7187 | + atleastone = true; |
---|
| 7188 | + |
---|
| 7189 | + f0.r = vc; |
---|
| 7190 | + |
---|
| 7191 | + faces.remove(toremove1); |
---|
| 7192 | + faces.remove(toremove2); |
---|
7131 | 7193 | |
---|
7132 | 7194 | if (!f0.contains(otherf.p)) |
---|
7133 | 7195 | { |
---|
.. | .. |
---|
7335 | 7397 | Trim(); |
---|
7336 | 7398 | Untrim(); |
---|
7337 | 7399 | |
---|
7338 | | - BoundaryRep tmp = new BoundaryRep(); // (BoundaryRep) GraphreeD.clone(this); |
---|
| 7400 | + BoundaryRep tmp = new BoundaryRep(); // (BoundaryRep) GrafreeD.clone(this); |
---|
7339 | 7401 | |
---|
7340 | 7402 | double minx = Float.POSITIVE_INFINITY; |
---|
7341 | 7403 | double maxx = Float.NEGATIVE_INFINITY; |
---|
.. | .. |
---|
7373 | 7435 | if (max < maxz - minz) |
---|
7374 | 7436 | max = maxz - minz; |
---|
7375 | 7437 | |
---|
7376 | | - tmp.THRESHOLD = max/25; // 50; |
---|
| 7438 | + tmp.THRESHOLD = 0.5; // max/25; // 50; |
---|
7377 | 7439 | |
---|
7378 | 7440 | tmp.faces.clear(); |
---|
7379 | 7441 | |
---|
.. | .. |
---|
7932 | 7994 | |
---|
7933 | 7995 | minface.q = minface.r = minface.p; |
---|
7934 | 7996 | |
---|
| 7997 | + int count = 0; |
---|
| 7998 | + |
---|
7935 | 7999 | for (int i=0; i<faces.size(); i++) |
---|
7936 | 8000 | { |
---|
7937 | 8001 | Face face = (Face) faces.get(i); |
---|
.. | .. |
---|
7943 | 8007 | TouchVertex(face.r, true); // , minface.weight); |
---|
7944 | 8008 | // assert(!lock); |
---|
7945 | 8009 | faces.remove(i--); |
---|
| 8010 | + count++; |
---|
| 8011 | + if (count == 4) |
---|
| 8012 | + break; |
---|
7946 | 8013 | } |
---|
7947 | 8014 | } |
---|
7948 | 8015 | |
---|
.. | .. |
---|
8006 | 8073 | if (!trimmed) |
---|
8007 | 8074 | return; |
---|
8008 | 8075 | |
---|
8009 | | - GraphreeD.linkUV = false; |
---|
| 8076 | + GrafreeD.linkUV = false; |
---|
8010 | 8077 | |
---|
8011 | 8078 | try |
---|
8012 | 8079 | { |
---|
.. | .. |
---|
8214 | 8281 | return "trim = " + trimmed + "; stripped = " + stripified + "; colors = " + colors + "; faces = " + (faces!=null?faces.size():null) + "; triangles = " + (triangles!=null?triangles.length:null) + "; indices = " + indices; |
---|
8215 | 8282 | } |
---|
8216 | 8283 | |
---|
8217 | | - static Camera localcamera = new Camera(); |
---|
8218 | | - static cVector from = new cVector(); |
---|
8219 | | - static cVector to = new cVector(); |
---|
8220 | 8284 | boolean trimmed = false; |
---|
8221 | 8285 | boolean stripified = false; |
---|
8222 | 8286 | transient boolean AOdone = false; |
---|
.. | .. |
---|
8224 | 8288 | /*transient*/ int maxIndexV = 0; |
---|
8225 | 8289 | /*transient*/ int bufV, bufF; |
---|
8226 | 8290 | // Raw version |
---|
8227 | | - private float[] positions; |
---|
8228 | | - private float[] normals; |
---|
| 8291 | + //private |
---|
| 8292 | + float[] positions; |
---|
| 8293 | + //private |
---|
| 8294 | + float[] normals; |
---|
8229 | 8295 | float[] colors; |
---|
8230 | 8296 | private float[] uvmap; |
---|
8231 | 8297 | private int[] triangles; |
---|