Subdividing a Mesh with Hemesh

Posted on 2011-01-07 by Jan Vantomme
Tags: processing, tutorial

EDIT: Some things have changed in the latest version of Hemesh. These examples don't work with this version. I wrote an article that explains how to use the new WB_Render class to draw the meshes to the screen. Read it over here.

In this third article, I'm going to take a look at the different ways to subdivide a mesh with Hemesh. The mesh.subdivide() method takes two parameters. The first one is the kind of subdividor, the second one is the level of subdivision. Be careful when you set the level parameter. Try setting it to 200 if you want to crash Processing.

I've used a cube and rendered it five times so you can see what the subdivision does when you set it to a higher level. Each example shows levels 0 to 4.

CatmullClark

Read about Catmull-Clark subdivision at Wikipedia.

for (int i = 0; i < 5; i++) {
    HEC_Cube cube = new HEC_Cube(this).setEdge(100);
    mesh&#91;i&#93; = new HE_Mesh(cube);
    HES_CatmullClark cc = new HES_CatmullClark();
    mesh&#91;i&#93;.subdivide( cc, i );
}

Five cubes subdivided with HES_CatmullClark. Levels of subdivision from 0 to 4.

DooSabin

Read about Doo-Sabin subdivision at Wikipedia.

for (int i = 0; i < 5; i++) {
    HEC_Cube cube = new HEC_Cube(this).setEdge(100);
    mesh&#91;i&#93; = new HE_Mesh(cube);
    HES_DooSabin ds = new HES_DooSabin().setFactors(0.4, 0.6);
    mesh&#91;i&#93;.subdivide( ds, i );
}

Five cubes subdivided with HES_DooSabin. Levels of subdivision from 0 to 4.

Planar

for (int i = 0; i < 5; i++) {
    HEC_Cube cube = new HEC_Cube(this).setEdge(100);
    mesh&#91;i&#93; = new HE_Mesh(cube);
    HES_Planar planar = new HES_Planar().setRandom(true) ¬
        .setRange(0.6);
    mesh&#91;i&#93;.subdivide( planar, i );
}

Five cubes subdivided with HES_Planar. Levels of subdivision from 0 to 4.

PlanarMidEdge

for (int i = 0; i < 5; i++) {
    HEC_Cube cube = new HEC_Cube(this).setEdge(100);
    mesh&#91;i&#93; = new HE_Mesh(cube);
    HES_PlanarMidEdge planar = new HES_PlanarMidEdge();
    mesh&#91;i&#93;.subdivide( planar, i );
}

Five cubes subdivided with HES_PlanarMidEdge. Levels of subdivision from 0 to 4.

Smooth

for (int i = 0; i < 5; i++) {
    HEC_Cube cube = new HEC_Cube(this).setEdge(100);
    mesh&#91;i&#93; = new HE_Mesh(cube);
    HES_Smooth sm = new HES_Smooth();
    mesh&#91;i&#93;.subdivide( sm, i );
}

Five cubes subdivided with HES_Smooth. Levels of subdivision from 0 to 4.

Download

Download all Hemesh subdivision examples used in this article.

Tweet this article