PageRenderTime 28ms CodeModel.GetById 2ms app.highlight 23ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/llcharacter/llvisualparam.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 165 lines | 93 code | 29 blank | 43 comment | 4 complexity | 93d1c12c66917c0a3447fefc6062bc2c MD5 | raw file
  1/** 
  2 * @file llvisualparam.h
  3 * @brief Implementation of LLPolyMesh 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_LLVisualParam_H
 28#define LL_LLVisualParam_H
 29
 30#include "v3math.h"
 31#include "llstring.h"
 32#include "llxmltree.h"
 33#include <boost/function.hpp>
 34
 35class LLPolyMesh;
 36class LLXmlTreeNode;
 37
 38enum ESex
 39{
 40	SEX_FEMALE =	0x01,
 41	SEX_MALE =		0x02,
 42	SEX_BOTH =		0x03  // values chosen to allow use as a bit field.
 43};
 44
 45enum EVisualParamGroup
 46{
 47	VISUAL_PARAM_GROUP_TWEAKABLE,
 48	VISUAL_PARAM_GROUP_ANIMATABLE,
 49	VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT,
 50	NUM_VISUAL_PARAM_GROUPS
 51};
 52
 53const S32 MAX_TRANSMITTED_VISUAL_PARAMS = 255;
 54
 55//-----------------------------------------------------------------------------
 56// LLVisualParamInfo
 57// Contains shared data for VisualParams
 58//-----------------------------------------------------------------------------
 59class LLVisualParamInfo
 60{
 61	friend class LLVisualParam;
 62public:
 63	LLVisualParamInfo();
 64	virtual ~LLVisualParamInfo() {};
 65
 66	virtual BOOL parseXml(LLXmlTreeNode *node);
 67
 68	S32 getID() const { return mID; }
 69
 70	virtual void toStream(std::ostream &out);
 71	
 72protected:
 73	S32					mID;				// ID associated with VisualParam
 74	
 75	std::string			mName;				// name (for internal purposes)
 76	std::string			mDisplayName;		// name displayed to the user
 77	std::string			mMinName;			// name associated with minimum value
 78	std::string			mMaxName;			// name associated with maximum value
 79	EVisualParamGroup	mGroup;				// morph group for separating UI controls
 80	F32					mMinWeight;			// minimum weight that can be assigned to this morph target
 81	F32					mMaxWeight;			// maximum weight that can be assigned to this morph target
 82	F32					mDefaultWeight;		
 83	ESex				mSex;				// Which gender(s) this param applies to.
 84};
 85
 86//-----------------------------------------------------------------------------
 87// LLVisualParam
 88// VIRTUAL CLASS
 89// An interface class for a generalized parametric modification of the avatar mesh
 90// Contains data that is specific to each Avatar
 91//-----------------------------------------------------------------------------
 92class LLVisualParam
 93{
 94public:
 95	typedef	boost::function<LLVisualParam*(S32)> visual_param_mapper;
 96
 97	LLVisualParam();
 98	virtual ~LLVisualParam();
 99
100	// Special: These functions are overridden by child classes
101	// (They can not be virtual because they use specific derived Info classes)
102	LLVisualParamInfo*		getInfo() const { return mInfo; }
103	//   This sets mInfo and calls initialization functions
104	BOOL					setInfo(LLVisualParamInfo *info);
105
106	// Virtual functions
107	//  Pure virtuals
108	//virtual BOOL			parseData( LLXmlTreeNode *node ) = 0;
109	virtual void			apply( ESex avatar_sex ) = 0;
110	//  Default functions
111	virtual void			setWeight(F32 weight, BOOL upload_bake);
112	virtual void			setAnimationTarget( F32 target_value, BOOL upload_bake );
113	virtual void			animate(F32 delta, BOOL upload_bake);
114	virtual void			stopAnimating(BOOL upload_bake);
115
116	virtual BOOL			linkDrivenParams(visual_param_mapper mapper, BOOL only_cross_params);
117	virtual void			resetDrivenParams();
118
119	// Interface methods
120	S32						getID() const		{ return mID; }
121	void					setID(S32 id) 		{ llassert(!mInfo); mID = id; }
122	
123	const std::string&		getName() const 			{ return mInfo->mName; }
124	const std::string&		getDisplayName() const 		{ return mInfo->mDisplayName; }
125	const std::string&		getMaxDisplayName() const	{ return mInfo->mMaxName; }
126	const std::string&		getMinDisplayName() const	{ return mInfo->mMinName; }
127
128	void					setDisplayName(const std::string& s) 	 { mInfo->mDisplayName = s; }
129	void					setMaxDisplayName(const std::string& s) { mInfo->mMaxName = s; }
130	void					setMinDisplayName(const std::string& s) { mInfo->mMinName = s; }
131
132	EVisualParamGroup		getGroup() const 			{ return mInfo->mGroup; }
133	F32						getMinWeight() const		{ return mInfo->mMinWeight; }
134	F32						getMaxWeight() const		{ return mInfo->mMaxWeight; }
135	F32						getDefaultWeight() const 	{ return mInfo->mDefaultWeight; }
136	ESex					getSex() const			{ return mInfo->mSex; }
137
138	F32						getWeight() const		{ return mIsAnimating ? mTargetWeight : mCurWeight; }
139	F32						getCurrentWeight() const 	{ return mCurWeight; }
140	F32						getLastWeight() const	{ return mLastWeight; }
141	BOOL					isAnimating() const	{ return mIsAnimating; }
142	BOOL					isTweakable() const { return (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)  || (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT); }
143
144	LLVisualParam*			getNextParam()		{ return mNext; }
145	void					setNextParam( LLVisualParam *next );
146	
147	virtual void			setAnimating(BOOL is_animating) { mIsAnimating = is_animating && !mIsDummy; }
148	BOOL					getAnimating() const { return mIsAnimating; }
149
150	void					setIsDummy(BOOL is_dummy) { mIsDummy = is_dummy; }
151
152protected:
153	F32					mCurWeight;			// current weight
154	F32					mLastWeight;		// last weight
155	LLVisualParam*		mNext;				// next param in a shared chain
156	F32					mTargetWeight;		// interpolation target
157	BOOL				mIsAnimating;	// this value has been given an interpolation target
158	BOOL				mIsDummy;  // this is used to prevent dummy visual params from animating
159
160
161	S32					mID;				// id for storing weight/morphtarget compares compactly
162	LLVisualParamInfo	*mInfo;
163};
164
165#endif // LL_LLVisualParam_H