Subdividing a Mesh with Hemesh

Posted by Jan Vantomme on 07 January 2011.
Tags: ,

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 05i++) {
    HEC_Cube cube 
= new HEC_Cube(this).setEdge(100);
    
mesh[i] = new HE_Mesh(cube);
    
HES_CatmullClark cc = new HES_CatmullClark();
    
mesh[i].subdividecc);

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

DooSabin

Read about Doo-Sabin subdivision at Wikipedia.

for (int i 05i++) {
    HEC_Cube cube 
= new HEC_Cube(this).setEdge(100);
    
mesh[i] = new HE_Mesh(cube);
    
HES_DooSabin ds = new HES_DooSabin().setFactors(0.40.6);
    
mesh[i].subdivideds);

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

Planar
for (int i 05i++) {
    HEC_Cube cube 
= new HEC_Cube(this).setEdge(100);
    
mesh[i] = new HE_Mesh(cube);
    
HES_Planar planar = new HES_Planar().setRandom(true¬
        
.setRange(0.6);
    
mesh[i].subdivideplanar);

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

PlanarMidEdge
for (int i 05i++) {
    HEC_Cube cube 
= new HEC_Cube(this).setEdge(100);
    
mesh[i] = new HE_Mesh(cube);
    
HES_PlanarMidEdge planar = new HES_PlanarMidEdge();
    
mesh[i].subdivideplanar);

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

Smooth
for (int i 05i++) {
    HEC_Cube cube 
= new HEC_Cube(this).setEdge(100);
    
mesh[i] = new HE_Mesh(cube);
    
HES_Smooth sm = new HES_Smooth();
    
mesh[i].subdividesm);

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