POV-Ray : Newsgroups : povray.general : Objects in camera Server Time
5 Aug 2024 16:09:22 EDT (-0400)
  Objects in camera (Message 1 to 8 of 8)  
From: Tom A 
Subject: Objects in camera
Date: 3 Sep 2002 20:00:44
Message: <3D754D2C.4902973A@my-deja.com>
I did a few quick searches, and didn't see anything - so if someone
already answered this, just point me to the answer.

I'm placing a large bunch of objects into my animation scene.  Obviously
only some of them are going to be on screen at from a particular view. 
Does anyone know of a way to determine if a particular point is in the
camera's viewpoint?

(I'm not worried about objects behind objects - but I'm trying to place
trees on a hillside, and if I didn't have to parse the ones that aren't
on camera at the moment, it would probably speed things up.  A small
render I did the other day ran for two hours - at that rate, I'll never
get an animation done. :-(

Thanks for any help.  I'm not too bad at regular math - it's the 3d
stuff that gets me.

-- 
Tom A.
When scientist say they're making a "quantum leap" it 
means they are going out to catch some rays.  - Dr. Science
Deja mail is gone.  Look for me at raugost at yahoo . com


Post a reply to this message

From: Warp
Subject: Re: Objects in camera
Date: 3 Sep 2002 21:18:42
Message: <3d755f71@news.povray.org>
Tom A. <tar### [at] my-dejacom> wrote:
> Does anyone know of a way to determine if a particular point is in the
> camera's viewpoint?

  The task is simple: Project the point onto the viewing plane and see
if it's inside the limits of the image. (Scanline rendering uses this
in order to draw polygons on screen: They are first projected onto the
viewing plane and then drawn as 2D polygons.)

  Implementing this task is a bit more difficult.

  If your camera is located at the origin and looking at the positive z axis,
the formulas for projecting a 3D point onto the viewing plane are simple:

  x' = x*d/z
  y' = y*d/z

where x, y and z are the coordinates of the point and d is the length of
the direction vector of the camera.
  x' and y' will be the coordinates of the projected points in such way
that x'=0, y'=0 means the middle of the screen, y'=1 means the upper
edge of the screen and x'=4/3 means the right edge of the screen, given
that your camera ratio is 4/3 (I think! I am not sure about this since I
don't remember how POV-Ray uses the up and right vectors to do these
calculations; if you do try these formulas, you should try projecting
things on screen and see where do they end).

  The real problem is that the camera is most probably not at the origin
and looking at the positive z axis, which makes things more complicated.
I think that the easier way to solve this problem is to take the
transformations applied to the camera and apply the inverse transformation
to the point before projecting it. Of course this means that you must know
the transformations made to the camera and how to get their inverse (which
can be a bit complicated if you just use 'location' and 'look_at').

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Warp
Subject: Re: Objects in camera
Date: 3 Sep 2002 21:25:15
Message: <3d7560fb@news.povray.org>
By the way: Coordinates with z <= 0 should be discarded immediately
(because they can't be visible to the camera anyways, but the actual
reason is that you would not get a correct answer for coordinates with
negative z values (as they would be just mirrored about z)).

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Slime
Subject: Re: Objects in camera
Date: 3 Sep 2002 23:31:47
Message: <3d757ea3$1@news.povray.org>
The wimpy (non-mathematical, less learning involved) way to do what Warp
described is to create a thin box in front of the camera that covers the
viewing plane, and then use trace() from the point you're testing to the
camera's location and see if it hits the box.

Neither of these methods work so easily for a non-perspective camera,
however.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Norbert Kern
Subject: Re: Objects in camera
Date: 4 Sep 2002 04:00:10
Message: <web.3d75bcbacf9ebab2ed02f1080@news.povray.org>
Your problem is well known.
In addition it is useful to know the visible positions on a heightfield in
front of the camera.
My personal solution is to create a scene with a orthographic camera above
the heightfield and to put a light instead of the scene camera. I managed
to define an object, which defines the visible area and blocks unwanted
light.

With some finish changes I get a map, which shows all visible parts in white
and others in black.

Then I define an if_then loop at the trace step.

If you want, I can provide you with some example code.


Norbert


Post a reply to this message

From: Warp
Subject: Re: Objects in camera
Date: 4 Sep 2002 10:33:06
Message: <3d7619a1@news.povray.org>
Slime <slm### [at] slimelandcom> wrote:
> The wimpy (non-mathematical, less learning involved) way to do what Warp
> described is to create a thin box in front of the camera that covers the
> viewing plane

  This still has the problem of putting the box there. Fortunately I think
there are tools for this in the standard include files.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Tom A 
Subject: Re: Objects in camera
Date: 5 Sep 2002 17:19:14
Message: <3D77CA51.1FDB1988@my-deja.com>
Warp wrote:
> 
> Slime <slm### [at] slimelandcom> wrote:
> > The wimpy (non-mathematical, less learning involved) way to do what Warp
> > described is to create a thin box in front of the camera that covers the
> > viewing plane
> 
>   This still has the problem of putting the box there. Fortunately I think
> there are tools for this in the standard include files.
> 

> --
>  - Warp -

Sorry, been a little busy, haven't had a chance to say Thank You for the
suggestions.

Question about this answer - while I understand how to create the box,
and the trace conditional, Warp is right in that it still leaves the
problem with the box there.  Can you point me at the include files that
might help with this?

Actually, in thinking about it, a simpler solution is to think 2
dimensionally - since I'm just worried about which trees will be in
view, I can ignore the Y dimension of the trees or camera.  
The math then comes down to figuring out the angle between the vector
from the camera position to the look_at point and the camera and the
location of the tree.  Compare that with half the angle of the screen
(about 40 degrees, maybe a little more, to allow for trees just outside
the view to have branches in screen).  

Then, I should be able to put the camera in the middle of a forest, and
get a reasonable render time.

Again, thanks everyone.

-- 
Tom A.
When scientist say they're making a "quantum leap" it 
means they are going out to catch some rays.  - Dr. Science
Deja mail is gone.  Look for me at raugost at yahoo . com


Post a reply to this message

From: Warp
Subject: Re: Objects in camera
Date: 6 Sep 2002 05:11:56
Message: <3d78715c@news.povray.org>
Tom A. <tar### [at] my-dejacom> wrote:
> Question about this answer - while I understand how to create the box,
> and the trace conditional, Warp is right in that it still leaves the
> problem with the box there.  Can you point me at the include files that
> might help with this?

  screen.inc

http://povray.org/documentation/view/288/

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

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