1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://ogre.sourceforge.net/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __AutoParamDataSource_H_
|
---|
26 | #define __AutoParamDataSource_H_
|
---|
27 |
|
---|
28 | #include "OgrePrerequisites.h"
|
---|
29 | #include "OgreCommon.h"
|
---|
30 | #include "OgreMatrix4.h"
|
---|
31 | #include "OgreVector4.h"
|
---|
32 | #include "OgreLight.h"
|
---|
33 | #include "OgreColourValue.h"
|
---|
34 |
|
---|
35 | namespace Ogre {
|
---|
36 |
|
---|
37 |
|
---|
38 | /** This utility class is used to hold the information used to generate the matrices
|
---|
39 | and other information required to automatically populate GpuProgramParameters.
|
---|
40 | @remarks
|
---|
41 | This class exercises a lazy-update scheme in order to avoid having to update all
|
---|
42 | the information a GpuProgramParameters class could possibly want all the time.
|
---|
43 | It relies on the SceneManager to update it when the base data has changed, and
|
---|
44 | will calculate concatenated matrices etc only when required, passing back precalculated
|
---|
45 | matrices when they are requested more than once when the underlying information has
|
---|
46 | not altered.
|
---|
47 | */
|
---|
48 | class _OgreExport AutoParamDataSource
|
---|
49 | {
|
---|
50 | protected:
|
---|
51 | mutable Matrix4 mWorldMatrix[256];
|
---|
52 | mutable size_t mWorldMatrixCount;
|
---|
53 | mutable Matrix4 mWorldViewMatrix;
|
---|
54 | mutable Matrix4 mViewProjMatrix;
|
---|
55 | mutable Matrix4 mWorldViewProjMatrix;
|
---|
56 | mutable Matrix4 mInverseWorldMatrix;
|
---|
57 | mutable Matrix4 mInverseWorldViewMatrix;
|
---|
58 | mutable Matrix4 mInverseViewMatrix;
|
---|
59 | mutable Matrix4 mInverseTransposeWorldMatrix;
|
---|
60 | mutable Matrix4 mInverseTransposeWorldViewMatrix;
|
---|
61 | mutable Vector4 mCameraPositionObjectSpace;
|
---|
62 | mutable Matrix4 mTextureViewProjMatrix;
|
---|
63 | mutable Matrix4 mViewMatrix;
|
---|
64 | mutable Matrix4 mProjectionMatrix;
|
---|
65 | mutable Real mDirLightExtrusionDistance;
|
---|
66 | mutable Vector4 mCameraPosition;
|
---|
67 |
|
---|
68 | mutable bool mWorldMatrixDirty;
|
---|
69 | mutable bool mViewMatrixDirty;
|
---|
70 | mutable bool mProjMatrixDirty;
|
---|
71 | mutable bool mWorldViewMatrixDirty;
|
---|
72 | mutable bool mViewProjMatrixDirty;
|
---|
73 | mutable bool mWorldViewProjMatrixDirty;
|
---|
74 | mutable bool mInverseWorldMatrixDirty;
|
---|
75 | mutable bool mInverseWorldViewMatrixDirty;
|
---|
76 | mutable bool mInverseViewMatrixDirty;
|
---|
77 | mutable bool mInverseTransposeWorldMatrixDirty;
|
---|
78 | mutable bool mInverseTransposeWorldViewMatrixDirty;
|
---|
79 | mutable bool mCameraPositionObjectSpaceDirty;
|
---|
80 | mutable bool mCameraPositionDirty;
|
---|
81 | mutable bool mTextureViewProjMatrixDirty;
|
---|
82 | mutable ColourValue mAmbientLight;
|
---|
83 | mutable ColourValue mFogColour;
|
---|
84 | mutable Vector4 mFogParams;
|
---|
85 | mutable int mPassNumber;
|
---|
86 |
|
---|
87 | const Renderable* mCurrentRenderable;
|
---|
88 | const Camera* mCurrentCamera;
|
---|
89 | const LightList* mCurrentLightList;
|
---|
90 | const Frustum* mCurrentTextureProjector;
|
---|
91 | const RenderTarget* mCurrentRenderTarget;
|
---|
92 | const Viewport* mCurrentViewport;
|
---|
93 |
|
---|
94 | Light mBlankLight;
|
---|
95 | public:
|
---|
96 | AutoParamDataSource();
|
---|
97 | ~AutoParamDataSource();
|
---|
98 | /** Updates the current renderable */
|
---|
99 | void setCurrentRenderable(const Renderable* rend);
|
---|
100 | /** Updates the current camera */
|
---|
101 | void setCurrentCamera(const Camera* cam);
|
---|
102 | /** Sets the light list that should be used */
|
---|
103 | void setCurrentLightList(const LightList* ll);
|
---|
104 | /** Sets the current texture projector */
|
---|
105 | void setTextureProjector(const Frustum* frust);
|
---|
106 | /** Sets the current render target */
|
---|
107 | void setCurrentRenderTarget(const RenderTarget* target);
|
---|
108 | /** Sets the current viewport */
|
---|
109 | void setCurrentViewport(const Viewport* viewport);
|
---|
110 | /** Sets the shadow extrusion distance to be used for point lights. */
|
---|
111 | void setShadowDirLightExtrusionDistance(Real dist);
|
---|
112 |
|
---|
113 | const Matrix4& getWorldMatrix(void) const;
|
---|
114 | const Matrix4* getWorldMatrixArray(void) const;
|
---|
115 | size_t getWorldMatrixCount(void) const;
|
---|
116 | const Matrix4& getViewMatrix(void) const;
|
---|
117 | const Matrix4& getViewProjectionMatrix(void) const;
|
---|
118 | const Matrix4& getProjectionMatrix(void) const;
|
---|
119 | const Matrix4& getWorldViewProjMatrix(void) const;
|
---|
120 | const Matrix4& getWorldViewMatrix(void) const;
|
---|
121 | const Matrix4& getInverseWorldMatrix(void) const;
|
---|
122 | const Matrix4& getInverseWorldViewMatrix(void) const;
|
---|
123 | const Matrix4& getInverseViewMatrix(void) const;
|
---|
124 | const Matrix4& getInverseTransposeWorldMatrix(void) const;
|
---|
125 | const Matrix4& getInverseTransposeWorldViewMatrix(void) const;
|
---|
126 | const Vector4& getCameraPosition(void) const;
|
---|
127 | const Vector4& getCameraPositionObjectSpace(void) const;
|
---|
128 | /** Get the light which is 'index'th closest to the current object */
|
---|
129 | const Light& getLight(size_t index) const;
|
---|
130 | void setAmbientLightColour(const ColourValue& ambient);
|
---|
131 | const ColourValue& getAmbientLightColour(void) const;
|
---|
132 | void setFog(FogMode mode, const ColourValue& colour, Real expDensity, Real linearStart, Real linearEnd);
|
---|
133 | const ColourValue& getFogColour(void) const;
|
---|
134 | const Vector4& getFogParams(void) const;
|
---|
135 | const Matrix4& getTextureViewProjMatrix(void) const;
|
---|
136 | const RenderTarget* getCurrentRenderTarget(void) const;
|
---|
137 | const Renderable* getCurrentRenderable(void) const;
|
---|
138 | Real getShadowExtrusionDistance(void) const;
|
---|
139 | Matrix4 getInverseViewProjMatrix(void) const;
|
---|
140 | Matrix4 getInverseTransposeViewProjMatrix() const;
|
---|
141 | Matrix4 getTransposeViewProjMatrix() const;
|
---|
142 | Matrix4 getTransposeViewMatrix() const;
|
---|
143 | Matrix4 getInverseTransposeViewMatrix() const;
|
---|
144 | Matrix4 getTransposeProjectionMatrix() const;
|
---|
145 | Matrix4 getInverseProjectionMatrix() const;
|
---|
146 | Matrix4 getInverseTransposeProjectionMatrix() const;
|
---|
147 | Matrix4 getTransposeWorldViewProjMatrix() const;
|
---|
148 | Matrix4 getInverseWorldViewProjMatrix() const;
|
---|
149 | Matrix4 getInverseTransposeWorldViewProjMatrix() const;
|
---|
150 | Matrix4 getTransposeWorldViewMatrix() const;
|
---|
151 | Matrix4 getTransposeWorldMatrix() const;
|
---|
152 | Real getTime(void) const;
|
---|
153 | Real getTime_0_X(Real x) const;
|
---|
154 | Real getCosTime_0_X(Real x) const;
|
---|
155 | Real getSinTime_0_X(Real x) const;
|
---|
156 | Real getTanTime_0_X(Real x) const;
|
---|
157 | Vector4 getTime_0_X_packed(Real x) const;
|
---|
158 | Real getTime_0_1(Real x) const;
|
---|
159 | Real getCosTime_0_1(Real x) const;
|
---|
160 | Real getSinTime_0_1(Real x) const;
|
---|
161 | Real getTanTime_0_1(Real x) const;
|
---|
162 | Vector4 getTime_0_1_packed(Real x) const;
|
---|
163 | Real getTime_0_2Pi(Real x) const;
|
---|
164 | Real getCosTime_0_2Pi(Real x) const;
|
---|
165 | Real getSinTime_0_2Pi(Real x) const;
|
---|
166 | Real getTanTime_0_2Pi(Real x) const;
|
---|
167 | Vector4 getTime_0_2Pi_packed(Real x) const;
|
---|
168 | Real getFrameTime(void) const;
|
---|
169 | Real getFPS() const;
|
---|
170 | Real getViewportWidth() const;
|
---|
171 | Real getViewportHeight() const;
|
---|
172 | Real getInverseViewportWidth() const;
|
---|
173 | Real getInverseViewportHeight() const;
|
---|
174 | Vector3 getViewDirection() const;
|
---|
175 | Vector3 getViewSideVector() const;
|
---|
176 | Vector3 getViewUpVector() const;
|
---|
177 | Real getFOV() const;
|
---|
178 | Real getNearClipDistance() const;
|
---|
179 | Real getFarClipDistance() const;
|
---|
180 | int getPassNumber(void) const;
|
---|
181 | void setPassNumber(const int passNumber);
|
---|
182 | void incPassNumber(void);
|
---|
183 | };
|
---|
184 | }
|
---|
185 |
|
---|
186 | #endif
|
---|