Simple AnimationPlayer now working.
parent
80ea25483b
commit
a1931185d8
20
src/main.cc
20
src/main.cc
|
@ -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();
|
||||
}
|
||||
|
||||
// TODO: add AnimGraph to calculate pose
|
||||
// skinned_mesh.CalcModelMatrices();
|
||||
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();
|
||||
}
|
||||
|
||||
sgl_defaults();
|
||||
sgl_matrix_mode_projection();
|
||||
|
|
Loading…
Reference in New Issue