From Chuck Seberino, "Attached are modified versions of RotateCylinderDragger and Projector files that clean up the use of _onCylinder / isProjectionOnCylinder().
I have also made changes to the RotateCylinderDragger to provide a cylinder ring with a thickness. It is totally optional, but IMHO makes the default behavior work better than a solid cylinder (which typically obscures the geometry you are trying to drag). Gives it a bit more to grab, especially in the case where eyepoint and cylinder axis are near parallel. "
This commit is contained in:
@@ -263,7 +263,11 @@ class OSGMANIPULATOR_EXPORT CylinderProjector : public Projector
|
||||
};
|
||||
|
||||
/**
|
||||
* CylinderPlaneProjector projects points onto the given cylinder.
|
||||
* CylinderPlaneProjector projects a point onto a plane relative to the
|
||||
* given cylinder. For most cases, the plane will be parallel to the
|
||||
* cylinder axis oriented towards the eyepoint. When the eyepoint and
|
||||
* cylinder axis are close to parallel, then it will project onto a plane
|
||||
* perpendicular to the cylinder.
|
||||
*/
|
||||
class OSGMANIPULATOR_EXPORT CylinderPlaneProjector : public CylinderProjector
|
||||
{
|
||||
@@ -277,23 +281,26 @@ class OSGMANIPULATOR_EXPORT CylinderPlaneProjector : public CylinderProjector
|
||||
* Calculates the object coordinates (projectedPoint) of a window
|
||||
* coordinate (pointToProject) when projected onto the given plane.
|
||||
* Returns true on successful projection.
|
||||
* \param[in] pi Incoming intersection information
|
||||
* \param[out] projectedPoint Point located on the given plane
|
||||
* \return bool Whether the projection onto the plane was successful.
|
||||
*/
|
||||
virtual bool project(const PointerInfo& pi, osg::Vec3d& projectedPoint) const;
|
||||
|
||||
/**
|
||||
* Returns true if the previous projection was on the cylinder and
|
||||
* false if the projection was on the plane.
|
||||
* Generates a rotation about the cylinder axis based upon the incoming
|
||||
* projected points on the plane computed from project().
|
||||
* \param[in] p1 Initial projection point
|
||||
* \param[in] p2 Second projection point
|
||||
* \return osg::Quat Rotation about cylinder axis
|
||||
*/
|
||||
bool isProjectionOnCylinder() const { return _onCylinder; }
|
||||
|
||||
osg::Quat getRotation(const osg::Vec3d& p1, bool p1OnCyl, const osg::Vec3d& p2, bool p2OnCyl) const;
|
||||
osg::Quat getRotation(const osg::Vec3d& p1, const osg::Vec3d& p2) const;
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~CylinderPlaneProjector();
|
||||
|
||||
mutable osg::Plane _plane;
|
||||
mutable bool _onCylinder;
|
||||
mutable osg::Vec3d _planeLineStart, _planeLineEnd;
|
||||
mutable bool _parallelPlane;
|
||||
};
|
||||
|
||||
@@ -59,7 +59,6 @@ class OSGMANIPULATOR_EXPORT RotateCylinderDragger : public Dragger
|
||||
osg::ref_ptr<CylinderPlaneProjector> _projector;
|
||||
|
||||
osg::Vec3d _prevWorldProjPt;
|
||||
bool _prevPtOnCylinder;
|
||||
osg::Matrix _startLocalToWorld, _startWorldToLocal;
|
||||
osg::Quat _prevRotation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user