Skip to content

Commit 68828f1

Browse files
committed
free camera overhaul, no more blackbars
1 parent a5257e9 commit 68828f1

23 files changed

+440
-65
lines changed

MKXHook/MKXHook.rc

0 Bytes
Binary file not shown.

MKXHook/MKXHook.vcxproj

+8
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,20 @@
140140
<ClInclude Include="code\eSettingsManager.h" />
141141
<ClInclude Include="code\GameInfo.h" />
142142
<ClInclude Include="code\helper\eKeyboardMan.h" />
143+
<ClInclude Include="code\helper\eMath.h" />
144+
<ClInclude Include="code\helper\eMouse.h" />
143145
<ClInclude Include="code\mk10.h" />
144146
<ClInclude Include="code\mk10menu.h" />
145147
<ClInclude Include="code\mk10utils.h" />
146148
<ClInclude Include="code\MKCamera.h" />
147149
<ClInclude Include="code\MKCharacter.h" />
148150
<ClInclude Include="code\MKStructs.h" />
149151
<ClInclude Include="code\PlayerInfo.h" />
152+
<ClInclude Include="code\unreal\FMath.h" />
150153
<ClInclude Include="code\unreal\FMatrix.h" />
151154
<ClInclude Include="code\unreal\FName.h" />
155+
<ClInclude Include="code\unreal\FQuat.h" />
156+
<ClInclude Include="code\unreal\FRotator.h" />
152157
<ClInclude Include="code\unreal\FVector.h" />
153158
<ClInclude Include="eDirectX11Hook.h" />
154159
<ClInclude Include="font.h" />
@@ -181,12 +186,15 @@
181186
<ClCompile Include="code\eSettingsManager.cpp" />
182187
<ClCompile Include="code\GameInfo.cpp" />
183188
<ClCompile Include="code\helper\eKeyboardMan.cpp" />
189+
<ClCompile Include="code\helper\eMath.cpp" />
190+
<ClCompile Include="code\helper\eMouse.cpp" />
184191
<ClCompile Include="code\mk10.cpp" />
185192
<ClCompile Include="code\mk10menu.cpp" />
186193
<ClCompile Include="code\mk10utils.cpp" />
187194
<ClCompile Include="code\MKCamera.cpp" />
188195
<ClCompile Include="code\MKCharacter.cpp" />
189196
<ClCompile Include="code\PlayerInfo.cpp" />
197+
<ClCompile Include="code\unreal\FMath.cpp" />
190198
<ClCompile Include="code\unreal\FMatrix.cpp" />
191199
<ClCompile Include="code\unreal\FName.cpp" />
192200
<ClCompile Include="dllmain.cpp" />

MKXHook/MKXHook.vcxproj.filters

+24
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@
156156
<ClInclude Include="code\helper\eKeyboardMan.h">
157157
<Filter>Header Files\code\helper</Filter>
158158
</ClInclude>
159+
<ClInclude Include="code\unreal\FRotator.h">
160+
<Filter>Header Files\code\unreal</Filter>
161+
</ClInclude>
162+
<ClInclude Include="code\unreal\FMath.h">
163+
<Filter>Header Files\code\unreal</Filter>
164+
</ClInclude>
165+
<ClInclude Include="code\helper\eMath.h">
166+
<Filter>Header Files\code\helper</Filter>
167+
</ClInclude>
168+
<ClInclude Include="code\helper\eMouse.h">
169+
<Filter>Header Files\code\helper</Filter>
170+
</ClInclude>
171+
<ClInclude Include="code\unreal\FQuat.h">
172+
<Filter>Header Files\code\unreal</Filter>
173+
</ClInclude>
159174
</ItemGroup>
160175
<ItemGroup>
161176
<ClCompile Include="dllmain.cpp">
@@ -248,6 +263,15 @@
248263
<ClCompile Include="code\helper\eKeyboardMan.cpp">
249264
<Filter>Header Files\code\helper</Filter>
250265
</ClCompile>
266+
<ClCompile Include="code\unreal\FMath.cpp">
267+
<Filter>Header Files\code\unreal</Filter>
268+
</ClCompile>
269+
<ClCompile Include="code\helper\eMath.cpp">
270+
<Filter>Header Files\code\helper</Filter>
271+
</ClCompile>
272+
<ClCompile Include="code\helper\eMouse.cpp">
273+
<Filter>Header Files\code\helper</Filter>
274+
</ClCompile>
251275
</ItemGroup>
252276
<ItemGroup>
253277
<ResourceCompile Include="MKXHook.rc">

MKXHook/code/MKCamera.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,10 @@ void MKCamera::HookedSetRotation(FRotator * rot)
288288
}
289289
}
290290

