[32] | 1 | #pragma once |
---|
| 2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
| 3 | * |
---|
| 4 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
| 5 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
| 6 | * (at your option) any later version. The full license is in LICENSE file |
---|
| 7 | * included with this distribution, and on the openscenegraph.org website. |
---|
| 8 | * |
---|
| 9 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
| 10 | * You have to aquire licenses for all used proprietary modules. |
---|
| 11 | * |
---|
| 12 | * This library is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | * OpenSceneGraph Public License for more details. |
---|
| 16 | */ |
---|
| 17 | |
---|
[125] | 18 | // XML Parser |
---|
| 19 | #include <stdio.h> |
---|
| 20 | #include <libxml/parser.h> |
---|
| 21 | #include <libxml/tree.h> |
---|
| 22 | |
---|
| 23 | |
---|
[32] | 24 | #include <osg/Referenced> |
---|
[97] | 25 | #include <osg/Notify> |
---|
[32] | 26 | |
---|
| 27 | #include <osgViewer/Viewer> |
---|
| 28 | |
---|
| 29 | #include <osgDB/ReadFile> |
---|
| 30 | |
---|
| 31 | // OSG eventhandler |
---|
| 32 | #include <osgViewer/ViewerEventHandlers> |
---|
| 33 | |
---|
| 34 | // OSG manipulator |
---|
| 35 | #include <osgGA/TrackballManipulator> |
---|
| 36 | #include <osgGA/FlightManipulator> |
---|
| 37 | #include <osgGA/DriveManipulator> |
---|
| 38 | #include <osgGA/KeySwitchMatrixManipulator> |
---|
| 39 | #include <osgGA/StateSetManipulator> |
---|
| 40 | #include <osgGA/AnimationPathManipulator> |
---|
| 41 | #include <osgGA/TerrainManipulator> |
---|
| 42 | #include <osgGA/NodeTrackerManipulator> |
---|
| 43 | |
---|
| 44 | // Spacenavigator manipulator |
---|
| 45 | #ifdef USE_SPACENAVIGATOR |
---|
| 46 | #include <manip_spaceMouse.h> |
---|
| 47 | #include <manip_nodeTrackerSpaceMouse.h> |
---|
| 48 | #include <manip_freeSpaceMouse.h> |
---|
| 49 | #endif |
---|
| 50 | |
---|
| 51 | // Object mounted manipulator |
---|
| 52 | #include <manip_objectMounted.h> |
---|
| 53 | |
---|
| 54 | #ifdef USE_DISTORTION |
---|
| 55 | // Distortion |
---|
| 56 | #include <visual_distortion.h> |
---|
| 57 | #endif |
---|
| 58 | |
---|
| 59 | #ifdef USE_SKY_SILVERLINING |
---|
| 60 | // Sky |
---|
[98] | 61 | #include <visual_skySilverLining.h> |
---|
[32] | 62 | #endif |
---|
| 63 | |
---|
| 64 | // DataIO |
---|
| 65 | #include <visual_dataIO.h> |
---|
| 66 | #include <object_updater.h> |
---|
| 67 | |
---|
| 68 | // visual_object |
---|
| 69 | #include <visual_object.h> |
---|
| 70 | |
---|
| 71 | // visual_hud |
---|
| 72 | #include <visual_hud.h> |
---|
| 73 | #include <visual_debug_hud.h> |
---|
| 74 | |
---|
| 75 | // visual_draw2D |
---|
| 76 | #include <visual_draw2D.h> |
---|
| 77 | #include <visual_draw3D.h> |
---|
| 78 | |
---|
| 79 | // visual util |
---|
| 80 | #include <visual_util.h> |
---|
| 81 | |
---|
| 82 | // visual_vista2D |
---|
| 83 | #ifdef USE_VISTA2D |
---|
| 84 | #include <visual_vista2D.h> |
---|
| 85 | #endif |
---|
| 86 | |
---|
| 87 | // Test |
---|
| 88 | #include <dataIO_transportContainer.h> |
---|
| 89 | #include <osgDB/OutputStream> |
---|
| 90 | #include <iostream> |
---|
| 91 | |
---|
| 92 | |
---|
| 93 | |
---|
[57] | 94 | |
---|
[32] | 95 | namespace osgVisual |
---|
| 96 | { |
---|
| 97 | |
---|
| 98 | class visual_core : public osg::Referenced |
---|
| 99 | { |
---|
[88] | 100 | #include <leakDetection.h> |
---|
| 101 | |
---|
[32] | 102 | public: |
---|
| 103 | visual_core(osg::ArgumentParser& arguments_); |
---|
| 104 | void initialize(); |
---|
| 105 | void shutdown(); |
---|
| 106 | |
---|
| 107 | void addManipulators(); |
---|
[125] | 108 | void parseConfigFile(osg::ArgumentParser& arguments_); |
---|
| 109 | void checkXMLNode(xmlNode * a_node); |
---|
[127] | 110 | void parseModule(xmlNode * a_node); |
---|
[125] | 111 | void parseScenery(xmlNode * a_node); |
---|
[129] | 112 | void config(xmlNode * a_node); |
---|
[32] | 113 | bool loadTerrain(osg::ArgumentParser& arguments_); |
---|
| 114 | bool checkCommandlineArgumentsForFinalErrors(); |
---|
| 115 | |
---|
| 116 | void setupScenery(); |
---|
| 117 | |
---|
| 118 | protected: |
---|
| 119 | virtual ~visual_core(void); |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | private: |
---|
| 123 | void mainLoop(); |
---|
| 124 | |
---|
| 125 | /** |
---|
| 126 | * Argument object, with contains all commandline arguments, which where called during programm sstartup |
---|
| 127 | */ |
---|
| 128 | osg::ArgumentParser& arguments; |
---|
| 129 | |
---|
| 130 | /** |
---|
| 131 | * This CSN is at the top node on the complete scenery. Only the nodes for distortion are located above this node. |
---|
| 132 | */ |
---|
| 133 | osg::ref_ptr<osg::CoordinateSystemNode> rootNode; |
---|
| 134 | |
---|
| 135 | /** |
---|
| 136 | * Reference pointer to the viewer instance. The viewer is the core of the graphical subsystem. |
---|
| 137 | */ |
---|
| 138 | osg::ref_ptr<osgViewer::Viewer> viewer; |
---|
| 139 | |
---|
[125] | 140 | /** |
---|
[144] | 141 | * XML configuration filename. |
---|
[125] | 142 | */ |
---|
[144] | 143 | std::string configFilename; |
---|
[125] | 144 | |
---|
[144] | 145 | |
---|
[32] | 146 | #ifdef USE_SPACENAVIGATOR |
---|
| 147 | /** |
---|
| 148 | * Spacemouse node tracker manipulator |
---|
| 149 | */ |
---|
| 150 | osg::ref_ptr<NodeTrackerSpaceMouse> mouseTrackerManip; |
---|
[55] | 151 | |
---|
| 152 | /** |
---|
| 153 | * Space mouse hardware driver instance |
---|
| 154 | */ |
---|
| 155 | SpaceMouse* mouse; |
---|
[32] | 156 | #endif |
---|
| 157 | |
---|
| 158 | /** |
---|
| 159 | * This Matrix manipulator is used for controlling Camera by Nodes. |
---|
| 160 | */ |
---|
| 161 | osg::ref_ptr<objectMountedManipulator> objectMountedCameraManip; |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | #ifdef USE_SKY_SILVERLINING |
---|
| 165 | /** |
---|
| 166 | * Silverlining Sky instance |
---|
| 167 | */ |
---|
| 168 | osg::ref_ptr<visual_skySilverLining> sky; |
---|
[129] | 169 | |
---|
| 170 | xmlNode* skySilverliningConfig; |
---|
[32] | 171 | #endif |
---|
| 172 | |
---|
| 173 | #ifdef USE_DISTORTION |
---|
| 174 | /** |
---|
| 175 | * Distortion instance. |
---|
| 176 | */ |
---|
| 177 | osg::ref_ptr<visual_distortion> distortion; |
---|
[129] | 178 | |
---|
| 179 | xmlNode* distortionConfig; |
---|
[32] | 180 | #endif |
---|
| 181 | |
---|
| 182 | osg::ref_ptr<visual_object> testObj; |
---|
| 183 | |
---|
| 184 | osg::ref_ptr<osgGA::NodeTrackerManipulator> nt; |
---|
[87] | 185 | |
---|
| 186 | osg::ref_ptr<visual_debug_hud> hud; |
---|
[32] | 187 | }; |
---|
| 188 | |
---|
| 189 | } // END NAMESPACE |
---|