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