Files
hfut-bishe/client/core/domain/Project.h

104 lines
3.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "domain/EntityIntro.h"
#include <QString>
#include <QPointF>
#include <QVector>
#include <algorithm>
namespace core {
class Project {
public:
void setName(const QString& name) { m_name = name; }
const QString& name() const { return m_name; }
// 背景图在项目目录内的相对路径,例如 "assets/background.png"
void setBackgroundImagePath(const QString& relativePath) { m_backgroundImagePath = relativePath; }
const QString& backgroundImagePath() const { return m_backgroundImagePath; }
// 背景在视口/预览中的显隐(默认显示)
void setBackgroundVisible(bool on) { m_backgroundVisible = on; }
bool backgroundVisible() const { return m_backgroundVisible; }
void setDepthComputed(bool on) { m_depthComputed = on; }
bool depthComputed() const { return m_depthComputed; }
// 深度图在项目目录内的相对路径,例如 "assets/depth.png"
void setDepthMapPath(const QString& relativePath) { m_depthMapPath = relativePath; }
const QString& depthMapPath() const { return m_depthMapPath; }
void setFrameStart(int f) { m_frameStart = f; }
int frameStart() const { return m_frameStart; }
void setFrameEnd(int f) { m_frameEnd = f; }
int frameEnd() const { return m_frameEnd; }
void setFps(int fps) { m_fps = std::max(1, fps); }
int fps() const { return m_fps; }
struct Entity {
QString id;
QString displayName; // 显示名(空则界面用 id
bool visible = true; // Outliner 眼睛:默认显示
// 可移动实体形状:存为局部坐标(相对 originWorld
QVector<QPointF> polygonLocal;
// 从背景中抠洞的位置:固定在创建时的 world 坐标,不随实体移动
QVector<QPointF> cutoutPolygonWorld;
QPointF originWorld;
int depth = 0; // 0..255
QString imagePath; // 相对路径,例如 "assets/entities/entity-1.png"
QPointF imageTopLeftWorld; // 贴图左上角 world 坐标
// 人为整体缩放,与深度驱动的距离缩放相乘(画布中 visualScale = distanceScale * userScale
// distanceScale 在有 distanceScaleCalibMult 时为 (0.5+depth01)/calib使抠图处为 1.0
double userScale = 1.0;
// 抠图创建时该位置对应的原始距离乘子0.5+depth01用于校准该处 distanceScale==1.0。0 表示未校准(兼容旧工程)
double distanceScaleCalibMult = 0.0;
struct KeyframeVec2 {
int frame = 0;
QPointF value;
};
struct KeyframeFloat01 {
int frame = 0;
double value = 0.5; // 0..1,默认 0.5 -> scale=1.00.5..1.5 映射)
};
struct KeyframeDouble {
int frame = 0;
double value = 1.0;
};
struct ImageFrame {
int frame = 0;
QString imagePath; // 相对路径
};
// v2project.json 仅存 id + payload几何与动画在 entityPayloadPath.hfe中。
QString entityPayloadPath; // 例如 "assets/entities/entity-1.hfe"
// 仅打开 v1 项目时由 JSON 的 animationBundle 填入,用于合并旧 .anim保存 v2 前应为空。
QString legacyAnimSidecarPath;
QVector<KeyframeVec2> locationKeys;
QVector<KeyframeFloat01> depthScaleKeys;
QVector<KeyframeDouble> userScaleKeys;
QVector<ImageFrame> imageFrames;
EntityIntroContent intro;
};
void setEntities(const QVector<Entity>& entities) { m_entities = entities; }
const QVector<Entity>& entities() const { return m_entities; }
private:
QString m_name;
QString m_backgroundImagePath;
bool m_backgroundVisible = true;
bool m_depthComputed = false;
QString m_depthMapPath;
int m_frameStart = 0;
int m_frameEnd = 600;
int m_fps = 60;
QVector<Entity> m_entities;
};
} // namespace core