POV-Ray : Newsgroups : povray.advanced-users : Array initializer versus macros - syntax error : Array initializer versus macros - syntax error Server Time
26 Jun 2024 09:02:17 EDT (-0400)
  Array initializer versus macros - syntax error  
From: Drakonis
Date: 1 Mar 2012 17:15:01
Message: <web.4f4ff3ab1a931bd7f281f53a0@news.povray.org>
This may not be a bug, but it is certainly confusing me (easier to do these
days)...

This is using POV-Ray 3.7 RC4 on Mac, but is likely a language issue on all
platforms.  I have poked through the docs and POV-Wiki to no avail.

I'm starting to play with pre-creating arrays of texture elements, and writing
macros to help pre-build color-maps for them.  I've done this successfully with
certain elements (for example "pigment").  But I cannot do the same construct
for the "color_map" element.  Here's a boiled down scene file that will cause a
syntax error:

// POV-Ray 3.7 file that gives a syntax error when using a macro to init an
array element
#version 3.7
// define a Macro that creates a color_map
#macro ColorMapMacro(lineColor)
color_map
{
 [ 0.0 color rgb 0 ]
 [ 0.5 color rgb lineColor  ]
 [ 1.0 color rgb 0  ]
}
#end

// create a local color_map variable from the macro, this works fine
#local localCM= ColorMapMacro(<1,1,1>);

// declare an array of color_maps
#local ColorMapArray1 = array[3];
// now MANUALLY initialize each element in 3 different ways

#local ColorMapArray1[0] =  color_map
 {
 [ 0.0 color rgb 0 ]
 [ 0.5 color rgb 1  ]
 [ 1.0 color rgb 0  ]
 };

#local ColorMapArray1[1] =  localCM;

#local ColorMapArray1[2] =  ColorMapMacro(<1,1,1>);

// Do the same thing, but this time use the inline array initializer syntax
#local ColorMapArray2 = array[3]
{

 color_map
 {
 [ 0.0 color rgb 0 ]
 [ 0.5 color rgb 1  ]
 [ 1.0 color rgb 0  ]
 },

 localCM,

// "Parse Error: Attempted to redefine colour map identifier as object
identifier."
 ColorMapMacro(<1,1,1>)
}

What part of the POV-Ray language syntax am I missing here?  Can't an array
element be initialized from a macro?  Isn't it just magically injecting a
color_map declaration there?

I am poised with my hand hovering over my forehead, for the upcoming slap. :-)

ttfn,
Eduard


--------------------
POV-Ray Mac Developer - Emeritus
www.schwansongs.com


Post a reply to this message

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