Learn creative coding writing simple programs

152. Exporting 3D shapes as .obj files in Processing

This time we are taking the shape we created in episode 151 and exporting it as an .obj file. To achieve that we use the ObjExport Processing library. We also take a look at how to make code run only once even if it's inside the draw loop. That becomes useful to avoid exporting the .obj file over and over again. We only need the file once :)

Processing by default offers a limited set of 3D primitives: only spheres and cubes. Other shapes you have to load or build yourself out of triangles calling vertex(), which probably means knowing a lot of math. To make it easier to generate and manipulate complex 3D shapes there are several libraries, for instance Toxiclibs (http://toxiclibs.org/) and HE_Mesh (http://hemesh.wblut.com/). In this tutorial I also show where you can find examples for exporting .obj files using both HE_Mesh and Toxiclibs.

In the next episode we will import the .obj file into Blender and render an image with realistic lights and shadows!

Tags: obj, export, toxiclibs, hemesh

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus