5#include "flutter/testing/testing.h"
10#include "impeller/scene/importer/scene_flatbuffers.h"
17TEST(ImporterTest, CanParseUnskinnedGLTF) {
24 ASSERT_EQ(scene.children.size(), 1u);
25 auto& node = scene.nodes[scene.children[0]];
30 ASSERT_EQ(node->mesh_primitives.size(), 1u);
31 auto&
mesh = *node->mesh_primitives[0];
32 ASSERT_EQ(
mesh.indices->count, 918u);
34 uint16_t first_index =
35 *
reinterpret_cast<uint16_t*
>(
mesh.indices->data.data());
36 ASSERT_EQ(first_index, 45u);
38 ASSERT_EQ(
mesh.vertices.type, fb::VertexBuffer::UnskinnedVertexBuffer);
39 auto& vertices =
mesh.vertices.AsUnskinnedVertexBuffer()->vertices;
40 ASSERT_EQ(vertices.size(), 260u);
41 auto& vertex = vertices[0];
59TEST(ImporterTest, CanParseSkinnedGLTF) {
65 ASSERT_EQ(scene.children.size(), 1u);
66 auto& node = scene.nodes[scene.children[0]];
71 ASSERT_EQ(node->mesh_primitives.size(), 0u);
72 ASSERT_EQ(node->children.size(), 2u);
76 auto& skinned_node = scene.nodes[node->children[0]];
77 ASSERT_NE(skinned_node->skin,
nullptr);
79 ASSERT_EQ(skinned_node->mesh_primitives.size(), 2u);
80 auto& bottom_triangle = *skinned_node->mesh_primitives[0];
81 ASSERT_EQ(bottom_triangle.indices->count, 3u);
83 ASSERT_EQ(bottom_triangle.vertices.type,
84 fb::VertexBuffer::SkinnedVertexBuffer);
85 auto& vertices = bottom_triangle.vertices.AsSkinnedVertexBuffer()->vertices;
86 ASSERT_EQ(vertices.size(), 3u);
87 auto& vertex = vertices[0];
110 ASSERT_EQ(scene.animations.size(), 2u);
111 ASSERT_EQ(scene.animations[0]->name,
"Idle");
112 ASSERT_EQ(scene.animations[1]->name,
"Metronome");
113 ASSERT_EQ(scene.animations[1]->channels.size(), 6u);
114 auto& channel = scene.animations[1]->channels[3];
115 ASSERT_EQ(channel->keyframes.type, fb::Keyframes::RotationKeyframes);
116 auto* keyframes = channel->keyframes.AsRotationKeyframes();
117 ASSERT_EQ(keyframes->values.size(), 40u);
119 Vector4(0.653281, -0.270598, 0.270598, 0.653281));
121 Vector4(0.700151, 0.0989373, -0.0989373, 0.700151));
#define ASSERT_VECTOR4_NEAR(a, b)
#define ASSERT_MATRIX_NEAR(a, b)
#define ASSERT_COLOR_NEAR(a, b)
#define ASSERT_POINT_NEAR(a, b)
#define ASSERT_VECTOR3_NEAR(a, b)
SK_API sk_sp< SkShader > Color(SkColor)
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
TEST(ImporterTest, CanParseUnskinnedGLTF)
Matrix ToMatrix(const std::vector< double > &m)
Color ToColor(const fb::Color &c)
bool ParseGLTF(const fml::Mapping &source_mapping, fb::SceneT &out_scene)
Vector3 ToVector3(const fb::Vec3 &v)
Vector4 ToVector4(const fb::Vec4 &v)
Vector2 ToVector2(const fb::Vec2 &v)
SK_API sk_sp< PrecompileColorFilter > Matrix()
A 4x4 matrix using column-major storage.