Ron,

In your particular case, you have a camera positioned at (0,0,320)
looking at the origin (right down the z-axis) with "up" being the
y-axis. For the orthographic projection, the viewing region is a box per
se. The left and right sides align with the x-axis and the top and
bottom sides align with the y-axis. The projection of an object onto the
near plane has all lines of projection parallel to each other. When you
change the x and y boundaries, you're effectively changing the sides
(left, right, bottom, top) of the box relative to the eye position. This
is the same effect as changing the eye (x,y) relative to the box
assuming the vector from the eye position to the look-at point is
parallel to the sides of the box (ignoring the near-far sides).

For your example, if you change the box to (-50, 150, -75, 125), this is
the same as setting the view point to (-50,-25,320) with a look-at of
(-50,-25,0) with the same "up" vector (0,1,0) (e.g.
setViewMatrixAsLookAt()). If you draw the geometry (the viewing "box"
and the eye) on paper in 2D and do the translation, you can see why it
does what it does.

In general, you do want to use the ModelView matrix to set the position
and orientation of the camera...

-Shayne

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ron
Mayer
Sent: Monday, July 23, 2012 7:14 AM
To: [email protected]
Subject: [osg-users] Question regarding the position of the camera
inorthographic projection

Hi, 

There is a mode in our application where the user does not control the
camera. The camera is initially set to look at the z=0 plane
(perpendicular to the plane) at a fixed height. We then get
notifications from the application to move the camera in x and y only.

I was looking at our code we had for that, and I found out that we may
have been doing a mistake. On the other hand, the view looks correct so
I wanted to ask for more insight on this.

When the application comes in with a delta [x, y], we only move the
frustum of the orthographic projection, without moving the camera.
I would imagine the right thing to do would be to move the camera in [x,
y] without changing the frustum. But for some reason just moving the
frustum works fine. I am not sure if this is valid or not.
[I do know that if we were in perspective we would have to move the
camera, since the frustum is defined by the angle and ratio of the
view.]

Just as an example, we start by setting the camera:

Code:
camera->setProjectionMatrixAsOrtho(-100.0, 100.0, -100.0, 100.0, 0.0,
320); // frustum of [200X200]
camera->setViewMatrixAsLookAt( osg::Vec3(0.0, 0.0, 320.0),
osg::Vec3(0.0, 0.0, 0.0), osg::Vec3(0.0, 1.0, 0.0)); // [eye, center,
up]


then at a later time, the application may say: "move the camera in x=50,
y=25"

Instead of moving the camera location we just call:

Code:
camera->setProjectionMatrixAsOrtho(-50.0, 150.0, -75.0, 125.0, 0.0,
320); 


Without moving the camera.


Cheers,
Ron

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=48990#48990





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to