<osgGA/MatrixManipulator>:No such file or directory

修改为

#include <osgGA/CameraManipulator>

osgGA::GUIEventHandler

  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13.  
  14. #ifndef OSGGA_GUIEVENTHANDLER
  15. #define OSGGA_GUIEVENTHANDLER 1
  16.  
  17. #include <vector>
  18.  
  19. #include <osg/Drawable>
  20. #include <osg/ApplicationUsage>
  21.  
  22. #include <osgGA/EventHandler>
  23. #include <osgGA/GUIEventAdapter>
  24. #include <osgGA/GUIActionAdapter>
  25.  
  26. // #define COMPILE_COMPOSITE_EVENTHANDLER
  27.  
  28. namespace osgGA{
  29.  
  30. /**
  31.  
  32. GUIEventHandler provides a basic interface for any class which wants to handle
  33. a GUI Events.
  34.  
  35. The GUIEvent is supplied by a GUIEventAdapter. Feedback resulting from the
  36. handle method is supplied by a GUIActionAdapter, which allows the GUIEventHandler
  37. to ask the GUI to take some action in response to an incoming event.
  38.  
  39. For example, consider a Trackball Viewer class which takes mouse events and
  40. manipulates a scene camera in response. The Trackball Viewer is a GUIEventHandler,
  41. and receives the events via the handle method. If the user 'throws' the model,
  42. the Trackball Viewer class can detect this via the incoming events, and
  43. request that the GUI set up a timer callback to continually redraw the view.
  44. This request is made via the GUIActionAdapter class.
  45.  
  46. */
  47.  
  48. class OSGGA_EXPORT GUIEventHandler : public EventHandler
  49. {
  50. public:
  51.  
  52. GUIEventHandler() {}
  53. GUIEventHandler(const GUIEventHandler& eh,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
  54. osg::Object(eh, copyop),
  55. osg::Callback(eh, copyop),
  56. EventHandler(eh, copyop) {}
  57.  
  58. META_Object(osgGA,GUIEventHandler);
  59.  
  60. /** Handle event. Override the handle(..) method in your event handlers to respond to events. */
  61. virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv);
  62.  
  63. /** Handle events, return true if handled, false otherwise. */
  64. virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*) { return handle(ea,aa); }
  65.  
  66. /** Deprecated, Handle events, return true if handled, false otherwise. */
  67. virtual bool handle(const GUIEventAdapter&,GUIActionAdapter&) { return false; }
  68.  
  69. protected:
  70. virtual ~GUIEventHandler();
  71.  
  72. };
  73.  
  74. }
  75.  
  76. #endif

