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/llvoclouds.cpp | |
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 '')
-rw-r--r-- | linden/indra/newview/llvoclouds.cpp | 207 |
1 files changed, 207 insertions, 0 deletions
diff --git a/linden/indra/newview/llvoclouds.cpp b/linden/indra/newview/llvoclouds.cpp new file mode 100644 index 0000000..a4e424a --- /dev/null +++ b/linden/indra/newview/llvoclouds.cpp | |||
@@ -0,0 +1,207 @@ | |||
1 | /** | ||
2 | * @file llvoclouds.cpp | ||
3 | * @brief Implementation of LLVOClouds class which is a derivation fo LLViewerObject | ||
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 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llvoclouds.h" | ||
31 | |||
32 | #include "llviewercontrol.h" | ||
33 | |||
34 | #include "llagent.h" // to get camera position | ||
35 | #include "lldrawable.h" | ||
36 | #include "llface.h" | ||
37 | #include "llprimitive.h" | ||
38 | #include "llsky.h" | ||
39 | #include "llviewercamera.h" | ||
40 | #include "llviewerimagelist.h" | ||
41 | #include "llviewerobjectlist.h" | ||
42 | #include "llviewerregion.h" | ||
43 | #include "llvosky.h" | ||
44 | #include "llworld.h" | ||
45 | #include "pipeline.h" | ||
46 | #include "viewer.h" | ||
47 | |||
48 | LLVOClouds::LLVOClouds(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) | ||
49 | : LLViewerObject(id, LL_VO_CLOUDS, regionp) | ||
50 | { | ||
51 | mCloudGroupp = NULL; | ||
52 | mbCanSelect = FALSE; | ||
53 | setNumTEs(1); | ||
54 | LLViewerImage* image = gImageList.getImage(gCloudTextureID); | ||
55 | image->setBoostLevel(LLViewerImage::BOOST_CLOUDS); | ||
56 | setTEImage(0, image); | ||
57 | } | ||
58 | |||
59 | |||
60 | LLVOClouds::~LLVOClouds() | ||
61 | { | ||
62 | } | ||
63 | |||
64 | |||
65 | BOOL LLVOClouds::isActive() const | ||
66 | { | ||
67 | return TRUE; | ||
68 | } | ||
69 | |||
70 | |||
71 | BOOL LLVOClouds::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time) | ||
72 | { | ||
73 | if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS))) | ||
74 | return TRUE; | ||
75 | |||
76 | // Set dirty flag (so renderer will rebuild primitive) | ||
77 | if (mDrawable) | ||
78 | { | ||
79 | gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE); | ||
80 | } | ||
81 | return TRUE; | ||
82 | } | ||
83 | |||
84 | |||
85 | void LLVOClouds::setPixelAreaAndAngle(LLAgent &agent) | ||
86 | { | ||
87 | mAppAngle = 50; | ||
88 | mPixelArea = 1500*100; | ||
89 | } | ||
90 | |||
91 | void LLVOClouds::updateTextures(LLAgent &agent) | ||
92 | { | ||
93 | getTEImage(0)->addTextureStats(mPixelArea); | ||
94 | } | ||
95 | |||
96 | LLDrawable* LLVOClouds::createDrawable(LLPipeline *pipeline) | ||
97 | { | ||
98 | pipeline->allocDrawable(this); | ||
99 | mDrawable->setLit(FALSE); | ||
100 | mDrawable->setRenderType(LLPipeline::RENDER_TYPE_CLOUDS); | ||
101 | |||
102 | LLDrawPool *pool = gPipeline.getPool(LLDrawPool::POOL_CLOUDS); | ||
103 | |||
104 | mDrawable->setNumFaces(1, pool, getTEImage(0)); | ||
105 | |||
106 | return mDrawable; | ||
107 | } | ||
108 | |||
109 | BOOL LLVOClouds::updateGeometry(LLDrawable *drawable) | ||
110 | { | ||
111 | if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS))) | ||
112 | return TRUE; | ||
113 | |||
114 | LLVector3 at; | ||
115 | LLVector3 up; | ||
116 | LLVector3 right; | ||
117 | LLVector3 normal(0.f,0.f,-1.f); | ||
118 | LLVector3 position_agent; | ||
119 | //LLVector3 v[4]; | ||
120 | LLFace *facep; | ||
121 | const LLVector3 region_pos_agent = mRegionp->getOriginAgent(); | ||
122 | const LLVector3 camera_agent = gAgent.getCameraPositionAgent(); | ||
123 | LLVector3 center_offset = getPositionRegion(); | ||
124 | LLVector2 uvs[4]; | ||
125 | |||
126 | uvs[0].setVec(0.f, 1.f); | ||
127 | uvs[1].setVec(0.f, 0.f); | ||
128 | uvs[2].setVec(1.f, 1.f); | ||
129 | uvs[3].setVec(1.f, 0.f); | ||
130 | |||
131 | LLVector3 vtx[4]; | ||
132 | |||
133 | S32 num_faces = mCloudGroupp->getNumPuffs(); | ||
134 | |||
135 | drawable->setNumFacesFast(num_faces, gPipeline.getPool(LLDrawPool::POOL_CLOUDS), getTEImage(0)); | ||
136 | |||
137 | S32 face_indx = 0; | ||
138 | for ( ; face_indx < num_faces; face_indx++) | ||
139 | { | ||
140 | facep = drawable->getFace(face_indx); | ||
141 | |||
142 | LLStrider<LLVector3> verticesp, normalsp; | ||
143 | LLStrider<LLVector2> texCoordsp; | ||
144 | U32 *indicesp; | ||
145 | S32 index_offset; | ||
146 | |||
147 | facep->setPrimType(LLTriangles); | ||
148 | facep->setSize(4, 6); | ||
149 | index_offset = facep->getGeometry(verticesp,normalsp,texCoordsp, indicesp); | ||
150 | if (-1 == index_offset) | ||
151 | { | ||
152 | return TRUE; | ||
153 | } | ||
154 | |||
155 | const LLCloudPuff &puff = mCloudGroupp->getPuff(face_indx); | ||
156 | const LLVector3 puff_pos_agent = gAgent.getPosAgentFromGlobal(puff.getPositionGlobal()); | ||
157 | facep->mCenterAgent = puff_pos_agent; | ||
158 | |||
159 | LLVector3 from_camera_vec = gCamera->getAtAxis();//puff_pos_agent - camera_agent; | ||
160 | at = from_camera_vec; | ||
161 | right = at % LLVector3(0.f, 0.f, 1.f); | ||
162 | right.normVec(); | ||
163 | up = right % at; | ||
164 | up.normVec(); | ||
165 | right *= 0.5f*CLOUD_PUFF_WIDTH; | ||
166 | up *= 0.5f*CLOUD_PUFF_HEIGHT;; | ||
167 | |||
168 | facep->mCenterAgent = puff_pos_agent; | ||
169 | |||
170 | LLColor4 color(1.f, 1.f, 1.f, puff.getAlpha()); | ||
171 | facep->setFaceColor(color); | ||
172 | |||
173 | vtx[0] = puff_pos_agent - right + up; | ||
174 | vtx[1] = puff_pos_agent - right - up; | ||
175 | vtx[2] = puff_pos_agent + right + up; | ||
176 | vtx[3] = puff_pos_agent + right - up; | ||
177 | |||
178 | *verticesp++ = vtx[0]; | ||
179 | *verticesp++ = vtx[1]; | ||
180 | *verticesp++ = vtx[2]; | ||
181 | *verticesp++ = vtx[3]; | ||
182 | |||
183 | *texCoordsp++ = uvs[0]; | ||
184 | *texCoordsp++ = uvs[1]; | ||
185 | *texCoordsp++ = uvs[2]; | ||
186 | *texCoordsp++ = uvs[3]; | ||
187 | |||
188 | *normalsp++ = normal; | ||
189 | *normalsp++ = normal; | ||
190 | *normalsp++ = normal; | ||
191 | *normalsp++ = normal; | ||
192 | |||
193 | *indicesp++ = index_offset + 0; | ||
194 | *indicesp++ = index_offset + 1; | ||
195 | *indicesp++ = index_offset + 2; | ||
196 | |||
197 | *indicesp++ = index_offset + 1; | ||
198 | *indicesp++ = index_offset + 3; | ||
199 | *indicesp++ = index_offset + 2; | ||
200 | } | ||
201 | for ( ; face_indx < drawable->getNumFaces(); face_indx++) | ||
202 | { | ||
203 | drawable->getFace(face_indx)->setSize(0,0); | ||
204 | } | ||
205 | |||
206 | return TRUE; | ||
207 | } | ||