Exploring the Hemesh WB_Render Class
Hemesh has changed a lot since the last tutorials I wrote about Creating Shapes, Modifying a Mesh and Subdividing a Mesh. The examples in these articles don’t work with the latest version of the libary. In the previous version, you needed to render your mesh to the screen using mesh.drawFaces(), in the latest version, the new WB_Render class does all the hard work. To use the class, you need to declare a WB_Render object and create it in setup(). This is the code you need to get started.
WB_Render render;
HE_Mesh mesh;
void setup()
{
size(450, 400);
HEC_Geodesic geo = new HEC_Geodesic(60, 1);
mesh = new HE_Mesh( geo );
render = new WB_Render( this );
}
All the code to render the mesh to the screen goes inside draw(). This is a list with the descriptions of the most important methods for the WB_Render class. I’ve used them all to create the image below.
render.drawFaces( mesh )– Draw the faces of the mesh object. You’ll normally use this withfill()andnoStroke().render.drawFacesSmooth( mesh )– Draw the faces using the vertex normals. This is a great method if you need to render a really smooth organic shape. You’ll normally use this withfill()andnoStroke().render.drawFaceNormals( 20, mesh )– Draw the face normals of the mesh. The first parameter is the length of the normal. You’ll normally use this withnoFill()andstroke(). This is a useful method for debugging.render.drawEdges( mesh )– Draw the edges of the mesh. You’ll normally use this withnoFill()andstroke().render.drawVertices( 10, mesh )– Draw the vertices of the mesh, a useful method for debugging if you want to create your own meshes from scratch. The vertices are rendered as cubes, the first parameter sets the size for these cubes. You’ll normally use this withnoFill()andstroke().render.drawHalfedges( 10, mesh )– Draw the halfedges of the mesh, again a useful method for debugging. The vertices are rendered as cubes, the first parameter sets the size for these cubes.

Download
Download the example for rendering with the WB_Render class.
Related Articles
- Creating 3D Shapes with Hemesh (Blog)
- Modifying a Mesh with Hemesh (Blog)
- Subdividing a Mesh with Hemesh (Blog)
Browse Articles
Comments (3)
From:nikhil
Date:12.08.2011
Thanks a lot..i spent a lot of time trying to figure out why ‘drawFaces()’ wasn’t working in the new version :P Then finally realized that the method is a part of the old version
From:nikhil
Date:24.08.2011
How can i import a .obj file and represent it as a mesh? (as in get it to a HE_Mesh object format)
Popular Articles
- Introduction to openFrameworks
- Creating 3D Shapes with Hemesh
- Mirroring Video with openFrameworks
- An Introduction to colorLib
- How to create a FullScreen iPhone Application
Popular Tags
- processing (95)
- software (50)
- art (48)
- web design (40)
- photography (39)
From:Jan Vantomme
Date:27.08.2011
Don’t think it’s possible to open *.obj files at the moment. The only files you can open are the standard Hemesh file formats: *.hemesh, *.mesh and *.binmesh. You can however save your mesh as a *.obj file with the HET_OBJWriter class if you need it.
Top · Permanent link to this comment