Simple AnimationPlayer now working.
parent
80ea25483b
commit
a1931185d8
18
src/main.cc
18
src/main.cc
|
@ -65,7 +65,7 @@ static struct {
|
||||||
struct {
|
struct {
|
||||||
ozz::animation::Animation* animation = nullptr;
|
ozz::animation::Animation* animation = nullptr;
|
||||||
ozz::animation::SamplingJob sampling_job;
|
ozz::animation::SamplingJob sampling_job;
|
||||||
ozz::animation::SamplingJob::Context* m_sampling_context = nullptr;
|
ozz::vector<ozz::math::SoaTransform> local_matrices;
|
||||||
} ozz;
|
} ozz;
|
||||||
sg_pass_action pass_action;
|
sg_pass_action pass_action;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
|
@ -690,6 +690,8 @@ int main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.ozz.animation != nullptr) {
|
if (state.ozz.animation != nullptr) {
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
ImGui::SliderFloat(
|
ImGui::SliderFloat(
|
||||||
"Time",
|
"Time",
|
||||||
&state.time.absolute,
|
&state.time.absolute,
|
||||||
|
@ -702,8 +704,20 @@ int main() {
|
||||||
ImGui::End();
|
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
|
// TODO: add AnimGraph to calculate pose
|
||||||
// skinned_mesh.CalcModelMatrices();
|
skinned_mesh.CalcModelMatrices();
|
||||||
|
}
|
||||||
|
|
||||||
sgl_defaults();
|
sgl_defaults();
|
||||||
sgl_matrix_mode_projection();
|
sgl_matrix_mode_projection();
|
||||||
|
|
Loading…
Reference in New Issue