Processing Tutorials

There are many ways of importing data into processing. The important thing to figure out first is what kind of data we want and how we want to represent it in our program (as an array, through some more complex data structure or representation…). For example, it is possible to import height data as an image (a height-map) which is a standard form of representing topographic data in computer graphics. Here are for example a few examples of using this type of data in Processing to render a height-map as points (example by Anastasis Chasandras) or for creating contour maps (from the tutorial by Onformative). There are a number of sites where this type of data is available, often downloadable under different licenses and conditions, for example from theNASA Shuttle Radar Topography Mission (SRTM) .

For geometry, there are also few libraries available for importing 3D OBJ files, such as the OBJLoader
by Tatsuya Saito and Matt Ditton and the equivalent for output in OBJ format, OBJExport by Jesse Louis-Rosenberg. These are Contributed libraries, and can be installed and used as we explained in the previous tutorial. Another alternative to using these libraries, is to import files “by hand”: From programs such as Rhino, one can export all data as row triangles (.row). This produces a text file with all the vertices of the trinagles. One can take a file like this and edit it in a text editor (through for example find-replace) until it has the form of java/processing code, as an example, this is a .row file produced by Rhino:

And this is the way it can look after editing it in a text editor, so it looks like an array of floats in Processing. It is important to notice the syntax used for declaring and initialising an array at the same time. This is different from the cases we have previously seen, which used “new”, and is an easy way of filling an array with values when we know those values beforehand, as in this case. There is more information about initialising arrays in the array reference at the processing website.

This particular data is made of vertices which form triangular faces. For displaying it we need to paste it inside our code. Here is an example using PeasyCam, and a function called “drawData()” to do this: