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:09:34 EDT (-0400)
  Re: how to check if an object is in the camera view  
From: Jaap
Date: 6 Nov 2005 17:50:00
Message: <web.436e87d88e315a6a8399d8d0@news.povray.org>
you could use the sphereradio:  (all code untested)
(I assume you will be change the camera or object position with the "clock")

// Variables
#declare cameralocation = <5-clock, 0.5, -4.0>;
#declare cameralookat =    <5-clock, 0.5,  0.0>;
#declare camerangle = 90;

camera {
  location  cameralocation
  sky       z // you probably use y for up ??)
//up        z
  right     -x*image_width/image_height // (=camera aspect ratio)
  look_at   cameralookat
  angle     camerangle
}

//////
#declare sphereradio = .1    ;
#declare sphereposition = <5,1,0>;

#declare A  = cameralocation;  // camera position
#declare B  = cameralookat;  // look at posision
#declare C  = sphereposition;    // cylinder position
#declare AB = B-A;
#declare AC = C-A;
//#declare BC = AC-AB;  // (not used)
#declare objectDistance = vlength(AC);
#declare objectSize = degrees(asin(sphereradio/objectDistance)); //(half of
it)
#declare extraSize = 1.0; //(degrees) (zero should be possible!)
//#declare D = A + AB + AC;
#declare objectangle = VAngleD(AC,AB);
#if ( objectangle < ((camerangle/2)+extraSize+objectSize) )
  #declare #include "myfile.inc"
#else
  #declare #include "myfiletest.inc" // (empty or simplifyed version)
#end


Post a reply to this message

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