|
| 1 | +/* |
| 2 | + * Copyright (C) 2021 Open Source Robotics Foundation |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | +*/ |
| 17 | + |
| 18 | +#ifndef IGNITION_RENDERING_OGRE2_OGRE2HEIGHTMAP_HH_ |
| 19 | +#define IGNITION_RENDERING_OGRE2_OGRE2HEIGHTMAP_HH_ |
| 20 | + |
| 21 | +#include <memory> |
| 22 | + |
| 23 | +#include "ignition/rendering/base/BaseHeightmap.hh" |
| 24 | +#include "ignition/rendering/ogre2/Ogre2Geometry.hh" |
| 25 | + |
| 26 | +// Ignoring warning: "non dll-interface class |
| 27 | +// 'ignition::rendering::v5::Heightmap' used as base for dll-interface class" |
| 28 | +// because `Heightmap` and `BaseHeightmap` are header-only |
| 29 | +#ifdef _MSC_VER |
| 30 | + #pragma warning(push) |
| 31 | + #pragma warning(disable:4275) |
| 32 | +#endif |
| 33 | + |
| 34 | +namespace Ogre |
| 35 | +{ |
| 36 | + class Camera; |
| 37 | + class Terra; |
| 38 | +} |
| 39 | + |
| 40 | +namespace ignition |
| 41 | +{ |
| 42 | + namespace rendering |
| 43 | + { |
| 44 | + inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { |
| 45 | + // |
| 46 | + // Forward declaration |
| 47 | + class Ogre2HeightmapPrivate; |
| 48 | + |
| 49 | + /// \brief Ogre implementation of a heightmap geometry. |
| 50 | + class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Heightmap |
| 51 | + : public BaseHeightmap<Ogre2Geometry> |
| 52 | + { |
| 53 | + /// \brief Constructor |
| 54 | + /// \param[in] _desc Parameters describing how a |
| 55 | + /// heightmap should be loaded |
| 56 | + public: explicit Ogre2Heightmap(const HeightmapDescriptor &_desc); |
| 57 | + |
| 58 | + /// \brief Destructor |
| 59 | + public: virtual ~Ogre2Heightmap() override; |
| 60 | + |
| 61 | + // Documentation inherited. |
| 62 | + public: virtual void Init() override; |
| 63 | + |
| 64 | + // Documentation inherited. |
| 65 | + public: virtual void PreRender() override; |
| 66 | + |
| 67 | + /// \brief Returns the Terra pointer as it is a movable object that |
| 68 | + /// must be attached to a regular SceneNode |
| 69 | + /// \remarks This behavior is different from ogre1 |
| 70 | + /// \return Terra pointer |
| 71 | + public: virtual Ogre::MovableObject *OgreObject() const override; |
| 72 | + |
| 73 | + /// \brief Returns NULL, heightmap materials don't inherit from |
| 74 | + /// MaterialPtr. |
| 75 | + /// \return Null pointer. |
| 76 | + public: virtual MaterialPtr Material() const override; |
| 77 | + |
| 78 | + /// \brief Has no effect for heightmaps. The material is set through a |
| 79 | + /// HeightmapDescriptor. |
| 80 | + /// \param[in] _material Not used. |
| 81 | + /// \param[in] _unique Not used. |
| 82 | + public: virtual void SetMaterial(MaterialPtr _material, bool _unique) |
| 83 | + override; |
| 84 | + |
| 85 | + /// \internal |
| 86 | + /// \brief Retrieves the internal Terra pointer |
| 87 | + /// \return internal Terra pointer |
| 88 | + public: Ogre::Terra* Terra(); |
| 89 | + |
| 90 | + /// \internal |
| 91 | + /// \brief Must be called before rendering with the camera |
| 92 | + /// that will perform rendering. |
| 93 | + /// |
| 94 | + /// May update shadows if light direction changed |
| 95 | + /// \param[in] _camera Camera about to be used for rendering |
| 96 | + public: void UpdateForRender(Ogre::Camera *_activeCamera); |
| 97 | + |
| 98 | + /// \brief Heightmap should only be created by scene. |
| 99 | + private: friend class OgreScene; |
| 100 | + |
| 101 | + /// \brief Private data class |
| 102 | + private: std::unique_ptr<Ogre2HeightmapPrivate> dataPtr; |
| 103 | + }; |
| 104 | + } |
| 105 | + } |
| 106 | +} |
| 107 | +#ifdef _MSC_VER |
| 108 | + #pragma warning(pop) |
| 109 | +#endif |
| 110 | + |
| 111 | +#endif |
0 commit comments