diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llcharacter/llkeyframemotion.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llcharacter/llkeyframemotion.cpp')
-rw-r--r-- | linden/indra/llcharacter/llkeyframemotion.cpp | 295 |
1 files changed, 115 insertions, 180 deletions
diff --git a/linden/indra/llcharacter/llkeyframemotion.cpp b/linden/indra/llcharacter/llkeyframemotion.cpp index 4288b8d..0138860 100644 --- a/linden/indra/llcharacter/llkeyframemotion.cpp +++ b/linden/indra/llcharacter/llkeyframemotion.cpp | |||
@@ -122,6 +122,7 @@ U32 LLKeyframeMotion::JointMotionList::dumpDiagInfo() | |||
122 | //----------------------------------------------------------------------------- | 122 | //----------------------------------------------------------------------------- |
123 | //----------------------------------------------------------------------------- | 123 | //----------------------------------------------------------------------------- |
124 | 124 | ||
125 | |||
125 | //----------------------------------------------------------------------------- | 126 | //----------------------------------------------------------------------------- |
126 | // ScaleCurve::ScaleCurve() | 127 | // ScaleCurve::ScaleCurve() |
127 | //----------------------------------------------------------------------------- | 128 | //----------------------------------------------------------------------------- |
@@ -136,7 +137,7 @@ LLKeyframeMotion::ScaleCurve::ScaleCurve() | |||
136 | //----------------------------------------------------------------------------- | 137 | //----------------------------------------------------------------------------- |
137 | LLKeyframeMotion::ScaleCurve::~ScaleCurve() | 138 | LLKeyframeMotion::ScaleCurve::~ScaleCurve() |
138 | { | 139 | { |
139 | mKeys.deleteAllData(); | 140 | mKeys.clear(); |
140 | mNumKeys = 0; | 141 | mNumKeys = 0; |
141 | } | 142 | } |
142 | 143 | ||
@@ -146,43 +147,42 @@ LLKeyframeMotion::ScaleCurve::~ScaleCurve() | |||
146 | LLVector3 LLKeyframeMotion::ScaleCurve::getValue(F32 time, F32 duration) | 147 | LLVector3 LLKeyframeMotion::ScaleCurve::getValue(F32 time, F32 duration) |
147 | { | 148 | { |
148 | LLVector3 value; | 149 | LLVector3 value; |
149 | F32 index_before, index_after; | ||
150 | ScaleKey* scale_before; | ||
151 | ScaleKey* scale_after; | ||
152 | 150 | ||
153 | mKeys.getInterval(time, index_before, index_after, scale_before, scale_after); | 151 | if (mKeys.empty()) |
154 | if (scale_before) | ||
155 | { | 152 | { |
156 | if (!scale_after) | 153 | value.clearVec(); |
157 | { | 154 | return value; |
158 | scale_after = &mLoopInKey; | 155 | } |
159 | index_after = duration; | 156 | |
160 | } | 157 | key_map_t::iterator right = mKeys.lower_bound(time); |
161 | 158 | if (right == mKeys.end()) | |
162 | if (index_after == index_before) | 159 | { |
163 | { | 160 | // Past last key |
164 | value = scale_after->mScale; | 161 | --right; |
165 | } | 162 | value = right->second.mScale; |
166 | else | 163 | } |
167 | { | 164 | else if (right == mKeys.begin() || right->first == time) |
168 | F32 u = (time - index_before) / (index_after - index_before); | 165 | { |
169 | value = interp(u, *scale_before, *scale_after); | 166 | // Before first key or exactly on a key |
170 | } | 167 | value = right->second.mScale; |
171 | } | 168 | } |
172 | else | 169 | else |
173 | { | 170 | { |
174 | // before first key | 171 | // Between two keys |
175 | if (scale_after) | 172 | key_map_t::iterator left = right; --left; |
176 | { | 173 | F32 index_before = left->first; |
177 | value = scale_after->mScale; | 174 | F32 index_after = right->first; |
178 | } | 175 | ScaleKey& scale_before = left->second; |
179 | // no keys? | 176 | ScaleKey& scale_after = right->second; |
180 | else | 177 | if (right == mKeys.end()) |
181 | { | 178 | { |
182 | value.clearVec(); | 179 | scale_after = mLoopInKey; |
180 | index_after = duration; | ||
183 | } | 181 | } |
184 | } | ||
185 | 182 | ||
183 | F32 u = (time - index_before) / (index_after - index_before); | ||
184 | value = interp(u, scale_before, scale_after); | ||
185 | } | ||
186 | return value; | 186 | return value; |
187 | } | 187 | } |
188 | 188 | ||
@@ -217,7 +217,7 @@ LLKeyframeMotion::RotationCurve::RotationCurve() | |||
217 | //----------------------------------------------------------------------------- | 217 | //----------------------------------------------------------------------------- |
218 | LLKeyframeMotion::RotationCurve::~RotationCurve() | 218 | LLKeyframeMotion::RotationCurve::~RotationCurve() |
219 | { | 219 | { |
220 | mKeys.deleteAllData(); | 220 | mKeys.clear(); |
221 | mNumKeys = 0; | 221 | mNumKeys = 0; |
222 | } | 222 | } |
223 | 223 | ||
@@ -227,44 +227,42 @@ LLKeyframeMotion::RotationCurve::~RotationCurve() | |||
227 | LLQuaternion LLKeyframeMotion::RotationCurve::getValue(F32 time, F32 duration) | 227 | LLQuaternion LLKeyframeMotion::RotationCurve::getValue(F32 time, F32 duration) |
228 | { | 228 | { |
229 | LLQuaternion value; | 229 | LLQuaternion value; |
230 | F32 index_before, index_after; | ||
231 | RotationKey* rot_before; | ||
232 | RotationKey* rot_after; | ||
233 | 230 | ||
234 | mKeys.getInterval(time, index_before, index_after, rot_before, rot_after); | 231 | if (mKeys.empty()) |
235 | |||
236 | if (rot_before) | ||
237 | { | 232 | { |
238 | if (!rot_after) | 233 | value = LLQuaternion::DEFAULT; |
239 | { | 234 | return value; |
240 | rot_after = &mLoopInKey; | 235 | } |
241 | index_after = duration; | 236 | |
242 | } | 237 | key_map_t::iterator right = mKeys.lower_bound(time); |
243 | 238 | if (right == mKeys.end()) | |
244 | if (index_after == index_before) | 239 | { |
245 | { | 240 | // Past last key |
246 | value = rot_after->mRotation; | 241 | --right; |
247 | } | 242 | value = right->second.mRotation; |
248 | else | 243 | } |
249 | { | 244 | else if (right == mKeys.begin() || right->first == time) |
250 | F32 u = (time - index_before) / (index_after - index_before); | 245 | { |
251 | value = interp(u, *rot_before, *rot_after); | 246 | // Before first key or exactly on a key |
252 | } | 247 | value = right->second.mRotation; |
253 | } | 248 | } |
254 | else | 249 | else |
255 | { | 250 | { |
256 | // before first key | 251 | // Between two keys |
257 | if (rot_after) | 252 | key_map_t::iterator left = right; --left; |
253 | F32 index_before = left->first; | ||
254 | F32 index_after = right->first; | ||
255 | RotationKey& rot_before = left->second; | ||
256 | RotationKey& rot_after = right->second; | ||
257 | if (right == mKeys.end()) | ||
258 | { | 258 | { |
259 | value = rot_after->mRotation; | 259 | rot_after = mLoopInKey; |
260 | } | 260 | index_after = duration; |
261 | // no keys? | ||
262 | else | ||
263 | { | ||
264 | value = LLQuaternion::DEFAULT; | ||
265 | } | 261 | } |
266 | } | ||
267 | 262 | ||
263 | F32 u = (time - index_before) / (index_after - index_before); | ||
264 | value = interp(u, rot_before, rot_after); | ||
265 | } | ||
268 | return value; | 266 | return value; |
269 | } | 267 | } |
270 | 268 | ||
@@ -300,7 +298,7 @@ LLKeyframeMotion::PositionCurve::PositionCurve() | |||
300 | //----------------------------------------------------------------------------- | 298 | //----------------------------------------------------------------------------- |
301 | LLKeyframeMotion::PositionCurve::~PositionCurve() | 299 | LLKeyframeMotion::PositionCurve::~PositionCurve() |
302 | { | 300 | { |
303 | mKeys.deleteAllData(); | 301 | mKeys.clear(); |
304 | mNumKeys = 0; | 302 | mNumKeys = 0; |
305 | } | 303 | } |
306 | 304 | ||
@@ -310,46 +308,45 @@ LLKeyframeMotion::PositionCurve::~PositionCurve() | |||
310 | LLVector3 LLKeyframeMotion::PositionCurve::getValue(F32 time, F32 duration) | 308 | LLVector3 LLKeyframeMotion::PositionCurve::getValue(F32 time, F32 duration) |
311 | { | 309 | { |
312 | LLVector3 value; | 310 | LLVector3 value; |
313 | F32 index_before, index_after; | ||
314 | PositionKey* pos_before; | ||
315 | PositionKey* pos_after; | ||
316 | |||
317 | mKeys.getInterval(time, index_before, index_after, pos_before, pos_after); | ||
318 | 311 | ||
319 | if (pos_before) | 312 | if (mKeys.empty()) |
320 | { | 313 | { |
321 | if (!pos_after) | 314 | value.clearVec(); |
322 | { | 315 | return value; |
323 | pos_after = &mLoopInKey; | 316 | } |
324 | index_after = duration; | 317 | |
325 | } | 318 | key_map_t::iterator right = mKeys.lower_bound(time); |
326 | 319 | if (right == mKeys.end()) | |
327 | if (index_after == index_before) | 320 | { |
328 | { | 321 | // Past last key |
329 | value = pos_after->mPosition; | 322 | --right; |
330 | } | 323 | value = right->second.mPosition; |
331 | else | 324 | } |
332 | { | 325 | else if (right == mKeys.begin() || right->first == time) |
333 | F32 u = (time - index_before) / (index_after - index_before); | 326 | { |
334 | value = interp(u, *pos_before, *pos_after); | 327 | // Before first key or exactly on a key |
335 | } | 328 | value = right->second.mPosition; |
336 | } | 329 | } |
337 | else | 330 | else |
338 | { | 331 | { |
339 | // before first key | 332 | // Between two keys |
340 | if (pos_after) | 333 | key_map_t::iterator left = right; --left; |
334 | F32 index_before = left->first; | ||
335 | F32 index_after = right->first; | ||
336 | PositionKey& pos_before = left->second; | ||
337 | PositionKey& pos_after = right->second; | ||
338 | if (right == mKeys.end()) | ||
341 | { | 339 | { |
342 | value = pos_after->mPosition; | 340 | pos_after = mLoopInKey; |
343 | } | 341 | index_after = duration; |
344 | // no keys? | ||
345 | else | ||
346 | { | ||
347 | value.clearVec(); | ||
348 | } | 342 | } |
343 | |||
344 | F32 u = (time - index_before) / (index_after - index_before); | ||
345 | value = interp(u, pos_before, pos_after); | ||
349 | } | 346 | } |
350 | 347 | ||
351 | llassert(value.isFinite()); | 348 | llassert(value.isFinite()); |
352 | 349 | ||
353 | return value; | 350 | return value; |
354 | } | 351 | } |
355 | 352 | ||
@@ -1404,8 +1401,8 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1404 | time = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); | 1401 | time = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); |
1405 | } | 1402 | } |
1406 | 1403 | ||
1407 | RotationKey *rot_key = new RotationKey; | 1404 | RotationKey rot_key; |
1408 | rot_key->mTime = time; | 1405 | rot_key.mTime = time; |
1409 | LLVector3 rot_angles; | 1406 | LLVector3 rot_angles; |
1410 | U16 x, y, z; | 1407 | U16 x, y, z; |
1411 | 1408 | ||
@@ -1416,7 +1413,7 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1416 | success = dp.unpackVector3(rot_angles, "rot_angles"); | 1413 | success = dp.unpackVector3(rot_angles, "rot_angles"); |
1417 | 1414 | ||
1418 | LLQuaternion::Order ro = StringToOrder("ZYX"); | 1415 | LLQuaternion::Order ro = StringToOrder("ZYX"); |
1419 | rot_key->mRotation = mayaQ(rot_angles.mV[VX], rot_angles.mV[VY], rot_angles.mV[VZ], ro); | 1416 | rot_key.mRotation = mayaQ(rot_angles.mV[VX], rot_angles.mV[VY], rot_angles.mV[VZ], ro); |
1420 | } | 1417 | } |
1421 | else | 1418 | else |
1422 | { | 1419 | { |
@@ -1428,13 +1425,12 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1428 | rot_vec.mV[VX] = U16_to_F32(x, -1.f, 1.f); | 1425 | rot_vec.mV[VX] = U16_to_F32(x, -1.f, 1.f); |
1429 | rot_vec.mV[VY] = U16_to_F32(y, -1.f, 1.f); | 1426 | rot_vec.mV[VY] = U16_to_F32(y, -1.f, 1.f); |
1430 | rot_vec.mV[VZ] = U16_to_F32(z, -1.f, 1.f); | 1427 | rot_vec.mV[VZ] = U16_to_F32(z, -1.f, 1.f); |
1431 | rot_key->mRotation.unpackFromVector3(rot_vec); | 1428 | rot_key.mRotation.unpackFromVector3(rot_vec); |
1432 | } | 1429 | } |
1433 | 1430 | ||
1434 | if (!success) | 1431 | if (!success) |
1435 | { | 1432 | { |
1436 | llwarns << "can't read rotation key (" << k << ")" << llendl; | 1433 | llwarns << "can't read rotation key (" << k << ")" << llendl; |
1437 | delete rot_key; | ||
1438 | return FALSE; | 1434 | return FALSE; |
1439 | } | 1435 | } |
1440 | 1436 | ||
@@ -1464,14 +1460,13 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1464 | for (S32 k = 0; k < joint_motion->mPositionCurve.mNumKeys; k++) | 1460 | for (S32 k = 0; k < joint_motion->mPositionCurve.mNumKeys; k++) |
1465 | { | 1461 | { |
1466 | U16 time_short; | 1462 | U16 time_short; |
1467 | PositionKey* pos_key = new PositionKey; | 1463 | PositionKey pos_key; |
1468 | 1464 | ||
1469 | if (old_version) | 1465 | if (old_version) |
1470 | { | 1466 | { |
1471 | if (!dp.unpackF32(pos_key->mTime, "time")) | 1467 | if (!dp.unpackF32(pos_key.mTime, "time")) |
1472 | { | 1468 | { |
1473 | llwarns << "can't read position key (" << k << ")" << llendl; | 1469 | llwarns << "can't read position key (" << k << ")" << llendl; |
1474 | delete pos_key; | ||
1475 | return FALSE; | 1470 | return FALSE; |
1476 | } | 1471 | } |
1477 | } | 1472 | } |
@@ -1480,18 +1475,17 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1480 | if (!dp.unpackU16(time_short, "time")) | 1475 | if (!dp.unpackU16(time_short, "time")) |
1481 | { | 1476 | { |
1482 | llwarns << "can't read position key (" << k << ")" << llendl; | 1477 | llwarns << "can't read position key (" << k << ")" << llendl; |
1483 | delete pos_key; | ||
1484 | return FALSE; | 1478 | return FALSE; |
1485 | } | 1479 | } |
1486 | 1480 | ||
1487 | pos_key->mTime = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); | 1481 | pos_key.mTime = U16_to_F32(time_short, 0.f, mJointMotionList->mDuration); |
1488 | } | 1482 | } |
1489 | 1483 | ||
1490 | BOOL success = TRUE; | 1484 | BOOL success = TRUE; |
1491 | 1485 | ||
1492 | if (old_version) | 1486 | if (old_version) |
1493 | { | 1487 | { |
1494 | success = dp.unpackVector3(pos_key->mPosition, "pos"); | 1488 | success = dp.unpackVector3(pos_key.mPosition, "pos"); |
1495 | } | 1489 | } |
1496 | else | 1490 | else |
1497 | { | 1491 | { |
@@ -1501,23 +1495,22 @@ BOOL LLKeyframeMotion::deserialize(LLDataPacker& dp) | |||
1501 | success &= dp.unpackU16(y, "pos_y"); | 1495 | success &= dp.unpackU16(y, "pos_y"); |
1502 | success &= dp.unpackU16(z, "pos_z"); | 1496 | success &= dp.unpackU16(z, "pos_z"); |
1503 | 1497 | ||
1504 | pos_key->mPosition.mV[VX] = U16_to_F32(x, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); | 1498 | pos_key.mPosition.mV[VX] = U16_to_F32(x, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); |
1505 | pos_key->mPosition.mV[VY] = U16_to_F32(y, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); | 1499 | pos_key.mPosition.mV[VY] = U16_to_F32(y, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); |
1506 | pos_key->mPosition.mV[VZ] = U16_to_F32(z, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); | 1500 | pos_key.mPosition.mV[VZ] = U16_to_F32(z, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); |
1507 | } | 1501 | } |
1508 | 1502 | ||
1509 | if (!success) | 1503 | if (!success) |
1510 | { | 1504 | { |
1511 | llwarns << "can't read position key (" << k << ")" << llendl; | 1505 | llwarns << "can't read position key (" << k << ")" << llendl; |
1512 | delete pos_key; | ||
1513 | return FALSE; | 1506 | return FALSE; |
1514 | } | 1507 | } |
1515 | 1508 | ||
1516 | pCurve->mKeys[pos_key->mTime] = pos_key; | 1509 | pCurve->mKeys[pos_key.mTime] = pos_key; |
1517 | 1510 | ||
1518 | if (is_pelvis) | 1511 | if (is_pelvis) |
1519 | { | 1512 | { |
1520 | mJointMotionList->mPelvisBBox.addPoint(pos_key->mPosition); | 1513 | mJointMotionList->mPelvisBBox.addPoint(pos_key.mPosition); |
1521 | } | 1514 | } |
1522 | } | 1515 | } |
1523 | 1516 | ||
@@ -1724,14 +1717,14 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const | |||
1724 | success &= dp.packS32(joint_motionp->mPriority, "joint_priority"); | 1717 | success &= dp.packS32(joint_motionp->mPriority, "joint_priority"); |
1725 | success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys"); | 1718 | success &= dp.packS32(joint_motionp->mRotationCurve.mNumKeys, "num_rot_keys"); |
1726 | 1719 | ||
1727 | for (RotationKey* rot_keyp = joint_motionp->mRotationCurve.mKeys.getFirstData(); | 1720 | for (RotationCurve::key_map_t::iterator iter = joint_motionp->mRotationCurve.mKeys.begin(); |
1728 | rot_keyp; | 1721 | iter != joint_motionp->mRotationCurve.mKeys.end(); ++iter) |
1729 | rot_keyp = joint_motionp->mRotationCurve.mKeys.getNextData()) | ||
1730 | { | 1722 | { |
1731 | U16 time_short = F32_to_U16(rot_keyp->mTime, 0.f, mJointMotionList->mDuration); | 1723 | RotationKey& rot_key = iter->second; |
1724 | U16 time_short = F32_to_U16(rot_key.mTime, 0.f, mJointMotionList->mDuration); | ||
1732 | success &= dp.packU16(time_short, "time"); | 1725 | success &= dp.packU16(time_short, "time"); |
1733 | 1726 | ||
1734 | LLVector3 rot_angles = rot_keyp->mRotation.packToVector3(); | 1727 | LLVector3 rot_angles = rot_key.mRotation.packToVector3(); |
1735 | 1728 | ||
1736 | U16 x, y, z; | 1729 | U16 x, y, z; |
1737 | rot_angles.quantize16(-1.f, 1.f, -1.f, 1.f); | 1730 | rot_angles.quantize16(-1.f, 1.f, -1.f, 1.f); |
@@ -1744,18 +1737,18 @@ BOOL LLKeyframeMotion::serialize(LLDataPacker& dp) const | |||
1744 | } | 1737 | } |
1745 | 1738 | ||
1746 | success &= dp.packS32(joint_motionp->mPositionCurve.mNumKeys, "num_pos_keys"); | 1739 | success &= dp.packS32(joint_motionp->mPositionCurve.mNumKeys, "num_pos_keys"); |
1747 | for (PositionKey* pos_keyp = joint_motionp->mPositionCurve.mKeys.getFirstData(); | 1740 | for (PositionCurve::key_map_t::iterator iter = joint_motionp->mPositionCurve.mKeys.begin(); |
1748 | pos_keyp; | 1741 | iter != joint_motionp->mPositionCurve.mKeys.end(); ++iter) |
1749 | pos_keyp = joint_motionp->mPositionCurve.mKeys.getNextData()) | ||
1750 | { | 1742 | { |
1751 | U16 time_short = F32_to_U16(pos_keyp->mTime, 0.f, mJointMotionList->mDuration); | 1743 | PositionKey& pos_key = iter->second; |
1744 | U16 time_short = F32_to_U16(pos_key.mTime, 0.f, mJointMotionList->mDuration); | ||
1752 | success &= dp.packU16(time_short, "time"); | 1745 | success &= dp.packU16(time_short, "time"); |
1753 | 1746 | ||
1754 | U16 x, y, z; | 1747 | U16 x, y, z; |
1755 | pos_keyp->mPosition.quantize16(-LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); | 1748 | pos_key.mPosition.quantize16(-LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET, -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); |
1756 | x = F32_to_U16(pos_keyp->mPosition.mV[VX], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); | 1749 | x = F32_to_U16(pos_key.mPosition.mV[VX], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); |
1757 | y = F32_to_U16(pos_keyp->mPosition.mV[VY], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); | 1750 | y = F32_to_U16(pos_key.mPosition.mV[VY], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); |
1758 | z = F32_to_U16(pos_keyp->mPosition.mV[VZ], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); | 1751 | z = F32_to_U16(pos_key.mPosition.mV[VZ], -LL_MAX_PELVIS_OFFSET, LL_MAX_PELVIS_OFFSET); |
1759 | success &= dp.packU16(x, "pos_x"); | 1752 | success &= dp.packU16(x, "pos_x"); |
1760 | success &= dp.packU16(y, "pos_y"); | 1753 | success &= dp.packU16(y, "pos_y"); |
1761 | success &= dp.packU16(z, "pos_z"); | 1754 | success &= dp.packU16(z, "pos_z"); |
@@ -2030,64 +2023,6 @@ void LLKeyframeMotion::onLoadComplete(LLVFS *vfs, | |||
2030 | } | 2023 | } |
2031 | } | 2024 | } |
2032 | 2025 | ||
2033 | |||
2034 | //----------------------------------------------------------------------------- | ||
2035 | // writeCAL3D() | ||
2036 | //----------------------------------------------------------------------------- | ||
2037 | void LLKeyframeMotion::writeCAL3D(apr_file_t* fp) | ||
2038 | { | ||
2039 | // <ANIMATION VERSION="1000" DURATION="1.03333" NUMTRACKS="58"> | ||
2040 | // <TRACK BONEID="0" NUMKEYFRAMES="31"> | ||
2041 | // <KEYFRAME TIME="0"> | ||
2042 | // <TRANSLATION>0 0 48.8332</TRANSLATION> | ||
2043 | // <ROTATION>0.0512905 0.05657 0.66973 0.738668</ROTATION> | ||
2044 | // </KEYFRAME> | ||
2045 | // </TRACK> | ||
2046 | // </ANIMATION> | ||
2047 | |||
2048 | apr_file_printf(fp, "<ANIMATION VERSION=\"1000\" DURATION=\"%.5f\" NUMTRACKS=\"%d\">\n", getDuration(), mJointMotionList->getNumJointMotions()); | ||
2049 | for (U32 joint_index = 0; joint_index < mJointMotionList->getNumJointMotions(); joint_index++) | ||
2050 | { | ||
2051 | JointMotion* joint_motionp = mJointMotionList->getJointMotion(joint_index); | ||
2052 | LLJoint* animated_joint = mCharacter->getJoint(joint_motionp->mJointName); | ||
2053 | S32 joint_num = animated_joint->mJointNum + 1; | ||
2054 | |||
2055 | apr_file_printf(fp, " <TRACK BONEID=\"%d\" NUMKEYFRAMES=\"%d\">\n", joint_num, joint_motionp->mRotationCurve.mNumKeys ); | ||
2056 | PositionKey* pos_keyp = joint_motionp->mPositionCurve.mKeys.getFirstData(); | ||
2057 | for (RotationKey* rot_keyp = joint_motionp->mRotationCurve.mKeys.getFirstData(); | ||
2058 | rot_keyp; | ||
2059 | rot_keyp = joint_motionp->mRotationCurve.mKeys.getNextData()) | ||
2060 | { | ||
2061 | apr_file_printf(fp, " <KEYFRAME TIME=\"%0.3f\">\n", rot_keyp->mTime); | ||
2062 | LLVector3 nominal_pos = animated_joint->getPosition(); | ||
2063 | if (animated_joint->getParent()) | ||
2064 | { | ||
2065 | nominal_pos.scaleVec(animated_joint->getParent()->getScale()); | ||
2066 | } | ||
2067 | nominal_pos = nominal_pos * 100.f; | ||
2068 | |||
2069 | if (joint_motionp->mUsage & LLJointState::POS && pos_keyp) | ||
2070 | { | ||
2071 | LLVector3 pos_val = pos_keyp->mPosition; | ||
2072 | pos_val = pos_val * 100.f; | ||
2073 | pos_val += nominal_pos; | ||
2074 | apr_file_printf(fp, " <TRANSLATION>%0.4f %0.4f %0.4f</TRANSLATION>\n", pos_val.mV[VX], pos_val.mV[VY], pos_val.mV[VZ]); | ||
2075 | pos_keyp = joint_motionp->mPositionCurve.mKeys.getNextData(); | ||
2076 | } | ||
2077 | else | ||
2078 | { | ||
2079 | apr_file_printf(fp, " <TRANSLATION>%0.4f %0.4f %0.4f</TRANSLATION>\n", nominal_pos.mV[VX], nominal_pos.mV[VY], nominal_pos.mV[VZ]); | ||
2080 | } | ||
2081 | |||
2082 | LLQuaternion rot_val = ~rot_keyp->mRotation; | ||
2083 | apr_file_printf(fp, " <ROTATION>%0.4f %0.4f %0.4f %0.4f</ROTATION>\n", rot_val.mQ[VX], rot_val.mQ[VY], rot_val.mQ[VZ], rot_val.mQ[VW]); | ||
2084 | apr_file_printf(fp, " </KEYFRAME>\n"); | ||
2085 | } | ||
2086 | apr_file_printf(fp, " </TRACK>\n"); | ||
2087 | } | ||
2088 | apr_file_printf(fp, "</ANIMATION>\n"); | ||
2089 | } | ||
2090 | |||
2091 | //-------------------------------------------------------------------- | 2026 | //-------------------------------------------------------------------- |
2092 | // LLKeyframeDataCache::dumpDiagInfo() | 2027 | // LLKeyframeDataCache::dumpDiagInfo() |
2093 | //-------------------------------------------------------------------- | 2028 | //-------------------------------------------------------------------- |