Interactive Parameter Passing in SZGPOV

Command-line Parameters

Both for testing purposes and for fully-realized RTICAs, it is useful to have a means of selecting parameter values for the POV-Ray command line. The command line can be used to control numerous "global" factors, including:

I have added to szgpov.py a means of changing certain parameters passed on the command line, based on user input in the interactive environment. (At present, the various parameter values are controlled simply by the xyz-coordinates of the user's head in the VE; however, this can easily be adapted, so that the handheld controller manipulates soft switches (either visible or invisible) within the RTICA, thus allowing head movement while the parameters remain fixed.)

Controlling POV-Ray Scene Elements Using "clock"

The command-line arguments mentioned above are useful for global settings like the ones mentioned, but how do we use interactive parameter-passing to effect changes at the POV-Ray scene description "layer"? For example, we may wish to make an object or light appear or disappear, to make a texture/material switch from one description to another, or to turn a shadow off, etc. We may wish to alter the way a loop or macro is processed. Such "within-scene" details are not directly accessible via the command line. Nor does POV-Ray provide for user-defined command-line arguments.

Not per se.

However, there is one built-in float identifier, "clock," whose value can be set by a command-line argument (use +Kn.n). This is normally used in rendering animations as a sequence of (an arbitrary number of) frames; in each frame, the value of "clock" is linearly interpolated, from 0.0 in the first frame, to 1.0 in the final frame.

Since the szgpov platform does not use POV-Ray's animation features, the "clock" variable is freed up for other uses. One method I have used successfully is to write a "mini-program" in the POV-Ray scene, which decomposes the clock value into an array of nine one-bit switches. The position of each switch is set by the first three digits after the decimal point in the clock value.

An explanation is in order. Here's an example:

Invoke POV-Ray with the command-line argument +K0.013 [* --see note at bottom]. The result is that the value 0.013 is assigned to the built-in variable "clock."

The "mini-program" sets the value of each switch in an array called switches[ ], based on a decimal value equal to 1000*clock. Here, then, the decimal value is 13 = 2^0 + 2^2 + 2^3, which decomposes into the binary switch settings

switches[0] = 1
switches[1] = 0
switches[2] = 1
switches[3] = 1
switches[4] = 0
switches[5] = 0
...
switches[9] = 0

Later in the POV-Ray scene file text, we use these switches to control specific elements of the scene. For example:

#if (switches[2]) // i.e., "if switches[2]==1"
   light_source {
     <5,5,5>
     color rgb 1
   }
#end

Our given clock value of 0.013 has set switches[2] equal to 1, thus this light source description is parsed, and the light appears in the scene. In order to change only this element of the scene--i.e., omit this light source--we would render it with +K0.009 [*]. Then POV-Ray's scene parser skips this section of the scene description, and the light does not appear in the rendered image.

* -- NOTE: Due to a quirk in the way POV-Ray's int() function rounds float values passed as arguments (at least on my MS-Windows system), it is necessary to place a nonzero digit in the fourth decimal place of the clock argument. Thus, the argument described above as +K0.013 should acutally be entered as +K0.0131; +K0.009 should be entered as +K0.0091 . Without this fix, the value of the first switch (switch[0]) is faulty.