.. | .. |
---|
3531 | 3531 | e.printStackTrace(); |
---|
3532 | 3532 | } |
---|
3533 | 3533 | |
---|
3534 | | - Trim(wastrim,true,crease,wasstrip,false); |
---|
| 3534 | + Trim(true/*wastrim*/,true,crease,wasstrip,false); |
---|
3535 | 3535 | } |
---|
3536 | 3536 | |
---|
3537 | 3537 | void GenNormalsJME() |
---|
.. | .. |
---|
5038 | 5038 | colors = null; |
---|
5039 | 5039 | } |
---|
5040 | 5040 | |
---|
| 5041 | + void CreateMesh(iHeightField hf, int x, int y) |
---|
| 5042 | + { |
---|
| 5043 | + BoundaryRep tmp = new BoundaryRep(); |
---|
| 5044 | + |
---|
| 5045 | + int vc = 0; |
---|
| 5046 | + |
---|
| 5047 | + Vertex v = new Vertex(true); |
---|
| 5048 | + |
---|
| 5049 | + for (int i=0; i<x; i++) |
---|
| 5050 | + { |
---|
| 5051 | + for (int j=0; j<y; j++) |
---|
| 5052 | + { |
---|
| 5053 | +// Vertex v = tmp.GetVertex(vc++); |
---|
| 5054 | + |
---|
| 5055 | + v.s = v.x = i; |
---|
| 5056 | + v.t = v.z = j; |
---|
| 5057 | + v.s /= x; v.t /= y; |
---|
| 5058 | + v.y = hf.f(i,j); |
---|
| 5059 | + |
---|
| 5060 | + int iu = tmp.AddTableVertex(v); |
---|
| 5061 | + |
---|
| 5062 | + v.s = v.x = i+1; |
---|
| 5063 | + v.t = v.z = j; |
---|
| 5064 | + v.s /= x; v.t /= y; |
---|
| 5065 | + v.y = hf.f(i+1,j); |
---|
| 5066 | + |
---|
| 5067 | + int iv = tmp.AddTableVertex(v); |
---|
| 5068 | + |
---|
| 5069 | + v.s = v.x = i+1; |
---|
| 5070 | + v.t = v.z = j+1; |
---|
| 5071 | + v.s /= x; v.t /= y; |
---|
| 5072 | + v.y = hf.f(i+1,j+1); |
---|
| 5073 | + |
---|
| 5074 | + int iw = tmp.AddTableVertex(v); |
---|
| 5075 | + |
---|
| 5076 | + v.s = v.x = i; |
---|
| 5077 | + v.t = v.z = j+1; |
---|
| 5078 | + v.s /= x; v.t /= y; |
---|
| 5079 | + v.y = hf.f(i,j+1); |
---|
| 5080 | + |
---|
| 5081 | + int ix = tmp.AddTableVertex(v); |
---|
| 5082 | + |
---|
| 5083 | + tmp.AddFace(iu,iw,iv); |
---|
| 5084 | + tmp.AddFace(iu,ix,iw); |
---|
| 5085 | + } |
---|
| 5086 | + } |
---|
| 5087 | + |
---|
| 5088 | + Set(tmp); |
---|
| 5089 | + |
---|
| 5090 | + Trim(true,false,true); |
---|
| 5091 | + ClearColors(); |
---|
| 5092 | + } |
---|
| 5093 | + |
---|
5041 | 5094 | void Stripify() |
---|
5042 | 5095 | { |
---|
5043 | 5096 | if (stripified) |
---|
.. | .. |
---|
5297 | 5350 | double minweight = 1E10; |
---|
5298 | 5351 | |
---|
5299 | 5352 | nbbadfaces = 0; |
---|
5300 | | - for (int i=faces.size(); (i-=8)>=0;) |
---|
| 5353 | + for (int i=0; i<faces.size(); i+=8) |
---|
| 5354 | +// for (int i=faces.size(); (i-=8)>=0;) |
---|
5301 | 5355 | { |
---|
5302 | 5356 | 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 | 5357 | |
---|
5313 | 5358 | if (!Valid(face)) |
---|
5314 | 5359 | { |
---|
.. | .. |
---|
5327 | 5372 | !ValidValence(face.r)) |
---|
5328 | 5373 | continue; |
---|
5329 | 5374 | |
---|
| 5375 | + //?? if (face.weight < 0) |
---|
| 5376 | + // continue; |
---|
| 5377 | + |
---|
| 5378 | + double K = 1; // 0.01; // .25; |
---|
| 5379 | + |
---|
| 5380 | + double factor = (1-K)*face.nbiterations + K; //*face.weight; |
---|
| 5381 | + |
---|
| 5382 | + double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor; |
---|
| 5383 | + |
---|
5330 | 5384 | if (minweight > weight) |
---|
5331 | 5385 | { |
---|
5332 | 5386 | minweight = weight; |
---|
5333 | 5387 | chosen = i; |
---|
| 5388 | + if (minweight == 0) |
---|
| 5389 | + break; |
---|
5334 | 5390 | } |
---|
5335 | 5391 | } |
---|
5336 | 5392 | |
---|
.. | .. |
---|
7373 | 7429 | if (max < maxz - minz) |
---|
7374 | 7430 | max = maxz - minz; |
---|
7375 | 7431 | |
---|
7376 | | - tmp.THRESHOLD = max/25; // 50; |
---|
| 7432 | + tmp.THRESHOLD = 0.5; // max/25; // 50; |
---|
7377 | 7433 | |
---|
7378 | 7434 | tmp.faces.clear(); |
---|
7379 | 7435 | |
---|
.. | .. |
---|
7932 | 7988 | |
---|
7933 | 7989 | minface.q = minface.r = minface.p; |
---|
7934 | 7990 | |
---|
| 7991 | + int count = 0; |
---|
| 7992 | + |
---|
7935 | 7993 | for (int i=0; i<faces.size(); i++) |
---|
7936 | 7994 | { |
---|
7937 | 7995 | Face face = (Face) faces.get(i); |
---|
.. | .. |
---|
7943 | 8001 | TouchVertex(face.r, true); // , minface.weight); |
---|
7944 | 8002 | // assert(!lock); |
---|
7945 | 8003 | faces.remove(i--); |
---|
| 8004 | + count++; |
---|
| 8005 | + if (count == 4) |
---|
| 8006 | + break; |
---|
7946 | 8007 | } |
---|
7947 | 8008 | } |
---|
7948 | 8009 | |
---|