POV-Ray : Newsgroups : povray.pov4.discussion.general : POV-Ray 4 SDL: Some concrete proposal : POV-Ray 4 SDL: Some concrete proposal Server Time
2 Dec 2024 17:37:27 EST (-0500)
  POV-Ray 4 SDL: Some concrete proposal  
From: clipka
Date: 13 Apr 2009 16:00:00
Message: <web.49e39942d93ad1dd2dae03a10@news.povray.org>
I'll try to describe what I have currently in mind. But first let me present to
you a kind of "hello world" scene written in that language:


include "colors.inc";

SphereCenter = <0,1,0>;

sphere {
  center: SphereCenter;
  radius: 1 as SphereRadius;
  texture {
    pigment { color: #<1,0,0> }
  };
} as MainSphere;

plane {
  normal: <1,1,0>;
  offset: SphereRadius;
  translate(SphereCenter);
  texture {
    pigment { color: #<0,1,0> };
  };
};

for I = 1 to 100 do
  sphere {
    radius: 0.1;
    center: y * SphereRadius;
    rotate((x * rand() as local R1 * 2 * pi), (y * rand() * 2 * pi));
    texture {
      pigment { color: #<0,0,R1> };
    };
  };
end;

modify MainSphere {
  radius: 0.9;
};

MainSphere {
  center: .center + y*0.5;
};

debug(MainSphere.center);
debug(MainSphere["center"]);


Some things about the basic formalism:

- There is always a "current object"

- Expressions by themselves constitute a statement basically saying "apply this
to the current object in the manner making most sense" (the definition of which
is up to that object).

- "sphere{...}" is an expression returning a sphere. As a matter of fact, it is
an expression taking a "prototype" object (in this case *the* prototype sphere)
and a "modification block" describing how the desired object differs from that
prototype. (Similarly, "MainSphere{...}" takes MainSphere as a prototype to
build yet another one.) Within that modification block, the newly created
object is the current one.

- "rotate(...) and translate()" are functions both returning a transformation;
as an expression-only statement, these transformations are applied to the
current object (which hopefully knows what to do with them).

- "modify MainSphere{...}" is a statement taking a "modification block" as well,
in this case describing how the object itself is to be changed.

- adding "as <Name>" to an expression stores the value of that expression for
later use, serving as an "on-the-fly assignment"

- variables are global by default when assigned; in expressions, local variables
take precedence. Local variables are visible only in the code block in which
they are used (in case of the "R1" variable, this is the enclosing for loop)

- the current object's properties are assigned to using "<Name>: <Value>" to
avoid mixups with local and global variables

- the current object's properties can also be accessed using ".<Name>"; note
that this also allows for ".<Name> = <Value>", but using so makes the code ugly
as it optically disrupts indentation ;)

- "MainSphere["center"]" and "MainSphere.center" are equivalent notation. Only
works with strings conforming to identifier rules of course.

- the language will ultimately provide means to roll your own objects (thereby
allowing to create very powerful "macros")


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.