osgGA::CameraManipulator

  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13.  
  14. #ifndef OSGGA_CameraManipulator
  15. #define OSGGA_CameraManipulator 1
  16.  
  17. #include <osg/Node>
  18. #include <osg/Matrixd>
  19. #include <osg/CoordinateSystemNode>
  20.  
  21. #include <osgUtil/SceneView>
  22.  
  23. #include <osgGA/Export>
  24. #include <osgGA/GUIEventHandler>
  25. #include <osgGA/GUIEventAdapter>
  26. #include <osgGA/GUIActionAdapter>
  27.  
  28. namespace osgGA{
  29.  
  30. #define NEW_HOME_POSITION
  31.  
  32. /**
  33.  
  34. CameraManipulator is an abstract base class defining the interface, and a certain
  35. amount of default functionality, for classes which wish to control OSG cameras
  36. in response to GUI events.
  37.  
  38. */
  39. class OSGGA_EXPORT CameraManipulator : public GUIEventHandler
  40. {
  41. typedef GUIEventHandler inherited;
  42.  
  43. public:
  44.  
  45. // We are not using META_Object as this is abstract class.
  46. // Use META_Object(osgGA,YourManipulator); in your descendant non-abstract classes.
  47. virtual const char* className() const { return "CameraManipulator"; }
  48.  
  49. /** callback class to use to allow matrix manipulators to query the application for the local coordinate frame.*/
  50. class CoordinateFrameCallback : public osg::Referenced
  51. {
  52. public:
  53. virtual osg::CoordinateFrame getCoordinateFrame(const osg::Vec3d& position) const = ;
  54. protected:
  55. virtual ~CoordinateFrameCallback() {}
  56. };
  57.  
  58. /** set the coordinate frame which callback tells the manipulator which way is up, east and north.*/
  59. virtual void setCoordinateFrameCallback(CoordinateFrameCallback* cb) { _coordinateFrameCallback = cb; }
  60.  
  61. /** get the coordinate frame callback which tells the manipulator which way is up, east and north.*/
  62. CoordinateFrameCallback* getCoordinateFrameCallback() { return _coordinateFrameCallback.get(); }
  63.  
  64. /** get the coordinate frame callback which tells the manipulator which way is up, east and north.*/
  65. const CoordinateFrameCallback* getCoordinateFrameCallback() const { return _coordinateFrameCallback.get(); }
  66.  
  67. /** get the coordinate frame.*/
  68. osg::CoordinateFrame getCoordinateFrame(const osg::Vec3d& position) const
  69. {
  70. if (_coordinateFrameCallback.valid()) return _coordinateFrameCallback->getCoordinateFrame(position);
  71. return osg::CoordinateFrame();
  72. }
  73.  
  74. osg::Vec3d getSideVector(const osg::CoordinateFrame& cf) const { return osg::Vec3d(cf(,),cf(,),cf(,)); }
  75. osg::Vec3d getFrontVector(const osg::CoordinateFrame& cf) const { return osg::Vec3d(cf(,),cf(,),cf(,)); }
  76. osg::Vec3d getUpVector(const osg::CoordinateFrame& cf) const { return osg::Vec3d(cf(,),cf(,),cf(,)); }
  77.  
  78. /** set the position of the matrix manipulator using a 4x4 Matrix.*/
  79. virtual void setByMatrix(const osg::Matrixd& matrix) = ;
  80.  
  81. /** set the position of the matrix manipulator using a 4x4 Matrix.*/
  82. virtual void setByInverseMatrix(const osg::Matrixd& matrix) = ;
  83.  
  84. /** get the position of the manipulator as 4x4 Matrix.*/
  85. virtual osg::Matrixd getMatrix() const = ;
  86.  
  87. /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
  88. virtual osg::Matrixd getInverseMatrix() const = ;
  89.  
  90. /** update the camera for the current frame, typically called by the viewer classes.
  91. Default implementation simply set the camera view matrix. */
  92. virtual void updateCamera(osg::Camera& camera) { camera.setViewMatrix(getInverseMatrix()); }
  93.  
  94. /** Get the FusionDistanceMode. Used by SceneView for setting up stereo convergence.*/
  95. virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::PROPORTIONAL_TO_SCREEN_DISTANCE; }
  96.  
  97. /** Get the FusionDistanceValue. Used by SceneView for setting up stereo convergence.*/
  98. virtual float getFusionDistanceValue() const { return 1.0f; }
  99.  
  100. /** Set the mask to use when set up intersection traversal such as used in manipulators that follow terrain or have collision detection.
  101. * The intersection traversal mask is useful for controlling what parts of the scene graph should be used for intersection purposes.*/
  102. void setIntersectTraversalMask(unsigned int mask) { _intersectTraversalMask = mask; }
  103.  
  104. /** Get the mask to use when set up intersection traversal such as used in manipulators that follow terrain or have collision detection.*/
  105. unsigned int getIntersectTraversalMask() const { return _intersectTraversalMask; }
  106.  
  107. /**
  108. Attach a node to the manipulator, automatically detaching any previously attached node.
  109. setNode(NULL) detaches previous nodes.
  110. May be ignored by manipulators which do not require a reference model.
  111. */
  112. virtual void setNode(osg::Node*) {}
  113.  
  114. /** Return const node if attached.*/
  115. virtual const osg::Node* getNode() const { return NULL; }
  116.  
  117. /** Return node if attached.*/
  118. virtual osg::Node* getNode() { return NULL; }
  119.  
  120. /** Manually set the home position, and set the automatic compute of home position. */
  121. virtual void setHomePosition(const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up, bool autoComputeHomePosition=false)
  122. {
  123. setAutoComputeHomePosition(autoComputeHomePosition);
  124. _homeEye = eye;
  125. _homeCenter = center;
  126. _homeUp = up;
  127. }
  128.  
  129. /** Get the manually set home position. */
  130. virtual void getHomePosition(osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up) const
  131. {
  132. eye = _homeEye;
  133. center = _homeCenter;
  134. up = _homeUp;
  135. }
  136.  
  137. /** Set whether the automatic compute of the home position is enabled.*/
  138. virtual void setAutoComputeHomePosition(bool flag) { _autoComputeHomePosition = flag; }
  139.  
  140. /** Get whether the automatic compute of the home position is enabled.*/
  141. bool getAutoComputeHomePosition() const { return _autoComputeHomePosition; }
  142.  
  143. /** Compute the home position.*/
  144. virtual void computeHomePosition(const osg::Camera *camera = NULL, bool useBoundingBox = false);
  145.  
  146. /** finish any active manipulator animations.*/
  147. virtual void finishAnimation() {}
  148.  
  149. /**
  150. Move the camera to the default position.
  151. May be ignored by manipulators if home functionality is not appropriate.
  152. */
  153. virtual void home(const GUIEventAdapter& ,GUIActionAdapter&) {}
  154.  
  155. /**
  156. Move the camera to the default position.
  157. This version does not require GUIEventAdapter and GUIActionAdapter so may be
  158. called from somewhere other than a handle() method in GUIEventHandler. Application
  159. must be aware of implications.
  160. */
  161. virtual void home(double /*currentTime*/) {}
  162.  
  163. /**
  164. Start/restart the manipulator.
  165. */
  166. virtual void init(const GUIEventAdapter& ,GUIActionAdapter&) {}
  167.  
  168. /** Handle event. Override the handle(..) method in your event handlers to respond to events. */
  169. virtual bool handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv) { return GUIEventHandler::handle(event, object, nv); }
  170.  
  171. /** Handle events, return true if handled, false otherwise. */
  172. virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
  173.  
  174. protected:
  175.  
  176. CameraManipulator();
  177. CameraManipulator(const CameraManipulator& mm, const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY);
  178.  
  179. virtual ~CameraManipulator();
  180.  
  181. std::string getManipulatorName() const;
  182.  
  183. unsigned int _intersectTraversalMask;
  184.  
  185. bool _autoComputeHomePosition;
  186.  
  187. osg::Vec3d _homeEye;
  188. osg::Vec3d _homeCenter;
  189. osg::Vec3d _homeUp;
  190.  
  191. osg::ref_ptr<CoordinateFrameCallback> _coordinateFrameCallback;
  192.  
  193. };
  194.  
  195. }
  196.  
  197. #endif

