|
 |
Chris Cason wrote:
> I have had a look at a few embeddable languages, such as AngelCode (see
> http://www.angelcode.com/angelscript/) but haven't come to any solid
> conclusion yet.
I'm going to make a radical proposal for you to think over.
As POVRay's SDL has evolved over the years, it's become more and more
like a programming language. I think it's worth considering pushing it
into a real programming language.
These days, I do most of my work in Smalltalk. It's one of the simplest
yet most powerful programming languages around. Building a Smalltalk
compiler/interpreter is not terribly hard (I've done it before) and if
you wish, there are commercial systems (and freeware systems) which you
can already use. The commercial system have "free for non-commercial"
licenses.
A few years ago, I built a simple little raytracer in Smalltalk to see
what it would be like. Here's what the scene description code looks
like in this system (The code below is extracted directly from that
reaytracer and it renders an actual image.):
"This method renders a scene and displays it in a window"
view
self show: self renderImage
"This method renders the image"
renderImage
^(self camera)
imageSize: 640 , 480;
render: self scene
"Here is the definition of the camera"
camera
^(Camera new)
location: 0 , 2 , -10;
direction: 0 , 0 , 1;
up: 0 , 1 , 0;
right: 1.333 , 0 , 0
"And here is the scene"
scene
^(Scene new)
lightSource: self lightSource;
shape: self floor;
shape: self sphere1;
shape: self sphere2
"The definition of the light source"
lightSource
^(LightSource new)
location: 10 , 20 , -20;
color: Vector white
"Here's the floor"
floor
^(Plane new)
normal: 0 , 1 , 0;
offset: 1;
texture: self floorTexture
"We need the floorTexture"
floorTexture
^(TextureWithFinish new)
pigment: self checkerBoardPigment;
finish: self reflectingFloorFinish
"And the checkerBoardPigment"
checkerBoardPigment
^(CheckerBoardPigment new)
center: 0 , 0.1 , 0;
color1: Vector green;
color2: Vector white;
squareSize: 1
"The reflectingFloorFinish makes it reflect"
reflectingFloorFinish
^(CompoundFinish new)
finish: self floorFinish;
finish: self fullReflectionFinish
I'll leave it at that for now.
By doing this, you can make libraries of textures, shapes, finishes,
light sources, etc. which can be reused. The definition of an entire
scene could exist in one class and could re-use common textures, shapes,
etc. You have the full power of Smalltalk to build the shapes including
loops, conditions, random numbers, importing data from files, writing
out files, etc. You also have the full power of the development
environment when running including inspecting your scenes and debugging
the rendering.
I know this is coming from left field, but it's good to think about some
radical ideas every once in a while to really inspire innovation.
Discussion is welcome.
David Buck
Post a reply to this message
|
 |