aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcharacter/lljointsolverrp3.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llcharacter/lljointsolverrp3.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llcharacter/lljointsolverrp3.h')
-rw-r--r--linden/indra/llcharacter/lljointsolverrp3.h177
1 files changed, 177 insertions, 0 deletions
diff --git a/linden/indra/llcharacter/lljointsolverrp3.h b/linden/indra/llcharacter/lljointsolverrp3.h
new file mode 100644
index 0000000..7dd35eb
--- /dev/null
+++ b/linden/indra/llcharacter/lljointsolverrp3.h
@@ -0,0 +1,177 @@
1/**
2 * @file lljointsolverrp3.h
3 * @brief Implementation of LLJointSolverRP3 class
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLJOINTSOLVERRP3_H
29#define LL_LLJOINTSOLVERRP3_H
30
31//-----------------------------------------------------------------------------
32// Header Files
33//-----------------------------------------------------------------------------
34#include "lljoint.h"
35
36/* -some compilers don't like line continuation chars-
37//-----------------------------------------------------------------------------
38// class LLJointSolverRP3
39//
40// This class is a "poor man's" IK for simple 3 joint kinematic chains.
41// It is modeled after the 'ikRPSolver' in Maya.
42// This class takes 4 LLJoints:
43// jointA
44// jointB
45// jointC
46// jointGoal
47//
48// Such that jointA is the parent of jointB, jointB is the parent of jointC.
49// When invoked, this class modifies the rotations of jointA and jointB such
50// that the position of the jointC attempts to reach the position of jointGoal.
51//
52// At object initialization time, the distances between jointA - jointB and
53// jointB - jointC are cached. During evaluation these bone lengths are
54// preserved.
55//
56// A A
57// | |
58// | |
59// B B---CG A---B---C...G
60// \
61// \
62// CG
63//
64//
65// In addition a "poleVector" is specified that does two things:
66//
67// a) defines the plane in which the solution occurs, thus
68// reducing an infinite number of solutions, down to 2.
69//
70// b) disambiguates the resulting two solutions as follows:
71//
72// A A A--->poleVector
73// | \ \
74// | \ \
75// B vs. B ==> B
76// \ | |
77// \ | |
78// CG CG CG
79//
80// A "twist" setting allows the solution plane to be rotated about the
81// line between A and C. A handy animation feature.
82//
83// For "smarter" results for non-coplanar limbs, specify the joints axis
84// of bend in the B's local frame (see setBAxis())
85//-----------------------------------------------------------------------------
86*/
87
88class LLJointSolverRP3
89{
90protected:
91 LLJoint *mJointA;
92 LLJoint *mJointB;
93 LLJoint *mJointC;
94 LLJoint *mJointGoal;
95
96 F32 mLengthAB;
97 F32 mLengthBC;
98
99 LLVector3 mPoleVector;
100 LLVector3 mBAxis;
101 BOOL mbUseBAxis;
102
103 F32 mTwist;
104
105 BOOL mFirstTime;
106 LLMatrix4 mSavedJointAMat;
107 LLMatrix4 mSavedInvPlaneMat;
108
109 LLQuaternion mJointABaseRotation;
110 LLQuaternion mJointBBaseRotation;
111
112public:
113 //-------------------------------------------------------------------------
114 // Constructor/Destructor
115 //-------------------------------------------------------------------------
116 LLJointSolverRP3();
117 virtual ~LLJointSolverRP3();
118
119 //-------------------------------------------------------------------------
120 // setupJoints()
121 // This must be called one time to setup the solver.
122 // This must be called AFTER the skeleton has been created, all parent/child
123 // relationships are established, and after the joints are placed in
124 // a valid configuration (as distances between them will be cached).
125 //-------------------------------------------------------------------------
126 void setupJoints( LLJoint* jointA,
127 LLJoint* jointB,
128 LLJoint* jointC,
129 LLJoint* jointGoal );
130
131 //-------------------------------------------------------------------------
132 // getPoleVector()
133 // Returns the current pole vector.
134 //-------------------------------------------------------------------------
135 const LLVector3& getPoleVector();
136
137 //-------------------------------------------------------------------------
138 // setPoleVector()
139 // Sets the pole vector.
140 // The pole vector is defined relative to (in the space of) jointA's parent.
141 // The default pole vector is (1,0,0), and this is used if this function
142 // is never called.
143 // This vector is normalized when set.
144 //-------------------------------------------------------------------------
145 void setPoleVector( const LLVector3& poleVector );
146
147 //-------------------------------------------------------------------------
148 // setBAxis()
149 // Sets the joint's axis in B's local frame, and enable "smarter" solve().
150 // This allows for smarter IK when for twisted limbs.
151 //-------------------------------------------------------------------------
152 void setBAxis( const LLVector3& bAxis );
153
154 //-------------------------------------------------------------------------
155 // getTwist()
156 // Returns the current twist in radians.
157 //-------------------------------------------------------------------------
158 F32 getTwist();
159
160 //-------------------------------------------------------------------------
161 // setTwist()
162 // Sets the twist value.
163 // The default is 0.0.
164 //-------------------------------------------------------------------------
165 void setTwist( F32 twist );
166
167 //-------------------------------------------------------------------------
168 // solve()
169 // This is the "work" function.
170 // When called, the rotations of jointA and jointB will be modified
171 // such that jointC attempts to reach jointGoal.
172 //-------------------------------------------------------------------------
173 void solve();
174};
175
176#endif // LL_LLJOINTSOLVERRP3_H
177