forked from OGRECave/ogre
/
OgreAutoParamDataSource.h
280 lines (263 loc) · 13.4 KB
/
OgreAutoParamDataSource.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org
Copyright (c) 2000-2014 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __AutoParamDataSource_H_
#define __AutoParamDataSource_H_
#include "OgrePrerequisites.h"
#include "OgreCommon.h"
#include "OgreLight.h"
#include "OgreSceneNode.h"
namespace Ogre {
// forward decls
struct VisibleObjectsBoundsInfo;
/** \addtogroup Core
* @{
*/
/** \addtogroup Materials
* @{
*/
/** This utility class is used to hold the information used to generate the matrices
and other information required to automatically populate GpuProgramParameters.
This class exercises a lazy-update scheme in order to avoid having to update all
the information a GpuProgramParameters class could possibly want all the time.
It relies on the SceneManager to update it when the base data has changed, and
will calculate concatenated matrices etc only when required, passing back precalculated
matrices when they are requested more than once when the underlying information has
not altered.
*/
class _OgreExport AutoParamDataSource : public SceneMgtAlloc
{
private:
const Light& getLight(size_t index) const;
mutable Affine3 mWorldMatrix[256];
mutable Affine3 mLocalMatrix[256];
mutable size_t mWorldMatrixCount;
mutable const Affine3* mWorldMatrixArray;
mutable size_t mLocalMatrixCount;
mutable const Affine3* mLocalMatrixArray;
mutable Affine3 mWorldViewMatrix;
mutable Matrix4 mViewProjMatrix;
mutable Matrix4 mWorldViewProjMatrix;
mutable Affine3 mInverseWorldMatrix;
mutable Affine3 mInverseWorldViewMatrix;
mutable Affine3 mInverseViewMatrix;
mutable Matrix4 mInverseTransposeWorldMatrix;
mutable Matrix4 mInverseTransposeWorldViewMatrix;
mutable Vector4 mCameraPosition;
mutable Vector4 mCameraPositionObjectSpace;
mutable Matrix4 mTextureViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable Matrix4 mTextureWorldViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable Matrix4 mSpotlightViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable Matrix4 mSpotlightWorldViewProjMatrix[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable Vector4 mShadowCamDepthRanges[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable Affine3 mViewMatrix;
mutable Matrix4 mProjectionMatrix;
mutable Real mDirLightExtrusionDistance;
mutable Real mPointLightExtrusionDistance;
mutable Vector4 mLodCameraPosition;
mutable Vector4 mLodCameraPositionObjectSpace;
mutable bool mLocalMatrixDirty;
mutable bool mWorldMatrixDirty;
mutable bool mViewMatrixDirty;
mutable bool mProjMatrixDirty;
mutable bool mWorldViewMatrixDirty;
mutable bool mViewProjMatrixDirty;
mutable bool mWorldViewProjMatrixDirty;
mutable bool mInverseWorldMatrixDirty;
mutable bool mInverseWorldViewMatrixDirty;
mutable bool mInverseViewMatrixDirty;
mutable bool mInverseTransposeWorldMatrixDirty;
mutable bool mInverseTransposeWorldViewMatrixDirty;
mutable bool mCameraPositionDirty;
mutable bool mCameraPositionObjectSpaceDirty;
mutable bool mTextureViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable bool mTextureWorldViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable bool mSpotlightViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable bool mSpotlightWorldViewProjMatrixDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS];
mutable bool mShadowCamDepthRangesDirty[OGRE_MAX_SIMULTANEOUS_LIGHTS];
ColourValue mAmbientLight;
ColourValue mFogColour;
Vector4f mFogParams;
Vector4f mPointParams;
int mPassNumber;
mutable Vector4 mSceneDepthRange;
mutable bool mSceneDepthRangeDirty;
mutable bool mLodCameraPositionDirty;
mutable bool mLodCameraPositionObjectSpaceDirty;
const Renderable* mCurrentRenderable;
const Camera* mCurrentCamera;
bool mCameraRelativeRendering;
Vector3 mCameraRelativePosition;
const LightList* mCurrentLightList;
const Frustum* mCurrentTextureProjector[OGRE_MAX_SIMULTANEOUS_LIGHTS];
const RenderTarget* mCurrentRenderTarget;
const Viewport* mCurrentViewport;
const SceneManager* mCurrentSceneManager;
const VisibleObjectsBoundsInfo* mMainCamBoundsInfo;
const Pass* mCurrentPass;
SceneNode mDummyNode;
Light mBlankLight;
public:
AutoParamDataSource();
/** Updates the current renderable */
void setCurrentRenderable(const Renderable* rend);
/** Sets the world matrices, avoid query from renderable again */
void setWorldMatrices(const Affine3* m, size_t count);
/** Updates the current camera */
void setCurrentCamera(const Camera* cam, bool useCameraRelative);
/** Sets the light list that should be used, and it's base index from the global list */
void setCurrentLightList(const LightList* ll);
/** Sets the current texture projector for a index */
void setTextureProjector(const Frustum* frust, size_t index);
/** Sets the current render target */
void setCurrentRenderTarget(const RenderTarget* target);
/** Sets the current viewport */
void setCurrentViewport(const Viewport* viewport);
/** Sets the shadow extrusion distance to be used for dir lights. */
void setShadowDirLightExtrusionDistance(Real dist);
/** Sets the shadow extrusion distance to be used for point lights. */
void setShadowPointLightExtrusionDistance(Real dist);
/** Sets the main camera's scene bounding information */
void setMainCamBoundsInfo(VisibleObjectsBoundsInfo* info);
/** Set the current scene manager for enquiring on demand */
void setCurrentSceneManager(const SceneManager* sm);
/** Sets the current pass */
void setCurrentPass(const Pass* pass);
/** Returns the current bounded camera */
const Camera* getCurrentCamera() const;
const Affine3& getLocalMatrix (void) const;
const Affine3& getWorldMatrix(void) const;
const Affine3* getLocalMatrixArray (void) const;
const Affine3* getWorldMatrixArray(void) const;
size_t getLocalMatrixCount (void) const;
size_t getWorldMatrixCount(void) const;
const Affine3& getViewMatrix(void) const;
const Matrix4& getViewProjectionMatrix(void) const;
const Matrix4& getProjectionMatrix(void) const;
const Matrix4& getWorldViewProjMatrix(void) const;
const Affine3& getWorldViewMatrix(void) const;
const Affine3& getInverseWorldMatrix(void) const;
const Affine3& getInverseWorldViewMatrix(void) const;
const Affine3& getInverseViewMatrix(void) const;
const Matrix4& getInverseTransposeWorldMatrix(void) const;
const Matrix4& getInverseTransposeWorldViewMatrix(void) const;
const Vector4& getCameraPosition(void) const;
const Vector4& getCameraPositionObjectSpace(void) const;
const Vector4 getCameraRelativePosition(void) const;
const Vector4& getLodCameraPosition(void) const;
const Vector4& getLodCameraPositionObjectSpace(void) const;
bool hasLightList() const { return mCurrentLightList != 0; }
/** Get the light which is 'index'th closest to the current object */
float getLightNumber(size_t index) const;
float getLightCount() const;
float getLightCastsShadows(size_t index) const;
const ColourValue& getLightDiffuseColour(size_t index) const;
const ColourValue& getLightSpecularColour(size_t index) const;
const ColourValue getLightDiffuseColourWithPower(size_t index) const;
const ColourValue getLightSpecularColourWithPower(size_t index) const;
Vector3 getLightPosition(size_t index) const;
Vector4 getLightAs4DVector(size_t index) const;
Vector3 getLightDirection(size_t index) const;
Real getLightPowerScale(size_t index) const;
const Vector4f& getLightAttenuation(size_t index) const;
Vector4f getSpotlightParams(size_t index) const;
void setAmbientLightColour(const ColourValue& ambient);
const ColourValue& getAmbientLightColour(void) const;
const ColourValue& getSurfaceAmbientColour(void) const;
const ColourValue& getSurfaceDiffuseColour(void) const;
const ColourValue& getSurfaceSpecularColour(void) const;
const ColourValue& getSurfaceEmissiveColour(void) const;
Real getSurfaceShininess(void) const;
Real getSurfaceAlphaRejectionValue(void) const;
ColourValue getDerivedAmbientLightColour(void) const;
ColourValue getDerivedSceneColour(void) const;
void setFog(FogMode mode, const ColourValue& colour, Real expDensity, Real linearStart, Real linearEnd);
const ColourValue& getFogColour(void) const;
const Vector4f& getFogParams(void) const;
void setPointParameters(bool attenuation, const Vector4f& params);
const Vector4f& getPointParams() const;
const Matrix4& getTextureViewProjMatrix(size_t index) const;
const Matrix4& getTextureWorldViewProjMatrix(size_t index) const;
const Matrix4& getSpotlightViewProjMatrix(size_t index) const;
const Matrix4& getSpotlightWorldViewProjMatrix(size_t index) const;
const Matrix4& getTextureTransformMatrix(size_t index) const;
const RenderTarget* getCurrentRenderTarget(void) const;
const Renderable* getCurrentRenderable(void) const;
const Pass* getCurrentPass(void) const;
Vector4f getTextureSize(size_t index) const;
Vector4f getInverseTextureSize(size_t index) const;
Vector4f getPackedTextureSize(size_t index) const;
Real getShadowExtrusionDistance(void) const;
const Vector4& getSceneDepthRange() const;
const Vector4& getShadowSceneDepthRange(size_t index) const;
const ColourValue& getShadowColour() const;
Matrix4 getInverseViewProjMatrix(void) const;
Matrix4 getInverseTransposeViewProjMatrix() const;
Matrix4 getTransposeViewProjMatrix() const;
Matrix4 getTransposeViewMatrix() const;
Matrix4 getInverseTransposeViewMatrix() const;
Matrix4 getTransposeProjectionMatrix() const;
Matrix4 getInverseProjectionMatrix() const;
Matrix4 getInverseTransposeProjectionMatrix() const;
Matrix4 getTransposeWorldViewProjMatrix() const;
Matrix4 getInverseWorldViewProjMatrix() const;
Matrix4 getInverseTransposeWorldViewProjMatrix() const;
Matrix4 getTransposeWorldViewMatrix() const;
Matrix4 getTransposeWorldMatrix() const;
Real getTime(void) const;
Real getTime_0_X(Real x) const;
Real getCosTime_0_X(Real x) const;
Real getSinTime_0_X(Real x) const;
Real getTanTime_0_X(Real x) const;
Vector4f getTime_0_X_packed(Real x) const;
Real getTime_0_1(Real x) const;
Real getCosTime_0_1(Real x) const;
Real getSinTime_0_1(Real x) const;
Real getTanTime_0_1(Real x) const;
Vector4f getTime_0_1_packed(Real x) const;
Real getTime_0_2Pi(Real x) const;
Real getCosTime_0_2Pi(Real x) const;
Real getSinTime_0_2Pi(Real x) const;
Real getTanTime_0_2Pi(Real x) const;
Vector4f getTime_0_2Pi_packed(Real x) const;
Real getFrameTime(void) const;
Real getFPS() const;
Real getViewportWidth() const;
Real getViewportHeight() const;
Real getInverseViewportWidth() const;
Real getInverseViewportHeight() const;
Vector3 getViewDirection() const;
Vector3 getViewSideVector() const;
Vector3 getViewUpVector() const;
Real getFOV() const;
Real getNearClipDistance() const;
Real getFarClipDistance() const;
int getPassNumber(void) const;
void setPassNumber(const int passNumber);
void incPassNumber(void);
void updateLightCustomGpuParameter(const GpuProgramParameters::AutoConstantEntry& constantEntry, GpuProgramParameters *params) const;
};
/** @} */
/** @} */
}
#endif