.. | .. |
---|
7 | 7 | |
---|
8 | 8 | class BoundaryRep implements java.io.Serializable |
---|
9 | 9 | { |
---|
10 | | - static final long serialVersionUID = -4852664309425035321L; |
---|
| 10 | + static final long serialVersionUID = // VERY old 2008 -5762968998168738314L; |
---|
| 11 | + -4852664309425035321L; |
---|
11 | 12 | |
---|
12 | 13 | transient int displaylist = 0; |
---|
13 | 14 | |
---|
.. | .. |
---|
530 | 531 | static Vertex vertextemp = new Vertex(true); |
---|
531 | 532 | static Vertex vertextemp2 = new Vertex(true); |
---|
532 | 533 | |
---|
533 | | - static double SEUIL = 0.05f; // 0.1 for rag doll; 0.07; |
---|
| 534 | + static double SEUIL = 0.025f; // 0.1 for rag doll; 0.07; |
---|
534 | 535 | |
---|
535 | 536 | // Compute weight of point w/r to this |
---|
536 | 537 | float ComputeWeight(Vertex v, double[][] toRoot, int k) |
---|
.. | .. |
---|
686 | 687 | |
---|
687 | 688 | void RecomputeBasis(BoundaryRep other, double[][] toRoot, Vertex v) |
---|
688 | 689 | { |
---|
| 690 | + CameraPane.CreateSelectedPoint(); |
---|
689 | 691 | CameraPane.selectedpoint. |
---|
690 | 692 | getAverage(cStatic.point1, true); |
---|
691 | 693 | |
---|
.. | .. |
---|
1003 | 1005 | |
---|
1004 | 1006 | v.closestsupport = -1; |
---|
1005 | 1007 | |
---|
| 1008 | + CameraPane.CreateSelectedPoint(); |
---|
1006 | 1009 | CameraPane.selectedpoint. |
---|
1007 | 1010 | getAverage(cStatic.point1, true); |
---|
1008 | 1011 | |
---|
.. | .. |
---|
1261 | 1264 | for (int wi = v0.weights.length; --wi>=0;) |
---|
1262 | 1265 | v[wi] = 0; |
---|
1263 | 1266 | |
---|
| 1267 | + CameraPane.CreateSelectedPoint(); |
---|
1264 | 1268 | CameraPane.selectedpoint. |
---|
1265 | 1269 | getAverage(cStatic.point1, true); |
---|
1266 | 1270 | |
---|
.. | .. |
---|
1398 | 1402 | v0.x = v0.y = v0.z = 0; |
---|
1399 | 1403 | v0.norm.x = v0.norm.y = v0.norm.z = 0; |
---|
1400 | 1404 | |
---|
| 1405 | + CameraPane.CreateSelectedPoint(); |
---|
1401 | 1406 | CameraPane.selectedpoint. |
---|
1402 | 1407 | getAverage(cStatic.point1, true); |
---|
1403 | 1408 | |
---|
.. | .. |
---|
1997 | 2002 | if (v.vertexlinks == null) |
---|
1998 | 2003 | continue; |
---|
1999 | 2004 | |
---|
2000 | | - if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0) |
---|
| 2005 | + // Warning: faster but dangerous |
---|
| 2006 | + if (v.weights != null && v.weights[j] |
---|
| 2007 | + == 0) |
---|
| 2008 | + //< 0.001 * v.totalweight) |
---|
2001 | 2009 | { |
---|
2002 | 2010 | //testweight += v.weights[j-1]; |
---|
2003 | 2011 | continue; |
---|
.. | .. |
---|
3767 | 3775 | |
---|
3768 | 3776 | //tempRep.Unstripify(); |
---|
3769 | 3777 | |
---|
3770 | | - tempRep.GenerateNormals2(crease); |
---|
| 3778 | + tempRep.GenerateNormals(crease); |
---|
3771 | 3779 | |
---|
3772 | 3780 | boolean keepnormal = Vertex.normalmode; |
---|
3773 | 3781 | boolean epsequal = Grafreed.epsequal; |
---|
.. | .. |
---|
3830 | 3838 | if (n == null) |
---|
3831 | 3839 | continue; |
---|
3832 | 3840 | |
---|
| 3841 | + if (v.norm == null) |
---|
| 3842 | + v.norm = new cVector(); |
---|
| 3843 | + |
---|
3833 | 3844 | LA.vecCopy(n, v.norm); |
---|
3834 | 3845 | |
---|
3835 | 3846 | this.SetVertex(v, i); |
---|
.. | .. |
---|
3855 | 3866 | } |
---|
3856 | 3867 | |
---|
3857 | 3868 | Trim(true/*wastrim*/,true,crease,wasstrip,false); |
---|
| 3869 | + } |
---|
| 3870 | + |
---|
| 3871 | + void GenerateNormalsMesh() |
---|
| 3872 | + { |
---|
| 3873 | + if (stripified) |
---|
| 3874 | + { |
---|
| 3875 | + Unstripify(); |
---|
| 3876 | + } |
---|
| 3877 | + |
---|
| 3878 | + if (trimmed) |
---|
| 3879 | + { |
---|
| 3880 | + normals = null; |
---|
| 3881 | + } |
---|
| 3882 | + else |
---|
| 3883 | + { |
---|
| 3884 | + for (int i=VertexCount(); --i>=0;) |
---|
| 3885 | + { |
---|
| 3886 | + Vertex v = GetVertex(i); |
---|
| 3887 | + |
---|
| 3888 | + v.norm = null; |
---|
| 3889 | + } |
---|
| 3890 | + } |
---|
3858 | 3891 | } |
---|
3859 | 3892 | |
---|
3860 | 3893 | void GenNormalsJME() |
---|
.. | .. |
---|
3979 | 4012 | NormalGenerator ng; |
---|
3980 | 4013 | |
---|
3981 | 4014 | if (crease) |
---|
3982 | | - ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4); |
---|
| 4015 | + ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4); |
---|
3983 | 4016 | else |
---|
3984 | 4017 | ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4); |
---|
3985 | 4018 | |
---|
.. | .. |
---|
3997 | 4030 | //System.out.println("NEW = " + positions.length); |
---|
3998 | 4031 | uvmap = new float[ta.getVertexCount() * 2]; |
---|
3999 | 4032 | |
---|
4000 | | - colors = new float[ta.getVertexCount()]; // * 3]; |
---|
4001 | | - |
---|
4002 | 4033 | ta.getCoordinates(0, positions); |
---|
4003 | 4034 | ta.getNormals(0, normals); |
---|
4004 | 4035 | // ta.getColors(0, colors); |
---|
.. | .. |
---|
4006 | 4037 | |
---|
4007 | 4038 | System.out.println("UV = " + uvmap[2] + ", " + uvmap[3] + ";"); |
---|
4008 | 4039 | |
---|
| 4040 | + colors = null; |
---|
| 4041 | +// colors = new float[ta.getVertexCount()]; // * 3]; |
---|
| 4042 | +// |
---|
| 4043 | +// for (int i=colors.length; --i>=0;) |
---|
| 4044 | +// { |
---|
| 4045 | +// colors[i] = 1; |
---|
| 4046 | +// } |
---|
| 4047 | + |
---|
4009 | 4048 | triangles = new int[ta.getVertexCount()]; |
---|
4010 | 4049 | |
---|
4011 | 4050 | for (int i = 0; i < triangles.length; i++) |
---|
.. | .. |
---|
4013 | 4052 | triangles[i] = i; |
---|
4014 | 4053 | } |
---|
4015 | 4054 | |
---|
4016 | | - Untrim(); |
---|
4017 | | - MergeNormals(); |
---|
| 4055 | +// Untrim(); |
---|
| 4056 | + if (!trimmed) |
---|
| 4057 | + MergeNormals(); |
---|
4018 | 4058 | } |
---|
4019 | 4059 | } |
---|
4020 | 4060 | |
---|
.. | .. |
---|
4042 | 4082 | positions = new float[3 * ga.getVertexCount()]; |
---|
4043 | 4083 | normals = new float[3 * ga.getVertexCount()]; |
---|
4044 | 4084 | uvmap = new float[2 * ga.getVertexCount()]; |
---|
4045 | | - colors = new float[1 * ga.getVertexCount()]; |
---|
4046 | 4085 | |
---|
4047 | 4086 | tsa.getCoordinates(0, positions); |
---|
4048 | 4087 | tsa.getNormals(0, normals); |
---|
4049 | 4088 | tsa.getTextureCoordinates(0, 0, uvmap); |
---|
4050 | 4089 | // tsa.getColors(0, colors); |
---|
4051 | | - |
---|
4052 | | - for (int i=colors.length; --i>=0;) |
---|
4053 | | - { |
---|
4054 | | - colors[i] = 1; |
---|
4055 | | - } |
---|
| 4090 | + |
---|
| 4091 | + colors = null; |
---|
| 4092 | +// colors = new float[1 * ga.getVertexCount()]; |
---|
| 4093 | +// for (int i=colors.length; --i>=0;) |
---|
| 4094 | +// { |
---|
| 4095 | +// colors[i] = 1; |
---|
| 4096 | +// } |
---|
4056 | 4097 | |
---|
4057 | 4098 | int stripcount = tsa.getNumStrips(); |
---|
4058 | 4099 | triangles = new int[stripcount]; |
---|
.. | .. |
---|
4061 | 4102 | stripified = true; |
---|
4062 | 4103 | } catch (ClassCastException e) |
---|
4063 | 4104 | { |
---|
| 4105 | + // ??? aug 2019 |
---|
4064 | 4106 | TriangleArray ta = (TriangleArray) ga; |
---|
4065 | 4107 | |
---|
4066 | 4108 | positions = new float[3 * ga.getVertexCount()]; |
---|
.. | .. |
---|
4076 | 4118 | triangles[0] = 3; |
---|
4077 | 4119 | } |
---|
4078 | 4120 | |
---|
4079 | | - Untrim(); |
---|
4080 | | - MergeNormals(); |
---|
| 4121 | + //Untrim(); |
---|
| 4122 | + if (!trimmed) |
---|
| 4123 | + MergeNormals(); |
---|
4081 | 4124 | } |
---|
4082 | 4125 | |
---|
4083 | 4126 | /* |
---|
.. | .. |
---|
4131 | 4174 | |
---|
4132 | 4175 | void MergeNormals() |
---|
4133 | 4176 | { |
---|
| 4177 | + assert(!trimmed); |
---|
| 4178 | + |
---|
4134 | 4179 | boolean smooth = Grafreed.smoothmode; |
---|
4135 | 4180 | boolean link = Grafreed.linkUV; |
---|
4136 | 4181 | Grafreed.smoothmode = true; |
---|
.. | .. |
---|
4942 | 4987 | v./*pos.*/y = positions[i3 + 1]; |
---|
4943 | 4988 | v./*pos.*/z = positions[i3 + 2]; |
---|
4944 | 4989 | |
---|
4945 | | - v.norm.x = normals[i3]; |
---|
4946 | | - v.norm.y = normals[i3 + 1]; |
---|
4947 | | - v.norm.z = normals[i3 + 2]; |
---|
| 4990 | + if (normals == null) |
---|
| 4991 | + { |
---|
| 4992 | + v.norm.x = 0; |
---|
| 4993 | + v.norm.y = 0; |
---|
| 4994 | + v.norm.z = 0; |
---|
| 4995 | + } |
---|
| 4996 | + else |
---|
| 4997 | + { |
---|
| 4998 | + v.norm.x = normals[i3]; |
---|
| 4999 | + v.norm.y = normals[i3 + 1]; |
---|
| 5000 | + v.norm.z = normals[i3 + 2]; |
---|
| 5001 | + } |
---|
4948 | 5002 | |
---|
4949 | 5003 | v.s = uvmap[i2]; |
---|
4950 | 5004 | v.t = uvmap[i2 + 1]; |
---|