root/OpenSceneGraph/trunk/examples/osgimpostor/TestManipulator.h @ 2235

Revision 2235, 3.1 kB (checked in by robert, 11 years ago)

Added new Matrixf and Matrixd implementations.

Made Matrix be a typedef to either Matrixf or Matrixd. Defaults to Matrixf.

Converted the osgGA::MatrixManipulators? and osgProducer::Viewer/OsgCameraGroup
across to using exclusively Matrixd for internal computations and passing betwen
Manipulators, Producer and SceneView?. Note, SceneView? still uses Matrix internally
so will depend on what is set as the default in include/osg/Matrix.

Added the ability to osgProducer::setDone/getDone(), kept done() as the
method that the viewer main loop uses for detecting the exit condition.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
2//Distributed under the terms of the GNU Library General Public License (LGPL)
3//as published by the Free Software Foundation.
4
5#ifndef OSGGA_TESTMANIPULATOR
6#define OSGGA_TESTMANIPULATOR 1
7
8#include <osgGA/MatrixManipulator>
9#include <osg/Quat>
10
11class TestManipulator : public osgGA::MatrixManipulator
12{
13    public:
14
15        TestManipulator();
16        virtual ~TestManipulator();
17
18        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
19        virtual void setByMatrix(const osg::Matrixd& matrix);
20
21        /** set the position of the matrix manipulator using a 4x4 Matrix.*/
22        virtual void setByInverseMatrix(const osg::Matrixd& matrix) { setByMatrix(osg::Matrixd::inverse(matrix)); }
23
24        /** get the position of the manipulator as 4x4 Matrix.*/
25        virtual osg::Matrixd getMatrix() const;
26
27        /** get the position of the manipulator as a inverse matrix of the manipulator, typically used as a model view matrix.*/
28        virtual osg::Matrixd getInverseMatrix() const;
29
30        /** Attach a node to the manipulator.
31            Automatically detaches previously attached node.
32            setNode(NULL) detaches previously nodes.
33            Is ignored by manipulators which do not require a reference model.*/
34        virtual void setNode(osg::Node*);
35
36        /** Return node if attached.*/
37        virtual const osg::Node* getNode() const;
38
39        /** Return node if attached.*/
40        virtual osg::Node* getNode();
41
42        /** Move the camera to the default position.
43            May be ignored by manipulators if home functionality is not appropriate.*/
44        virtual void home(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
45       
46        /** Start/restart the manipulator.*/
47        virtual void init(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
48
49
50        /** handle events, return true if handled, false otherwise.*/
51        virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& us);
52
53    private:
54
55        /** Reset the internal GUIEvent stack.*/
56        void flushMouseEventStack();
57        /** Add the current mouse GUIEvent to internal stack.*/
58        void addMouseEvent(const osgGA::GUIEventAdapter& ea);
59
60        void computePosition(const osg::Vec3& eye,const osg::Vec3& lv,const osg::Vec3& up);
61
62        /** For the give mouse movement calculate the movement of the camera.
63            Return true is camera has moved and a redraw is required.*/
64        bool calcMovement();
65       
66        /** Check the speed at which the mouse is moving.
67            If speed is below a threshold then return false, otherwise return true.*/
68        bool isMouseMoving();
69
70        // Internal event stack comprising last three mouse events.
71        osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t1;
72        osg::ref_ptr<const osgGA::GUIEventAdapter> _ga_t0;
73
74        osg::ref_ptr<osg::Node>       _node;
75
76        float _modelScale;
77        float _minimumZoomScale;
78
79        bool _thrown;
80       
81        osg::Vec3   _center;
82        osg::Quat   _rotation;
83        float       _distance;
84
85};
86
87#endif
Note: See TracBrowser for help on using the browser.