pikmin2/include/Camera.h

164 lines
4.9 KiB
C
Raw Normal View History

2021-10-13 16:40:06 +00:00
#ifndef _CAMERA_H
#define _CAMERA_H
#include "Matrixf.h"
#include "Vector3.h"
2021-10-13 16:40:06 +00:00
#include "types.h"
#include "Container.h"
#include "Plane.h"
#include "System.h"
#include "Game/P2JST/ObjectCamera.h"
2021-10-13 16:40:06 +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
2021-10-13 23:59:32 +00:00
namespace Sys {
struct Sphere;
struct Cylinder;
2021-10-13 23:59:32 +00:00
} // namespace Sys
// Size: 0x28
struct CullPlane : public ArrayContainer<Plane> {
// needed for Camera ctor
2023-09-16 07:55:31 +00:00
CullPlane(int a);
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)
bool isPointVisible(Vector3f&, f32);
bool isVisible(Sys::Sphere&);
bool isCylinderVisible(Sys::Cylinder&);
};
// Size: 0x34
struct CullFrustum : public CullPlane {
2022-08-06 06:14:49 +00:00
// needed for Camera ctor
2023-09-16 07:55:31 +00:00
CullFrustum(int a);
virtual ~CullFrustum() { } // _08
virtual Matrixf* getViewMatrix(bool) { return mViewMatrix; } // _48 (weak)
virtual Vector3f getPosition(); // _4C
virtual void updatePlanes(); // _50
Vector3f getSideVector();
Vector3f getUpVector();
Vector3f getViewVector();
2024-05-26 12:13:32 +00:00
inline f32 getFOV(f32 viewAngle) { return (f32)atan(mAspectRatio * (f32)tan(viewAngle)); }
// CullPlane _00 - _24
f32 mViewAngle; // _28
f32 mAspectRatio; // _2C
Matrixf* mViewMatrix; // _30
};
// Size: 0x144
struct Camera : public CullFrustum {
2021-10-13 23:59:32 +00:00
Camera();
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)
{
return &mSoundPosition;
2021-12-12 02:42:06 +00:00
}
2022-07-25 15:01:24 +00:00
virtual Matrixf* getSoundMatrixPtr() // _6C (weak)
{
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);
f32 calcScreenSize(Sys::Sphere&);
2021-10-13 23:59:32 +00:00
void copyFrom(Camera*);
f32 getFar();
Vector3f getLookAtPosition();
f32 getNear();
void setFixNearFar(bool isFixed, f32 nearZ, f32 farZ);
2021-10-13 23:59:32 +00:00
void setProjection();
void update();
void updateSoundCamera(f32);
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;
}
// CullFrustum _00 - _34
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
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
Game::P2JST::ObjectCamera* mJstObject; // _140
};
struct LookAtCamera : public Camera {
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
virtual void startVibration(int) { } // _7C (weak)
2024-06-01 01:37:03 +00:00
inline void setPosition(Vector3f& pos) { mPosition = pos; }
// 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 {
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
void setBlendFactor(f32);
2022-01-16 01:57:14 +00:00
void setCameras(Camera**);
// 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 {
extern f32 sCamFov;
2022-08-06 12:15:03 +00:00
}
2021-10-14 19:43:06 +00:00
#endif