1 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer |
---|
2 | * |
---|
3 | * This library is based on OpenSceneGraph, 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 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
9 | * You have to aquire licenses for all used proprietary modules. |
---|
10 | * |
---|
11 | * This library is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * OpenSceneGraph Public License for more details. |
---|
15 | */ |
---|
16 | |
---|
17 | #include <osg/Node> |
---|
18 | #include <osg/Notify> |
---|
19 | #include <osg/ArgumentParser> |
---|
20 | #include <osgViewer/Viewer> |
---|
21 | |
---|
22 | #include <visual_dataIO.h> |
---|
23 | |
---|
24 | // OSG Eventhandler |
---|
25 | #include <osgViewer/ViewerEventHandlers> |
---|
26 | |
---|
27 | // OSG manipulator |
---|
28 | #include <osgGA/TrackballManipulator> |
---|
29 | #include <osgGA/FlightManipulator> |
---|
30 | #include <osgGA/DriveManipulator> |
---|
31 | #include <osgGA/KeySwitchMatrixManipulator> |
---|
32 | #include <osgGA/StateSetManipulator> |
---|
33 | #include <osgGA/AnimationPathManipulator> |
---|
34 | #include <osgGA/TerrainManipulator> |
---|
35 | #include <osgGA/NodeTrackerManipulator> |
---|
36 | |
---|
37 | // Spacenavigator manipulator |
---|
38 | #ifdef USE_SPACENAVIGATOR |
---|
39 | #include <manip_spaceMouse.h> |
---|
40 | #include <manip_nodeTrackerSpaceMouse.h> |
---|
41 | #include <manip_freeSpaceMouse.h> |
---|
42 | #endif |
---|
43 | |
---|
44 | // Object mounted manipulator |
---|
45 | #include <manip_objectMounted.h> |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | namespace osgVisual |
---|
51 | { |
---|
52 | |
---|
53 | class core_manipulator : public osg::Node |
---|
54 | { |
---|
55 | #include <leakDetection.h> |
---|
56 | public: |
---|
57 | core_manipulator(); |
---|
58 | ~core_manipulator(){}; |
---|
59 | |
---|
60 | bool init(osgViewer::Viewer* viewer, osg::ArgumentParser& arguments, std::string configFilename, osg::Node* rootNode); |
---|
61 | void shutdown(); |
---|
62 | void trackNode( osg::Node* node_ ); |
---|
63 | void trackNode( int trackingID ); |
---|
64 | int getCurrentTrackingID(){return _currentTrackingID;}; |
---|
65 | void setTrackingIdUpdaterSlot(std::string updaterSlot){_updaterSlot=updaterSlot;}; |
---|
66 | std::string getTrackingIdUpdaterSlot(){return _updaterSlot;}; |
---|
67 | |
---|
68 | private: |
---|
69 | class core_manipulatorCallback : public osg::NodeCallback |
---|
70 | { |
---|
71 | public: |
---|
72 | /** |
---|
73 | * \brief Constructor, for setting the member variables. |
---|
74 | * |
---|
75 | * @param manipulators : Pointer to the manipulator and tracking class. |
---|
76 | */ |
---|
77 | core_manipulatorCallback(core_manipulator* manipulators):_manipulators(manipulators){}; |
---|
78 | |
---|
79 | /** |
---|
80 | * \brief This function is executed as callback during event traversal. |
---|
81 | * |
---|
82 | */ |
---|
83 | virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); |
---|
84 | private: |
---|
85 | /** Pointer to the manipulator class to edit its value */ |
---|
86 | core_manipulator* _manipulators; |
---|
87 | }; |
---|
88 | |
---|
89 | /** Pointer to the callback isntalled to update the tracking ID */ |
---|
90 | osg::ref_ptr<core_manipulatorCallback> _callback; |
---|
91 | |
---|
92 | /** core_manipulatorCallback must be a freind of this class to allow the callback to edit the member values of this class directly */ |
---|
93 | friend class core_manipulatorCallback; |
---|
94 | |
---|
95 | #ifdef USE_SPACENAVIGATOR |
---|
96 | /** |
---|
97 | * Spacemouse node tracker manipulator |
---|
98 | */ |
---|
99 | osg::ref_ptr<NodeTrackerSpaceMouse> _mouseTrackerManip; |
---|
100 | |
---|
101 | /** |
---|
102 | * Space mouse hardware driver instance |
---|
103 | */ |
---|
104 | SpaceMouse* _mouse; |
---|
105 | #endif |
---|
106 | |
---|
107 | /** |
---|
108 | * This Matrix manipulator is used for controlling Camera by Nodes. |
---|
109 | */ |
---|
110 | osg::ref_ptr<objectMountedManipulator> _objectMountedCameraManip; |
---|
111 | |
---|
112 | /** |
---|
113 | * Classical OSG NodeTrackerManipulator |
---|
114 | */ |
---|
115 | osg::ref_ptr<osgGA::NodeTrackerManipulator> _nt; |
---|
116 | |
---|
117 | /** |
---|
118 | * ID of the currently tracked ID |
---|
119 | */ |
---|
120 | int _currentTrackingID; |
---|
121 | |
---|
122 | /** Slotname to use for dynamic updated tracking ID. */ |
---|
123 | std::string _updaterSlot; |
---|
124 | |
---|
125 | /** |
---|
126 | * Pointer to the scene root node |
---|
127 | */ |
---|
128 | osg::ref_ptr<osg::Node> _rootNode; |
---|
129 | |
---|
130 | /** |
---|
131 | * Referenced pointer to the applications viewer. |
---|
132 | */ |
---|
133 | osg::ref_ptr<osgViewer::Viewer> _viewer; |
---|
134 | }; |
---|
135 | |
---|
136 | } // END NAMESPACE |
---|