Working on doors and scripting
This commit is contained in:
1 parent
774397f690
commit
0f2b2e55af
11 files changed
+322
-9
No files matched your search
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
#include <cstdint>
|
||||
#include <Eigen/Core>
|
||||
#include "render/Renderer.h"
|
||||
|
||||
@@ -17,12 +20,35 @@ namespace ZL {
|
||||
struct InteractiveObject {
|
||||
LoadedGameObject loadedObject; // name, texture, mesh
|
||||
Eigen::Vector3f position;
|
||||
Eigen::Vector3f pivot = Eigen::Vector3f::Zero(); // local-space offset to rotation pivot
|
||||
float rotationY = 0.0f; // Y-axis rotation in radians
|
||||
float scale = 1.0f; // uniform scale
|
||||
float interactionRadius;
|
||||
bool isActive = true;
|
||||
bool isActive = true;
|
||||
bool isAnimating = false; // true while a timed animation is running
|
||||
std::string activateFunctionName;
|
||||
|
||||
struct AnimTask {
|
||||
enum class Type { Move, Rotate, Scale } type;
|
||||
Eigen::Vector3f startPos;
|
||||
float startRotY;
|
||||
float startScale;
|
||||
Eigen::Vector3f targetPos;
|
||||
float targetRotY;
|
||||
float targetScale;
|
||||
float durationMs;
|
||||
float elapsedMs = 0.f;
|
||||
std::function<void()> onComplete;
|
||||
};
|
||||
|
||||
std::optional<AnimTask> animTask;
|
||||
|
||||
InteractiveObject() : interactionRadius(2.0f) {}
|
||||
|
||||
void moveTo(const Eigen::Vector3f& target, float durationSec, std::function<void()> onComplete = {});
|
||||
void rotateTo(float targetRotY, float durationSec, std::function<void()> onComplete = {});
|
||||
void scaleTo(float targetScale, float durationSec, std::function<void()> onComplete = {});
|
||||
void update(int64_t deltaMs);
|
||||
void draw(Renderer& renderer) const;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user