PageRenderTime 224ms CodeModel.GetById 101ms app.highlight 11ms RepoModel.GetById 110ms app.codeStats 0ms

/indra/llcharacter/llkeyframewalkmotion.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 174 lines | 85 code | 21 blank | 68 comment | 0 complexity | fe8de14ea542e9550bbb2272e9532a23 MD5 | raw file
  1/** 
  2 * @file llkeyframewalkmotion.h
  3 * @brief Implementation of LLKeframeWalkMotion 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_LLKEYFRAMEWALKMOTION_H
 28#define LL_LLKEYFRAMEWALKMOTION_H
 29
 30//-----------------------------------------------------------------------------
 31// Header files
 32//-----------------------------------------------------------------------------
 33#include "llkeyframemotion.h"
 34#include "llcharacter.h"
 35#include "v3dmath.h"
 36
 37#define MIN_REQUIRED_PIXEL_AREA_WALK_ADJUST (20.f)
 38#define MIN_REQUIRED_PIXEL_AREA_FLY_ADJUST (20.f)
 39
 40//-----------------------------------------------------------------------------
 41// class LLKeyframeWalkMotion
 42//-----------------------------------------------------------------------------
 43class LLKeyframeWalkMotion :
 44	public LLKeyframeMotion
 45{
 46	friend class LLWalkAdjustMotion;
 47public:
 48	// Constructor
 49	LLKeyframeWalkMotion(const LLUUID &id);
 50
 51	// Destructor
 52	virtual ~LLKeyframeWalkMotion();
 53
 54public:
 55	//-------------------------------------------------------------------------
 56	// functions to support MotionController and MotionRegistry
 57	//-------------------------------------------------------------------------
 58	
 59	// static constructor
 60	// all subclasses must implement such a function and register it
 61	static LLMotion *create(const LLUUID &id) { return new LLKeyframeWalkMotion(id); }
 62
 63public:
 64	//-------------------------------------------------------------------------
 65	// animation callbacks to be implemented by subclasses
 66	//-------------------------------------------------------------------------
 67	virtual LLMotionInitStatus onInitialize(LLCharacter *character);
 68	virtual BOOL onActivate();
 69	virtual void onDeactivate();
 70	virtual BOOL onUpdate(F32 time, U8* joint_mask);
 71
 72public:
 73	//-------------------------------------------------------------------------
 74	// Member Data
 75	//-------------------------------------------------------------------------
 76	LLCharacter	*mCharacter;
 77	F32			mCyclePhase;
 78	F32			mRealTimeLast;
 79	F32			mAdjTimeLast;
 80	S32			mDownFoot;
 81};
 82
 83class LLWalkAdjustMotion : public LLMotion
 84{
 85public:
 86	// Constructor
 87	LLWalkAdjustMotion(const LLUUID &id);
 88
 89public:
 90	//-------------------------------------------------------------------------
 91	// functions to support MotionController and MotionRegistry
 92	//-------------------------------------------------------------------------
 93
 94	// static constructor
 95	// all subclasses must implement such a function and register it
 96	static LLMotion *create(const LLUUID &id) { return new LLWalkAdjustMotion(id); }
 97
 98public:
 99	//-------------------------------------------------------------------------
100	// animation callbacks to be implemented by subclasses
101	//-------------------------------------------------------------------------
102	virtual LLMotionInitStatus onInitialize(LLCharacter *character);
103	virtual BOOL onActivate();
104	virtual void onDeactivate();
105	virtual BOOL onUpdate(F32 time, U8* joint_mask);
106	virtual LLJoint::JointPriority getPriority(){return LLJoint::HIGH_PRIORITY;}
107	virtual BOOL getLoop() { return TRUE; }
108	virtual F32 getDuration() { return 0.f; }
109	virtual F32 getEaseInDuration() { return 0.f; }
110	virtual F32 getEaseOutDuration() { return 0.f; }
111	virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_WALK_ADJUST; }
112	virtual LLMotionBlendType getBlendType() { return ADDITIVE_BLEND; }
113
114public:
115	//-------------------------------------------------------------------------
116	// Member Data
117	//-------------------------------------------------------------------------
118	LLCharacter		*mCharacter;
119	LLJoint*		mLeftAnkleJoint;
120	LLJoint*		mRightAnkleJoint;
121	LLPointer<LLJointState>	mPelvisState;
122	LLJoint*		mPelvisJoint;
123	LLVector3d		mLastLeftFootGlobalPos;
124	LLVector3d		mLastRightFootGlobalPos;
125	F32				mLastTime;
126	F32				mAdjustedSpeed;
127	F32				mAnimSpeed;
128	F32				mRelativeDir;
129	LLVector3		mPelvisOffset;
130	F32				mAnkleOffset;
131};
132
133class LLFlyAdjustMotion : public LLMotion
134{
135public:
136	// Constructor
137	LLFlyAdjustMotion(const LLUUID &id);
138
139public:
140	//-------------------------------------------------------------------------
141	// functions to support MotionController and MotionRegistry
142	//-------------------------------------------------------------------------
143
144	// static constructor
145	// all subclasses must implement such a function and register it
146	static LLMotion *create(const LLUUID &id) { return new LLFlyAdjustMotion(id); }
147
148public:
149	//-------------------------------------------------------------------------
150	// animation callbacks to be implemented by subclasses
151	//-------------------------------------------------------------------------
152	virtual LLMotionInitStatus onInitialize(LLCharacter *character);
153	virtual BOOL onActivate();
154	virtual void onDeactivate() {};
155	virtual BOOL onUpdate(F32 time, U8* joint_mask);
156	virtual LLJoint::JointPriority getPriority(){return LLJoint::HIGHER_PRIORITY;}
157	virtual BOOL getLoop() { return TRUE; }
158	virtual F32 getDuration() { return 0.f; }
159	virtual F32 getEaseInDuration() { return 0.f; }
160	virtual F32 getEaseOutDuration() { return 0.f; }
161	virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_FLY_ADJUST; }
162	virtual LLMotionBlendType getBlendType() { return ADDITIVE_BLEND; }
163
164protected:
165	//-------------------------------------------------------------------------
166	// Member Data
167	//-------------------------------------------------------------------------
168	LLCharacter		*mCharacter;
169	LLPointer<LLJointState>	mPelvisState;
170	F32				mRoll;
171};
172
173#endif // LL_LLKeyframeWalkMotion_H
174