aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvoground.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llvoground.cpp
parentREADME.txt (diff)
downloadmeta-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/llvoground.cpp184
1 files changed, 184 insertions, 0 deletions
diff --git a/linden/indra/newview/llvoground.cpp b/linden/indra/newview/llvoground.cpp
new file mode 100644
index 0000000..7001cb8
--- /dev/null
+++ b/linden/indra/newview/llvoground.cpp
@@ -0,0 +1,184 @@
1/**
2 * @file llvoground.cpp
3 * @brief LLVOGround class implementation
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 "llvoground.h"
31
32#include "llviewercontrol.h"
33
34#include "llagent.h"
35#include "lldrawable.h"
36#include "llface.h"
37#include "llsky.h"
38#include "llviewercamera.h"
39#include "llviewerregion.h"
40#include "pipeline.h"
41
42LLVOGround::LLVOGround(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
43: LLViewerObject(id, pcode, regionp)
44{
45 mbCanSelect = FALSE;
46}
47
48
49LLVOGround::~LLVOGround()
50{
51}
52
53BOOL LLVOGround::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
54{
55 if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_GROUND)))
56 {
57 return TRUE;
58 }
59
60 if (mDrawable)
61 {
62 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE);
63 }
64 return TRUE;
65}
66
67
68void LLVOGround::updateTextures(LLAgent &agent)
69{
70}
71
72
73LLDrawable *LLVOGround::createDrawable(LLPipeline *pipeline)
74{
75 pipeline->allocDrawable(this);
76 mDrawable->setLit(FALSE);
77
78 LLDrawPool *poolp = gPipeline.getPool(LLDrawPool::POOL_GROUND);
79
80 mDrawable->addFace(poolp, NULL);
81
82 return mDrawable;
83}
84
85BOOL LLVOGround::updateGeometry(LLDrawable *drawable)
86{
87 LLStrider<LLVector3> verticesp;
88 LLStrider<LLVector3> normalsp;
89 LLStrider<LLVector2> texCoordsp;
90 U32 *indicesp;
91 S32 index_offset;
92 LLFace *face;
93
94 if (drawable->getNumFaces() < 1)
95 drawable->addFace(gPipeline.getPool(LLDrawPool::POOL_GROUND), NULL);
96 face = drawable->getFace(0);
97 face->setPrimType(LLTriangles);
98 face->setSize(6, 12);
99 index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp);
100 if (-1 == index_offset)
101 {
102 return TRUE;
103 }
104
105 ///////////////////////////////////////
106 //
107 //
108 //
109 LLVector3 at_dir = gCamera->getAtAxis();
110 at_dir.mV[VZ] = 0.f;
111 if (at_dir.normVec() < 0.01)
112 {
113 // We really don't care, as we're not looking anywhere near the horizon.
114 }
115 LLVector3 left_dir = gCamera->getLeftAxis();
116 left_dir.mV[VZ] = 0.f;
117 left_dir.normVec();
118
119 // Our center top point
120 LLVector3 center_top, center_bottom;
121
122 LLColor4 ground_color = gSky.getFogColor();
123 ground_color.mV[3] = 1.f;
124 face->setFaceColor(ground_color);
125
126 if (gCamera->getOrigin().mV[VZ] < gAgent.getRegion()->getWaterHeight())
127 {
128 // Underwater
129 //center_top = gCamera->getOrigin() + at_dir*gCamera->getFar();
130 center_top = gCamera->getOrigin() - LLVector3(0, 0, 5);
131 center_bottom = gCamera->getOrigin() + at_dir*gCamera->getFar();;
132 //center_top.mV[VZ] = gAgent.getRegion()->getWaterHeight() + 0.5f;
133 center_bottom.mV[VZ] = -100.f;
134 }
135 else
136 {
137 // Above water
138 center_top = gCamera->getOrigin() - LLVector3(0, 0, 30);
139 if ((gPipeline.getVertexShaderLevel(LLPipeline::SHADER_ENVIRONMENT) > 0))
140 {
141 center_top.mV[VZ] = gAgent.getRegion()->getWaterHeight();
142 }
143 //center_top = gCamera->getOrigin() + at_dir*9000.f;
144 center_bottom = gCamera->getOrigin() - at_dir*gCamera->getFar();
145 //center_top.mV[VZ] = 0.f;
146 //center_bottom.mV[VZ] = gAgent.getRegion()->getWaterHeight();
147 }
148
149 *(verticesp++) = center_top + LLVector3(6000, 6000, 0);
150 *(verticesp++) = center_top + LLVector3(-6000, 6000, 0);
151 *(verticesp++) = center_top + LLVector3(-6000, -6000, 0);
152
153 *(verticesp++) = center_top + LLVector3(-6000, -6000, 0);
154 *(verticesp++) = center_top + LLVector3(6000, -6000, 0);
155 *(verticesp++) = center_top + LLVector3(6000, 6000, 0);
156
157
158 // Triangles for each side
159 *indicesp++ = index_offset + 0;
160 *indicesp++ = index_offset + 1;
161 *indicesp++ = index_offset + 3;
162
163 *indicesp++ = index_offset + 0;
164 *indicesp++ = index_offset + 3;
165 *indicesp++ = index_offset + 2;
166
167 *indicesp++ = index_offset + 2;
168 *indicesp++ = index_offset + 3;
169 *indicesp++ = index_offset + 5;
170
171 *indicesp++ = index_offset + 2;
172 *indicesp++ = index_offset + 5;
173 *indicesp++ = index_offset + 4;
174
175 *(texCoordsp++) = LLVector2(0.f, 0.f);
176 *(texCoordsp++) = LLVector2(1.f, 0.f);
177 *(texCoordsp++) = LLVector2(0.f, 1.f);
178 *(texCoordsp++) = LLVector2(1.f, 1.f);
179 *(texCoordsp++) = LLVector2(0.f, 2.f);
180 *(texCoordsp++) = LLVector2(1.f, 2.f);
181
182 LLPipeline::sCompiles++;
183 return TRUE;
184}