Processing Month, Day 29 - Distorted 3D Mesh

Posted on 2011-05-29 by Jan Vantomme
Tags: processing, tutorial

Today we'll take a look at how we can construct the grid we made yesterday in 3D. The first thing you need to do is add a third parameter to the size() function. If you import the OpenGL library, you can use OPENGL as the third parameter, but for now we'll use the P3D renderer. When we fill the PVector array, we need a third parameter for the PVector constructor. This will be the z-coordinate of that point in space. I've used a random number between -20 and 20. In the draw function, you need to add this z-coordinate to the vertex() function.

Examples

The grid in 3D looks like this. I used the lights() to add shadows to the mesh so it looks better when Processing renders it.

A distorted 3D mesh made with Processing.

A distorted 3D mesh made with Processing.

A distorted 3D mesh made with Processing.

A distorted 3D mesh made with Processing.

Download

Download the distorted 3D mesh sketch.

Tweet this article