summaryrefslogtreecommitdiff
path: root/include/egg/gfx/eggCamera.h
blob: 67c3853d9264dffe86d40232535f27d49a34ece5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#ifndef EGG_CAMERA_H
#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"

namespace EGG {

class BaseCamera {
public:
    BaseCamera() {}
    virtual Matrix34f &getViewMatrix() = 0;
    virtual const Matrix34f &getViewMatrix() const = 0;
    virtual void updateMatrix();
    virtual void doUpdateMatrix() = 0;
    virtual void loadMatrix() = 0;
    virtual void loadOldMatrix() = 0;
    virtual EGG::Vector3f getPosition() = 0;
    virtual void draw(EGG::BaseCamera *cam);
    virtual void doDraw() = 0;
    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() : mPos(0.0f, 10.0f, 0.0f), mAt(0.0f, 0.0f, 0.0f), mUp(0.0f, 1.0f, 0.0f) {}
    
    LookAtCamera& operator=(const LookAtCamera &other) {
        mViewMtx.copyFrom(other.mViewMtx);
        mOtherMtx.copyFrom(other.mOtherMtx);
        mPos = other.mPos;
        mAt = other.mAt;
        mUp = other.mUp;
        return *this;
    }
    // Which way around?
    virtual Matrix34f &getViewMatrix() override {
        return mViewMtx;
    }
    virtual const Matrix34f &getViewMatrix() const override {
        return mViewMtx;
    }

    virtual void doUpdateMatrix() override;
    virtual void loadMatrix() override;
    virtual void loadOldMatrix() override;
    virtual EGG::Vector3f getPosition() override {
        return mPos;
    }

    virtual void doDraw() override;
    virtual Matrix34f &getViewMatrixOld() override;

    Vector3f getDirection() const {
        return mAt - mPos;
    }

    Vector3f getOtherDirection() const {
        return mPos - mAt;
    }

public:
    /* 0x64 */ Vector3f mPos;
    /* 0x70 */ Vector3f mAt;
    /* 0x7C */ Vector3f mUp;
};

class OrthoCamera : public LookAtCamera {
public:
    OrthoCamera();

    virtual void doUpdateMatrix() override;

private:
    void update_parms();

    /* 0x88 */ EGG::Rotation<f32> field_0x88;
    /* 0x8C */ EGG::Rotation<f32> field_0x8C;
};

} // namespace EGG

#endif