POV-Ray : Newsgroups : povray.advanced-users : Test against all objects? Server Time
1 Nov 2024 15:28:17 EDT (-0400)
  Test against all objects? (Message 1 to 7 of 7)  
From: RAY
Subject: Test against all objects?
Date: 28 Jan 2002 18:30:54
Message: <3c55df2e$1@news.povray.org>
Is there a way to test a macro against an entire scene? I need this for a
collision detection macro I am trying to make, my current method is to use
trace() to find the distance from the center of the sphere and test that
against the radius, is there a better way?  Thanks for your time.

--
__________________
 Yours truly,

                  RAY


Post a reply to this message

From: Zeger Knaepen
Subject: Re: Test against all objects?
Date: 28 Jan 2002 19:52:58
Message: <3c55f26a$1@news.povray.org>
> Is there a way to test a macro against an entire scene? I need this for a
> collision detection macro I am trying to make, my current method is to use
> trace() to find the distance from the center of the sphere and test that
> against the radius, is there a better way?  Thanks for your time.
correct me if I'm wrong, but I believe this is impossible.
For example: take the following scene:
//a simple room
box {-1,1}
//calculate the intersection of the calculated path with the scene
#declare Normal=<0,0,0>;
#declare Location=trace(<0,0,0>,<-1,1,1>,Normal); //first vector: startpoint, second
vector: direction, third vector: normal of intersection
//add the sphere
sphere {Location-Normal*.5,.5}
//calculate the intersection of another calculated path with the scene
#declare Normal=<0,0,0>;
#declare Location=trace(<0,0,0>,<-1,1,1>,Normal);
//add the sphere
sphere {Location-Normal*.5,.5}

//end of scene-file

However, in order to calculate the location of the first sphere, the parser needs to
know
all the objects in the scene, so it first has to parse the rest of the scene-file. 
But
then it reaches another trace-call.  Now what?  In order to compute the first trace,
it
has to know the second, but in order to calculate the second, it has to know the
first,
because both trace-calls alter the scene.

Well, it might not be impossible, it might not even be hard at all to solve this
problem,
but this is a very simple example of a problem that might come with a global
trace-function (or any other thing that tests for the entire scene)

I hope this makes some sense...

cu!
--
camera{location-z*3}#macro G(b,e)b+(e-b)*(C/50)#end#macro L(b,e,k,l)#local C=0
;#while(C<50)sphere{G(b,e),.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1
;#end#end L(y-x,y,x,x+y)L(y,-x-y,x+y,y)L(-x-y,-y,y,y+z)L(-y,y,y+z,x+y)L(0,x+y,
<.5,1,.5>,x)L(0,x-y,<.5,1,.5>,x)               // ZK http://www.povplace.be.tf


Post a reply to this message

From: Christopher James Huff
Subject: Re: Test against all objects?
Date: 28 Jan 2002 21:26:20
Message: <chrishuff-7C0497.21282928012002@netplex.aussie.org>
In article <3c55df2e$1@news.povray.org>,
 "RAY" <PCH### [at] mindspringcom> wrote:

> Is there a way to test a macro against an entire scene? I need this for a
> collision detection macro I am trying to make, my current method is to use
> trace() to find the distance from the center of the sphere and test that
> against the radius, is there a better way?  Thanks for your time.

There is no way to do that...the scene isn't yet complete when you make 
the call, and may (and most likely does) depend on the results of the 
call.
You could accomplish the desired result by tracing each individual 
object, or by putting the objects in a union and using trace() on that.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Leroy Whetstone
Subject: Re: Test against all objects?
Date: 29 Jan 2002 00:49:47
Message: <3C565371.23B349BB@joplin.com>
I just have to throw my two cent in, with every one so far saying 'no way!'
If you had every object in the scene minimum and maximum points in an array
(using 'min_extent' and 'max_extent' in POV3.5beta) Then a quick search through
the array would do the trick. This would tell ya easily if an object is in a
'zone' of another. Being that 'min_extent' and 'max_extent give a square around
an object you could then use 'trace' to make sure they hit.
 I know this is no solution if the scene contains thousands of objects but
should work for smaller secnes.

--
Have Fun!


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Test against all objects?
Date: 29 Jan 2002 12:25:02
Message: <3c56daee$1@news.povray.org>
Chris' idea is the best.
#declare a union{} of all your objects.
Then do trace calls from your actor to the declared union.


Post a reply to this message

From: RAY
Subject: Re: Test against all objects?
Date: 31 Jan 2002 18:18:19
Message: <3c59d0bb@news.povray.org>
"Christopher James Huff" <chr### [at] maccom> wrote in message
news:chr### [at] netplexaussieorg...
> In article <3c55df2e$1@news.povray.org>,
>  "RAY" <PCH### [at] mindspringcom> wrote:
>
> There is no way to do that...the scene isn't yet complete when you make
> the call, and may (and most likely does) depend on the results of the
> call
Can it test all curently defined objects, or do they need to #declare it?
> You could accomplish the desired result by tracing each individual
> object, or by putting the objects in a union and using trace() on that.
That might work


Post a reply to this message

From: Christopher James Huff
Subject: Re: Test against all objects?
Date: 1 Feb 2002 17:14:36
Message: <chrishuff-E7C7E0.17155201022002@netplex.aussie.org>
In article <3c59d0bb@news.povray.org>, "RAY" <PCH### [at] yahoocom> 
wrote:

> Can it test all curently defined objects, or do they need to #declare it?

I think that could be done, but it would be unnecessarily hard to 
control, and is not needed. Just put the objects in a union.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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