Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
BoundaryRep.java
....@@ -1997,7 +1997,10 @@
19971997 if (v.vertexlinks == null)
19981998 continue;
19991999
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.001 * v.totalweight)
20012004 {
20022005 //testweight += v.weights[j-1];
20032006 continue;
....@@ -3857,6 +3860,28 @@
38573860 Trim(true/*wastrim*/,true,crease,wasstrip,false);
38583861 }
38593862
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
+
38603885 void GenNormalsJME()
38613886 {
38623887 assert(false);
....@@ -3979,7 +4004,7 @@
39794004 NormalGenerator ng;
39804005
39814006 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);
39834008 else
39844009 ng = new NormalGenerator(Math.PI); // (Math.PI / 3); // /4);
39854010
....@@ -3997,8 +4022,6 @@
39974022 //System.out.println("NEW = " + positions.length);
39984023 uvmap = new float[ta.getVertexCount() * 2];
39994024
4000
- colors = new float[ta.getVertexCount()]; // * 3];
4001
-
40024025 ta.getCoordinates(0, positions);
40034026 ta.getNormals(0, normals);
40044027 // ta.getColors(0, colors);
....@@ -4006,6 +4029,14 @@
40064029
40074030 System.out.println("UV = " + uvmap[2] + ", " + uvmap[3] + ";");
40084031
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
+
40094040 triangles = new int[ta.getVertexCount()];
40104041
40114042 for (int i = 0; i < triangles.length; i++)
....@@ -4013,8 +4044,9 @@
40134044 triangles[i] = i;
40144045 }
40154046
4016
- Untrim();
4017
- MergeNormals();
4047
+// Untrim();
4048
+ if (!trimmed)
4049
+ MergeNormals();
40184050 }
40194051 }
40204052
....@@ -4042,17 +4074,18 @@
40424074 positions = new float[3 * ga.getVertexCount()];
40434075 normals = new float[3 * ga.getVertexCount()];
40444076 uvmap = new float[2 * ga.getVertexCount()];
4045
- colors = new float[1 * ga.getVertexCount()];
40464077
40474078 tsa.getCoordinates(0, positions);
40484079 tsa.getNormals(0, normals);
40494080 tsa.getTextureCoordinates(0, 0, uvmap);
40504081 // 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
+// }
40564089
40574090 int stripcount = tsa.getNumStrips();
40584091 triangles = new int[stripcount];
....@@ -4061,6 +4094,7 @@
40614094 stripified = true;
40624095 } catch (ClassCastException e)
40634096 {
4097
+ // ??? aug 2019
40644098 TriangleArray ta = (TriangleArray) ga;
40654099
40664100 positions = new float[3 * ga.getVertexCount()];
....@@ -4076,8 +4110,9 @@
40764110 triangles[0] = 3;
40774111 }
40784112
4079
- Untrim();
4080
- MergeNormals();
4113
+ //Untrim();
4114
+ if (!trimmed)
4115
+ MergeNormals();
40814116 }
40824117
40834118 /*
....@@ -4131,6 +4166,8 @@
41314166
41324167 void MergeNormals()
41334168 {
4169
+ assert(!trimmed);
4170
+
41344171 boolean smooth = Grafreed.smoothmode;
41354172 boolean link = Grafreed.linkUV;
41364173 Grafreed.smoothmode = true;
....@@ -4942,9 +4979,18 @@
49424979 v./*pos.*/y = positions[i3 + 1];
49434980 v./*pos.*/z = positions[i3 + 2];
49444981
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
+ }
49484994
49494995 v.s = uvmap[i2];
49504996 v.t = uvmap[i2 + 1];