Close Show/hide page

Archive for May, 2008

Strange 3D objects, Perlin noise

Sunday, May 18th, 2008
Thumbnail - Click me

Recently I’ve been thinking on ways of programmatically creating curvy and strange, organic-looking shapes in 3D. And reflecting on the fact that I can think of no particular ‘practical’ application for such an endeavor. And concluding that that’s part of what makes it interesting…

Here’s the high-level recipe:

Start with a cylinder or sphere-shaped mesh, where the vertices are evenly spaced . The vertices of the mesh can be thought of as a matrix or grid, where the left and right edges are curved 360 degrees until they meet.

Take an interesting bitmap with varying light and dark areas, whose height and width match the number of rows and columns in the mesh.

Use brightness (or some other color-derived property) from the pixels of the bitmap as a multiplier value to dictate the distance of the corresponding vertices from the z-axis (center) of the shape.

That’s basically it. In Flash, the built-in BitmapData.perlinNoise method is perfect for generating interesting gradients. The kicker is that the last parameter of the method allows you to change the x & y offset for each ‘octave’ (think semi-transparent layer), allowing for gradual, random-looking changes over time.

So on each update, change the offset of each octave of the perlin noise image and recalculate the vertices accordingly. The behavior and properties of Perlin noise does the rest.

Main class.as | Project.zip (Flex Builder 3)

Licensed under a Creative Commons Attribution 3.0 License.

Processing - 3D Spiral Patterns

Monday, May 5th, 2008
Thumbnail - Click me

I’ve been getting comfortable with Processing over the last few days by experimenting with what else but … particles. The three-dimensional patterns that emerge by moving the sliders to change the internal parameters can be quite complex and unexpected, and sometimes strange attractor-like.

The algorithm governing the particle motion is very straightforward. New particles are created with a starting orientation which rotates linearly on 2 axes over time. On each frame, a given amount of x, y, and z rotation is added to each particle and then the particle is translated according to its orientation by a steadily increasing distance.

Click on the buttons in the bottom right corner to change the order that the x, y, and z rotations are applied (which creates very different results from each other). The 3 sliders on top-left control the amount of rotation added per frame; the two sliders in the middle control the rate of ’spin’ for the initial orientation of new particles; and the slider on the right controls the ’speed’ that particles move away from the point of origin.

Main class file| Full source code

Licensed under a Creative Commons Attribution 3.0 License.