POV-Ray : Newsgroups : povray.beta-test : Function weirdness : Re: Function weirdness Server Time
31 Jul 2024 00:25:50 EDT (-0400)
  Re: Function weirdness  
From: Ron Parker
Date: 17 Sep 2001 21:59:34
Message: <slrn9qdak6.2hj.ron.parker@fwi.com>
On Mon, 17 Sep 2001 21:00:30 -0400, Slime wrote:
>I have this simple function...
>
>function {
>     #local normvec = vnormalize(x,y,z);
>     vlength(normvec)+f_noise3d(normvec.x,normvec.y,normvec.z)-1
>}
>
>I'm trying to get the normal vector of the current x,y,z coordinate being
>tested, but it appears to think i'm referring to the variables x=<1,0,0>,
>y=<0,1,0>, and z=<0,0,1>, so it gives me the error "Parse Error: Expected
>')', , found instead" on the line with the "local" statement.
>
>Is this a bug, or do I need to do this some other way? Trying
>#local normlen = sqrt(x^2+y^2+z^2)
>also caused an error.

#local doesn't do what you think it does in a function: it gets evaluated
when the scene file is parsed, not when the function is called.

--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}


Post a reply to this message

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