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:

    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.)

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/[email protected]/msg33695.html

Cory


_______________________________________________ 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

Reply via email to