diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-04-11 22:24:46 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-04-11 22:24:46 +0100 |
commit | ccdf76463228751dee100b544d854b6f1be5596c (patch) | |
tree | bc2a06ba04e56966d63455a013c49193eb339e10 /yage | |
parent | 99c106ca8ee633fc28fb18e36686aa533b6fa3c9 (diff) | |
download | YAGE-ccdf76463228751dee100b544d854b6f1be5596c.tar.gz YAGE-ccdf76463228751dee100b544d854b6f1be5596c.zip |
Adding 3D support
Diffstat (limited to 'yage')
-rw-r--r-- | yage/experimental/camera3d.h | 13 | ||||
-rw-r--r-- | yage/experimental/loader.cpp | 45 | ||||
-rw-r--r-- | yage/experimental/loader.h | 19 |
3 files changed, 74 insertions, 3 deletions
diff --git a/yage/experimental/camera3d.h b/yage/experimental/camera3d.h index efd96dc0..6a712a17 100644 --- a/yage/experimental/camera3d.h +++ b/yage/experimental/camera3d.h @@ -1,8 +1,15 @@ #ifndef YAGE_EXPERIMENTAL_CAMERA3D_H #define YAGE_EXPERIMENTAL_CAMERA3D_H -class Camera3D { - -} +#include <glm/glm.hpp> + +class Camera3D +{ +public: + Camera3D() = default; + +private: + glm::mat4 +}; #endif diff --git a/yage/experimental/loader.cpp b/yage/experimental/loader.cpp new file mode 100644 index 00000000..a13af1f2 --- /dev/null +++ b/yage/experimental/loader.cpp @@ -0,0 +1,45 @@ +#include "loader.h" + +#include "../core/exception.h" + +#include <fstream> +#include <sstream> + +namespace yage +{ + +void load_obj(std::string filename, std::vector<glm::vec4> &vertices, + std::vector<glm::vec3> &normals, std::vector<GLushort> &elements) +{ + std::ifstream in(filename, std::ios::in); + + if (!in.is_open()) { + throw FileLoadException("Could not load obj file '" + filename + "'"); + } + + std::string line; + + while (getline(in, line)) { + if (line.substr(0, 2) == "v ") { + std::istringstream s(line.substr(2)); + glm::vec4 v; + s >> v.x >> v.y >> v.z; + v.w = 1.f; + vertices.push_back(v); + } else if (line.substr(0, 2) == "f ") { + std::istringstream s(line.substr(2)); + GLushort a, b, c; + s >> a >> b >> c; + a--, b--, c--; + elements.push_back(a); + elements.push_back(b); + elements.push_back(c); + } else { + // do nothing otherwise + } + } + + normals.resize() +} + +} // namespace yage diff --git a/yage/experimental/loader.h b/yage/experimental/loader.h new file mode 100644 index 00000000..9f076bb1 --- /dev/null +++ b/yage/experimental/loader.h @@ -0,0 +1,19 @@ +#ifndef YAGE_EXPERIMENTAL_LOADER_H +#define YAGE_EXPERIMENTAL_LOADER_H + +#include <string> +#include <vector> + +#include <glad/glad.h> +#include <glm/glm.hpp> + +namespace yage +{ + +extern void load_obj(std::string filename, std::vector<glm::vec4> &vertices, + std::vector<glm::vec3> &normals, + std::vector<GLushort> &elements); + +} // namespace yage + +#endif |