POV-Ray : Newsgroups : povray.advanced-users : Vector Components : Re: Vector Components Server Time
28 Jul 2024 16:16:01 EDT (-0400)
  Re: Vector Components  
From: Andrew C on Mozilla
Date: 15 Sep 2004 16:09:25
Message: <4148a175@news.povray.org>
> #declare MyFn = function {
>   #switch ( y )
>     #case ( 1 )
>       // funcion code 1
>     #break // 1
>     #case ...
>   #end // switch
> }
> 
> Parse Error: Float expected but vector or color expression found.
> 
> Is there a vector function I can use to get they y component, MyFn.y, <y> or
> such?

Hmm... that's not gonna work.

The #switch executes at parse time, whereas the rest of the function 
executes at trace time. In other words, you can use a switch that 
depends on a constant defined somewhere else (e.g., animation frame 
number), but *not* on a parameter to the function.

(The exact error you're seeing is because "y" has two meanings in 
POV-Ray. Usually y = <0, 1, 0> - *except* inside functions, where "y" 
suddenly means the 2nd parameter to the function. But only at trace 
time, not parse time. Confused? POV-Ray is!)

Andrew @ home.


Post a reply to this message

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