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 __Pixel_Count_Lod_Strategy_H__ |
---|
29 | #define __Pixel_Count_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 | |
---|
39 | /** \addtogroup Core |
---|
40 | * @{ |
---|
41 | */ |
---|
42 | /** \addtogroup LOD |
---|
43 | * @{ |
---|
44 | */ |
---|
45 | /** Abstract base class for level of detail strategy based on pixel count approximations from bounding sphere projection. */ |
---|
46 | class _OgreExport PixelCountLodStrategy : public LodStrategy |
---|
47 | { |
---|
48 | protected: |
---|
49 | /// @copydoc LodStrategy::getValueImpl |
---|
50 | virtual Real getValueImpl(const MovableObject *movableObject, const Camera *camera) const = 0; |
---|
51 | |
---|
52 | public: |
---|
53 | /** Default constructor. */ |
---|
54 | PixelCountLodStrategy(const String& name); |
---|
55 | |
---|
56 | /// @copydoc LodStrategy::getBaseValue |
---|
57 | virtual Real getBaseValue() const; |
---|
58 | |
---|
59 | /// @copydoc LodStrategy::transformBias |
---|
60 | virtual Real transformBias(Real factor) const; |
---|
61 | |
---|
62 | /// @copydoc LodStrategy::getIndex |
---|
63 | virtual ushort getIndex(Real value, const Mesh::MeshLodUsageList& meshLodUsageList) const; |
---|
64 | |
---|
65 | /// @copydoc LodStrategy::getIndex |
---|
66 | virtual ushort getIndex(Real value, const Material::LodValueList& materialLodValueList) const; |
---|
67 | |
---|
68 | /// @copydoc LodStrategy::sort |
---|
69 | virtual void sort(Mesh::MeshLodUsageList& meshLodUsageList) const; |
---|
70 | |
---|
71 | /// @copydoc LodStrategy::isSorted |
---|
72 | virtual bool isSorted(const Mesh::LodValueList& values) const; |
---|
73 | }; |
---|
74 | /** @} */ |
---|
75 | /** @} */ |
---|
76 | |
---|
77 | class _OgreExport AbsolutePixelCountLodStrategy : public PixelCountLodStrategy, public Singleton<AbsolutePixelCountLodStrategy> |
---|
78 | { |
---|
79 | public: |
---|
80 | /** Default constructor. */ |
---|
81 | AbsolutePixelCountLodStrategy(); |
---|
82 | |
---|
83 | /// @copydoc LodStrategy::getValueImpl |
---|
84 | Real getValueImpl(const MovableObject *movableObject, const Camera *camera) const; |
---|
85 | |
---|
86 | /** Override standard Singleton retrieval. |
---|
87 | @remarks |
---|
88 | Why do we do this? Well, it's because the Singleton |
---|
89 | implementation is in a .h file, which means it gets compiled |
---|
90 | into anybody who includes it. This is needed for the |
---|
91 | Singleton template to work, but we actually only want it |
---|
92 | compiled into the implementation of the class based on the |
---|
93 | Singleton, not all of them. If we don't change this, we get |
---|
94 | link errors when trying to use the Singleton-based class from |
---|
95 | an outside dll. |
---|
96 | @par |
---|
97 | This method just delegates to the template version anyway, |
---|
98 | but the implementation stays in this single compilation unit, |
---|
99 | preventing link errors. |
---|
100 | */ |
---|
101 | static AbsolutePixelCountLodStrategy& getSingleton(void); |
---|
102 | /** Override standard Singleton retrieval. |
---|
103 | @remarks |
---|
104 | Why do we do this? Well, it's because the Singleton |
---|
105 | implementation is in a .h file, which means it gets compiled |
---|
106 | into anybody who includes it. This is needed for the |
---|
107 | Singleton template to work, but we actually only want it |
---|
108 | compiled into the implementation of the class based on the |
---|
109 | Singleton, not all of them. If we don't change this, we get |
---|
110 | link errors when trying to use the Singleton-based class from |
---|
111 | an outside dll. |
---|
112 | @par |
---|
113 | This method just delegates to the template version anyway, |
---|
114 | but the implementation stays in this single compilation unit, |
---|
115 | preventing link errors. |
---|
116 | */ |
---|
117 | static AbsolutePixelCountLodStrategy* getSingletonPtr(void); |
---|
118 | }; |
---|
119 | /** @} */ |
---|
120 | /** @} */ |
---|
121 | |
---|
122 | class _OgreExport ScreenRatioPixelCountLodStrategy : public PixelCountLodStrategy, public Singleton<ScreenRatioPixelCountLodStrategy> |
---|
123 | { |
---|
124 | public: |
---|
125 | /** Default constructor. */ |
---|
126 | ScreenRatioPixelCountLodStrategy(); |
---|
127 | |
---|
128 | /// @copydoc LodStrategy::getValueImpl |
---|
129 | Real getValueImpl(const MovableObject *movableObject, const Camera *camera) const; |
---|
130 | |
---|
131 | /** Override standard Singleton retrieval. |
---|
132 | @remarks |
---|
133 | Why do we do this? Well, it's because the Singleton |
---|
134 | implementation is in a .h file, which means it gets compiled |
---|
135 | into anybody who includes it. This is needed for the |
---|
136 | Singleton template to work, but we actually only want it |
---|
137 | compiled into the implementation of the class based on the |
---|
138 | Singleton, not all of them. If we don't change this, we get |
---|
139 | link errors when trying to use the Singleton-based class from |
---|
140 | an outside dll. |
---|
141 | @par |
---|
142 | This method just delegates to the template version anyway, |
---|
143 | but the implementation stays in this single compilation unit, |
---|
144 | preventing link errors. |
---|
145 | */ |
---|
146 | static ScreenRatioPixelCountLodStrategy& getSingleton(void); |
---|
147 | /** Override standard Singleton retrieval. |
---|
148 | @remarks |
---|
149 | Why do we do this? Well, it's because the Singleton |
---|
150 | implementation is in a .h file, which means it gets compiled |
---|
151 | into anybody who includes it. This is needed for the |
---|
152 | Singleton template to work, but we actually only want it |
---|
153 | compiled into the implementation of the class based on the |
---|
154 | Singleton, not all of them. If we don't change this, we get |
---|
155 | link errors when trying to use the Singleton-based class from |
---|
156 | an outside dll. |
---|
157 | @par |
---|
158 | This method just delegates to the template version anyway, |
---|
159 | but the implementation stays in this single compilation unit, |
---|
160 | preventing link errors. |
---|
161 | */ |
---|
162 | static ScreenRatioPixelCountLodStrategy* getSingletonPtr(void); |
---|
163 | }; |
---|
164 | /** @} */ |
---|
165 | /** @} */ |
---|
166 | |
---|
167 | } // namespace |
---|
168 | |
---|
169 | #endif |
---|