.. | .. |
---|
1997 | 1997 | if (v.vertexlinks == null) |
---|
1998 | 1998 | continue; |
---|
1999 | 1999 | |
---|
2000 | | - if (v.weights != null && v.weights[j] < 0.001 * v.totalweight) // == 0) |
---|
| 2000 | + // Warning: faster but dangerous |
---|
| 2001 | + if (v.weights != null && v.weights[j] |
---|
| 2002 | + // == 0) |
---|
| 2003 | + < 0.0001 * v.totalweight) |
---|
2001 | 2004 | { |
---|
2002 | 2005 | //testweight += v.weights[j-1]; |
---|
2003 | 2006 | continue; |
---|
.. | .. |
---|
3857 | 3860 | Trim(true/*wastrim*/,true,crease,wasstrip,false); |
---|
3858 | 3861 | } |
---|
3859 | 3862 | |
---|
| 3863 | + void GenerateNormalsMesh() |
---|
| 3864 | + { |
---|
| 3865 | + if (stripified) |
---|
| 3866 | + { |
---|
| 3867 | + Unstripify(); |
---|
| 3868 | + } |
---|
| 3869 | + |
---|
| 3870 | + if (trimmed) |
---|
| 3871 | + { |
---|
| 3872 | + normals = null; |
---|
| 3873 | + } |
---|
| 3874 | + else |
---|
| 3875 | + { |
---|
| 3876 | + for (int i=VertexCount(); --i>=0;) |
---|
| 3877 | + { |
---|
| 3878 | + Vertex v = GetVertex(i); |
---|
| 3879 | + |
---|
| 3880 | + v.norm = null; |
---|
| 3881 | + } |
---|
| 3882 | + } |
---|
| 3883 | + } |
---|
| 3884 | + |
---|
3860 | 3885 | void GenNormalsJME() |
---|
3861 | 3886 | { |
---|
3862 | 3887 | assert(false); |
---|
.. | .. |
---|
3979 | 4004 | NormalGenerator ng; |
---|
3980 | 4005 | |
---|
3981 | 4006 | if (crease) |
---|
3982 | | - ng = new NormalGenerator(Math.PI/6); // default is 44 degrees (or Math.PI/3); // /4); |
---|
| 4007 | + ng = new NormalGenerator(Math.PI/4); // default is 44 degrees (or Math.PI/3); // /4); |
---|
3983 | 4008 | else |
---|
3984 | 4009 | ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4); |
---|
3985 | 4010 | |
---|
.. | .. |
---|
3997 | 4022 | //System.out.println("NEW = " + positions.length); |
---|
3998 | 4023 | uvmap = new float[ta.getVertexCount() * 2]; |
---|
3999 | 4024 | |
---|
4000 | | - colors = new float[ta.getVertexCount()]; // * 3]; |
---|
4001 | | - |
---|
4002 | 4025 | ta.getCoordinates(0, positions); |
---|
4003 | 4026 | ta.getNormals(0, normals); |
---|
4004 | 4027 | // ta.getColors(0, colors); |
---|
.. | .. |
---|
4006 | 4029 | |
---|
4007 | 4030 | System.out.println("UV = " + uvmap[2] + ", " + uvmap[3] + ";"); |
---|
4008 | 4031 | |
---|
| 4032 | + colors = null; |
---|
| 4033 | +// colors = new float[ta.getVertexCount()]; // * 3]; |
---|
| 4034 | +// |
---|
| 4035 | +// for (int i=colors.length; --i>=0;) |
---|
| 4036 | +// { |
---|
| 4037 | +// colors[i] = 1; |
---|
| 4038 | +// } |
---|
| 4039 | + |
---|
4009 | 4040 | triangles = new int[ta.getVertexCount()]; |
---|
4010 | 4041 | |
---|
4011 | 4042 | for (int i = 0; i < triangles.length; i++) |
---|
.. | .. |
---|
4013 | 4044 | triangles[i] = i; |
---|
4014 | 4045 | } |
---|
4015 | 4046 | |
---|
4016 | | - Untrim(); |
---|
4017 | | - MergeNormals(); |
---|
| 4047 | +// Untrim(); |
---|
| 4048 | + if (!trimmed) |
---|
| 4049 | + MergeNormals(); |
---|
4018 | 4050 | } |
---|
4019 | 4051 | } |
---|
4020 | 4052 | |
---|
.. | .. |
---|
4042 | 4074 | positions = new float[3 * ga.getVertexCount()]; |
---|
4043 | 4075 | normals = new float[3 * ga.getVertexCount()]; |
---|
4044 | 4076 | uvmap = new float[2 * ga.getVertexCount()]; |
---|
4045 | | - colors = new float[1 * ga.getVertexCount()]; |
---|
4046 | 4077 | |
---|
4047 | 4078 | tsa.getCoordinates(0, positions); |
---|
4048 | 4079 | tsa.getNormals(0, normals); |
---|
4049 | 4080 | tsa.getTextureCoordinates(0, 0, uvmap); |
---|
4050 | 4081 | // tsa.getColors(0, colors); |
---|
4051 | | - |
---|
4052 | | - for (int i=colors.length; --i>=0;) |
---|
4053 | | - { |
---|
4054 | | - colors[i] = 1; |
---|
4055 | | - } |
---|
| 4082 | + |
---|
| 4083 | + colors = null; |
---|
| 4084 | +// colors = new float[1 * ga.getVertexCount()]; |
---|
| 4085 | +// for (int i=colors.length; --i>=0;) |
---|
| 4086 | +// { |
---|
| 4087 | +// colors[i] = 1; |
---|
| 4088 | +// } |
---|
4056 | 4089 | |
---|
4057 | 4090 | int stripcount = tsa.getNumStrips(); |
---|
4058 | 4091 | triangles = new int[stripcount]; |
---|
.. | .. |
---|
4061 | 4094 | stripified = true; |
---|
4062 | 4095 | } catch (ClassCastException e) |
---|
4063 | 4096 | { |
---|
| 4097 | + // ??? aug 2019 |
---|
4064 | 4098 | TriangleArray ta = (TriangleArray) ga; |
---|
4065 | 4099 | |
---|
4066 | 4100 | positions = new float[3 * ga.getVertexCount()]; |
---|
.. | .. |
---|
4076 | 4110 | triangles[0] = 3; |
---|
4077 | 4111 | } |
---|
4078 | 4112 | |
---|
4079 | | - Untrim(); |
---|
4080 | | - MergeNormals(); |
---|
| 4113 | + //Untrim(); |
---|
| 4114 | + if (!trimmed) |
---|
| 4115 | + MergeNormals(); |
---|
4081 | 4116 | } |
---|
4082 | 4117 | |
---|
4083 | 4118 | /* |
---|
.. | .. |
---|
4131 | 4166 | |
---|
4132 | 4167 | void MergeNormals() |
---|
4133 | 4168 | { |
---|
| 4169 | + assert(!trimmed); |
---|
| 4170 | + |
---|
4134 | 4171 | boolean smooth = Grafreed.smoothmode; |
---|
4135 | 4172 | boolean link = Grafreed.linkUV; |
---|
4136 | 4173 | Grafreed.smoothmode = true; |
---|
.. | .. |
---|
4942 | 4979 | v./*pos.*/y = positions[i3 + 1]; |
---|
4943 | 4980 | v./*pos.*/z = positions[i3 + 2]; |
---|
4944 | 4981 | |
---|
4945 | | - v.norm.x = normals[i3]; |
---|
4946 | | - v.norm.y = normals[i3 + 1]; |
---|
4947 | | - v.norm.z = normals[i3 + 2]; |
---|
| 4982 | + if (normals == null) |
---|
| 4983 | + { |
---|
| 4984 | + v.norm.x = 0; |
---|
| 4985 | + v.norm.y = 0; |
---|
| 4986 | + v.norm.z = 0; |
---|
| 4987 | + } |
---|
| 4988 | + else |
---|
| 4989 | + { |
---|
| 4990 | + v.norm.x = normals[i3]; |
---|
| 4991 | + v.norm.y = normals[i3 + 1]; |
---|
| 4992 | + v.norm.z = normals[i3 + 2]; |
---|
| 4993 | + } |
---|
4948 | 4994 | |
---|
4949 | 4995 | v.s = uvmap[i2]; |
---|
4950 | 4996 | v.t = uvmap[i2 + 1]; |
---|