osgGA::StandardManipulator

  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. *
  13. * StandardManipulator code Copyright (C) 2010 PCJohn (Jan Peciva)
  14. * while some pieces of code were taken from OSG.
  15. * Thanks to company Cadwork (www.cadwork.ch) and
  16. * Brno University of Technology (www.fit.vutbr.cz) for open-sourcing this work.
  17. */
  18.  
  19. #ifndef OSGGA_CAMERA_MANIPULATOR
  20. #define OSGGA_CAMERA_MANIPULATOR 1
  21.  
  22. #include <osgGA/CameraManipulator>
  23.  
  24. namespace osgGA {
  25.  
  26. /** StandardManipulator class provides basic functionality
  27. for user controlled manipulation.*/
  28. class OSGGA_EXPORT StandardManipulator : public CameraManipulator
  29. {
  30. typedef CameraManipulator inherited;
  31.  
  32. public:
  33.  
  34. // flags
  35. enum UserInteractionFlags
  36. {
  37. UPDATE_MODEL_SIZE = 0x01,
  38. COMPUTE_HOME_USING_BBOX = 0x02,
  39. PROCESS_MOUSE_WHEEL = 0x04,
  40. SET_CENTER_ON_WHEEL_FORWARD_MOVEMENT = 0x08,
  41. DEFAULT_SETTINGS = UPDATE_MODEL_SIZE /*| COMPUTE_HOME_USING_BBOX*/ | PROCESS_MOUSE_WHEEL
  42. };
  43.  
  44. StandardManipulator( int flags = DEFAULT_SETTINGS );
  45. StandardManipulator( const StandardManipulator& m,
  46. const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
  47.  
  48. // We are not using META_Object as this is abstract class.
  49. // Use META_Object(osgGA,YourManipulator); in your descendant non-abstract classes.
  50. virtual const char* className() const { return "StandardManipulator"; }
  51.  
  52. /** Sets manipulator by eye position and eye orientation.*/
  53. virtual void setTransformation( const osg::Vec3d& eye, const osg::Quat& rotation ) = ;
  54.  
  55. /** Sets manipulator by eye position, center of rotation, and up vector.*/
  56. virtual void setTransformation( const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up ) = ;
  57.  
  58. /** Gets manipulator's eye position and eye orientation.*/
  59. virtual void getTransformation( osg::Vec3d& eye, osg::Quat& rotation ) const = ;
  60.  
  61. /** Gets manipulator's focal center, eye position, and up vector.*/
  62. virtual void getTransformation( osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up ) const = ;
  63.  
  64. virtual void setNode( osg::Node* );
  65. virtual const osg::Node* getNode() const;
  66. virtual osg::Node* getNode();
  67.  
  68. virtual void setVerticalAxisFixed( bool value );
  69. inline bool getVerticalAxisFixed() const;
  70. inline bool getAllowThrow() const;
  71. virtual void setAllowThrow( bool allowThrow );
  72.  
  73. virtual void setAnimationTime( const double t );
  74. double getAnimationTime() const;
  75. bool isAnimating() const;
  76. virtual void finishAnimation();
  77.  
  78. virtual void home( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  79. virtual void home( double );
  80.  
  81. virtual void init( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  82. virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  83. virtual void getUsage( osg::ApplicationUsage& usage ) const;
  84.  
  85. protected:
  86.  
  87. virtual bool handleFrame( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  88. virtual bool handleResize( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  89. virtual bool handleMouseMove( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  90. virtual bool handleMouseDrag( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  91. virtual bool handleMousePush( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  92. virtual bool handleMouseRelease( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  93. virtual bool handleKeyDown( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  94. virtual bool handleKeyUp( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  95. virtual bool handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  96. virtual bool handleMouseDeltaMovement( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  97.  
  98. virtual bool performMovement();
  99. virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
  100. virtual bool performMovementMiddleMouseButton( const double eventTimeDelta, const double dx, const double dy );
  101. virtual bool performMovementRightMouseButton( const double eventTimeDelta, const double dx, const double dy );
  102. virtual bool performMouseDeltaMovement( const float dx, const float dy );
  103. virtual bool performAnimationMovement( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  104. virtual void applyAnimationStep( const double currentProgress, const double prevProgress );
  105.  
  106. void addMouseEvent( const osgGA::GUIEventAdapter& ea );
  107. void flushMouseEventStack();
  108. virtual bool isMouseMoving() const;
  109. float getThrowScale( const double eventTimeDelta ) const;
  110. virtual void centerMousePointer( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  111.  
  112. static void rotateYawPitch( osg::Quat& rotation, const double yaw, const double pitch,
  113. const osg::Vec3d& localUp = osg::Vec3d( .,.,.) );
  114. static void fixVerticalAxis( osg::Quat& rotation, const osg::Vec3d& localUp, bool disallowFlipOver );
  115. void fixVerticalAxis( osg::Vec3d& eye, osg::Quat& rotation, bool disallowFlipOver );
  116. static void fixVerticalAxis( const osg::Vec3d& forward, const osg::Vec3d& up, osg::Vec3d& newUp,
  117. const osg::Vec3d& localUp, bool disallowFlipOver );
  118. virtual bool setCenterByMousePointerIntersection( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  119. virtual bool startAnimationByMousePointerIntersection( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  120.  
  121. // mouse state
  122. bool _thrown;
  123. bool _allowThrow;
  124. float _mouseCenterX, _mouseCenterY;
  125.  
  126. // internal event stack comprising last two mouse events.
  127. osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t1;
  128. osg::ref_ptr< const osgGA::GUIEventAdapter > _ga_t0;
  129.  
  130. /** The approximate amount of time it is currently taking to draw a frame.
  131. * This is used to compute the delta in translation/rotation during a thrown display update.
  132. * It allows us to match an delta in position/rotation independent of the rendering frame rate.
  133. */
  134. double _delta_frame_time;
  135.  
  136. /** The time the last frame started.
  137. * Used when _rate_sensitive is true so that we can match display update rate to rotation/translation rate.
  138. */
  139. double _last_frame_time;
  140.  
  141. // scene data
  142. osg::ref_ptr< osg::Node > _node;
  143. double _modelSize;
  144. bool _verticalAxisFixed;
  145.  
  146. // animation stuff
  147. class OSGGA_EXPORT AnimationData : public osg::Referenced {
  148. public:
  149. double _animationTime;
  150. bool _isAnimating;
  151. double _startTime;
  152. double _phase;
  153.  
  154. AnimationData();
  155. void start( const double startTime );
  156. };
  157. osg::ref_ptr< AnimationData > _animationData;
  158. virtual void allocAnimationData() { _animationData = new AnimationData(); }
  159.  
  160. // flags
  161. int _flags;
  162.  
  163. // flags indicating that a value is relative to model size
  164. int _relativeFlags;
  165. inline bool getRelativeFlag( int index ) const;
  166. inline void setRelativeFlag( int index, bool value );
  167. static int numRelativeFlagsAllocated;
  168. static int allocateRelativeFlag();
  169. };
  170.  
  171. //
  172. // inline methods
  173. //
  174.  
  175. inline bool StandardManipulator::getRelativeFlag( int index ) const
  176. {
  177. return ( _relativeFlags & (0x01 << index) ) != ;
  178. }
  179.  
  180. inline void StandardManipulator::setRelativeFlag( int index, bool value )
  181. {
  182. if( value ) _relativeFlags |= (0x01 << index);
  183. else _relativeFlags &= ~(0x01 << index);
  184. }
  185.  
  186. /// Returns whether manipulator preserves camera's "UP" vector.
  187. inline bool StandardManipulator::getVerticalAxisFixed() const
  188. {
  189. return _verticalAxisFixed;
  190. }
  191.  
  192. /// Returns true if the camera can be thrown, false otherwise. It defaults to true.
  193. inline bool StandardManipulator::getAllowThrow() const
  194. {
  195. return _allowThrow;
  196. }
  197.  
  198. }
  199.  
  200. #endif /* OSGGA_CAMERA_MANIPULATOR */

osgGA::OrbitManipulator

  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. *
  13. * OrbitManipulator code Copyright (C) 2010 PCJohn (Jan Peciva)
  14. * while some pieces of code were taken from OSG.
  15. * Thanks to company Cadwork (www.cadwork.ch) and
  16. * Brno University of Technology (www.fit.vutbr.cz) for open-sourcing this work.
  17. */
  18.  
  19. #ifndef OSGGA_ORBIT_MANIPULATOR
  20. #define OSGGA_ORBIT_MANIPULATOR 1
  21.  
  22. #include <osgGA/StandardManipulator>
  23.  
  24. namespace osgGA {
  25.  
  26. /** OrbitManipulator is base class for camera control based on focal center,
  27. distance from the center, and orientation of distance vector to the eye.
  28. This is the base class for trackball style manipulators.*/
  29. class OSGGA_EXPORT OrbitManipulator : public StandardManipulator
  30. {
  31. typedef StandardManipulator inherited;
  32.  
  33. public:
  34.  
  35. OrbitManipulator( int flags = DEFAULT_SETTINGS );
  36. OrbitManipulator( const OrbitManipulator& om,
  37. const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
  38.  
  39. META_Object( osgGA, OrbitManipulator );
  40.  
  41. virtual void setByMatrix( const osg::Matrixd& matrix );
  42. virtual void setByInverseMatrix( const osg::Matrixd& matrix );
  43. virtual osg::Matrixd getMatrix() const;
  44. virtual osg::Matrixd getInverseMatrix() const;
  45.  
  46. virtual void setTransformation( const osg::Vec3d& eye, const osg::Quat& rotation );
  47. virtual void setTransformation( const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up );
  48. virtual void getTransformation( osg::Vec3d& eye, osg::Quat& rotation ) const;
  49. virtual void getTransformation( osg::Vec3d& eye, osg::Vec3d& center, osg::Vec3d& up ) const;
  50.  
  51. void setHeading( double azimuth );
  52. double getHeading() const;
  53. void setElevation( double elevation );
  54. double getElevation() const;
  55.  
  56. virtual void setCenter( const osg::Vec3d& center );
  57. const osg::Vec3d& getCenter() const;
  58. virtual void setRotation( const osg::Quat& rotation );
  59. const osg::Quat& getRotation() const;
  60. virtual void setDistance( double distance );
  61. double getDistance() const;
  62.  
  63. virtual void setTrackballSize( const double& size );
  64. inline double getTrackballSize() const;
  65. virtual void setWheelZoomFactor( double wheelZoomFactor );
  66. inline double getWheelZoomFactor() const;
  67.  
  68. virtual void setMinimumDistance( const double& minimumDistance, bool relativeToModelSize = false );
  69. double getMinimumDistance( bool *relativeToModelSize = NULL ) const;
  70.  
  71. virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const;
  72. virtual float getFusionDistanceValue() const;
  73.  
  74. protected:
  75.  
  76. virtual bool handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  77.  
  78. virtual bool performMovementLeftMouseButton( const double eventTimeDelta, const double dx, const double dy );
  79. virtual bool performMovementMiddleMouseButton( const double eventTimeDelta, const double dx, const double dy );
  80. virtual bool performMovementRightMouseButton( const double eventTimeDelta, const double dx, const double dy );
  81. virtual bool performMouseDeltaMovement( const float dx, const float dy );
  82. virtual void applyAnimationStep( const double currentProgress, const double prevProgress );
  83.  
  84. virtual void rotateTrackball( const float px0, const float py0,
  85. const float px1, const float py1, const float scale );
  86. virtual void rotateWithFixedVertical( const float dx, const float dy );
  87. virtual void rotateWithFixedVertical( const float dx, const float dy, const osg::Vec3f& up );
  88. virtual void panModel( const float dx, const float dy, const float dz = .f );
  89. virtual void zoomModel( const float dy, bool pushForwardIfNeeded = true );
  90. void trackball( osg::Vec3d& axis, float& angle, float p1x, float p1y, float p2x, float p2y );
  91. float tb_project_to_sphere( float r, float x, float y );
  92. virtual bool startAnimationByMousePointerIntersection( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
  93.  
  94. osg::Vec3d _center;
  95. osg::Quat _rotation;
  96. double _distance;
  97.  
  98. double _trackballSize;
  99. double _wheelZoomFactor;
  100.  
  101. double _minimumDistance;
  102. static int _minimumDistanceFlagIndex;
  103.  
  104. class OrbitAnimationData : public AnimationData {
  105. public:
  106. osg::Vec3d _movement;
  107. void start( const osg::Vec3d& movement, const double startTime );
  108. };
  109. virtual void allocAnimationData() { _animationData = new OrbitAnimationData(); }
  110. };
  111.  
  112. //
  113. // inline functions
  114. //
  115.  
  116. /** Get the size of the trackball relative to the model size. */
  117. inline double OrbitManipulator::getTrackballSize() const { return _trackballSize; }
  118. /** Get the mouse wheel zoom factor.*/
  119. inline double OrbitManipulator::getWheelZoomFactor() const { return _wheelZoomFactor; }
  120.  
  121. }
  122.  
  123. #endif /* OSGGA_ORBIT_MANIPULATOR */

osgGA::TrackballManipulator

  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13.  
  14. #ifndef OSGGA_TRACKBALL_MANIPULATOR
  15. #define OSGGA_TRACKBALL_MANIPULATOR 1
  16.  
  17. #include <osgGA/OrbitManipulator>
  18.  
  19. namespace osgGA {
  20.  
  21. class OSGGA_EXPORT TrackballManipulator : public OrbitManipulator
  22. {
  23. typedef OrbitManipulator inherited;
  24.  
  25. public:
  26.  
  27. TrackballManipulator( int flags = DEFAULT_SETTINGS );
  28. TrackballManipulator( const TrackballManipulator& tm,
  29. const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY );
  30.  
  31. META_Object( osgGA, TrackballManipulator );
  32.  
  33. };
  34.  
  35. }
  36.  
  37. #endif /* OSGGA_TRACKBALL_MANIPULATOR */

osg MatrixManipulator CameraManipulator的更多相关文章

  1. [OSG]OpenSceneGraph FAQ 以及OSG资源

    1.地球背面的一个点,计算它在屏幕上的坐标,能得到吗? 不是被挡住了吗? 答:计算一个空间点的屏幕坐标,使用osgAPEx::GetScreenPosition函数.当空间点处于相机视空间内(不管它是 ...

  2. osg设置相机参数,包括初始位置

    严重注意!!!以下设置必须在viewer.realize();之后,否则不起作用!!!! 设置相机的位置,可以通过CameraManipulator(一般是osgGA::TrackballManipu ...

  3. osg中的视点控制

    osg中的视点控制 osg的视点控制基类是CameraManipulator, 它是一个虚基类, 有用的方法都跟home有关. 在这个类里面有三个重要的成员变量: osg::Vec3d _homeEy ...

  4. osg实例介绍

    osg实例介绍 转自:http://blog.csdn.net/yungis/article/list/1 [原]osgmotionblur例子 该例子演示了运动模糊的效果.一下内容是转自网上的:原理 ...

  5. OSG开发概览

    1 OSG基础知识 Ø OSG是Open Scene Graphic 的缩写,OSG于1997年诞生于以为滑翔机爱好者之手,Don burns  为了对滑翔机的飞行进行模拟,对openGL的库进行了封 ...

  6. OSG 实现跟随节点的相机(转)

      本章教程将继续使用回调和节点路径(NodePath)来检索节点的世界坐标. 本章目标: 在一个典型的仿真过程中,用户可能需要从场景中的各种车辆和人物里选择一个进行跟随.本章将介绍一种将摄像机“依附 ...

  7. OSG实现场景漫游(转载)

    OSG实现场景漫游 下面的代码将可以实现场景模型的导入,然后在里面任意行走,于此同时还实现了碰撞检测. 源代码下载地址: /* * File : Travel.cpp * Description : ...

  8. OSG开发概览(转载)

    OSG开发概览 1 OSG基础知识 Ø OSG是Open Scene Graphic 的缩写,OSG于1997年诞生于以为滑翔机爱好者之手,Don burns  为了对滑翔机的飞行进行模拟,对open ...

  9. OSG开源教程(转)

    例:geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4)); 来指定要利用这些数据生成一个怎么样的形状. ...

随机推荐

  1. Nginx服务优化及优化深入(配置网页缓存时间、日志切割、防盗链等等)

    原文:https://blog.51cto.com/11134648/2134389 默认的Nginx安装参数只能提供最基本的服务,还需要调整如网页缓存时间.连接超时.网页压缩等相应参数,才能发挥出服 ...

  2. selenium xpath定位方式整理

    #xpath定位元素方法: /html/body/div[2] #绝对路径定位 #相对路径定位元素 //* #找到所有的元素 //input #找到input元素 //*[@*] #表示有属性的所有元 ...

  3. 前端知识总结--html

    1.  doctype的作用是什么? <!DOCTYPE> 声明必须是 HTML 文档的第一行,位于 <html> 标签之前. <!DOCTYPE> 声明不是 HT ...

  4. Vmware Pro 14报错:无法连接 MKS: 套接字连接尝试次数太多;正在放弃。

    软件环境: 虚拟机软件:VMware Pro 14 母机操作系统:win7 客户机操作系统:CentOS 7     问题详情: 报错:无法连接 MKS: 套接字连接尝试次数太多:正在放弃.     ...

  5. Nginx入门(四)——反向代理

    server { listen 8020; server_name localhost; location / { root html; index index.html index.htm; pro ...

  6. python基础--文件控制

    读写文件是最常见的IO操作.Python内置了读写文件的函数,用法和C是兼容的. 读写文件前,我们先必须了解一下,在磁盘上读写文件的功能都是由操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘, ...

  7. C语言入坑指南-缓冲区溢出

    前言 缓冲区溢出通常指的是向缓冲区写入了超过缓冲区所能保存的最大数据量的数据.如果说之前所提到的一些问题可能只是影响部分功能的实现,那么缓冲区溢出将可能会造成程序运行终止,被不安全代码攻击等严重问题, ...

  8. 二十七. Keepalived热备 Keepalived+LVS 、 HAProxy服务器

    1.Keepalived高可用服务器 proxy:192.168.4.5(客户端主机) web1:192.168.4.100(Web服务器,部署Keepalived高可用软件) web2:192.16 ...

  9. The backup set holds a backup of a database other than the existing ‘dbName’ database

     [Solved] System.Data.SqlClient.SqlError: The backup set holds a backup of a database other than t ...

  10. Linux Swap是干嘛的?

    swap是干嘛的? 在Linux下,SWAP的作用类似Windows系统下的“虚拟内存”.当物理内存不足时,拿出部分硬盘空间当SWAP分区(虚拟成内存)使用,从而解决内存容量不足的情况. SWAP意思 ...