Processing Month, Day 29 - Distorted 3D Mesh
Posted by Jan Vantomme on 29 May 2011.
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
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.
Download the distorted 3D mesh sketch.