initial import, >900commits predate this

This commit is contained in:
2020-09-29 13:47:50 +02:00
commit e74154ccee
352 changed files with 108120 additions and 0 deletions

View File

@ -0,0 +1,10 @@
#pragma once
#include <glm/vec4.hpp>
namespace MM::Components {
struct Color {
glm::vec4 color {1.f, 1.f, 1.f, 1.f};
};
}

View File

@ -0,0 +1,11 @@
#pragma once
#include <string>
namespace MM::Components {
struct Name {
static const size_t max_str_len = 64;
std::string str;
};
}

View File

@ -0,0 +1,12 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/color.hpp>
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Color, color)
} // MM::Components

View File

@ -0,0 +1,16 @@
#pragma once
#include <glm/vec2.hpp>
#include <glm/vec3.hpp>
#include <glm/vec4.hpp>
#include <nlohmann/json.hpp>
namespace glm {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec2, x, y)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec3, x, y, z)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(vec4, x, y, z, w)
}

View File

@ -0,0 +1,10 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/name.hpp>
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Name, str)
} // MM::Components

View File

@ -0,0 +1,12 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/transform2d.hpp>
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform2D, position, scale, rotation)
} // MM::Components

View File

@ -0,0 +1,12 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/transform3d.hpp>
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Transform3D, position, scale, rotation)
} // MM::Components

View File

@ -0,0 +1,12 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/velocity2d.hpp>
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity2D, velocity, rotation)
} // MM::Components

View File

@ -0,0 +1,12 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/velocity3d.hpp>
#include "./json_glm.hpp"
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Velocity3D, velocity, rotation)
} // MM::Components

View File

@ -0,0 +1,10 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/view_dir2d.hpp>
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ViewDir2D, dir)
} // MM::Components

View File

@ -0,0 +1,10 @@
#pragma once
#include <nlohmann/json.hpp>
#include <mm/components/view_dir3d.hpp>
namespace MM::Components {
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ViewDir3D, yaw, pitch, roll)
} // MM::Components

View File

@ -0,0 +1,55 @@
//
// Created by FlaXxy on 29.07.2018.
//
#pragma once
#include <glm/vec2.hpp>
#include <glm/mat3x3.hpp>
#include <glm/mat4x4.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace MM::Components {
struct Transform2D {
glm::vec2 position {0.0f,0.0f};
glm::vec2 scale {1.0f,1.0f};
float rotation {0.0f};
glm::mat3x3 getTransform3(void) const {
//return transformationMatrix(scale, rotation, position);
glm::mat3x3 res(1);
res[2][0] = position.x;
res[2][1] = position.y;
float const s = sinf(rotation);
float const c = cosf(rotation);
res[0][0] = scale.x * c;
res[0][1] = scale.x * s;
res[1][0] = scale.y * -s;
res[1][1] = scale.y * c;
return res;
}
glm::mat4x4 getTransform4(float z = 500.f) const {
//return transformationMatrix(scale, rotation, position);
glm::mat4x4 res{1};
//res[2][0] = position.x;
//res[2][1] = position.y;
res = glm::translate(res, glm::vec3(position, z));
//float const s = sinf(rotation);
//float const c = cosf(rotation);
//res[0][0] = scale.x * c;
//res[0][1] = scale.x * s;
//res[1][0] = scale.y * -s;
//res[1][1] = scale.y * c;
res = glm::rotate(res, rotation, glm::vec3(0.f, 0.f, 1.f));
res = glm::scale(res, glm::vec3(scale, 1.f));
return res;
}
};
} // MM::Components

View File

@ -0,0 +1,37 @@
#pragma once
//#include <glm/mat3x3.hpp>
#include <glm/mat4x4.hpp>
#include <glm/gtc/matrix_transform.hpp>
//#include <entt/core/type_traits.hpp>
namespace MM::Components {
struct Transform3D {
glm::vec3 position {0.0f,0.0f,0.0f};
glm::vec3 scale {1.0f,1.0f,1.0f};
float rotation {0.0f};
glm::mat4x4 getTransform4(void) const {
//return transformationMatrix(scale, rotation, position);
glm::mat4x4 res{1};
//res[2][0] = position.x;
//res[2][1] = position.y;
res = glm::translate(res, position);
//float const s = sinf(rotation);
//float const c = cosf(rotation);
//res[0][0] = scale.x * c;
//res[0][1] = scale.x * s;
//res[1][0] = scale.y * -s;
//res[1][1] = scale.y * c;
res = glm::rotate(res, rotation, glm::vec3(0.f, 0.f, 1.f));
res = glm::scale(res, scale);
return res;
}
};
} // MM::Components

View File

@ -0,0 +1,16 @@
//
// Created by FlaXxy on 29.07.2018.
//
#pragma once
#include <glm/vec2.hpp>
namespace MM::Components {
struct Velocity2D {
glm::vec2 velocity;
float rotation {0.f};
};
} // MM::Components

View File

@ -0,0 +1,13 @@
#pragma once
#include <glm/vec3.hpp>
namespace MM::Components {
struct Velocity3D {
glm::vec3 velocity {0.f, 0.f, 0.f};
glm::vec3 rotation {0.f, 0.f, 0.f};
};
} // MM::Components

View File

@ -0,0 +1,10 @@
#pragma once
namespace MM::Components {
struct ViewDir2D {
float dir = 0.f; // rad
};
} // MM::Components

View File

@ -0,0 +1,12 @@
#pragma once
namespace MM::Components {
struct ViewDir3D {
float yaw = 0.f; // rad
float pitch = 0.f; // rad
float roll = 0.f; // rad
};
} // MM::Components