2014-06-02 05:58:41 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2017-01-03 15:18:06 +01:00
|
|
|
#include <data/Clump.hpp>
|
2016-09-09 22:13:22 +02:00
|
|
|
#include <engine/Animator.hpp>
|
2014-06-02 05:58:41 +02:00
|
|
|
#include <glm/gtx/string_cast.hpp>
|
|
|
|
#include "test_globals.hpp"
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(AnimationTests)
|
|
|
|
|
2016-06-16 22:11:55 +02:00
|
|
|
#if RW_TEST_WITH_DATA
|
2016-09-09 22:13:22 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_matrix) {
|
|
|
|
{
|
|
|
|
Animation animation;
|
|
|
|
|
|
|
|
/** Models are currently needed to relate animation bones <=> model
|
|
|
|
* frame #s. */
|
2016-09-11 22:57:55 +02:00
|
|
|
auto test_model = Global::get().d->loadClump("player.dff");
|
2016-09-09 22:13:22 +02:00
|
|
|
|
2017-01-08 04:28:33 +01:00
|
|
|
Animator animator(test_model);
|
2016-09-09 22:13:22 +02:00
|
|
|
|
|
|
|
animation.duration = 1.f;
|
|
|
|
animation.bones["player"] = new AnimationBone{
|
|
|
|
"player",
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
1.0f,
|
|
|
|
AnimationBone::RT0,
|
|
|
|
{
|
|
|
|
{glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0},
|
|
|
|
{glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1},
|
|
|
|
}};
|
|
|
|
|
|
|
|
animator.playAnimation(0, &animation, 1.f, false);
|
|
|
|
|
|
|
|
animator.tick(0.0f);
|
|
|
|
|
2017-01-08 04:28:33 +01:00
|
|
|
const auto& root = test_model->findFrame("player");
|
|
|
|
|
|
|
|
BOOST_CHECK(glm::vec3(root->getTransform()[3]) ==
|
2016-09-09 22:13:22 +02:00
|
|
|
glm::vec3(0.f, 0.f, 0.f));
|
|
|
|
|
|
|
|
animator.tick(1.0f);
|
|
|
|
|
2017-01-08 04:28:33 +01:00
|
|
|
BOOST_CHECK(glm::vec3(root->getTransform()[3]) ==
|
2016-09-09 22:13:22 +02:00
|
|
|
glm::vec3(0.f, 1.f, 0.f));
|
|
|
|
}
|
2014-06-02 05:58:41 +02:00
|
|
|
}
|
2016-06-16 22:11:55 +02:00
|
|
|
#endif
|
2014-06-02 05:58:41 +02:00
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|