diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llanimalcontrols.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llanimalcontrols.cpp')
-rw-r--r-- | linden/indra/newview/llanimalcontrols.cpp | 458 |
1 files changed, 0 insertions, 458 deletions
diff --git a/linden/indra/newview/llanimalcontrols.cpp b/linden/indra/newview/llanimalcontrols.cpp deleted file mode 100644 index f3ba729..0000000 --- a/linden/indra/newview/llanimalcontrols.cpp +++ /dev/null | |||
@@ -1,458 +0,0 @@ | |||
1 | /** | ||
2 | * @file llanimalcontrols.cpp | ||
3 | * @brief LLAnimalControl class implementation | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2005&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2005-2008, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
34 | #include "llanimalcontrols.h" | ||
35 | #include "llglheaders.h" | ||
36 | #include "llsphere.h" | ||
37 | #include "llrand.h" | ||
38 | #include "llviewerobject.h" | ||
39 | |||
40 | /* | ||
41 | //const F32 ANIMAL_CONTROLS_MAX_TENSION_FORCE = 0.99f;// I'll explain in a minute... | ||
42 | //const F32 ANIMAL_CONTROLS_MINIMUM_RADIUS = 0.005f; | ||
43 | |||
44 | const F32 OPACITY = 1.0f; | ||
45 | const int _X_ = 0; | ||
46 | const int _Y_ = 1; | ||
47 | const int _Z_ = 2; | ||
48 | const F32 BODY_RADIUS = 0.2f; | ||
49 | const F32 HEAD_RADIUS = 0.1f; | ||
50 | const F32 ONE_HALF = 0.5f; | ||
51 | |||
52 | //----------------------------------------------- | ||
53 | // constructor | ||
54 | //----------------------------------------------- | ||
55 | LLHUDAnimalControls::LLHUDAnimalControls() | ||
56 | : LLHUDObject( LL_HUD_ANIMAL_CONTROLS )// cal the base class and pass this in, K? | ||
57 | { | ||
58 | mParentObject = NULL; | ||
59 | |||
60 | }//------------------------------------------------------------------------------ | ||
61 | |||
62 | |||
63 | |||
64 | |||
65 | //--------------------------------------------------------------------------------- | ||
66 | //--------------------------------------------------------------------------------- | ||
67 | // Virtual Server methods... | ||
68 | //--------------------------------------------------------------------------------- | ||
69 | //--------------------------------------------------------------------------------- | ||
70 | LLAnimalControlsVirtualServer::LLAnimalControlsVirtualServer() | ||
71 | { | ||
72 | focusPosition.setVec( 0.0f, 0.0f, 0.0f ); | ||
73 | animalPosition.setVec( 0.0f, 0.0f, 0.0f ); | ||
74 | animalRotation = LLQuaternion::DEFAULT; | ||
75 | fakeClock = 0; | ||
76 | settingFocusPosition = false; | ||
77 | |||
78 | }//--------------------------------------------------------------------------------- | ||
79 | |||
80 | |||
81 | |||
82 | //--------------------------------------------------------------------------------- | ||
83 | void LLAnimalControlsVirtualServer::update() | ||
84 | { | ||
85 | fakeClock ++; | ||
86 | |||
87 | if ( settingFocusPosition ) | ||
88 | { | ||
89 | settingFocusPosition = false; | ||
90 | } | ||
91 | |||
92 | if ( fakeClock == 20 ) | ||
93 | { | ||
94 | fakeClock = 0; | ||
95 | |||
96 | settingFocusPosition = true; | ||
97 | |||
98 | LLMatrix3 bodyRotationMatrix = animalRotation.getMatrix3(); | ||
99 | |||
100 | LLVector3 forwardDirection = bodyRotationMatrix.getLeftRow(); | ||
101 | LLVector3 leftDirection = bodyRotationMatrix.getFwdRow(); | ||
102 | |||
103 | forwardDirection.mV[_Z_] = 0.0f; | ||
104 | forwardDirection.normVec(); | ||
105 | |||
106 | focusPosition = animalPosition + forwardDirection * 5.0f; | ||
107 | |||
108 | F32 leftRightSpan = 5.0f; | ||
109 | |||
110 | F32 randomSpan = ll_frand( leftRightSpan ); | ||
111 | |||
112 | focusPosition += leftDirection * ( - leftRightSpan * ONE_HALF + randomSpan ); | ||
113 | } | ||
114 | |||
115 | }//------------------------------------------------------------------------------ | ||
116 | |||
117 | |||
118 | |||
119 | //--------------------------------------------------------------------------------- | ||
120 | bool LLAnimalControlsVirtualServer::getSettingFocusPosition() | ||
121 | { | ||
122 | return settingFocusPosition; | ||
123 | |||
124 | }//------------------------------------------------------------------------------ | ||
125 | |||
126 | //--------------------------------------------------------------------------------- | ||
127 | LLVector3 LLAnimalControlsVirtualServer::getFocusPosition() | ||
128 | { | ||
129 | return focusPosition; | ||
130 | |||
131 | }//------------------------------------------------------------------------------ | ||
132 | |||
133 | |||
134 | //--------------------------------------------------------------------------------- | ||
135 | void LLAnimalControlsVirtualServer::setParentPositionAndRotation( LLVector3 p, LLQuaternion r ) | ||
136 | { | ||
137 | animalPosition = p; | ||
138 | animalRotation = r; | ||
139 | |||
140 | }//------------------------------------------------------------------------------ | ||
141 | |||
142 | //--------------------------------------------------------------------------------- | ||
143 | //--------------------------------------------------------------------------------- | ||
144 | // End of Virtual Server methods... | ||
145 | //--------------------------------------------------------------------------------- | ||
146 | //--------------------------------------------------------------------------------- | ||
147 | |||
148 | |||
149 | |||
150 | |||
151 | //--------------------------------------------------------------------------------- | ||
152 | //--------------------------------------------------------------------------------- | ||
153 | // Head behavior methods... | ||
154 | //--------------------------------------------------------------------------------- | ||
155 | //--------------------------------------------------------------------------------- | ||
156 | LLAnimalControlsHeadBehavior::LLAnimalControlsHeadBehavior() | ||
157 | { | ||
158 | mPosition.setVec ( 0.0f, 0.0f, 0.0f ); | ||
159 | mFocusPosition.setVec ( 0.0f, 0.0f, 0.0f ); | ||
160 | mBodyPosition.setVec ( 0.0f, 0.0f, 0.0f ); | ||
161 | mRotation = LLQuaternion::DEFAULT; | ||
162 | mEyesBlinking = true; | ||
163 | mEyeBlinkRate = 0.1f; | ||
164 | mBodyRotation = LLQuaternion::DEFAULT; | ||
165 | |||
166 | LLFlexibleObjectAttributes headFeatherAttributes; | ||
167 | headFeatherAttributes.mAnchorPositionOffset.setVec( 0.0f, 0.0f, 0.1f ); | ||
168 | headFeatherAttributes.mAnchorDirection.setVec( 0.0f, 1.0f, 1.0f ); | ||
169 | headFeatherAttributes.mAnchorDirection.normVec(); | ||
170 | headFeatherAttributes.mColor = LLColor4( 1.0f, 0.4f, 0.0f, 1.0f ); | ||
171 | headFeatherAttributes.mAnchorRadius = 0.01f; | ||
172 | headFeatherAttributes.mLength = 0.4f; | ||
173 | headFeatherAttributes.mEndRadius = 0.06f; | ||
174 | headFeatherAttributes.mRenderStyle = "tube"; | ||
175 | |||
176 | mFeather.setAttributes( headFeatherAttributes ); | ||
177 | |||
178 | }//------------------------------------------------------------------ | ||
179 | |||
180 | //------------------------------------------------------------------ | ||
181 | void LLAnimalControlsHeadBehavior::setBodyPositionAndRotation( LLVector3 p, LLQuaternion r ) | ||
182 | { | ||
183 | mBodyPosition = p; | ||
184 | mBodyRotation = r; | ||
185 | |||
186 | }//------------------------------------------------------------------ | ||
187 | |||
188 | //------------------------------------------------------------------ | ||
189 | void LLAnimalControlsHeadBehavior::setFocusPosition( LLVector3 f ) | ||
190 | { | ||
191 | mFocusPosition = f; | ||
192 | |||
193 | }//------------------------------------------------------------------ | ||
194 | |||
195 | |||
196 | //------------------------------------------------------------------ | ||
197 | void LLAnimalControlsHeadBehavior::update() | ||
198 | { | ||
199 | //-------------------------------------------------------------------------- | ||
200 | // Let's get the parent orientation and associated components | ||
201 | //-------------------------------------------------------------------------- | ||
202 | LLQuaternion parentOrientation = mBodyRotation; | ||
203 | LLMatrix3 parentMatrix = parentOrientation.getMatrix3(); | ||
204 | LLVector3 parentForwardDirection = parentMatrix.getLeftRow(); | ||
205 | LLVector3 parentUpwardDirection = parentMatrix.getUpRow(); | ||
206 | |||
207 | //-------------------------------------------------------------------------- | ||
208 | // head position is based on this | ||
209 | //-------------------------------------------------------------------------- | ||
210 | mPosition = mBodyPosition + parentForwardDirection * 0.5f + parentUpwardDirection * 0.5f; | ||
211 | |||
212 | //-------------------------------------------------------------------------------------------------- | ||
213 | // let's figure out how the head would have to rotate in order to aim in the focus direction | ||
214 | //-------------------------------------------------------------------------------------------------- | ||
215 | LLVector3 headFocusDirection = mFocusPosition - mPosition; | ||
216 | LLQuaternion headRotationToFocusDirection; | ||
217 | headRotationToFocusDirection.shortestArc( parentForwardDirection, headFocusDirection ); | ||
218 | |||
219 | //-------------------------------------------------------------------------------------------------- | ||
220 | // Now we rotate the head towards its focus direction | ||
221 | //-------------------------------------------------------------------------------------------------- | ||
222 | mRotation = parentOrientation * headRotationToFocusDirection; | ||
223 | |||
224 | //-------------------------------------------------------------------------------------------------- | ||
225 | // now, setting the head feather position and orientation, and updating it... | ||
226 | //-------------------------------------------------------------------------------------------------- | ||
227 | mFeather.setParentPositionAndRotationDirectly( mPosition, mRotation ); | ||
228 | mFeather.update(); | ||
229 | |||
230 | }//------------------------------------------------------------------ | ||
231 | |||
232 | //------------------------------------------------------------------ | ||
233 | |||
234 | |||
235 | { | ||
236 | //-------------------------------------------------------------------------------------------------- | ||
237 | // let's get the head rotation components... | ||
238 | //-------------------------------------------------------------------------------------------------- | ||
239 | LLMatrix3 headMatrix = mRotation.getMatrix3(); | ||
240 | LLVector3 headForwardDirection = headMatrix.getLeftRow(); | ||
241 | LLVector3 headUpwardDirection = headMatrix.getUpRow(); | ||
242 | LLVector3 headLeftDirection = headMatrix.getFwdRow(); | ||
243 | |||
244 | //------------------------------------------------------ | ||
245 | // show head ball | ||
246 | //------------------------------------------------------ | ||
247 | glColor4fv( LLColor4( 1.0f, 1.0f, 1.0f, OPACITY ).mV ); | ||
248 | glPushMatrix(); | ||
249 | glTranslatef( mPosition.mV[_X_], mPosition.mV[_Y_], mPosition.mV[_Z_] ); | ||
250 | glScalef( HEAD_RADIUS, HEAD_RADIUS, HEAD_RADIUS ); | ||
251 | gSphere.render(); | ||
252 | glPopMatrix(); | ||
253 | |||
254 | //------------------------------------------------------ | ||
255 | // show head direction | ||
256 | //------------------------------------------------------ | ||
257 | LLVector3 end = mPosition + headForwardDirection * 0.4f; | ||
258 | glBegin( GL_LINES ); | ||
259 | glVertex3fv( mPosition.mV ); | ||
260 | glVertex3fv( end.mV ); | ||
261 | glEnd(); | ||
262 | |||
263 | |||
264 | //------------------------------------------------------ | ||
265 | // show eye behavior | ||
266 | //------------------------------------------------------ | ||
267 | LLVector3 leftEyePosition = mPosition + headForwardDirection * HEAD_RADIUS + headUpwardDirection * HEAD_RADIUS + headLeftDirection * HEAD_RADIUS * ONE_HALF; | ||
268 | LLVector3 rightEyePosition = mPosition + headForwardDirection * HEAD_RADIUS + headUpwardDirection * HEAD_RADIUS - headLeftDirection * HEAD_RADIUS * ONE_HALF; | ||
269 | glColor4fv( LLColor4( 0.0f, 0.0f, 0.0f, 1.0f ).mV ); | ||
270 | |||
271 | glPushMatrix(); | ||
272 | glTranslatef( leftEyePosition.mV[_X_], leftEyePosition.mV[_Y_], leftEyePosition.mV[_Z_] ); | ||
273 | glScalef( 0.03f, 0.03f, 0.03f ); | ||
274 | gSphere.render(); | ||
275 | glPopMatrix(); | ||
276 | |||
277 | glPushMatrix(); | ||
278 | glTranslatef( rightEyePosition.mV[_X_], rightEyePosition.mV[_Y_], rightEyePosition.mV[_Z_] ); | ||
279 | glScalef( 0.03f, 0.03f, 0.03f ); | ||
280 | gSphere.render(); | ||
281 | glPopMatrix(); | ||
282 | |||
283 | //------------------------------------------------------------------ | ||
284 | // render feather | ||
285 | //------------------------------------------------------------------ | ||
286 | mFeather.render(); | ||
287 | |||
288 | }//------------------------------------------------------------------ | ||
289 | |||
290 | //--------------------------------------------------------------------------------- | ||
291 | //--------------------------------------------------------------------------------- | ||
292 | // End of head behavior methods... | ||
293 | //--------------------------------------------------------------------------------- | ||
294 | //--------------------------------------------------------------------------------- | ||
295 | |||
296 | |||
297 | |||
298 | |||
299 | //--------------------------------------------------------------------------------- | ||
300 | //--------------------------------------------------------------------------------- | ||
301 | // Leg behavior methods... | ||
302 | //--------------------------------------------------------------------------------- | ||
303 | //--------------------------------------------------------------------------------- | ||
304 | LLAnimalControlsLegBehavior::LLAnimalControlsLegBehavior() | ||
305 | { | ||
306 | mBodyPosition.setVec ( 0.0f, 0.0f, 0.0f ); | ||
307 | mHipAnchorPosition.setVec ( 0.0f, 0.0f, 0.0f ); | ||
308 | mBodyRotation = LLQuaternion::DEFAULT; | ||
309 | mWalking = false; | ||
310 | mIsLeft = true; | ||
311 | |||
312 | }//------------------------------------------------------------- | ||
313 | |||
314 | |||
315 | //------------------------------------------------------------------ | ||
316 | void LLAnimalControlsLegBehavior::setBodyPositionAndRotation( LLVector3 p, LLQuaternion r ) | ||
317 | { | ||
318 | mBodyPosition = p; | ||
319 | mBodyRotation = r; | ||
320 | |||
321 | }//------------------------------------------------------------------ | ||
322 | |||
323 | |||
324 | //--------------------------------------------------------------------------------- | ||
325 | void LLAnimalControlsLegBehavior::update() | ||
326 | { | ||
327 | |||
328 | }//------------------------------------------------------------- | ||
329 | |||
330 | |||
331 | //--------------------------------------------------------------------------------- | ||
332 | void LLAnimalControlsLegBehavior::render() | ||
333 | { | ||
334 | }//------------------------------------------------------------- | ||
335 | |||
336 | |||
337 | |||
338 | |||
339 | |||
340 | |||
341 | |||
342 | |||
343 | //--------------------------------------------------------------------------------- | ||
344 | void LLHUDAnimalControls::update() | ||
345 | { | ||
346 | if ( ! mParentObject ) | ||
347 | { | ||
348 | return; | ||
349 | } | ||
350 | |||
351 | //----------------------------------------------------------------------------------- | ||
352 | // To help in development of this client-side functionality, | ||
353 | // we are pretending that the server is periodically sending us information, | ||
354 | // such as focus position (what we want the animal head to look at) | ||
355 | //----------------------------------------------------------------------------------- | ||
356 | mVirtualServer.setParentPositionAndRotation( mParentObject->getRenderPosition(), mParentObject->getRenderRotation() ); // fake, hacky, temporary, just ignore this. | ||
357 | mVirtualServer.update(); | ||
358 | |||
359 | // here is where we ask the virtual server stuff. | ||
360 | if ( mVirtualServer.getSettingFocusPosition() ) | ||
361 | { | ||
362 | mHeadBehavior.setFocusPosition( mVirtualServer.getFocusPosition() ); | ||
363 | } | ||
364 | |||
365 | updateBodyBehavior(); | ||
366 | |||
367 | mHeadBehavior.setBodyPositionAndRotation ( mParentObject->getPosition(), mParentObject->getRenderRotation() ); | ||
368 | mLeftLegBehavior.setBodyPositionAndRotation ( mParentObject->getPosition(), mParentObject->getRenderRotation() ); | ||
369 | mRightLegBehavior.setBodyPositionAndRotation( mParentObject->getPosition(), mParentObject->getRenderRotation() ); | ||
370 | |||
371 | mHeadBehavior.update(); | ||
372 | mLeftLegBehavior.update(); | ||
373 | mRightLegBehavior.update(); | ||
374 | |||
375 | }//------------------------------------------------------------------ | ||
376 | |||
377 | |||
378 | |||
379 | |||
380 | |||
381 | //------------------------------------------------------------------ | ||
382 | void LLHUDAnimalControls::updateBodyBehavior() | ||
383 | { | ||
384 | |||
385 | }//------------------------------------------------------------------ | ||
386 | |||
387 | |||
388 | |||
389 | |||
390 | //------------------------------------------------------------------ | ||
391 | void LLHUDAnimalControls::render() | ||
392 | { | ||
393 | mHeadBehavior.render(); | ||
394 | mLeftLegBehavior.render(); | ||
395 | mRightLegBehavior.render(); | ||
396 | |||
397 | }//------------------------------------------------------------------ | ||
398 | |||
399 | |||
400 | |||
401 | |||
402 | |||
403 | |||
404 | |||
405 | |||
406 | |||
407 | //------------------------------------------------------------------ | ||
408 | void LLHUDAnimalControls::setAttributes( LLAnimalControlsAttributes a ) | ||
409 | { | ||
410 | //mAttributes = a; // ???? // how do I do this? | ||
411 | |||
412 | //mAttributes.mAnchorPositionOffset = a.mAnchorPositionOffset; | ||
413 | //mAttributes.mAnchorDirection = a.mAnchorDirection; | ||
414 | //mAttributes.mAnchorRadius = a.mAnchorRadius; | ||
415 | //mAttributes.mNumSections = a.mNumSections; | ||
416 | //mAttributes.mLength = a.mLength; | ||
417 | //mAttributes.mGravity = a.mGravity; | ||
418 | //mAttributes.mAirFriction = a.mAirFriction; | ||
419 | //mAttributes.mTension = a.mTension; | ||
420 | //mAttributes.mRadiusChange = a.mRadiusChange; | ||
421 | |||
422 | }//------------------------------------------------------------------ | ||
423 | |||
424 | |||
425 | |||
426 | //------------------------------------------------------------------ | ||
427 | void LLHUDAnimalControls::setParentObject( LLViewerObject * p ) | ||
428 | { | ||
429 | printf( "Setting parent of animal controls %x to object %x \n", this, p ); | ||
430 | mParentObject = p; | ||
431 | |||
432 | }//------------------------------------------------------------------ | ||
433 | |||
434 | |||
435 | //------------------------------------------------------------------ | ||
436 | LLViewerObject * LLHUDAnimalControls::getParentObject() | ||
437 | { | ||
438 | return mParentObject; | ||
439 | |||
440 | }//------------------------------------------------------------------ | ||
441 | |||
442 | |||
443 | |||
444 | //------------------------------------------------------------------ | ||
445 | void LLHUDAnimalControls::markAsDead() | ||
446 | { | ||
447 | mDead = TRUE; | ||
448 | mParentObject = NULL; | ||
449 | |||
450 | }//------------------------------------------------------------------ | ||
451 | |||
452 | |||
453 | |||
454 | |||
455 | */ | ||
456 | |||
457 | |||
458 | |||