|
![](/i/fill.gif) |
"Nekar Xenos" <nek### [at] gmail com> wrote:
> I am trying to duplicate the camera angle in a scene with a box mapped
> with the image, but when I use certain camera positions and look
> combinations, it rotates the image along the z axis. It seems to happen
> when the Camera position and look position don't have the same y value.
>
> How can i fix this?
>
> here is a stripped down version. If the "doesn't work' part is commented
> out it works fine.
>
> I must admit, I don't always know when to use Reorient_Trans() vs
> vrotate() vs VAngleD() and even less how to use them. It gets confusing.
Reorient_Trans() rotates an object so that a given axis is aligned with another
axis by rotating the object around an axis perpendicular to both.
e.g. reorienting the object to align its x axis with it's z axis would rotate it
around y. This is, of course, an extremely trivial example, but you could also
use it to align an axis with a given vector (not sure if it needs to be a
unit-vector or not)
vrotate() simply rotates an object around a vector.
VAngle() and VAngleD() compute the angle between two vectors, the former
returning an angle in radians, the latter returning an angle in degrees.
>
>
> //-----------------------------------//
> // begin code
> #version 3.7;
>
> global_settings { max_trace_level 5 assumed_gamma 1}
>
>
> #include "Transforms.inc"
>
>
> //works:
> #declare CamPos= <0.5, 1.5,4.5 >;
> #declare CamLook= <1.3,1.5,0>;
> ///////////////////////////////////
>
> // doesn't work:
> #declare CamPos= <0.5, 1.5,4 >;
> #declare CamLook= <1.3,1.2,0>;
> //////////////////////////////////
>
> #declare CamDirect=<0,0,1>;
> #declare CamWidth=image_width;
> #declare CamHeight=image_height;
>
> #declare ColMapPig=pigment {image_map { png "test.png" }
> translate -0.5*(x+y)
> scale <CamWidth/CamHeight,1,1>*2
> }
>
> box{<-CamWidth/CamHeight,-1,CamDirect.z>,<CamWidth/CamHeight,1,CamDirect.z+0.001>//}
>
> texture {
> pigment {ColMapPig}
> finish { ambient 1 diffuse 1}
> }
>
>
> translate CamDirect
> Reorient_Trans(z, (CamLook-CamPos))
>
> translate CamPos
> }
>
> #declare ColMap="test.png"
>
> ///////////////////////////////////////////////////
>
> camera {
> location CamPos
> direction CamDirect
> right x*image_width/image_height
> look_at CamLook
> }
> // End code
> //-------------------------//
>
>
> //--
> -Nekar Xenos-
I agree with Christian that you need to specify the up vector in your camera
definition. My default camera is usually something like this: (actually a lot
like yours)
camera {
perspective
location locVect
up y
right x*(image_width/image_height)
look_at lookVect
}
regards,
A.D.B.
Post a reply to this message
|
![](/i/fill.gif) |