Exploring the Hemesh WB_Render Class

Posted by Jan Vantomme on 11 August 2011.
Tags: ,

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
(450400);
    
HEC_Geodesic geo = new HEC_Geodesic(601);
    
mesh = new HE_Meshgeo );
    
render = new WB_Renderthis );

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 with fill() and noStroke().
  • 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 with fill() and noStroke().
  • 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 with noFill() and stroke(). This is a useful method for debugging.
  • render.drawEdges( mesh ) - Draw the edges of the mesh. You’ll normally use this with noFill() and stroke().
  • 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 with noFill() and stroke().
  • 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.

The different render modes from the WB_Render class in Hemesh

Download

Download the example for rendering with the WB_Render class.

Tweet this article

Oldskool Comments (3)

Gravatar for nikhil

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

Top · Permanent link to this comment

Gravatar for nikhil

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)

Top · Permanent link to this comment

Gravatar for Jan Vantomme

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