2021-10-13 16:40:06 +00:00
|
|
|
#ifndef _CAMERA_H
|
|
|
|
#define _CAMERA_H
|
|
|
|
|
2021-11-17 22:25:52 +00:00
|
|
|
#include "Matrixf.h"
|
|
|
|
#include "Vector3.h"
|
2021-10-13 16:40:06 +00:00
|
|
|
#include "types.h"
|
2021-11-17 22:25:52 +00:00
|
|
|
#include "Container.h"
|
|
|
|
#include "Plane.h"
|
2022-08-06 05:33:13 +00:00
|
|
|
#include "System.h"
|
|
|
|
#include "Game/P2JST/ObjectCamera.h"
|
2021-10-13 16:40:06 +00:00
|
|
|
|
2021-11-17 22:25:52 +00:00
|
|
|
namespace Game {
|
2021-11-17 23:09:12 +00:00
|
|
|
namespace P2JST {
|
2022-01-04 13:51:21 +00:00
|
|
|
struct ObjectCamera;
|
2022-10-26 00:12:41 +00:00
|
|
|
}
|
2021-11-17 23:09:12 +00:00
|
|
|
} // namespace Game
|
2022-07-25 14:34:09 +00:00
|
|
|
|
2021-10-13 23:59:32 +00:00
|
|
|
namespace Sys {
|
|
|
|
struct Sphere;
|
2021-11-24 02:43:50 +00:00
|
|
|
struct Cylinder;
|
2021-10-13 23:59:32 +00:00
|
|
|
} // namespace Sys
|
|
|
|
|
2022-07-25 14:34:09 +00:00
|
|
|
// Size: 0x28
|
2021-11-17 22:25:52 +00:00
|
|
|
struct CullPlane : public ArrayContainer<Plane> {
|
2022-08-06 05:33:13 +00:00
|
|
|
|
|
|
|
// needed for Camera ctor
|
2023-09-16 07:55:31 +00:00
|
|
|
CullPlane(int a);
|
2022-07-25 14:34:09 +00:00
|
|
|
|
2022-07-25 15:01:24 +00:00
|
|
|
virtual ~CullPlane() { } // _08 (weak)
|
|
|
|
virtual void writeObject(Stream&, Plane&) {}; // _2C (weak)
|
|
|
|
virtual void readObject(Stream&, Plane&) {}; // _30 (weak)
|
2022-07-25 14:34:09 +00:00
|
|
|
|
2022-09-15 03:00:12 +00:00
|
|
|
bool isPointVisible(Vector3f&, f32);
|
2021-11-24 02:43:50 +00:00
|
|
|
bool isVisible(Sys::Sphere&);
|
|
|
|
bool isCylinderVisible(Sys::Cylinder&);
|
2021-11-17 22:25:52 +00:00
|
|
|
};
|
|
|
|
|
2022-07-25 14:34:09 +00:00
|
|
|
// Size: 0x34
|
2021-11-17 22:25:52 +00:00
|
|
|
struct CullFrustum : public CullPlane {
|
2022-08-06 06:14:49 +00:00
|
|
|
|
2022-08-06 05:33:13 +00:00
|
|
|
// needed for Camera ctor
|
2023-09-16 07:55:31 +00:00
|
|
|
CullFrustum(int a);
|
2022-07-25 14:34:09 +00:00
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
virtual ~CullFrustum() { } // _08
|
|
|
|
virtual Matrixf* getViewMatrix(bool) { return mViewMatrix; } // _48 (weak)
|
|
|
|
virtual Vector3f getPosition(); // _4C
|
|
|
|
virtual void updatePlanes(); // _50
|
2021-11-17 22:25:52 +00:00
|
|
|
|
2021-11-24 02:43:50 +00:00
|
|
|
Vector3f getSideVector();
|
|
|
|
Vector3f getUpVector();
|
|
|
|
Vector3f getViewVector();
|
2021-11-17 22:25:52 +00:00
|
|
|
|
2024-05-26 12:13:32 +00:00
|
|
|
inline f32 getFOV(f32 viewAngle) { return (f32)atan(mAspectRatio * (f32)tan(viewAngle)); }
|
|
|
|
|
2022-07-25 14:34:09 +00:00
|
|
|
// CullPlane _00 - _24
|
2023-01-25 21:50:15 +00:00
|
|
|
f32 mViewAngle; // _28
|
|
|
|
f32 mAspectRatio; // _2C
|
|
|
|
Matrixf* mViewMatrix; // _30
|
2021-11-17 22:25:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Size: 0x144
|
|
|
|
struct Camera : public CullFrustum {
|
2021-10-13 23:59:32 +00:00
|
|
|
Camera();
|
2022-07-25 14:34:09 +00:00
|
|
|
|
2024-05-26 12:13:32 +00:00
|
|
|
virtual ~Camera() { } // _08 (weak)
|
|
|
|
virtual Matrixf* getViewMatrix(bool); // _48
|
|
|
|
virtual Vector3f getPosition(); // _4C
|
|
|
|
virtual void updatePlanes(); // _50
|
|
|
|
virtual void updateScreenConstants(); // _54
|
|
|
|
virtual Vector3f getLookAtPosition_() // _58 (weak)
|
|
|
|
{
|
|
|
|
return Vector3f::zero;
|
|
|
|
}
|
2023-09-22 01:48:11 +00:00
|
|
|
virtual f32 getTargetDistance() { return 0.0f; } // _5C (weak)
|
2022-08-06 12:15:03 +00:00
|
|
|
virtual Vector3f* getPositionPtr(); // _60
|
|
|
|
virtual Vector3f* on_getPositionPtr() { return nullptr; } // _64 (weak)
|
|
|
|
virtual Vector3f* getSoundPositionPtr() // _68 (weak)
|
2022-07-25 14:34:09 +00:00
|
|
|
{
|
2023-01-25 21:50:15 +00:00
|
|
|
return &mSoundPosition;
|
2021-12-12 02:42:06 +00:00
|
|
|
}
|
2022-07-25 15:01:24 +00:00
|
|
|
virtual Matrixf* getSoundMatrixPtr() // _6C (weak)
|
|
|
|
{
|
2023-01-25 21:50:15 +00:00
|
|
|
return &mSoundMatrix;
|
2021-12-12 02:42:06 +00:00
|
|
|
}
|
2023-09-22 01:48:11 +00:00
|
|
|
virtual bool isSpecialCamera() { return false; } // _70 (weak)
|
|
|
|
virtual void updateMatrix() { } // _74 (weak)
|
2024-01-12 09:20:52 +00:00
|
|
|
virtual void doUpdate() { } // _78 (weak)
|
2021-10-13 23:59:32 +00:00
|
|
|
|
2022-12-31 19:49:58 +00:00
|
|
|
f32 calcProperDistance(f32, f32);
|
2022-09-15 03:00:12 +00:00
|
|
|
f32 calcScreenSize(Sys::Sphere&);
|
2021-10-13 23:59:32 +00:00
|
|
|
void copyFrom(Camera*);
|
2022-09-15 03:00:12 +00:00
|
|
|
f32 getFar();
|
2021-11-24 02:43:50 +00:00
|
|
|
Vector3f getLookAtPosition();
|
2022-09-15 03:00:12 +00:00
|
|
|
f32 getNear();
|
2024-04-17 14:34:19 +00:00
|
|
|
void setFixNearFar(bool isFixed, f32 nearZ, f32 farZ);
|
2021-10-13 23:59:32 +00:00
|
|
|
void setProjection();
|
|
|
|
void update();
|
2022-09-15 03:00:12 +00:00
|
|
|
void updateSoundCamera(f32);
|
2021-11-17 22:25:52 +00:00
|
|
|
|
2023-01-25 21:50:15 +00:00
|
|
|
inline bool isRunning() { return (mJstObject && mJstObject->isRunning()); }
|
2022-08-06 06:14:49 +00:00
|
|
|
|
2023-09-02 00:02:11 +00:00
|
|
|
inline void setProjectionNearFar(f32 near, f32 far)
|
|
|
|
{
|
|
|
|
mProjectionNear = near;
|
|
|
|
mProjectionFar = far;
|
|
|
|
}
|
|
|
|
|
2021-11-17 22:25:52 +00:00
|
|
|
// CullFrustum _00 - _34
|
2023-01-25 21:50:15 +00:00
|
|
|
Matrixf mCurViewMatrix; // _034
|
|
|
|
f32 mNear; // _064 - distance to 'near' plane
|
|
|
|
f32 mFar; // _068 - distance to 'far' plane
|
2024-04-26 20:20:42 +00:00
|
|
|
bool mIsFixed; // _06C - determines which near/far values should be used
|
2023-01-25 21:50:15 +00:00
|
|
|
f32 mProjectionNear; // _070 - projected distance to 'near' plane when not in fixed camera
|
|
|
|
f32 mProjectionFar; // _074 - projected distance to 'far' plane when not in fixed camera
|
|
|
|
Vector3f mSoundPosition; // _078
|
|
|
|
Matrixf mSoundMatrix; // _084
|
|
|
|
Mtx44 mProjectionMtx; // _0B4
|
2024-04-26 20:20:42 +00:00
|
|
|
Mtx44 mBackupMtx; // _0F4
|
|
|
|
f32 mFieldOfViewRatio; // _134, from 0.0 when FOV is 0, to 1.0 when FOV is 180
|
|
|
|
f32 mFieldOfViewTangent; // _138, tangent from cos/sin of mFieldOfViewRatio
|
|
|
|
f32 mCameraSizeModifier; // _13C, used for detecting when things are far away? Stays very close to -0.5
|
2023-01-25 21:50:15 +00:00
|
|
|
Game::P2JST::ObjectCamera* mJstObject; // _140
|
2021-11-17 22:25:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LookAtCamera : public Camera {
|
2021-12-06 00:22:31 +00:00
|
|
|
LookAtCamera();
|
2022-08-06 12:15:03 +00:00
|
|
|
|
2023-09-22 01:48:11 +00:00
|
|
|
virtual ~LookAtCamera() { } // _08 (weak)
|
|
|
|
virtual Vector3f getLookAtPosition_() { return mLookAtPosition; } // _58 (weak)
|
|
|
|
virtual Vector3f* on_getPositionPtr() { return &mPosition; } // _64 (weak)
|
|
|
|
virtual void updateMatrix(); // _74
|
2023-11-17 04:50:02 +00:00
|
|
|
virtual void startVibration(int) { } // _7C (weak)
|
2021-11-17 22:25:52 +00:00
|
|
|
|
2024-06-01 01:37:03 +00:00
|
|
|
inline void setPosition(Vector3f& pos) { mPosition = pos; }
|
|
|
|
|
2022-07-25 14:34:09 +00:00
|
|
|
// Camera _00 - _144
|
2023-07-21 04:33:52 +00:00
|
|
|
Matrixf mLookMatrix; // _144
|
|
|
|
Vector3f mPosition; // _174
|
|
|
|
Vector3f mLookAtPosition; // _180
|
2023-12-31 12:07:54 +00:00
|
|
|
Vector3f mLookAtRotation; // _18C
|
2021-10-13 16:40:06 +00:00
|
|
|
};
|
|
|
|
|
2022-01-16 01:57:14 +00:00
|
|
|
struct BlendCamera : public Camera {
|
2022-09-15 03:00:12 +00:00
|
|
|
BlendCamera(int, Camera**);
|
2022-01-16 01:57:14 +00:00
|
|
|
|
2022-08-06 12:15:03 +00:00
|
|
|
virtual ~BlendCamera() { } // _08 (weak)
|
2024-01-12 09:20:52 +00:00
|
|
|
virtual void doUpdate(); // _78
|
2022-01-16 01:57:14 +00:00
|
|
|
|
2022-09-15 03:00:12 +00:00
|
|
|
void setBlendFactor(f32);
|
2022-01-16 01:57:14 +00:00
|
|
|
void setCameras(Camera**);
|
|
|
|
|
2022-07-25 14:34:09 +00:00
|
|
|
// Camera _00 - _144
|
2023-12-31 12:07:54 +00:00
|
|
|
int mCameraCount; // _144
|
|
|
|
Camera** mCameras; // _148
|
|
|
|
f32 mBlendFactor; // _14C
|
|
|
|
Matrixf mTargetMatrix; // _150
|
2022-01-16 01:57:14 +00:00
|
|
|
};
|
|
|
|
|
2022-08-06 12:15:03 +00:00
|
|
|
namespace PSM {
|
2023-01-16 20:23:01 +00:00
|
|
|
extern f32 sCamFov;
|
2022-08-06 12:15:03 +00:00
|
|
|
}
|
|
|
|
|
2021-10-14 19:43:06 +00:00
|
|
|
#endif
|