POV-Ray : Newsgroups : povray.text.scene-files : run-time scoping example Server Time
28 Jul 2024 16:32:51 EDT (-0400)
  run-time scoping example (Message 1 to 2 of 2)  
From: Nathan Kopp
Subject: run-time scoping example
Date: 26 Feb 2000 16:11:16
Message: <38b84174@news.povray.org>
/*
Author: Nathan Kopp
Date: Feb 26, 2000
This example demonstrates run-time scoping using the POV scripting language.

If you don't understand the term 'scope', then just ignore this message.  It
is posted here for a discussion in povray.unofficial.patches.

The call to makesph() will generate a while sphere.  The call to makesph2
will generate a red sphere.  The variable 'col' is resolved differently
depending on where and when the macro is called.
*/

#version 3.1;

camera
{
  location  <0.0, 0.5, -4.0>
  look_at   <0.0, 0.0,  0.0>
}

sky_sphere
{
  pigment
  {
    gradient y
    color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }
  }
}

light_source
{
  <-30, 30, -30> color rgb 1
}

#macro makesph()
  sphere { 0.0, 1
  texture {
    pigment { rgb col }
    finish{specular 1}
  }
}
#end

#macro makesph2()
  #local col = <1,0,0>
  makesph()
#end

#declare col=<1,1,1>;

object{
  makesph2()
  translate -x
}

object{
  makesph()
  translate x
}


Post a reply to this message

From: Philippe Debar
Subject: Re: run-time scoping example
Date: 29 Feb 2000 04:16:12
Message: <38bb8e5c@news.povray.org>
The example is very interesting indeed.

> The call to makesph() will generate a while sphere.
I found the "while sphere" to be an intriguing concept (I first
tried to imagine what it was before reading any further... ). But it is a
perfectly logical concept: 2 nested while loops surely form a while sphere
:-)


Philippe


Post a reply to this message

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