~ubuntu-branches/debian/sid/ember/sid

« back to all changes in this revision

Viewing changes to src/components/ogre/SceneManagers/EmberPagingSceneManager/include/OgrePagingLandScapePage.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Koch
  • Date: 2009-07-23 07:46:40 UTC
  • Revision ID: james.westby@ubuntu.com-20090723074640-wh0ukzis0kda36qv
Tags: upstream-0.5.6
ImportĀ upstreamĀ versionĀ 0.5.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
        OgrePagingLandScapePage.h  -  description
 
3
  -------------------
 
4
  begin                : Sat Mar 08 2003
 
5
  copyright            : (C) 2003-2006 by Jose A. Milan and Tuan Kuranes
 
6
  email                : spoke2@supercable.es && tuan.kuranes@free.fr
 
7
***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
*                                                                         *
 
11
*   This program is free software; you can redistribute it and/or modify  *
 
12
*   it under the terms of the GNU Lesser General Public License as        *
 
13
*   published by the Free Software Foundation; either version 2 of the    *
 
14
*   License, or (at your option) any later version.                       *
 
15
*                                                                         *
 
16
***************************************************************************/
 
17
 
 
18
#ifndef PAGINGLandScapePAGE_H
 
19
#define PAGINGLandScapePAGE_H
 
20
 
 
21
#include "OgrePagingLandScapePrerequisites.h"
 
22
 
 
23
namespace Ogre
 
