POV-Ray : Newsgroups : povray.animations : how to check if an object is in the camera view : Re: how to check if an object is in the camera view Server Time
1 Jul 2024 03:23:44 EDT (-0400)
  Re: how to check if an object is in the camera view  
From: Jaap
Date: 1 Nov 2005 15:15:01
Message: <web.4367cc298e315a6a8399d8d0@news.povray.org>
The only way i can think of is doing it manually, but it can automated a
bit:

define a sphere (location and radius) that completely includes your object
and any possible shadows of it. Then calculate a vector from your camera
point in the look-at direction as well as a vector from the camera to the
center of the sphere.
Then Calculate the angle between the two vectors. This indicated how far
your object is from the center of the camera view (in radians).
Then take the distance from the camera to your object (center of the sphere)
and the radius of the sphere to calculate the "size" of the object in
radians.

then:
distance_center_of_camera_view - (object_size/2) - (diaginal_camera_angle/2)
(all in radians)
if the result is negative, part of the sphere (and so possibly your object)
could be within the camera view.

It would be nice to use the trace function to detect if the sphere is within
the camera view. it might work if you shoot a couple of ray's, one in each
corner of the camera view, and a couple along the edge and in the middle.
(only if your object is relatively big).

once you have worked out whether the object will be vi sable, you can just
use an IF statement to include an include file (with the actual object)
when needed.

anyone who can think of a simpler solution ?

jaap. (let me now if you need any help calculating the above)


Post a reply to this message

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