Skip to content

Commit

Permalink
Merge branch 'adaf/visual-studio'
Browse files Browse the repository at this point in the history
  • Loading branch information
adafcaefc committed Jan 15, 2025
2 parents 58955d3 + c5b3ab0 commit 359489c
Show file tree
Hide file tree
Showing 95 changed files with 683,926 additions and 870 deletions.
54 changes: 27 additions & 27 deletions Geome3Dash/src/engine/sus3d/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,35 @@ namespace sus3d
glm::vec3 scale = glm::vec3(1.0);
bool visible = 1;
public:
void setRotation(glm::vec3 rotation) { this->rotation = rotation; }
void setRotationX(float rotation) { this->rotation.x = rotation; }
void setRotationY(float rotation) { this->rotation.y = rotation; }
void setRotationZ(float rotation) { this->rotation.z = rotation; }
glm::vec3 getRotation() const { return this->rotation; }
float getRotationX() const { return this->rotation.x; }
float getRotationY() const { return this->rotation.y; }
float getRotationZ() const { return this->rotation.z; }
virtual void setRotation(glm::vec3 rotation) { this->rotation = rotation; }
virtual void setRotationX(float rotation) { this->rotation.x = rotation; }
virtual void setRotationY(float rotation) { this->rotation.y = rotation; }
virtual void setRotationZ(float rotation) { this->rotation.z = rotation; }
virtual glm::vec3 getRotation() const { return this->rotation; }
virtual float getRotationX() const { return this->rotation.x; }
virtual float getRotationY() const { return this->rotation.y; }
virtual float getRotationZ() const { return this->rotation.z; }

void setPosition(glm::vec3 position) { this->position = position; }
void setPositionX(float position) { this->position.x = position; }
void setPositionY(float position) { this->position.y = position; }
void setPositionZ(float position) { this->position.z = position; }
glm::vec3 getPosition() const { return this->position; }
float getPositionX() const { return this->position.x; }
float getPositionY() const { return this->position.y; }
float getPositionZ() const { return this->position.z; }
virtual void setPosition(glm::vec3 position) { this->position = position; }
virtual void setPositionX(float position) { this->position.x = position; }
virtual void setPositionY(float position) { this->position.y = position; }
virtual void setPositionZ(float position) { this->position.z = position; }
virtual glm::vec3 getPosition() const { return this->position; }
virtual float getPositionX() const { return this->position.x; }
virtual float getPositionY() const { return this->position.y; }
virtual float getPositionZ() const { return this->position.z; }

void setScale(glm::vec3 scale) { this->scale = scale; }
void setScaleX(float scale) { this->scale.x = scale; }
void setScaleY(float scale) { this->scale.y = scale; }
void setScaleZ(float scale) { this->scale.z = scale; }
glm::vec3 getScale() const { return this->scale; }
float getScaleX() const { return this->scale.x; }
float getScaleY() const { return this->scale.y; }
float getScaleZ() const { return this->scale.z; }
virtual void setScale(glm::vec3 scale) { this->scale = scale; }
virtual void setScaleX(float scale) { this->scale.x = scale; }
virtual void setScaleY(float scale) { this->scale.y = scale; }
virtual void setScaleZ(float scale) { this->scale.z = scale; }
virtual glm::vec3 getScale() const { return this->scale; }
virtual float getScaleX() const { return this->scale.x; }
virtual float getScaleY() const { return this->scale.y; }
virtual float getScaleZ() const { return this->scale.z; }

void setVisible(bool visible) { this->visible = visible; }
bool getVisible() const { return this->visible; }
virtual void setVisible(bool visible) { this->visible = visible; }
virtual bool getVisible() const { return this->visible; }

virtual ~ModelProtocol() {};
};
Expand All @@ -62,7 +62,7 @@ namespace sus3d
public:
std::vector<Mesh*> meshes;
static Model* create(const aiScene* scene);
void render(
virtual void render(
ShaderProgram* shaderProgram,
const glm::mat4& view,
const glm::vec3& lightPos,
Expand Down
34 changes: 34 additions & 0 deletions Geome3Dash/src/gui/DebugWindowImGui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "pch.h"

#include "DebugWindowImGui.h"
#include "manager/LevelDataManager.h"
#include "lib/imgui-cocos/imgui-cocos.hpp"

namespace g3d
{
void setupImGui()
{
auto& io = ImGui::GetIO();
io.ConfigWindowsMoveFromTitleBarOnly = true;
}

void renderImGui()
{
// for debugging only
// should I make a settings for this?
//if (PlayLayer::get())
//{
// ImGui::Begin("Test");
// auto player = PlayLayer::get()->m_player1;
// ImGui::Text("m_currentRobotAnimation -> %s", player->m_currentRobotAnimation.c_str());
// ImGui::Text("m_wasRobotJump -> %i", player->m_wasRobotJump);
// ImGui::Text("m_isOnGround -> %i", player->m_isOnGround);
// ImGui::End();
//}
}

$on_mod(Loaded)
{
ImGuiCocos::get().setup(setupImGui).draw(renderImGui);
}
}
File renamed without changes.
24 changes: 0 additions & 24 deletions Geome3Dash/src/gui/LevelEditorImGui.cpp

This file was deleted.

20 changes: 19 additions & 1 deletion Geome3Dash/src/hook/LoadingLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@

namespace g3d
{
// I should really decouple the loading functionality from this class hook
// maybe I will do it later but for now the loading layer hook is only used
// for this loading mechanism so it's fine for the time being
// if I ever implement any other functionality to this class I might have to
// decouple this and make a loading manager class

class $modify(HookedLoadingLayer, LoadingLayer)
{
struct ShaderData
Expand Down Expand Up @@ -99,6 +105,13 @@ namespace g3d
m_fields->queuedModels.push(entry.path());
}
}
for (const auto& entry : std::filesystem::recursive_directory_iterator(bms->getABP()))
{
if (entry.is_regular_file() && entry.path().extension() == ".obj")
{
m_fields->queuedModels.push(entry.path());
}
}
}

void initCleanup(ModelManager* bms)
Expand Down Expand Up @@ -164,7 +177,12 @@ namespace g3d
"Geome3Dash: loading models ({}/{})",
m_fields->queuedModelsAmount - m_fields->queuedModels.size(),
m_fields->queuedModelsAmount).c_str());
this->setLabelText2(modelPath.lexically_relative(bms->getBP()).string().c_str());

