POV-Ray : Newsgroups : povray.advanced-users : #if(trace(....... Server Time
26 Dec 2024 23:12:59 EST (-0500)
  #if(trace(....... (Message 1 to 4 of 4)  
From: Veggiet
Subject: #if(trace(.......
Date: 22 Nov 2005 12:15:00
Message: <web.4383511392feae79e4087eb70@news.povray.org>
Hi,
   I'm not sure if this goes in the advanced category or not, but I'm having
a problem. I trying to make a snow casting macro, and for this I using
nested loops, but I don't want to have a blob created if a collision isn't
made so here is the conext:

[code]
#declare trval = trace(Objapply, coords1, coords2, <0,0,0>);
#if(trval != <0,0,0>)
....
#end
[/code]

It highlights the #if line and comes up with
"Parse Error: Float expected but vector or color expression found."

and If I change the expression to "(trval != 0)" It does the same thing.


Post a reply to this message

From: Roman Reiner
Subject: Re: #if(trace(.......
Date: 22 Nov 2005 12:30:00
Message: <web.4383551c50cf0a77b293c4340@news.povray.org>
"Veggiet" <nomail@nomail> wrote:
> Hi,
>    I'm not sure if this goes in the advanced category or not, but I'm having
> a problem. I trying to make a snow casting macro, and for this I using
> nested loops, but I don't want to have a blob created if a collision isn't
> made so here is the conext:
>
> [code]
> #declare trval = trace(Objapply, coords1, coords2, <0,0,0>);
> #if(trval != <0,0,0>)
> ....
> #end
> [/code]
>
> It highlights the #if line and comes up with
> "Parse Error: Float expected but vector or color expression found."
>
> and If I change the expression to "(trval != 0)" It does the same thing.

this should work:

[code]
#declare Norm = <0,0,0>;
#declare trval = trace(Objapply, coords1, coords2, Norm);
#if(vlength(Norm)!=0)
.....
#end
[/code]

two faults. first: when an object was hit then the intersection point will
be stored in trval and the normalvector at the intersectionpoint will be
stored in the (optional) fourth indentifier. so when you want to know if an
object was hit or not you have to test that vector (Norm in the example)
and not trval. second fault: you can't compare vectors like you did. either
you compare there length (which works when you test for zero, as in the
example) or you use VEq(V1, V2) in math.inc

Roman


Post a reply to this message

From: Mike Williams
Subject: Re: #if(trace(.......
Date: 22 Nov 2005 12:34:35
Message: <bCHFvAAja1gDFwlv@econym.demon.co.uk>
Wasn't it Veggiet who wrote:
>Hi,
>   I'm not sure if this goes in the advanced category or not, but I'm having
>a problem. I trying to make a snow casting macro, and for this I using
>nested loops, but I don't want to have a blob created if a collision isn't
>made so here is the conext:
>
>[code]
>#declare trval = trace(Objapply, coords1, coords2, <0,0,0>);
>#if(trval != <0,0,0>)
>....
>#end
>[/code]
>
>It highlights the #if line and comes up with
>"Parse Error: Float expected but vector or color expression found."
>
>and If I change the expression to "(trval != 0)" It does the same thing.

Even if you get the syntax right, there's always the possibility of a
valid hit at the point <0,0,0>

The usual way to check for trace() hits is like this:

#declare Norm=<0,0,0>;
#declare trval = trace(Objapply, coords1, coords2, Norm);
#if (vlength(Norm) > 0)
  ...
#end

The normal will only have length zero if the trace misses.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Veggiet
Subject: Re: #if(trace(.......
Date: 23 Nov 2005 10:50:00
Message: <web.43848e9b50cf0a77b0d78f980@news.povray.org>
Wow, Thank you all for your very quick responses! Yep, Checking the Norm
works. Thank you again very much.

VeggieT


Post a reply to this message

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