1/* -*-c++-*- */ 2/* osgEarth - Geospatial SDK for OpenSceneGraph 3 * Copyright 2008-2014 Pelican Mapping 4 * http://osgearth.org 5 * 6 * osgEarth is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/> 18 */ 19#ifndef OSGEARTH_REX_TERRAIN_DRAWABLE_H 20#define OSGEARTH_REX_TERRAIN_DRAWABLE_H 1 21 22#include "RenderBindings" 23#include "DrawState" 24#include "LayerDrawable" 25 26using namespace osgEarth; 27 28namespace osgEarth { namespace Drivers { namespace RexTerrainEngine 29{ 30 /** 31 * Main data structure assembled by the TerrainCuller that contains 32 * everything necessary to render one frame of the terrain. 33 */ 34 class TerrainRenderData 35 { 36 public: 37 TerrainRenderData() : 38 _bindings(0L) { } 39 40 /** Set up the map layers before culling the terrain */ 41 void setup(const Map* map, const RenderBindings& bindings, unsigned frameNum, osgUtil::CullVisitor* cv); 42 43 /** Optimize for best state sharing (when using geometry pooling). Returns total tile count. */ 44 unsigned sortDrawCommands(); 45 46 /** Add a Drawable for a layer. Add these in the order you wish to render them. */ 47 LayerDrawable* addLayerDrawable(const Layer*); 48 49 /** Layers to draw */ 50 LayerDrawableList& layers() { return _layerList; } 51 const LayerDrawableList& layers() const { return _layerList; } 52 53 /** Look up a LayerDrawable by its source layer UID. */ 54 osg::ref_ptr<LayerDrawable>& layer(UID uid) { return _layerMap[uid]; } 55 56 // Draw state shared by all layers during one frame. 57 osg::ref_ptr<DrawState> _drawState; 58 59 // Layers of type RENDERTYPE_TERRAIN_PATCH 60 PatchLayerVector& patchLayers() { return _patchLayers; } 61 62 private: 63 64 LayerDrawableList _layerList; 65 LayerDrawableMap _layerMap; 66 const RenderBindings* _bindings; 67 PatchLayerVector _patchLayers; 68 }; 69 70} } } // namespace 71 72#endif // OSGEARTH_REX_TERRAIN_DRAWABLE_H 73