2014-06-02 05:58:41 +02:00
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <engine/Animator.hpp>
|
2014-12-11 18:48:47 +01:00
|
|
|
#include <data/Skeleton.hpp>
|
2016-04-15 02:06:10 +02:00
|
|
|
#include <data/Model.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
|
2014-06-02 05:58:41 +02:00
|
|
|
BOOST_AUTO_TEST_CASE(test_matrix)
|
|
|
|
{
|
|
|
|
{
|
2014-12-11 18:48:47 +01:00
|
|
|
Skeleton skeleton;
|
|
|
|
Animation animation;
|
|
|
|
|
|
|
|
/** Models are currently needed to relate animation bones <=> model frame #s. */
|
2015-04-18 02:11:17 +02:00
|
|
|
Global::get().e->data->loadDFF("player.dff");
|
|
|
|
ModelRef& test_model = Global::get().e->data->models["player"];
|
2014-12-11 18:48:47 +01:00
|
|
|
|
2015-03-06 05:38:22 +01:00
|
|
|
Animator animator(test_model->resource, &skeleton);
|
2014-06-02 05:58:41 +02:00
|
|
|
|
|
|
|
animation.duration = 1.f;
|
|
|
|
animation.bones["player"] = new AnimationBone{
|
|
|
|
"player",
|
|
|
|
0, 0, 1.0f,
|
|
|
|
AnimationBone::RT0,
|
|
|
|
{
|
|
|
|
{
|
2014-12-12 01:36:45 +01:00
|
|
|
glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0
|
2014-06-02 05:58:41 +02:00
|
|
|
},
|
|
|
|
{
|
2014-12-12 01:36:45 +01:00
|
|
|
glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1
|
2014-06-02 05:58:41 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
2014-12-11 18:48:47 +01:00
|
|
|
|
2016-05-02 18:38:04 +02:00
|
|
|
animator.playAnimation(0, &animation, 1.f, false);
|
2014-12-11 18:48:47 +01:00
|
|
|
|
|
|
|
animator.tick(0.0f);
|
|
|
|
|
|
|
|
BOOST_CHECK( skeleton.getData(0).a.translation == glm::vec3(0.f, 0.f, 0.f) );
|
|
|
|
BOOST_CHECK( skeleton.getData(0).b.translation == glm::vec3(0.f, 0.f, 0.f) );
|
|
|
|
|
|
|
|
animator.tick(1.0f);
|
|
|
|
|
|
|
|
BOOST_CHECK( skeleton.getData(0).a.translation == glm::vec3(0.f, 1.f, 0.f) );
|
|
|
|
BOOST_CHECK( skeleton.getData(0).b.translation == glm::vec3(0.f, 0.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()
|
|
|
|
|