/* -*-c++-*- */ /* osgEarth - Geospatial SDK for OpenSceneGraph * Copyright 2020 Pelican Mapping * http://osgearth.org * * osgEarth is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see */ #ifndef OSGEARTH_TRITON_DRAWABLE_H #define OSGEARTH_TRITON_DRAWABLE_H #include #include #include #include #include #include #include #include #include #include const unsigned int TRITON_OCEAN_MASK = 0x4; // 0100 namespace osgEarth { namespace Triton { class TritonContext; class TritonHeightMap; /** * Custom drawable for rendering the Triton ocean effects */ class TritonDrawable : public osg::Drawable { public: TritonDrawable(TritonContext* TRITON); //! Layer to use as an ocean rendering mask void setMaskLayer(const osgEarth::ImageLayer* maskLayer); //! Height map generator to use to mask out the ocean where the //! terrain has positive elevation void setHeightMapGenerator(TritonHeightMap* heightMap); //! Vertical datum to use to calculate sea level void setVerticalDatum(VerticalDatum* value) { _verticalDatum = value; } //! Gets the Triton Camera associated with an osg Camera ::Triton::Camera* getTritonCam(const osg::Camera* cam) { return _local.get(cam)._tritonCam; } void setPlanarReflectionMap(osg::Texture2D* map); void setPlanarReflectionProjection(osg::RefMatrix* proj); public: // osg::Drawable void drawImplementation(osg::RenderInfo& ri) const override; osg::BoundingBox computeBoundingBox() const override; protected: virtual ~TritonDrawable(); osg::observer_ptr _TRITON; osg::observer_ptr _maskLayer; osg::ref_ptr _cubeMap; osg::ref_ptr _planarReflectionMap; osg::ref_ptr _planarReflectionProjection; mutable osg::ref_ptr _heightMapGenerator; osg::ref_ptr _verticalDatum; osg::ref_ptr _wgs84, _ecef; mutable osg::buffered_object _adapters; struct CameraLocal { ::Triton::Camera* _tritonCam = nullptr; }; mutable PerObjectFastMap _local; }; } } // namespace osgEarth::Triton #endif // OSGEARTH_TRITON_DRAWABLE_H