diff options
| author | petrie911 <69443847+petrie911@users.noreply.github.com> | 2024-03-13 15:56:30 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-13 14:56:30 -0600 |
| commit | 92e7076647d2da64e8f90aa66974c4a3dba03a06 (patch) | |
| tree | 968573727b890d6b0cf74a6ae354fffd98999af0 /src/types | |
| parent | 2338cab8df24d483a4a1eaf8bd23a997a4beffb8 (diff) | |
Add vector classes and SF64 colpoly factory. Also fix enum parsing (#39)
* 3D
* and env
* so much to fix
Diffstat (limited to 'src/types')
| -rw-r--r-- | src/types/Vec3D.cpp | 57 | ||||
| -rw-r--r-- | src/types/Vec3D.h | 64 |
2 files changed, 121 insertions, 0 deletions
diff --git a/src/types/Vec3D.cpp b/src/types/Vec3D.cpp new file mode 100644 index 0000000..0d75e88 --- /dev/null +++ b/src/types/Vec3D.cpp @@ -0,0 +1,57 @@ +#include "Vec3D.h" +#include <iomanip> + +Vec3f::Vec3f(float xv, float yv, float zv) : x(xv), y(yv), z(zv) {} + +std::ostream& operator<< (std::ostream& stream, const Vec3f& vec) { + int width = stream.width(); + + stream << std::setw(0) << "{" << std::setw(width) << vec.x << ", " << std::setw(width) << vec.y << ", " << std::setw(width) << vec.z << "}"; + + return stream; +} + +Vec3s::Vec3s(int16_t xv, int16_t yv, int16_t zv) : x(xv), y(yv), z(zv) {} + +std::ostream& operator<< (std::ostream& stream, const Vec3s& vec) { + int width = stream.width(); + + stream << std::setw(0) << "{" << std::setw(width) << vec.x << ", " << std::setw(width) << vec.y << ", " << std::setw(width) << vec.z << "}"; + return stream; +} + +Vec3i::Vec3i(int32_t xv, int32_t yv, int32_t zv) : x(xv), y(yv), z(zv) {} + +std::ostream& operator<< (std::ostream& stream, const Vec3i& vec) { + int width = stream.width(); + + stream << std::setw(0) << "{" << std::setw(width) << vec.x << ", " << std::setw(width) << vec.y << ", " << std::setw(width) << vec.z << "}"; + return stream; +} + +Vec2f::Vec2f(float xv, float zv) : x(xv), z(zv) {} + +std::ostream& operator<< (std::ostream& stream, const Vec2f& vec) { + int width = stream.width(); + + stream << std::setw(0) << "{" << std::setw(width) << vec.x << ", " << std::setw(width) << vec.z << "}"; + return stream; +} + +Vec4f::Vec4f(float xv, float yv, float zv, float wv) : x(xv), y(yv), z(zv), w(wv) {} + +std::ostream& operator<< (std::ostream& stream, const Vec4f& vec) { + int width = stream.width(); + + stream << std::setw(0) << "{" << std::setw(width) << vec.x << ", " << std::setw(width) << vec.y << ", " << std::setw(width) << vec.z << ", " << std::setw(width) << vec.w << "}"; + return stream; +} + +Vec4s::Vec4s(int16_t xv, int16_t yv, int16_t zv, int16_t wv) : x(xv), y(yv), z(zv), w(wv) {} + +std::ostream& operator<< (std::ostream& stream, const Vec4s& vec) { + int width = stream.width(); + + stream << std::setw(0) << "{" << std::setw(width) << vec.x << ", " << std::setw(width) << vec.y << ", " << std::setw(width) << vec.z << ", " << std::setw(width) << vec.w << "}"; + return stream; +} diff --git a/src/types/Vec3D.h b/src/types/Vec3D.h new file mode 100644 index 0000000..e861f12 --- /dev/null +++ b/src/types/Vec3D.h @@ -0,0 +1,64 @@ +#pragma once + +#include "../factories/BaseFactory.h" + +class Vec3f : public IParsedData { +public: + float x; + float y; + float z; + + Vec3f(float xv = 0, float yv = 0, float zv = 0); + friend std::ostream& operator<< (std::ostream& stream, const Vec3f& vec); +}; + +class Vec3s : public IParsedData { +public: + int16_t x; + int16_t y; + int16_t z; + + Vec3s(int16_t xv = 0, int16_t yv = 0, int16_t zv = 0); + friend std::ostream& operator<< (std::ostream& stream, const Vec3s& vec); +}; + +class Vec3i : public IParsedData { +public: + int32_t x; + int32_t y; + int32_t z; + + Vec3i(int32_t xv = 0, int32_t yv = 0, int32_t zv = 0); + friend std::ostream& operator<< (std::ostream& stream, const Vec3i& vec); +}; + +class Vec2f : public IParsedData { +public: + float x; + float z; + + Vec2f(float xv = 0, float zv = 0); + friend std::ostream& operator<< (std::ostream& stream, const Vec2f& vec); +}; + +class Vec4f : public IParsedData { +public: + float x; + float y; + float z; + float w; + + Vec4f(float xv = 0, float yv = 0, float zv = 0, float wv = 0); + friend std::ostream& operator<< (std::ostream& stream, const Vec4f& vec); +}; + +class Vec4s : public IParsedData { +public: + int16_t x; + int16_t y; + int16_t z; + int16_t w; + + Vec4s(int16_t xv = 0, int16_t yv = 0, int16_t zv = 0, int16_t wv = 0); + friend std::ostream& operator<< (std::ostream& stream, const Vec4s& vec); +};
\ No newline at end of file |
