PageRenderTime 146ms CodeModel.GetById 22ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcharacter/llkeyframemotionparam.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 170 lines | 74 code | 31 blank | 65 comment | 2 complexity | fbbb03b81fcafab41780468c406a07e3 MD5 | raw file
  1/** 
  2 * @file llkeyframemotionparam.h
  3 * @brief Implementation of LLKeframeMotionParam class.
  4 *
  5 * $LicenseInfo:firstyear=2002&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_LLKEYFRAMEMOTIONPARAM_H
 28#define LL_LLKEYFRAMEMOTIONPARAM_H
 29
 30//-----------------------------------------------------------------------------
 31// Header files
 32//-----------------------------------------------------------------------------
 33
 34#include <string>
 35
 36#include "llmotion.h"
 37#include "lljointstate.h"
 38#include "v3math.h"
 39#include "llquaternion.h"
 40#include "linked_lists.h"
 41#include "llkeyframemotion.h"
 42
 43//-----------------------------------------------------------------------------
 44// class LLKeyframeMotionParam
 45//-----------------------------------------------------------------------------
 46class LLKeyframeMotionParam :
 47	public LLMotion
 48{
 49public:
 50	// Constructor
 51	LLKeyframeMotionParam(const LLUUID &id);
 52
 53	// Destructor
 54	virtual ~LLKeyframeMotionParam();
 55
 56public:
 57	//-------------------------------------------------------------------------
 58	// functions to support MotionController and MotionRegistry
 59	//-------------------------------------------------------------------------
 60
 61	// static constructor
 62	// all subclasses must implement such a function and register it
 63	static LLMotion *create(const LLUUID &id) { return new LLKeyframeMotionParam(id); }
 64
 65public:
 66	//-------------------------------------------------------------------------
 67	// animation callbacks to be implemented by subclasses
 68	//-------------------------------------------------------------------------
 69
 70	// motions must specify whether or not they loop
 71	virtual BOOL getLoop() {
 72		return TRUE;
 73	}
 74
 75	// motions must report their total duration
 76	virtual F32 getDuration() { 
 77		return mDuration;
 78	}
 79
 80	// motions must report their "ease in" duration
 81	virtual F32 getEaseInDuration() { 
 82		return mEaseInDuration;
 83	}
 84
 85	// motions must report their "ease out" duration.
 86	virtual F32 getEaseOutDuration() { 
 87		return mEaseOutDuration;
 88	}
 89
 90	// motions must report their priority
 91	virtual LLJoint::JointPriority getPriority() { 
 92		return mPriority;
 93	}
 94
 95	virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
 96
 97	// called to determine when a motion should be activated/deactivated based on avatar pixel coverage
 98	virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_KEYFRAME; }
 99
100	// run-time (post constructor) initialization,
101	// called after parameters have been set
102	// must return true to indicate success and be available for activation
103	virtual LLMotionInitStatus onInitialize(LLCharacter *character);
104
105	// called when a motion is activated
106	// must return TRUE to indicate success, or else
107	// it will be deactivated
108	virtual BOOL onActivate();
109
110	// called per time step
111	// must return TRUE while it is active, and
112	// must return FALSE when the motion is completed.
113	virtual BOOL onUpdate(F32 time, U8* joint_mask);
114
115	// called when a motion is deactivated
116	virtual void onDeactivate();
117
118	virtual LLPose* getPose() { return mPoseBlender.getBlendedPose();}
119
120protected:
121	//-------------------------------------------------------------------------
122	// new functions defined by this subclass
123	//-------------------------------------------------------------------------
124	struct ParameterizedMotion
125	{
126		ParameterizedMotion(LLMotion* motion, F32 param) : mMotion(motion), mParam(param) {}
127		LLMotion* mMotion;
128		F32 mParam;
129	};
130	
131	// add a motion and associated parameter triplet
132	BOOL addKeyframeMotion(char *name, const LLUUID &id, char *param, F32 value);
133	
134	// set default motion for LOD and retrieving blend constants
135	void setDefaultKeyframeMotion(char *);
136
137	BOOL loadMotions();
138
139protected:
140	//-------------------------------------------------------------------------
141	// Member Data
142	//-------------------------------------------------------------------------
143
144	struct compare_motions
145	{
146		bool operator() (const ParameterizedMotion& a, const ParameterizedMotion& b) const
147		{
148			if (a.mParam != b.mParam)
149				return (a.mParam < b.mParam);
150			else
151				return a.mMotion < b.mMotion;
152		}
153	};
154	
155	typedef std::set < ParameterizedMotion, compare_motions > motion_list_t;
156	typedef std::map <std::string, motion_list_t > motion_map_t;
157	motion_map_t 		mParameterizedMotions;
158	LLMotion*			mDefaultKeyframeMotion;
159	LLCharacter*		mCharacter;
160	LLPoseBlender		mPoseBlender;
161
162	F32					mEaseInDuration;
163	F32					mEaseOutDuration;
164	F32					mDuration;
165	LLJoint::JointPriority	mPriority;
166
167	LLUUID				mTransactionID;
168};
169
170#endif // LL_LLKEYFRAMEMOTIONPARAM_H