osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_seamless/PatchSet

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003  * Copyright 2010 Pelican Ventures, Inc.
00004  * http://osgearth.org
00005  *
00006  * osgEarth is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU Lesser General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public License
00017  * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018  */
00019 
00020 #ifndef SEAMLESS_PATCHSET
00021 #define SEAMLESS_PATCHSET 1
00022 
00023 #include <osg/CopyOp>
00024 #include <osg/Node>
00025 #include <osg/Object>
00026 #include <osg/PrimitiveSet>
00027 #include <osg/ref_ptr>
00028 #include <osg/Transform>
00029 
00030 #include <osgEarth/Map>
00031 
00032 #include "Patch"
00033 #include "PatchGroup"
00034 #include "SeamlessOptions"
00035 
00036 namespace seamless
00037 {
00038 class PatchSet : public osg::Object
00039 {
00040 public:
00041     PatchSet();
00042     PatchSet(const osgEarth::Drivers::SeamlessOptions& options,
00043              PatchOptions* poptionsPrototype = 0);
00044     PatchSet(const PatchSet& rhs,
00045              const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
00046     META_Object(seamless, PatchSet);
00047     int getResolution() const { return _resolution; }
00048     void setPrecisionFactor(double factor) { _precisionFactor = factor; }
00049     double getPrecisionFactor() const { return _precisionFactor; }
00050     double calcPrecisionFactor(int pixelError, double horiz_fov_deg = 60.0,
00051                                int screenRes = 1280, int dpi = 90);
00052     void setPrecisionFactor(int pixelError, double horiz_fov_deg = 60.0,
00053                             int screenRes = 1280, int dpi = 90)
00054     {
00055         setPrecisionFactor(calcPrecisionFactor(pixelError, horiz_fov_deg,
00056                                                screenRes, dpi));
00057     }
00058     void setPatchOptionsPrototype(PatchOptions* proto)
00059     {
00060         _patchOptionsPrototype = proto;
00061     }
00062     PatchOptions* getPatchOptionsPrototype() const
00063     {
00064         return _patchOptionsPrototype;
00065     }
00066     void setMaxLevel(int maxLevel) { _maxLevel = maxLevel; }
00067     int getMaxLevel() const { return _maxLevel; }
00068     void setVerticalScale(float  scale) { _verticalScale = scale; }
00069     float getVerticalScale() const { return _verticalScale; }
00070     void setMap(const osgEarth::Map* map);
00071     const osgEarth::Map* getMap() const { return _map.get(); }
00072     osgEarth::MapFrame& getMapFrame() const { return *_mapf; }
00073     virtual osg::Node* createPatchGroup(const std::string& filename,
00074                                         PatchOptions* poptions);
00075     virtual osg::Transform* createPatch(const std::string& filename,
00076                                         PatchOptions* poptions);
00077     virtual osg::Node* createPatchSetGraph(const std::string& filename);
00078     virtual osg::Node* createChild(const PatchOptions* parentOptions, int childNum);
00079     friend class Patch;
00084     unsigned short makeIndex(int x, int y)
00085     {
00086         return static_cast<unsigned short>(y * (_resolution + 1) + x);
00087     }
00090     unsigned short rotateIndex(unsigned short index);
00091 protected:
00092     virtual ~PatchSet();
00093     double _precisionFactor;
00094     int _resolution;
00095     int _maxLevel;
00096     float _verticalScale;
00097     osg::ref_ptr<PatchOptions> _patchOptionsPrototype;
00098     // Shared primitive sets for all the geometry.
00099     void initPrimitiveSets();
00100     osg::ref_ptr<osg::DrawElementsUShort> makeBasicTrile(int delta);
00101     osg::ref_ptr<osg::DrawElementsUShort> makeSingleStrip(int delta);
00102     osg::ref_ptr<osg::DrawElementsUShort> makeDualStrip();
00103     osg::ref_ptr<osg::DrawElementsUShort> trilePset[2][4];
00104     osg::ref_ptr<osg::DrawElementsUShort> stripPset[4][4];
00105     osg::ref_ptr<const osgEarth::Map> _map;
00106     osgEarth::MapFrame* _mapf;
00107     osgEarth::Drivers::SeamlessOptions _options;
00108 };
00109 }
00110 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines