Left-Brained Modeler

A Snapshot

Of some work in progress.

Left brain?

A while back I started prototyping a "higher level" modeling language that would emit POV code when "compiled". If you think about that, it's pretty much what a modeler does—generate POV code—only this is a language not a GUI.

Here is an example from the original effort. The interesting part, shown in bold in the listing, is that a value once set can be read for use in other statements, or changed by subsequent statements. Even the list of all objects in the scene could be traversed for inspection and/or modification by subsequent statements. Everything is a scratch variable, not showing in the scene, until it's "pushed".

$main_camera= Camera (
   location =>  Vec (0, 3,-10),
   direction => Vec (0, 0,  1),
   up =>        Vec (0, 1,  0),
   right =>     Vec (4/3, 0,  0),
   look_at =>   Vec (0, 2, 0)

$closeup= $main_camera->copy;
$closeup->{direction} *= 3;  #zoom in
push @scenelist, $closeup;

I never got very far with it, beyond some primitive low-level features. More reciently, I returned to the idea of doing an "encapsulated modeled object" that could be manipulated at a high level, and eventually emit POV source code. Only instead of building a language first, I did it in straight Perl. I figure I'll build a couple models this way, and then I'll have a better idea of what I need in a special purpose language, and some real examples to port to it as it developes.

The window blinds shown above is an example of an "object". The idea behind an encapsulated object is that it can easily be included in a scene file.

use Blinds;

my $x= new Blinds (34.75, 58);
$x->{angle} = $ARGV[0] || 30;

$x->render (\*STDOUT, "MyBlinds");
Here is the source: I create a Blinds object that is 34 3/4 inches by 58 inches, to fit my window. This doesn't just "scale" the object, but builds custom blinds to suit, out of 2-inch wood slats. Then I set the "angle" property, which adjusts the angle of all the slats to open or close the blinds. Finally, the POV code for a #declare called "MyBlinds" is written to standard output.

I can mix scene elements generated by the script with ordinary POV files easily, because I can specify the name of the object to be emitted. That is then included into my master POV file. The included file uses all generated names so it won't conflict with my hand-written POV code or other generated objects.

So conceptually, it's a little bit beyond a "utility" to generate a specific kind of object, and more of a framework into which many such object generates can exist and interact. That's why I call it a "modeler".

Page content copyright 1998 by John M. Dlugosz. Home:http://www.dlugosz.com, email:mailto:john@dlugosz.com