My first Rhinoscript…

Feb 5, 2008 | AHO, Code, Processing / Java, Rhino, Software


Rhinoscript sketch, extruding a revolution surface along random curves. Good cheesy fun.

I had a chance to see a bit more of the impressive tool Rhino 4 during the Generator.x 2.0 workshop, and so I thought I’d have a go at making a simple sketch in Rhinoscript. As it turns out, the fact that Rhinoscript is based on VBScript makes coding feel horrible at first. Seriously, who would want to use syntax like that? It might be easy for beginners to pick up, but it quickly gets painful once you’re dealing with complex API calls and 100+ lines of code.

Nevertheless, frustration soon gives way to amazement at the built-in Rhino library and its vast array of heavy-duty functions for creating and manipulating curves, meshes and NURBS surfaces. In comparison, mesh generation in Processing is enough to give anyone a headache, and I seriously doubt anyone would even attempt to implement NURBS. Even Boolean mesh operations is a staggering task, with no good Java libraries readily available.

While Rhinoscript is firmly a non-realtime tool, its power for pure geometry is amazing. I would definitely use Rhino as a creative tool for digital fabrication projects, where animation is not the goal. There are some excellent RhinoScript resources online, for starters look at RhinoScript 101 and David Rutten’s tutorial. I would also definitely recommend using the Monkey Script editor instead of the built-in editor, it’s more powerful and has a very useful documentation feature.

The script below gives a basic idea of the Rhino syntax, and while it is a basic sketch suffering from 3D clichées, it shows the power and versatility of Rhinoscript. I just wish it wasn’t Visual Basic.

Code: RandRail.rvb


, , , , , , ,

libCollada: 3D export from Processing

Sep 17, 2007 | Open source, Processing / Java

Marcus Wendt has published a new Processing library called libCollada, providing 3D export in the Collada 3D format. Collada is XML-based, and is intended to provide support both for basic 3D geometry and more advanced 3D authoring features like shaders and physics.

The obvious question is why another 3D format? Well, I guess the ones out there still aren’t good enough. Collada looks very complete, but most importantly is not tied to a single software vendor. It comes with a range of Open Source libraries for importing and exporting for various languages, and so could easily become a good choice for Open Source developers.

I recommed subscribing to Marcus’ Infostuka blog for technology- and design-related news. His own projects like Gestures on Sound show a great eye for computational work.

, , , , , , , , ,

Code: 3dmesh.pde

Apr 18, 2007 | Code, Processing / Java, Workshops

[Merz Akademie workshop] Here is the code I wrote to create a 3D mesh by rotating a set of 2D points:

// 3dmesh.pde
// Marius Watz -

import processing.opengl.*;

int numrot;
float px[],py[],mesh[][][];

