On Mon, Oct 18, 2010 at 10:23 PM, Cory Riddell <c...@codeware.com> wrote:

>  I've been plowing through this and I can almost get what I need, I just
> don't entirely understand a couple of things.
>
> Is it safe to think of the view matrix as the camera position and
> orientation? By doing so, I think I understand
> SphericalManipulator::getMatrix() method. It returns:
>
> As was mentioned recently, the view matrix is actually the inverse of
camera position and orientation in the world. You can also think of it as
the position and orientation of the world in eye space. The "matrix"
returned by the manipulator classes is the camera pose; the matrix returned
by getInverseMatrix() is the view matrix.


>     return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
>             osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
>             osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
>             osg::Matrixd::translate(m_center);
>
> This manipulator has two parameters - heading and elevation. Heading is the
> angle from the x-axis in the x-y plane and elevation is the angle from the
> x-y plane (pi/2 would give you the z-axis).
>
> If I want the x-axis to be up rather than the z-axis, I add an additional
> rotation:
>
>     return osg::Matrixd::translate(osg::Vec3d(0.0, 0.0, m_distance))*
>             osg::Matrixd::rotate(M_PI_2-m_elevation, 1.0, 0.0, 0.0)*
>             osg::Matrixd::rotate(M_PI_2+m_heading, 0.0, 0.0, 1.0)*
>             osg::Matrixd::rotate(M_PI_2, 0.0, 1.0, 0.0)*    //  NEW!
>             osg::Matrixd::translate(m_center);
>
> Am I tinkering with the right stuff here? (I've also made the appropriate
> change to my getInverseMatrix() method.)
>
Yes, that looks fine.
Tim

>
> It's feeling ok, but I do need to make more changes to the manipulators
> code that handles pans.
>
> Cory
>
>
> On 10/15/2010 5:03 PM, Cory Riddell wrote:
>
> I have been using the SphericalManipulator and it works really well for my
> application.
>
> One thing I would like to do is change which direction is up. The default
> is Z == up. Sometimes I want X to be up. If I understand the code, I need to
> make fairly extensive modifications to the existing manipulator. Before I
> start down that road, I just wanted to ask if that sounds right. I'm hoping
> I'm not missing some place where I obviously just need to apply some
> transformation matrix.
>
> I actually want my entire scene to go sideways, not just orbit up and down
> on my screen rather than right and left. For example, if I were modeling a
> pencil (coaxial the z axis), I sometimes want it standing on end, and
> sometimes lying on its side on my screen.
>
> I think I'm asking a question that has been asked before:
>
> http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33695.html<http://www.mail-archive.com/osg-users@lists.openscenegraph.org/msg33695.html>
>
> Cory
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to