74 auto allocator = GetContext()->GetResourceAllocator();
78 ASSERT_NE(mapping,
nullptr);
80 flatbuffers::Verifier verifier(mapping->GetMapping(), mapping->GetSize());
81 ASSERT_TRUE(fb::VerifySceneBuffer(verifier));
83 std::shared_ptr<Node> gltf_scene =
85 ASSERT_NE(gltf_scene,
nullptr);
86 ASSERT_EQ(gltf_scene->GetChildren().size(), 1u);
87 ASSERT_EQ(gltf_scene->GetChildren()[0]->GetMesh().GetPrimitives().size(), 1u);
89 auto scene_context = std::make_shared<SceneContext>(GetContext());
90 auto scene =
Scene(scene_context);
91 scene.GetRoot().AddChild(std::move(gltf_scene));
95 Quaternion rotation({0, 1, 0}, -GetSecondsElapsed() * 0.5);
96 Vector3 start_position(-1, -1.5, -5);
101 rotation * start_position)
106 scene.Render(render_target, camera);
115 GTEST_SKIP_(
"Temporarily disabled.");
117 auto allocator = GetContext()->GetResourceAllocator();
121 ASSERT_NE(mapping,
nullptr);
123 std::shared_ptr<Node> gltf_scene =
125 ASSERT_NE(gltf_scene,
nullptr);
127 auto animation = gltf_scene->FindAnimationByName(
"Metronome");
128 ASSERT_NE(animation,
nullptr);
130 AnimationClip* metronome_clip = gltf_scene->AddAnimation(animation);
131 ASSERT_NE(metronome_clip,
nullptr);
133 metronome_clip->
Play();
135 auto scene_context = std::make_shared<SceneContext>(GetContext());
136 auto scene =
Scene(scene_context);
137 scene.GetRoot().AddChild(std::move(gltf_scene));
140 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
142 static Scalar playback_time_scale = 1;
144 static bool loop =
true;
146 ImGui::SliderFloat(
"Playback time scale", &playback_time_scale, -5, 5);
147 ImGui::SliderFloat(
"Weight", &weight, -2, 2);
148 ImGui::Checkbox(
"Loop", &loop);
149 if (ImGui::Button(
"Play")) {
150 metronome_clip->
Play();
152 if (ImGui::Button(
"Pause")) {
153 metronome_clip->
Pause();
155 if (ImGui::Button(
"Stop")) {
156 metronome_clip->
Stop();
169 static ImVec2 mouse_pos_prev = ImGui::GetMousePos();
170 ImVec2 mouse_pos = ImGui::GetMousePos();
172 Vector2(mouse_pos.x - mouse_pos_prev.x, mouse_pos.y - mouse_pos_prev.y);
174 static Vector3 position(0, 1, -5);
175 static Vector3 cam_position = position;
177 Vector3(ImGui::IsKeyDown(ImGuiKey_D) - ImGui::IsKeyDown(ImGuiKey_A),
178 ImGui::IsKeyDown(ImGuiKey_E) - ImGui::IsKeyDown(ImGuiKey_Q),
179 ImGui::IsKeyDown(ImGuiKey_W) - ImGui::IsKeyDown(ImGuiKey_S));
180 position += strafe * 0.5;
181 cam_position = cam_position.
Lerp(position, 0.02);
188 cam_position +
Vector3(0, 0, 1),
191 scene.Render(render_target, camera);
199 auto allocator = GetContext()->GetResourceAllocator();
209 ASSERT_NE(mapping,
nullptr);
211 std::shared_ptr<Node> gltf_scene =
213 ASSERT_NE(gltf_scene,
nullptr);
215 auto walk_anim = gltf_scene->FindAnimationByName(
"Walk");
216 ASSERT_NE(walk_anim,
nullptr);
218 AnimationClip* walk_clip = gltf_scene->AddAnimation(walk_anim);
219 ASSERT_NE(walk_clip,
nullptr);
223 auto run_anim = gltf_scene->FindAnimationByName(
"Run");
224 ASSERT_NE(walk_anim,
nullptr);
226 AnimationClip* run_clip = gltf_scene->AddAnimation(run_anim);
227 ASSERT_NE(run_clip,
nullptr);
231 auto scene_context = std::make_shared<SceneContext>(GetContext());
232 auto scene =
Scene(scene_context);
233 scene.GetRoot().AddChild(std::move(gltf_scene));
236 ImGui::Begin(
"Controls",
nullptr, ImGuiWindowFlags_AlwaysAutoResize);
238 static Scalar playback_time_scale = 1;
241 static bool loop =
true;
243 ImGui::SliderFloat(
"Playback time scale", &playback_time_scale, -5, 5);
244 ImGui::SliderFloat(
"Walk weight", &walk, 0, 1);
245 ImGui::SliderFloat(
"Run weight", &
run, 0, 1);
246 ImGui::Checkbox(
"Loop", &loop);
247 if (ImGui::Button(
"Play")) {
251 if (ImGui::Button(
"Pause")) {
255 if (ImGui::Button(
"Stop")) {
274 static ImVec2 mouse_pos_prev = ImGui::GetMousePos();
275 ImVec2 mouse_pos = ImGui::GetMousePos();
277 Vector2(mouse_pos.x - mouse_pos_prev.x, mouse_pos.y - mouse_pos_prev.y);
279 static Vector3 position(0, 1, -5);
280 static Vector3 cam_position = position;
282 Vector3(ImGui::IsKeyDown(ImGuiKey_D) - ImGui::IsKeyDown(ImGuiKey_A),
283 ImGui::IsKeyDown(ImGuiKey_E) - ImGui::IsKeyDown(ImGuiKey_Q),
284 ImGui::IsKeyDown(ImGuiKey_W) - ImGui::IsKeyDown(ImGuiKey_S));
285 position += strafe * 0.5;
286 cam_position = cam_position.
Lerp(position, 0.02);
293 cam_position +
Vector3(0, 0, 1),
296 scene.Render(render_target, camera);