POV-Ray : Newsgroups : povray.advanced-users : Macro Problem : Re: Macro Problem Server Time
29 Jul 2024 22:33:35 EDT (-0400)
  Re: Macro Problem  
From: ingo
Date: 2 Oct 2000 07:22:01
Message: <8FC185E05seed7@204.213.191.228>
David Vincent-Jones wrote:

>Can somebody tell me how to get the following concept to work...
>
>macro ShapeMacro(Nums,Data)
>       prism{ linear_sweep linear_spline 0,70,Nums,Data texture
>{pigment{color Red}}}
>       #end
># object {ShapeMacro
>(4),(<2107,1480>,<2105,1481>,<2104,1480>,<2107,1480> )} 
>
>The problem occurs in trying to split the number of sides and the data
>coordinates.
>Is there a way around this ?

Using arrays may be an option:

#macro ShapeMacro(DataArray)
   #local Num=dimension_size(DataArray,1)
   prism {  
     linear_sweep 
     linear_spline 
     0,1,
     Num
     #local i=0;
     #while (i<Num)
        DataArr[i]
        #local i=i+1;
     #end
   
     pigment{color rgb 1}
   }
#end

#declare DataArr=array [5]{
   <0,0>,
   <0,1>,
   <1,1>,
   <1,0>,
   <0,0> 
}

object {ShapeMacro(DataArr)}

>I have a very long list of objects that will be generated by an outside
>source and need to use a macro format rather than building each element
>separately.

If the outside source is an appropriatly formatted textfile you can read 
it with povray, within the prism statement


Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/


Post a reply to this message

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