source: OGRE/trunk/ogrenew/OgreMain/include/OgreAutoParamDataSource.h @ 657

Revision 657, 7.5 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

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        const Viewport* mCurrentViewport;
87
88        Light mBlankLight;
89    public:
90        AutoParamDataSource();
91        ~AutoParamDataSource();
92        /** Updates the current renderable */
93        void setCurrentRenderable(const Renderable* rend);
94        /** Updates the current camera */
95        void setCurrentCamera(const Camera* cam);
96        /** Sets the light list that should be used */
97        void setCurrentLightList(const LightList* ll);
98        /** Sets the current texture projector */
99        void setTextureProjector(const Frustum* frust);
100        /** Sets the current render target */
101        void setCurrentRenderTarget(const RenderTarget* target);
102        /** Sets the current viewport */
103        void setCurrentViewport(const Viewport* viewport);
104                /** Sets the shadow extrusion distance to be used for point lights. */
105                void setShadowDirLightExtrusionDistance(Real dist);
106
107        const Matrix4& getWorldMatrix(void) const;
108        const Matrix4* getWorldMatrixArray(void) const;
109        size_t getWorldMatrixCount(void) const;
110        const Matrix4& getViewMatrix(void) const;
111        const Matrix4& getViewProjectionMatrix(void) const;
112        const Matrix4& getProjectionMatrix(void) const;
113        const Matrix4& getWorldViewProjMatrix(void) const;
114        const Matrix4& getWorldViewMatrix(void) const;
115        const Matrix4& getInverseWorldMatrix(void) const;
116        const Matrix4& getInverseWorldViewMatrix(void) const;
117        const Matrix4& getInverseViewMatrix(void) const;
118        const Matrix4& getInverseTransposeWorldMatrix(void) const;
119        const Matrix4& getInverseTransposeWorldViewMatrix(void) const;
120        const Vector4& getCameraPosition(void) const;
121        const Vector4& getCameraPositionObjectSpace(void) const;
122        /** Get the light which is 'index'th closest to the current object */
123        const Light& getLight(size_t index) const;
124                void setAmbientLightColour(const ColourValue& ambient);
125                const ColourValue& getAmbientLightColour(void) const;
126        const Matrix4& getTextureViewProjMatrix(void) const;
127        const RenderTarget* getCurrentRenderTarget(void) const;
128        const Renderable* getCurrentRenderable(void) const;
129                Real getShadowExtrusionDistance(void) const;
130                Matrix4 getInverseViewProjMatrix(void) const;
131                Matrix4 getInverseTransposeViewProjMatrix() const;
132                Matrix4 getTransposeViewProjMatrix() const;
133                Matrix4 getTransposeViewMatrix() const;
134                Matrix4 getTransposeProjectionMatrix() const;
135                Matrix4 getInverseProjectionMatrix() const;
136                Matrix4 getInverseTransposeProjectionMatrix() const;
137                Matrix4 getTransposeWorldViewProjMatrix() const;
138                Matrix4 getInverseWorldViewProjMatrix() const;
139                Matrix4 getInverseTransposeWorldViewProjMatrix() const;
140                Matrix4 getTransposeWorldViewMatrix() const;
141                Matrix4 getTransposeWorldMatrix() const;
142        Real getTime(void) const;
143                Real getTime_0_X(Real x) const;
144                Real getCosTime_0_X(Real x) const;
145                Real getSinTime_0_X(Real x) const;
146                Real getTanTime_0_X(Real x) const;
147                Vector4 getTime_0_X_packed(Real x) const;
148                Real getTime_0_1(Real x) const;
149                Real getCosTime_0_1(Real x) const;
150                Real getSinTime_0_1(Real x) const;
151                Real getTanTime_0_1(Real x) const;
152                Vector4 getTime_0_1_packed(Real x) const;
153                Real getTime_0_2Pi(Real x) const;
154                Real getCosTime_0_2Pi(Real x) const;
155                Real getSinTime_0_2Pi(Real x) const;
156                Real getTanTime_0_2Pi(Real x) const;
157                Vector4 getTime_0_2Pi_packed(Real x) const;
158                Real getFPS() const;
159                Real getViewportWidth() const;
160                Real getViewportHeight() const;
161                Real getInverseViewportWidth() const;
162                Real getInverseViewportHeight() const;
163                Vector3 getViewDirection() const;
164                Vector3 getViewSideVector() const;
165                Vector3 getViewUpVector() const;
166                Real getFOV() const;
167                Real getNearClipDistance() const;
168                Real getFarClipDistance() const;
169    };
170}
171
172#endif
Note: See TracBrowser for help on using the repository browser.