Hi,

I would like to submit my modifications to the osgGA::SphericalManipulator
class to allow the specification of any up axis. The default now is to
always use the Z axis as the vertical axis. This change is a generalization
of the idea allowing one to specify any vector as the up axis.

I've implemented the getMatrix() and getInverseMatrix() methods to
incorporate this additional transformation. However, I did not update the
setByMatrix() method as I was unsure of the correct way to implement this.
If anyone has hints about how to do this please let me know and I will
incorporate it.

Regards,
Chris

$ diff
/s/sandbox/dev/extern/OpenSceneGraph-3.2.0/include/osgGA/SphericalManipulator
SphericalManipulator
81a82,85

>         void setUpAxis(const osg::Vec3d& upAxis);
>         const osg::Vec3d& getUpAxis() const {return _upAxis;}
>         const osg::Vec3d& getPitchAxis() const {return _pitchAxis;}
>
170a175,178
>         osg::Vec3d      _upAxis;
>         osg::Vec3d      _pitchAxis;
>         osg::Matrix     _orientationOffset;
>         osg::Matrix     _orientationOffsetInverse;



$ diff
/s/sandbox/dev/extern/OpenSceneGraph-3.2.0/src/osgGA/SphericalManipulator.cpp
SphericalManipulator.cpp
17a18,19

>     _upAxis.set(0.0, 0.0, 1.0);
>     _pitchAxis.set(1.0, 0.0, 0.0);
62a65,77
>
>
//--------------------------------------------------------------------------------------------------
> void SphericalManipulator::setUpAxis(const osg::Vec3d& upAxis)
> {
>     _upAxis = upAxis;
>     _upAxis.normalize();
>
>     osg::Quat q; q.makeRotate( osg::Vec3d(0.0,0.0,1.0), _upAxis );
>     _pitchAxis = q * osg::Vec3d(1.0,0.0,0.0);
>     _orientationOffset.makeRotate(q);
>     _orientationOffsetInverse = osg::Matrix::inverse(_orientationOffset);
> }
>
263,264c278,280
<            osg::Matrixd::rotate(PI_2-_elevation,1.0,0.0,0.0)*
<            osg::Matrixd::rotate(PI_2+_heading,0.0,0.0,1.0)*
---
>            _orientationOffset*
>            osg::Matrixd::rotate(PI_2-_elevation,_pitchAxis)*
>            osg::Matrixd::rotate(PI_2+_heading,_upAxis)*
271,272c287,289
<            osg::Matrixd::rotate(PI_2+_heading,0.0,0.0,-1.0)*
<            osg::Matrixd::rotate(PI_2-_elevation,-1.0,0.0,0.0)*
---
>            osg::Matrixd::rotate(PI_2+_heading,-_upAxis)*
>            osg::Matrixd::rotate(PI_2-_elevation,-_pitchAxis)*
>            _orientationOffsetInverse*
427a445
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to