|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I am trying to make a function which uses a vector cordnate return a value.
Within this the I am trying to pull the y component of the input to do a
compareson on it. I have tried with both #if and #switch and have the same
problem.
#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?
-=<{()}>=-
Thorcane
-=<{()}>=-
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> #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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Hmm... that's not gonna work.
Not exactly what I wanted to hear. I guess I will have to work out a new
function to do what I wanted.
Thank you. If anyone has any suggestions to make the original work please
feel free to post.
-=<{()}>=-
Thorcane
-=<{()}>=-
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
You should read the thread "How to get a texture like (y>0.8 & z>0.9) ->
texture a else -> texture= b?" by D. H. Berlin in povray.newusers on
9/3/2004 11:23 AM. He had a nearly identical problem. The solution is
probably the select() function.
- Slime
[ http://www.slimeland.com/ ]
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
nomail@nomail wrote:
>>Hmm... that's not gonna work.
>
>
> Not exactly what I wanted to hear. I guess I will have to work out a new
> function to do what I wanted.
>
> Thank you. If anyone has any suggestions to make the original work please
> feel free to post.
I suggest that you read about about user defined functions and
the select() function.
2.2.1.6.3 Declaring User-Defined Float Functions:
http://www.povray.org/documentation/view/3.6.1/231/
2.2.1.3.4 Functions:
http://www.povray.org/documentation/view/3.6.1/228/
Here's a simple example:
#declare MyFn =
function(x, y, z) { // Or just: function {
select(y - 1, 0, SomeExpression, 0) + // Case: y = 1
select(y - 2, 0, OtherExpression, 0) + // Case: y = 2
select(y - 2, 0, 0, YetAnotherExpression) // Case: y > 2
}
You may also have a look at my reply in this thread in p.b.s-f:
From: Yadgar
Subject: Discontinuous functions?
Date: 14 Aug 2004 11:19:55
http://tinyurl.com/6vaar
http://news.povray.org/povray.binaries.scene-files/message/%3C411fd33c%40news.povray.org%3E/#%3C411fd33c%40news.povray.org%3E
--
Tor Olav
http://subcube.net
http://subcube.com
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>>> Hmm... that's not gonna work.
>>
>>
>>
>> Not exactly what I wanted to hear. I guess I will have to work out a new
>> function to do what I wanted.
>
> I suggest that you read about about user defined functions and
> the select() function.
Ah... I forgot about this. Yes, that would seem to be the answer. (I was
trying to construct something using the abs() and sign() functions to
achieve the same result...)
Andrew @ home.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |