diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llvowater.h | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llvowater.h')
-rw-r--r-- | linden/indra/newview/llvowater.h | 259 |
1 files changed, 259 insertions, 0 deletions
diff --git a/linden/indra/newview/llvowater.h b/linden/indra/newview/llvowater.h new file mode 100644 index 0000000..11dc0e5 --- /dev/null +++ b/linden/indra/newview/llvowater.h | |||
@@ -0,0 +1,259 @@ | |||
1 | /** | ||
2 | * @file llvowater.h | ||
3 | * @brief Description of LLVOWater class | ||
4 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_VOWATER_H | ||
29 | #define LL_VOWATER_H | ||
30 | |||
31 | #include "llviewerobject.h" | ||
32 | #include "llviewerimage.h" | ||
33 | #include "v2math.h" | ||
34 | #include "llfft.h" | ||
35 | |||
36 | #include "llwaterpatch.h" | ||
37 | |||
38 | |||
39 | const U32 N_RES = 16; //32 // number of subdivisions of wave tile | ||
40 | const U8 WAVE_STEP = 8; | ||
41 | |||
42 | /* | ||
43 | #define N_DET 32 // number of subdivisions of wave tile for details | ||
44 | |||
45 | class LLWaterDetail | ||
46 | { | ||
47 | protected: | ||
48 | S32 mResolution; | ||
49 | LLViewerImage *mTex; | ||
50 | U8 *mTexData; | ||
51 | |||
52 | public: | ||
53 | LLWaterDetail() : mResolution(N_DET), mTex(0), mTexData(0) {init();} | ||
54 | void init(); | ||
55 | |||
56 | ~LLWaterDetail() | ||
57 | { | ||
58 | delete[] mTexData; | ||
59 | mTexData = NULL; | ||
60 | } | ||
61 | |||
62 | |||
63 | //void initEmpty(); | ||
64 | |||
65 | void setPixel(const LLVector3 &norm, const S32 i, const S32 j) | ||
66 | { | ||
67 | S32 offset = (i * mResolution + j) * 3; | ||
68 | mTexData[offset] = llround(norm.mV[VX] * 255); | ||
69 | mTexData[offset+1] = llround(norm.mV[VX] * 255); | ||
70 | mTexData[offset+2] = llround(norm.mV[VX] * 255); | ||
71 | } | ||
72 | void setPixel(F32 x, F32 y, F32 z, const S32 i, const S32 j) | ||
73 | { | ||
74 | S32 offset = (i * mResolution + j) * 3; | ||
75 | mTexData[offset] = llround(x * 255); | ||
76 | mTexData[offset+1] = llround(y * 255); | ||
77 | mTexData[offset+2] = llround(z * 255); | ||
78 | } | ||
79 | |||
80 | S32 getResolution() { return mResolution; } | ||
81 | |||
82 | void createDetailBumpmap(F32* u, F32* v); | ||
83 | void createTexture() const { mTex->createTexture(); } | ||
84 | void bindTexture() const { mTex->bindTexture(); } | ||
85 | LLViewerImage* getTexture() const { return mTex; } | ||
86 | }; | ||
87 | */ | ||
88 | |||
89 | class LLWaterSurface | ||
90 | { | ||
91 | protected: | ||
92 | BOOL mInitialized; | ||
93 | LLVector3 mWind; | ||
94 | F32 mA; | ||
95 | F32 mVisc; // viscosity of the fluid | ||
96 | F32 mShininess; | ||
97 | |||
98 | //LLWaterDetail* mDetail; | ||
99 | |||
100 | LLFFTPlan mPlan; | ||
101 | F32 mOmega[N_RES+1][N_RES+1]; // wave frequency | ||
102 | COMPLEX mHtilda0[N_RES+1][N_RES+1]; // wave amplitudes and phases at time 0. | ||
103 | LLVector3 mNorms[N_RES][N_RES]; | ||
104 | COMPLEX mHtilda[N_RES * N_RES]; | ||
105 | |||
106 | public: | ||
107 | LLWaterSurface(); | ||
108 | ~LLWaterSurface() {} | ||
109 | |||
110 | //void initSpecularLookup(); | ||
111 | |||
112 | F32 phillips(const LLVector2& k, const LLVector2& wind_n, F32 L, F32 L_small); | ||
113 | |||
114 | void initAmplitudes(); | ||
115 | |||
116 | F32 height(S32 i, S32 j) const { return mHtilda[i * N_RES + j].re; } | ||
117 | F32 heightWrapped(S32 i, S32 j) const | ||
118 | { | ||
119 | return height((i + N_RES) % N_RES, (j + N_RES) % N_RES); | ||
120 | } | ||
121 | |||
122 | void generateWaterHeightField(F64 time); | ||
123 | void calcNormals(); | ||
124 | |||
125 | void getHeightAndNormal(F32 i, F32 j, F32& height, LLVector3& normal) const; | ||
126 | void getIntegerHeightAndNormal(S32 i, S32 j, F32& height, LLVector3& normal) const; | ||
127 | F32 agentDepth() const; | ||
128 | |||
129 | // const LLWaterHeightField* hField() const { return &mHeightField; } | ||
130 | |||
131 | //void generateDetail(F64 t); | ||
132 | //void fluidSolver(F32* u, F32* v, F32* u0, F32* v0, F64 dt); | ||
133 | |||
134 | const LLVector3& getWind() const { return mWind; } | ||
135 | void setWind(const LLVector3& w) { mWind = w; } // initialized = 0? | ||
136 | F32 A() const { return mA; } | ||
137 | void setA(F32 a) { mA = a; } | ||
138 | F32 getShininess() const { return mShininess; } | ||
139 | //LLViewerImage* getSpecularLookup() const { return mSpecularLookup; } | ||
140 | //LLViewerImage* getDetail() const { return mDetail->getTexture(); } | ||
141 | }; | ||
142 | |||
143 | class LLVOWater; | ||
144 | |||
145 | class LLWaterGrid | ||
146 | { | ||
147 | public: | ||
148 | LLWaterGrid(); | ||
149 | |||
150 | void init(); | ||
151 | void cleanup(); | ||
152 | |||
153 | LLWaterSurface* getWaterSurface() { return &mWater; } | ||
154 | |||
155 | void update(); | ||
156 | void updateTree(const LLVector3 &camera_pos, const LLVector3 &look_at, F32 clip_far, | ||
157 | BOOL restart); | ||
158 | void updateVisibility(const LLVector3 &camera_pos, const LLVector3 &look_at, F32 clip_far); | ||
159 | |||
160 | LLVector3 mRegionOrigin; | ||
161 | |||
162 | LLVector3* mVtx; | ||
163 | LLVector3* mNorms; | ||
164 | U32 mRegionWidth; | ||
165 | U32 mMaxGridSize; | ||
166 | U32 mPatchRes; | ||
167 | U32 mMinStep; | ||
168 | U32 mStepsInRegion; | ||
169 | LLWaterPatch* mPatches; | ||
170 | LLRoam mRoam; | ||
171 | F32 mResIncrease; | ||
172 | U32 mResDecrease; | ||
173 | |||
174 | LLVOWater* mTab[5][5]; | ||
175 | |||
176 | U32 gridDim() const { return mGridDim; } | ||
177 | U32 rowSize() const { return mGridDim1; } | ||
178 | void setGridDim(U32 gd) { mGridDim = gd; mGridDim1 = mGridDim + 1; } | ||
179 | U32 index(const LL2Coord& c) const { return c.y() * mGridDim1 + c.x(); } | ||
180 | U32 index(U32 x, U32 y) const { return y * mGridDim1 + x; } | ||
181 | |||
182 | LLVector3 vtx(const LL2Coord& c, F32 raised) const | ||
183 | { | ||
184 | LLVector3 v = mVtx[index(c)]; | ||
185 | v.mV[VZ] += raised; | ||
186 | return v; | ||
187 | } | ||
188 | |||
189 | LLVector3 vtx(U32 x, U32 y, F32 raised) const | ||
190 | { | ||
191 | LLVector3 v = mVtx[index(x, y)]; | ||
192 | v.mV[VZ] += raised; | ||
193 | return v; | ||
194 | } | ||
195 | |||
196 | void setVertex(const U32 x, const U32 y, const F32 raised, LLVector3 &vertex) const | ||
197 | { | ||
198 | vertex = mVtx[index(x, y)]; | ||
199 | vertex.mV[VZ] += raised; | ||
200 | } | ||
201 | |||
202 | void setCamPosition(LL2Coord& cam, const LLVector3& cam_pos) | ||
203 | { | ||
204 | cam.x() = llround((cam_pos.mV[VX] - mRegionOrigin.mV[VX]) / mMinStep); | ||
205 | cam.y() = llround((cam_pos.mV[VY] - mRegionOrigin.mV[VY]) / mMinStep); | ||
206 | } | ||
207 | |||
208 | LLVector3 vtx(const LL2Coord& c) const { return mVtx[index(c)]; } | ||
209 | LLVector3 norm(const LL2Coord& c) const { return mNorms[index(c)]; } | ||
210 | LLVector3 vtx(U32 x, U32 y) const { return mVtx[index(x, y)]; } | ||
211 | LLVector3 norm(U32 x, U32 y) const { return mNorms[index(x, y)]; } | ||
212 | |||
213 | protected: | ||
214 | LLWaterSurface mWater; | ||
215 | U32 mGridDim; | ||
216 | U32 mGridDim1; | ||
217 | }; | ||
218 | |||
219 | class LLSurface; | ||
220 | class LLHeavenBody; | ||
221 | class LLVOSky; | ||
222 | class LLFace; | ||
223 | |||
224 | class LLVOWater : public LLViewerObject | ||
225 | { | ||
226 | public: | ||
227 | LLVOWater(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); | ||
228 | virtual ~LLVOWater() {} | ||
229 | |||
230 | /*virtual*/ void markDead(); | ||
231 | |||
232 | // Initialize data that's only inited once per class. | ||
233 | static void initClass(); | ||
234 | static void cleanupClass(); | ||
235 | |||
236 | /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time); | ||
237 | /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline); | ||
238 | /*virtual*/ BOOL updateGeometry(LLDrawable *drawable); | ||
239 | BOOL updateGeometryFlat(LLDrawable *drawable); | ||
240 | BOOL updateGeometryHeightFieldSimple(LLDrawable *drawable); | ||
241 | BOOL updateGeometryHeightFieldRoam(LLDrawable *drawable); | ||
242 | |||
243 | /*virtual*/ void updateDrawable(BOOL force_damped); | ||
244 | /*virtual*/ void updateTextures(LLAgent &agent); | ||
245 | /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent); // generate accurate apparent angle and area | ||
246 | |||
247 | /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate. | ||
248 | |||
249 | void setUseTexture(const BOOL use_texture); | ||
250 | |||
251 | static void generateNewWaves(F64 time); | ||
252 | static LLWaterSurface* getWaterSurface() { return sGrid->getWaterSurface(); }//return &mWater; } | ||
253 | static const LLWaterGrid* getGrid() { return sGrid; } | ||
254 | protected: | ||
255 | BOOL mUseTexture; | ||
256 | static LLWaterGrid *sGrid; | ||
257 | }; | ||
258 | |||
259 | #endif // LL_VOSURFACEPATCH_H | ||