void setup() {
  size(700,700, OPENGL);
  // To create a mesh, first create two arrays to hold the 
  // X and Y coordinates of the path you will use to create it
  px=new float[20];
  py=new float[20];
  float t=0;
  for(int i=0; i< px.length; i++) {
    px[i]=bezierPoint(0,130, 130, 0, t);
    py[i]=bezierPoint(450,350,150,50, t);

  // use createMesh to create the mesh. createMesh takes three parameters:
  // num == number of rotations
  // startDeg == start degree of rotation
  // endDeg == end degree of rotation

  mesh=createMesh(px,py,20, -60,60);

void draw() {

  for(int i=0; i< 6; i++) {    
    // to draw the mesh, use drawMesh and pass your mesh variable to it

float [][][] createMesh(float px[],float py[],int numrot, 
  float startDeg,float endDeg) {

  float deg,x,z;
  double cosval,sinval,tmp1,tmp2;

  float [][][] mesh=new float[numrot][px.length][3];
  int meshindex=0;
  for(int i=0; i< numrot; i++) {
    for(int j=0; j< px.length; j++) {
      tmp1=x*cosval - z*sinval;
      tmp2=x*sinval + z*cosval;
  return mesh;

void drawMesh(float mesh[][][]) {
  println(mesh.length+" "+mesh[0].length+" "+mesh[0][0].length);
  for(int i=0; i< mesh.length-1; i++) {
    for(int j=0; j< mesh[0].length; j++) {

, , , ,

Oldskool sketches

Sep 15, 2006 | Flickr


Oldskool: Sketches 1994-1998)

I just posted a sequence of old sketches to Flickr, ranging from 1994 to 1998 and showing some of my earliest computational work. Actually, since I never drew or worked visually in any other non-computational way after age 12, it is also some of my earliest visual work of any kind.

While some of the images are deeply mired in the techno aesthetic I was so taken with at that time (after all, I had just turned 20 and these were the 1990’s), others point to the beginning of a generative approach. Some of the basic ideas about form and structure expressed in these pieces are still with me today (see Kugelstudie or Illuminations for proof).

These are some of my favorites:

You can still see these pieces on my Evolutionzone web site as part of the historical section, but that design was done in 1996 and is painful to look at now. Seeing the images on their own in the pristine Flickr interface makes me look at them in a different way. It still feels a bit vulnerable to expose them to public viewing like this, but I figure it’s not a bad thing.

The 3D images were rendered in POV-Ray, my first ever visual tool.

, , , , , , , , ,

Supersurfaces for Processing

Sep 3, 2006 | Code, Processing / Java

Remember Sanch’s work with Supersurfaces, done in VVVV? Now Eskimoblood has made a Processing library to render the same surface. Have a look at his surface Flickr set for some examples. He has posted his code in the form of a Surface library.

The documentation is a little sparse, but more understanding of the supersurface formula can be gleaned from Paul Bourke’s excellent presentation of the shape. See also Eskimoblood’s .

(via Lightcycle)

, , , , ,

Processing news: OpenGL + SVG libs

Jul 23, 2006 | Code, Processing / Java

Just came back from the Art.ficial Emotion 3.0 exhibition in Sao Paulo, which featured some excellent interactive works. See my Art.ficial Emotion Flickr set for documentation.

I’ve pretty much been on blogging holiday lately, but here’s a few Processing links at least…

  • Christian Riekoff has released an early version of a new PGraphics renderer called proGL, aimed at optimizing OpenGL performance by calling OpenGL directly instead of performing world transformations in Processing. See his post on the Processing forums for details.

    This should improve OpenGL performance for many applications. This project started during the EXTEND workshop in Barcelona, so I am personally especially happy to see this realized.

  • Michael Chang has released a new version of his SVG importer library, called “Candy”. It’s a beta, again see the post on Processing forums.
  • Ben has posted a new Processing status report, detailing what’s going on with the project. Some API changes are in the works on the way towards 1.0 status, and they are focusing on libraries as a way of extending Processing. Ben mentions changes to the library structure, but no details. Should be interesting.

, , , , , , ,

More PDF: Graphics for NIAF

May 26, 2006 | Processing / Java


More PDF output examples: Graphics for NIAF

More gratuitous (real-world) examples of how great PDF output is. These are teaser postcards for Norwich International Animation Festival, which will take place in October this year. I am doing a generative piece which will function as identity graphics for the festival. Essentially, a single Processing software will generate a large variety of stills for print use (using PDF), as well as realtime animated trailers to be run ahead of every screening.

See Flickr for my sketches for the NIAF piece, the image over shows the 4 postcards that will go out in the next few weeks. Posters and a catalogue will follow, which I am very excited about. Again, the images show that the new PDF output library gives very high quality for print when using 3D objects.

However, there are a few quirks to PDF:

  • No depth-sorting or intersecting objects. In the NIAF project that proved to be a benefit rather than a setback, as the shapes would sometimes intersect in a visually unattractive way.
  • No pro-vertex shading, i.e. no gradient-filled polygons. In the NIAF piece you can see that I have used multiple polygons with interpolated color. This is not ideal, as it produces banding, but it can be worked into the aesthetic of the piece.
  • No possibilities for using groups or layers, a typical feature of PDF and Illustrator documents. If this could be added it would make it much easier to post-edit the results. Processing uses the free iText PDF library, and I experimented briefly with inserting layers by directly accessing the PDFWriter object, but no luck so far.

Still, PDF output is a god-send for a range of new Processing applications.

, , , ,

Code: PDF for complex 3D output

May 22, 2006 | Code, Processing / Java

Complex 3D output using PDF in Processing

Complex 3D output using PDF in Processing.

Sample code for PDF output of complex geometries from Processing, with a 3D shape using lines and polygons being written correctly to PDF. Uses beginRaw() / endRaw() and should probably be used with revision 0115 or later due to recent bug fixes.

Source code – pdf_complex.pde


, , , , ,

Flickr: C3D 0035 no bg flat

May 17, 2006 | Flickr, Processing / Java

Real test of complex polygon models with PDF output from Processing, rasterized and monotoned in Photoshop. Some very few 3D rendering artifacts are visible, but considering the complexity of the scene it’s impressive.

hint(ENABLE_DEPTH_SORT) breaks PDF output for me, so haven’t been able to see if that would help with the few incorrectly sorted triangles visible to the right.

, , , ,