PageRenderTime 29ms CodeModel.GetById 12ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llpolymorph.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 182 lines | 100 code | 31 blank | 51 comment | 0 complexity | f768f1223226c22fee1c077340938841 MD5 | raw file
  1/** 
  2 * @file llpolymorph.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_LLPOLYMORPH_H
 28#define LL_LLPOLYMORPH_H
 29
 30#include <string>
 31#include <vector>
 32
 33#include "llviewervisualparam.h"
 34
 35class LLPolyMeshSharedData;
 36class LLVOAvatar;
 37class LLVector2;
 38class LLViewerJointCollisionVolume;
 39class LLWearable;
 40
 41//-----------------------------------------------------------------------------
 42// LLPolyMorphData()
 43//-----------------------------------------------------------------------------
 44class LLPolyMorphData
 45{
 46public:
 47	LLPolyMorphData(const std::string& morph_name);
 48	~LLPolyMorphData();
 49	LLPolyMorphData(const LLPolyMorphData &rhs);
 50
 51	BOOL			loadBinary(LLFILE* fp, LLPolyMeshSharedData *mesh);
 52	const std::string& getName() { return mName; }
 53
 54public:
 55	std::string			mName;
 56
 57	// morphology
 58	U32					mNumIndices;
 59	U32*				mVertexIndices;
 60	U32					mCurrentIndex;
 61	LLVector3*			mCoords;
 62	LLVector3*			mNormals;
 63	LLVector3*			mBinormals;
 64	LLVector2*			mTexCoords;
 65
 66	F32					mTotalDistortion;	// vertex distortion summed over entire morph
 67	F32					mMaxDistortion;		// maximum single vertex distortion in a given morph
 68	LLVector3			mAvgDistortion;		// average vertex distortion, to infer directionality of the morph
 69	LLPolyMeshSharedData*	mMesh;
 70};
 71
 72//-----------------------------------------------------------------------------
 73// LLPolyVertexMask()
 74//-----------------------------------------------------------------------------
 75class LLPolyVertexMask
 76{
 77public:
 78	LLPolyVertexMask(LLPolyMorphData* morph_data);
 79	~LLPolyVertexMask();
 80
 81	void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights);
 82	F32* getMorphMaskWeights();
 83
 84
 85protected:
 86	F32*		mWeights;
 87	LLPolyMorphData *mMorphData;
 88	BOOL			mWeightsGenerated;
 89
 90};
 91
 92//-----------------------------------------------------------------------------
 93// LLPolyMorphTarget Data structs
 94//-----------------------------------------------------------------------------
 95struct LLPolyVolumeMorphInfo
 96{
 97	LLPolyVolumeMorphInfo(std::string &name, LLVector3 &scale, LLVector3 &pos)
 98		: mName(name), mScale(scale), mPos(pos) {};
 99
100	std::string						mName;
101	LLVector3						mScale;
102	LLVector3						mPos;
103};
104
105struct LLPolyVolumeMorph
106{
107	LLPolyVolumeMorph(LLViewerJointCollisionVolume* volume, LLVector3 scale, LLVector3 pos)
108		: mVolume(volume), mScale(scale), mPos(pos) {};
109
110	LLViewerJointCollisionVolume*	mVolume;
111	LLVector3						mScale;
112	LLVector3						mPos;
113};
114
115//-----------------------------------------------------------------------------
116// LLPolyMorphTargetInfo
117// Shared information for LLPolyMorphTargets
118//-----------------------------------------------------------------------------
119class LLPolyMorphTargetInfo : public LLViewerVisualParamInfo
120{
121	friend class LLPolyMorphTarget;
122public:
123	LLPolyMorphTargetInfo();
124	/*virtual*/ ~LLPolyMorphTargetInfo() {};
125	
126	/*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
127
128protected:
129	std::string		mMorphName;
130	BOOL			mIsClothingMorph;
131	typedef std::vector<LLPolyVolumeMorphInfo> volume_info_list_t;
132	volume_info_list_t mVolumeInfoList;	
133};
134
135//-----------------------------------------------------------------------------
136// LLPolyMorphTarget
137// A set of vertex data associated with morph target.
138// These morph targets must be topologically consistent with a given Polymesh
139// (share face sets)
140//-----------------------------------------------------------------------------
141class LLPolyMorphTarget : public LLViewerVisualParam
142{
143public:
144	LLPolyMorphTarget(LLPolyMesh *poly_mesh);
145	~LLPolyMorphTarget();
146
147	// Special: These functions are overridden by child classes
148	LLPolyMorphTargetInfo*	getInfo() const { return (LLPolyMorphTargetInfo*)mInfo; }
149	//   This sets mInfo and calls initialization functions
150	BOOL					setInfo(LLPolyMorphTargetInfo *info);
151
152	/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const;
153
154	// LLVisualParam Virtual functions
155	///*virtual*/ BOOL				parseData(LLXmlTreeNode* node);
156	/*virtual*/ void				apply( ESex sex );
157	
158	// LLViewerVisualParam Virtual functions
159	/*virtual*/ F32					getTotalDistortion();
160	/*virtual*/ const LLVector3&	getAvgDistortion();
161	/*virtual*/ F32					getMaxDistortion();
162	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
163	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
164	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
165
166	void	applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
167	void	addPendingMorphMask() { mNumMorphMasksPending++; }
168
169protected:
170	LLPolyMorphData*				mMorphData;
171	LLPolyMesh*						mMesh;
172	LLPolyVertexMask *				mVertMask;
173	ESex							mLastSex;
174	// number of morph masks that haven't been generated, must be 0 before this morph is applied
175	BOOL							mNumMorphMasksPending;	
176
177	typedef std::vector<LLPolyVolumeMorph> volume_list_t;
178	volume_list_t 					mVolumeMorphs;
179
180};
181
182#endif // LL_LLPOLYMORPH_H