增加摄像机
This commit is contained in:
@@ -17,7 +17,7 @@ public:
|
||||
static constexpr const char* kProjectIndexFileName = "project.json";
|
||||
static constexpr const char* kAssetsDirName = "assets";
|
||||
// 写入 project.json 的 version 字段;仍可读 version 1(内嵌实体 + 可选 .anim)。
|
||||
static constexpr int kProjectIndexFormatVersion = 3;
|
||||
static constexpr int kProjectIndexFormatVersion = 4;
|
||||
|
||||
ProjectWorkspace() = default;
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
|
||||
const QVector<Project::Entity>& entities() const { return m_project.entities(); }
|
||||
const QVector<Project::Tool>& tools() const { return m_project.tools(); }
|
||||
const QVector<Project::Camera>& cameras() const { return m_project.cameras(); }
|
||||
|
||||
bool addTool(const Project::Tool& tool);
|
||||
bool setToolVisible(const QString& id, bool on);
|
||||
@@ -94,6 +95,17 @@ public:
|
||||
bool removeToolVisibilityKey(const QString& id, int frame);
|
||||
bool setToolParent(const QString& id, const QString& parentId, const QPointF& parentOffsetWorld);
|
||||
bool moveToolBy(const QString& id, const QPointF& delta, int currentFrame, bool autoKeyLocation);
|
||||
bool setCameraVisible(const QString& id, bool on);
|
||||
bool setActiveCameraId(const QString& id);
|
||||
bool setCameraDisplayName(const QString& id, const QString& displayName);
|
||||
bool setCameraCenterWorld(const QString& id, const QPointF& centerWorld);
|
||||
/// keyframeAtFrame >= 0 时同时写入当前活动 clip 的缩放关键帧(与实体 userScale 行为一致)
|
||||
bool setCameraViewScaleValue(const QString& id, double viewScale, int keyframeAtFrame = -1);
|
||||
bool moveCameraBy(const QString& id, const QPointF& delta, int currentFrame, bool autoKeyLocation);
|
||||
bool setCameraLocationKey(const QString& id, int frame, const QPointF& centerWorld);
|
||||
bool setCameraScaleKey(const QString& id, int frame, double viewScale);
|
||||
bool removeCameraLocationKey(const QString& id, int frame);
|
||||
bool removeCameraScaleKey(const QString& id, int frame);
|
||||
bool addEntity(const Project::Entity& entity, const QImage& image);
|
||||
bool setEntityVisible(const QString& id, bool on);
|
||||
bool setEntityBlackholeVisible(const QString& id, bool on);
|
||||
@@ -155,9 +167,14 @@ private:
|
||||
static bool entityStubFromJsonV2(const QJsonObject& o, Project::Entity& out);
|
||||
static QJsonObject toolToJson(const Project::Tool& t);
|
||||
static bool toolFromJsonV2(const QJsonObject& o, Project::Tool& out);
|
||||
static QJsonObject cameraToJson(const Project::Camera& c);
|
||||
static bool cameraFromJsonV4(const QJsonObject& o, Project::Camera& out);
|
||||
|
||||
/// 若工程尚无摄像机,则创建默认主摄像机(居中背景、缩放适配整张背景图)。不写盘;若创建了摄像机且 outAdded 非空则 *outAdded=true。
|
||||
bool ensureDefaultCameraIfMissing(bool* outAdded = nullptr);
|
||||
|
||||
struct Operation {
|
||||
enum class Type { ImportBackground, SetEntities, SetTools, SetProjectTitle, SetProjectFrameRange };
|
||||
enum class Type { ImportBackground, SetEntities, SetTools, SetCameras, SetProjectTitle, SetProjectFrameRange };
|
||||
Type type {Type::ImportBackground};
|
||||
QString label;
|
||||
QString beforeBackgroundPath;
|
||||
@@ -166,6 +183,8 @@ private:
|
||||
QVector<Project::Entity> afterEntities;
|
||||
QVector<Project::Tool> beforeTools;
|
||||
QVector<Project::Tool> afterTools;
|
||||
QVector<Project::Camera> beforeCameras;
|
||||
QVector<Project::Camera> afterCameras;
|
||||
QString beforeProjectTitle;
|
||||
QString afterProjectTitle;
|
||||
int beforeFrameStart = 0;
|
||||
@@ -180,6 +199,7 @@ private:
|
||||
bool applyBackgroundPath(const QString& relativePath, bool recordHistory, const QString& label);
|
||||
bool applyEntities(const QVector<Project::Entity>& entities, bool recordHistory, const QString& label);
|
||||
bool applyTools(const QVector<Project::Tool>& tools, bool recordHistory, const QString& label);
|
||||
bool applyCameras(const QVector<Project::Camera>& cameras, bool recordHistory, const QString& label);
|
||||
QString copyIntoAssetsAsBackground(const QString& sourceFilePath, const QRect& cropRectInSourceImage);
|
||||
bool writeDepthMap(const QImage& depth8);
|
||||
bool writeDepthMapBytes(const QByteArray& pngBytes);
|
||||
|
||||
Reference in New Issue
Block a user