|
![](/i/fill.gif) |
remigagne nous apporta ses lumieres en ce 2007/09/17 14:32:
> Hi all,
>
> I have a scene that renders correctly at 1000 x 1000 with this true
> orthographic camera:
>
> camera { orthographic
> location <-28, -14.5, -28> * 1000
> right 1000 * x
> up 1000 * y
> look_at <0, 0, 0> }
>
> I'm now trying to create new 100 x 100 sub-portions of this scene. For
> example, if I render at 100 x 100 using this camera:
>
> camera { orthographic
> location <-28, -14.5, -28> * 1000
> right 100 * x
> up 100 * y
> look_at <0, 0, 0> }
>
> I get a 100 x 100 image that's *identical* to the (450, 450) to (550, 550)
> center of the original 1000 x 1000 image, which is perfect. But how can I
> generalize this to render any portion of the scene? For example, how can I
> generate a 100 x 100 image centered on the (30, 400) portion of the
> original?
>
> I think I can translate the camera and look_at point, doing something like:
>
> camera { orthographic
> #declare dx = ?;
> #declare dy = ?;
> #declare dz = ?;
> location (<-28, -14.5, -28> * 1000) + <dx, dy, dz>
> right 100 * x
> up 100 * y
> look_at <dx, dy, dz> }
>
> I just can't wrap my head around the math required to calculate dx, dy & dz,
> given a center pixel location of (30, 400). Any advice?
>
> A little more background: the scene is in a predefined pov file with no
> camera. I'm generating new pov files programmatically; these simply
> include the original scene and a dynamically calculated camera (based on
> user input).
>
> Thanks in advance!
>
>
> Remi
>
>
>
It would be easier if your camera was parallel to an axis, like the z axis.
You first need to evaluate how many pov-units fit in your 1000 original pixels.
It can be evaluated empiricaly using a plane with a checker pattern. It can be
calculated from the direction vector that default to 1. It's about the same as
the distance between the location and the look_at point, or about 42169
pov-units whide! The field of view extend 0.5 units left and right from the
camera axis at 1 unit in front of the camera, multiplied by the distance to the
look_at point.
So, for each 1 pixel of movement, you need to move the camera 42.17 units. You
could use the vrotate(<Udx,Udy,0>, Your_Angle) macro on the <Udx, Udy, 0> vector
of the user to get the <dx,dy,dz> translate vector you need.
You can add translate<dx,dy,dz> to your camera after everything else. This way,
your camera won't change it's orientation: the location and look_at will change
in exactly the same direction and distance. Easier to maintain and less chance
of making a typo.
--
Alain
-------------------------------------------------
You know you've been raytracing too long when you have ever "Hand-Coded" a
bezier patch.
Stephan Ahonen
Post a reply to this message
|
![](/i/fill.gif) |