Skip to content

Commit

Permalink
FOV added
Browse files Browse the repository at this point in the history
  • Loading branch information
coltonon committed Nov 4, 2019
1 parent fd19980 commit eadcb60
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 9 deletions.
4 changes: 3 additions & 1 deletion OpenGameCamera/KeyMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,6 @@ KeyDef Keys::cameraRight = { "D", 0x44 };
KeyDef Keys::camerUp = { "SPACE", VK_SPACE };
KeyDef Keys::cameraDown = { "CONTROL", VK_CONTROL };
KeyDef Keys::disableUi = { "F7", VK_F7 };
KeyDef Keys::freezeTime = { "F8", VK_F8 };
KeyDef Keys::freezeTime = { "F8", VK_F8 };
KeyDef Keys::fovIncrease = { "+", VK_OEM_PLUS };
KeyDef Keys::fovDecrease = { "-", VK_OEM_MINUS };
3 changes: 2 additions & 1 deletion OpenGameCamera/KeyMan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <Windows.h>
#include <ctime>
#include <string>

// keyboard manager

// a key definition. Has the name of the key, and it's keycode
Expand All @@ -28,6 +27,8 @@ class Keys {
static KeyDef cameraDown;
static KeyDef disableUi;
static KeyDef freezeTime;
static KeyDef fovIncrease;
static KeyDef fovDecrease;
};


Expand Down
1 change: 0 additions & 1 deletion OpenGameCamera/OpenGameCamera.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
<ClCompile Include="minhook\hde\hde64.c" />
<ClCompile Include="minhook\hook.c" />
<ClCompile Include="minhook\trampoline.c" />
<ClCompile Include="Renderer.cpp" />
<ClCompile Include="SigScan\SigScan.cpp" />
<ClCompile Include="Source.cpp" />
</ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions OpenGameCamera/OpenGameCamera.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
<ClCompile Include="SigScan\SigScan.cpp">
<Filter>SigScan</Filter>
</ClCompile>
<ClCompile Include="Renderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="minhook\buffer.c">
<Filter>MinHook</Filter>
</ClCompile>
Expand Down
28 changes: 28 additions & 0 deletions OpenGameCamera/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Settings {
float mainSpeed = 0.1f;
float slowSpeed = .001f;
float fastSpeed = 2.f;
float fov = 55;
}

// global static variables
Expand Down Expand Up @@ -63,12 +64,21 @@ void buildMenu(Menu &menu) {
elemFreeze.type = Element::ElementType::checkBox;
elemFreeze.value = &Settings::freezeTime;


Element elemFovP;
elemFovP.text = "Increase FOV [" + Keys::fovIncrease.name + "]";

Element elemFovM;
elemFovM.text = "Decrease FOV [" + Keys::fovDecrease.name + "]";

// add them to the menu
menu.elements.push_back(elem1);
menu.elements.push_back(elem2);
menu.elements.push_back(elem3);
menu.elements.push_back(elemDisableUi);
menu.elements.push_back(elemFreeze);
menu.elements.push_back(elemFovP);
menu.elements.push_back(elemFovM);
}

// Camera Update function
Expand Down Expand Up @@ -113,6 +123,23 @@ void drawLoop(Renderer* pRenderer, uint32_t width, uint32_t height) {
mainMenu.draw(pRenderer);
}

// Set our FOV
if (Settings::enableFreeCam) {
float amount = .25f;
if (KeyMan::ReadKey(Keys::speedUpCamera)) amount = 1.f;
if (KeyMan::ReadKey(Keys::slowDownCamera)) amount = .05f;
if (KeyMan::ReadKeyOnce(Keys::fovIncrease, 25)) {
Settings::fov += amount;
}
if (KeyMan::ReadKeyOnce(Keys::fovDecrease, 25)) {
Settings::fov -= amount;
}
GameRenderer::GetInstance()->gameRenderSettings->forceFov = Settings::fov;
}
else {
GameRenderer::GetInstance()->gameRenderSettings->forceFov = -1;
}

// freeze time hotkey toggle
if (KeyMan::ReadKeyOnce(Keys::freezeTime, 100)) {
Settings::freezeTime = !Settings::freezeTime;
Expand Down Expand Up @@ -229,6 +256,7 @@ DWORD __stdcall mainThread(HMODULE hOwnModule)
// reset the timescale, and drawEnable
GameTimeSettings::GetInstance()->timeScale = 1.f;
UISettings::GetInstance()->drawEnable = true;
GameRenderer::GetInstance()->gameRenderSettings->forceFov = -1;

printf("Unhooking\n");
// now unhook everything we hooked
Expand Down
16 changes: 13 additions & 3 deletions OpenGameCamera/sdk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,28 @@ class RenderView;
class UISettings;
class GameTimeSettings;
class CameraObject;
class GameRenderSettings;


class GameRenderer {
public:
char pad[0x538];
RenderView* renderView;

char pad_0000[1304]; //0x0000
class GameRenderSettings* gameRenderSettings; //0x0510
char pad_0520[24]; //0x0520
class RenderView* renderView; //0x0538
char pad_0540[4872]; //0x0540
// static method to return the default instance
static GameRenderer* GetInstance(void) {
return *(GameRenderer**)StaticOffsets::Get_OFFSET_GAMERENDERER();
}
};

class GameRenderSettings {
public:
char pad[0x5c];
float forceFov;
};

// RenderView structure, where we can read the camera transform
class RenderView {
public:
Expand Down

0 comments on commit eadcb60

Please sign in to comment.