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/llfollowcam.h | |
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/llfollowcam.h | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/linden/indra/newview/llfollowcam.h b/linden/indra/newview/llfollowcam.h new file mode 100644 index 0000000..c8a5c88 --- /dev/null +++ b/linden/indra/newview/llfollowcam.h | |||
@@ -0,0 +1,235 @@ | |||
1 | /** | ||
2 | * @file llfollowcam.h | ||
3 | * @author Jeffrey Ventrella | ||
4 | * @brief LLFollowCam class definition | ||
5 | * | ||
6 | * Copyright (c) 2005-2007, Linden Research, Inc. | ||
7 | * | ||
8 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
9 | * to you under the terms of the GNU General Public License, version 2.0 | ||
10 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
11 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
12 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
13 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
14 | * | ||
15 | * There are special exceptions to the terms and conditions of the GPL as | ||
16 | * it is applied to this Source Code. View the full text of the exception | ||
17 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
18 | * online at http://secondlife.com/developers/opensource/flossexception | ||
19 | * | ||
20 | * By copying, modifying or distributing this software, you acknowledge | ||
21 | * that you have read and understood your obligations described above, | ||
22 | * and agree to abide by those obligations. | ||
23 | * | ||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
26 | * COMPLETENESS OR PERFORMANCE. | ||
27 | */ | ||
28 | |||
29 | //-------------------------------------------------------------------- | ||
30 | // FollowCam | ||
31 | // | ||
32 | // The FollowCam controls three dynamic variables which determine | ||
33 | // a camera orientation and position for a "loose" third-person view | ||
34 | // (orientation being derived from a combination of focus and up | ||
35 | // vector). It is good for fast-moving vehicles that change | ||
36 | // acceleration a lot, but it can also be general-purpose, like for | ||
37 | // avatar navigation. It has a handful of parameters allowing it to | ||
38 | // be tweaked to assume different styles of tracking objects. | ||
39 | // | ||
40 | //-------------------------------------------------------------------- | ||
41 | #ifndef LL_FOLLOWCAM_H | ||
42 | #define LL_FOLLOWCAM_H | ||
43 | |||
44 | #include "llcoordframe.h" | ||
45 | #include "indra_constants.h" | ||
46 | #include "llmath.h" | ||
47 | #include "lltimer.h" | ||
48 | #include "llquaternion.h" | ||
49 | #include "llcriticaldamp.h" | ||
50 | #include <map> | ||
51 | #include <vector> | ||
52 | |||
53 | class LLFollowCamParams | ||
54 | { | ||
55 | public: | ||
56 | LLFollowCamParams(); | ||
57 | virtual ~LLFollowCamParams(); | ||
58 | |||
59 | //-------------------------------------- | ||
60 | // setty setty set set | ||
61 | //-------------------------------------- | ||
62 | virtual void setPositionLag ( F32 ); | ||
63 | virtual void setFocusLag ( F32 ); | ||
64 | virtual void setFocusThreshold ( F32 ); | ||
65 | virtual void setPositionThreshold ( F32 ); | ||
66 | virtual void setDistance ( F32 ); | ||
67 | virtual void setPitch ( F32 ); | ||
68 | virtual void setFocusOffset ( const LLVector3& ); | ||
69 | virtual void setBehindnessAngle ( F32 ); | ||
70 | virtual void setBehindnessLag ( F32 ); | ||
71 | virtual void setPosition ( const LLVector3& ); | ||
72 | virtual void setFocus ( const LLVector3& ); | ||
73 | virtual void setPositionLocked ( bool ); | ||
74 | virtual void setFocusLocked ( bool ); | ||
75 | |||
76 | |||
77 | //-------------------------------------- | ||
78 | // getty getty get get | ||
79 | //-------------------------------------- | ||
80 | virtual F32 getPositionLag() const; | ||
81 | virtual F32 getFocusLag() const; | ||
82 | virtual F32 getPositionThreshold() const; | ||
83 | virtual F32 getFocusThreshold() const; | ||
84 | virtual F32 getDistance() const; | ||
85 | virtual F32 getPitch() const; | ||
86 | virtual LLVector3 getFocusOffset() const; | ||
87 | virtual F32 getBehindnessAngle() const; | ||
88 | virtual F32 getBehindnessLag() const; | ||
89 | virtual LLVector3 getPosition() const; | ||
90 | virtual LLVector3 getFocus() const; | ||
91 | virtual bool getFocusLocked() const; | ||
92 | virtual bool getPositionLocked() const; | ||
93 | virtual bool getUseFocus() const { return mUseFocus; } | ||
94 | virtual bool getUsePosition() const { return mUsePosition; } | ||
95 | |||
96 | protected: | ||
97 | F32 mPositionLag; | ||
98 | F32 mFocusLag; | ||
99 | F32 mFocusThreshold; | ||
100 | F32 mPositionThreshold; | ||
101 | F32 mDistance; | ||
102 | F32 mPitch; | ||
103 | LLVector3 mFocusOffset; | ||
104 | F32 mBehindnessMaxAngle; | ||
105 | F32 mBehindnessLag; | ||
106 | F32 mMaxCameraDistantFromSubject; | ||
107 | |||
108 | bool mPositionLocked; | ||
109 | bool mFocusLocked; | ||
110 | bool mUsePosition; // specific camera point specified by script | ||
111 | bool mUseFocus; // specific focus point specified by script | ||
112 | LLVector3 mPosition; // where the camera is (in world-space) | ||
113 | LLVector3 mFocus; // what the camera is aimed at (in world-space) | ||
114 | }; | ||
115 | |||
116 | class LLFollowCam : public LLFollowCamParams | ||
117 | { | ||
118 | public: | ||
119 | //-------------------- | ||
120 | // Contructor | ||
121 | //-------------------- | ||
122 | LLFollowCam(); | ||
123 | |||
124 | //-------------------- | ||
125 | // Destructor | ||
126 | //-------------------- | ||
127 | virtual ~LLFollowCam(); | ||
128 | |||
129 | //--------------------------------------------------------------------------------------- | ||
130 | // The following methods must be called every time step. However, if you know for | ||
131 | // sure that your subject matter (what the camera is looking at) is not moving, | ||
132 | // then you can get away with not calling "update" But keep in mind that "update" | ||
133 | // may still be needed after the subject matter has stopped moving because the | ||
134 | // camera may still need to animate itself catching up to its ideal resting place. | ||
135 | //--------------------------------------------------------------------------------------- | ||
136 | void setSubjectPositionAndRotation ( const LLVector3 p, const LLQuaternion r ); | ||
137 | void update(); | ||
138 | |||
139 | // initialize from another instance of llfollowcamparams | ||
140 | void copyParams(LLFollowCamParams& params); | ||
141 | |||
142 | //----------------------------------------------------------------------------------- | ||
143 | // this is how to bang the followCam into a specific configuration. Keep in mind | ||
144 | // that it will immediately try to adjust these values according to its attributes. | ||
145 | //----------------------------------------------------------------------------------- | ||
146 | void reset( const LLVector3 position, const LLVector3 focus, const LLVector3 upVector ); | ||
147 | |||
148 | void setMaxCameraDistantFromSubject ( F32 m ); // this should be determined by llAgent | ||
149 | bool isZoomedToMinimumDistance(); | ||
150 | LLVector3 getUpVector(); | ||
151 | void zoom( S32 ); | ||
152 | |||
153 | // overrides for setters and getters | ||
154 | virtual void setPitch( F32 ); | ||
155 | virtual void setDistance( F32 ); | ||
156 | virtual void setPosition(const LLVector3& pos); | ||
157 | virtual void setFocus(const LLVector3& focus); | ||
158 | virtual void setPositionLocked ( bool ); | ||
159 | virtual void setFocusLocked ( bool ); | ||
160 | |||
161 | LLVector3 getSimulatedPosition() const; | ||
162 | LLVector3 getSimulatedFocus() const; | ||
163 | |||
164 | //------------------------------------------ | ||
165 | // protected members of FollowCam | ||
166 | //------------------------------------------ | ||
167 | protected: | ||
168 | F32 mPositionLagTimeScale; // derived from mPositionLag | ||
169 | F32 mFocusLagTimeScale; // derived from mFocusLag | ||
170 | F32 mPitchCos; // derived from mPitch | ||
171 | F32 mPitchSin; // derived from mPitch | ||
172 | LLGlobalVec mSimulatedPositionGlobal; // where the camera is (global coordinates), simulated | ||
173 | LLGlobalVec mSimulatedFocusGlobal; // what the camera is aimed at (global coordinates), simulated | ||
174 | F32 mSimulatedDistance; | ||
175 | |||
176 | //--------------------- | ||
177 | // dynamic variables | ||
178 | //--------------------- | ||
179 | bool mZoomedToMinimumDistance; | ||
180 | LLFrameTimer mTimer; | ||
181 | LLVector3 mSubjectPosition; // this is the position of what I'm looking at | ||
182 | LLQuaternion mSubjectRotation; // this is the rotation of what I'm looking at | ||
183 | LLVector3 mUpVector; // the camera's up vector in world-space (determines roll) | ||
184 | LLVector3 mRelativeFocus; | ||
185 | LLVector3 mRelativePos; | ||
186 | |||
187 | bool mPitchSineAndCosineNeedToBeUpdated; | ||
188 | |||
189 | //------------------------------------------ | ||
190 | // protected methods of FollowCam | ||
191 | //------------------------------------------ | ||
192 | protected: | ||
193 | void calculatePitchSineAndCosine(); | ||
194 | BOOL updateBehindnessConstraint(LLVector3 focus, LLVector3& cam_position); | ||
195 | |||
196 | };// end of FollowCam class | ||
197 | |||
198 | |||
199 | class LLFollowCamMgr | ||
200 | { | ||
201 | public: | ||
202 | static void cleanupClass ( ); | ||
203 | |||
204 | static void setPositionLag ( const LLUUID& source, F32 lag); | ||
205 | static void setFocusLag ( const LLUUID& source, F32 lag); | ||
206 | static void setFocusThreshold ( const LLUUID& source, F32 threshold); | ||
207 | static void setPositionThreshold ( const LLUUID& source, F32 threshold); | ||
208 | static void setDistance ( const LLUUID& source, F32 distance); | ||
209 | static void setPitch ( const LLUUID& source, F32 pitch); | ||
210 | static void setFocusOffset ( const LLUUID& source, const LLVector3& offset); | ||
211 | static void setBehindnessAngle ( const LLUUID& source, F32 angle); | ||
212 | static void setBehindnessLag ( const LLUUID& source, F32 lag); | ||
213 | static void setPosition ( const LLUUID& source, const LLVector3 position); | ||
214 | static void setFocus ( const LLUUID& source, const LLVector3 focus); | ||
215 | static void setPositionLocked ( const LLUUID& source, bool locked); | ||
216 | static void setFocusLocked ( const LLUUID& source, bool locked ); | ||
217 | |||
218 | static void setCameraActive ( const LLUUID& source, bool active ); | ||
219 | |||
220 | static LLFollowCamParams* getActiveFollowCamParams(); | ||
221 | static LLFollowCamParams* getParamsForID(const LLUUID& source); | ||
222 | static void removeFollowCamParams(const LLUUID& source); | ||
223 | static bool isScriptedCameraSource(const LLUUID& source); | ||
224 | static void dump(); | ||
225 | |||
226 | protected: | ||
227 | |||
228 | typedef std::map<LLUUID, LLFollowCamParams*> param_map_t; | ||
229 | static param_map_t sParamMap; | ||
230 | |||
231 | typedef std::vector<LLFollowCamParams*> param_stack_t; | ||
232 | static param_stack_t sParamStack; | ||
233 | }; | ||
234 | |||
235 | #endif //LL_FOLLOWCAM_H | ||