LWOAnimation.cpp 21 KB

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