2
0

LWOAnimation.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2020, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file LWOAnimation.cpp
  34. * @brief LWOAnimationResolver utility class
  35. *
  36. * It's a very generic implementation of LightWave's system of
  37. * component-wise-animated stuff. The one and only fully free
  38. * implementation of LightWave envelopes of which I know.
  39. */
  40. #if (!defined ASSIMP_BUILD_NO_LWO_IMPORTER) && (!defined ASSIMP_BUILD_NO_LWS_IMPORTER)
  41. #include <functional>
  42. // internal headers
  43. #include "LWOFileData.h"
  44. #include <assimp/anim.h>
  45. using namespace Assimp;
  46. using namespace Assimp::LWO;
  47. // ------------------------------------------------------------------------------------------------
  48. // Construct an animation resolver from a given list of envelopes
  49. AnimResolver::AnimResolver(std::list<Envelope> &_envelopes, double tick) :
  50. envelopes(_envelopes),
  51. sample_rate(0.),
  52. envl_x(),
  53. envl_y(),
  54. envl_z(),
  55. end_x(),
  56. end_y(),
  57. end_z(),
  58. flags(),
  59. sample_delta() {
  60. trans_x = trans_y = trans_z = nullptr;
  61. rotat_x = rotat_y = rotat_z = nullptr;
  62. scale_x = scale_y = scale_z = nullptr;
  63. first = last = 150392.;
  64. // find transformation envelopes
  65. for (std::list<LWO::Envelope>::iterator it = envelopes.begin(); it != envelopes.end(); ++it) {
  66. (*it).old_first = 0;
  67. (*it).old_last = (*it).keys.size() - 1;
  68. if ((*it).keys.empty()) continue;
  69. switch ((*it).type) {
  70. // translation
  71. case LWO::EnvelopeType_Position_X:
  72. trans_x = &*it;
  73. break;
  74. case LWO::EnvelopeType_Position_Y:
  75. trans_y = &*it;
  76. break;
  77. case LWO::EnvelopeType_Position_Z:
  78. trans_z = &*it;
  79. break;
  80. // rotation
  81. case LWO::EnvelopeType_Rotation_Heading:
  82. rotat_x = &*it;
  83. break;
  84. case LWO::EnvelopeType_Rotation_Pitch:
  85. rotat_y = &*it;
  86. break;
  87. case LWO::EnvelopeType_Rotation_Bank:
  88. rotat_z = &*it;
  89. break;
  90. // scaling
  91. case LWO::EnvelopeType_Scaling_X:
  92. scale_x = &*it;
  93. break;
  94. case LWO::EnvelopeType_Scaling_Y:
  95. scale_y = &*it;
  96. break;
  97. case LWO::EnvelopeType_Scaling_Z:
  98. scale_z = &*it;
  99. break;
  100. default:
  101. continue;
  102. };
  103. // convert from seconds to ticks
  104. for (std::vector<LWO::Key>::iterator d = (*it).keys.begin(); d != (*it).keys.end(); ++d)
  105. (*d).time *= tick;
  106. // set default animation range (minimum and maximum time value for which we have a keyframe)
  107. first = std::min(first, (*it).keys.front().time);
  108. last = std::max(last, (*it).keys.back().time);
  109. }
  110. // deferred setup of animation range to increase performance.
  111. // typically the application will want to specify its own.
  112. need_to_setup = true;
  113. }
  114. // ------------------------------------------------------------------------------------------------
  115. // Reset all envelopes to their original contents
  116. void AnimResolver::ClearAnimRangeSetup() {
  117. for (std::list<LWO::Envelope>::iterator it = envelopes.begin(); it != envelopes.end(); ++it) {
  118. (*it).keys.erase((*it).keys.begin(), (*it).keys.begin() + (*it).old_first);
  119. (*it).keys.erase((*it).keys.begin() + (*it).old_last + 1, (*it).keys.end());
  120. }
  121. }
  122. // ------------------------------------------------------------------------------------------------
  123. // Insert additional keys to match LWO's pre& post behaviors.
  124. void AnimResolver::UpdateAnimRangeSetup() {
  125. // XXX doesn't work yet (hangs if more than one envelope channels needs to be interpolated)
  126. for (std::list<LWO::Envelope>::iterator it = envelopes.begin(); it != envelopes.end(); ++it) {
  127. if ((*it).keys.empty()) continue;
  128. const double my_first = (*it).keys.front().time;
  129. const double my_last = (*it).keys.back().time;
  130. const double delta = my_last - my_first;
  131. const size_t old_size = (*it).keys.size();
  132. const float value_delta = (*it).keys.back().value - (*it).keys.front().value;
  133. // NOTE: We won't handle reset, linear and constant here.
  134. // See DoInterpolation() for their implementation.
  135. // process pre behavior
  136. switch ((*it).pre) {
  137. case LWO::PrePostBehaviour_OffsetRepeat:
  138. case LWO::PrePostBehaviour_Repeat:
  139. case LWO::PrePostBehaviour_Oscillate: {
  140. const double start_time = delta - std::fmod(my_first - first, delta);
  141. std::vector<LWO::Key>::iterator n = std::find_if((*it).keys.begin(), (*it).keys.end(),
  142. [start_time](double t) { return start_time > t; }),
  143. m;
  144. size_t ofs = 0;
  145. if (n != (*it).keys.end()) {
  146. // copy from here - don't use iterators, insert() would invalidate them
  147. ofs = (*it).keys.end() - n;
  148. (*it).keys.insert((*it).keys.begin(), ofs, LWO::Key());
  149. std::copy((*it).keys.end() - ofs, (*it).keys.end(), (*it).keys.begin());
  150. }
  151. // do full copies. again, no iterators
  152. const unsigned int num = (unsigned int)((my_first - first) / delta);
  153. (*it).keys.resize((*it).keys.size() + num * old_size);
  154. n = (*it).keys.begin() + ofs;
  155. bool reverse = false;
  156. for (unsigned int i = 0; i < num; ++i) {
  157. m = n + old_size * (i + 1);
  158. std::copy(n, n + old_size, m);
  159. const bool res = ((*it).pre == LWO::PrePostBehaviour_Oscillate);
  160. reverse = !reverse;
  161. if (res && reverse) {
  162. std::reverse(m, m + old_size - 1);
  163. }
  164. }
  165. // update time values
  166. n = (*it).keys.end() - (old_size + 1);
  167. double cur_minus = delta;
  168. unsigned int tt = 1;
  169. for (const double tmp = delta * (num + 1); cur_minus <= tmp; cur_minus += delta, ++tt) {
  170. m = (delta == tmp ? (*it).keys.begin() : n - (old_size + 1));
  171. for (; m != n; --n) {
  172. (*n).time -= cur_minus;
  173. // offset repeat? add delta offset to key value
  174. if ((*it).pre == LWO::PrePostBehaviour_OffsetRepeat) {
  175. (*n).value += tt * value_delta;
  176. }
  177. }
  178. }
  179. break;
  180. }
  181. default:
  182. // silence compiler warning
  183. break;
  184. }
  185. // process post behavior
  186. switch ((*it).post) {
  187. case LWO::PrePostBehaviour_OffsetRepeat:
  188. case LWO::PrePostBehaviour_Repeat:
  189. case LWO::PrePostBehaviour_Oscillate:
  190. break;
  191. default:
  192. // silence compiler warning
  193. break;
  194. }
  195. }
  196. }
  197. // ------------------------------------------------------------------------------------------------
  198. // Extract bind pose matrix
  199. void AnimResolver::ExtractBindPose(aiMatrix4x4 &out) {
  200. // If we have no envelopes, return identity
  201. if (envelopes.empty()) {
  202. out = aiMatrix4x4();
  203. return;
  204. }
  205. aiVector3D angles, scaling(1.f, 1.f, 1.f), translation;
  206. if (trans_x) translation.x = trans_x->keys[0].value;
  207. if (trans_y) translation.y = trans_y->keys[0].value;
  208. if (trans_z) translation.z = trans_z->keys[0].value;
  209. if (rotat_x) angles.x = rotat_x->keys[0].value;
  210. if (rotat_y) angles.y = rotat_y->keys[0].value;
  211. if (rotat_z) angles.z = rotat_z->keys[0].value;
  212. if (scale_x) scaling.x = scale_x->keys[0].value;
  213. if (scale_y) scaling.y = scale_y->keys[0].value;
  214. if (scale_z) scaling.z = scale_z->keys[0].value;
  215. // build the final matrix
  216. aiMatrix4x4 s, rx, ry, rz, t;
  217. aiMatrix4x4::RotationZ(angles.z, rz);
  218. aiMatrix4x4::RotationX(angles.y, rx);
  219. aiMatrix4x4::RotationY(angles.x, ry);
  220. aiMatrix4x4::Translation(translation, t);
  221. aiMatrix4x4::Scaling(scaling, s);
  222. out = t * ry * rx * rz * s;
  223. }
  224. // ------------------------------------------------------------------------------------------------
  225. // Do a single interpolation on a channel
  226. void AnimResolver::DoInterpolation(std::vector<LWO::Key>::const_iterator cur,
  227. LWO::Envelope *envl, double time, float &fill) {
  228. if (envl->keys.size() == 1) {
  229. fill = envl->keys[0].value;
  230. return;
  231. }
  232. // check whether we're at the beginning of the animation track
  233. if (cur == envl->keys.begin()) {
  234. // ok ... this depends on pre behaviour now
  235. // we don't need to handle repeat&offset repeat&oszillate here, see UpdateAnimRangeSetup()
  236. switch (envl->pre) {
  237. case LWO::PrePostBehaviour_Linear:
  238. DoInterpolation2(cur, cur + 1, time, fill);
  239. return;
  240. case LWO::PrePostBehaviour_Reset:
  241. fill = 0.f;
  242. return;
  243. default: //case LWO::PrePostBehaviour_Constant:
  244. fill = (*cur).value;
  245. return;
  246. }
  247. }
  248. // check whether we're at the end of the animation track
  249. else if (cur == envl->keys.end() - 1 && time > envl->keys.rbegin()->time) {
  250. // ok ... this depends on post behaviour now
  251. switch (envl->post) {
  252. case LWO::PrePostBehaviour_Linear:
  253. DoInterpolation2(cur, cur - 1, time, fill);
  254. return;
  255. case LWO::PrePostBehaviour_Reset:
  256. fill = 0.f;
  257. return;
  258. default: //case LWO::PrePostBehaviour_Constant:
  259. fill = (*cur).value;
  260. return;
  261. }
  262. }
  263. // Otherwise do a simple interpolation
  264. DoInterpolation2(cur - 1, cur, time, fill);
  265. }
  266. // ------------------------------------------------------------------------------------------------
  267. // Almost the same, except we won't handle pre/post conditions here
  268. void AnimResolver::DoInterpolation2(std::vector<LWO::Key>::const_iterator beg,
  269. std::vector<LWO::Key>::const_iterator end, double time, float &fill) {
  270. switch ((*end).inter) {
  271. case LWO::IT_STEP:
  272. // no interpolation at all - take the value of the last key
  273. fill = (*beg).value;
  274. return;
  275. default:
  276. // silence compiler warning
  277. break;
  278. }
  279. // linear interpolation - default
  280. double duration = (*end).time - (*beg).time;
  281. if (duration > 0.0) {
  282. fill = (*beg).value + ((*end).value - (*beg).value) * (float)(((time - (*beg).time) / duration));
  283. } else {
  284. fill = (*beg).value;
  285. }
  286. }
  287. // ------------------------------------------------------------------------------------------------
  288. // Subsample animation track by given key values
  289. void AnimResolver::SubsampleAnimTrack(std::vector<aiVectorKey> & /*out*/,
  290. double /*time*/, double /*sample_delta*/) {
  291. //ai_assert(out.empty() && sample_delta);
  292. //const double time_start = out.back().mTime;
  293. // for ()
  294. }
  295. // ------------------------------------------------------------------------------------------------
  296. // Track interpolation
  297. void AnimResolver::InterpolateTrack(std::vector<aiVectorKey> &out, aiVectorKey &fill, double time) {
  298. // subsample animation track?
  299. if (flags & AI_LWO_ANIM_FLAG_SAMPLE_ANIMS) {
  300. SubsampleAnimTrack(out, time, sample_delta);
  301. }
  302. fill.mTime = time;
  303. // get x
  304. if ((*cur_x).time == time) {
  305. fill.mValue.x = (*cur_x).value;
  306. if (cur_x != envl_x->keys.end() - 1) /* increment x */
  307. ++cur_x;
  308. else
  309. end_x = true;
  310. } else
  311. DoInterpolation(cur_x, envl_x, time, (float &)fill.mValue.x);
  312. // get y
  313. if ((*cur_y).time == time) {
  314. fill.mValue.y = (*cur_y).value;
  315. if (cur_y != envl_y->keys.end() - 1) /* increment y */
  316. ++cur_y;
  317. else
  318. end_y = true;
  319. } else
  320. DoInterpolation(cur_y, envl_y, time, (float &)fill.mValue.y);
  321. // get z
  322. if ((*cur_z).time == time) {
  323. fill.mValue.z = (*cur_z).value;
  324. if (cur_z != envl_z->keys.end() - 1) /* increment z */
  325. ++cur_z;
  326. else
  327. end_x = true;
  328. } else
  329. DoInterpolation(cur_z, envl_z, time, (float &)fill.mValue.z);
  330. }
  331. // ------------------------------------------------------------------------------------------------
  332. // Build linearly subsampled keys from three single envelopes, one for each component (x,y,z)
  333. void AnimResolver::GetKeys(std::vector<aiVectorKey> &out,
  334. LWO::Envelope *_envl_x,
  335. LWO::Envelope *_envl_y,
  336. LWO::Envelope *_envl_z,
  337. unsigned int _flags) {
  338. envl_x = _envl_x;
  339. envl_y = _envl_y;
  340. envl_z = _envl_z;
  341. flags = _flags;
  342. // generate default channels if none are given
  343. LWO::Envelope def_x, def_y, def_z;
  344. LWO::Key key_dummy;
  345. key_dummy.time = 0.f;
  346. if ((envl_x && envl_x->type == LWO::EnvelopeType_Scaling_X) ||
  347. (envl_y && envl_y->type == LWO::EnvelopeType_Scaling_Y) ||
  348. (envl_z && envl_z->type == LWO::EnvelopeType_Scaling_Z)) {
  349. key_dummy.value = 1.f;
  350. } else
  351. key_dummy.value = 0.f;
  352. if (!envl_x) {
  353. envl_x = &def_x;
  354. envl_x->keys.push_back(key_dummy);
  355. }
  356. if (!envl_y) {
  357. envl_y = &def_y;
  358. envl_y->keys.push_back(key_dummy);
  359. }
  360. if (!envl_z) {
  361. envl_z = &def_z;
  362. envl_z->keys.push_back(key_dummy);
  363. }
  364. // guess how many keys we'll get
  365. size_t reserve;
  366. double sr = 1.;
  367. if (flags & AI_LWO_ANIM_FLAG_SAMPLE_ANIMS) {
  368. if (!sample_rate)
  369. sr = 100.f;
  370. else
  371. sr = sample_rate;
  372. sample_delta = 1.f / sr;
  373. reserve = (size_t)(
  374. std::max(envl_x->keys.rbegin()->time,
  375. std::max(envl_y->keys.rbegin()->time, envl_z->keys.rbegin()->time)) *
  376. sr);
  377. } else
  378. reserve = std::max(envl_x->keys.size(), std::max(envl_x->keys.size(), envl_z->keys.size()));
  379. out.reserve(reserve + (reserve >> 1));
  380. // Iterate through all three arrays at once - it's tricky, but
  381. // rather interesting to implement.
  382. cur_x = envl_x->keys.begin();
  383. cur_y = envl_y->keys.begin();
  384. cur_z = envl_z->keys.begin();
  385. end_x = end_y = end_z = false;
  386. while (1) {
  387. aiVectorKey fill;
  388. if ((*cur_x).time == (*cur_y).time && (*cur_x).time == (*cur_z).time) {
  389. // we have a keyframe for all of them defined .. this means
  390. // we don't need to interpolate here.
  391. fill.mTime = (*cur_x).time;
  392. fill.mValue.x = (*cur_x).value;
  393. fill.mValue.y = (*cur_y).value;
  394. fill.mValue.z = (*cur_z).value;
  395. // subsample animation track
  396. if (flags & AI_LWO_ANIM_FLAG_SAMPLE_ANIMS) {
  397. //SubsampleAnimTrack(out,cur_x, cur_y, cur_z, d, sample_delta);
  398. }
  399. }
  400. // Find key with lowest time value
  401. else if ((*cur_x).time <= (*cur_y).time && !end_x) {
  402. if ((*cur_z).time <= (*cur_x).time && !end_z) {
  403. InterpolateTrack(out, fill, (*cur_z).time);
  404. } else {
  405. InterpolateTrack(out, fill, (*cur_x).time);
  406. }
  407. } else if ((*cur_z).time <= (*cur_y).time && !end_y) {
  408. InterpolateTrack(out, fill, (*cur_y).time);
  409. } else if (!end_y) {
  410. // welcome on the server, y
  411. InterpolateTrack(out, fill, (*cur_y).time);
  412. } else {
  413. // we have reached the end of at least 2 channels,
  414. // only one is remaining. Extrapolate the 2.
  415. if (end_y) {
  416. InterpolateTrack(out, fill, (end_x ? (*cur_z) : (*cur_x)).time);
  417. } else if (end_x) {
  418. InterpolateTrack(out, fill, (end_z ? (*cur_y) : (*cur_z)).time);
  419. } else { // if (end_z)
  420. InterpolateTrack(out, fill, (end_y ? (*cur_x) : (*cur_y)).time);
  421. }
  422. }
  423. double lasttime = fill.mTime;
  424. out.push_back(fill);
  425. if (lasttime >= (*cur_x).time) {
  426. if (cur_x != envl_x->keys.end() - 1)
  427. ++cur_x;
  428. else
  429. end_x = true;
  430. }
  431. if (lasttime >= (*cur_y).time) {
  432. if (cur_y != envl_y->keys.end() - 1)
  433. ++cur_y;
  434. else
  435. end_y = true;
  436. }
  437. if (lasttime >= (*cur_z).time) {
  438. if (cur_z != envl_z->keys.end() - 1)
  439. ++cur_z;
  440. else
  441. end_z = true;
  442. }
  443. if (end_x && end_y && end_z) /* finished? */
  444. break;
  445. }
  446. if (flags & AI_LWO_ANIM_FLAG_START_AT_ZERO) {
  447. for (std::vector<aiVectorKey>::iterator it = out.begin(); it != out.end(); ++it)
  448. (*it).mTime -= first;
  449. }
  450. }
  451. // ------------------------------------------------------------------------------------------------
  452. // Extract animation channel
  453. void AnimResolver::ExtractAnimChannel(aiNodeAnim **out, unsigned int /*= 0*/) {
  454. *out = nullptr;
  455. //FIXME: crashes if more than one component is animated at different timings, to be resolved.
  456. // If we have no envelopes, return nullptr
  457. if (envelopes.empty()) {
  458. return;
  459. }
  460. // We won't spawn an animation channel if we don't have at least one envelope with more than one keyframe defined.
  461. const bool trans = ((trans_x && trans_x->keys.size() > 1) || (trans_y && trans_y->keys.size() > 1) || (trans_z && trans_z->keys.size() > 1));
  462. const bool rotat = ((rotat_x && rotat_x->keys.size() > 1) || (rotat_y && rotat_y->keys.size() > 1) || (rotat_z && rotat_z->keys.size() > 1));
  463. const bool scale = ((scale_x && scale_x->keys.size() > 1) || (scale_y && scale_y->keys.size() > 1) || (scale_z && scale_z->keys.size() > 1));
  464. if (!trans && !rotat && !scale)
  465. return;
  466. // Allocate the output animation
  467. aiNodeAnim *anim = *out = new aiNodeAnim();
  468. // Setup default animation setup if necessary
  469. if (need_to_setup) {
  470. UpdateAnimRangeSetup();
  471. need_to_setup = false;
  472. }
  473. // copy translation keys
  474. if (trans) {
  475. std::vector<aiVectorKey> keys;
  476. GetKeys(keys, trans_x, trans_y, trans_z, flags);
  477. anim->mPositionKeys = new aiVectorKey[anim->mNumPositionKeys = static_cast<unsigned int>(keys.size())];
  478. std::copy(keys.begin(), keys.end(), anim->mPositionKeys);
  479. }
  480. // copy rotation keys
  481. if (rotat) {
  482. std::vector<aiVectorKey> keys;
  483. GetKeys(keys, rotat_x, rotat_y, rotat_z, flags);
  484. anim->mRotationKeys = new aiQuatKey[anim->mNumRotationKeys = static_cast<unsigned int>(keys.size())];
  485. // convert heading, pitch, bank to quaternion
  486. // mValue.x=Heading=Rot(Y), mValue.y=Pitch=Rot(X), mValue.z=Bank=Rot(Z)
  487. // Lightwave's rotation order is ZXY
  488. aiVector3D X(1.0, 0.0, 0.0);
  489. aiVector3D Y(0.0, 1.0, 0.0);
  490. aiVector3D Z(0.0, 0.0, 1.0);
  491. for (unsigned int i = 0; i < anim->mNumRotationKeys; ++i) {
  492. aiQuatKey &qk = anim->mRotationKeys[i];
  493. qk.mTime = keys[i].mTime;
  494. qk.mValue = aiQuaternion(Y, keys[i].mValue.x) * aiQuaternion(X, keys[i].mValue.y) * aiQuaternion(Z, keys[i].mValue.z);
  495. }
  496. }
  497. // copy scaling keys
  498. if (scale) {
  499. std::vector<aiVectorKey> keys;
  500. GetKeys(keys, scale_x, scale_y, scale_z, flags);
  501. anim->mScalingKeys = new aiVectorKey[anim->mNumScalingKeys = static_cast<unsigned int>(keys.size())];
  502. std::copy(keys.begin(), keys.end(), anim->mScalingKeys);
  503. }
  504. }
  505. #endif // no lwo or no lws