root/OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/Document.h @ 8563

Revision 8563, 10.7 kB (checked in by robert, 6 years ago)

From Joakim Simmonsson, fixed various spelling typos in comments

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[7748]1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is 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 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13
[5038]14//
15// OpenFlight® loader for OpenSceneGraph
16//
[7748]17//  Copyright (C) 2005-2007  Brede Johansen
[5038]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
[8003]29#include "Types.h"
[5038]30#include "Record.h"
31#include "Pools.h"
32
33
34namespace flt {
35
36class Header;
37class PushLevel;
38class PopLevel;
39
40enum 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,
[5145]54    VERSION_16_0    = 1600,
55    VERSION_16_1    = 1610
[5038]56};
57
58enum CoordUnits {
59    METERS = 0,
60    KILOMETERS = 1,
61    FEET = 4,
62    INCHES = 5,
63    NAUTICAL_MILES = 8
64};
65
66double unitsToMeters(CoordUnits unit);
67
68
69enum 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
79enum Ellipsoid {
80    WGS_1984 = 0,
81    WGS_1972 = 1,
82    BESSEL = 2,
83    CLARKE_1866 = 3,
84    NAD_1927 = 4
85};
86
87
88class Document
89{
90    public:
91
[5145]92        Document();
93        virtual ~Document();
[5038]94
95        void setOptions(const osgDB::ReaderWriter::Options* options) { _options = options; }
96        const osgDB::ReaderWriter::Options* getOptions() const { return _options.get(); }
97
[8563]98        // Current primary record
[7756]99        void setCurrentPrimaryRecord(PrimaryRecord* record) { _currentPrimaryRecord=record; }
[5038]100        PrimaryRecord* getCurrentPrimaryRecord() { return _currentPrimaryRecord.get(); }
101        const PrimaryRecord* getCurrentPrimaryRecord() const { return _currentPrimaryRecord.get(); }
102
103        // Level stack
104        PrimaryRecord* getTopOfLevelStack();
105        void pushLevel();
106        void popLevel();
107
108        // Subface stack
109        void pushSubface();
110        void popSubface();
111
112        // Extension stack
113        void pushExtension();
114        void popExtension();
115
116        void setHeaderNode(osg::Node* node) { _osgHeader = node; }
117        osg::Node* getHeaderNode() { return _osgHeader.get(); }
118
119        // Instance definitions
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        // Pools
130        void setVertexPool(VertexPool* vp) { _vertexPool = vp; }
131        VertexPool* getVertexPool() { return _vertexPool.get(); }
132        const VertexPool* getVertexPool() const { return _vertexPool.get(); }
133
[5236]134        void setColorPool(ColorPool* cp, bool parent=false) { _colorPool = cp; _colorPoolParent=parent; }
[5038]135        ColorPool* getColorPool() { return _colorPool.get(); }
136        const ColorPool* getColorPool() const { return _colorPool.get(); }
[5236]137        bool getColorPoolParent() const { return _colorPoolParent; }
[5038]138
[5236]139        void setTexturePool(TexturePool* tp, bool parent=false) { _texturePool = tp; _texturePoolParent=parent; }
[6091]140        TexturePool* getTexturePool() { return _texturePool.get(); }
[5038]141        TexturePool* getOrCreateTexturePool();
[5236]142        bool getTexturePoolParent() const { return _texturePoolParent; }
143
144        void setMaterialPool(MaterialPool* mp, bool parent=false) { _materialPool = mp; _materialPoolParent=parent; }
[6091]145        MaterialPool* getMaterialPool() { return _materialPool.get(); }
[5038]146        MaterialPool* getOrCreateMaterialPool();
[5236]147        bool getMaterialPoolParent() const { return _materialPoolParent; }
148
[6091]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
[5236]154        void setLightPointAppearancePool(LightPointAppearancePool* lpap, bool parent=false) { _lightPointAppearancePool = lpap; _lightPointAppearancePoolParent=parent; }
[6091]155        LightPointAppearancePool* getLightPointAppearancePool() { return _lightPointAppearancePool.get(); }
[5038]156        LightPointAppearancePool* getOrCreateLightPointAppearancePool();
[5236]157        bool getLightPointAppearancePoolParent() const { return _lightPointAppearancePoolParent; }
158
[6759]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
[5236]164        void setShaderPool(ShaderPool* cp, bool parent=false) { _shaderPool = cp; _shaderPoolParent=parent; }
[6091]165        ShaderPool* getShaderPool() { return _shaderPool.get(); }
[5038]166        ShaderPool* getOrCreateShaderPool();
[5236]167        bool getShaderPoolParent() const { return _shaderPoolParent; }
[5038]168
[5236]169
[5038]170        // Options
[5794]171        void setReplaceClampWithClampToEdge(bool flag) { _replaceClampWithClampToEdge = flag; }
172        bool getReplaceClampWithClampToEdge() const { return _replaceClampWithClampToEdge; }
[5205]173        void setPreserveFace(bool flag) { _preserveFace = flag; }
174        bool getPreserveFace() const { return _preserveFace; }
[5528]175        void setPreserveObject(bool flag) { _preserveObject = flag; }
176        bool getPreserveObject() const { return _preserveObject; }
[5038]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; }
[5610]181        void setUseBillboardCenter(bool flag) { _useBillboardCenter=flag; }
182        bool getUseBillboardCenter() const { return _useBillboardCenter; }
[5038]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; }
[5461]187       
[7931]188        void setKeepExternalReferences( bool flag) { _keepExternalReferences=flag; }
[5461]189        bool getKeepExternalReferences() const { return _keepExternalReferences; }
[5038]190
[7931]191        void setReadObjectRecordData(bool flag) { _readObjectRecordData = flag; }
192        bool getReadObjectRecordData() const { return _readObjectRecordData; }
193
[5038]194    protected:
195
196        // Options
197        osg::ref_ptr<const osgDB::ReaderWriter::Options> _options;
[5794]198        bool                        _replaceClampWithClampToEdge;
[5205]199        bool                        _preserveFace;
[5528]200        bool                        _preserveObject;
[5038]201        bool                        _defaultDOFAnimationState;
202        bool                        _useTextureAlphaForTransparancyBinning;
[5610]203        bool                        _useBillboardCenter;
[5038]204        bool                        _doUnitsConversion;
[7931]205        bool                        _readObjectRecordData;
[5038]206        CoordUnits                  _desiredUnits;
[5461]207       
208        bool                        _keepExternalReferences;
[5038]209
210        friend class Header;
211        bool _done;
212        int _level;
213        int _subfaceLevel;
214        double _unitScale;
215        uint32 _version;
216
217        // Header data
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;
[6091]224        osg::ref_ptr<LightSourcePool> _lightSourcePool;
[5038]225        osg::ref_ptr<LightPointAppearancePool> _lightPointAppearancePool;
[6759]226        osg::ref_ptr<LightPointAnimationPool> _lightPointAnimationPool;
[5038]227        osg::ref_ptr<ShaderPool> _shaderPool;
[5236]228        bool _colorPoolParent;
229        bool _texturePoolParent;
230        bool _materialPoolParent;
[6091]231        bool _lightSourcePoolParent;
[5236]232        bool _lightPointAppearancePoolParent;
[6759]233        bool _lightPointAnimationPoolParent;
[5236]234        bool _shaderPoolParent;
[5038]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
247inline TexturePool* Document::getOrCreateTexturePool()
248{
249    if (!_texturePool.valid())
250        _texturePool = new TexturePool;
251    return _texturePool.get();
252}
253
254
255inline MaterialPool* Document::getOrCreateMaterialPool()
256{
257    if (!_materialPool.valid())
258        _materialPool = new MaterialPool;
259    return _materialPool.get();
260}
261
262
[6091]263inline LightSourcePool* Document::getOrCreateLightSourcePool()
264{
265    if (!_lightSourcePool.valid())
266        _lightSourcePool = new LightSourcePool;
267    return _lightSourcePool.get();
268}
269
270
[5038]271inline LightPointAppearancePool* Document::getOrCreateLightPointAppearancePool()
272{
273    if (!_lightPointAppearancePool.valid())
274        _lightPointAppearancePool = new LightPointAppearancePool;
275    return _lightPointAppearancePool.get();
276}
277
[6759]278inline LightPointAnimationPool* Document::getOrCreateLightPointAnimationPool()
279{
280    if (!_lightPointAnimationPool.valid())
281        _lightPointAnimationPool = new LightPointAnimationPool;
282    return _lightPointAnimationPool.get();
283}
[5038]284
[6759]285
[5038]286inline ShaderPool* Document::getOrCreateShaderPool()
287{
288    if (!_shaderPool.valid())
289        _shaderPool = new ShaderPool;
290    return _shaderPool.get();
291}
292
293
294inline PrimaryRecord* Document::getTopOfLevelStack()
295{
296    // Anything on the level stack?
297    if (_levelStack.empty())
298        return NULL;
299
300    return _levelStack.back().get();
301}
302
303
304} // end namespace
305
306#endif
Note: See TracBrowser for help on using the browser.