mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
Add a Gait component synchronized over the network and procedural animation for model nodes. Load animation parameters from assets/model/creature/pig/animation.json and apply leg swing, body bob, and head motion based on gait. Refactor Gait into its own header for reuse.
21 lines
546 B
C++
21 lines
546 B
C++
#pragma once
|
|
#include <stdexcept>
|
|
#include <utility>
|
|
|
|
namespace Cubed {
|
|
enum class Gait { STOP = 0, WALK = 1, RUN = 2 };
|
|
constexpr int get_gait_id(Gait gait) { return std::to_underlying(gait); }
|
|
|
|
inline Gait get_gait_from_id(int id) {
|
|
switch (id) {
|
|
case std::to_underlying(Gait::STOP):
|
|
return Gait::STOP;
|
|
case std::to_underlying(Gait::WALK):
|
|
return Gait::WALK;
|
|
case std::to_underlying(Gait::RUN):
|
|
return Gait::RUN;
|
|
default:
|
|
throw std::runtime_error("Unknown Gait");
|
|
}
|
|
}
|
|
} // namespace Cubed
|