291+
FMatrix MKCamera::GetMatrix()
292+
{
293+
FRotator rot = *(FRotator*)(this + 0x420);
294+
FMatrix mat(&rot);
295+
return mat;
296+
}
297+

MKXHook/code/MKCamera.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22
#include "mk10.h"
3-
3+
#include "unreal/FMatrix.h"
44
// generic layer for other plugins too
55
class MKCamera {
66
public:
@@ -11,6 +11,8 @@ class MKCamera {
1111

1212
void HookedSetPosition(FVector* pos);
1313
void HookedSetRotation(FRotator* rot);
14+
15+
FMatrix GetMatrix();
1416
};
1517

1618
extern MKCamera* TheCamera;

MKXHook/code/MKStructs.h

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
#pragma once
2-
3-
4-
struct FRotator
5-
{
6-
int Pitch;
7-
int Yaw;
8-
int Roll;
9-
};
10-
11-
2+
#include "unreal/FRotator.h"
123
struct FLinearColor
134
{
145
float A;

MKXHook/code/eSettingsManager.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ void eSettingsManager::Init()
1616
bEnable60FPSFrontend = ini.ReadBoolean("Settings", "bEnable60FPSPatch", true);
1717
bDisableSweatEffects = ini.ReadBoolean("Settings", "bDisableSweatEffects", false);
1818
bEnableGamepadSupport = ini.ReadBoolean("Settings", "bEnableGamepadSupport", true);
19+
bDisableCinematicLetterboxing = ini.ReadBoolean("Settings", "bDisableCinematicLetterboxing", false);
1920

2021
iToggleCustomCamKey = user.ReadInteger("Settings", "iToggleCustomCamKey", 0);
2122

@@ -100,6 +101,11 @@ void eSettingsManager::Init()
100101
if (fMenuScale < 1.0f)
101102
fMenuScale = 1.0f;
102103

104+
105+
mouse.sens = user.ReadInteger("Mouse", "Sensitivity", 10);
106+
mouse.invert_y = user.ReadBoolean("Mouse", "InvertY", false);
107+
mouse.invert_x = user.ReadBoolean("Mouse", "InvertX", false);
108+
103109
}
104110

105111
void eSettingsManager::SaveSettings()
@@ -123,6 +129,9 @@ void eSettingsManager::SaveSettings()
123129
user.WriteInteger("Settings", "iFreeCameraKeyFOVPlus", iFreeCameraKeyFOVPlus);
124130
user.WriteInteger("Settings", "iFreeCameraKeyFOVMinus", iFreeCameraKeyFOVMinus);
125131
user.WriteInteger("Settings", "iResetStageInteractablesKey", iResetStageInteractablesKey);
132+
user.WriteInteger("Mouse", "Sensitivity", mouse.sens);
133+
user.WriteBoolean("Mouse", "InvertY", mouse.invert_y);
134+
user.WriteBoolean("Mouse", "InvertX", mouse.invert_x);
126135

127136
CIniReader ini("");
128137
ini.WriteBoolean("Settings", "bEnableGamepadSupport", bEnableGamepadSupport);
@@ -133,6 +142,7 @@ void eSettingsManager::SaveSettings()
133142
ini.WriteBoolean("Settings", "bFixNPCGenderFatalityMessage", bFixNPCGenderFatalityMessage);
134143
ini.WriteBoolean("Settings", "bEnableNPCVictoryPoses", bEnableNPCVictoryPoses);
135144
ini.WriteBoolean("Settings", "bEnableNPCFatalities", bEnableNPCFatalities);
145+
ini.WriteBoolean("Settings", "bDisableCinematicLetterboxing", bDisableCinematicLetterboxing);
136146

137147
}
138148

MKXHook/code/eSettingsManager.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
// as usual, pluginmh/mugenhook
55

