summaryrefslogtreecommitdiff
path: root/include/egg
diff options
context:
space:
mode:
authorelijah-thomas774 <elijahthomas774@gmail.com>2025-03-21 19:38:30 -0400
committerelijah-thomas774 <elijahthomas774@gmail.com>2025-03-21 19:38:30 -0400
commit00ececa0b583cc7893d37898beab2d2ae3f36b7a (patch)
tree5c555b824933896d07e71748f76743538e328abf /include/egg
parentb6505d23ad73d1f0a32ef23dd57f85092a0e2745 (diff)
Egg Camera a small bit closer
Diffstat (limited to 'include/egg')
-rw-r--r--include/egg/gfx/eggCamera.h23
-rw-r--r--include/egg/math/eggRotation.h50
-rw-r--r--include/egg/math/eggVector.h26
3 files changed, 72 insertions, 27 deletions
diff --git a/include/egg/gfx/eggCamera.h b/include/egg/gfx/eggCamera.h
index 220d91c7..c3104fb7 100644
--- a/include/egg/gfx/eggCamera.h
+++ b/include/egg/gfx/eggCamera.h
@@ -2,6 +2,7 @@
#define EGG_CAMERA_H
#include "egg/math/eggMatrix.h"
+#include "egg/math/eggRotation.h"
#include "egg/math/eggVector.h"
#include "nw4r/g3d/g3d_camera.h"
@@ -10,7 +11,6 @@ namespace EGG {
class BaseCamera {
public:
BaseCamera() {}
- // Which way around?
virtual Matrix34f &getViewMatrix() = 0;
virtual const Matrix34f &getViewMatrix() const = 0;
virtual void updateMatrix();
@@ -23,11 +23,18 @@ public:
virtual Matrix34f &getViewMatrixOld() = 0;
void setG3DCamera(nw4r::g3d::Camera &);
+ // Vector3f getRightVector();
+ // Vector3f getLookVector();
+ // Vector3f getUpVector();
+
+protected:
+ /* 0x04 */ Matrix34f mViewMtx;
+ /* 0x34 */ Matrix34f mOtherMtx;
};
class LookAtCamera : public BaseCamera {
public:
- LookAtCamera() : mPosition(0.0f, 10.0f, 0.0f), mRight(0.0f, 0.0f, 0.0f), mUp(0.0f, 1.0f, 0.0f) {}
+ LookAtCamera() : mPos(0.0f, 10.0f, 0.0f), mAt(0.0f, 0.0f, 0.0f), mUp(0.0f, 1.0f, 0.0f) {}
// Which way around?
virtual Matrix34f &getViewMatrix() override {
return mViewMtx;
@@ -40,17 +47,15 @@ public:
virtual void loadMatrix() override;
virtual void loadOldMatrix() override;
virtual EGG::Vector3f getPosition() override {
- return mPosition;
+ return mPos;
}
virtual void doDraw() override;
virtual Matrix34f &getViewMatrixOld() override;
protected:
- /* 0x04 */ Matrix34f mViewMtx;
- /* 0x34 */ Matrix34f mOtherMtx;
- /* 0x64 */ Vector3f mPosition;
- /* 0x70 */ Vector3f mRight;
+ /* 0x64 */ Vector3f mPos;
+ /* 0x70 */ Vector3f mAt;
/* 0x7C */ Vector3f mUp;
};
@@ -63,8 +68,8 @@ public:
private:
void update_parms();
- /* 0x88 */ f32 field_0x88;
- /* 0x8C */ f32 field_0x8C;
+ /* 0x88 */ EGG::Rotation<f32> field_0x88;
+ /* 0x8C */ EGG::Rotation<f32> field_0x8C;
};
} // namespace EGG
diff --git a/include/egg/math/eggRotation.h b/include/egg/math/eggRotation.h
new file mode 100644
index 00000000..97910e97
--- /dev/null
+++ b/include/egg/math/eggRotation.h
@@ -0,0 +1,50 @@
+#ifndef EGG_ROTATION_H
+#define EGG_ROTATION_H
+
+#include "egg/math/eggMath.h"
+
+namespace EGG {
+
+template <typename T>
+struct Rotation {
+ Rotation() {}
+ Rotation(T val) : mRot(val) {}
+ Rotation(const Rotation &other) {
+ mRot = other.mRot;
+ }
+ Rotation &operator=(const Rotation &other) {
+ mRot = val;
+ return *this;
+ }
+ Rotation &operator=(T val) {
+ mRot = val;
+ return *this;
+ }
+
+ operator T() const {
+ return mRot;
+ }
+
+ Rotation &operator-=(T val) {
+ mRot -= val;
+ return *this;
+ }
+ Rotation &operator+=(T val) {
+ mRot -= val;
+ return *this;
+ }
+
+ const T cos() const {
+ return Math<T>::cos(*this);
+ }
+ const T sin() const {
+ return Math<T>::sin(*this);
+ }
+
+protected:
+ T mRot;
+};
+
+} // namespace EGG
+
+#endif
diff --git a/include/egg/math/eggVector.h b/include/egg/math/eggVector.h
index b0ac18c4..3fa0c871 100644
--- a/include/egg/math/eggVector.h
+++ b/include/egg/math/eggVector.h
@@ -3,25 +3,19 @@
#include "common.h"
#include "egg/math/eggMath.h"
+
#include "nw4r/math.h"
namespace EGG {
struct Vector3f : public nw4r::math::VEC3 {
- // __ct__Q23EGG8Vector3fFv
Vector3f() : nw4r::math::VEC3() {}
-
- // __ct__Q23EGG8Vector3fFfff
Vector3f(f32 fx, f32 fy, f32 fz) : VEC3(fx, fy, fz) {}
- // ~Vector3f() {}
-
- // __cl__Q23EGG8Vector3fFi
f32 &operator()(int i) {
return ((f32 *)this)[i];
}
- // __ml__Q23EGG8Vector3fCFf
Vector3f operator*(f32 f) const {
return Vector3f(x * f, y * f, z * f);
}
@@ -30,12 +24,10 @@ struct Vector3f : public nw4r::math::VEC3 {
return Vector3f(v.x * f, v.y * f, v.z * f);
}
- // __pl__Q23EGG8Vector3fCFRCQ23EGG8Vector3f
Vector3f operator+(const Vector3f &v) const {
return Vector3f(x + v.x, y + v.y, z + v.z);
}
- // __apl__Q23EGG8Vector3fFRCQ23EGG8Vector3f
Vector3f &operator+=(const Vector3f &v) {
x += v.x;
y += v.y;
@@ -43,7 +35,6 @@ struct Vector3f : public nw4r::math::VEC3 {
return *this;
}
- // __mi__Q23EGG8Vector3fCFv
Vector3f operator-() const {
f32 z = this->z;
f32 y = this->y;
@@ -51,12 +42,10 @@ struct Vector3f : public nw4r::math::VEC3 {
return Vector3f(-x, -y, -z);
}
- // __mi__Q23EGG8Vector3fCFRCQ23EGG8Vector3f
Vector3f operator-(const Vector3f &v) {
return Vector3f(x - v.x, y - v.y, z - v.z);
}
- // __ami__Q23EGG8Vector3fFRCQ23EGG8Vector3f
Vector3f &operator-=(const Vector3f &v) {
x -= v.x;
y -= v.y;
@@ -64,24 +53,20 @@ struct Vector3f : public nw4r::math::VEC3 {
return *this;
}
- // __amu__Q23EGG8Vector3fFf
Vector3f &operator*=(f32 f) {
multScalar(f);
return *this;
}
- // __dv__Q23EGG8Vector3fCFf
Vector3f operator/(f32 f) const {
return Vector3f(x / f, y / f, z / f);
}
- // __adv__Q23EGG8Vector3fCFf // assumed
Vector3f &operator/=(f32 f) {
divScalar(f);
return *this;
}
- // __ne__Q23EGG8Vector3fCFRCQ23EGG8Vector3f
bool operator!=(const Vector3f &v) {
return x != v.x || y != v.y || z != v.z;
}
@@ -101,12 +86,10 @@ struct Vector3f : public nw4r::math::VEC3 {
return EGG::Math<f32>::abs(EGG::Math<f32>::atan2(b, a));
}
- // dot__Q23EGG8Vector3fCFRCQ23EGG8Vector3f
f32 dot(const Vector3f &v) const {
return x * v.x + y * v.y + z * v.z;
}
- // cross__Q23EGG8Vector3fCFRCQ23EGG8Vector3f
Vector3f cross(const Vector3f &b) const {
f32 _x = (y * b.z) - (z * b.y);
f32 _y = (z * b.x) - (x * b.z);
@@ -126,6 +109,13 @@ struct Vector3f : public nw4r::math::VEC3 {
}
f32 normalise();
+
+ Vector3f normalize() {
+ Vector3f other(x, y, z);
+ other.normalise();
+ return other;
+ }
+
f32 setLength(const Vector3f &src, f32 len);
f32 setLength(f32 len);