AnimatLab  2
Test
OsgCameraManipulator.h
1 #pragma once
2 
3 namespace OsgAnimatSim
4 {
5  namespace Visualization
6  {
7 
8  class OsgCameraManipulator : public osgGA::TrackballManipulator
9  {
10  private:
11  bool m_bShiftDown;
12  bool m_bControlDown;
13  bool m_bInDrag;
14 
15  float m_fltPrevX;
16  float m_fltPrevY;
17 
18  Simulator *m_lpSim;
19  OsgSimulator *m_lpOsgSim;
20 
21  osg::Vec3 m_vPickPoint;
22  osg::Vec3 m_vPickNormal;
23  MovableItem *m_lpPicked;
24  osg::Vec3 m_vSelectedVertex;
25 
26  osg::Quat m_quatRotation;
27  osg::Vec3 m_v3Eye;
28 
29  osg::ref_ptr<osgViewer::Viewer> m_osgViewer;
30  osg::ref_ptr<osg::Viewport> m_osgViewport;
31 
32  virtual const osg::Camera *GetCamera(float x, float y, float &local_x, float &local_y);
33  virtual const osg::Camera *GetCamera(float x, float y);
34 
35  virtual osg::Vec3 FindSelectedVertex(osgUtil::LineSegmentIntersector::Intersections::iterator &hitr);
36 
37  protected:
38  bool CanDoMouseSpring();
39  bool DoMouseSpring(const GUIEventAdapter& ea, float x, float y);
40  void DoPan(const GUIEventAdapter& ea, float x, float y);
41  void DoZoom(const GUIEventAdapter& ea, float x, float y);
42  void DoRotate(const GUIEventAdapter& ea, float x, float y);
43 
44  osg::Vec3 ConvertMouseTo3D(const GUIEventAdapter& ea, int x, int y, osg::Vec3 vGrabPos);
45 
46  void pick(const osgGA::GUIEventAdapter& ea, GUIActionAdapter& aa);
47  float tb_project_to_sphere(float r, float x, float y);
48 
49  public:
50  OsgCameraManipulator(Simulator *lpSim, osgViewer::Viewer *osgViewer, osg::Viewport *osgViewport = NULL);
51  ~OsgCameraManipulator(void);
52 
54  virtual bool handle(const GUIEventAdapter& ea,GUIActionAdapter& us);
55 
56  };
57 
58  }// end Visualization
59 }// end OsgAnimatSim
60 
Classes for implementing the cm-labs vortex physics engine for AnimatLab.
virtual bool handle(const GUIEventAdapter &ea, GUIActionAdapter &us)