Cursor 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifndef OSGPRESENTATION_CURSOR
  14. #define OSGPRESENTATION_CURSOR 1
  15. #include <osg/AutoTransform>
  16. #include <osg/Camera>
  17. #include <osgPresentation/Export>
  18. namespace osgPresentation {
  19. class OSGPRESENTATION_EXPORT Cursor : public osg::Group
  20. {
  21. public:
  22. Cursor();
  23. Cursor(const std::string& filename, float size);
  24. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  25. Cursor(const Cursor& rhs,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  26. META_Node(osgPresentation, Cursor)
  27. void setFilename(const std::string& filename) { _filename = filename; _cursorDirty=true; }
  28. const std::string& getFilename() const { return _filename; }
  29. void setSize(float size) { _size = size; _cursorDirty=true; }
  30. float getSize() const { return _size; }
  31. virtual void traverse(osg::NodeVisitor& nv);
  32. protected:
  33. virtual ~Cursor();
  34. void initializeCursor();
  35. void updatePosition();
  36. std::string _filename;
  37. float _size;
  38. bool _cursorDirty;
  39. osg::ref_ptr<osg::AutoTransform> _transform;
  40. osg::Vec2 _cursorXY;
  41. osg::observer_ptr<osg::Camera> _camera;
  42. };
  43. }
  44. #endif