[osg-users] how to get model scale？
Jolley, Thomas P
thomas.p.jolley at boeing.com
Fri Sep 19 08:11:06 PDT 2008
Hi Cliff, Forest,
Read the camera analogy in the viewing chapter of the OpenGl red book. It will help with everyone having the same definitions of zoom and scale. And, a better chance the original post can be answered with a question using terms we can understand.
Positioning the viewing volume (moving your eyepoint or camera) is not the same as zoom or scale but could easily be confused as either. This is the view matrix. Cliff's post seems to call this zoom.
Scale is a modeling transformation. In an osg scenegraph a MatrixTransform or related nodes modify the scale of an object (or scene if the top node is an MT).
Zoom is a projection transformation. Change the field of view to change the zoom.
Forest, we don't know what "zoom scale" means. If you're trying to get zoom it doesn't make sense to look at the view matrix. You need to look at the projection matrix. Also, it doesn't make sense to look at the view matrix to get the scale of an object.
> -----Original Message-----
> From: Cliff Taylor [mailto:bloodgain at gmail.com]
> Sent: Thursday, September 18, 2008 6:44 PM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] how to get model scale？
> I think I understand what he means. I'm going to throw in my
> 2 cents, because I'm interested in the answer to this question.
> I'm going to use directions based on a line-of-sight instead
> of x/y/z to avoid confusing myself or others.
> I think what he means is this:
> -- assume the camera at a fixed angle (i.e. 2D view of either
> a 2D or 3D object) and the user can manually move the camera
> (via click and drag, perhaps) up/down, left/right, and in/out
> (this is our "zoom").
> The user just cannot "turn" the camera.
> -- at any given camera position, I would like to know the
> "scale" of the "zoom". That is, how much bigger or smaller
> does the object appear.
> I'm sure at some level (OpenGL, hardware), a transform is
> done using some form of scaling of the original object
> description. That may, however, be very difficult or
> impossible to retrieve or use.
> From what I see you guys saying, he will just need to do the
> math on his in/out camera position. For instance, if the
> user is half the distance to the object, the "zoom scale" is
> now 2 (or 200%).
> Likewise, if the user has moved the camera half the original
> distance farther away, the "scale" should be 0.75 (75%). If
> the camera moves twice the original distance away, the
> "scale" is 0.5 (50%), meaning everything looks half as big
> (in theory).
> Is this correct? Is there no way to find the "scale" of the
> object compared to the original view other than do the math
> with the distances?
> Forgive me if I'm wrong about your question, Forest. That
> sounds like what you were asking to me, being a relative
> newbie to the graphics and scene graph world myself.
> 2008/9/18 Paul Martz <pmartz at skew-matrix.com>:
> > I'm not entirely sure what you mean by "scale of the scene"
> from your
> > message. To me, this is an application concept. The user sets the
> > scale using some user interface, and the application stores
> this value
> > and modifies the scene graph to redraw the scene at a
> different size.
> > If your application were set up this way, you would already
> have the
> > scale and wouldn't need to retrieve it from OSG.
> > -Paul
> > ________________________________
> > From: osg-users-bounces at lists.openscenegraph.org
> > [mailto:osg-users-bounces at lists.openscenegraph.org] On
> Behalf Of forest37
> > Sent: Thursday, September 18, 2008 9:22 AM
> > To: osg-users at lists.openscenegraph.org
> > Subject: [osg-users] how to get model scale？
> > hi all,
> > When the secne is zoomed in or out ,I want to
> get the zoom
> > scale.I do it like this:
> > osg::Camera* camera= viewer.getCamera();
> > osg::Matrix vm=camera->getViewMatrix();
> > osg::Vec3 scale=vm.getScale();
> > the result is that scale always equals to
> (1,1,1).What does
> > this mean and how can I get the reall scale of the scene?
> > thanks
> > best regards
> > forest
> > ________________________________
> > [广告] 买房不必东奔西走，上房老大，看"二手房"网上房展会
> > <http://popme.163.com/link/003984_0909_8679.html>
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> > org
> osg-users mailing list
> osg-users at lists.openscenegraph.org
More information about the osg-users