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/llcape.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/llcape.cpp')
-rw-r--r-- | linden/indra/newview/llcape.cpp | 638 |
1 files changed, 638 insertions, 0 deletions
diff --git a/linden/indra/newview/llcape.cpp b/linden/indra/newview/llcape.cpp new file mode 100644 index 0000000..327a0d0 --- /dev/null +++ b/linden/indra/newview/llcape.cpp | |||
@@ -0,0 +1,638 @@ | |||
1 | /** | ||
2 | * @file llcape.cpp | ||
3 | * @brief LLVOCloth class implementation | ||
4 | * | ||
5 | * Copyright (c) 2005-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 "llcape.h" | ||
31 | |||
32 | #include "llglheaders.h" | ||
33 | #include "llsphere.h" | ||
34 | #include "llrand.h" | ||
35 | #include "llvoavatar.h" | ||
36 | #include "llagent.h" | ||
37 | #include "llviewerobject.h" | ||
38 | #include "llimagegl.h" | ||
39 | #include "llviewerimagelist.h" | ||
40 | #include "llviewercontrol.h" | ||
41 | #include "llflexibleobject.h" | ||
42 | |||
43 | const int _X_ = 0; | ||
44 | const int _Y_ = 1; | ||
45 | const int _Z_ = 2; | ||
46 | const F32 ONE_HALF = 0.5f; | ||
47 | const F32 STRAND_VISUALIZATION_ANCHOR_BALL_RADIUS = 0.01f; | ||
48 | |||
49 | //----------------------------------------------- | ||
50 | // constructor | ||
51 | //----------------------------------------------- | ||
52 | LLVOCloth::LLVOCloth(const LLUUID &id, const LLPCode type, LLViewerRegion *regionp) | ||
53 | : LLViewerObject(id, type, regionp) | ||
54 | { | ||
55 | mAttributes.mTextureFileName = CLOTH_DEFAULT_TEXTURE_FILENAME; | ||
56 | mAttributes.mTextureIndex = CLOTH_DEFAULT_TEXTURE_INDEX; | ||
57 | mAttributes.mNumStrands = CLOTH_DEFAULT_NUM_STRANDS; | ||
58 | mAttributes.mNumSegments = CLOTH_DEFAULT_NUM_SEGMENTS; | ||
59 | mAttributes.mVisualizeStrands = CLOTH_DEFAULT_VISUALIZE_STRANDS; | ||
60 | mAttributes.mVisualizeAvCollisionSphere = CLOTH_DEFAULT_VISUALIZE_COLLISION_SPHERE; | ||
61 | mAttributes.mWidth = CLOTH_DEFAULT_WIDTH; | ||
62 | mAttributes.mLength = CLOTH_DEFAULT_LENGTH; | ||
63 | mAttributes.mPitch = CLOTH_DEFAULT_PITCH; | ||
64 | mAttributes.mGravity = CLOTH_DEFAULT_GRAVITY; | ||
65 | mAttributes.mTension = CLOTH_DEFAULT_TENSION; | ||
66 | mAttributes.mAirFriction = CLOTH_DEFAULT_AIR_FRICTION; | ||
67 | mAttributes.mWindSensitivity = CLOTH_DEFAULT_WIND_SENSITIVITY; | ||
68 | mAttributes.mCircleWrapAmount = CLOTH_DEFAULT_CIRCLE_WRAP_AMOUNT; | ||
69 | mAttributes.mUsingAvatarCollisionSphere = CLOTH_DEFAULT_USING_AVATAR_COLLISION_SPHERE; | ||
70 | //mAttributes.mAvatarCollisionSpherePositionOffset = CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_POSITION_OFFSET; | ||
71 | mAttributes.mAvatarCollisionSphereRadius = CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_RADIUS; | ||
72 | mAttributes.mAvatarCollisionSphereRightOffset = CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET; | ||
73 | mAttributes.mAvatarCollisionSphereUpOffset = CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_UP_OFFSET; | ||
74 | mAttributes.mAvatarCollisionSphereForwardOffset = CLOTH_DEFAULT_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET; | ||
75 | |||
76 | generateStrands(); | ||
77 | |||
78 | }//------------------------------------------------------------------------------ | ||
79 | |||
80 | |||
81 | //------------------------------------------------------------------------------ | ||
82 | // this method is only called when attributes of the cloth are set, | ||
83 | // and so it is not so important to try optimized it. | ||
84 | //------------------------------------------------------------------------------ | ||
85 | void LLVOCloth::generateStrands() | ||
86 | { | ||
87 | LLFlexibleObjectData strandAttributes; | ||
88 | |||
89 | bool oddNumStrands = (bool)( mAttributes.mNumStrands % 2 ); | ||
90 | F32 piOver180 = F_PI / 180.0f; | ||
91 | F32 x = 0.0f; | ||
92 | F32 y = 0.0f; | ||
93 | F32 startAngle = -mAttributes.mCircleWrapAmount * 180.0f; | ||
94 | F32 angleDelta = ( mAttributes.mCircleWrapAmount * 360.0f ) / (F32)( mAttributes.mNumStrands - 1 ); | ||
95 | F32 subWidth = mAttributes.mWidth / (F32)( mAttributes.mNumStrands - 1 ); | ||
96 | |||
97 | F32 angle = 0.0f; | ||
98 | |||
99 | if ( mAttributes.mNumStrands > 2 ) | ||
100 | { | ||
101 | angle = startAngle; | ||
102 | } | ||
103 | |||
104 | //------------------------------------------- | ||
105 | // displace x and y to start the process of | ||
106 | // iterating through the positional offsets | ||
107 | //------------------------------------------- | ||
108 | if ( ! oddNumStrands ) | ||
109 | { | ||
110 | y += subWidth * ONE_HALF; | ||
111 | } | ||
112 | |||
113 | int half = mAttributes.mNumStrands / 2; | ||
114 | for ( int s=0; s<half; s ++) | ||
115 | { | ||
116 | if ( mAttributes.mNumStrands > 2 ) | ||
117 | { | ||
118 | angle += angleDelta; | ||
119 | } | ||
120 | |||
121 | F32 r = angle * piOver180; | ||
122 | x -= subWidth * sin(r); | ||
123 | y -= subWidth * cos(r); | ||
124 | } | ||
125 | |||
126 | |||
127 | if ( mAttributes.mNumStrands > 2 ) | ||
128 | { | ||
129 | angle = startAngle; | ||
130 | } | ||
131 | else | ||
132 | { | ||
133 | angle = 0.0f; | ||
134 | } | ||
135 | |||
136 | |||
137 | for ( int s=0; s<mAttributes.mNumStrands; s ++) | ||
138 | { | ||
139 | //strandAttributes.mAnchorPositionOffset.setVec( x, y, 0.0f ); | ||
140 | |||
141 | if ( mAttributes.mNumStrands > 2 ) | ||
142 | { | ||
143 | angle += angleDelta; | ||
144 | } | ||
145 | |||
146 | F32 r = angle * piOver180; | ||
147 | F32 dX = subWidth * sin(r); | ||
148 | F32 dY = subWidth * cos(r); | ||
149 | x += dX; | ||
150 | y += dY; | ||
151 | |||
152 | //-------------------------------------------------- | ||
153 | // set anchor directions | ||
154 | //-------------------------------------------------- | ||
155 | LLVector3 perpendicular; | ||
156 | perpendicular.setVec( -dY, dX, 0.0f ); | ||
157 | perpendicular.normVec(); | ||
158 | |||
159 | //F32 pitchRadian = mAttributes.mPitch * F_PI_BY_TWO; | ||
160 | |||
161 | /*strandAttributes.mAnchorDirection.setVec | ||
162 | ( | ||
163 | perpendicular.mV[_X_] * cos( pitchRadian ), | ||
164 | perpendicular.mV[_Y_] * cos( pitchRadian ), | ||
165 | sin( pitchRadian ) | ||
166 | );*/ | ||
167 | |||
168 | //strandAttributes.mAnchorDirection.normVec(); // just to be sure... | ||
169 | |||
170 | /*strandAttributes.mTension = mAttributes.mTension; | ||
171 | strandAttributes.mSimulateLOD = mAttributes.mNumSegments; | ||
172 | strandAttributes.mGravity = mAttributes.mGravity; | ||
173 | strandAttributes.mAirFriction = mAttributes.mAirFriction; | ||
174 | strandAttributes.mWindSensitivity = mAttributes.mWindSensitivity; | ||
175 | strandAttributes.mUsingCollisionSphere = mAttributes.mUsingAvatarCollisionSphere;*/ | ||
176 | } | ||
177 | |||
178 | }//------------------------------------------------------------------------------ | ||
179 | |||
180 | |||
181 | |||
182 | |||
183 | |||
184 | |||
185 | //--------------------------------------------------------------------------------- | ||
186 | void LLVOCloth::update() | ||
187 | { | ||
188 | if ( mAttributes.mUsingAvatarCollisionSphere ) | ||
189 | { | ||
190 | LLVector3 offset; | ||
191 | offset.setVec | ||
192 | ( | ||
193 | mAttributes.mAvatarCollisionSphereForwardOffset, // in this strange world, forward is along X (I think that's kinda wierd) | ||
194 | mAttributes.mAvatarCollisionSphereRightOffset, | ||
195 | mAttributes.mAvatarCollisionSphereUpOffset | ||
196 | ); | ||
197 | |||
198 | //------------------------------------------------------ | ||
199 | // rotate into avatar space | ||
200 | //------------------------------------------------------ | ||
201 | offset *= gAgent.getAvatarObject()->getRenderRotation(); | ||
202 | |||
203 | mAvatarCollisionSpherePosition = gAgent.getAvatarObject()->getRenderPosition() + offset; | ||
204 | } | ||
205 | |||
206 | if ( mParent ) | ||
207 | { | ||
208 | // update the attachment of the strands to their parent object, and let them flop around! | ||
209 | for ( int s=0; s<mAttributes.mNumStrands; s++) | ||
210 | { | ||
211 | mStrand[s]->setParentPositionAndRotationDirectly( getRenderPosition(), getRenderRotation() ); | ||
212 | //mStrand[s]->update(); | ||
213 | |||
214 | if ( mAttributes.mUsingAvatarCollisionSphere ) | ||
215 | { | ||
216 | // it's not efficient to create the exact same collision | ||
217 | // sphere for every strand, but it'll do for the time being | ||
218 | mStrand[s]->setCollisionSphere( mAvatarCollisionSpherePosition, mAttributes.mAvatarCollisionSphereRadius ); | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | |||
223 | }//------------------------------------------------------------------ | ||
224 | |||
225 | |||
226 | |||
227 | |||
228 | //------------------------------------------------------------------ | ||
229 | void LLVOCloth::render() | ||
230 | { | ||
231 | if ( mAttributes.mTextureFileName != "not_specified" ) | ||
232 | { | ||
233 | LLViewerImage* theTexture = gImageList.getImage( LLUUID( gViewerArt.getString( mAttributes.mTextureFileName ) ), MIPMAP_FALSE, TRUE); | ||
234 | if ( theTexture ) | ||
235 | { | ||
236 | /*if ( mAttributes.mVisualizeAvCollisionSphere ) | ||
237 | { | ||
238 | for ( int s=0; s<mAttributes.mNumStrands; s++) | ||
239 | { | ||
240 | mStrand[s]->renderCollisionSphere(); | ||
241 | } | ||
242 | }*/ | ||
243 | |||
244 | if ( mAttributes.mVisualizeStrands ) | ||
245 | { | ||
246 | for ( int s=0; s<mAttributes.mNumStrands; s++) | ||
247 | { | ||
248 | //------------------------------------------------ | ||
249 | // draw a small sphere at the top of the strand | ||
250 | //------------------------------------------------ | ||
251 | glPushMatrix(); | ||
252 | |||
253 | glTranslatef | ||
254 | ( | ||
255 | mStrand[s]->getAnchorPosition().mV[_X_], | ||
256 | mStrand[s]->getAnchorPosition().mV[_Y_], | ||
257 | mStrand[s]->getAnchorPosition().mV[_Z_] | ||
258 | ); | ||
259 | |||
260 | glScalef | ||
261 | ( | ||
262 | STRAND_VISUALIZATION_ANCHOR_BALL_RADIUS, | ||
263 | STRAND_VISUALIZATION_ANCHOR_BALL_RADIUS, | ||
264 | STRAND_VISUALIZATION_ANCHOR_BALL_RADIUS | ||
265 | ); | ||
266 | |||
267 | gSphere.render(); | ||
268 | glPopMatrix(); | ||
269 | |||
270 | //-------------------------------- | ||
271 | // draw the strand | ||
272 | //-------------------------------- | ||
273 | //mStrand[s]->render(); | ||
274 | |||
275 | |||
276 | |||
277 | |||
278 | |||
279 | |||
280 | |||
281 | //-------------------------------------------- | ||
282 | // draw the segments between the strands | ||
283 | //-------------------------------------------- | ||
284 | if ( s > 0 ) | ||
285 | { | ||
286 | //-------------------------------- | ||
287 | // draw the top edge... | ||
288 | //-------------------------------- | ||
289 | glBegin( GL_LINES ); | ||
290 | glVertex3fv( mStrand[s-1]->getAnchorPosition().mV ); | ||
291 | glVertex3fv( mStrand[s ]->getAnchorPosition().mV ); | ||
292 | glEnd(); | ||
293 | |||
294 | //-------------------------------------------- | ||
295 | // draw the rest of the segments | ||
296 | //-------------------------------------------- | ||
297 | for ( int i=0; i<mAttributes.mNumSegments; i++) | ||
298 | { | ||
299 | glBegin( GL_LINES ); | ||
300 | glVertex3fv( mStrand[s-1]->getNodePosition(i).mV ); | ||
301 | glVertex3fv( mStrand[s ]->getNodePosition(i).mV ); | ||
302 | glEnd(); | ||
303 | } | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | |||
308 | //-------------------------------------------------------- | ||
309 | // now, render the cape itself | ||
310 | //-------------------------------------------------------- | ||
311 | glColor4fv( LLColor4( 1.0f, 1.0f, 1.0f, 1.0f ).mV ); | ||
312 | |||
313 | for ( int s=1; s<mAttributes.mNumStrands; s++) | ||
314 | { | ||
315 | //to be optimized later (should be calculated only once and stored in an array) | ||
316 | F32 x0 = (F32)(s-1) / (F32)( mAttributes.mNumStrands - 1 ); | ||
317 | F32 x1 = (F32)s / (F32)( mAttributes.mNumStrands - 1 ); | ||
318 | |||
319 | for ( int i=0; i<mAttributes.mNumSegments; i++) | ||
320 | { | ||
321 | LLVector3 leftBottom; | ||
322 | LLVector3 rightBottom; | ||
323 | LLVector3 leftTop; | ||
324 | LLVector3 rightTop; | ||
325 | |||
326 | F32 y0 = (F32)i / (F32)mAttributes.mNumSegments; | ||
327 | F32 y1 = (F32)(i+1) / (F32)mAttributes.mNumSegments; | ||
328 | |||
329 | y0 = 1.0f - y0; | ||
330 | y1 = 1.0f - y1; | ||
331 | |||
332 | if ( i == 0 ) | ||
333 | { | ||
334 | leftBottom = mStrand[ s-1 ]->getAnchorPosition(); | ||
335 | rightBottom = mStrand[ s ]->getAnchorPosition(); | ||
336 | } | ||
337 | else | ||
338 | { | ||
339 | leftBottom = mStrand[ s-1 ]->getNodePosition( i-1 ); | ||
340 | rightBottom = mStrand[ s ]->getNodePosition( i-1 ); | ||
341 | } | ||
342 | |||
343 | leftTop = mStrand[ s-1 ]->getNodePosition( i ); | ||
344 | rightTop = mStrand[ s ]->getNodePosition( i ); | ||
345 | |||
346 | //gGLSTexture.set(); //set render state to use texture | ||
347 | LLViewerImage::bindTexture(theTexture); | ||
348 | |||
349 | glBegin( GL_TRIANGLE_STRIP ); | ||
350 | glTexCoord2f( x0, y0 ); glVertex3fv( leftBottom.mV ); | ||
351 | glTexCoord2f( x1, y0 ); glVertex3fv( rightBottom.mV ); | ||
352 | glTexCoord2f( x0, y1 ); glVertex3fv( leftTop.mV ); | ||
353 | glEnd(); | ||
354 | glBegin( GL_TRIANGLE_STRIP ); | ||
355 | glTexCoord2f( x1, y0 ); glVertex3fv( rightBottom.mV ); | ||
356 | glTexCoord2f( x1, y1 ); glVertex3fv( rightTop.mV ); | ||
357 | glTexCoord2f( x0, y1 ); glVertex3fv( leftTop.mV ); | ||
358 | glEnd(); | ||
359 | |||
360 | theTexture->unbindTexture(0, GL_TEXTURE_2D); | ||
361 | } | ||
362 | } | ||
363 | } | ||
364 | } | ||
365 | |||
366 | }//------------------------------------------------------------------ | ||
367 | |||
368 | |||
369 | |||
370 | |||
371 | //------------------------------------------------------------------ | ||
372 | void LLVOCloth::setAttributes( LLClothAttributes a ) | ||
373 | { | ||
374 | mAttributes.mTextureFileName = a.mTextureFileName; | ||
375 | mAttributes.mTextureIndex = a.mTextureIndex; | ||
376 | mAttributes.mNumSegments = a.mNumSegments; | ||
377 | mAttributes.mNumStrands = a.mNumStrands; | ||
378 | mAttributes.mVisualizeStrands = a.mVisualizeStrands; | ||
379 | mAttributes.mVisualizeAvCollisionSphere = a.mVisualizeAvCollisionSphere; | ||
380 | mAttributes.mWidth = a.mWidth; | ||
381 | mAttributes.mLength = a.mLength; | ||
382 | mAttributes.mPitch = a.mPitch; | ||
383 | mAttributes.mTension = a.mTension; | ||
384 | mAttributes.mGravity = a.mGravity; | ||
385 | mAttributes.mAirFriction = a.mAirFriction; | ||
386 | mAttributes.mWindSensitivity = a.mWindSensitivity; | ||
387 | mAttributes.mCircleWrapAmount = a.mCircleWrapAmount; | ||
388 | mAttributes.mUsingAvatarCollisionSphere = a.mUsingAvatarCollisionSphere; | ||
389 | //mAttributes.mAvatarCollisionSpherePositionOffset = a.mAvatarCollisionSpherePositionOffset; | ||
390 | mAttributes.mAvatarCollisionSphereRadius = a.mAvatarCollisionSphereRadius; | ||
391 | mAttributes.mAvatarCollisionSphereRightOffset = a.mAvatarCollisionSphereRightOffset; | ||
392 | mAttributes.mAvatarCollisionSphereUpOffset = a.mAvatarCollisionSphereUpOffset; | ||
393 | mAttributes.mAvatarCollisionSphereForwardOffset = a.mAvatarCollisionSphereForwardOffset; | ||
394 | |||
395 | |||
396 | if ( mAttributes.mTextureIndex < CLOTH_MIN_TEXTURE_INDEX ){ mAttributes.mTextureIndex = CLOTH_MIN_TEXTURE_INDEX; } | ||
397 | else if ( mAttributes.mTextureIndex > CLOTH_MAX_TEXTURE_INDEX ){ mAttributes.mTextureIndex = CLOTH_MAX_TEXTURE_INDEX; } | ||
398 | if ( mAttributes.mPitch < CLOTH_MIN_PITCH ){ mAttributes.mPitch = CLOTH_MIN_PITCH; } | ||
399 | else if ( mAttributes.mPitch > CLOTH_MAX_PITCH ){ mAttributes.mPitch = CLOTH_MAX_PITCH; } | ||
400 | if ( mAttributes.mWidth < CLOTH_MIN_WIDTH ){ mAttributes.mWidth = CLOTH_MIN_WIDTH; } | ||
401 | else if ( mAttributes.mWidth > CLOTH_MAX_WIDTH ){ mAttributes.mWidth = CLOTH_MAX_WIDTH; } | ||
402 | if ( mAttributes.mLength < CLOTH_MIN_LENGTH ){ mAttributes.mLength = CLOTH_MIN_LENGTH; } | ||
403 | else if ( mAttributes.mLength > CLOTH_MAX_LENGTH ){ mAttributes.mLength = CLOTH_MAX_LENGTH; } | ||
404 | if ( mAttributes.mNumSegments < CLOTH_MIN_SEGMENTS ){ mAttributes.mNumSegments = CLOTH_MIN_SEGMENTS; } | ||
405 | else if ( mAttributes.mNumSegments > CLOTH_MAX_SEGMENTS ){ mAttributes.mNumSegments = CLOTH_MAX_SEGMENTS; } | ||
406 | if ( mAttributes.mNumStrands < CLOTH_MIN_STRANDS ){ mAttributes.mNumStrands = CLOTH_MIN_STRANDS; } | ||
407 | else if ( mAttributes.mNumStrands > CLOTH_MAX_STRANDS ){ mAttributes.mNumStrands = CLOTH_MAX_STRANDS; } | ||
408 | if ( mAttributes.mTension < CLOTH_MIN_TENSION ){ mAttributes.mTension = CLOTH_MIN_TENSION; } | ||
409 | else if ( mAttributes.mTension > CLOTH_MAX_TENSION ){ mAttributes.mTension = CLOTH_MAX_TENSION; } | ||
410 | if ( mAttributes.mGravity < CLOTH_MIN_GRAVITY ){ mAttributes.mGravity = CLOTH_MIN_GRAVITY; } | ||
411 | else if ( mAttributes.mGravity > CLOTH_MAX_GRAVITY ){ mAttributes.mGravity = CLOTH_MAX_GRAVITY; } | ||
412 | if ( mAttributes.mAirFriction < CLOTH_MIN_AIR_FRICTION ){ mAttributes.mAirFriction = CLOTH_MIN_AIR_FRICTION; } | ||
413 | else if ( mAttributes.mAirFriction > CLOTH_MAX_AIR_FRICTION ){ mAttributes.mAirFriction = CLOTH_MAX_AIR_FRICTION; } | ||
414 | if ( mAttributes.mWindSensitivity < CLOTH_MIN_WIND_SENSITIVITY ){ mAttributes.mWindSensitivity = CLOTH_MIN_WIND_SENSITIVITY;} | ||
415 | else if ( mAttributes.mWindSensitivity > CLOTH_MAX_WIND_SENSITIVITY ){ mAttributes.mWindSensitivity = CLOTH_MAX_WIND_SENSITIVITY;} | ||
416 | if ( mAttributes.mCircleWrapAmount < CLOTH_MIN_CIRCLE_WRAP_AMOUNT ){ mAttributes.mCircleWrapAmount = CLOTH_MIN_CIRCLE_WRAP_AMOUNT;} | ||
417 | else if ( mAttributes.mCircleWrapAmount > CLOTH_MAX_CIRCLE_WRAP_AMOUNT ){ mAttributes.mCircleWrapAmount = CLOTH_MAX_CIRCLE_WRAP_AMOUNT;} | ||
418 | |||
419 | if ( mAttributes.mAvatarCollisionSphereRadius < CLOTH_MIN_AVATAR_COLLISION_SPHERE_RADIUS ){ mAttributes.mAvatarCollisionSphereRadius = CLOTH_MIN_AVATAR_COLLISION_SPHERE_RADIUS;} | ||
420 | else if ( mAttributes.mAvatarCollisionSphereRadius > CLOTH_MAX_AVATAR_COLLISION_SPHERE_RADIUS ){ mAttributes.mAvatarCollisionSphereRadius = CLOTH_MAX_AVATAR_COLLISION_SPHERE_RADIUS;} | ||
421 | if ( mAttributes.mAvatarCollisionSphereRightOffset < CLOTH_MIN_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET ){ mAttributes.mAvatarCollisionSphereRightOffset = CLOTH_MIN_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET;} | ||
422 | else if ( mAttributes.mAvatarCollisionSphereRightOffset > CLOTH_MAX_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET ){ mAttributes.mAvatarCollisionSphereRightOffset = CLOTH_MAX_AVATAR_COLLISION_SPHERE_RIGHT_OFFSET;} | ||
423 | if ( mAttributes.mAvatarCollisionSphereUpOffset < CLOTH_MIN_AVATAR_COLLISION_SPHERE_UP_OFFSET ){ mAttributes.mAvatarCollisionSphereUpOffset = CLOTH_MIN_AVATAR_COLLISION_SPHERE_UP_OFFSET;} | ||
424 | else if ( mAttributes.mAvatarCollisionSphereUpOffset > CLOTH_MAX_AVATAR_COLLISION_SPHERE_UP_OFFSET ){ mAttributes.mAvatarCollisionSphereUpOffset = CLOTH_MAX_AVATAR_COLLISION_SPHERE_UP_OFFSET;} | ||
425 | if ( mAttributes.mAvatarCollisionSphereForwardOffset < CLOTH_MIN_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET ){ mAttributes.mAvatarCollisionSphereForwardOffset = CLOTH_MIN_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET;} | ||
426 | else if ( mAttributes.mAvatarCollisionSphereForwardOffset > CLOTH_MAX_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET ){ mAttributes.mAvatarCollisionSphereForwardOffset = CLOTH_MAX_AVATAR_COLLISION_SPHERE_FORWARD_OFFSET;} | ||
427 | |||
428 | //----------------------------------------------------------------------------------- | ||
429 | // based on the above attributes, the strands (flexible objects) are generated | ||
430 | //----------------------------------------------------------------------------------- | ||
431 | generateStrands(); | ||
432 | |||
433 | }//------------------------------------------------------------------ | ||
434 | |||
435 | |||
436 | |||
437 | |||
438 | |||
439 | //------------------------------------------------------------------ | ||
440 | // set methods | ||
441 | //------------------------------------------------------------------ | ||
442 | |||
443 | //------------------------------------------------------------------ | ||
444 | void LLVOCloth::setNumStrands( int num ) | ||
445 | { | ||
446 | mAttributes.mNumStrands = num; | ||
447 | generateStrands(); | ||
448 | }//------------------------------------------------------------------ | ||
449 | //------------------------------------------------------------------ | ||
450 | void LLVOCloth::setNumSegments( int num ) | ||
451 | { | ||
452 | mAttributes.mNumSegments = num; | ||
453 | generateStrands(); | ||
454 | }//------------------------------------------------------------------ | ||
455 | //------------------------------------------------------------------ | ||
456 | void LLVOCloth::setLength( F32 le ) | ||
457 | { | ||
458 | mAttributes.mLength = le; | ||
459 | generateStrands(); | ||
460 | }//------------------------------------------------------------------ | ||
461 | //------------------------------------------------------------------ | ||
462 | void LLVOCloth::setCircleWrapAmount( F32 n ) | ||
463 | { | ||
464 | mAttributes.mCircleWrapAmount = n; | ||
465 | generateStrands(); | ||
466 | }//------------------------------------------------------------------ | ||
467 | //------------------------------------------------------------------ | ||
468 | void LLVOCloth::setGravity( F32 g ) | ||
469 | { | ||
470 | mAttributes.mGravity = g; | ||
471 | generateStrands(); | ||
472 | }//------------------------------------------------------------------ | ||
473 | //------------------------------------------------------------------ | ||
474 | void LLVOCloth::setPitch( F32 p ) | ||
475 | { | ||
476 | mAttributes.mPitch = p; | ||
477 | generateStrands(); | ||
478 | }//------------------------------------------------------------------ | ||
479 | //------------------------------------------------------------------ | ||
480 | void LLVOCloth::setAirFriction( F32 a ) | ||
481 | { | ||
482 | mAttributes.mAirFriction = a; | ||
483 | generateStrands(); | ||
484 | }//------------------------------------------------------------------ | ||
485 | //------------------------------------------------------------------ | ||
486 | void LLVOCloth::setWindSensitivity( F32 w ) | ||
487 | { | ||
488 | mAttributes.mWindSensitivity = w; | ||
489 | generateStrands(); | ||
490 | }//------------------------------------------------------------------ | ||
491 | //------------------------------------------------------------------ | ||
492 | void LLVOCloth::setTension( F32 t ) | ||
493 | { | ||
494 | mAttributes.mTension = t; | ||
495 | generateStrands(); | ||
496 | }//------------------------------------------------------------------ | ||
497 | //------------------------------------------------------------------ | ||
498 | void LLVOCloth::setWidth( F32 n ) | ||
499 | { | ||
500 | mAttributes.mWidth = n; | ||
501 | generateStrands(); | ||
502 | }//------------------------------------------------------------------ | ||
503 | //------------------------------------------------------------------ | ||
504 | void LLVOCloth::setVisualizingStrands( bool v ) | ||
505 | { | ||
506 | mAttributes.mVisualizeStrands = v; | ||
507 | }//------------------------------------------------------------------//------------------------------------------------------------------ | ||
508 | void LLVOCloth::setVisualizingAvCollisionSphere( bool v ) | ||
509 | { | ||
510 | mAttributes.mVisualizeAvCollisionSphere = v; | ||
511 | }//------------------------------------------------------------------ | ||
512 | //------------------------------------------------------------------ | ||
513 | void LLVOCloth::setAvatarCollisionSphereRadius( F32 r ) | ||
514 | { | ||
515 | mAttributes.mAvatarCollisionSphereRadius = r; | ||
516 | |||
517 | }//------------------------------------------------------------------ | ||
518 | //------------------------------------------------------------------ | ||
519 | void LLVOCloth::setAvatarCollisionSphereRight( F32 r ) | ||
520 | { | ||
521 | mAttributes.mAvatarCollisionSphereRightOffset = r; | ||
522 | |||
523 | }//------------------------------------------------------------------ | ||
524 | //------------------------------------------------------------------ | ||
525 | void LLVOCloth::setAvatarCollisionSphereUp( F32 u ) | ||
526 | { | ||
527 | mAttributes.mAvatarCollisionSphereUpOffset = u; | ||
528 | |||
529 | }//------------------------------------------------------------------ | ||
530 | //------------------------------------------------------------------ | ||
531 | void LLVOCloth::setAvatarCollisionSphereForward( F32 f ) | ||
532 | { | ||
533 | mAttributes.mAvatarCollisionSphereForwardOffset = f; | ||
534 | |||
535 | }//------------------------------------------------------------------ | ||
536 | |||
537 | |||
538 | //------------------------------------------------------------------ | ||
539 | // get methods | ||
540 | //------------------------------------------------------------------ | ||
541 | |||
542 | //------------------------------------------------------------------ | ||
543 | int LLVOCloth::getNumStrands() | ||
544 | { | ||
545 | return mAttributes.mNumStrands; | ||
546 | }//------------------------------------------------------------------ | ||
547 | //------------------------------------------------------------------ | ||
548 | int LLVOCloth::getNumSegments() | ||
549 | { | ||
550 | return mAttributes.mNumSegments; | ||
551 | }//------------------------------------------------------------------ | ||
552 | //------------------------------------------------------------------ | ||
553 | F32 LLVOCloth::getLength() | ||
554 | { | ||
555 | return mAttributes.mLength; | ||
556 | }//------------------------------------------------------------------ | ||
557 | //------------------------------------------------------------------ | ||
558 | F32 LLVOCloth::getWidth() | ||
559 | { | ||
560 | return mAttributes.mWidth; | ||
561 | }//------------------------------------------------------------------ | ||
562 | //------------------------------------------------------------------ | ||
563 | F32 LLVOCloth::getCircleWrapAmount() | ||
564 | { | ||
565 | return mAttributes.mCircleWrapAmount; | ||
566 | }//------------------------------------------------------------------ | ||
567 | //------------------------------------------------------------------ | ||
568 | F32 LLVOCloth::getPitch() | ||
569 | { | ||
570 | return mAttributes.mPitch; | ||
571 | }//------------------------------------------------------------------ | ||
572 | //------------------------------------------------------------------ | ||
573 | F32 LLVOCloth::getTension() | ||
574 | { | ||
575 | return mAttributes.mTension; | ||
576 | }//------------------------------------------------------------------ | ||
577 | //------------------------------------------------------------------ | ||
578 | F32 LLVOCloth::getGravity() | ||
579 | { | ||
580 | return mAttributes.mGravity; | ||
581 | }//------------------------------------------------------------------ | ||
582 | //------------------------------------------------------------------ | ||
583 | F32 LLVOCloth::getAirFriction() | ||
584 | { | ||
585 | return mAttributes.mAirFriction; | ||
586 | }//------------------------------------------------------------------ | ||
587 | //------------------------------------------------------------------ | ||
588 | F32 LLVOCloth::getWindSensitivity() | ||
589 | { | ||
590 | return mAttributes.mWindSensitivity; | ||
591 | }//------------------------------------------------------------------ | ||
592 | //------------------------------------------------------------------ | ||
593 | bool LLVOCloth::getVisualizingStrands() const | ||
594 | { | ||
595 | return mAttributes.mVisualizeStrands; | ||
596 | }//------------------------------------------------------------------ | ||
597 | //------------------------------------------------------------------ | ||
598 | bool LLVOCloth::getVisualizingAvCollisionSphere() const | ||
599 | { | ||
600 | return mAttributes.mVisualizeAvCollisionSphere; | ||
601 | }//------------------------------------------------------------------ | ||
602 | //------------------------------------------------------------------ | ||
603 | F32 LLVOCloth::getAvatarCollisionSphereRadius() | ||
604 | { | ||
605 | return mAttributes.mAvatarCollisionSphereRadius; | ||
606 | }//------------------------------------------------------------------ | ||
607 | //------------------------------------------------------------------ | ||
608 | F32 LLVOCloth::getAvatarCollisionSphereRight() | ||
609 | { | ||
610 | return mAttributes.mAvatarCollisionSphereRightOffset; | ||
611 | }//------------------------------------------------------------------ | ||
612 | //------------------------------------------------------------------ | ||
613 | F32 LLVOCloth::getAvatarCollisionSphereUp() | ||
614 | { | ||
615 | return mAttributes.mAvatarCollisionSphereUpOffset; | ||
616 | }//------------------------------------------------------------------ | ||
617 | //------------------------------------------------------------------ | ||
618 | F32 LLVOCloth::getAvatarCollisionSphereForward() | ||
619 | { | ||
620 | return mAttributes.mAvatarCollisionSphereForwardOffset; | ||
621 | }//------------------------------------------------------------------ | ||
622 | |||
623 | |||
624 | |||
625 | //------------------------------------------------------------------ | ||
626 | void LLVOCloth::markAsDead() | ||
627 | { | ||
628 | mDead = TRUE; | ||
629 | |||
630 | }//------------------------------------------------------------------ | ||
631 | |||
632 | |||
633 | |||
634 | |||
635 | |||
636 | |||
637 | |||
638 | |||