« Back to Processing

Shadow casting strips

| No Comments | Published on November 2, 2008
The content that follows was originally published on the Don Havey website at http://donhavey.com/projects/shadow-casting-strips/

Here’s a preview of a drawing tool that I put together recently. I hope you love it.

It basically projects the shape that you draw on to a randomly generated terrain, then creates the objects that would cast that shadow at a certain time of day. Now that I’ve finally jumped on the Vimeo bandwagon, I’ve uploaded a video of me drawing with the applet: Shadow casting strips from Don Havey on Vimeo. There’s also a link to an in-browser demo below…

I’ll explain the thing in depth some time, but the concept is pretty simple. My new Terrain class handles the projection of points on to its surface using the Plane class’s get_line_intersect_point() method. The drawing is projected downwards, then those points are in turn projected on to vertical planes that coincide with the lines that originally split the drawn shape.

Here’s the source code so far. Note that there’s still a big bug with it, which is a problem integral to the Polygon class’s split() method. If a (vertical) split line intersects a drawn polygon more than twice, it will not split it. So you can draw vertically-aligned mountains, but not horizontally-aligned ones, or awesome fish with giant mouths, as shown in the diagram.

I think the problem is fixable, but I’m probably not going to have time to revisit this one for a while.

I’ve uploaded a (small) demo here: Shadow casting strips, in progress. Click the applet to give it focus, draw with the mouse, then rotate the thing with the arrow keys. Pressing Enter/Return will clear the drawing board.

See ya.

Categories: Processing / Projects

Tags: / / / / /

Leave a Response

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>