| [7748] | 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| [5038] | 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| [7748] | 17 | |
|---|
| [5038] | 18 | |
|---|
| 19 | |
|---|
| 20 | #include "Document.h" |
|---|
| 21 | |
|---|
| 22 | using namespace flt; |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | Document::Document() : |
|---|
| [5794] | 26 | _replaceClampWithClampToEdge(false), |
|---|
| [5229] | 27 | _preserveFace(false), |
|---|
| [5528] | 28 | _preserveObject(false), |
|---|
| [5229] | 29 | _defaultDOFAnimationState(false), |
|---|
| 30 | _useTextureAlphaForTransparancyBinning(true), |
|---|
| [5610] | 31 | _useBillboardCenter(false), |
|---|
| [5229] | 32 | _doUnitsConversion(true), |
|---|
| [7931] | 33 | _readObjectRecordData(false), |
|---|
| [5229] | 34 | _desiredUnits(METERS), |
|---|
| [5038] | 35 | _done(false), |
|---|
| 36 | _level(0), |
|---|
| 37 | _subfaceLevel(0), |
|---|
| 38 | _unitScale(1.0), |
|---|
| [5236] | 39 | _version(0), |
|---|
| 40 | _colorPoolParent(false), |
|---|
| 41 | _texturePoolParent(false), |
|---|
| 42 | _materialPoolParent(false), |
|---|
| [6091] | 43 | _lightSourcePoolParent(false), |
|---|
| [5236] | 44 | _lightPointAppearancePoolParent(false), |
|---|
| [6759] | 45 | _lightPointAnimationPoolParent(false), |
|---|
| [5236] | 46 | _shaderPoolParent(false) |
|---|
| [5038] | 47 | { |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | Document::~Document() |
|---|
| 51 | { |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | void Document::pushLevel() |
|---|
| 55 | { |
|---|
| 56 | _levelStack.push_back(_currentPrimaryRecord.get()); |
|---|
| 57 | _level++; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | void Document::popLevel() |
|---|
| 61 | { |
|---|
| 62 | _levelStack.pop_back(); |
|---|
| 63 | |
|---|
| 64 | if (!_levelStack.empty()) |
|---|
| [7756] | 65 | _currentPrimaryRecord = _levelStack.back(); |
|---|
| [5038] | 66 | |
|---|
| 67 | if (--_level<=0) |
|---|
| 68 | _done = true; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | void Document::pushSubface() |
|---|
| 72 | { |
|---|
| 73 | _subfaceLevel++; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | void Document::popSubface() |
|---|
| 77 | { |
|---|
| 78 | _subfaceLevel--; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | void Document::pushExtension() |
|---|
| 82 | { |
|---|
| 83 | if (!_currentPrimaryRecord.valid()) |
|---|
| 84 | { |
|---|
| 85 | osg::notify(osg::WARN) << "No current primary in Document::pushExtension()." << std::endl; |
|---|
| 86 | return; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | _extensionStack.push_back(_currentPrimaryRecord.get()); |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | void Document::popExtension() |
|---|
| 93 | { |
|---|
| 94 | _currentPrimaryRecord=_extensionStack.back().get(); |
|---|
| 95 | if (!_currentPrimaryRecord.valid()) |
|---|
| 96 | { |
|---|
| [8563] | 97 | osg::notify(osg::WARN) << "Can't decide primary in Document::popExtension()." << std::endl; |
|---|
| [5038] | 98 | return; |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | _extensionStack.pop_back(); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | osg::Node* Document::getInstanceDefinition(int no) |
|---|
| 105 | { |
|---|
| 106 | InstanceDefinitionMap::iterator itr = _instanceDefinitionMap.find(no); |
|---|
| 107 | if (itr != _instanceDefinitionMap.end()) |
|---|
| 108 | return (*itr).second.get(); |
|---|
| 109 | |
|---|
| 110 | return NULL; |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | double flt::unitsToMeters(CoordUnits unit) |
|---|
| 114 | { |
|---|
| 115 | switch (unit) |
|---|
| 116 | { |
|---|
| 117 | case METERS: |
|---|
| 118 | return 1.0; |
|---|
| 119 | case KILOMETERS: |
|---|
| 120 | return 1000.0; |
|---|
| 121 | case FEET: |
|---|
| 122 | return 0.3048; |
|---|
| 123 | case INCHES: |
|---|
| 124 | return 0.02540; |
|---|
| 125 | case NAUTICAL_MILES: |
|---|
| 126 | return 1852.0; |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | return 1.0; |
|---|
| 130 | } |
|---|