Gouraud shading engine

My goal is to create a fast Gouraud shading engine for Flash. It should be possible (see: http://en.wikipedia.org/wiki/Gouraud_shading).

I searched the tutorials and the forums. I found this tutorial: http://www.kirupa.com/developer/mx2004/shinyorbs.htm

Here’s how it works: on steps “ix” and “x.”, it shows how the highlight is positioned to give the illusion of a light source reflecting.

Using ActionScript: based on the coordinates of the object relative to the viewport, we can move the light reflection around to replicate Gouraud shading.

For cube shaped objects: I was thinking of creating a class for these objects that will have the current orientation of the cube as properties of the object. So, all of the calculations will be in the class (encapsulated), but when using the class, we could reference the property and simply calculate the “Z” depth based on the cube’s scale. The X/Y coordinates will be fed in and the property value returned will tell us where to position the reflections.

This means the class takes care of half the computational requirements, in theory.

Anyone find something like this that’s already been created? I’ll post a sample sometime soon.