| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #ifndef FLT_FLIGHTDATA_H |
|---|
| 21 | #define FLT_FLIGHTDATA_H 1 |
|---|
| 22 | |
|---|
| 23 | #include <vector> |
|---|
| 24 | #include <osg/Notify> |
|---|
| 25 | #include <osg/Transform> |
|---|
| 26 | #include <osg/Geometry> |
|---|
| 27 | #include <osgDB/ReaderWriter> |
|---|
| 28 | |
|---|
| 29 | #include "Types.h" |
|---|
| 30 | #include "Record.h" |
|---|
| 31 | #include "Pools.h" |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | namespace flt { |
|---|
| 35 | |
|---|
| 36 | class Header; |
|---|
| 37 | class PushLevel; |
|---|
| 38 | class PopLevel; |
|---|
| 39 | |
|---|
| 40 | enum Version |
|---|
| 41 | { |
|---|
| 42 | VERSION_11 = 11, |
|---|
| 43 | VERSION_12 = 12, |
|---|
| 44 | VERSION_13 = 13, |
|---|
| 45 | VERSION_14 = 14, |
|---|
| 46 | VERSION_14_1 = 14, |
|---|
| 47 | VERSION_14_2 = 1420, |
|---|
| 48 | VERSION_15_1 = 1510, |
|---|
| 49 | VERSION_15_4 = 1540, |
|---|
| 50 | VERSION_15_5 = 1550, |
|---|
| 51 | VERSION_15_6 = 1560, |
|---|
| 52 | VERSION_15_7 = 1570, |
|---|
| 53 | VERSION_15_8 = 1580, |
|---|
| 54 | VERSION_16_0 = 1600, |
|---|
| 55 | VERSION_16_1 = 1610 |
|---|
| 56 | }; |
|---|
| 57 | |
|---|
| 58 | enum CoordUnits { |
|---|
| 59 | METERS = 0, |
|---|
| 60 | KILOMETERS = 1, |
|---|
| 61 | FEET = 4, |
|---|
| 62 | INCHES = 5, |
|---|
| 63 | NAUTICAL_MILES = 8 |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | double unitsToMeters(CoordUnits unit); |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | enum Projection { |
|---|
| 70 | FLAT_EARTH = 0, |
|---|
| 71 | TRAPEZOIDAL = 1, |
|---|
| 72 | ROUND_EARTH = 2, |
|---|
| 73 | LAMBERT = 3, |
|---|
| 74 | UTM = 4, |
|---|
| 75 | GEODETIC = 5, |
|---|
| 76 | GEOCENTRIC = 6 |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 79 | enum Ellipsoid { |
|---|
| 80 | WGS_1984 = 0, |
|---|
| 81 | WGS_1972 = 1, |
|---|
| 82 | BESSEL = 2, |
|---|
| 83 | CLARKE_1866 = 3, |
|---|
| 84 | NAD_1927 = 4 |
|---|
| 85 | }; |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | class Document |
|---|
| 89 | { |
|---|
| 90 | public: |
|---|
| 91 | |
|---|
| 92 | Document(); |
|---|
| 93 | virtual ~Document(); |
|---|
| 94 | |
|---|
| 95 | void setOptions(const osgDB::ReaderWriter::Options* options) { _options = options; } |
|---|
| 96 | const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); } |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | void setCurrentPrimaryRecord(PrimaryRecord* record) { _currentPrimaryRecord=record; } |
|---|
| 100 | PrimaryRecord* getCurrentPrimaryRecord() { return _currentPrimaryRecord.get(); } |
|---|
| 101 | const PrimaryRecord* getCurrentPrimaryRecord() const { return _currentPrimaryRecord.get(); } |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | PrimaryRecord* getTopOfLevelStack(); |
|---|
| 105 | void pushLevel(); |
|---|
| 106 | void popLevel(); |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | void pushSubface(); |
|---|
| 110 | void popSubface(); |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | void pushExtension(); |
|---|
| 114 | void popExtension(); |
|---|
| 115 | |
|---|
| 116 | void setHeaderNode(osg::Node* node) { _osgHeader = node; } |
|---|
| 117 | osg::Node* getHeaderNode() { return _osgHeader.get(); } |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | void setInstanceDefinition(int no, osg::Node* node) { _instanceDefinitionMap[no] = node; } |
|---|
| 121 | osg::Node* getInstanceDefinition(int no); |
|---|
| 122 | |
|---|
| 123 | uint32 version() const { return _version; } |
|---|
| 124 | bool done() const { return _done; } |
|---|
| 125 | int level() const { return _level; } |
|---|
| 126 | int subfaceLevel() const { return _subfaceLevel; } |
|---|
| 127 | double unitScale() const { return _unitScale; } |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | void setVertexPool(VertexPool* vp) { _vertexPool = vp; } |
|---|
| 131 | VertexPool* getVertexPool() { return _vertexPool.get(); } |
|---|
| 132 | const VertexPool* getVertexPool() const { return _vertexPool.get(); } |
|---|
| 133 | |
|---|
| 134 | void setColorPool(ColorPool* cp, bool parent=false) { _colorPool = cp; _colorPoolParent=parent; } |
|---|
| 135 | ColorPool* getColorPool() { return _colorPool.get(); } |
|---|
| 136 | const ColorPool* getColorPool() const { return _colorPool.get(); } |
|---|
| 137 | bool getColorPoolParent() const { return _colorPoolParent; } |
|---|
| 138 | |
|---|
| 139 | void setTexturePool(TexturePool* tp, bool parent=false) { _texturePool = tp; _texturePoolParent=parent; } |
|---|
| 140 | TexturePool* getTexturePool() { return _texturePool.get(); } |
|---|
| 141 | TexturePool* getOrCreateTexturePool(); |
|---|
| 142 | bool getTexturePoolParent() const { return _texturePoolParent; } |
|---|
| 143 | |
|---|
| 144 | void setMaterialPool(MaterialPool* mp, bool parent=false) { _materialPool = mp; _materialPoolParent=parent; } |
|---|
| 145 | MaterialPool* getMaterialPool() { return _materialPool.get(); } |
|---|
| 146 | MaterialPool* getOrCreateMaterialPool(); |
|---|
| 147 | bool getMaterialPoolParent() const { return _materialPoolParent; } |
|---|
| 148 | |
|---|
| 149 | void setLightSourcePool(LightSourcePool* lsp, bool parent=false) { _lightSourcePool = lsp; _lightSourcePoolParent=parent; } |
|---|
| 150 | LightSourcePool* getLightSourcePool() { return _lightSourcePool.get(); } |
|---|
| 151 | LightSourcePool* getOrCreateLightSourcePool(); |
|---|
| 152 | bool getLightSourcePoolParent() const { return _lightSourcePoolParent; } |
|---|
| 153 | |
|---|
| 154 | void setLightPointAppearancePool(LightPointAppearancePool* lpap, bool parent=false) { _lightPointAppearancePool = lpap; _lightPointAppearancePoolParent=parent; } |
|---|
| 155 | LightPointAppearancePool* getLightPointAppearancePool() { return _lightPointAppearancePool.get(); } |
|---|
| 156 | LightPointAppearancePool* getOrCreateLightPointAppearancePool(); |
|---|
| 157 | bool getLightPointAppearancePoolParent() const { return _lightPointAppearancePoolParent; } |
|---|
| 158 | |
|---|
| 159 | void setLightPointAnimationPool(LightPointAnimationPool* lpap, bool parent=false) { _lightPointAnimationPool = lpap; _lightPointAnimationPoolParent=parent; } |
|---|
| 160 | LightPointAnimationPool* getLightPointAnimationPool() { return _lightPointAnimationPool.get(); } |
|---|
| 161 | LightPointAnimationPool* getOrCreateLightPointAnimationPool(); |
|---|
| 162 | bool getLightPointAnimationPoolParent() const { return _lightPointAnimationPoolParent; } |
|---|
| 163 | |
|---|
| 164 | void setShaderPool(ShaderPool* cp, bool parent=false) { _shaderPool = cp; _shaderPoolParent=parent; } |
|---|
| 165 | ShaderPool* getShaderPool() { return _shaderPool.get(); } |
|---|
| 166 | ShaderPool* getOrCreateShaderPool(); |
|---|
| 167 | bool getShaderPoolParent() const { return _shaderPoolParent; } |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | void setReplaceClampWithClampToEdge(bool flag) { _replaceClampWithClampToEdge = flag; } |
|---|
| 172 | bool getReplaceClampWithClampToEdge() const { return _replaceClampWithClampToEdge; } |
|---|
| 173 | void setPreserveFace(bool flag) { _preserveFace = flag; } |
|---|
| 174 | bool getPreserveFace() const { return _preserveFace; } |
|---|
| 175 | void setPreserveObject(bool flag) { _preserveObject = flag; } |
|---|
| 176 | bool getPreserveObject() const { return _preserveObject; } |
|---|
| 177 | void setDefaultDOFAnimationState(bool state) { _defaultDOFAnimationState = state; } |
|---|
| 178 | bool getDefaultDOFAnimationState() const { return _defaultDOFAnimationState; } |
|---|
| 179 | void setUseTextureAlphaForTransparancyBinning(bool flag) { _useTextureAlphaForTransparancyBinning=flag; } |
|---|
| 180 | bool getUseTextureAlphaForTransparancyBinning() const { return _useTextureAlphaForTransparancyBinning; } |
|---|
| 181 | void setUseBillboardCenter(bool flag) { _useBillboardCenter=flag; } |
|---|
| 182 | bool getUseBillboardCenter() const { return _useBillboardCenter; } |
|---|
| 183 | void setDoUnitsConversion(bool flag) { _doUnitsConversion=flag; } |
|---|
| 184 | bool getDoUnitsConversion() const { return _doUnitsConversion; } |
|---|
| 185 | void setDesiredUnits(CoordUnits units ) { _desiredUnits=units; } |
|---|
| 186 | CoordUnits getDesiredUnits() const { return _desiredUnits; } |
|---|
| 187 | |
|---|
| 188 | void setKeepExternalReferences( bool flag) { _keepExternalReferences=flag; } |
|---|
| 189 | bool getKeepExternalReferences() const { return _keepExternalReferences; } |
|---|
| 190 | |
|---|
| 191 | void setReadObjectRecordData(bool flag) { _readObjectRecordData = flag; } |
|---|
| 192 | bool getReadObjectRecordData() const { return _readObjectRecordData; } |
|---|
| 193 | |
|---|
| 194 | protected: |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | osg::ref_ptr<const osgDB::ReaderWriter::Options> _options; |
|---|
| 198 | bool _replaceClampWithClampToEdge; |
|---|
| 199 | bool _preserveFace; |
|---|
| 200 | bool _preserveObject; |
|---|
| 201 | bool _defaultDOFAnimationState; |
|---|
| 202 | bool _useTextureAlphaForTransparancyBinning; |
|---|
| 203 | bool _useBillboardCenter; |
|---|
| 204 | bool _doUnitsConversion; |
|---|
| 205 | bool _readObjectRecordData; |
|---|
| 206 | CoordUnits _desiredUnits; |
|---|
| 207 | |
|---|
| 208 | bool _keepExternalReferences; |
|---|
| 209 | |
|---|
| 210 | friend class Header; |
|---|
| 211 | bool _done; |
|---|
| 212 | int _level; |
|---|
| 213 | int _subfaceLevel; |
|---|
| 214 | double _unitScale; |
|---|
| 215 | uint32 _version; |
|---|
| 216 | |
|---|
| 217 | |
|---|
| 218 | osg::ref_ptr<osg::Node> _osgHeader; |
|---|
| 219 | |
|---|
| 220 | osg::ref_ptr<VertexPool> _vertexPool; |
|---|
| 221 | osg::ref_ptr<ColorPool> _colorPool; |
|---|
| 222 | osg::ref_ptr<TexturePool> _texturePool; |
|---|
| 223 | osg::ref_ptr<MaterialPool> _materialPool; |
|---|
| 224 | osg::ref_ptr<LightSourcePool> _lightSourcePool; |
|---|
| 225 | osg::ref_ptr<LightPointAppearancePool> _lightPointAppearancePool; |
|---|
| 226 | osg::ref_ptr<LightPointAnimationPool> _lightPointAnimationPool; |
|---|
| 227 | osg::ref_ptr<ShaderPool> _shaderPool; |
|---|
| 228 | bool _colorPoolParent; |
|---|
| 229 | bool _texturePoolParent; |
|---|
| 230 | bool _materialPoolParent; |
|---|
| 231 | bool _lightSourcePoolParent; |
|---|
| 232 | bool _lightPointAppearancePoolParent; |
|---|
| 233 | bool _lightPointAnimationPoolParent; |
|---|
| 234 | bool _shaderPoolParent; |
|---|
| 235 | |
|---|
| 236 | osg::ref_ptr<PrimaryRecord> _currentPrimaryRecord; |
|---|
| 237 | |
|---|
| 238 | typedef std::vector<osg::ref_ptr<PrimaryRecord> > LevelStack; |
|---|
| 239 | LevelStack _levelStack; |
|---|
| 240 | LevelStack _extensionStack; |
|---|
| 241 | |
|---|
| 242 | typedef std::map<int,osg::ref_ptr<osg::Node> > InstanceDefinitionMap; |
|---|
| 243 | InstanceDefinitionMap _instanceDefinitionMap; |
|---|
| 244 | }; |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | inline TexturePool* Document::getOrCreateTexturePool() |
|---|
| 248 | { |
|---|
| 249 | if (!_texturePool.valid()) |
|---|
| 250 | _texturePool = new TexturePool; |
|---|
| 251 | return _texturePool.get(); |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | inline MaterialPool* Document::getOrCreateMaterialPool() |
|---|
| 256 | { |
|---|
| 257 | if (!_materialPool.valid()) |
|---|
| 258 | _materialPool = new MaterialPool; |
|---|
| 259 | return _materialPool.get(); |
|---|
| 260 | } |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | inline LightSourcePool* Document::getOrCreateLightSourcePool() |
|---|
| 264 | { |
|---|
| 265 | if (!_lightSourcePool.valid()) |
|---|
| 266 | _lightSourcePool = new LightSourcePool; |
|---|
| 267 | return _lightSourcePool.get(); |
|---|
| 268 | } |
|---|
| 269 | |
|---|
| 270 | |
|---|
| 271 | inline LightPointAppearancePool* Document::getOrCreateLightPointAppearancePool() |
|---|
| 272 | { |
|---|
| 273 | if (!_lightPointAppearancePool.valid()) |
|---|
| 274 | _lightPointAppearancePool = new LightPointAppearancePool; |
|---|
| 275 | return _lightPointAppearancePool.get(); |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | inline LightPointAnimationPool* Document::getOrCreateLightPointAnimationPool() |
|---|
| 279 | { |
|---|
| 280 | if (!_lightPointAnimationPool.valid()) |
|---|
| 281 | _lightPointAnimationPool = new LightPointAnimationPool; |
|---|
| 282 | return _lightPointAnimationPool.get(); |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | inline ShaderPool* Document::getOrCreateShaderPool() |
|---|
| 287 | { |
|---|
| 288 | if (!_shaderPool.valid()) |
|---|
| 289 | _shaderPool = new ShaderPool; |
|---|
| 290 | return _shaderPool.get(); |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | inline PrimaryRecord* Document::getTopOfLevelStack() |
|---|
| 295 | { |
|---|
| 296 | |
|---|
| 297 | if (_levelStack.empty()) |
|---|
| 298 | return NULL; |
|---|
| 299 | |
|---|
| 300 | return _levelStack.back().get(); |
|---|
| 301 | } |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | #endif |
|---|