added finding path with A* and json file to know where character can walk
This commit is contained in:
1 parent
eff7322140
commit
4eaefd25d4
11 files changed
+905
-11
No files matched your search
+12
-1
@@ -8,6 +8,7 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace ZL {
|
||||
|
||||
@@ -22,6 +23,10 @@ enum class AnimationState {
|
||||
|
||||
class Character {
|
||||
public:
|
||||
using PathPlanner = std::function<std::vector<Eigen::Vector3f>(
|
||||
const Eigen::Vector3f& start,
|
||||
const Eigen::Vector3f& end)>;
|
||||
|
||||
void loadAnimation(AnimationState state, const std::string& filename, const std::string& zipFile = "");
|
||||
// void setTexture(std::shared_ptr<Texture> texture);
|
||||
void setTexture(std::shared_ptr<Texture> texture) {
|
||||
@@ -32,6 +37,7 @@ public:
|
||||
// From Python you can chain further commands (walk, wait, trigger others).
|
||||
void setTarget(const Eigen::Vector3f& target,
|
||||
std::function<void()> onArrived = nullptr);
|
||||
void setPathPlanner(PathPlanner planner);
|
||||
void draw(Renderer& renderer);
|
||||
|
||||
// Public: read by Game for camera tracking and ray-cast origin
|
||||
@@ -70,13 +76,18 @@ private:
|
||||
};
|
||||
|
||||
std::map<AnimationState, AnimationData> animations;
|
||||
std::shared_ptr<Texture> texture;
|
||||
std::shared_ptr<Texture> texture;
|
||||
|
||||
Eigen::Vector3f walkTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
|
||||
Eigen::Vector3f requestedWalkTarget = Eigen::Vector3f(0.f, 0.f, 0.f);
|
||||
std::vector<Eigen::Vector3f> pathWaypoints;
|
||||
size_t currentWaypointIndex = 0;
|
||||
PathPlanner pathPlanner;
|
||||
float targetFacingAngle = 0.0f;
|
||||
std::function<void()> onArrivedCallback;
|
||||
|
||||
static constexpr float WALK_THRESHOLD = 0.05f;
|
||||
static constexpr float TARGET_REPLAN_THRESHOLD = 0.25f;
|
||||
|
||||
// Returns the animation state to actually play/draw, falling back to IDLE
|
||||
// if the requested state has no loaded animation.
|
||||
|
||||
Reference in new issue
Block a user