11 August 2011

Author

Jan Vantomme

Tags

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 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.

Browse Articles

Next Article
Previous Article

Comments (3)

From:nikhil
Date:12.08.2011

Gravatar for nikhil

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

From:nikhil
Date:24.08.2011

Gravatar for nikhil

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

From:Jan Vantomme
Date:27.08.2011

Gravatar for Jan Vantomme

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

Commenting is closed for this article.
Commenting is not available in this channel entry.