camera seems to rotate?
in
Programming Questions
•
1 years ago
hello, i'm trying to modify camera setting to make an object that change its dimension always in the center of the screen.
my 3d object is dinamically changing its height and i want the camera to move far or near from it to make it always in the center.
so if it is small.. my camera is near, if it is big the camera moves back.
i'm using the formula:
- float distance = h / tan((fov)/2);
-
- camera(width/2.0, height/2.0, distance,
- AABBcenter.x, AABBcenter.y, 0,
- 0, 1, 0);
where
h is the height of the object,
fov is the field of view (i used the standard one in processings.org, PI/3.0) and the gained
distance is the distance the camera has to move along z-axis. the PVector
AABBcenter object record the center of bounding box of my object.
the formula is correct (i used it with panda3d render engine and it is ok), and the camera moves correctly and the object remains in the center.
the problem is that the object seems to rotate!
why??
how can i avoid this?
1