Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreAutoParamDataSource.h @ 1

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