PageRenderTime 23ms CodeModel.GetById 15ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lldriverparam.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 128 lines | 72 code | 22 blank | 34 comment | 0 complexity | ba0f9975747e27d4bae346de07df5501 MD5 | raw file
  1/** 
  2 * @file lldriverparam.h
  3 * @brief A visual parameter that drives (controls) other visual parameters.
  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_LLDRIVERPARAM_H
 28#define LL_LLDRIVERPARAM_H
 29
 30#include "llviewervisualparam.h"
 31#include "llwearabletype.h"
 32
 33class LLPhysicsMotion;
 34class LLVOAvatar;
 35class LLWearable;
 36
 37//-----------------------------------------------------------------------------
 38
 39struct LLDrivenEntryInfo
 40{
 41	LLDrivenEntryInfo( S32 id, F32 min1, F32 max1, F32 max2, F32 min2 )
 42		: mDrivenID( id ), mMin1( min1 ), mMax1( max1 ), mMax2( max2 ), mMin2( min2 ) {}
 43	S32					mDrivenID;
 44	F32					mMin1;
 45	F32					mMax1;
 46	F32					mMax2;
 47	F32					mMin2;
 48};
 49
 50struct LLDrivenEntry
 51{
 52	LLDrivenEntry( LLViewerVisualParam* param, LLDrivenEntryInfo *info )
 53		: mParam( param ), mInfo( info ) {}
 54	LLViewerVisualParam* mParam;
 55	LLDrivenEntryInfo*	 mInfo;
 56};
 57
 58//-----------------------------------------------------------------------------
 59
 60class LLDriverParamInfo : public LLViewerVisualParamInfo
 61{
 62	friend class LLDriverParam;
 63public:
 64	LLDriverParamInfo();
 65	/*virtual*/ ~LLDriverParamInfo() {};
 66	
 67	/*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
 68
 69	/*virtual*/ void toStream(std::ostream &out);	
 70
 71protected:
 72	typedef std::deque<LLDrivenEntryInfo> entry_info_list_t;
 73	entry_info_list_t mDrivenInfoList;
 74};
 75
 76//-----------------------------------------------------------------------------
 77
 78class LLDriverParam : public LLViewerVisualParam
 79{
 80	friend class LLPhysicsMotion; // physics motion needs to access driven params directly.
 81public:
 82	LLDriverParam(LLVOAvatar *avatarp);
 83	LLDriverParam(LLWearable *wearablep);
 84	~LLDriverParam();
 85
 86	// Special: These functions are overridden by child classes
 87	LLDriverParamInfo*		getInfo() const { return (LLDriverParamInfo*)mInfo; }
 88	//   This sets mInfo and calls initialization functions
 89	BOOL					setInfo(LLDriverParamInfo *info);
 90
 91	void					setWearable(LLWearable *wearablep);
 92	void					setAvatar(LLVOAvatar *avatarp);
 93	void					updateCrossDrivenParams(LLWearableType::EType driven_type);
 94
 95	/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const;
 96
 97	// LLVisualParam Virtual functions
 98	///*virtual*/ BOOL				parseData(LLXmlTreeNode* node);
 99	/*virtual*/ void				apply( ESex sex ) {} // apply is called separately for each driven param.
100	/*virtual*/ void				setWeight(F32 weight, BOOL upload_bake);
101	/*virtual*/ void				setAnimationTarget( F32 target_value, BOOL upload_bake );
102	/*virtual*/ void				stopAnimating(BOOL upload_bake);
103	/*virtual*/ BOOL				linkDrivenParams(visual_param_mapper mapper, BOOL only_cross_params);
104	/*virtual*/ void				resetDrivenParams();
105	
106	// LLViewerVisualParam Virtual functions
107	/*virtual*/ F32					getTotalDistortion();
108	/*virtual*/ const LLVector3&	getAvgDistortion();
109	/*virtual*/ F32					getMaxDistortion();
110	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
111	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
112	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
113
114protected:
115	F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight);
116	void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake);
117
118
119	LLVector3	mDefaultVec; // temp holder
120	typedef std::vector<LLDrivenEntry> entry_list_t;
121	entry_list_t mDriven;
122	LLViewerVisualParam* mCurrentDistortionParam;
123	// Backlink only; don't make this an LLPointer.
124	LLVOAvatar* mAvatarp;
125	LLWearable* mWearablep;
126};
127
128#endif  // LL_LLDRIVERPARAM_H