POV-Ray : Newsgroups : povray.general : Status of Moray? : Re: New SDL for POVRay Server Time
13 Jul 2025 22:07:03 EDT (-0400)
  Re: New SDL for POVRay  
From: Nicolas Alvarez
Date: 5 Oct 2007 14:51:24
Message: <470687ac@news.povray.org>

> Possible 4.0 way:
> 
> #local A = sphere {
>   translate y*1
>   rotate z*10
>   rotate x*20
>   scale <23,44,33>
> }
> 
> // an instance of a
> A.transform[0] = <0,1,0>
> object { A }
> 
> // another instance of a
> A.transform[0] = <0,2,0>
> object { A }
> 

The real OOP way would be:

Sphere A = sphere {
   translate y*1
   rotate z*10
   rotate x*20
   scale <23,44,33>
}

// an instance of a
A.transform[0] = <0,1,0>;
scene.addObject(A);

// another instance of a
A.transform[0] = <0,2,0>
scene.addObject(A);

addObject could also apply to CSG objects :) I think it's nicer to do this:

Union all = union{};
/* shinyThings is an array */
foreach(obj in shinyThings) {
     all.addObject(obj);
}

Than using POV-Ray's current "power" to put loops anywhere:
union {
     #foreach(obj in shinyThings)
         object { obj }
     #end
}

This is just like allowing macros anywhere: it blocks from doing many 
performance improvements. Evil stuff like this is currently possible:
#declare I=0;
#while (I<10)
union {
#declare I=I+1;
#end

whatever

#declare I=0;
#while (I<10)
}
#declare I=I+1;
#end

Just as bad as #macro abuse.


Post a reply to this message

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