source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreAutoParamDataSource.h @ 1092

Revision 1092, 7.3 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://ogre.sourceforge.net/
6
7Copyright (c) 2000-2005 The OGRE Team
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-----------------------------------------------------------------------------
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
35namespace 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 mProjectionMatrix;
64                mutable Real mDirLightExtrusionDistance;
65        mutable Vector4 mCameraPosition;
66               
67        mutable bool mWorldMatrixDirty;
68        mutable bool mWorldViewMatrixDirty;
69        mutable bool mViewProjMatrixDirty;
70        mutable bool mWorldViewProjMatrixDirty;
71        mutable bool mInverseWorldMatrixDirty;
72        mutable bool mInverseWorldViewMatrixDirty;
73        mutable bool mInverseViewMatrixDirty;
74        mutable bool mInverseTransposeWorldMatrixDirty;
75        mutable bool mInverseTransposeWorldViewMatrixDirty;
76        mutable bool mCameraPositionObjectSpaceDirty;
77        mutable bool mCameraPositionDirty;
78        mutable bool mTextureViewProjMatrixDirty;
79                mutable ColourValue mAmbientLight;
80
81        const Renderable* mCurrentRenderable;
82        const Camera* mCurrentCamera;
83        const LightList* mCurrentLightList;
84        const Frustum* mCurrentTextureProjector;
85        const RenderTarget* mCurrentRenderTarget;
86
87        Light mBlankLight;
88    public:
89        AutoParamDataSource();
90        ~AutoParamDataSource();
91        /** Updates the current renderable */
92        void setCurrentRenderable(const Renderable* rend);
93        /** Updates the current camera */
94        void setCurrentCamera(const Camera* cam);
95        /** Sets the light list that should be used */
96        void setCurrentLightList(const LightList* ll);
97        /** Sets the current texture projector */
98        void setTextureProjector(const Frustum* frust);
99        /** Sets the current render target */
100        void setCurrentRenderTarget(const RenderTarget* target);
101                /** Sets the shadow extrusion distance to be used for point lights. */
102                void setShadowDirLightExtrusionDistance(Real dist);
103
104        const Matrix4& getWorldMatrix(void) const;
105        const Matrix4* getWorldMatrixArray(void) const;
106        size_t getWorldMatrixCount(void) const;
107        const Matrix4& getViewMatrix(void) const;
108        const Matrix4& getViewProjectionMatrix(void) const;
109        const Matrix4& getProjectionMatrix(void) const;
110        const Matrix4& getWorldViewProjMatrix(void) const;
111        const Matrix4& getWorldViewMatrix(void) const;
112        const Matrix4& getInverseWorldMatrix(void) const;
113        const Matrix4& getInverseWorldViewMatrix(void) const;
114        const Matrix4& getInverseViewMatrix(void) const;
115        const Matrix4& getInverseTransposeWorldMatrix(void) const;
116        const Matrix4& getInverseTransposeWorldViewMatrix(void) const;
117        const Vector4& getCameraPosition(void) const;
118        const Vector4& getCameraPositionObjectSpace(void) const;
119        /** Get the light which is 'index'th closest to the current object */
120        const Light& getLight(size_t index) const;
121                void setAmbientLightColour(const ColourValue& ambient);
122                const ColourValue& getAmbientLightColour(void) const;
123        const Matrix4& getTextureViewProjMatrix(void) const;
124        const RenderTarget* getCurrentRenderTarget(void) const;
125        const Renderable* getCurrentRenderable(void) const;
126                Real getShadowExtrusionDistance(void) const;
127                Matrix4 getInverseViewProjMatrix(void) const;
128                Matrix4 getInverseTransposeViewProjMatrix() const;
129                Matrix4 getTransposeViewProjMatrix() const;
130                Matrix4 getTransposeViewMatrix() const;
131                Matrix4 getTransposeProjectionMatrix() const;
132                Matrix4 getInverseProjectionMatrix() const;
133                Matrix4 getInverseTransposeProjectionMatrix() const;
134                Matrix4 getTransposeWorldViewProjMatrix() const;
135                Matrix4 getInverseWorldViewProjMatrix() const;
136                Matrix4 getInverseTransposeWorldViewProjMatrix() const;
137                Matrix4 getTransposeWorldViewMatrix() const;
138                Matrix4 getTransposeWorldMatrix() const;
139        Real getTime(void) const;
140                Real getTime_0_X(Real x) const;
141                Real getCosTime_0_X(Real x) const;
142                Real getSinTime_0_X(Real x) const;
143                Real getTanTime_0_X(Real x) const;
144                Vector4 getTime_0_X_packed(Real x) const;
145                Real getTime_0_1(Real x) const;
146                Real getCosTime_0_1(Real x) const;
147                Real getSinTime_0_1(Real x) const;
148                Real getTanTime_0_1(Real x) const;
149                Vector4 getTime_0_1_packed(Real x) const;
150                Real getTime_0_2Pi(Real x) const;
151                Real getCosTime_0_2Pi(Real x) const;
152                Real getSinTime_0_2Pi(Real x) const;
153                Real getTanTime_0_2Pi(Real x) const;
154                Vector4 getTime_0_2Pi_packed(Real x) const;
155                Real getFPS() const;
156                Real getViewportWidth() const;
157                Real getViewportHeight() const;
158                Real getInverseViewportWidth() const;
159                Real getInverseViewportHeight() const;
160                Vector3 getViewDirection() const;
161                Vector3 getViewSideVector() const;
162                Vector3 getViewUpVector() const;
163                Real getFOV() const;
164                Real getNearClipDistance() const;
165                Real getFarClipDistance() const;
166    };
167}
168
169#endif
Note: See TracBrowser for help on using the repository browser.