/src/ogre/OgreMain/include/OgreAutoParamDataSource.h
Line | Count | Source (jump to first uncovered line) |
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-2014 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 __AutoParamDataSource_H_ |
29 | | #define __AutoParamDataSource_H_ |
30 | | |
31 | | #include "OgrePrerequisites.h" |
32 | | #include "OgreCommon.h" |
33 | | #include "OgreLight.h" |
34 | | #include "OgreSceneNode.h" |
35 | | |
36 | | namespace Ogre { |
37 | | |
38 | | // forward decls |
39 | | struct VisibleObjectsBoundsInfo; |
40 | | |
41 | | /** \addtogroup Core |
42 | | * @{ |
43 | | */ |
44 | | /** \addtogroup Materials |
45 | | * @{ |
46 | | */ |
47 | | |
48 | | |
49 | | /** This utility class is used to hold the information used to generate the matrices |
50 | | and other information required to automatically populate GpuProgramParameters. |
51 | | |
52 | | This class exercises a lazy-update scheme in order to avoid having to update all |
53 | | the information a GpuProgramParameters class could possibly want all the time. |
54 | | It relies on the SceneManager to update it when the base data has changed, and |
55 | | will calculate concatenated matrices etc only when required, passing back precalculated |
56 | | matrices when they are requested more than once when the underlying information has |
57 | | not altered. |
58 | | */ |
59 | | class _OgreExport AutoParamDataSource : public SceneMgtAlloc |
60 | | { |
61 | | private: |
62 | | const Light& getLight(size_t index) const; |
63 | | mutable Affine3 mWorldMatrix[OGRE_MAX_NUM_BONES + 1]; |
64 | | mutable size_t mWorldMatrixCount; |
65 | | mutable const Affine3* mWorldMatrixArray; |
66 | | mutable Affine3 mWorldViewMatrix; |
67 | | mutable Matrix4 mViewProjMatrix; |
68 | | mutable Matrix4 mWorldViewProjMatrix; |
69 | | mutable Affine3 mInverseWorldMatrix; |
70 | | mutable Affine3 mInverseWorldViewMatrix; |
71 | | mutable Affine3 mInverseViewMatrix; |
72 | | mutable Matrix4 mInverseTransposeWorldMatrix; |
73 | | mutable Matrix4 mInverseTransposeWorldViewMatrix; |
74 | | mutable Vector4 mCameraPosition; |
75 | | mutable Vector4 mCameraPositionObjectSpace; |
76 | | mutable Matrix4 mTextureViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
77 | | mutable Matrix4 mTextureWorldViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
78 | | mutable Matrix4 mSpotlightViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
79 | | mutable Matrix4 mSpotlightWorldViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
80 | | mutable Vector4 mShadowCamDepthRanges[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
81 | | mutable Affine3 mViewMatrix; |
82 | | mutable Matrix4 mProjectionMatrix; |
83 | | mutable Real mDirLightExtrusionDistance; |
84 | | mutable Real mPointLightExtrusionDistance; |
85 | | mutable Vector4 mLodCameraPosition; |
86 | | mutable Vector4 mLodCameraPositionObjectSpace; |
87 | | |
88 | | mutable bool mWorldMatrixDirty; |
89 | | mutable bool mViewMatrixDirty; |
90 | | mutable bool mProjMatrixDirty; |
91 | | mutable bool mWorldViewMatrixDirty; |
92 | | mutable bool mViewProjMatrixDirty; |
93 | | mutable bool mWorldViewProjMatrixDirty; |
94 | | mutable bool mInverseWorldMatrixDirty; |
95 | | mutable bool mInverseWorldViewMatrixDirty; |
96 | | mutable bool mInverseViewMatrixDirty; |
97 | | mutable bool mInverseTransposeWorldMatrixDirty; |
98 | | mutable bool mInverseTransposeWorldViewMatrixDirty; |
99 | | mutable bool mCameraPositionDirty; |
100 | | mutable bool mCameraPositionObjectSpaceDirty; |
101 | | mutable bool mTextureViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
102 | | mutable bool mTextureWorldViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
103 | | mutable bool mSpotlightViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
104 | | mutable bool mSpotlightWorldViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
105 | | mutable bool mShadowCamDepthRangesDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
106 | | ColourValue mAmbientLight; |
107 | | ColourValue mFogColour; |
108 | | ColourValue mShadowColour; |
109 | | Vector4f mFogParams; |
110 | | Vector4f mPointParams; |
111 | | int mPassNumber; |
112 | | mutable Vector4 mSceneDepthRange; |
113 | | mutable bool mSceneDepthRangeDirty; |
114 | | mutable bool mLodCameraPositionDirty; |
115 | | mutable bool mLodCameraPositionObjectSpaceDirty; |
116 | | |
117 | | const Renderable* mCurrentRenderable; |
118 | | const Camera* mCurrentCamera; |
119 | | std::vector<const Camera*> mCameraArray; |
120 | | bool mCameraRelativeRendering; |
121 | | Vector3 mCameraRelativePosition; |
122 | | const LightList* mCurrentLightList; |
123 | | const Frustum* mCurrentTextureProjector[OGRE_MAX_SIMULTANEOUS_LIGHTS]; |
124 | | const RenderTarget* mCurrentRenderTarget; |
125 | | const Viewport* mCurrentViewport; |
126 | | const SceneManager* mCurrentSceneManager; |
127 | | const VisibleObjectsBoundsInfo* mMainCamBoundsInfo; |
128 | | const Pass* mCurrentPass; |
129 | | |
130 | | SceneNode mDummyNode; |
131 | | Light mBlankLight; |
132 | | public: |
133 | | AutoParamDataSource(); |
134 | | /** Updates the current renderable */ |
135 | | void setCurrentRenderable(const Renderable* rend); |
136 | | /** Sets the world matrices, avoid query from renderable again */ |
137 | | void setWorldMatrices(const Affine3* m, size_t count); |
138 | | /** Updates the current camera */ |
139 | | void setCurrentCamera(const Camera* cam, bool useCameraRelative); |
140 | | void setCameraArray(const std::vector<const Camera*> cameras); |
141 | | /** Sets the light list that should be used, and it's base index from the global list */ |
142 | | void setCurrentLightList(const LightList* ll); |
143 | | /** Sets the current texture projector for a index */ |
144 | | void setTextureProjector(const Frustum* frust, size_t index); |
145 | | /** Sets the current render target */ |
146 | | void setCurrentRenderTarget(const RenderTarget* target); |
147 | | /** Sets the current viewport */ |
148 | | void setCurrentViewport(const Viewport* viewport); |
149 | | /** Sets the shadow extrusion distance to be used for dir lights. */ |
150 | | void setShadowDirLightExtrusionDistance(Real dist); |
151 | | /** Sets the shadow extrusion distance to be used for point lights. */ |
152 | | void setShadowPointLightExtrusionDistance(Real dist); |
153 | | /** Sets the main camera's scene bounding information */ |
154 | | void setMainCamBoundsInfo(VisibleObjectsBoundsInfo* info); |
155 | | /** Set the current scene manager for enquiring on demand */ |
156 | | void setCurrentSceneManager(const SceneManager* sm); |
157 | | /** Sets the current pass */ |
158 | | void setCurrentPass(const Pass* pass); |
159 | | |
160 | | /** Returns the current bounded camera */ |
161 | | const Camera* getCurrentCamera() const; |
162 | | |
163 | | const Affine3& getWorldMatrix(void) const; |
164 | | const Affine3* getBoneMatrixArray(void) const; |
165 | 0 | OGRE_DEPRECATED const Affine3* getWorldMatrixArray(void) const { return getBoneMatrixArray(); } |
166 | | size_t getBoneMatrixCount(void) const; |
167 | 0 | OGRE_DEPRECATED size_t getWorldMatrixCount(void) const { return getBoneMatrixCount(); } |
168 | | const Affine3& getViewMatrix(void) const; |
169 | | Affine3 getViewMatrix(const Camera* cam) const; |
170 | | const Matrix4& getViewProjectionMatrix(void) const; |
171 | | const Matrix4& getProjectionMatrix(void) const; |
172 | | Matrix4 getProjectionMatrix(const Camera* cam) const; |
173 | | const Matrix4& getWorldViewProjMatrix(void) const; |
174 | | Matrix4 getWorldViewProjMatrix(size_t index) const; |
175 | | const Affine3& getWorldViewMatrix(void) const; |
176 | | const Affine3& getInverseWorldMatrix(void) const; |
177 | | const Affine3& getInverseWorldViewMatrix(void) const; |
178 | | const Affine3& getInverseViewMatrix(void) const; |
179 | | const Matrix4& getInverseTransposeWorldMatrix(void) const; |
180 | | const Matrix4& getInverseTransposeWorldViewMatrix(void) const; |
181 | | const Vector4& getCameraPosition(void) const; |
182 | | const Vector4& getCameraPositionObjectSpace(void) const; |
183 | | const Vector4 getCameraRelativePosition(void) const; |
184 | | const Vector4& getLodCameraPosition(void) const; |
185 | | const Vector4& getLodCameraPositionObjectSpace(void) const; |
186 | 0 | bool hasLightList() const { return mCurrentLightList != 0; } |
187 | | /** Get the light which is 'index'th closest to the current object */ |
188 | | float getLightNumber(size_t index) const; |
189 | | float getLightCount() const; |
190 | | float getLightCastsShadows(size_t index) const; |
191 | | const ColourValue& getLightDiffuseColour(size_t index) const; |
192 | | const ColourValue& getLightSpecularColour(size_t index) const; |
193 | | const ColourValue getLightDiffuseColourWithPower(size_t index) const; |
194 | | const ColourValue getLightSpecularColourWithPower(size_t index) const; |
195 | | Vector3 getLightPosition(size_t index) const; |
196 | | Vector4 getLightAs4DVector(size_t index) const; |
197 | | Vector3 getLightDirection(size_t index) const; |
198 | | Real getLightPowerScale(size_t index) const; |
199 | | Vector4f getLightAttenuation(size_t index) const; |
200 | | Vector4f getSpotlightParams(size_t index) const; |
201 | | void setAmbientLightColour(const ColourValue& ambient); |
202 | | const ColourValue& getAmbientLightColour(void) const; |
203 | | const ColourValue& getSurfaceAmbientColour(void) const; |
204 | | const ColourValue& getSurfaceDiffuseColour(void) const; |
205 | | const ColourValue& getSurfaceSpecularColour(void) const; |
206 | | const ColourValue& getSurfaceEmissiveColour(void) const; |
207 | | Real getSurfaceShininess(void) const; |
208 | | Real getSurfaceAlphaRejectionValue(void) const; |
209 | | ColourValue getDerivedAmbientLightColour(void) const; |
210 | | ColourValue getDerivedSceneColour(void) const; |
211 | | void setFog(FogMode mode, const ColourValue& colour, Real expDensity, Real linearStart, Real linearEnd); |
212 | | const ColourValue& getFogColour(void) const; |
213 | | const Vector4f& getFogParams(void) const; |
214 | | void setPointParameters(bool attenuation, const Vector4f& params); |
215 | | const Vector4f& getPointParams() const; |
216 | | const Matrix4& getTextureViewProjMatrix(size_t index) const; |
217 | | const Matrix4& getTextureWorldViewProjMatrix(size_t index) const; |
218 | | const Matrix4& getSpotlightViewProjMatrix(size_t index) const; |
219 | | const Matrix4& getSpotlightWorldViewProjMatrix(size_t index) const; |
220 | | const Matrix4& getTextureTransformMatrix(size_t index) const; |
221 | | const RenderTarget* getCurrentRenderTarget(void) const; |
222 | | const Renderable* getCurrentRenderable(void) const; |
223 | | const Pass* getCurrentPass(void) const; |
224 | | Vector4f getTextureSize(size_t index) const; |
225 | | Vector4f getInverseTextureSize(size_t index) const; |
226 | | Vector4f getPackedTextureSize(size_t index) const; |
227 | | Real getShadowExtrusionDistance(void) const; |
228 | | const Vector4& getSceneDepthRange() const; |
229 | | const Vector4& getShadowSceneDepthRange(size_t index) const; |
230 | | void setShadowColour(const ColourValue& colour); |
231 | | const ColourValue& getShadowColour() const; |
232 | | Matrix4 getInverseViewProjMatrix(void) const; |
233 | | Matrix4 getInverseTransposeViewProjMatrix() const; |
234 | | Matrix4 getTransposeViewProjMatrix() const; |
235 | | Matrix4 getTransposeViewMatrix() const; |
236 | | Matrix4 getInverseTransposeViewMatrix() const; |
237 | | Matrix4 getTransposeProjectionMatrix() const; |
238 | | Matrix4 getInverseProjectionMatrix() const; |
239 | | Matrix4 getInverseTransposeProjectionMatrix() const; |
240 | | Matrix4 getTransposeWorldViewProjMatrix() const; |
241 | | Matrix4 getInverseWorldViewProjMatrix() const; |
242 | | Matrix4 getInverseTransposeWorldViewProjMatrix() const; |
243 | | Matrix4 getTransposeWorldViewMatrix() const; |
244 | | Matrix4 getTransposeWorldMatrix() const; |
245 | | Real getTime(void) const; |
246 | | Real getTime_0_X(Real x) const; |
247 | | Real getCosTime_0_X(Real x) const; |
248 | | Real getSinTime_0_X(Real x) const; |
249 | | Real getTanTime_0_X(Real x) const; |
250 | | Vector4f getTime_0_X_packed(Real x) const; |
251 | | Real getTime_0_1(Real x) const; |
252 | | Real getCosTime_0_1(Real x) const; |
253 | | Real getSinTime_0_1(Real x) const; |
254 | | Real getTanTime_0_1(Real x) const; |
255 | | Vector4f getTime_0_1_packed(Real x) const; |
256 | | Real getTime_0_2Pi(Real x) const; |
257 | | Real getCosTime_0_2Pi(Real x) const; |
258 | | Real getSinTime_0_2Pi(Real x) const; |
259 | | Real getTanTime_0_2Pi(Real x) const; |
260 | | Vector4f getTime_0_2Pi_packed(Real x) const; |
261 | | Real getFrameTime(void) const; |
262 | | Real getFPS() const; |
263 | | Real getViewportWidth() const; |
264 | | Real getViewportHeight() const; |
265 | | Real getInverseViewportWidth() const; |
266 | | Real getInverseViewportHeight() const; |
267 | | Vector3 getViewDirection() const; |
268 | | Vector3 getViewSideVector() const; |
269 | | Vector3 getViewUpVector() const; |
270 | | float getFOV() const; |
271 | | float getNearClipDistance() const; |
272 | | float getFarClipDistance() const; |
273 | | int getPassNumber(void) const; |
274 | | int getMaterialLodIndex() const; |
275 | | void setPassNumber(const int passNumber); |
276 | | void incPassNumber(void); |
277 | | void updateLightCustomGpuParameter(const GpuProgramParameters::AutoConstantEntry& constantEntry, GpuProgramParameters *params) const; |
278 | | }; |
279 | | /** @} */ |
280 | | /** @} */ |
281 | | } |
282 | | |
283 | | #endif |