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/llviewerjointshape.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 'linden/indra/newview/llviewerjointshape.cpp')
-rw-r--r-- | linden/indra/newview/llviewerjointshape.cpp | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewerjointshape.cpp b/linden/indra/newview/llviewerjointshape.cpp new file mode 100644 index 0000000..d40d8c3 --- /dev/null +++ b/linden/indra/newview/llviewerjointshape.cpp | |||
@@ -0,0 +1,229 @@ | |||
1 | /** | ||
2 | * @file llviewerjointshape.cpp | ||
3 | * @brief Implementation of LLViewerJointShape 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 | //----------------------------------------------------------------------------- | ||
29 | // Header Files | ||
30 | //----------------------------------------------------------------------------- | ||
31 | #include "llviewerprecompiledheaders.h" | ||
32 | |||
33 | #include "llviewerjointshape.h" | ||
34 | |||
35 | #include "llbox.h" | ||
36 | #include "llsphere.h" | ||
37 | #include "llcylinder.h" | ||
38 | #include "llgldbg.h" | ||
39 | #include "llglheaders.h" | ||
40 | |||
41 | F32 LLViewerJointShape::sColorScale = 1.0f; | ||
42 | |||
43 | //----------------------------------------------------------------------------- | ||
44 | // LLViewerJointShape() | ||
45 | //----------------------------------------------------------------------------- | ||
46 | LLViewerJointShape::LLViewerJointShape() | ||
47 | { | ||
48 | mType = ST_NULL; | ||
49 | mColor[0] = 1.0f; | ||
50 | mColor[1] = 1.0f; | ||
51 | mColor[2] = 1.0f; | ||
52 | mColor[3] = 1.0f; | ||
53 | mTexture = NULL; | ||
54 | } | ||
55 | |||
56 | |||
57 | //----------------------------------------------------------------------------- | ||
58 | // LLViewerJointShape() | ||
59 | //----------------------------------------------------------------------------- | ||
60 | LLViewerJointShape::LLViewerJointShape( ShapeType type, F32 red, F32 green, F32 blue, F32 alpha ) | ||
61 | { | ||
62 | mType = type; | ||
63 | mColor[0] = red * sColorScale; | ||
64 | mColor[1] = green * sColorScale; | ||
65 | mColor[2] = blue * sColorScale; | ||
66 | mColor[3] = alpha; | ||
67 | mTexture = NULL; | ||
68 | } | ||
69 | |||
70 | |||
71 | //----------------------------------------------------------------------------- | ||
72 | // ~LLViewerJointShape() | ||
73 | // Class Destructor | ||
74 | //----------------------------------------------------------------------------- | ||
75 | LLViewerJointShape::~LLViewerJointShape() | ||
76 | { | ||
77 | } | ||
78 | |||
79 | |||
80 | //-------------------------------------------------------------------- | ||
81 | // getType() | ||
82 | //-------------------------------------------------------------------- | ||
83 | LLViewerJointShape::ShapeType LLViewerJointShape::getType() | ||
84 | { | ||
85 | return mType; | ||
86 | } | ||
87 | |||
88 | |||
89 | //-------------------------------------------------------------------- | ||
90 | // setType() | ||
91 | //-------------------------------------------------------------------- | ||
92 | void LLViewerJointShape::setType( ShapeType type ) | ||
93 | { | ||
94 | mType = type; | ||
95 | } | ||
96 | |||
97 | |||
98 | //-------------------------------------------------------------------- | ||
99 | // getColor() | ||
100 | //-------------------------------------------------------------------- | ||
101 | void LLViewerJointShape::getColor( F32 *red, F32 *green, F32 *blue, F32 *alpha ) | ||
102 | { | ||
103 | *red = mColor[0]; | ||
104 | *green = mColor[1]; | ||
105 | *blue = mColor[2]; | ||
106 | *alpha = mColor[3]; | ||
107 | } | ||
108 | |||
109 | //-------------------------------------------------------------------- | ||
110 | // setColor() | ||
111 | //-------------------------------------------------------------------- | ||
112 | void LLViewerJointShape::setColor( F32 red, F32 green, F32 blue, F32 alpha ) | ||
113 | { | ||
114 | mColor[0] = red * sColorScale; | ||
115 | mColor[1] = green * sColorScale; | ||
116 | mColor[2] = blue * sColorScale; | ||
117 | mColor[3] = alpha; | ||
118 | } | ||
119 | |||
120 | |||
121 | //-------------------------------------------------------------------- | ||
122 | // getTexture() | ||
123 | //-------------------------------------------------------------------- | ||
124 | LLViewerImage *LLViewerJointShape::getTexture() | ||
125 | { | ||
126 | return mTexture; | ||
127 | } | ||
128 | |||
129 | //-------------------------------------------------------------------- | ||
130 | // setTexture() | ||
131 | //-------------------------------------------------------------------- | ||
132 | void LLViewerJointShape::setTexture( LLViewerImage *texture ) | ||
133 | { | ||
134 | mTexture = texture; | ||
135 | } | ||
136 | |||
137 | |||
138 | //-------------------------------------------------------------------- | ||
139 | // drawBone() | ||
140 | //-------------------------------------------------------------------- | ||
141 | void LLViewerJointShape::drawBone() | ||
142 | { | ||
143 | } | ||
144 | |||
145 | |||
146 | //-------------------------------------------------------------------- | ||
147 | // isTransparent() | ||
148 | //-------------------------------------------------------------------- | ||
149 | BOOL LLViewerJointShape::isTransparent() | ||
150 | { | ||
151 | return ( (mColor[3] < 1.0f) || | ||
152 | (!mTexture.isNull() && (mTexture->getComponents()==4)) ); | ||
153 | } | ||
154 | |||
155 | //-------------------------------------------------------------------- | ||
156 | // drawShape() | ||
157 | //-------------------------------------------------------------------- | ||
158 | U32 LLViewerJointShape::drawShape( F32 pixelArea ) | ||
159 | { | ||
160 | U32 triangle_count = 0; | ||
161 | |||
162 | //---------------------------------------------------------------- | ||
163 | // render ST_NULL | ||
164 | //---------------------------------------------------------------- | ||
165 | if (mType == ST_NULL) | ||
166 | { | ||
167 | return triangle_count; | ||
168 | } | ||
169 | |||
170 | //---------------------------------------------------------------- | ||
171 | // setup current color | ||
172 | //---------------------------------------------------------------- | ||
173 | glColor4fv(mColor.mV); | ||
174 | |||
175 | //---------------------------------------------------------------- | ||
176 | // setup current texture | ||
177 | //---------------------------------------------------------------- | ||
178 | glMatrixMode(GL_TEXTURE); | ||
179 | glPushMatrix(); | ||
180 | glLoadIdentity(); | ||
181 | if (mType == ST_SPHERE) | ||
182 | { | ||
183 | glTranslatef(-0.25f, 0.0f, 0.0f); | ||
184 | } | ||
185 | glMatrixMode(GL_MODELVIEW); | ||
186 | LLViewerImage::bindTexture(mTexture); | ||
187 | |||
188 | //---------------------------------------------------------------- | ||
189 | // update pixel area | ||
190 | //---------------------------------------------------------------- | ||
191 | F32 s1 = llmax( getScale().mV[VX], llmax( getScale().mV[VY], getScale().mV[VZ] ) ); | ||
192 | F32 s2 = llmin( getScale().mV[VX], llmax( getScale().mV[VY], getScale().mV[VZ] ) ); | ||
193 | pixelArea *= s1 * s2; | ||
194 | |||
195 | //---------------------------------------------------------------- | ||
196 | // render shape | ||
197 | //---------------------------------------------------------------- | ||
198 | switch ( mType ) | ||
199 | { | ||
200 | case ST_CUBE: | ||
201 | gBox.render(); | ||
202 | break; | ||
203 | |||
204 | case ST_SPHERE: | ||
205 | gSphere.render( pixelArea ); | ||
206 | break; | ||
207 | |||
208 | case ST_CYLINDER: | ||
209 | gCylinder.render( pixelArea ); | ||
210 | break; | ||
211 | |||
212 | default: | ||
213 | break; | ||
214 | } | ||
215 | |||
216 | //---------------------------------------------------------------- | ||
217 | // disable texture | ||
218 | //---------------------------------------------------------------- | ||
219 | if ( mTexture ) | ||
220 | { | ||
221 | glMatrixMode(GL_TEXTURE); | ||
222 | glPopMatrix(); | ||
223 | glMatrixMode(GL_MODELVIEW); | ||
224 | } | ||
225 | |||
226 | return triangle_count; | ||
227 | } | ||
228 | |||
229 | // End | ||