From 89da025f40680d9cea46f2b0a7c8c6829a0d0451 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 12 Apr 2015 19:37:37 -0400 Subject: [PATCH] Height fields. --- BoundaryRep.java | 85 ++++++++++++++++++++++++++++++++++++------ 1 files changed, 73 insertions(+), 12 deletions(-) diff --git a/BoundaryRep.java b/BoundaryRep.java index 931cfab..693d818 100644 --- a/BoundaryRep.java +++ b/BoundaryRep.java @@ -3531,7 +3531,7 @@ e.printStackTrace(); } - Trim(wastrim,true,crease,wasstrip,false); + Trim(true/*wastrim*/,true,crease,wasstrip,false); } void GenNormalsJME() @@ -5038,6 +5038,59 @@ colors = null; } + void CreateMesh(iHeightField hf, int x, int y) + { + BoundaryRep tmp = new BoundaryRep(); + + int vc = 0; + + Vertex v = new Vertex(true); + + for (int i=0; i<x; i++) + { + for (int j=0; j<y; j++) + { +// Vertex v = tmp.GetVertex(vc++); + + v.s = v.x = i; + v.t = v.z = j; + v.s /= x; v.t /= y; + v.y = hf.f(i,j); + + int iu = tmp.AddTableVertex(v); + + v.s = v.x = i+1; + v.t = v.z = j; + v.s /= x; v.t /= y; + v.y = hf.f(i+1,j); + + int iv = tmp.AddTableVertex(v); + + v.s = v.x = i+1; + v.t = v.z = j+1; + v.s /= x; v.t /= y; + v.y = hf.f(i+1,j+1); + + int iw = tmp.AddTableVertex(v); + + v.s = v.x = i; + v.t = v.z = j+1; + v.s /= x; v.t /= y; + v.y = hf.f(i,j+1); + + int ix = tmp.AddTableVertex(v); + + tmp.AddFace(iu,iw,iv); + tmp.AddFace(iu,ix,iw); + } + } + + Set(tmp); + + Trim(true,false,true); + ClearColors(); + } + void Stripify() { if (stripified) @@ -5297,18 +5350,10 @@ double minweight = 1E10; nbbadfaces = 0; - for (int i=faces.size(); (i-=8)>=0;) + for (int i=0; i<faces.size(); i+=8) +// for (int i=faces.size(); (i-=8)>=0;) { Face face = (Face) faces.get(i); - - //?? if (face.weight < 0) - // continue; - - double K = 1; // 0.01; // .25; - - double factor = (1-K)*face.nbiterations + K; //*face.weight; - - double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor; if (!Valid(face)) { @@ -5327,10 +5372,21 @@ !ValidValence(face.r)) continue; + //?? if (face.weight < 0) + // continue; + + double K = 1; // 0.01; // .25; + + double factor = (1-K)*face.nbiterations + K; //*face.weight; + + double weight = FaceWeight(face); // *Math.pow(PerimeterMax(face),0.25)*factor; + if (minweight > weight) { minweight = weight; chosen = i; + if (minweight == 0) + break; } } @@ -7373,7 +7429,7 @@ if (max < maxz - minz) max = maxz - minz; - tmp.THRESHOLD = max/25; // 50; + tmp.THRESHOLD = 0.5; // max/25; // 50; tmp.faces.clear(); @@ -7932,6 +7988,8 @@ minface.q = minface.r = minface.p; + int count = 0; + for (int i=0; i<faces.size(); i++) { Face face = (Face) faces.get(i); @@ -7943,6 +8001,9 @@ TouchVertex(face.r, true); // , minface.weight); // assert(!lock); faces.remove(i--); + count++; + if (count == 4) + break; } } -- Gitblit v1.6.2