PageRenderTime 29ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcharacter/llheadrotmotion.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 212 lines | 74 code | 45 blank | 93 comment | 0 complexity | 66d772944176d94cd2349861712198ab MD5 | raw file
  1/** 
  2 * @file llheadrotmotion.h
  3 * @brief Implementation of LLHeadRotMotion class.
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLHEADROTMOTION_H
 28#define LL_LLHEADROTMOTION_H
 29
 30//-----------------------------------------------------------------------------
 31// Header files
 32//-----------------------------------------------------------------------------
 33#include "llmotion.h"
 34#include "llframetimer.h"
 35
 36#define MIN_REQUIRED_PIXEL_AREA_HEAD_ROT 500.f;
 37#define MIN_REQUIRED_PIXEL_AREA_EYE 25000.f;
 38
 39//-----------------------------------------------------------------------------
 40// class LLHeadRotMotion
 41//-----------------------------------------------------------------------------
 42class LLHeadRotMotion :
 43	public LLMotion
 44{
 45public:
 46	// Constructor
 47	LLHeadRotMotion(const LLUUID &id);
 48
 49	// Destructor
 50	virtual ~LLHeadRotMotion();
 51
 52public:
 53	//-------------------------------------------------------------------------
 54	// functions to support MotionController and MotionRegistry
 55	//-------------------------------------------------------------------------
 56
 57	// static constructor
 58	// all subclasses must implement such a function and register it
 59	static LLMotion *create(const LLUUID &id) { return new LLHeadRotMotion(id); }
 60
 61public:
 62	//-------------------------------------------------------------------------
 63	// animation callbacks to be implemented by subclasses
 64	//-------------------------------------------------------------------------
 65
 66	// motions must specify whether or not they loop
 67	virtual BOOL getLoop() { return TRUE; }
 68
 69	// motions must report their total duration
 70	virtual F32 getDuration() { return 0.0; }
 71
 72	// motions must report their "ease in" duration
 73	virtual F32 getEaseInDuration() { return 1.f; }
 74
 75	// motions must report their "ease out" duration.
 76	virtual F32 getEaseOutDuration() { return 1.f; }
 77
 78	// called to determine when a motion should be activated/deactivated based on avatar pixel coverage
 79	virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_HEAD_ROT; }
 80
 81	// motions must report their priority
 82	virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; }
 83
 84	virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
 85
 86	// run-time (post constructor) initialization,
 87	// called after parameters have been set
 88	// must return true to indicate success and be available for activation
 89	virtual LLMotionInitStatus onInitialize(LLCharacter *character);
 90
 91	// called when a motion is activated
 92	// must return TRUE to indicate success, or else
 93	// it will be deactivated
 94	virtual BOOL onActivate();
 95
 96	// called per time step
 97	// must return TRUE while it is active, and
 98	// must return FALSE when the motion is completed.
 99	virtual BOOL onUpdate(F32 time, U8* joint_mask);
100
101	// called when a motion is deactivated
102	virtual void onDeactivate();
103
104public:
105	//-------------------------------------------------------------------------
106	// joint states to be animated
107	//-------------------------------------------------------------------------
108	LLCharacter			*mCharacter;
109
110	LLJoint				*mTorsoJoint;
111	LLJoint				*mHeadJoint;
112	LLJoint				*mRootJoint;
113	LLJoint				*mPelvisJoint;
114
115	LLPointer<LLJointState> mTorsoState;
116	LLPointer<LLJointState> mNeckState;
117	LLPointer<LLJointState> mHeadState;
118
119	LLQuaternion		mLastHeadRot;
120};
121
122//-----------------------------------------------------------------------------
123// class LLEyeMotion
124//-----------------------------------------------------------------------------
125class LLEyeMotion :
126	public LLMotion
127{
128public:
129	// Constructor
130	LLEyeMotion(const LLUUID &id);
131
132	// Destructor
133	virtual ~LLEyeMotion();
134
135public:
136	//-------------------------------------------------------------------------
137	// functions to support MotionController and MotionRegistry
138	//-------------------------------------------------------------------------
139
140	// static constructor
141	// all subclasses must implement such a function and register it
142	static LLMotion *create( const LLUUID &id) { return new LLEyeMotion(id); }
143
144public:
145	//-------------------------------------------------------------------------
146	// animation callbacks to be implemented by subclasses
147	//-------------------------------------------------------------------------
148
149	// motions must specify whether or not they loop
150	virtual BOOL getLoop() { return TRUE; }
151
152	// motions must report their total duration
153	virtual F32 getDuration() { return 0.0; }
154
155	// motions must report their "ease in" duration
156	virtual F32 getEaseInDuration() { return 0.5f; }
157
158	// motions must report their "ease out" duration.
159	virtual F32 getEaseOutDuration() { return 0.5f; }
160
161	// called to determine when a motion should be activated/deactivated based on avatar pixel coverage
162	virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_EYE; }
163
164	// motions must report their priority
165	virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; }
166
167	virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
168
169	// run-time (post constructor) initialization,
170	// called after parameters have been set
171	// must return true to indicate success and be available for activation
172	virtual LLMotionInitStatus onInitialize(LLCharacter *character);
173
174	// called when a motion is activated
175	// must return TRUE to indicate success, or else
176	// it will be deactivated
177	virtual BOOL onActivate();
178
179	// called per time step
180	// must return TRUE while it is active, and
181	// must return FALSE when the motion is completed.
182	virtual BOOL onUpdate(F32 time, U8* joint_mask);
183
184	// called when a motion is deactivated
185	virtual void onDeactivate();
186
187public:
188	//-------------------------------------------------------------------------
189	// joint states to be animated
190	//-------------------------------------------------------------------------
191	LLCharacter			*mCharacter;
192
193	LLJoint				*mHeadJoint;
194	LLPointer<LLJointState> mLeftEyeState;
195	LLPointer<LLJointState> mRightEyeState;
196
197	LLFrameTimer		mEyeJitterTimer;
198	F32					mEyeJitterTime;
199	F32					mEyeJitterYaw;
200	F32					mEyeJitterPitch;
201	F32					mEyeLookAwayTime;
202	F32					mEyeLookAwayYaw;
203	F32					mEyeLookAwayPitch;
204
205	// eye blinking
206	LLFrameTimer		mEyeBlinkTimer;
207	F32					mEyeBlinkTime;
208	BOOL				mEyesClosed;
209};
210
211#endif // LL_LLHEADROTMOTION_H
212