| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #ifndef FLT_POOLS_H |
|---|
| 21 | #define FLT_POOLS_H 1 |
|---|
| 22 | |
|---|
| 23 | #include <vector> |
|---|
| 24 | #include <map> |
|---|
| 25 | #include <sstream> |
|---|
| 26 | #include <osg/Vec4> |
|---|
| 27 | #include <osg/StateSet> |
|---|
| 28 | #include <osg/Material> |
|---|
| 29 | #include <osg/Light> |
|---|
| 30 | #include <osg/Program> |
|---|
| 31 | #include "Types.h" |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | namespace flt { |
|---|
| 35 | |
|---|
| 36 | class VertexPool : public osg::Referenced, public std::istringstream |
|---|
| 37 | { |
|---|
| 38 | public: |
|---|
| 39 | |
|---|
| 40 | explicit VertexPool( const std::string& str) : |
|---|
| 41 | std::istringstream(str,std::istringstream::in|std::istringstream::binary) {} |
|---|
| 42 | |
|---|
| 43 | protected: |
|---|
| 44 | |
|---|
| 45 | virtual ~VertexPool() {} |
|---|
| 46 | }; |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | class ColorPool : public osg::Referenced , public std::vector<osg::Vec4> |
|---|
| 50 | { |
|---|
| 51 | public: |
|---|
| 52 | |
|---|
| 53 | explicit ColorPool(bool old,int size) : |
|---|
| 54 | std::vector<osg::Vec4>(size), |
|---|
| 55 | _old(old) {} |
|---|
| 56 | |
|---|
| 57 | osg::Vec4 getColor(int indexIntensity) const; |
|---|
| 58 | |
|---|
| 59 | protected: |
|---|
| 60 | |
|---|
| 61 | virtual ~ColorPool() {} |
|---|
| 62 | |
|---|
| 63 | bool _old; |
|---|
| 64 | }; |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | class TexturePool : public osg::Referenced , public std::map<int,osg::ref_ptr<osg::StateSet> > |
|---|
| 68 | { |
|---|
| 69 | public: |
|---|
| 70 | |
|---|
| 71 | TexturePool() {} |
|---|
| 72 | |
|---|
| 73 | osg::StateSet* get(int index) |
|---|
| 74 | { |
|---|
| 75 | iterator itr = find(index); |
|---|
| 76 | if (itr != end()) |
|---|
| 77 | return (*itr).second.get(); |
|---|
| 78 | return NULL; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | protected: |
|---|
| 82 | |
|---|
| 83 | virtual ~TexturePool() {} |
|---|
| 84 | |
|---|
| 85 | }; |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | class MaterialPool : public osg::Referenced , public std::map<int,osg::ref_ptr<osg::Material> > |
|---|
| 89 | { |
|---|
| 90 | public: |
|---|
| 91 | |
|---|
| 92 | MaterialPool(); |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | osg::Material* get(int index); |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | osg::Material* getOrCreateMaterial(int index, const osg::Vec4& faceColor); |
|---|
| 101 | |
|---|
| 102 | protected: |
|---|
| 103 | |
|---|
| 104 | virtual ~MaterialPool() {} |
|---|
| 105 | |
|---|
| 106 | osg::ref_ptr<osg::Material> _defaultMaterial; |
|---|
| 107 | |
|---|
| 108 | struct MaterialParameters |
|---|
| 109 | { |
|---|
| 110 | int index; |
|---|
| 111 | osg::Vec4 color; |
|---|
| 112 | |
|---|
| 113 | MaterialParameters(): |
|---|
| 114 | index(-1) {} |
|---|
| 115 | |
|---|
| 116 | MaterialParameters(int i, const osg::Vec4& c): |
|---|
| 117 | index(i), |
|---|
| 118 | color(c) {} |
|---|
| 119 | |
|---|
| 120 | bool operator < (const MaterialParameters& rhs) const |
|---|
| 121 | { |
|---|
| 122 | if (index < rhs.index) return true; |
|---|
| 123 | else if (index > rhs.index) return false; |
|---|
| 124 | else return (color < rhs.color); |
|---|
| 125 | } |
|---|
| 126 | }; |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | typedef std::map<MaterialParameters,osg::ref_ptr<osg::Material> > FinalMaterialMap; |
|---|
| 130 | FinalMaterialMap _finalMaterialMap; |
|---|
| 131 | }; |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | class LightSourcePool : public osg::Referenced , public std::map<int,osg::ref_ptr<osg::Light> > |
|---|
| 135 | { |
|---|
| 136 | public: |
|---|
| 137 | |
|---|
| 138 | LightSourcePool() {} |
|---|
| 139 | |
|---|
| 140 | osg::Light* get(int index) |
|---|
| 141 | { |
|---|
| 142 | iterator itr = find(index); |
|---|
| 143 | if (itr != end()) |
|---|
| 144 | return (*itr).second.get(); |
|---|
| 145 | return NULL; |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | protected: |
|---|
| 149 | |
|---|
| 150 | virtual ~LightSourcePool() {} |
|---|
| 151 | }; |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | struct LPAppearance : public osg::Referenced |
|---|
| 155 | { |
|---|
| 156 | std::string name; |
|---|
| 157 | int32 index; |
|---|
| 158 | int16 materialCode; |
|---|
| 159 | int16 featureID; |
|---|
| 160 | osg::Vec4f backColor; |
|---|
| 161 | int32 displayMode; |
|---|
| 162 | float32 intensityFront; |
|---|
| 163 | float32 intensityBack; |
|---|
| 164 | float32 minDefocus; |
|---|
| 165 | float32 maxDefocus; |
|---|
| 166 | int32 fadingMode; |
|---|
| 167 | int32 fogPunchMode; |
|---|
| 168 | int32 directionalMode; |
|---|
| 169 | int32 rangeMode; |
|---|
| 170 | float32 minPixelSize; |
|---|
| 171 | float32 maxPixelSize; |
|---|
| 172 | float32 actualPixelSize; |
|---|
| 173 | float32 transparentFalloffPixelSize; |
|---|
| 174 | float32 transparentFalloffExponent; |
|---|
| 175 | float32 transparentFalloffScalar; |
|---|
| 176 | float32 transparentFalloffClamp; |
|---|
| 177 | float32 fogScalar; |
|---|
| 178 | float32 fogIntensity; |
|---|
| 179 | float32 sizeDifferenceThreshold; |
|---|
| 180 | int32 directionality; |
|---|
| 181 | float32 horizontalLobeAngle; |
|---|
| 182 | float32 verticalLobeAngle; |
|---|
| 183 | float32 lobeRollAngle; |
|---|
| 184 | float32 directionalFalloffExponent; |
|---|
| 185 | float32 directionalAmbientIntensity; |
|---|
| 186 | float32 significance; |
|---|
| 187 | uint32 flags; |
|---|
| 188 | float32 visibilityRange; |
|---|
| 189 | float32 fadeRangeRatio; |
|---|
| 190 | float32 fadeInDuration; |
|---|
| 191 | float32 fadeOutDuration; |
|---|
| 192 | float32 LODRangeRatio; |
|---|
| 193 | float32 LODScale; |
|---|
| 194 | int16 texturePatternIndex; |
|---|
| 195 | }; |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | class LightPointAppearancePool : public osg::Referenced , public std::map<int,osg::ref_ptr<LPAppearance> > |
|---|
| 199 | { |
|---|
| 200 | public: |
|---|
| 201 | |
|---|
| 202 | LightPointAppearancePool() {} |
|---|
| 203 | |
|---|
| 204 | LPAppearance* get(int index) |
|---|
| 205 | { |
|---|
| 206 | iterator itr = find(index); |
|---|
| 207 | if (itr != end()) |
|---|
| 208 | return (*itr).second.get(); |
|---|
| 209 | return NULL; |
|---|
| 210 | } |
|---|
| 211 | |
|---|
| 212 | protected: |
|---|
| 213 | |
|---|
| 214 | virtual ~LightPointAppearancePool() {} |
|---|
| 215 | |
|---|
| 216 | }; |
|---|
| 217 | |
|---|
| 218 | struct LPAnimation : public osg::Referenced |
|---|
| 219 | { |
|---|
| 220 | enum AnimationType |
|---|
| 221 | { |
|---|
| 222 | FLASHING_SEQUENCE = 0, |
|---|
| 223 | ROTATING = 1, |
|---|
| 224 | STROBE = 2, |
|---|
| 225 | MORSE_CODE = 3 |
|---|
| 226 | }; |
|---|
| 227 | |
|---|
| 228 | enum State |
|---|
| 229 | { |
|---|
| 230 | ON = 0, |
|---|
| 231 | OFF = 1, |
|---|
| 232 | COLOR_CHANGE = 2 |
|---|
| 233 | }; |
|---|
| 234 | |
|---|
| 235 | struct Pulse |
|---|
| 236 | { |
|---|
| 237 | uint32 state; |
|---|
| 238 | float32 duration; |
|---|
| 239 | osg::Vec4 color; |
|---|
| 240 | }; |
|---|
| 241 | |
|---|
| 242 | typedef std::vector<Pulse> PulseArray; |
|---|
| 243 | |
|---|
| 244 | std::string name; |
|---|
| 245 | int32 index; |
|---|
| 246 | float32 animationPeriod; |
|---|
| 247 | float32 animationPhaseDelay; |
|---|
| 248 | float32 animationEnabledPeriod; |
|---|
| 249 | osg::Vec3f axisOfRotation; |
|---|
| 250 | uint32 flags; |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | int32 animationType; |
|---|
| 256 | |
|---|
| 257 | |
|---|
| 258 | |
|---|
| 259 | |
|---|
| 260 | int32 morseCodeTiming; |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | int32 wordRate; |
|---|
| 264 | int32 characterRate; |
|---|
| 265 | std::string morseCodeString; |
|---|
| 266 | PulseArray sequence; |
|---|
| 267 | }; |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | class LightPointAnimationPool : public osg::Referenced , public std::map<int,osg::ref_ptr<LPAnimation> > |
|---|
| 271 | { |
|---|
| 272 | public: |
|---|
| 273 | |
|---|
| 274 | LightPointAnimationPool() {} |
|---|
| 275 | |
|---|
| 276 | LPAnimation* get(int index) |
|---|
| 277 | { |
|---|
| 278 | iterator itr = find(index); |
|---|
| 279 | if (itr != end()) |
|---|
| 280 | return (*itr).second.get(); |
|---|
| 281 | return NULL; |
|---|
| 282 | } |
|---|
| 283 | |
|---|
| 284 | protected: |
|---|
| 285 | |
|---|
| 286 | virtual ~LightPointAnimationPool() {} |
|---|
| 287 | |
|---|
| 288 | }; |
|---|
| 289 | |
|---|
| 290 | class ShaderPool : public osg::Referenced , public std::map<int,osg::ref_ptr<osg::Program> > |
|---|
| 291 | { |
|---|
| 292 | public: |
|---|
| 293 | |
|---|
| 294 | ShaderPool() {} |
|---|
| 295 | |
|---|
| 296 | osg::Program* get(int index) |
|---|
| 297 | { |
|---|
| 298 | iterator itr = find(index); |
|---|
| 299 | if (itr != end()) |
|---|
| 300 | return (*itr).second.get(); |
|---|
| 301 | return NULL; |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | protected: |
|---|
| 305 | |
|---|
| 306 | virtual ~ShaderPool() {} |
|---|
| 307 | }; |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | class ParentPools : public osg::Referenced |
|---|
| 317 | { |
|---|
| 318 | public: |
|---|
| 319 | |
|---|
| 320 | ParentPools() {} |
|---|
| 321 | |
|---|
| 322 | void setColorPool(ColorPool* pool) { _colorPool=pool; } |
|---|
| 323 | ColorPool* getColorPool() const { return _colorPool.get(); } |
|---|
| 324 | |
|---|
| 325 | void setTexturePool(TexturePool* pool) { _texturePool=pool; } |
|---|
| 326 | TexturePool* getTexturePool() const { return _texturePool.get(); } |
|---|
| 327 | |
|---|
| 328 | void setMaterialPool(MaterialPool* pool) { _materialPool=pool; } |
|---|
| 329 | MaterialPool* getMaterialPool() const { return _materialPool.get(); } |
|---|
| 330 | |
|---|
| 331 | void setLightSourcePool(LightSourcePool* pool) { _lightSourcePool=pool; } |
|---|
| 332 | LightSourcePool* getLightSourcePool() const { return _lightSourcePool.get(); } |
|---|
| 333 | |
|---|
| 334 | void setLPAppearancePool(LightPointAppearancePool* pool) { _lpAppearancePool=pool; } |
|---|
| 335 | LightPointAppearancePool* getLPAppearancePool() const { return _lpAppearancePool.get(); } |
|---|
| 336 | |
|---|
| 337 | void setLPAnimationPool(LightPointAnimationPool* pool) { _lpAnimationPool=pool; } |
|---|
| 338 | LightPointAnimationPool* getLPAnimationPool() const { return _lpAnimationPool.get(); } |
|---|
| 339 | |
|---|
| 340 | void setShaderPool(ShaderPool* pool) { _shaderPool=pool; } |
|---|
| 341 | ShaderPool* getShaderPool() const { return _shaderPool.get(); } |
|---|
| 342 | |
|---|
| 343 | protected: |
|---|
| 344 | |
|---|
| 345 | virtual ~ParentPools() {} |
|---|
| 346 | |
|---|
| 347 | osg::ref_ptr<ColorPool> _colorPool; |
|---|
| 348 | osg::ref_ptr<MaterialPool> _materialPool; |
|---|
| 349 | osg::ref_ptr<TexturePool> _texturePool; |
|---|
| 350 | osg::ref_ptr<LightSourcePool> _lightSourcePool; |
|---|
| 351 | osg::ref_ptr<LightPointAppearancePool> _lpAppearancePool; |
|---|
| 352 | osg::ref_ptr<LightPointAnimationPool> _lpAnimationPool; |
|---|
| 353 | osg::ref_ptr<ShaderPool> _shaderPool; |
|---|
| 354 | }; |
|---|
| 355 | |
|---|
| 356 | |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | #endif |
|---|