Simple AnimationPlayer now working.

AnimGraphEditor
Martin Felis 2023-03-26 18:53:32 +02:00
parent 80ea25483b
commit a1931185d8
1 changed files with 17 additions and 3 deletions

View File

@ -65,7 +65,7 @@ static struct {
struct {
ozz::animation::Animation* animation = nullptr;
ozz::animation::SamplingJob sampling_job;
ozz::animation::SamplingJob::Context* m_sampling_context = nullptr;
ozz::vector<ozz::math::SoaTransform> local_matrices;
} ozz;
sg_pass_action pass_action;
Camera camera;
@ -690,6 +690,8 @@ int main() {
}
if (state.ozz.animation != nullptr) {
ImGui::SameLine();
ImGui::SliderFloat(
"Time",
&state.time.absolute,
@ -702,8 +704,20 @@ int main() {
ImGui::End();
}
if (state.ozz.animation != nullptr) {
state.ozz.sampling_job.animation = state.ozz.animation;
state.ozz.sampling_job.ratio =
state.time.absolute / state.ozz.animation->duration();
state.ozz.sampling_job.context = &skinned_mesh.m_sampling_context;
state.ozz.sampling_job.output = ozz::make_span(skinned_mesh.m_local_matrices);
if(!state.ozz.sampling_job.Run()) {
ozz::log::Err() << "Error sampling animation." << std::endl;
}
// TODO: add AnimGraph to calculate pose
// skinned_mesh.CalcModelMatrices();
skinned_mesh.CalcModelMatrices();
}
sgl_defaults();
sgl_matrix_mode_projection();