diff --git a/build/vs/vs.vcxproj b/build/vs/vs.vcxproj
index 9b27639..cbe6246 100644
--- a/build/vs/vs.vcxproj
+++ b/build/vs/vs.vcxproj
@@ -77,9 +77,11 @@ xcopy /d /y "..\..\..\..\Dev\SDL2-2.0.3\lib\x86\SDL2.dll" "$(OutDir)"
+
+
@@ -92,11 +94,13 @@ xcopy /d /y "..\..\..\..\Dev\SDL2-2.0.3\lib\x86\SDL2.dll" "$(OutDir)"
-
+
+
+
diff --git a/build/vs/vs.vcxproj.filters b/build/vs/vs.vcxproj.filters
index 34506f3..f159183 100644
--- a/build/vs/vs.vcxproj.filters
+++ b/build/vs/vs.vcxproj.filters
@@ -36,6 +36,12 @@
Classes
+
+ Classes
+
+
+ Classes
+
@@ -52,14 +58,20 @@
Classes
-
- Header Files
-
Classes
Classes
+
+ Header Files
+
+
+ Classes
+
+
+ Classes
+
\ No newline at end of file
diff --git a/src/RenderCamera.hpp b/src/RenderCamera.hpp
index cba54fe..126ffe5 100644
--- a/src/RenderCamera.hpp
+++ b/src/RenderCamera.hpp
@@ -11,13 +11,14 @@ RenderScene and outputs all data to the friend class, RenderView.
#define RENDERCAMERA_HPP
#include "common.hpp"
#include "RenderView.hpp"
+#include "Vec.hpp"
class RenderCamera {
public:
RenderCamera();
~RenderCamera();
int setRenderView(RenderView *view);
private:
- //Vec3 x, y, z; // TODO: replace with quaternion
+ Vec3 x, y, z; // TODO: replace with quaternion
int render_mode; // 0 = perspective, 1 = orthogonal
RenderView *render_view; // RenderView to render the scene to
};
diff --git a/src/RenderObject.cpp b/src/RenderObject.cpp
new file mode 100644
index 0000000..de0244e
--- /dev/null
+++ b/src/RenderObject.cpp
@@ -0,0 +1,11 @@
+/* ================================================================
+RenderSet
+----------------
+This header file defines the RenderObject class.
+================================================================ */
+#include "RenderObject.hpp"
+/* ======== Constructors and Destructors ======== */
+RenderObject::RenderObject() {
+}
+RenderObject::~RenderObject() {
+}
\ No newline at end of file
diff --git a/src/RenderObject.hpp b/src/RenderObject.hpp
new file mode 100644
index 0000000..62d6d83
--- /dev/null
+++ b/src/RenderObject.hpp
@@ -0,0 +1,25 @@
+/* ================================================================
+RenderObject
+----------------
+This header file describes the RenderObject class.
+
+A RenderObject is the basic class that contains information for
+rendering an object within a RenderScene. An object has, at minimum,
+a Mesh, a texture, a position, and an orientation.
+================================================================ */
+#ifndef RENDEROBJECT_HPP
+#define RENDEROBJECT_HPP
+#include "common.hpp"
+#include "Vec.hpp"
+class RenderObject {
+ public:
+ RenderObject();
+ ~RenderObject();
+ private:
+ // Mesh mesh;
+ // GLuint texture;
+ // TODO: replace position and orientation with matrix?
+ Vec3 position;
+ Vec3 orientation;
+};
+#endif
\ No newline at end of file
diff --git a/src/RenderScene.hpp b/src/RenderScene.hpp
index de67c0f..9c7331d 100644
--- a/src/RenderScene.hpp
+++ b/src/RenderScene.hpp
@@ -11,13 +11,14 @@ each of which correspond to a different scene perspective.
#define RENDERSCENE_HPP
#include "common.hpp"
#include "RenderCamera.hpp"
+#include "RenderSet.hpp"
#include
class RenderScene {
public:
RenderScene();
~RenderScene();
private:
- std::vector cameras; // Our scene's cameras
- //std::vector render_sets; // Our scene's render sets
+ std::vector cameras; // Our scene's cameras
+ std::vector render_sets; // Our scene's render sets
};
#endif
diff --git a/src/RenderSet.hpp b/src/RenderSet.hpp
index 0c87d09..6d0df13 100644
--- a/src/RenderSet.hpp
+++ b/src/RenderSet.hpp
@@ -11,14 +11,15 @@ rendering layers of the program.
#ifndef RENDERSET_HPP
#define RENDERSET_HPP
#include "common.hpp"
+#include "RenderObject.hpp"
#include
class RenderSet {
public:
RenderSet();
~RenderSet();
private:
- int mode; // bitflag, 0 = normal, 1 = hide
- //std::vector objects; // Our vector of objects to render
- GLuint program; // Our rendering program
+ int mode; // bitflag, 0 = normal, 1 = hide
+ std::vector objects; // Our vector of objects to render
+ GLuint program; // Our rendering program
};
#endif
diff --git a/src/Vec.cpp b/src/Vec.cpp
new file mode 100644
index 0000000..9b9e9eb
--- /dev/null
+++ b/src/Vec.cpp
@@ -0,0 +1,265 @@
+/* ================================================================
+Vec2/Vec3/Vec4
+----------------
+This file defines the classes for Vec2 and Vec3, 2D and 3D Vectors respectively.
+================================================================ */
+#include "Vec.hpp"
+#include // abs
+#include // sqrt
+Vec2::Vec2() {
+ x = y = 0.0f;
+}
+// constructor
+Vec2::Vec2(float x_, float y_) {
+ x = x_;
+ y = y_;
+}
+// operators
+// add
+Vec2 Vec2::operator+(const Vec2 &Vec) {
+ return Vec2(x + Vec.x, y + Vec.y);
+}
+void Vec2::operator+=(const Vec2 &Vec) {
+ x += Vec.x;
+ y += Vec.y;
+}
+// sub
+Vec2 Vec2::operator-(const Vec2 &Vec) {
+ return Vec2(x - Vec.x, y - Vec.y);
+}
+void Vec2::operator-=(const Vec2 &Vec) {
+ x -= Vec.x;
+ y -= Vec.y;
+}
+// mul
+Vec2 Vec2::operator*(const Vec2 &Vec) {
+ return Vec2(x * Vec.x, y * Vec.y);
+}
+void Vec2::operator*=(const float &val) {
+ x *= val;
+ y *= val;
+}
+// mul overload
+Vec2 Vec2::operator*(const float &val) {
+ return Vec2(x * val, y * val);
+}
+// div
+Vec2 Vec2::operator/(const float &val) {
+ return Vec2(x / val, y / val);
+}
+// div overload
+Vec2 Vec2::operator/(const Vec2 &Vec) {
+ return Vec2(x / Vec.x, y / Vec.y);
+}
+// div assign
+void Vec2::operator/=(const float &val) {
+ x /= val;
+ y /= val;
+}
+// other stuff
+void Vec2::normalize() {
+ float magnitude = sqrt((x * x) + (y * y));
+ if (magnitude != 0) {
+ x /= magnitude;
+ y /= magnitude;
+ }
+}
+void Vec2::zero() {
+ x = y = 0;
+}
+float Vec2::dotProduct(const Vec2 &Vec) {
+ return x * Vec.x + y * Vec.y;
+}
+float Vec2::distanceTo(const Vec2 &Vec) {
+ float dx = abs(Vec.x - x);
+ float dy = abs(Vec.y - y);
+ return dx+dy;
+}
+/* Vec3
+```````````````````````````````````````````````````````````````` */
+Vec3::Vec3() {
+ x = y = z = 0.0f;
+}
+// constructor
+Vec3::Vec3(float x_, float y_, float z_) {
+ x = x_;
+ y = y_;
+ z = z_;
+}
+// operators
+// add
+Vec3 Vec3::operator+(const Vec3 &Vec) {
+ return Vec3(x + Vec.x, y + Vec.y, z + Vec.z);
+}
+void Vec3::operator+=(const Vec3 &Vec) {
+ x += Vec.x;
+ y += Vec.y;
+ z += Vec.z;
+}
+// sub
+Vec3 Vec3::operator-(const Vec3 &Vec) {
+ return Vec3(x - Vec.x, y - Vec.y, z - Vec.z);
+}
+void Vec3::operator-=(const Vec3 &Vec) {
+ x -= Vec.x;
+ y -= Vec.y;
+ z -= Vec.z;
+}
+// mul
+Vec3 Vec3::operator*(const Vec3 &Vec) {
+ return Vec3(x * Vec.x, y * Vec.y, z * Vec.z);
+}
+void Vec3::operator*=(const float &val) {
+ x *= val;
+ y *= val;
+ z *= val;
+}
+// mul overload
+Vec3 Vec3::operator*(const float &val) {
+ return Vec3(x * val, y * val, z * val);
+}
+// div
+Vec3 Vec3::operator/(const float &val) {
+ return Vec3(x / val, y / val, z / val);
+}
+// div overload
+Vec3 Vec3::operator/(const Vec3 &Vec) {
+ return Vec3(x / Vec.x, y / Vec.y, z / Vec.z);
+}
+// div assign
+void Vec3::operator/=(const float &val) {
+ x /= val;
+ y /= val;
+ z /= val;
+}
+// other stuff
+Vec3 Vec3::getInverse() {
+ return Vec3(-x, -y, -z);
+}
+void Vec3::normalize() {
+ float magnitude = sqrt((x * x) + (y * y) + (z * z));
+ if (magnitude != 0) {
+ x /= magnitude;
+ y /= magnitude;
+ z /= magnitude;
+ }
+}
+void Vec3::zero() {
+ x = y = z = 0;
+}
+float Vec3::dotProduct(const Vec3 &Vec) {
+ return (x * Vec.x + y * Vec.y + z * Vec.z);
+}
+Vec3 Vec3::crossProduct(const Vec3 &Vec) {
+ return Vec3(y * Vec.z - z * Vec.y, z * Vec.x - x * Vec.z, x * Vec.y - y * Vec.x);
+}
+float Vec3::distanceTo(const Vec3 &Vec) {
+ float dx = abs(Vec.x - x);
+ float dy = abs(Vec.y - y);
+ float dz = abs(Vec.z - z);
+ return dx+dy+dz;
+}
+float Vec3::lengthSquared() {
+ return x*x + y*y + z*z;
+}
+
+/* Vec4
+```````````````````````````````````````````````````````````````` */
+Vec4::Vec4() {
+ values[0] = values[1] = values[2] = values[3] = 0.0f;
+}
+// constructor
+Vec4::Vec4(float x_, float y_, float z_, float w_) {
+ values[0] = x_;
+ values[1] = y_;
+ values[2] = z_;
+ values[3] = w_;
+}
+// operators
+// add
+Vec4 Vec4::operator+(const Vec4 &Vec) {
+ return Vec4(values[0] + Vec[0], values[1] + Vec[1], values[2] + Vec[2], values[3] + Vec[3]);
+}
+void Vec4::operator+=(const Vec4 &Vec) {
+ values[0] += Vec[0];
+ values[1] += Vec[1];
+ values[2] += Vec[2];
+ values[3] += Vec[3];
+}
+// sub
+Vec4 Vec4::operator-(const Vec4 &Vec) {
+ return Vec4(values[0] - Vec[0], values[1] - Vec[1], values[2] - Vec[2], values[3] - Vec[3]);
+}
+void Vec4::operator-=(const Vec4 &Vec) {
+ values[0] -= Vec[0];
+ values[1] -= Vec[1];
+ values[2] -= Vec[2];
+ values[3] -= Vec[3];
+}
+Vec4 Vec4::operator-(const float &val) {
+ return Vec4(values[0] - val, values[1] - val, values[2] - val, values[3] - val);
+}
+// mul
+Vec4 Vec4::operator*(const Vec4 &Vec) {
+ return Vec4(values[0] * Vec[0], values[1] * Vec[1], values[2] * Vec[2], values[3] * Vec[3]);
+}
+void Vec4::operator*=(const Vec4 &Vec) {
+ values[0] *= Vec[0];
+ values[1] *= Vec[1];
+ values[2] *= Vec[2];
+ values[3] *= Vec[3];
+}
+void Vec4::operator*=(const float &val) {
+ values[0] *= val;
+ values[1] *= val;
+ values[2] *= val;
+ values[3] *= val;
+}
+// mul overload
+Vec4 Vec4::operator*(const float &val) {
+ return Vec4(values[0] * val, values[1] * val, values[2] * val, values[3] * val);
+}
+// div
+Vec4 Vec4::operator/(const float &val) {
+ return Vec4(values[0] / val, values[1] / val, values[2] / val, values[3] / val);
+}
+// div overload
+Vec4 Vec4::operator/(const Vec4 &Vec) {
+ return Vec4(values[0] / Vec[0], values[1] / Vec[1], values[2] / Vec[2], values[3] / Vec[3]);
+}
+// div assign
+void Vec4::operator/=(const float &val) {
+ values[0] /= val;
+ values[1] /= val;
+ values[2] /= val;
+ values[3] /= val;
+}
+const float& Vec4::operator[](int index) const {
+ return values[index];
+}
+float& Vec4::operator[](int index) {
+ return values[index];
+}
+
+// other stuff
+void Vec4::normalize() {
+ float magnitude = sqrt((values[0] * values[0]) + (values[1] * values[1]) + (values[2] * values[2]) + (values[3] * values[3]));
+ if (magnitude != 0) {
+ values[0] /= magnitude;
+ values[1] /= magnitude;
+ values[2] /= magnitude;
+ values[3] /= magnitude;
+ }
+}
+void Vec4::zero() {
+ values[0] = values[1] = values[2] = values[3] = 0;
+}
+float Vec4::dotProduct(const Vec4 &Vec) {
+ return values[0] * Vec[0] + values[1] * Vec[1] + values[2] * Vec[2] + values[3] * Vec[3];
+}
+float Vec4::distanceTo(const Vec4 &Vec) {
+ float dx = abs(Vec[0] - values[0]);
+ float dy = abs(Vec[1] - values[1]);
+ float dz = abs(Vec[2] - values[2]);
+ return dx+dy+dz;
+}
\ No newline at end of file
diff --git a/src/Vec.hpp b/src/Vec.hpp
new file mode 100644
index 0000000..63e0e3a
--- /dev/null
+++ b/src/Vec.hpp
@@ -0,0 +1,106 @@
+/* ================================================================
+Vec2/Vec3/Vec4
+----------------
+This header file describes the classes for 2d, 3d, and 4d Vectors.
+================================================================ */
+#ifndef VEC_HPP
+#define VEC_HPP
+
+class Vec2 {
+ public:
+ float x, y;
+ // default constructor
+ Vec2();
+ // constructor
+ Vec2(float x_, float y_);
+ // operators
+ // add
+ Vec2 operator+(const Vec2 &Vec);
+ void operator+=(const Vec2 &Vec);
+ Vec2 operator-(const Vec2 &Vec);
+ void operator-=(const Vec2 &Vec);
+ // mul
+ Vec2 operator*(const Vec2 &Vec);
+ void operator*=(const float &val);
+ // mul overload
+ Vec2 operator*(const float &val);
+ // div
+ Vec2 operator/(const float &val);
+ // div overload
+ Vec2 operator/(const Vec2 &Vec);
+ // div assign
+ void operator/=(const float &val);
+ // other stuff
+ void normalize();
+ void zero();
+ float dotProduct(const Vec2 &Vec);
+ float distanceTo(const Vec2 &Vec);
+};
+class Vec3 {
+ public:
+ float x, y, z;
+ // default constructor
+ Vec3();
+ // constructor
+ Vec3(float x_, float y_, float z_);
+ // operators
+ // add
+ Vec3 operator+(const Vec3 &Vec);
+ void operator+=(const Vec3 &Vec);
+ Vec3 operator-(const Vec3 &Vec);
+ void operator-=(const Vec3 &Vec);
+ // mul
+ Vec3 operator*(const Vec3 &Vec);
+ void operator*=(const float &val);
+ // mul overload
+ Vec3 operator*(const float &val);
+ // div
+ Vec3 operator/(const float &val);
+ // div overload
+ Vec3 operator/(const Vec3 &Vec);
+ // div assign
+ void operator/=(const float &val);
+ // other stuff
+ Vec3 getInverse();
+ void normalize();
+ void zero();
+ float dotProduct(const Vec3 &Vec);
+ Vec3 crossProduct(const Vec3 &Vec);
+ float distanceTo(const Vec3 &Vec);
+ float lengthSquared();
+};
+class Vec4 {
+ public:
+ float values[4];
+ // default constructor
+ Vec4();
+ // constructor
+ Vec4(float x_, float y_, float z_, float w_);
+ // operators
+ // add
+ Vec4 operator+(const Vec4 &Vec);
+ void operator+=(const Vec4 &Vec);
+ Vec4 operator-(const Vec4 &Vec);
+ Vec4 operator-(const float &val);
+ void operator-=(const Vec4 &Vec);
+ // mul
+ Vec4 operator*(const Vec4 &Vec);
+ void operator*=(const Vec4 &Vec);
+ void operator*=(const float &val);
+ // mul overload
+ Vec4 operator*(const float &val);
+ // div
+ Vec4 operator/(const float &val);
+ // div overload
+ Vec4 operator/(const Vec4 &Vec);
+ // div assign
+ void operator/=(const float &val);
+ const float& operator[](int index) const;
+ float& operator[](int index);
+ // other stuff
+ void normalize();
+ void zero();
+ float dotProduct(const Vec4 &Vec);
+ float distanceTo(const Vec4 &Vec);
+};
+#endif
\ No newline at end of file