POV-Ray : Newsgroups : povray.general : Camera Conundrum : Re: Camera Conundrum Server Time
10 Aug 2024 01:27:05 EDT (-0400)
  Re: Camera Conundrum  
From: Bob Hughes
Date: 24 Mar 2000 02:19:09
Message: <38db16ed@news.povray.org>
Unfortunately this won't find the proper area for all objects, like blobs for
instance as Greg J. was recently finding out, but sure looks better than nothing
by far.
I had known of a thing called Zoom All or similar used in some modellers so that
you can get back to the entire scene quickly (zooms all of it in or out) which
is what this is all about so now I understand the idea behind it anyway.

Bob

"Charles Fusner" <cfu### [at] enternet> wrote in message
news:38DABFA4.9E83DF5F@enter.net...
| Charles Krause wrote:
| >
| > Here's something I'd like to do with a camera, and I havn't got a clue how.
| >
| > What I'd like to do is to set the camera, and the image so that the bounding
| > box of an object fills the field of view completely. This if the object
| > _was_ a box, the side of the box would fill the image, the WHOLE side of the
| > box would show, and NOTHING else would show.
| >
| > any ideas?
|
| Disclaimers: #1. This solution uses functions found in MegaPOV...
| although they are among the features most likely to appear in the
| next generation of POV-Ray, this code will not run in standard
| POV 3.1. If you insist on using only standard POV code, you'll
| have to manually supply the corners of the bounding box. If you
| aren't familiar with MegaPOV, min_extent() returns the lower
| corner of the bounding box, while max_extent() returns the upper
| corner of the bounding box. You have to mentally substitute your
| hand supplied corners.
| #2. What you're asking to do (a sort of "zoom extents" camera)
| is somewhat angle dependant (we are, afterall, talking about a
| bounding *box*. So in order to get the image filled *completely*
| like you've described using this method, you kind of half to look
| head on from one of the axial directions, AND match the
| height/width ratio of the camera to the height width ratio of
| the box as seen from that direction, however, this will give you
| some ideas to get started. In fact, this is more likely to ensure
| you get the closest view that completely includes the full extents
| of the object, but you'll get the idea from this.
| #3. This code was written quickly, and I don't guarantee it works
| completely without modification in all situations. Take it as a
| starting point only.
| --------------------------------------------------------------------
| #macro AngleBetween(V1,V2)
| /* Calculates the angle between two vectors using the law of cosines -
|    A good multipurpose function...
| */
|     #local SA = vlength(V1);
|     #local SB = vlength(V2);
|     #local SC = vlength(V2-V1);
|
|     #if ( SA>0 & SB>0 )
|        #local T = degrees( acos ( (SA*SA+SB*SB-SC*SC)/(2*SA*SB) ));
|     #else
|        #local T = -1; file://generic return meaning failure of function
|     #end
|
|     T
| #end//end macro AngleBetween
|
| #macro ZoomCam(objTarget,LocationPoint)
| /*Given an object and the point of view to look from, define a camera
| that
|   zooms in on it...
| */
|     #local LookAtPoint =
| (max_extent(objTarget)+min_extent(objTarget))/2;
|     #local LocalizedMax = max_extent(objTarget)-LocationPoint;
|     #local LocalizedMin = min_extent(objTarget)-LocationPoint;
|     #local CamAngle = AngleBetween(LocalizedMax,LocalizedMin);
|
|     #if (CamAngle != -1 )
|     camera {
| location LocationPoint
|         look_at LookAtPoint
|         angle CamAngle
|     }
|     #else
|         #warning "Warning: Degenerate bounding or bad cam angle...
|                   unable to compute camera\n"
|     #end
| #end//end Zoomcam Macro
|
| file://now apply the macro...
| #declare SomeObject =
|    sphere { 0,1 pigment { rgb<0,0,1> } finish { phong 1 }}
|
| ZoomCam(SomeObject,<0,0,-10>)
| light_source { <200,200,-200> color rgb 1 }
| object {SomeObject }


Post a reply to this message

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