diff options
author | Jacek Antonelli | 2008-08-15 23:45:27 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:27 -0500 |
commit | a8a62201ba762e98dff92cf49033e577fc34d8d4 (patch) | |
tree | 11f8513c5cdc222f2fac0c93eb724c089803c200 /linden/indra/llcharacter/lleditingmotion.cpp | |
parent | Second Life viewer sources 1.18.6.4-RC (diff) | |
download | meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.zip meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.gz meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.bz2 meta-impy-a8a62201ba762e98dff92cf49033e577fc34d8d4.tar.xz |
Second Life viewer sources 1.19.0.0
Diffstat (limited to 'linden/indra/llcharacter/lleditingmotion.cpp')
-rw-r--r-- | linden/indra/llcharacter/lleditingmotion.cpp | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/linden/indra/llcharacter/lleditingmotion.cpp b/linden/indra/llcharacter/lleditingmotion.cpp index c2519c2..c693e6d 100644 --- a/linden/indra/llcharacter/lleditingmotion.cpp +++ b/linden/indra/llcharacter/lleditingmotion.cpp | |||
@@ -12,12 +12,12 @@ | |||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | 12 | * ("GPL"), unless you have obtained a separate licensing agreement |
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 13 | * ("Other License"), formally executed by you and Linden Lab. Terms of |
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | 14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or |
15 | * online at http://secondlife.com/developers/opensource/gplv2 | 15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
16 | * | 16 | * |
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlife.com/developers/opensource/flossexception | 20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception |
21 | * | 21 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 22 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 23 | * that you have read and understood your obligations described above, |
@@ -64,6 +64,12 @@ LLEditingMotion::LLEditingMotion( const LLUUID &id) : LLMotion(id) | |||
64 | mElbowJoint.addChild( &mWristJoint ); | 64 | mElbowJoint.addChild( &mWristJoint ); |
65 | 65 | ||
66 | mName = "editing"; | 66 | mName = "editing"; |
67 | |||
68 | mParentState = new LLJointState; | ||
69 | mShoulderState = new LLJointState; | ||
70 | mElbowState = new LLJointState; | ||
71 | mWristState = new LLJointState; | ||
72 | mTorsoState = new LLJointState; | ||
67 | } | 73 | } |
68 | 74 | ||
69 | 75 | ||
@@ -93,13 +99,13 @@ LLMotion::LLMotionInitStatus LLEditingMotion::onInitialize(LLCharacter *characte | |||
93 | } | 99 | } |
94 | 100 | ||
95 | // get the shoulder, elbow, wrist joints from the character | 101 | // get the shoulder, elbow, wrist joints from the character |
96 | mParentState.setJoint( mCharacter->getJoint("mShoulderLeft")->getParent() ); | 102 | mParentState->setJoint( mCharacter->getJoint("mShoulderLeft")->getParent() ); |
97 | mShoulderState.setJoint( mCharacter->getJoint("mShoulderLeft") ); | 103 | mShoulderState->setJoint( mCharacter->getJoint("mShoulderLeft") ); |
98 | mElbowState.setJoint( mCharacter->getJoint("mElbowLeft") ); | 104 | mElbowState->setJoint( mCharacter->getJoint("mElbowLeft") ); |
99 | mWristState.setJoint( mCharacter->getJoint("mWristLeft") ); | 105 | mWristState->setJoint( mCharacter->getJoint("mWristLeft") ); |
100 | mTorsoState.setJoint( mCharacter->getJoint("mTorso")); | 106 | mTorsoState->setJoint( mCharacter->getJoint("mTorso")); |
101 | 107 | ||
102 | if ( ! mParentState.getJoint() ) | 108 | if ( ! mParentState->getJoint() ) |
103 | { | 109 | { |
104 | llinfos << getName() << ": Can't get parent joint." << llendl; | 110 | llinfos << getName() << ": Can't get parent joint." << llendl; |
105 | return STATUS_FAILURE; | 111 | return STATUS_FAILURE; |
@@ -108,25 +114,25 @@ LLMotion::LLMotionInitStatus LLEditingMotion::onInitialize(LLCharacter *characte | |||
108 | mWristOffset = LLVector3(0.0f, 0.2f, 0.0f); | 114 | mWristOffset = LLVector3(0.0f, 0.2f, 0.0f); |
109 | 115 | ||
110 | // add joint states to the pose | 116 | // add joint states to the pose |
111 | mShoulderState.setUsage(LLJointState::ROT); | 117 | mShoulderState->setUsage(LLJointState::ROT); |
112 | mElbowState.setUsage(LLJointState::ROT); | 118 | mElbowState->setUsage(LLJointState::ROT); |
113 | mTorsoState.setUsage(LLJointState::ROT); | 119 | mTorsoState->setUsage(LLJointState::ROT); |
114 | mWristState.setUsage(LLJointState::ROT); | 120 | mWristState->setUsage(LLJointState::ROT); |
115 | addJointState( &mShoulderState ); | 121 | addJointState( mShoulderState ); |
116 | addJointState( &mElbowState ); | 122 | addJointState( mElbowState ); |
117 | addJointState( &mTorsoState ); | 123 | addJointState( mTorsoState ); |
118 | addJointState( &mWristState ); | 124 | addJointState( mWristState ); |
119 | 125 | ||
120 | // propagate joint positions to kinematic chain | 126 | // propagate joint positions to kinematic chain |
121 | mParentJoint.setPosition( mParentState.getJoint()->getWorldPosition() ); | 127 | mParentJoint.setPosition( mParentState->getJoint()->getWorldPosition() ); |
122 | mShoulderJoint.setPosition( mShoulderState.getJoint()->getPosition() ); | 128 | mShoulderJoint.setPosition( mShoulderState->getJoint()->getPosition() ); |
123 | mElbowJoint.setPosition( mElbowState.getJoint()->getPosition() ); | 129 | mElbowJoint.setPosition( mElbowState->getJoint()->getPosition() ); |
124 | mWristJoint.setPosition( mWristState.getJoint()->getPosition() + mWristOffset ); | 130 | mWristJoint.setPosition( mWristState->getJoint()->getPosition() + mWristOffset ); |
125 | 131 | ||
126 | // propagate current joint rotations to kinematic chain | 132 | // propagate current joint rotations to kinematic chain |
127 | mParentJoint.setRotation( mParentState.getJoint()->getWorldRotation() ); | 133 | mParentJoint.setRotation( mParentState->getJoint()->getWorldRotation() ); |
128 | mShoulderJoint.setRotation( mShoulderState.getJoint()->getRotation() ); | 134 | mShoulderJoint.setRotation( mShoulderState->getJoint()->getRotation() ); |
129 | mElbowJoint.setRotation( mElbowState.getJoint()->getRotation() ); | 135 | mElbowJoint.setRotation( mElbowState->getJoint()->getRotation() ); |
130 | 136 | ||
131 | // connect the ikSolver to the chain | 137 | // connect the ikSolver to the chain |
132 | mIKSolver.setPoleVector( LLVector3( -1.0f, 1.0f, 0.0f ) ); | 138 | mIKSolver.setPoleVector( LLVector3( -1.0f, 1.0f, 0.0f ) ); |
@@ -144,15 +150,15 @@ LLMotion::LLMotionInitStatus LLEditingMotion::onInitialize(LLCharacter *characte | |||
144 | BOOL LLEditingMotion::onActivate() | 150 | BOOL LLEditingMotion::onActivate() |
145 | { | 151 | { |
146 | // propagate joint positions to kinematic chain | 152 | // propagate joint positions to kinematic chain |
147 | mParentJoint.setPosition( mParentState.getJoint()->getWorldPosition() ); | 153 | mParentJoint.setPosition( mParentState->getJoint()->getWorldPosition() ); |
148 | mShoulderJoint.setPosition( mShoulderState.getJoint()->getPosition() ); | 154 | mShoulderJoint.setPosition( mShoulderState->getJoint()->getPosition() ); |
149 | mElbowJoint.setPosition( mElbowState.getJoint()->getPosition() ); | 155 | mElbowJoint.setPosition( mElbowState->getJoint()->getPosition() ); |
150 | mWristJoint.setPosition( mWristState.getJoint()->getPosition() + mWristOffset ); | 156 | mWristJoint.setPosition( mWristState->getJoint()->getPosition() + mWristOffset ); |
151 | 157 | ||
152 | // propagate current joint rotations to kinematic chain | 158 | // propagate current joint rotations to kinematic chain |
153 | mParentJoint.setRotation( mParentState.getJoint()->getWorldRotation() ); | 159 | mParentJoint.setRotation( mParentState->getJoint()->getWorldRotation() ); |
154 | mShoulderJoint.setRotation( mShoulderState.getJoint()->getRotation() ); | 160 | mShoulderJoint.setRotation( mShoulderState->getJoint()->getRotation() ); |
155 | mElbowJoint.setRotation( mElbowState.getJoint()->getRotation() ); | 161 | mElbowJoint.setRotation( mElbowState->getJoint()->getRotation() ); |
156 | 162 | ||
157 | return TRUE; | 163 | return TRUE; |
158 | } | 164 | } |
@@ -182,15 +188,15 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) | |||
182 | focus_pt += mCharacter->getCharacterPosition(); | 188 | focus_pt += mCharacter->getCharacterPosition(); |
183 | 189 | ||
184 | // propagate joint positions to kinematic chain | 190 | // propagate joint positions to kinematic chain |
185 | mParentJoint.setPosition( mParentState.getJoint()->getWorldPosition() ); | 191 | mParentJoint.setPosition( mParentState->getJoint()->getWorldPosition() ); |
186 | mShoulderJoint.setPosition( mShoulderState.getJoint()->getPosition() ); | 192 | mShoulderJoint.setPosition( mShoulderState->getJoint()->getPosition() ); |
187 | mElbowJoint.setPosition( mElbowState.getJoint()->getPosition() ); | 193 | mElbowJoint.setPosition( mElbowState->getJoint()->getPosition() ); |
188 | mWristJoint.setPosition( mWristState.getJoint()->getPosition() + mWristOffset ); | 194 | mWristJoint.setPosition( mWristState->getJoint()->getPosition() + mWristOffset ); |
189 | 195 | ||
190 | // propagate current joint rotations to kinematic chain | 196 | // propagate current joint rotations to kinematic chain |
191 | mParentJoint.setRotation( mParentState.getJoint()->getWorldRotation() ); | 197 | mParentJoint.setRotation( mParentState->getJoint()->getWorldRotation() ); |
192 | mShoulderJoint.setRotation( mShoulderState.getJoint()->getRotation() ); | 198 | mShoulderJoint.setRotation( mShoulderState->getJoint()->getRotation() ); |
193 | mElbowJoint.setRotation( mElbowState.getJoint()->getRotation() ); | 199 | mElbowJoint.setRotation( mElbowState->getJoint()->getRotation() ); |
194 | 200 | ||
195 | // update target position from character | 201 | // update target position from character |
196 | LLVector3 target = focus_pt - mParentJoint.getPosition(); | 202 | LLVector3 target = focus_pt - mParentJoint.getPosition(); |
@@ -199,7 +205,7 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) | |||
199 | LLVector3 edit_plane_normal(1.f / F_SQRT2, 1.f / F_SQRT2, 0.f); | 205 | LLVector3 edit_plane_normal(1.f / F_SQRT2, 1.f / F_SQRT2, 0.f); |
200 | edit_plane_normal.normVec(); | 206 | edit_plane_normal.normVec(); |
201 | 207 | ||
202 | edit_plane_normal.rotVec(mTorsoState.getJoint()->getWorldRotation()); | 208 | edit_plane_normal.rotVec(mTorsoState->getJoint()->getWorldRotation()); |
203 | 209 | ||
204 | F32 dot = edit_plane_normal * target; | 210 | F32 dot = edit_plane_normal * target; |
205 | 211 | ||
@@ -236,9 +242,9 @@ BOOL LLEditingMotion::onUpdate(F32 time, U8* joint_mask) | |||
236 | // now put blended values back into joints | 242 | // now put blended values back into joints |
237 | llassert(shoulderRot.isFinite()); | 243 | llassert(shoulderRot.isFinite()); |
238 | llassert(elbowRot.isFinite()); | 244 | llassert(elbowRot.isFinite()); |
239 | mShoulderState.setRotation(shoulderRot); | 245 | mShoulderState->setRotation(shoulderRot); |
240 | mElbowState.setRotation(elbowRot); | 246 | mElbowState->setRotation(elbowRot); |
241 | mWristState.setRotation(LLQuaternion::DEFAULT); | 247 | mWristState->setRotation(LLQuaternion::DEFAULT); |
242 | } | 248 | } |
243 | 249 | ||
244 | mCharacter->setAnimationData("Hand Pose", &sHandPose); | 250 | mCharacter->setAnimationData("Hand Pose", &sHandPose); |