POV-Ray : Newsgroups : povray.general : Trace()? : Re: Trace()? Server Time
7 Aug 2024 05:16:49 EDT (-0400)
  Re: Trace()?  
From: Redbeard
Date: 13 Nov 2001 23:07:06
Message: <3bf1edea$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message news:3bf0d894@news.povray.org...
> Mahalis <don### [at] fakeycom> wrote:
> : Could anyone explain to me exactly how one uses the trace() function to
> : detect object collisions?
>
>   If you mean that you want to detect if an object collided with another
> object, regardless of shape, then that's one of the most difficult things
> to do. Tracing can help a bit, but that's only perhaps 0.1% of everything you
> need for that.
>
This reminds me, I just thought of something for my 4.0 wishlist.  A function
like inside that works for objects instead of vectors, as in:

    #declare A = sphere { 0, 1 }
    #declare B = sphere { 0.5*x,1 }
    #if (intersect(A,B)) #debug "A intersects B\n" #end

That would make collision detection *much* easier.

Hmmm... is this always guaranteed to work?
    #include "stdinc.inc"
    #include "shapes.inc"

    #declare A = sphere { 0, 1 }
    #declare B = box { 2, 3 }
    #declare Min = x*0;
    #declare Max = x*0;
    Extents(intersection { object { A } object { B } }, Min, Max)
    #if (!VEq(Max,<10000000000,10000000000,10000000000>)) #debug "A intersects
B\n"
    #else #debug "A does not intersect B\n"
    #end

    #debug concat(VStr(Min), "  ", VStr(Max))

I would suppose it depends on what POV-Ray assigns as the Min/Max for a
degenerate bounding box.  And if the DBB is always possible to detect.

It appears to work with primatives and small CSGs... but I could be wrong.
Haven't tested it much.

Any thoughts?

Michael

--
#macro M(D)#local J=strlen(D);#local _=""#while(J>0)#local _=concat(_,substr(D
,J,1))#local J=J-1;#end _#end sphere{z*9,5pigment{rgb x}}#macro N(D,J)text{ttf
"timrom.ttf"M(D)1,0 translate-J}#end#macro O(E,K)#local _=N(E,K)light_source{-
z*9rgb 1projected_through{_}}#end O("leahciM"<1.6,-.3.9>)O("nosnhoJ"<1.6.9.9>)


Post a reply to this message

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