[hemesh] 3d tile map
in
Contributed Library Questions
•
1 year ago
hi, i'm just thinking about how to create a tile map with hemeshlib. now i'm using HEC_Box for creating single bricks. but if i try to smooth (with catmull clark for example) the whole obtained mesh i see that the bricks are separated.
i'm trying to join them in a close-unique mesh, but can't work it out.
maybe removing duplicate vertex? with some kind of custom modifiers?
i'm sure that there are thousand ways to do this with this supercool library.
some help?
here is the code:
- import processing.opengl.*;
- import wblut.geom.WB_Point;
- import wblut.hemesh.core.HE_Face;
- import wblut.hemesh.core.HE_Mesh;
- import wblut.hemesh.creators.HEC_Box;
- import wblut.hemesh.creators.HEC_Grid;
- import wblut.hemesh.subdividors.HES_CatmullClark;
- import wblut.processing.WB_Render;
- HE_Mesh mesh;
- WB_Render renderer;
- void setup() {
- size(600, 600, P3D);
- renderer = new WB_Render(this);
- mesh = new HE_Mesh();
- HEC_Grid creator = new HEC_Grid(3, 3, 10*3, 10*3);
- HE_Mesh grid = creator.create();
- mesh.add(grid);
- float values[][] = // the height map
- {
- { 1, 1, 1 } ,
- { 1, 2, 1 } ,
- { 1, 1, 1 }
- };
- HEC_Box cubeFactory = new HEC_Box().setWidth(10).setHeight(10);
- Iterator<HE_Face> itr = grid.fItr();
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 3; j++) {
- float d = values[i][j] * 10;
- cubeFactory.setDepth(d);
- WB_Point p = itr.next().getFaceCenter();
- p.z += d/2;
- cubeFactory.setCenter(p);
- mesh.add(cubeFactory.create());
- }
- }
- HES_CatmullClark catmull = new HES_CatmullClark() // test if the bricks are joined in a unique mesh
- .setKeepEdges(true)
- .setKeepBoundary(true);
- mesh.subdivide(catmull,1);
- }
- void draw() {
- background(120);
- lights();
- translate(300, 300, 300);
- rotateY(mouseX*1.0f/width*TWO_PI);
- rotateX(mouseY*1.0f/height*TWO_PI);
- fill(255);
- noStroke();
- renderer.drawFaces(mesh);
- stroke(0);
- renderer.drawEdges(mesh);
- }
1