/indra/llcharacter/lleditingmotion.h
C++ Header | 133 lines | 48 code | 25 blank | 60 comment | 0 complexity | e42d13c8a31a469bc59dd82ac3e6e0a4 MD5 | raw file
Possible License(s): LGPL-2.1
1/**
2 * @file lleditingmotion.h
3 * @brief Implementation of LLEditingMotion 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_LLEDITINGMOTION_H
28#define LL_LLEDITINGMOTION_H
29
30//-----------------------------------------------------------------------------
31// Header files
32//-----------------------------------------------------------------------------
33#include "llmotion.h"
34#include "lljointsolverrp3.h"
35#include "v3dmath.h"
36
37#define EDITING_EASEIN_DURATION 0.0f
38#define EDITING_EASEOUT_DURATION 0.5f
39#define EDITING_PRIORITY LLJoint::HIGH_PRIORITY
40#define MIN_REQUIRED_PIXEL_AREA_EDITING 500.f
41
42//-----------------------------------------------------------------------------
43// class LLEditingMotion
44//-----------------------------------------------------------------------------
45class LLEditingMotion :
46 public LLMotion
47{
48public:
49 // Constructor
50 LLEditingMotion(const LLUUID &id);
51
52 // Destructor
53 virtual ~LLEditingMotion();
54
55public:
56 //-------------------------------------------------------------------------
57 // functions to support MotionController and MotionRegistry
58 //-------------------------------------------------------------------------
59
60 // static constructor
61 // all subclasses must implement such a function and register it
62 static LLMotion *create(const LLUUID &id) { return new LLEditingMotion(id); }
63
64public:
65 //-------------------------------------------------------------------------
66 // animation callbacks to be implemented by subclasses
67 //-------------------------------------------------------------------------
68
69 // motions must specify whether or not they loop
70 virtual BOOL getLoop() { return TRUE; }
71
72 // motions must report their total duration
73 virtual F32 getDuration() { return 0.0; }
74
75 // motions must report their "ease in" duration
76 virtual F32 getEaseInDuration() { return EDITING_EASEIN_DURATION; }
77
78 // motions must report their "ease out" duration.
79 virtual F32 getEaseOutDuration() { return EDITING_EASEOUT_DURATION; }
80
81 // motions must report their priority
82 virtual LLJoint::JointPriority getPriority() { return EDITING_PRIORITY; }
83
84 virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
85
86 // called to determine when a motion should be activated/deactivated based on avatar pixel coverage
87 virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_EDITING; }
88
89 // run-time (post constructor) initialization,
90 // called after parameters have been set
91 // must return true to indicate success and be available for activation
92 virtual LLMotionInitStatus onInitialize(LLCharacter *character);
93
94 // called when a motion is activated
95 // must return TRUE to indicate success, or else
96 // it will be deactivated
97 virtual BOOL onActivate();
98
99 // called per time step
100 // must return TRUE while it is active, and
101 // must return FALSE when the motion is completed.
102 virtual BOOL onUpdate(F32 time, U8* joint_mask);
103
104 // called when a motion is deactivated
105 virtual void onDeactivate();
106
107public:
108 //-------------------------------------------------------------------------
109 // joint states to be animated
110 //-------------------------------------------------------------------------
111 LLCharacter *mCharacter;
112 LLVector3 mWristOffset;
113
114 LLPointer<LLJointState> mParentState;
115 LLPointer<LLJointState> mShoulderState;
116 LLPointer<LLJointState> mElbowState;
117 LLPointer<LLJointState> mWristState;
118 LLPointer<LLJointState> mTorsoState;
119
120 LLJoint mParentJoint;
121 LLJoint mShoulderJoint;
122 LLJoint mElbowJoint;
123 LLJoint mWristJoint;
124 LLJoint mTarget;
125 LLJointSolverRP3 mIKSolver;
126
127 static S32 sHandPose;
128 static S32 sHandPosePriority;
129 LLVector3 mLastSelectPt;
130};
131
132#endif // LL_LLKEYFRAMEMOTION_H
133