2019-12-02 14:49:19 +01:00
|
|
|
#include "camera.h"
|
2018-08-19 09:46:58 +02:00
|
|
|
#include <d3d9.h>
|
|
|
|
#include <d3dx9.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "draw.h"
|
2019-12-15 16:19:01 +01:00
|
|
|
|
|
|
|
extern int KeyTriggerActive;
|
|
|
|
|
|
|
|
void ActivateCamera()
|
|
|
|
{
|
|
|
|
KeyTriggerActive = 2;
|
|
|
|
}
|
|
|
|
|
2019-12-13 13:52:47 +01:00
|
|
|
void LookAt(int posX, int posY, int posZ, int targetX, int targetY, int targetZ, short roll)
|
2018-08-19 09:46:58 +02:00
|
|
|
{
|
2019-01-13 21:57:16 +01:00
|
|
|
Vector3 position = Vector3(posX, posY, posZ);
|
|
|
|
Vector3 target = Vector3(targetX, targetY, targetZ);
|
|
|
|
Vector3 up = Vector3(0.0f, -1.0f, 0.0f);
|
2019-12-11 07:40:47 +01:00
|
|
|
float fov = TR_ANGLE_TO_RAD(CurrentFOV / 1.333333f);
|
2019-05-31 21:45:13 +02:00
|
|
|
float r = TR_ANGLE_TO_RAD(roll);
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2019-05-31 21:45:13 +02:00
|
|
|
g_Renderer->UpdateCameraMatrices(posX, posY, posZ, targetX, targetY, targetZ, r, fov);
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void AlterFOV(int value)
|
2019-01-13 21:57:16 +01:00
|
|
|
{
|
2019-12-18 00:25:19 -03:00
|
|
|
if (SIN(value / 2) == 0) return; /* @FIXME Integer division by zero */
|
|
|
|
|
2018-08-19 09:46:58 +02:00
|
|
|
CurrentFOV = value;
|
2018-11-06 23:01:00 +01:00
|
|
|
PhdPerspective = PhdWidth / 2 * COS(CurrentFOV / 2) / SIN(CurrentFOV / 2);
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Inject_Camera()
|
|
|
|
{
|
2019-05-31 21:45:13 +02:00
|
|
|
INJECT(0x0048EDC0, AlterFOV);
|
|
|
|
INJECT(0x0048F760, LookAt);
|
2018-08-19 09:46:58 +02:00
|
|
|
}
|