POV-Ray : Newsgroups : povray.general : Camera Conundrum Server Time
10 Aug 2024 03:21:07 EDT (-0400)
  Camera Conundrum (Message 1 to 6 of 6)  
From: Charles Krause
Subject: Camera Conundrum
Date: 22 Mar 2000 21:21:43
Message: <38d97fb7@news.povray.org>
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?


Post a reply to this message

From: Bob Hughes
Subject: Re: Camera Conundrum
Date: 22 Mar 2000 21:50:24
Message: <38d98670@news.povray.org>
You lost me.  Nothing beyond a certain distance would show, is that the idea?
All I can say right now (hope I'm right too) is that you'll want to use at least
a 4 units wide by 3 units high bounding box whose inside face is at 0*z when the
camera is at -6.32*z and which has 'angle 36' in order to just cover the whole
area of a 'look_at <0,0,0>'.
Besides this, if this has anything to do with your question in the first place,
it seems you're wanting to bound the camera to the same area as the part of your
scene of which you wish to see exclusive of any other parts.
Did I make any sense?  Well, keep posting replies and maybe someone will get
somewhere with this.

Bob

"Charles Krause" <ckr### [at] telusplanetnet> wrote in message
news:38d97fb7@news.povray.org...
| 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?


Post a reply to this message

From: Charles Krause
Subject: Re: Camera Conundrum
Date: 23 Mar 2000 19:53:23
Message: <38dabc83$1@news.povray.org>
Ok - let me try again :)

If an object is in the field of view, it will take up part of the image.

If the camera is closer to the object, it will take up more of the image, if
the camera is farther away it will take up less.

If the camera is at _just_ the right distance, the edges of the object will
appear to touch the edge of the image. There would be no space around the
object.

If the aspect of the picture was set _just_ right as well, and the object
was centered in the field of view, the object would touch all 4 sides of the
image at the same time. THAT is what I want to do.

I would like to be able to define an object, and then have the program
automatically place the camera so this is the case.


Post a reply to this message

From: Charles Fusner
Subject: Re: Camera Conundrum
Date: 23 Mar 2000 20:04:35
Message: <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; //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

//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

From: Bob Hughes
Subject: Re: Camera Conundrum
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

From: Josh English
Subject: Re: Camera Conundrum
Date: 27 Mar 2000 15:05:14
Message: <38DFBF2A.5F3978C8@spiritone.com>
It sounds like you are trying to place a background image in POV-Ray, which
cannot be done natively.
Here is some code and explanations (from a post on January 7th)
#local CamLook = <0,0,3>; // Camera's Look_at
#local CamLoc = <0,0.5,-6>; //where the camera's location is
#local cam_z = 2; //the amount of camera zoom you want
#local back_dist = 100; // how far away the background is
#local cam_a = 4/3; // camera aspect ratio
#local cam_s = <0,1,0>; // camera sky vectoy
#local cam_d = vnormalize(CamLook-CamLoc);
#local cam_r = vnormalize(vcross(cam_s,cam_d));
#local cam_u = vnormalize(vcross(cam_d,cam_r)); // camera up vector
#local cam_dir = cam_d * cam_z;
#local cam_right = cam_r * cam_a;

#declare fz = vlength(cam_dir);
#declare fx = vlength(cam_right)/2;
#declare fy = vlength(cam_u)/2;

camera {
  location CamLoc
  up cam_u
  right cam_r * cam_a
  direction (cam_d * cam_z)
}

box { <0,0,0> <1,1,0.1>
      pigment { image_map { png "background.png"
                                             map_type 0
                                             interpolate 2 } }
      translate <-0.5,-0.5,0>
      scale 2*<fx,fy,0.5>
      translate fz*z
      scale back_dist
      #local nz = vnormalize(CamLook-CamLoc);
      #local nx = vnormalize(vcross(cam_s,nz));
      #local ny = vcross(nz,nx);
      matrix <nx.x,nx.y,nx.z,
               ny.x,ny.y,ny.z,
              nz.x,nz.y,nz.z,
              CamLoc.x,CamLoc.y,CamLoc.z> }

This assumes a normal perspective camera. Remember that all the rays that are
traced are from one point, so the edges of the viewable area make a four sided
pyramid in space, so there are an infinite number of boxes that would work.

Josh



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?

--
Josh English
eng### [at] spiritonecom
"May your hopes, dreams, and plans not be destroyed by a few zeros."


Post a reply to this message

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