static const auto shorter = [](const std::string& a, const std::string& b) { return (a.size() < b.size()) ? a : b; };
const std::string bpPath = modelPath.lexically_relative(bms->getBP()).string();
const std::string abpPath = modelPath.lexically_relative(bms->getABP()).string();

this->setLabelText2(shorter(bpPath, abpPath).c_str());
}
}

Expand Down
164 changes: 164 additions & 0 deletions Geome3Dash/src/impl/engine/AnimatedModel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#include "pch.h"

#include "AnimatedModel.h"

#include "helper/CommonHelper.h"
#include "manager/ModelManager.h"

namespace g3d
{
bool AnimatedModelNode::setup(const std::filesystem::path& base) {
if (!CCNode::init()) { return false; }
this->basePath = base;
this->fps = std::stof(utils::read_from_file(base / "fps.txt"));
size_t indexFrame = 0u;
const auto getIdxFrame = [this](const size_t i) { return this->basePath / "frame" / std::to_string(i) / "model.obj"; };
while (std::filesystem::exists(getIdxFrame(indexFrame))) {
this->models.emplace_back(ModelManager::get()->getModel(getIdxFrame(indexFrame)));
indexFrame++;
}
this->scheduleUpdate();
return true;
}

AnimatedModelNode* AnimatedModelNode::create(const std::filesystem::path& base) {
auto ret = new AnimatedModelNode();
if (!ret || !ret->setup(base)) {
delete ret;
return nullptr;
}
return ret;
}

void AnimatedModelNode::update(float dt) {
float frameTime = 1.0f / fps;
timeAccumulator += dt;

while (timeAccumulator >= frameTime) {
if (isLooping) {
timeAccumulator -= frameTime;
if (!models.empty()) {
currentModelIndex = (currentModelIndex + 1) % models.size();
}
}
else {
if (currentModelIndex < models.size() - 1) {
timeAccumulator -= frameTime;
currentModelIndex++;
}
else {
timeAccumulator = 0;
}
}
}
}

bool AnimatedModel::setup(const std::filesystem::path& base, PlayerObject* player) {
if (auto cnode = AnimatedModelNode::create(base)) {
this->node = cnode;
player->addChild(this->node);
return true;
}
return false;
}

AnimatedModel* AnimatedModel::create(const std::filesystem::path& base, PlayerObject* player) {
AnimatedModel* ret = new AnimatedModel();
if (!ret || !ret->setup(base, player)) {
delete ret;
return nullptr;
}
return ret;
}

void AnimatedModel::setRotation(glm::vec3 rotation) {
sus3d::Model::setRotation(rotation);
for (auto& model : node->models) {
model->setRotation(rotation);
}
}

void AnimatedModel::setRotationX(float rotation) {
sus3d::Model::setRotationX(rotation);
for (auto& model : node->models) {
model->setRotationX(rotation);
}
}

void AnimatedModel::setRotationY(float rotation) {
sus3d::Model::setRotationY(rotation);
for (auto& model : node->models) {
model->setRotationY(rotation);
}
}

void AnimatedModel::setRotationZ(float rotation) {
sus3d::Model::setRotationZ(rotation);
for (auto& model : node->models) {
model->setRotationZ(rotation);
}
}

void AnimatedModel::setPosition(glm::vec3 position) {
sus3d::Model::setPosition(position);
for (auto& model : node->models) {
model->setPosition(position);
}
}

void AnimatedModel::setPositionX(float position) {
sus3d::Model::setPositionX(position);
for (auto& model : node->models) {
model->setPositionX(position);
}
}

void AnimatedModel::setPositionY(float position) {
sus3d::Model::setPositionY(position);
for (auto& model : node->models) {
model->setPositionY(position);
}
}

void AnimatedModel::setPositionZ(float position) {
sus3d::Model::setPositionZ(position);
for (auto& model : node->models) {
model->setPositionZ(position);
}
}

void AnimatedModel::setScale(glm::vec3 scale) {
sus3d::Model::setScale(scale);
for (auto& model : node->models) {
model->setScale(scale);
}
}

void AnimatedModel::setScaleX(float scale) {
sus3d::Model::setScaleX(scale);
for (auto& model : node->models) {
model->setScaleX(scale);
}
}

void AnimatedModel::setScaleY(float scale) {
sus3d::Model::setScaleY(scale);
for (auto& model : node->models) {
model->setScaleY(scale);
}
}

void AnimatedModel::setScaleZ(float scale) {
sus3d::Model::setScaleZ(scale);
for (auto& model : node->models) {
model->setScaleZ(scale);
}
}

void AnimatedModel::setVisible(bool visible) {
sus3d::Model::setVisible(visible);
for (auto& model : node->models) {
model->setVisible(visible);
}
}
}
Loading

0 comments on commit 359489c

Please sign in to comment.