载入中...
搜索中...
未找到
CameraController.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Module.h"
4
5#include <glm/glm.hpp>
6
7#include <string>
8#include <vector>
9
10namespace eve::graphics {
11class Camera3D;
12}
13
14namespace eve::camera {
15
30public:
32 ~CameraController() = default;
33
34 // --- 绑定要驱动的摄像机 ---
37
38 // --- 目标 / 观察锚点 ---
39 void setTarget(float x, float y, float z);
40 float getTargetX() const;
41 float getTargetY() const;
42 float getTargetZ() const;
44 void setOffset(float x, float y, float z);
46 void setLookAhead(float x, float y, float z);
47
48 // --- 视角模式 ---
49 void setMode(const std::string &mode);
50 std::string getMode() const;
51
52 // --- orbit / topdown 参数 ---
53 void setRadius(float r); // orbit 半径 / topdown 高度
54 void setAzimuth(float deg); // orbit 方位角
55 void setElevation(float deg); // orbit 仰角
56 void setOrbitSpeed(float degPerSec); // 自动盘旋转速
57
58 // --- firstperson 参数 ---
59 void setYaw(float deg);
60 void setPitch(float deg);
61
62 // --- 平滑 ---
63 void setSmooth(float damping); // 每秒指数阻尼,越大越跟手
64 void setMaxSpeed(float unitsPerSec); // 0 = 不限速
65 void snap(); // 立即应用当前目标视角
66
67 // --- cinematic / 自动切换视角 ---
68 void addView(const std::string &name, float ex, float ey, float ez,
69 float tx, float ty, float tz);
70 bool switchTo(const std::string &name, float blendTime);
71 void playSequence(float stepTime); // 每隔 stepTime 秒切换到下一个 View
72 void stopSequence();
73 bool isPlaying() const;
74
75 // --- 每帧驱动 ---
76 void update(float dt);
77
78private:
79 struct View {
80 std::string name;
81 glm::vec3 eye{0.f};
82 glm::vec3 target{0.f};
83 };
84
85 View desired() const;
86 void applyView(const View &v);
87 void easeToward(const View &v, float dt);
88
89 graphics::Camera3D *cam_ = nullptr;
90
91 std::string mode_ = "follow";
92
93 glm::vec3 target_{0.f, 0.f, 0.f};
94 glm::vec3 offset_{0.f, 2.f, 6.f};
95 glm::vec3 lookAhead_{0.f, 0.f, 0.f};
96
97 float radius_ = 10.f;
98 float azimuthDeg_ = 45.f;
99 float elevationDeg_ = 30.f;
100 float orbitSpeedDeg_ = 20.f;
101
102 float yawDeg_ = 0.f;
103 float pitchDeg_ = 0.f;
104
105 float smooth_ = 6.f;
106 float maxSpeed_ = 0.f;
107 bool initialized_ = false;
108 View cur_{};
109
110 // cinematic
111 std::vector<View> views_;
112 int viewIndex_ = -1;
113 bool playing_ = false;
114 float stepTime_ = 3.f;
115 float timer_ = 0.f;
116 bool blending_ = false;
117 View blendFrom_{};
118 View blendTo_{};
119 float blendT_ = 0.f;
120 float blendDur_ = 1.f;
121};
122
126class Camera : public Module {
127public:
129 Camera() = default;
130 ~Camera() override = default;
131};
132
133} // namespace eve::camera
int y
Definition Grass.cpp:135
int z
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
glm::vec3 eye
const char * name
Definition RockMesh.cpp:21
int v
3D 摄像机控制器(eve.Camera / eve.CameraController)。
void addView(const std::string &name, float ex, float ey, float ez, float tx, float ty, float tz)
void setTarget(float x, float y, float z)
void setCamera(graphics::Camera3D *cam)
graphics::Camera3D * getCamera() const
void playSequence(float stepTime)
void setLookAhead(float x, float y, float z)
follow:额外的视线前移点(可让镜头看向玩家前方)。
void setMode(const std::string &mode)
void setMaxSpeed(float unitsPerSec)
bool switchTo(const std::string &name, float blendTime)
void setOffset(float x, float y, float z)
follow:摄像机相对 target 的偏移(默认 (0, 2, 6))。
void setOrbitSpeed(float degPerSec)
摄像机模块命名空间(eve.Camera)。主要职责是把 CameraController 绑定进脚本。
~Camera() override=default
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6