[148] | 1 | /* |
---|
| 2 | ----------------------------------------------------------------------------- |
---|
| 3 | This source file is part of OGRE |
---|
| 4 | (Object-oriented Graphics Rendering Engine) |
---|
| 5 | For the latest info, see http://www.ogre3d.org/ |
---|
| 6 | |
---|
| 7 | Copyright (c) 2000-2013 Torus Knot Software Ltd |
---|
| 8 | |
---|
| 9 | Permission is hereby granted, free of charge, to any person obtaining a copy |
---|
| 10 | of this software and associated documentation files (the "Software"), to deal |
---|
| 11 | in the Software without restriction, including without limitation the rights |
---|
| 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
---|
| 13 | copies of the Software, and to permit persons to whom the Software is |
---|
| 14 | furnished to do so, subject to the following conditions: |
---|
| 15 | |
---|
| 16 | The above copyright notice and this permission notice shall be included in |
---|
| 17 | all copies or substantial portions of the Software. |
---|
| 18 | |
---|
| 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
| 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
| 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
---|
| 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
| 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
| 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
---|
| 25 | THE SOFTWARE. |
---|
| 26 | ----------------------------------------------------------------------------- |
---|
| 27 | */ |
---|
| 28 | #ifndef __Distance_Lod_Strategy_H__ |
---|
| 29 | #define __Distance_Lod_Strategy_H__ |
---|
| 30 | |
---|
| 31 | #include "OgrePrerequisites.h" |
---|
| 32 | |
---|
| 33 | #include "OgreLodStrategy.h" |
---|
| 34 | #include "OgreSingleton.h" |
---|
| 35 | #include "OgreNode.h" |
---|
| 36 | |
---|
| 37 | namespace Ogre { |
---|
| 38 | /** \addtogroup Core |
---|
| 39 | * @{ |
---|
| 40 | */ |
---|
| 41 | /** \addtogroup LOD |
---|
| 42 | * @{ |
---|
| 43 | */ |
---|
| 44 | |
---|
| 45 | /** Level of detail strategy based on distance from camera. This is an abstract base class for DistanceLodBoxStrategy and DistanceLodSphereStrategy. |
---|
| 46 | @remarks |
---|
| 47 | The purpose of the reference view is to ensure a consistent experience for all users. Monitors of different resolutions and aspect ratios will each have different results for the distance queries. |
---|
| 48 | @par |
---|
| 49 | It depends on gameplay testing. If all testers had 16:9 monitors and 110° FOV, then that's the value you should enter (to ensure as much as possible the experience stays consistent for all other users who don't have a 16:9 monitor and/or use a different FOV). |
---|
| 50 | @par |
---|
| 51 | If all your testers had 4:3 monitors, then enter a 4:3 resolution. |
---|
| 52 | @par |
---|
| 53 | If all your testers had varying resolutions or you just didn't care, then this feature is useless for you and should be disabled (default: disabled). |
---|
| 54 | */ |
---|
| 55 | class _OgreExport DistanceLodStrategy : public LodStrategy |
---|
| 56 | { |
---|
| 57 | protected: |
---|
| 58 | /// @copydoc LodStrategy::getValueImpl |
---|
| 59 | virtual Real getValueImpl(const MovableObject *movableObject, const Camera *camera) const; |
---|
| 60 | |
---|
| 61 | public: |
---|
| 62 | /** Default constructor. */ |
---|
| 63 | DistanceLodStrategy(const String& name); |
---|
| 64 | |
---|
| 65 | /// @copydoc LodStrategy::getBaseValue |
---|
| 66 | virtual Real getBaseValue() const; |
---|
| 67 | |
---|
| 68 | /// @copydoc LodStrategy::transformBias |
---|
| 69 | virtual Real transformBias(Real factor) const; |
---|
| 70 | |
---|
| 71 | /// @copydoc LodStrategy::transformUserValue |
---|
| 72 | virtual Real transformUserValue(Real userValue) const; |
---|
| 73 | |
---|
| 74 | /// @copydoc LodStrategy::getIndex |
---|
| 75 | virtual ushort getIndex(Real value, const Mesh::MeshLodUsageList& meshLodUsageList) const; |
---|
| 76 | |
---|
| 77 | /// @copydoc LodStrategy::getIndex |
---|
| 78 | virtual ushort getIndex(Real value, const Material::LodValueList& materialLodValueList) const; |
---|
| 79 | |
---|
| 80 | /// @copydoc LodStrategy::sort |
---|
| 81 | virtual void sort(Mesh::MeshLodUsageList& meshLodUsageList) const; |
---|
| 82 | |
---|
| 83 | /// @copydoc LodStrategy::isSorted |
---|
| 84 | virtual bool isSorted(const Mesh::LodValueList& values) const; |
---|
| 85 | |
---|
| 86 | /** Get the squared depth from camera to the LOD object */ |
---|
| 87 | virtual Real getSquaredDepth(const MovableObject *movableObject, const Ogre::Camera *camera) const = 0; |
---|
| 88 | |
---|
| 89 | /** Sets the reference view upon which the distances were based. |
---|
| 90 | @note |
---|
| 91 | This automatically enables use of the reference view. |
---|
| 92 | @note |
---|
| 93 | There is no corresponding get method for these values as |
---|
| 94 | they are not saved, but used to compute a reference value. |
---|
| 95 | */ |
---|
| 96 | void setReferenceView(Real viewportWidth, Real viewportHeight, Radian fovY); |
---|
| 97 | |
---|
| 98 | /** Enables to disables use of the reference view. |
---|
| 99 | @note Do not enable use of the reference view before setting it. |
---|
| 100 | */ |
---|
| 101 | void setReferenceViewEnabled(bool value); |
---|
| 102 | |
---|
| 103 | /** Determine if use of the reference view is enabled */ |
---|
| 104 | bool isReferenceViewEnabled() const; |
---|
| 105 | |
---|
| 106 | private: |
---|
| 107 | bool mReferenceViewEnabled; |
---|
| 108 | Real mReferenceViewValue; |
---|
| 109 | |
---|
| 110 | }; |
---|
| 111 | /** @} */ |
---|
| 112 | /** @} */ |
---|
| 113 | |
---|
| 114 | /** \addtogroup Core |
---|
| 115 | * @{ |
---|
| 116 | */ |
---|
| 117 | /** \addtogroup LOD |
---|
| 118 | * @{ |
---|
| 119 | */ |
---|
| 120 | |
---|
| 121 | /** Level of detail strategy based on distance from camera to an object's bounding sphere. |
---|
| 122 | @remarks |
---|
| 123 | The purpose of the reference view is to ensure a consistent experience for all users. Monitors of different resolutions and aspect ratios will each have different results for the distance queries. |
---|
| 124 | @par |
---|
| 125 | It depends on gameplay testing. If all testers had 16:9 monitors and 110° FOV, then that's the value you should enter (to ensure as much as possible the experience stays consistent for all other users who don't have a 16:9 monitor and/or use a different FOV). |
---|
| 126 | @par |
---|
| 127 | If all your testers had 4:3 monitors, then enter a 4:3 resolution. |
---|
| 128 | @par |
---|
| 129 | If all your testers had varying resolutions or you just didn't care, then this feature is useless for you and should be disabled (default: disabled). |
---|
| 130 | */ |
---|
| 131 | class _OgreExport DistanceLodSphereStrategy : public DistanceLodStrategy, public Singleton<DistanceLodSphereStrategy> |
---|
| 132 | { |
---|
| 133 | public: |
---|
| 134 | /** Default constructor. */ |
---|
| 135 | DistanceLodSphereStrategy(); |
---|
| 136 | |
---|
| 137 | /// @copydoc DistanceLodStrategy::getSquaredDepth |
---|
| 138 | Real getSquaredDepth(const MovableObject *movableObject, const Ogre::Camera *camera) const; |
---|
| 139 | |
---|
| 140 | /** Override standard Singleton retrieval. |
---|
| 141 | @remarks |
---|
| 142 | Why do we do this? Well, it's because the Singleton |
---|
| 143 | implementation is in a .h file, which means it gets compiled |
---|
| 144 | into anybody who includes it. This is needed for the |
---|
| 145 | Singleton template to work, but we actually only want it |
---|
| 146 | compiled into the implementation of the class based on the |
---|
| 147 | Singleton, not all of them. If we don't change this, we get |
---|
| 148 | link errors when trying to use the Singleton-based class from |
---|
| 149 | an outside dll. |
---|
| 150 | @par |
---|
| 151 | This method just delegates to the template version anyway, |
---|
| 152 | but the implementation stays in this single compilation unit, |
---|
| 153 | preventing link errors. |
---|
| 154 | */ |
---|
| 155 | static DistanceLodSphereStrategy& getSingleton(void); |
---|
| 156 | /** Override standard Singleton retrieval. |
---|
| 157 | @remarks |
---|
| 158 | Why do we do this? Well, it's because the Singleton |
---|
| 159 | implementation is in a .h file, which means it gets compiled |
---|
| 160 | into anybody who includes it. This is needed for the |
---|
| 161 | Singleton template to work, but we actually only want it |
---|
| 162 | compiled into the implementation of the class based on the |
---|
| 163 | Singleton, not all of them. If we don't change this, we get |
---|
| 164 | link errors when trying to use the Singleton-based class from |
---|
| 165 | an outside dll. |
---|
| 166 | @par |
---|
| 167 | This method just delegates to the template version anyway, |
---|
| 168 | but the implementation stays in this single compilation unit, |
---|
| 169 | preventing link errors. |
---|
| 170 | */ |
---|
| 171 | static DistanceLodSphereStrategy* getSingletonPtr(void); |
---|
| 172 | }; |
---|
| 173 | /** @} */ |
---|
| 174 | /** @} */ |
---|
| 175 | |
---|
| 176 | /** \addtogroup Core |
---|
| 177 | * @{ |
---|
| 178 | */ |
---|
| 179 | /** \addtogroup LOD |
---|
| 180 | * @{ |
---|
| 181 | */ |
---|
| 182 | |
---|
| 183 | /** Level of detail strategy based on distance from camera to an object's bounding box. |
---|
| 184 | @remarks |
---|
| 185 | The purpose of the reference view is to ensure a consistent experience for all users. Monitors of different resolutions and aspect ratios will each have different results for the distance queries. |
---|
| 186 | @par |
---|
| 187 | It depends on gameplay testing. If all testers had 16:9 monitors and 110° FOV, then that's the value you should enter (to ensure as much as possible the experience stays consistent for all other users who don't have a 16:9 monitor and/or use a different FOV). |
---|
| 188 | @par |
---|
| 189 | If all your testers had 4:3 monitors, then enter a 4:3 resolution. |
---|
| 190 | @par |
---|
| 191 | If all your testers had varying resolutions or you just didn't care, then this feature is useless for you and should be disabled (default: disabled). |
---|
| 192 | */ |
---|
| 193 | class _OgreExport DistanceLodBoxStrategy : public DistanceLodStrategy, public Singleton<DistanceLodBoxStrategy> |
---|
| 194 | { |
---|
| 195 | public: |
---|
| 196 | /** Default constructor. */ |
---|
| 197 | DistanceLodBoxStrategy(); |
---|
| 198 | |
---|
| 199 | /// @copydoc DistanceLodStrategy::getSquaredDepth |
---|
| 200 | Real getSquaredDepth(const MovableObject *movableObject, const Ogre::Camera *camera) const; |
---|
| 201 | |
---|
| 202 | /** Override standard Singleton retrieval. |
---|
| 203 | @remarks |
---|
| 204 | Why do we do this? Well, it's because the Singleton |
---|
| 205 | implementation is in a .h file, which means it gets compiled |
---|
| 206 | into anybody who includes it. This is needed for the |
---|
| 207 | Singleton template to work, but we actually only want it |
---|
| 208 | compiled into the implementation of the class based on the |
---|
| 209 | Singleton, not all of them. If we don't change this, we get |
---|
| 210 | link errors when trying to use the Singleton-based class from |
---|
| 211 | an outside dll. |
---|
| 212 | @par |
---|
| 213 | This method just delegates to the template version anyway, |
---|
| 214 | but the implementation stays in this single compilation unit, |
---|
| 215 | preventing link errors. |
---|
| 216 | */ |
---|
| 217 | static DistanceLodBoxStrategy& getSingleton(void); |
---|
| 218 | /** Override standard Singleton retrieval. |
---|
| 219 | @remarks |
---|
| 220 | Why do we do this? Well, it's because the Singleton |
---|
| 221 | implementation is in a .h file, which means it gets compiled |
---|
| 222 | into anybody who includes it. This is needed for the |
---|
| 223 | Singleton template to work, but we actually only want it |
---|
| 224 | compiled into the implementation of the class based on the |
---|
| 225 | Singleton, not all of them. If we don't change this, we get |
---|
| 226 | link errors when trying to use the Singleton-based class from |
---|
| 227 | an outside dll. |
---|
| 228 | @par |
---|
| 229 | This method just delegates to the template version anyway, |
---|
| 230 | but the implementation stays in this single compilation unit, |
---|
| 231 | preventing link errors. |
---|
| 232 | */ |
---|
| 233 | static DistanceLodBoxStrategy* getSingletonPtr(void); |
---|
| 234 | }; |
---|
| 235 | /** @} */ |
---|
| 236 | /** @} */ |
---|
| 237 | |
---|
| 238 | } // namespace |
---|
| 239 | |
---|
| 240 | #endif |
---|