I found a very easy and intuitiv way to remove inclination (y-axis) and
rolling (x-axis) from a view matrix:
osg::Vec3d eye,center,up;
matrix.getLookAt(eye,center,up,1);
center.set(center.x(),center.y(),eye.z()); //removes inclination
up.set(0,0,1); //removes rolling
matrix.makeLookAt(eye,center,up);
At first I request eye, center and up vector from the matrix. Then I set the
heigt from center-vector to the height of eye-vector, which removes the
inclination (y-axis rotation). Then I set a new up-vector to (0,0,1) which
removes the rolling (x-axis rotation) from the matrix. Finally I create a
new view matrix with the manipulated vectors. It works 100% fine.
Thanks for all hints, Tobias
On Feb 4, 2008 10:37 PM, Thrall, Bryan <[EMAIL PROTECTED]>
wrote:
> John Kelso wrote on Monday, February 04, 2008 2:31 PM:
> > Won't this also remove the scale?
>
> Yes, but only for the X and Y axes :)
>
> > On Mon, 4 Feb 2008, Thrall, Bryan wrote:
> >
> >>
> >> Sorry, hit send too soon, updated below...
> >>
> >> Thrall, Bryan wrote on Monday, February 04, 2008 12:21 PM:
> >>> Tobias M?nch wrote on Monday, February 04, 2008 11:29 AM:
> >>>> Hello at all,
> >>>>
> >>>> I have osg::Matrixd view matrix and want to remove the rotation
> >>>> around x- and y-axis. Only rotation around z-axis should stay in
> >>>> the matrix. I try a lot of possibilties but couldn't find a
> >>>> solution.
> >>>>
> >>>> When I make the following steps, the rotation around all axis is
> >>>> removed, not only the two specified axis. The same with
> >>>> osg::Matrixd::makeRotate(..);
> >>>>
> >>>> matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0),
> >>>> osg::Vec3(0,1,0));
> >>>>
> >>>> matrix = osg::Matrixd::rotate(osg::DegreesToRadians(0.0),
> >>>> osg::Vec3(1,0,0));
> >>>>
> >>>>
> >>>> I also tried to set the matrix with complete new values and to take
> >>>> given value for z-rotation, but therefore I miss a function to read
> >>>> the one rotation part (around the z-axis).
> >>>>
> >>>> How can help me?
> >>>
> >>> Both of those lines *set* matrix to a non-rotating matrix; what you
> >>> want is to *modify* the matrix to remove the X and Y rotations.
> >>>
> >>> The easiest way is to modify the matrix directly:
> >>>
> >>
> >> matrix(0,0) = 1;
> >> matrix(0,1) = 0;
> >> matrix(0,2) = 0;
> >> matrix(1,0) = 0;
> >> matrix(1,1) = 1;
> >> matrix(1,2) = 0;
> >>
> >> If I didn't mess up my indices, this zeroes out the X and Y
> >> rotations while leaving the Z intact.
> --
> Bryan Thrall
> FlightSafety International
> [EMAIL PROTECTED]
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org