24
{
 
25
 
 
26
 
 
27
    class _OgrePagingLandScapeExport PagingLandScapePage
 
28
    {
 
29
        public:
 
30
                /** Sets the appropriate neighbor for this TerrainRenderable.  Neighbors are necessary
 
31
            to know when to bridge between LODs.
 
32
            */
 
33
            void _setNeighbor(const Neighbor& n, PagingLandScapePage* p);
 
34
 
 
35
                        /** Returns the page's scene node
 
36
                        */
 
37
                        SceneNode* getPageNode() const { return mPageNode; }
 
38
 
 
39
            /** Returns the neighbor TerrainRenderable.
 
40
            */
 
41
            PagingLandScapePage* _getNeighbor(const Neighbor& n) const
 
42
            {
 
43
                return mNeighbors[ n ];
 
44
            };
 
45
 
 
46
            PagingLandScapeTile* getTile(const unsigned int i , const unsigned int j) const;
 
47
 
 
48
            PagingLandScapeTile* getTile(const Vector3& pos);
 
49
                PagingLandScapePage(PagingLandScapePageManager *pageMgr);
 
50
 
 
51
                virtual ~PagingLandScapePage(void);
 
52
 
 
53
                /** Whole Map changes */
 
54
            void init(const unsigned int tableX, const unsigned int tableZ);
 
55
 
 
56
                /** Release the page, but keep it reusable if Whole Map changes */
 
57
            void uninit(void);
 
58
 
 
59
                /** Pre-loads the LandScape data using parameters int he given in the constructor. */
 
60
                void preload(void);
 
61
 
 
62
                /** Loads the LandScape tiles using parameters int he given in the constructor. */
 
63
                void load(void);
 
64
 
 
65
                /** Unloads the LandScape data, then reloads it */
 
66
                        void reload(void);
 
67
 
 
68
                /** Loads the LandScape texture using parameters int he given in the constructor. */
 
69
            void loadTexture(void);
 
70
 
 
71
                /** Unloads the LandScape texture, but doesn't destroy the LandScape data. */
 
72
            void unloadTexture(void);
 
73
 
 
74
                /** Unloads the LandScape data, but doesn't destroy the LandScape page. */
 
75
                void unload(void);
 
76
 
 
77
                /** Post Unloads the LandScape data, but doesn't destroy the LandScape page. */
 
78
                void postUnload(void);
 
79
            
 
80
                void unsetLoading(void)
 
81
                        {
 
82
                                mIsLoading = false;
 
83
                        };
 
84
 
 
85
                void unsetPreLoading(void)
 
86
                        {
 
87
                                mIsPreLoading = false;
 
88
                        };
 
89
 
 
90
                void unsetTextureLoading(void)
 
91
                        {
 
92
                                mIsTextureLoading = false;
 
93
                        };
 
94
 
 
95
                void unsetUnloading(void)
 
96
                        {
 
97
                                mIsUnloading = false;
 
98
                        };
 
99
 
 
100
                void unsetPostUnloading(void)
 
101
                        {
 
102
                                mIsPostUnloading = false;
 
103
                        };
 
104
 
 
105
            void unsetTextureunloading(void)
 
106
                        {
 
107
                                mIsTextureunloading = false;
 
108
                        };
 
109
        
 
110
            const bool isLoaded(void) const 
 
111
                        {
 
112
                                return mIsLoaded;
 
113
                        };
 
114
 
 
115
            const bool isPreLoaded(void) const 
 
116
                        {
 
117
                                return mIsPreLoaded;
 
118
                        };
 
119
 
 
120
            const bool isTextureLoaded(void) const 
 
121
                        {
 
122
                                return mIsTextureLoaded;
 
123
                        };
 
124
 
 
125
            const bool isLoadable(void) const 
 
126
                        {
 
127
                                return mIsLoadable;
 
128
                        };
 
129
 
 
130
            const bool unloadUntouched(void);
 
131
            void touch(void);
 
132
 
 
133
            bool isVisible(void) const 
 
134
                        {
 
135
                                return mVisible;
 
136
                        }
 
137
 
 
138
                /** Returns if the camera is over this LandScape page.
 
139
                */
 
140
                int isCameraIn(const Vector3& pos) const;
 
141
 
 
142
                bool _Notify(const Vector3 &pos, const PagingLandScapeCamera * const Cam);
 
143
            void _Show(const bool do_show);
 
144
 
 
145
            void getCoordinates(unsigned int& X, unsigned int& Z) const 
 
146
                        {
 
147
                                X = mTableX;
 
148
                                Z = mTableZ;
 
149
                        };
 
150
 
 
151
 
 
152
                bool mIsLoading;
 
153
                bool mIsPreLoading;
 
154
            bool mIsTextureLoading;
 
155
 
 
156
           
 
157
                bool mIsUnloading;
 
158
                bool mIsPostUnloading;
 
159
            bool mIsTextureunloading;
 
160
 
 
161
                    /** Sets the render queue group which the tiles should be rendered in. */
 
162
                    void setRenderQueue(uint8 qid);
 
163
 
 
164
            void _updateLod(void);
 
165
 
 
166
            void setMapMaterial(void);
 
167
 
 
168
                        inline bool isCoord(const unsigned int x, const unsigned int z){return (mTableZ == z && mTableX == x);};
 
169
                        
 
170
                        SceneNode *getSceneNode(){return mPageNode;};
 
171
                        const AxisAlignedBox &getWorldBbox() const {return mBounds;};
 
172
                        const Vector3 &getCenter(void) const {return mWorldPosition;};
 
173
                        
 
174
                        void updateTerrain();
 
175
                        
 
176
        protected:
 
177
                SceneNode* mPageNode;
 
178
 
 
179
                PagingLandScapeTiles mTiles;
 
180
 
 
181
                bool mIsLoaded;
 
182
                bool mIsPreLoaded;
 
183
            bool mIsTextureLoaded; 
 
184
            
 
185
            // if data needed for this page doesn't exists
 
186
            bool mIsLoadable;
 
187
 
 
188
            bool mVisible; 
 
189
                        // ensure page is not flickering due to shadow passes
 
190
                        // as it unload instantly
 
191
                        // but loading is queued
 
192
                        // if not page not showed until mVisibletouch==0 it becomes invisible
 
193
                        //size_t mVisibletouch;
 
194
 
 
195
                        // Position of this Terrain Page in the Terrain Page Array
 
196
                unsigned int mTableX;   
 
197
                unsigned int mTableZ;
 
198
 
 
199
            unsigned int mNumTiles;
 
200
 
 
201
                Real mIniX;     //, mEndX;      // Max and Min values of the terrain
 
202
                Real mIniZ;     //, mEndZ;
 
203
 
 
204
            PagingLandScapePage* mNeighbors[4];
 
205
 
 
206
                // Change Zone values
 
207
                AxisAlignedBox mBounds;
 
208
                AxisAlignedBox mBoundsInt;
 
209
                AxisAlignedBox mBoundsExt;
 
210
                        Vector3 mWorldPosition;
 
211
 
 
212
            PagingLandScapePageRenderable* mRenderable;
 
213
 
 
214
            unsigned int mTimeUntouched;
 
215
 
 
216
                        PageState pageState;
 
217
            PageQueuingState pageQueingState;
 
218
            PagingLandScapePageManager *mParent;
 
219
    };
 
220
 
 
221
}
 
222
 
 
223
#endif