Skip to content

Commit

Permalink
spline save and load
Browse files Browse the repository at this point in the history
  • Loading branch information
adafcaefc committed Dec 5, 2024
1 parent c3e6220 commit b08f50b
Show file tree
Hide file tree
Showing 12 changed files with 515 additions and 505 deletions.
20 changes: 12 additions & 8 deletions Geome3Dash/src/LevelDataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ namespace g3d
nlohmann::json jsonData = data;
std::string jsonMsg = jsonData.dump();
msgLevelEncode(layer, jsonMsg);
std::ofstream out("g3d.out.json");
out << jsonMsg;
}

LevelData LevelData::getDefault()
Expand All @@ -104,14 +106,16 @@ namespace g3d
ld.z = 40;
ld.yaw = -55;
ld.pitch = -6;
ld.bezierMultiplier = 1.0 / 3.0;
ld.bezierCurve =
{
0.167 * 6, 0.355 * 6,
0.516 * 6, 0.124 * 6,
0.121 * 6, 0.557 * 6,
0.412 * 6, 0.352 * 6
};
//ld.bezierMultiplier = 1.0 / 3.0;
//ld.bezierCurve =
//{
// 0.167 * 6, 0.355 * 6,
// 0.516 * 6, 0.124 * 6,
// 0.121 * 6, 0.557 * 6,
// 0.412 * 6, 0.352 * 6
//};
ld.spline = Spline();
ld.spline.addSegment(Curve(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 0.0f, 0.0f), glm::vec3(2.0f, 0.0f, 0.0f), glm::vec3(3.0f, 0.0f, 0.0f)));
return ld;
}
}
14 changes: 10 additions & 4 deletions Geome3Dash/src/LevelDataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
#include "CameraAction.h"

#include "helper/BezierHelper.h"
#include "helper/spline/Spline.h"

#include <nlohmann/json.hpp>

#include <glm/glm.hpp>

#include <string>
#include <vector>

Expand All @@ -25,16 +28,19 @@ namespace g3d

struct LevelData
{
CubicBezierLD bezierCurve; // Bezier values
double bezierMultiplier; // Path size
//CubicBezierLD bezierCurve; // Bezier values
//double bezierMultiplier; // Path size
//std::vector<CameraActionLD> actions; // Camera actions


double x, y, z; // Position
double yaw, pitch; // Rotation
bool lock; // Lock camera
std::vector<CameraActionLD> actions; // Camera actions
Spline spline; // Spline path

static LevelData getDefault();

NLOHMANN_DEFINE_TYPE_INTRUSIVE(LevelData, bezierCurve, bezierMultiplier, x, y, z, yaw, pitch, lock, actions);
NLOHMANN_DEFINE_TYPE_INTRUSIVE(LevelData, spline, x, y, z, yaw, pitch, lock);
};

void msgLevelEncode(GJBaseGameLayer* layer, const std::string& message);
Expand Down
Loading

0 comments on commit b08f50b

Please sign in to comment.