PageRenderTime 344ms CodeModel.GetById 150ms app.highlight 21ms RepoModel.GetById 171ms app.codeStats 0ms

/indra/llcharacter/lljointstate.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 128 lines | 66 code | 17 blank | 45 comment | 1 complexity | 1f8366ae9d24749931de3a336fc64e08 MD5 | raw file
  1/** 
  2 * @file lljointstate.h
  3 * @brief Implementation of LLJointState 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_LLJOINTSTATE_H
 28#define LL_LLJOINTSTATE_H
 29
 30//-----------------------------------------------------------------------------
 31// Header Files
 32//-----------------------------------------------------------------------------
 33#include "lljoint.h"
 34#include "llrefcount.h"
 35
 36//-----------------------------------------------------------------------------
 37// class LLJointState
 38//-----------------------------------------------------------------------------
 39class LLJointState : public LLRefCount
 40{
 41public:
 42	enum BlendPhase
 43	{
 44		INACTIVE,
 45		EASE_IN,
 46		ACTIVE,
 47		EASE_OUT
 48	};
 49protected:
 50	// associated joint
 51	LLJoint	*mJoint;
 52
 53	// indicates which members are used
 54	U32		mUsage;
 55
 56	// indicates weighted effect of this joint 
 57	F32		mWeight;
 58
 59	// transformation members
 60	LLVector3		mPosition;	// position relative to parent joint
 61	LLQuaternion	mRotation;	// joint rotation relative to parent joint
 62	LLVector3		mScale;		// scale relative to rotated frame
 63	LLJoint::JointPriority	mPriority;  // how important this joint state is relative to others
 64public:
 65	// Constructor
 66	LLJointState()
 67	{
 68		mUsage = 0;
 69		mJoint = NULL;
 70		mUsage = 0;
 71		mWeight = 0.f;
 72		mPriority = LLJoint::USE_MOTION_PRIORITY;
 73	}
 74
 75	LLJointState(LLJoint* joint)
 76	{
 77		mUsage = 0;
 78		mJoint = joint;
 79		mUsage = 0;
 80		mWeight = 0.f;
 81		mPriority = LLJoint::USE_MOTION_PRIORITY;
 82	}
 83
 84	// joint that this state is applied to
 85	LLJoint* getJoint()				{ return mJoint; }
 86	const LLJoint* getJoint() const	{ return mJoint; }
 87	BOOL setJoint( LLJoint *joint )	{ mJoint = joint; return mJoint != NULL; }
 88
 89	// transform type (bitwise flags can be combined)
 90	// Note that these are set automatically when various
 91	// member setPos/setRot/setScale functions are called.
 92	enum Usage
 93	{
 94		POS		= 1,
 95		ROT		= 2,
 96		SCALE	= 4,
 97	};
 98	U32 getUsage() const			{ return mUsage; }
 99	void setUsage( U32 usage )		{ mUsage = usage; }
100	F32 getWeight() const			{ return mWeight; }
101	void setWeight( F32 weight )	{ mWeight = weight; }
102
103	// get/set position
104	const LLVector3& getPosition() const		{ return mPosition; }
105	void setPosition( const LLVector3& pos )	{ llassert(mUsage & POS); mPosition = pos; }
106
107	// get/set rotation
108	const LLQuaternion& getRotation() const		{ return mRotation; }
109	void setRotation( const LLQuaternion& rot )	{ llassert(mUsage & ROT); mRotation = rot; }
110
111	// get/set scale
112	const LLVector3& getScale() const			{ return mScale; }
113	void setScale( const LLVector3& scale )		{ llassert(mUsage & SCALE); mScale = scale; }
114
115	// get/set priority
116	LLJoint::JointPriority getPriority() const	{ return mPriority; }
117	void setPriority( LLJoint::JointPriority priority ) { mPriority = priority; }
118
119protected:
120	// Destructor
121	virtual ~LLJointState()
122	{
123	}
124	
125};
126
127#endif // LL_LLJOINTSTATE_H
128