POV-Ray : Newsgroups : povray.pov4.discussion.general : Next Generation SDL: What's wrong with Lua, JavaScript, ... : Re: Next Generation SDL: What's wrong with Lua, JavaScript, ... Server Time
28 Apr 2024 21:36:42 EDT (-0400)
  Re: Next Generation SDL: What's wrong with Lua, JavaScript, ...  
From: clipka
Date: 11 Apr 2009 20:15:01
Message: <web.49e1326ae7a64ad8dc1687770@news.povray.org>
> I didn't quite understand your post. But, how about hash arrays?
>
> scene =
> {
>  objects =
>  {
>   My_Sphere =
>   {
>    type = "sphere",
>    location = <x,y,z>,
>    radius = r,
>    texture =
>    {
>     pigment =
>     {
>      color = <r,g,b>
>     }
>    },
>    transformation =
>    {
>     translate = <x,y,z>
>    }
>   }
>  }
> };


Hmm... at first glance I thought it could do the desired thing - but it can't.
How, for instance, would the following translate?

sphere { <x,y,z>, r
    translate <a,b,c>
    pigment { ... }
    translate <d,e,f>
}

Filing both translate statements as "translate" in the hash map would overwrite
the first of them. Just combining the two would fail to properly affect the
pigment.


At the moment I'm pondering a syntax (of course not Lua nor JavaScript) that
would use the following:

    expression { statement1; statement1; ... }

as a shortand form for

    {
        temp = expression;
        ifdef(temp.statement1) temp.statement1; else statement1;
        ifdef(temp.statement2) temp.statement2; else statement2;
        ...
        return temp;
    }

(just a sketch here, but it might show where I want to go)

This would allow for the following:

    sphere(<x,y,z>,r) {
        translate (<a,b,c>);
        pigment { ... };
        translate (<a,b,c>);
    }

with sphere(center,radius) doing something like:
    sphere = function(center,radius) {

        temp = new object;
        temp.pov_object = pov_create_sphere(center, radius);
        temp.pigment = function() {
            temp = new object;
            temp.pov_object = pov_create_pigment();
            pov_attach_pigment_to_object(this.pov_object, temp);
            return temp;
        }
        temp.translate = function(v) {
            pov_translate_object(this.pov_object, v);
            pov_translate_object(this.pov_object.pigment, v)
        }
        return temp;
    }

In other words, there would be a "sphere" function creating a new POV-SDL
object, attach to it (a) a brand new POV-engine sphere, and (b) some methods
"translate" and "pigment" properties, thereby defining the semantics of these
when used in the context of the sphere.


> Alternately, we could differentiate
> the content and behavior by using separate sections and languages for
> each (i.e. HTML and JavaScript in web pages).

Yuck. We see that in the current SDL. It can be quite powerful, but it's not
really the way to go.


Post a reply to this message

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