6+
struct eMouseSettings {
7+
int sens;
8+
bool invert_y;
9+
bool invert_x;
10+
};
11+
612
class eSettingsManager {
713
public:
814
void Init();
@@ -14,7 +20,7 @@ class eSettingsManager {
1420
bool bEnableConsoleWindow;
1521
bool bDisableSweatEffects;
1622
bool bEnableNPCVictoryPoses;
17-
23+
bool bDisableCinematicLetterboxing;
1824
bool bEnableGamepadSupport;
1925

2026
int iHookMenuOpenKey;
@@ -41,6 +47,7 @@ class eSettingsManager {
4147
int iFreeCameraKeyFOVMinus;
4248

4349

50+
eMouseSettings mouse;
4451

4552
float fMenuScale;
4653

MKXHook/code/helper/eMath.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include "eMath.h"
2+
3+
FVector eMath::quat2vec(FQuat q)
4+
{
5+
FVector result;
6+
7+
float ysqr = q.Y * q.Y;
8+
9+
float t0 = +2.0f * (q.W * q.X + q.Y * q.Z);
10+
float t1 = +1.0f - 2.0f * (q.X * q.X + ysqr);
11+
float roll = atan2(t0, t1);
12+
13+
float t2 = +2.0f * (q.W * q.Y - q.Z * q.X);
14+
t2 = ((t2 > 1.0f) ? 1.0f : t2);
15+
t2 = ((t2 < -1.0f) ? -1.0f : t2);
16+
17+
float pitch = asin(t2);
18+
float t3 = +2.0f * (q.W * q.Z + q.X * q.Y);
19+
float t4 = +1.0f - 2.0f * (ysqr + q.Z * q.Z);
20+
float yaw = atan2(t3, t4);
21+
22+
result.X = roll / M_PI * 180;
23+
result.Y = pitch / M_PI * 180;
24+
result.Z = yaw / M_PI * 180;
25+
return result;
26+
}
27+
28+
bool eMath::areVecsEqual(FVector v1, FVector v2)
29+
{
30+
if (fabs(v1.X - v2.X) < 0.1f &&
31+
(fabs(v1.Y - v2.Y) < 0.1f) &&
32+
(fabs(v1.Z - v2.Z) < 0.1f))
33+
return true;
34+
else
35+
return false;
36+
}

MKXHook/code/helper/eMath.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
#include "..\unreal\FVector.h"
3+
#include "..\unreal\FQuat.h"
4+
5+
#include <math.h>
6+
#define M_PI 3.14159265358979323846f
7+
8+
#define degToRad(angleInDegrees) ((angleInDegrees) * M_PI / 180.0)
9+
#define radToDeg(angleInRadians) ((angleInRadians) * 180.0 / M_PI)
10+
11+
class eMath {
12+
public:
13+
static FVector quat2vec(FQuat q);
14+
static bool areVecsEqual(FVector v1, FVector v2);
15+
};

MKXHook/code/helper/eMouse.cpp

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#include "eMouse.h"
2+
#include <Windows.h>
3+
#include <iostream>
4+
#include "../../eDirectX11Hook.h"
5+
#include "../mk10menu.h"
6+
#include "../eSettingsManager.h"
7+
8+
eMouse eMouse::mouse;
9+
10+
eMouse::eMouse()
11+
{
12+
Clear();
13+
}
14+
15+
void eMouse::Clear()
16+
{
17+
x = 0;
18+
y = 0;
19+
deltaX = 0;
20+
deltaY = 0;
21+
gotDelta = false;
22+
}
23+
24+
void eMouse::UpdateMouse()
25+
{
26+
if (!TheMenu->m_bIsActive && TheMenu->m_bMouseControl && TheMenu->m_bIsFocused)
27+
{
28+
mouse.Clear();
29+
POINT point;
30+
GetCursorPos(&point);
31+
32+
if (!mouse.gotDelta)
33+
{
34+
eMouse::LockMouse();
35+
mouse.gotDelta = true;
36+
}
37+
38+
POINT center;
39+
GetCursorPos(&center);
40+
41+
mouse.deltaX = point.x - center.x;
42+
mouse.deltaY = point.y - center.y;
43+
mouse.deltaX *= SettingsMgr->mouse.sens;
44+
mouse.deltaY *= SettingsMgr->mouse.sens;
45+
mouse.gotDelta = false;
46+
}
47+
}
48+
49+
50+
int eMouse::GetDeltaX()
51+
{
52+
return SettingsMgr->mouse.invert_x ? -mouse.deltaX : mouse.deltaX;
53+
}
54+
55+
int eMouse::GetDeltaY()
56+
{
57+
return SettingsMgr->mouse.invert_y ? mouse.deltaY : -mouse.deltaY;
58+
}
59+
60+
void eMouse::LockMouse()
61+
{
62+
if (eDirectX11Hook::ms_hWindow)
63+
{
64+
RECT rect;
65+
GetWindowRect(eDirectX11Hook::ms_hWindow, &rect);
66+
67+
SetCursorPos(rect.right / 2, rect.bottom / 2);
68+
}
69+
}

MKXHook/code/helper/eMouse.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
class eMouse {
4+
public:
5+
int x;
6+
int y;
7+
8+
int deltaX;
9+
int deltaY;
10+
bool gotDelta;
11+
12+
eMouse();
13+
14+
void Clear();
15+
16+
static void UpdateMouse();
17+
18+
static eMouse mouse;
19+
20+
21+
static int GetDeltaX();
22+
static int GetDeltaY();
23+
24+
static void LockMouse();
25+
};
26+

0 commit comments

Comments
 (0)