aboutsummaryrefslogtreecommitdiffstats
path: root/yage
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-04-11 22:24:46 +0100
committerYann Herklotz <ymherklotz@gmail.com>2018-04-11 22:24:46 +0100
commitccdf76463228751dee100b544d854b6f1be5596c (patch)
treebc2a06ba04e56966d63455a013c49193eb339e10 /yage
parent99c106ca8ee633fc28fb18e36686aa533b6fa3c9 (diff)
downloadYAGE-ccdf76463228751dee100b544d854b6f1be5596c.tar.gz
YAGE-ccdf76463228751dee100b544d854b6f1be5596c.zip
Adding 3D support
Diffstat (limited to 'yage')
-rw-r--r--yage/experimental/camera3d.h13
-rw-r--r--yage/experimental/loader.cpp45
-rw-r--r--yage/experimental/loader.h19
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