ofBox set number of faces ?


I’m new to openFrameworks and I would like to know if there is a way to add faces / edges / vertex on a ofBox object ? My goal is to achieve something like that (see below !) but I have no idea of what is the best way to do it…

Thanks for taking the time to reading me and forgive my english !


Hi Thomas and welcome to the forums!

ofBox is specifically created to draw a cube. If you look at the internals of the method you’ll see that it’s specifying vertices (with positions, normals and texture coordinates for every vertex) and committing those to the renderer. This set of vertices creates a cube, but more generally speaking a-collection-of-vertices,-edges-and-faces-is-called-a-mesh. openFrameworks has a nice class to handle meshes, it’s called ofMesh. Check-out-the-documentation and see if you can work it out from there.

I like the gif, nice sketchy style.

Thanks for your answer ! I looked arround the doc and already seen ofMesh but I didn’t manage to do anything with this because I haven’t found examples on Google… I come from Processing and I’m a beginner in C++ and it’s not very easy ! By the way, if you want to take a look at Mr Div’s Tumblr (http://mrdiv.tumblr.com/) he is the guy who makes this awesome gifs :wink:

Nice page! For an example of how to use ofMesh, check out the ‘examples’ folder in the 0071 release. Specifically, take a look at examples/3d/meshFromCamera to see how a mesh can be created and updated.