POV-Ray : Newsgroups : povray.newusers : can an array contain macros? Server Time
23 Nov 2024 11:44:52 EST (-0500)
  can an array contain macros? (Message 1 to 3 of 3)  
From: John Greenwood
Subject: can an array contain macros?
Date: 19 Jul 2014 04:55:00
Message: <web.53ca312ea00ddbada7cafab50@news.povray.org>
I tried this:

#version 3.7 ;
background {color rgb 1/2}

global_settings {
    assumed_gamma 1
 max_trace_level 100 }

   camera {
    location <5, 1, -22>
    look_at <-.5,0, 0>
    angle 30
  }
 light_source{<00,200,-200> rgb <1,.9,.5> }

#macro Sphere1()    sphere {<1,1,0>,1   pigment{rgb<1,0,0>}} #end
#macro Sphere2()    sphere {<1,-1,0>,1  pigment{rgb<0,1,0>}} #end
#macro Sphere3()    sphere {<-1,-1,0>,1 pigment{rgb<0,0,1>}} #end
#macro Sphere4()    sphere {<-1,1,0>,1  pigment{rgb<1,0,1>}} #end

#declare Event_Name = array[2][2]   {
{ Sphere1(),Sphere2()},
{ Sphere3(),Sphere4()}}

but get the error:

line 21: Parse Error: Insufficent number of initializers

John


Post a reply to this message

From: Le Forgeron
Subject: Re: can an array contain macros?
Date: 19 Jul 2014 05:10:16
Message: <53ca35f8@news.povray.org>
Le 19/07/2014 10:49, John Greenwood nous fit lire :
> I tried this:

> #macro Sphere1()    sphere {<1,1,0>,1   pigment{rgb<1,0,0>}} #end
> #macro Sphere2()    sphere {<1,-1,0>,1  pigment{rgb<0,1,0>}} #end
> #macro Sphere3()    sphere {<-1,-1,0>,1 pigment{rgb<0,0,1>}} #end
> #macro Sphere4()    sphere {<-1,1,0>,1  pigment{rgb<1,0,1>}} #end
> 
> #declare Event_Name = array[2][2]   {
> { Sphere1(),Sphere2()},
> { Sphere3(),Sphere4()}}
> 
> but get the error:
> 
> line 21: Parse Error: Insufficent number of initializers

Maybe because the "return" of the Sphere*() macro are nothing.
The sphere get added to the scene, but I'm afraid not in the array. (as
sphere is not an expression)

As you want to store object in the array, maybe (untested) something like
#macro Sphere1()
#local Obj=sphere{<1,1,0>,1   pigment{rgb<1,0,0>}};
Obj
#end

Caveat: #local vs #declare, there might be a scope issue in previous
version of povray. (referencing a released identifier)
-- 
IQ of crossposters with FU: 100 / (number of groups)
IQ of crossposters without FU: 100 / (1 + number of groups)
IQ of multiposters: 100 / ( (number of groups) * (number of groups))


Post a reply to this message

From: John Greenwood
Subject: Re: can an array contain macros?
Date: 19 Jul 2014 05:55:01
Message: <web.53ca3f5e5301cedba7cafab50@news.povray.org>
Le_Forgeron <jgr### [at] freefr> wrote:
> Le 19/07/2014 10:49, John Greenwood nous fit lire :
> > I tried this:

......
> Maybe because the "return" of the Sphere*() macro are nothing.
> The sphere get added to the scene, but I'm afraid not in the array. (as
> sphere is not an expression)
>
> As you want to store object in the array, maybe (untested) something like
> #macro Sphere1()
> #local Obj=sphere{<1,1,0>,1   pigment{rgb<1,0,0>}};
> Obj
> #end
>
> Caveat: #local vs #declare, there might be a scope issue in previous
> version of povray. (referencing a released identifier)
> --
> IQ of crossposters with FU: 100 / (number of groups)
> IQ of crossposters without FU: 100 / (1 + number of groups)
> IQ of multiposters: 100 / ( (number of groups) * (number of groups))

Thanks for the quick reply.

I am thinking this is not the way to go!

A #switch, #case structure is probably better.

John


Post a reply to this message

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