diff options
| author | 2025-11-18 10:59:50 -0500 | |
|---|---|---|
| committer | 2025-11-18 10:59:50 -0500 | |
| commit | 10463050906aae3d9d100ddb00bf1bbbd891dc26 (patch) | |
| tree | c9501a3af8a290f5044955cdd78a05fe8b42b0b6 | |
| parent | 3ec6e8c7adf6eb2045fddfb91a4b9b623e1b228b (diff) | |
| download | NewCamera-10463050906aae3d9d100ddb00bf1bbbd891dc26.tar.gz NewCamera-10463050906aae3d9d100ddb00bf1bbbd891dc26.tar.bz2 NewCamera-10463050906aae3d9d100ddb00bf1bbbd891dc26.zip | |
Version 3.0 grind
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rwxr-xr-x | Config.cs | 33 | ||||
| -rwxr-xr-x | Plugin.cs | 1895 |
2 files changed, 1228 insertions, 700 deletions
@@ -7,10 +7,10 @@ namespace MHWNewCamera {
public struct Settings
{
- public const float DEFAULT_SPEED = 4.5f;
+ public const float DEFAULT_SPEED = 5.25f;
+ public const float DEFAULT_SPEED_MODIFIER = 0.40f;
+ public const float DEFAULT_SENSITIVITY = 0.045f;
public const float DEFAULT_ZOOM_SPEED = 0.02f;
- public const float DEFAULT_SPEED_MODIFIER = 0.25f;
- public const float DEFAULT_SENSITIVITY = 0.04f;
public const double DEFAULT_PITCH_LIMIT = -1.0;
public const double MAX_PITCH_LIMIT = 89.95;
public const int DEFAULT_DEADZONE = 4750;
@@ -18,17 +18,17 @@ namespace MHWNewCamera public Settings()
{
CameraSpeed = DEFAULT_SPEED;
- CameraZoomSpeed = DEFAULT_ZOOM_SPEED;
CameraSpeedModifier = DEFAULT_SPEED_MODIFIER;
CameraSensitivity = DEFAULT_SENSITIVITY;
+ CameraZoomSpeed = DEFAULT_ZOOM_SPEED;
CameraPitchLimit = DEFAULT_PITCH_LIMIT;
StickDeadzone = DEFAULT_DEADZONE;
}
public float CameraSpeed { get; set; }
- public float CameraZoomSpeed { get; set; }
public float CameraSpeedModifier { get; set; }
public float CameraSensitivity { get; set; }
+ public float CameraZoomSpeed { get; set; }
public double CameraPitchLimit { get; set; }
public int StickDeadzone { get; set; }
}
@@ -40,7 +40,7 @@ namespace MHWNewCamera public float Right { get; set; }
public float Up { get; set; }
public double Roll { get; set; }
- public bool FadeObjects { get; set; }
+ public bool DisableFading { get; set; }
}
public struct SavedPosition
@@ -55,7 +55,7 @@ namespace MHWNewCamera }
public String Name => "MHWNewCamera";
- public String Version => "2.1";
+ public String Version => "3.0";
private static Dictionary<string, Button> buttonMap = new Dictionary<string, Button>
{
@@ -104,15 +104,18 @@ namespace MHWNewCamera public String Selected { get; set; } = "";
public Dictionary<String, SavedPosition> Positions { get; set; } = new Dictionary<String, SavedPosition>();
- public bool DoubleShadowResolution { get; set; } = false;
- public bool LargerShadowRange { get; set; } = false;
- public bool SlightlySofterShadows { get; set; } = false;
- public bool SofterShadows { get; set; } = false;
+ public bool TripleShadowResolution { get; set; } = false;
+ public float ShadowRangeOffset { get; set; } = 0.5f;
+ public bool ApplyShadowRange { get; set; } = false;
+ public float ShadowRadiusOffset { get; set; } = 0.0005f;
+ public bool ApplyShadowRadius { get; set; } = false;
+ public bool HigherShadowDetailInHoarfrost { get; set; } = false;
+ public bool DisableLodLimits { get; set; } = false;
public bool ApplyLodFactors { get; set; } = false;
- public float LodFactor1 { get; set; } = 0.0f;
- public float LodFactor2 { get; set; } = 0.0f;
- public float FoliageLodFactor { get; set; } = 64.0f;
- public float TerrainLodFactor { get; set; } = 64.0f;
+ public float FoliageLodBias { get; set; } = 3.5f;
+ public float TerrainLodBias { get; set; } = 6.0f;
+ public float FoliageLodFactor { get; set; } = 0.0f;
+ public float TerrainLodFactor { get; set; } = 0.0f;
public bool LargerFoliageSwayRange { get; set; } = false;
}
}
@@ -17,20 +17,21 @@ using System.Diagnostics; #endif
// @TODO:
-// - Special case freecam for cutscenes and canteen animations.
-// - Glass objects in research base and on the botanical research center table still fade.
-// - Contact shadow resolution.
+// - Bind to switch camera preset.
// - Thoroughly test "Disable Mod".
// - Improve AOB scans.
-// - How to change closer shadow "fade" range.
-// - Reduce the pop-in caused by updating shadow blobs.
+// - Glass objects in research base and on the botanical research center table still fade.
// - Snow LOD pop-in.
// - Stop animation rate lowering at distance.
-// - Display equiped armor in the debug UI.
// - Manully set freecam viewport index.
-// - Override in-game viewmode.
+// - Option to override in-game viewmode.
// - +right and +forward to move character.
+// Known Issues:
+// - Camera pitch wrap around while in the tent will sometimes flicker at the point of wrapping.
+// Likely due to the unpredictable position of SetCameraTentHook() in the chain of hooks.
+// Updating the free camera state within SetCameraTentHook() is not a solution because it comes out laggy.
+
// Steam proton launch command:
// env DOTNET_ROOT="" WINEDLLOVERRIDES="msvcrt,dinput8=n,b" %command%
@@ -84,37 +85,17 @@ namespace MHWNewCamera public string Author => "Akon City Software";
private const double DEFAULT_FOV = 60.0;
+ private const float DEFAULT_NEAR_CLIP = 16.0f;
private bool disableMod = false;
private float cameraSpeed;
- private float cameraZoomSpeed;
private float cameraSpeedModifier;
private float cameraSensitivity;
+ private float cameraZoomSpeed;
private double cameraPitchLimit;
private int stickDeadzone;
- private bool enableCombo = false;
- private Button[]? freeCameraCombo = null;
- private bool disableComboButton1 = false;
- private bool comboButton1Down = false;
-
- private uint lastPadDown = 0;
- private uint? prevPadDown = null;
- private bool unlockInputToggled = false;
- private bool buttonWasDown(Button button)
- {
- return (lastPadDown & (uint)button) == (uint)button;
- }
- private bool buttonWasPressed(Button button)
- {
- return (lastPadDown & (uint)button) == (uint)button && (prevPadDown & (uint)button) != (uint)button;
- }
- private bool buttonWasReleased(Button button)
- {
- return (lastPadDown & (uint)button) != (uint)button && (prevPadDown & (uint)button) == (uint)button;
- }
-
private double cameraFov = DEFAULT_FOV;
private float cameraForward = 0.0f;
private float cameraRight = 0.0f;
@@ -124,13 +105,16 @@ namespace MHWNewCamera private double cameraYaw = 0.0;
private double cameraPitch = 0.0;
private double cameraRoll = 0.0;
- private bool fadeObjects = true;
+ private bool disableFading = false;
private int cameraWrapState = 0;
private bool freeCamera = false;
private bool enableFreeCamera = false;
private Camera? vCamera = null;
private int vCameraViewportIndex = -1;
+ private double cameraFrameX;
+ private double cameraFrameY;
+ private double cameraFrameZ;
private Vector3 cameraPosition;
private Vector3 cameraTarget;
private double? preDetachFov = null;
@@ -150,7 +134,36 @@ namespace MHWNewCamera private int previousCameraAnimState = 0;
private bool ignoreAnimState = false;
- private bool debugButton = false;
+ private bool enableCombo = false;
+ private Button[]? freeCameraCombo = null;
+ private bool disableComboButton1 = false;
+ private bool comboButton1Down = false;
+
+ private static readonly MtObject sMhSteamController = SingletonManager.GetSingleton("sMhSteamController")!;
+ private nint controllerAddr() => sMhSteamController.Instance;
+ private nint primaryPad = 0x0;
+
+ private uint lastPadDown = 0;
+ private uint? prevPadDown = null;
+ private bool unlockInputToggled = false;
+ private bool buttonWasDown(Button button)
+ {
+ return (lastPadDown & (uint)button) == (uint)button;
+ }
+ private bool buttonWasPressed(Button button)
+ {
+ return (lastPadDown & (uint)button) == (uint)button && (prevPadDown & (uint)button) != (uint)button;
+ }
+ private bool buttonWasReleased(Button button)
+ {
+ return (lastPadDown & (uint)button) != (uint)button && (prevPadDown & (uint)button) == (uint)button;
+ }
+
+ private bool skipDofHook = true;
+ private bool forceOffDof = false;
+ private bool? wasDofAllowed = null;
+ private nint dofPointer = 0x0;
+
private float plusRight = 0.0f;
private float plusForward = 0.0f;
@@ -163,12 +176,21 @@ namespace MHWNewCamera private delegate void SetCameraTentDelegate(nint unknownPtr);
private Hook<SetCameraTentDelegate>? setCameraTentHook;
+ private delegate void SetCameraCutsceneDelegate(nint unknownPtr);
+ private Hook<SetCameraCutsceneDelegate>? setCameraCutsceneHook;
+
private delegate void WritePadInputDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3);
private Hook<WritePadInputDelegate>? writePadInputHook;
private delegate float CheckMovementDelegate(int stickValue);
private Hook<CheckMovementDelegate>? checkMovementHook;
+ private delegate void ShadowCascadeDelegate(nint unknownPtr, nint unknownPtr2);
+ private Hook<ShadowCascadeDelegate>? shadowCascadeHook;
+
+ private delegate void EvalDepthOfFieldDelegate(nint unknownPtr, nint unknownPtr2);
+ private Hook<EvalDepthOfFieldDelegate>? evalDepthOfFieldHook;
+
private Patch swapMinimapFollowsCamera;
private bool uiToggled = false;
@@ -177,45 +199,73 @@ namespace MHWNewCamera private bool disableCharacterFade = false;
private Patch noopCharacterFade;
- private bool doubleShadowRes = false;
- private bool largerShadowRange = false;
- private Patch shadowRes1;
+ private bool tripleShadowRes = false;
+ private bool lowShadowDetailOverride = false;
+ private Patch shadowRes1_3x;
private Patch shadowRes1_1;
private Patch shadowRes1_2;
private Patch shadowRes1_3;
private Patch shadowRes2;
private Patch shadowRes3;
- private Patch shadowRes4;
- private bool softerShadows = false;
- private bool slightlySofterShadows = false;
- private Patch higherMinThreshold;
- private Patch slightlyHigherMinThreshold;
+ private Patch shadowRes4_3x;
+
+ private float offsetBiasBy = 0.0f;
+ private float offsetRadiusBy = 0.0f;
+ //private float offsetSampleNumBy = 0.0f;
+ private bool applyShadowBias = false;
+ private bool applyShadowRadius = false;
+ //private bool applyShadowSampleNum = false;
+ private float lastShadowBias = -1.0f;
+ private float lastShadowRadius = -1.0f;
+ private float lastShadowSampleNum = -1.0f;
+ private nint lastShadowCascadeValue = -1;
- private void doubleShadowResEnable()
+ private void tripleShadowResEnable()
{
- shadowRes1.Enable();
+ shadowRes1_3x.Enable();
shadowRes1_1.Enable();
shadowRes1_2.Enable();
shadowRes1_3.Enable();
shadowRes2.Enable();
shadowRes3.Enable();
+ shadowRes4_3x.Enable();
}
- private void doubleShadowResDisable()
+ private void tripleShadowResDisable()
{
- shadowRes1.Disable();
+ shadowRes1_3x.Disable();
shadowRes1_1.Disable();
shadowRes1_2.Disable();
shadowRes1_3.Disable();
shadowRes2.Disable();
shadowRes3.Disable();
+ shadowRes4_3x.Disable();
}
- private float unknownLod1 = 1.0f;
- private float unknownLod2 = 1.0f;
+ private float foliageLodBias = 3.0f;
+ private float terrainLodBias = 3.0f;
private float foliageLodFactor = 1.0f;
private float terrainLodFactor = 1.0f;
+ private bool disableLodLimits = false;
+ private Patch defaultViewModeLodLimit;
+ private Patch defaultViewModeLodLimit_1;
+ private Patch defaultViewModeLodLimit_2;
+
+ private void disableLodLimitsEnable()
+ {
+ defaultViewModeLodLimit.Enable();
+ defaultViewModeLodLimit_1.Enable();
+ defaultViewModeLodLimit_2.Enable();
+ }
+
+ private void disableLodLimitsDisable()
+ {
+ defaultViewModeLodLimit.Disable();
+ defaultViewModeLodLimit_1.Disable();
+ defaultViewModeLodLimit_2.Disable();
+ }
+
private bool largerFoliageSwayRange = false;
private Patch addressHigherValueForFoliageSway;
@@ -278,10 +328,6 @@ namespace MHWNewCamera disableGravityEval.Disable();
}
- private static readonly MtObject sMhSteamController = SingletonManager.GetSingleton("sMhSteamController")!;
- private nint controllerAddr() => sMhSteamController.Instance;
- private nint primaryPad = 0x0;
-
private static readonly MtObject sOtomo = SingletonManager.GetSingleton("sOtomo")!;
// Gui strings.
@@ -314,9 +360,9 @@ namespace MHWNewCamera Config.Settings settings = config.CameraSettings;
cameraSpeed = settings.CameraSpeed;
- cameraZoomSpeed = settings.CameraZoomSpeed;
cameraSpeedModifier = settings.CameraSpeedModifier;
cameraSensitivity = settings.CameraSensitivity;
+ cameraZoomSpeed = settings.CameraZoomSpeed;
cameraPitchLimit = settings.CameraPitchLimit;
if (cameraPitchLimit != -1.0)
{
@@ -333,17 +379,16 @@ namespace MHWNewCamera cameraRight = preset.Right;
cameraYOffset = preset.Up;
cameraRoll = preset.Roll;
- fadeObjects = preset.FadeObjects;
+ disableFading = preset.DisableFading;
}
- doubleShadowRes = config.DoubleShadowResolution;
- largerShadowRange = config.LargerShadowRange;
- slightlySofterShadows = config.SlightlySofterShadows;
- if (slightlySofterShadows && config.SofterShadows)
- {
- config.SofterShadows = false;
- }
- softerShadows = config.SofterShadows;
+ tripleShadowRes = config.TripleShadowResolution;
+ offsetBiasBy = config.ShadowRangeOffset;
+ offsetRadiusBy = config.ShadowRadiusOffset;
+ applyShadowBias = config.ApplyShadowRange;
+ applyShadowRadius = config.ApplyShadowRadius;
+ lowShadowDetailOverride = config.HigherShadowDetailInHoarfrost;
+ disableLodLimits = config.DisableLodLimits;
largerFoliageSwayRange = config.LargerFoliageSwayRange;
ConfigManager.SaveConfig<Config>(this);
@@ -379,6 +424,12 @@ namespace MHWNewCamera #endif
setCameraTentHook = Hook.Create<SetCameraTentDelegate>(addr, SetCameraTentHook);
+ addr = PatternScanner.FindFirst(Pattern.FromString("48 8B C4 48 89 58 10 48 89 70 18 55 57 41 54 41 56 41 57 48 8D 6C 24 80 48 81 EC 80 01 00 00 0F 29 70 C8 48 8B F9 0F 29 78 B8 0F 57 C9 44 0F 29 40 A8 0F 57 F6 44 0F 29 48 98 44 0F 29 50 88"));
+#if ADDR_ASSERTS
+ Trace.Assert(addr == 0x141FB12D0); // nint
+#endif
+ setCameraCutsceneHook = Hook.Create<SetCameraCutsceneDelegate>(addr, SetCameraCutsceneHook);
+
addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 08 57 44 8B 9A 60 01 00 00 48 8B DA 41 0F BF 40 08 4D 8B D0 89 82 80 01 00 00 BF 00 10 00 00 41 0F BF 40 0A 89 82 84 01 00 00 41 0F BF 40 0C 89 82 78 01 00 00 41 0F BF 40 0E 89 82 7C 01 00 00"));
#if ADDR_ASSERTS
Trace.Assert(addr == 0x1422A1280); // nint, nint, nint
@@ -392,13 +443,25 @@ namespace MHWNewCamera #endif
checkMovementHook = Hook.Create<CheckMovementDelegate>(addr, CheckMovementHook);
+ addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 55 41 56 41 57 48 8B EC 48 83 EC 30 48 8B FA 48 8B D9 E8 AA B6 C1 FF 48 8B 47 10 48 8D 57 50"));
+#if ADDR_ASSERTS
+ Trace.Assert(addr == 0x141AB2260); // nint, nint
+#endif
+ shadowCascadeHook = Hook.Create<ShadowCascadeDelegate>(addr, ShadowCascadeHook);
+
+ addr = PatternScanner.FindFirst(Pattern.FromString("40 53 57 41 57 48 83 EC 20 80 B9 DD 01 00 00 00 4C 8B FA 48 8B D9 74 2B 48 8B 0D 99 0F DA 02 48 8B 01 FF 90 A8 00 00 00 84 C0 74 17 80 BB DE 01 00 00 00"));
+#if ADDR_ASSERTS
+ Trace.Assert(addr == 0x1424233B0); // nint, nint
+#endif
+ evalDepthOfFieldHook = Hook.Create<EvalDepthOfFieldDelegate>(addr, EvalDepthOfFieldHook);
+
unchecked
{
addr = PatternScanner.FindFirst(Pattern.FromString("84 C0 0F 84 ?? ?? ?? ?? 48 8B 57 28 45 33 C0 48 8B CE E8 ?? ?? ?? ?? 48 8B 97 E0 01 00 00 41 B0 01 48 8B CE E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B D8"));
#if ADDR_ASSERTS
Trace.Assert(addr == 0x141E55D9E);
#endif
- swapMinimapFollowsCamera = new Patch(addr + 0x3, [0x85]); // je -> jne
+ swapMinimapFollowsCamera = new Patch(addr + 0x3, [0xE9]); // je -> jmp
addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 18 48 89 6C 24 20 57 48 83 EC 20 48 8B 59 68 48 8B FA 48 8B E9 48 85 DB 0F 84 ?? ?? ?? ?? 4C 89 74 24 38 4C 8B B3 80 00 00 00 4D 85 F6"));
#if ADDR_ASSERTS
@@ -419,9 +482,9 @@ namespace MHWNewCamera addr = PatternScanner.FindFirst(Pattern.FromString("48 83 EC 28 F3 0F 10 0D ?? ?? ?? ?? 80 F9 04 75 2F 48 8B 0D ?? ?? ?? ?? E8 D3 8A E4 01 48 8B 0D ?? ?? ?? ?? 33 D2 E8 ?? ?? ?? ??"));
#if ADDR_ASSERTS
Trace.Assert(addr == 0x14043FF80);
- Trace.Assert(MemoryUtil.Read<float>(0x142F0F358) == 2.0f);
+ Trace.Assert(MemoryUtil.Read<float>(0x142E4FE5C) == 3.0f);
#endif
- shadowRes1 = new Patch(addr + 0x8, [0xCC, 0xF3, 0xAC, 0x02]);
+ shadowRes1_3x = new Patch(addr + 0x8, [0xD0, 0xFE, 0xA0, 0x02]); // 3.0
shadowRes1_1 = new Patch(addr + 0x65, [0x17]); // Always set "Value is not 1.0" flag.
shadowRes1_2 = new Patch(addr + 0x68, [0x59]); // movss -> mulss
shadowRes1_3 = new Patch(addr + 0x77, [0x59]); // movss -> mulss
@@ -433,7 +496,7 @@ namespace MHWNewCamera shadowRes2 = new Patch(addr + 0x3F, [
0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3,
0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3,
- 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, // Has to be 8192 for the fallback lower res shadow to be aligned.
+ 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, // Has to be 8192 for the fallback lower res shadow to be aligned.
0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xC3,
0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0xC3
]);
@@ -454,34 +517,43 @@ namespace MHWNewCamera #if ADDR_ASSERTS
Trace.Assert(addr == 0x142288B00);
#endif
- shadowRes4 = new Patch(addr + 0x29, [
- 0xB8, 0x00, 0x16, 0x00, 0x00, 0xEB, 0x21 // "Primary shadow range". This value is used for Low, Medium and High in-game.
+ // It's hard to tell exactly what this value does. It appears to be labeled "iPrimaryShadowSampleNum",
+ // but I may be reading the code wrong. Nevertheless, shadows in the Seliana smithy break if this value
+ // isn't increased. The value is already multiplied by the shadow resolution so directly increasing
+ // it here will result in an even bigger multiplier. Original value is 2816, with this offset and
+ // Shadow Quality: High the result will be 15360. Going past some number around 16384 will crash
+ // the game. I think it's related to N/64 >= 256.
+ shadowRes4_3x = new Patch(addr + 0x29, [
+ 0xB8, 0x00, 0x14, 0x00, 0x00, 0xEB, 0x21 // This case is used for Low, Medium and High in-game.
]);
-
- if (doubleShadowRes && !disableMod)
+ if (tripleShadowRes && !disableMod)
{
- doubleShadowResEnable();
- }
- if (largerShadowRange && !disableMod)
- {
- shadowRes4.Enable();
+ tripleShadowResEnable();
}
- addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 10 8F D0 E5 00 00 0F 57 C0 F3 0F 59 0D ?? ?? ?? ?? 8B C1 48 C1 E8 0C 25 FF 03 00 00 F3 48 0F 2A C3 F3 0F 5E C8 F3 41 0F 11 0C 87"));
+ // Gameplay.
+ addr = PatternScanner.FindFirst(Pattern.FromString("80 BB 34 EC 00 00 00 88 8B 31 EC 00 00 C6 83 30 EC 00 00 00 74 1C C6 83 34 EC 00 00 00 48 8B 0D 68 4B 4F 03 80 B9 58 02 00 00 00 75 05 E8 5A F5 01 00 48 8B CB E8 E2 05 00 00 83 BB DC EB 00 00 06 74 0A C7 83 DC EB 00 00 06 00 00 00"));
#if ADDR_ASSERTS
- Trace.Assert(addr == 0x142286B1B);
- Trace.Assert(MemoryUtil.Read<float>(0x14239CF98) == 4096.0f);
- Trace.Assert(MemoryUtil.Read<float>(0x140598864) == 3072.0f);
+ Trace.Assert(addr == 0x141B1A0B4);
#endif
- slightlyHigherMinThreshold = new Patch(addr + 0xF, [0x36, 0x1D, 0x31, 0xFE]);
- if (slightlySofterShadows && !disableMod)
- {
- slightlyHigherMinThreshold.Enable();
- }
- higherMinThreshold = new Patch(addr + 0xF, [0x6A, 0x64, 0x11, 0x00]);
- if (softerShadows && !disableMod)
+ defaultViewModeLodLimit = new Patch(addr + 0x40, [0x07, 0x74, 0x0A, 0xC7, 0x83, 0xDC, 0xEB, 0x00, 0x00, 0x07]);
+
+ // In room.
+ addr = PatternScanner.FindFirst(Pattern.FromString("8B 9F CC 00 00 00 81 FB F9 01 00 00 74 0C 8B CB E8 95 3F 65 01 83 F8 05 75 11 48 8B 0D 61 C8 F6 04 BA 02 00 00 00 E8 DF 2D 8C 01 48 8B 0D A0 C7 F6 04 8B D3"));
+#if ADDR_ASSERTS
+ Trace.Assert(addr == 0x140257AE6);
+#endif
+ defaultViewModeLodLimit_1 = new Patch(addr + 0x22, [0x07]);
+
+ // Forging/Changing Equipment.
+ addr = PatternScanner.FindFirst(Pattern.FromString("BA 02 00 00 00 E8 6E C0 80 00 48 8B 74 24 38 48 8B 57 28 48 8D 4F 30 E8 4C 79 B4 FE 48 8B 0D 0D FF A6 03 BA 04 00 00 00 E8 8B 64 3C 00 48 8B 05 D4 01 A7 03 80 B8 FD 46 01 00 00"));
+#if ADDR_ASSERTS
+ Trace.Assert(addr == 0x141754438);
+#endif
+ defaultViewModeLodLimit_2 = new Patch(addr + 0x24, [0x07]);
+ if (disableLodLimits && !disableMod)
{
- higherMinThreshold.Enable();
+ disableLodLimitsEnable();
}
addr = PatternScanner.FindFirst(Pattern.FromString("74 4D 33 C0 48 81 C1 00 02 00 00 F3 0F 10 11 0F 2F CA 72 0C FF C0 48 83 C1 04 83 F8 03 72 EC C3"));
@@ -542,59 +614,47 @@ namespace MHWNewCamera }
}
- public void OnLoad()
- {
- Config config = ConfigManager.GetConfig<Config>(this);
- unknownLod1 = config.LodFactor1;
- unknownLod2 = config.LodFactor2;
- foliageLodFactor = config.FoliageLodFactor;
- terrainLodFactor = config.TerrainLodFactor;
- if (config.ApplyLodFactors)
- {
- setLodFactors(true);
- }
- }
-
// Credit to Otis_Inf.
- private bool getFadeObjects(int viewportIndex)
+ private bool getDisableFadingObjects(int viewportIndex)
{
Viewport vp = CameraSystem.GetViewport(viewportIndex);
- return MemoryUtil.Read<byte>(vp.Instance + 0x21) == 1;
+ return MemoryUtil.Read<byte>(vp.Instance + 0x21) == 0;
}
- private void setFadeObjects(int viewportIndex, bool fadeOut)
+ private void setDisableFadingObjects(int viewportIndex, bool disable)
{
Viewport vp = CameraSystem.GetViewport(viewportIndex);
- MemoryUtil.WriteBytes(vp.Instance + 0x21, fadeOut ? [0x1] : [0x0]);
+ MemoryUtil.WriteBytes(vp.Instance + 0x21, disable ? [0x0] : [0x1]);
}
- private void setCharacterFade(bool fadeOut)
+ private void setDisableCharacterFade(bool disable)
{
- if (fadeOut && disableCharacterFade)
- {
- noopCharacterFade.Disable();
- disableCharacterFade = false;
- }
- else if (!fadeOut && !disableCharacterFade)
+ if (disable && !disableCharacterFade)
{
noopCharacterFade.Enable();
disableCharacterFade = true;
}
+ else if (!disable && disableCharacterFade)
+ {
+ noopCharacterFade.Disable();
+ disableCharacterFade = false;
+ }
}
private bool areLodFactorsDefault()
{
- return unknownLod1 == 1.0f && unknownLod2 == 1.0f && foliageLodFactor == 1.0f && terrainLodFactor == 1.0f;
+ return foliageLodBias == 3.0f && terrainLodBias == 3.0f && foliageLodFactor == 1.0f && terrainLodFactor == 1.0f;
}
private bool areLodFactorsSet()
{
nint baseAddr = MemoryUtil.Read<nint>(0x1451C4368);
- float lod1 = MemoryUtil.Read<float>(baseAddr + 0x224);
- float lod2 = MemoryUtil.Read<float>(baseAddr + 0x228);
- float lod3 = MemoryUtil.Read<float>(baseAddr + 0x234);
- float lod4 = MemoryUtil.Read<float>(baseAddr + 0x24C);
- return lod1 == unknownLod1 && lod2 == unknownLod2 && lod3 == foliageLodFactor && lod4 == terrainLodFactor;
+ float foliageLod1 = MemoryUtil.Read<float>(baseAddr + 0x21C);
+ float terrainLod1 = MemoryUtil.Read<float>(baseAddr + 0x220);
+ float foliageLod2 = MemoryUtil.Read<float>(baseAddr + 0x224);
+ float terrainLod2 = MemoryUtil.Read<float>(baseAddr + 0x228);
+ return foliageLod1 == foliageLodBias && terrainLod1 == terrainLodBias &&
+ foliageLod2 == foliageLodFactor && terrainLod2 == terrainLodFactor;
}
private void setLodFactors(bool toggleOn)
@@ -602,28 +662,85 @@ namespace MHWNewCamera nint baseAddr = MemoryUtil.Read<nint>(0x1451C4368);
if (toggleOn)
{
- MemoryUtil.WriteBytes(baseAddr + 0x224, BitConverter.GetBytes(unknownLod1)); // Something with lighting?
- MemoryUtil.WriteBytes(baseAddr + 0x228, BitConverter.GetBytes(unknownLod2));
- MemoryUtil.WriteBytes(baseAddr + 0x234, BitConverter.GetBytes(foliageLodFactor));
- MemoryUtil.WriteBytes(baseAddr + 0x24C, BitConverter.GetBytes(terrainLodFactor));
+ MemoryUtil.WriteBytes(baseAddr + 0x21C, BitConverter.GetBytes(foliageLodBias));
+ MemoryUtil.WriteBytes(baseAddr + 0x220, BitConverter.GetBytes(terrainLodBias));
+ MemoryUtil.WriteBytes(baseAddr + 0x224, BitConverter.GetBytes(foliageLodFactor));
+ MemoryUtil.WriteBytes(baseAddr + 0x228, BitConverter.GetBytes(terrainLodFactor));
}
else
{
+ MemoryUtil.WriteBytes(baseAddr + 0x21C, BitConverter.GetBytes(3.0f)); // LOD Bias: "High".
+ MemoryUtil.WriteBytes(baseAddr + 0x220, BitConverter.GetBytes(3.0f)); // LOD Bias: "High".
MemoryUtil.WriteBytes(baseAddr + 0x224, BitConverter.GetBytes(1.0f));
MemoryUtil.WriteBytes(baseAddr + 0x228, BitConverter.GetBytes(1.0f));
- MemoryUtil.WriteBytes(baseAddr + 0x234, BitConverter.GetBytes(1.0f));
- MemoryUtil.WriteBytes(baseAddr + 0x24C, BitConverter.GetBytes(1.0f));
}
}
- private void checkPlayerChange()
+ /*
+ private bool areLodLimitsDisabled()
{
- Player? player = Player.MainPlayer;
- if (player != lastPlayer)
+ nint addrAddr = MemoryUtil.Read<nint>(0x1451C4148);
+ nint baseAddr = MemoryUtil.Read<nint>(addrAddr + 0xAF828);
+ nint addrStart = baseAddr + 0xEB9C;
+ bool faceLimit = MemoryUtil.Read<byte>(addrStart) == 0x0;
+ bool faceShadowLimit = MemoryUtil.Read<byte>(addrStart + 0x4) == 0x0;
+ bool playerLimit = MemoryUtil.Read<byte>(addrStart + 0x8) == 0x0;
+ bool playerShadowLimit = MemoryUtil.Read<byte>(addrStart + 0xC) == 0x0;
+ bool otomoLimit = MemoryUtil.Read<byte>(addrStart + 0x10) == 0x0;
+ bool otomoShadowLimit = MemoryUtil.Read<byte>(addrStart + 0x14) == 0x0;
+ bool npcLimit = MemoryUtil.Read<byte>(addrStart + 0x18) == 0x0;
+ bool npcShadowLimit = MemoryUtil.Read<byte>(addrStart + 0x1C) == 0x0;
+ bool simpleNpcLimit = MemoryUtil.Read<byte>(addrStart + 0x20) == 0x0;
+ bool simpleNpcShadowLimit = MemoryUtil.Read<byte>(addrStart + 0x24) == 0x0;
+ return faceLimit && faceShadowLimit && playerLimit && playerShadowLimit &&
+ otomoLimit && otomoShadowLimit && npcLimit && npcShadowLimit &&
+ simpleNpcLimit && simpleNpcShadowLimit;
+ }
+
+ private void setLodLimits(bool limitOn)
+ {
+ nint addrAddr = MemoryUtil.Read<nint>(0x1451C4148);
+ nint baseAddr = MemoryUtil.Read<nint>(addrAddr + 0xAF828);
+ nint addrStart = baseAddr + 0xEB9C;
+ if (limitOn)
{
- pCamera = null;
- pCameraViewportIndex = -1;
- lastPlayer = player;
+ MemoryUtil.WriteBytes(addrStart, [0x1]);
+ MemoryUtil.WriteBytes(addrStart + 0x4, [0x3]);
+ MemoryUtil.WriteBytes(addrStart + 0x8, [0x1]);
+ MemoryUtil.WriteBytes(addrStart + 0xC, [0x3]);
+ MemoryUtil.WriteBytes(addrStart + 0x10, [0x1]);
+ MemoryUtil.WriteBytes(addrStart + 0x14, [0x3]);
+ MemoryUtil.WriteBytes(addrStart + 0x18, [0x1]);
+ MemoryUtil.WriteBytes(addrStart + 0x1C, [0x3]);
+ MemoryUtil.WriteBytes(addrStart + 0x20, [0x2]);
+ MemoryUtil.WriteBytes(addrStart + 0x24, [0x3]);
+ }
+ else
+ {
+ MemoryUtil.WriteBytes(addrStart, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x4, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x8, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0xC, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x10, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x14, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x18, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x1C, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x20, [0x0]);
+ MemoryUtil.WriteBytes(addrStart + 0x24, [0x0]);
+ }
+ }
+ */
+
+ public void OnLoad()
+ {
+ Config config = ConfigManager.GetConfig<Config>(this);
+ foliageLodBias = config.FoliageLodBias;
+ terrainLodBias = config.TerrainLodBias;
+ foliageLodFactor = config.FoliageLodFactor;
+ terrainLodFactor = config.TerrainLodFactor;
+ if (config.ApplyLodFactors)
+ {
+ setLodFactors(true);
}
}
@@ -640,9 +757,6 @@ namespace MHWNewCamera #endif
primaryPad = 0x0;
-
- // Consider that pCamera could become an invalid pointer.
- checkPlayerChange();
}
private static Quaternion getForward(Vector3 pos, Vector3 target)
@@ -650,6 +764,11 @@ namespace MHWNewCamera return new Quaternion(target.X - pos.X, target.Y - pos.Y, target.Z - pos.Z, 0.0f);
}
+ private static Quaternion getRight(Quaternion q)
+ {
+ return q * Quaternion.CreateFromYawPitchRoll((float)Math.PI, 0.0f, 0.0f);
+ }
+
private void setCameraRoll(Camera camera)
{
// Don't test our luck with precision weirdness if we know we can be exact.
@@ -677,7 +796,7 @@ namespace MHWNewCamera private void setPerspective(Camera camera)
{
Quaternion forward = getForward(camera.Position, camera.Target);
- Quaternion right = forward * Quaternion.CreateFromRotationMatrix(Matrix4x4.CreateRotationY(Single.DegreesToRadians(180.0f)));
+ Quaternion right = getRight(forward);
forward = Quaternion.Normalize(forward);
right = Quaternion.Normalize(right);
Vector3 pos = camera.Position;
@@ -687,10 +806,9 @@ namespace MHWNewCamera pos.X += right.X * cameraRight;
pos.Z += right.Z * cameraRight;
pos.X += cameraXOffset;
- if (debugButton) pos.Y += cameraYOffset;
pos.Z += cameraZOffset;
camera.Position = pos;
- if (debugButton && cameraFov != DEFAULT_FOV)
+ if (cameraFov != DEFAULT_FOV)
{
camera.FieldOfView = (float)Math.Clamp((cameraFov * previousFov) / DEFAULT_FOV, 1.0, 179.0);
}
@@ -723,8 +841,12 @@ namespace MHWNewCamera }
cameraWrapState = 0;
setTentBasePos(new Vector3(0.0f, -19850.0f, 270.0f), new Vector3(0.0f, -19830.0f, 0.0f));
- setFadeObjects(vCameraViewportIndex, (vCameraViewportIndex == pCameraViewportIndex) ? fadeObjects : true);
- setCharacterFade(fadeObjects);
+ setDisableFadingObjects(vCameraViewportIndex, (vCameraViewportIndex == pCameraViewportIndex) ? disableFading : false);
+ setDisableCharacterFade(disableFading);
+ if (vCamera != null)
+ {
+ vCamera.NearClip = DEFAULT_NEAR_CLIP;
+ }
swapMinimapFollowsCamera.Disable();
}
@@ -732,10 +854,14 @@ namespace MHWNewCamera {
float deltaTime = camera.DeltaTime;
- bool lockVerticalAndModify = buttonWasDown(Button.R2) || lockVerticalToggled;
- double adjustedSpeed = cameraSpeed * deltaTime * (lockVerticalAndModify ? cameraSpeedModifier : 1.0f);
+ bool lockVerticalAndModifySpeed = buttonWasDown(Button.L2) || lockVerticalToggled;
+ double adjustedSpeed = cameraSpeed * deltaTime * (lockVerticalAndModifySpeed ? cameraSpeedModifier : 1.0f);
double buttonOffset = adjustedSpeed / 2.0;
+ cameraFrameX = 0.0;
+ cameraFrameY = 0.0;
+ cameraFrameZ = 0.0;
+
if (buttonWasDown(Button.L2) && buttonWasDown(Button.R2)) // Left stick zoom.
{
int PadLy = MemoryUtil.Read<int>(controllerAddr() + 0x1BC);
@@ -755,47 +881,82 @@ namespace MHWNewCamera Quaternion forward = getForward(cameraPosition, cameraTarget);
- if (lockVerticalAndModify)
+ // Invert diagonal directions when upside down for movement consistency.
+ if (cameraWrapState == 1)
+ {
+ forward.X = -forward.X;
+ forward.Z = -forward.Z;
+ }
+
+ if (lockVerticalAndModifySpeed)
{
forward.Y = 0.0f;
}
Quaternion right = forward;
right.Y = 0.0f;
- right = right * Quaternion.CreateFromRotationMatrix(Matrix4x4.CreateRotationY(Single.DegreesToRadians(180.0f)));
+ right = getRight(right);
forward = Quaternion.Normalize(forward);
right = Quaternion.Normalize(right);
- cameraPosition.X += (float)(right.X * Lx);
- cameraPosition.Z += (float)(right.Z * Lx);
- cameraPosition.X += (float)(forward.X * Ly);
- cameraPosition.Y += (float)(forward.Y * Ly);
- cameraPosition.Z += (float)(forward.Z * Ly);
+ cameraFrameX += right.X * Lx;
+ cameraFrameZ += right.Z * Lx;
+ cameraFrameX += forward.X * Ly;
+ cameraFrameY += forward.Y * Ly;
+ cameraFrameZ += forward.Z * Ly;
if (plusForward != 0.0f)
{
- cameraPosition.X += (float)(forward.X * plusForward * deltaTime);
- cameraPosition.Y += (float)(forward.Y * plusForward * deltaTime);
- cameraPosition.Z += (float)(forward.Z * plusForward * deltaTime);
+ cameraFrameX += forward.X * plusForward * deltaTime;
+ cameraFrameY += forward.Y * plusForward * deltaTime;
+ cameraFrameZ += forward.Z * plusForward * deltaTime;
}
}
if (!unlockInputToggled)
{
- if (buttonWasDown(Button.Up))
+ if (buttonWasDown(Button.Share))
{
- cameraPosition.Y += (float)buttonOffset;
- }
- if (buttonWasDown(Button.Down))
- {
- cameraPosition.Y -= (float)buttonOffset;
+ if (buttonWasPressed(Button.Square))
+ {
+ if (camera.NearClip == 0.5f)
+ {
+ camera.NearClip = DEFAULT_NEAR_CLIP;
+ }
+ else
+ {
+ camera.NearClip = 0.5f;
+ }
+ }
}
- if (buttonWasDown(Button.Left))
+ if (buttonWasDown(Button.Triangle))
{
- cameraRoll -= buttonOffset / 2.0;
+ if (buttonWasPressed(Button.Left) || buttonWasPressed(Button.Right))
+ {
+ cameraRoll = (preDetachRoll != null) ? (double)preDetachRoll : 0.0f;
+ }
+ if (buttonWasPressed(Button.Up))
+ {
+ cameraFov = (preDetachFov != null) ? (double)preDetachFov : DEFAULT_FOV;
+ }
}
- if (buttonWasDown(Button.Right))
+ else
{
- cameraRoll += buttonOffset / 2.0;
+ if (buttonWasDown(Button.Up))
+ {
+ cameraFrameY += buttonOffset;
+ }
+ if (buttonWasDown(Button.Down))
+ {
+ cameraFrameY -= buttonOffset;
+ }
+ if (buttonWasDown(Button.Left))
+ {
+ cameraRoll -= buttonOffset / 2.0;
+ }
+ if (buttonWasDown(Button.Right))
+ {
+ cameraRoll += buttonOffset / 2.0;
+ }
}
}
@@ -846,13 +1007,13 @@ namespace MHWNewCamera cameraWrapState = 0;
}
}
- if (cameraRoll >= 360.0)
+ if (cameraRoll < 0.0)
{
- cameraRoll -= 360.0;
+ cameraRoll += 360.0;
}
- else if (cameraRoll < 0.0)
+ else if (cameraRoll >= 360.0)
{
- cameraRoll += 360.0;
+ cameraRoll -= 360.0;
}
if (plusRight != 0.0)
@@ -860,6 +1021,10 @@ namespace MHWNewCamera cameraYaw += plusRight * deltaTime;
}
+ cameraPosition.X += (float)cameraFrameX;
+ cameraPosition.Y += (float)cameraFrameY;
+ cameraPosition.Z += (float)cameraFrameZ;
+
// 700.0 is the same value the game uses for the player camera. The in-game view mode
// uses 1.0 like I did here before, which is really bad for precision.
double dist = 700.0 - cameraForward;
@@ -872,6 +1037,18 @@ namespace MHWNewCamera camera.FieldOfView = (float)cameraFov;
}
+ private Player? checkPlayerChange()
+ {
+ Player? player = Player.MainPlayer;
+ if (player != lastPlayer)
+ {
+ pCamera = null;
+ pCameraViewportIndex = -1;
+ lastPlayer = player;
+ }
+ return player;
+ }
+
private int getVisibleCamera()
{
for (int i = 0; i < 8; i++)
@@ -886,51 +1063,66 @@ namespace MHWNewCamera return -1;
}
- private void checkCurrentVisibleCamera()
+ private void checkCurrentVisibleCamera(Player? player)
{
int prevIndex = vCameraViewportIndex;
vCameraViewportIndex = getVisibleCamera();
if (vCameraViewportIndex >= 0)
{
Camera camera = CameraSystem.GetViewport(vCameraViewportIndex).Camera!;
- // Free camera target change.
- if (freeCamera && camera != vCamera)
+ // Evaluate potential free camera target change.
+ if (freeCamera)
{
if (prevIndex != vCameraViewportIndex)
{
- setFadeObjects(prevIndex, (prevIndex == pCameraViewportIndex) ? fadeObjects : true);
- setFadeObjects(vCameraViewportIndex, false);
+ if (prevIndex >= 0)
+ {
+ setDisableFadingObjects(prevIndex, (prevIndex == pCameraViewportIndex) ? disableFading : false);
+ }
+ setDisableFadingObjects(vCameraViewportIndex, true);
}
- Player? player = Player.MainPlayer;
- if (player != null)
+ if (vCamera != camera)
{
- // Try to position the camera behind the player.
- cameraPosition = player.Position;
- cameraPosition.X -= player.Forward.X * 250.0f;
- cameraPosition.Y += 200.0f;
- cameraPosition.Z -= player.Forward.Z * 250.0f;
- cameraTarget = player.Position;
- cameraTarget.Y += 150.0f;
- }
- else
- {
- cameraPosition = camera.Position;
- cameraTarget = camera.Target;
+ if (vCamera != null)
+ {
+ camera.NearClip = vCamera.NearClip;
+ vCamera.NearClip = DEFAULT_NEAR_CLIP;
+ }
+ if (player != null)
+ {
+ // Try to position the camera behind the player.
+ cameraPosition = player.Position;
+ cameraPosition.X -= player.Forward.X * 250.0f;
+ cameraPosition.Y += 200.0f;
+ cameraPosition.Z -= player.Forward.Z * 250.0f;
+ cameraTarget = player.Position;
+ cameraTarget.Y += 150.0f;
+ }
+ else
+ {
+ cameraPosition = camera.Position;
+ cameraTarget = camera.Target;
+ }
+ Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget));
+ cameraYaw = Double.RadiansToDegrees(Math.Atan2(forward.Z, forward.X));
+ cameraPitch = Double.RadiansToDegrees(Math.Asin(forward.Y));
}
- Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget));
- cameraYaw = Double.RadiansToDegrees(Math.Atan2(forward.Z, forward.X));
- cameraPitch = Double.RadiansToDegrees(Math.Asin(forward.Y));
}
vCamera = camera;
- // pCamera is the first visible camera after a player is set.
- // We assume it is the player camera.
- if (pCamera == null && lastPlayer != null)
+ // Assume that after a player is set the visible camera is the player camera.
+ if (pCamera == null && player != null)
{
pCamera = vCamera;
pCameraViewportIndex = vCameraViewportIndex;
- setFadeObjects(pCameraViewportIndex, fadeObjects);
+ setDisableFadingObjects(pCameraViewportIndex, disableFading);
}
}
+ else
+ {
+ vCamera = null;
+ pCamera = null;
+ pCameraViewportIndex = -1;
+ }
}
private void checkCameraAnimState()
@@ -971,12 +1163,13 @@ namespace MHWNewCamera }
#if HOOK_ORDER_ASSERTS
- debugLog($"SetCameraHook() @ {frameTick}");
+ debugLog($"SetCameraHook({unknownPtr:x}) @ {frameTick}");
Trace.Assert(hookOrder == 0);
hookOrder = 1;
#endif
- checkCurrentVisibleCamera();
+ Player? player = checkPlayerChange();
+ checkCurrentVisibleCamera(player);
checkCameraAnimState();
// CalculateCameraHook() within this function.
@@ -1019,7 +1212,7 @@ namespace MHWNewCamera }
#if HOOK_ORDER_ASSERTS
- debugLog($"CalculateCameraHook() @ {frameTick}");
+ debugLog($"CalculateCameraHook({unknownPtr:x}) @ {frameTick}");
Trace.Assert(hookOrder == 1);
hookOrder = 2;
#endif
@@ -1046,7 +1239,7 @@ namespace MHWNewCamera applyPerspective &= !assumeInQuestBoard(previousFov);
}
- if (applyPerspective && !debugButton)
+ if (applyPerspective)
{
// Applying Y offset here keeps crosshair UI centered, but affects the angle of the camera.
pCamera!.Position.Y += cameraYOffset;
@@ -1058,10 +1251,10 @@ namespace MHWNewCamera calculateCameraHook!.Original(unknownPtr);
- // Setting the perspective at this point (after Original()), allows the offset to not
+ // Setting the perspective after calculateCameraHook.Original() allows the offset to not
// negatively affect the right stick camera movement. If set earlier, camera movement
- // would be too snappy and incorrectly smoothed. If set too much later, it may not
- // be considered by lower-level functions like culling.
+ // would be too snappy and incorrectly smoothed. If set later, it may not be
+ // considered by lower-level functions like culling.
if (applyPerspective)
{
setPerspective(pCamera!);
@@ -1088,8 +1281,8 @@ namespace MHWNewCamera // actually shown, which avoids a jump when toggling freecam. This is also why
// we don't enable freecam until after applying a offset on this update.
cameraFov = vCamera.FieldOfView;
- setFadeObjects(vCameraViewportIndex, false);
- setCharacterFade(false);
+ setDisableFadingObjects(vCameraViewportIndex, true);
+ setDisableCharacterFade(true);
swapMinimapFollowsCamera.Enable();
}
}
@@ -1110,7 +1303,7 @@ namespace MHWNewCamera }
#if HOOK_ORDER_ASSERTS
// The order of this hook between SetCameraHook() and CalculateCameraHook() is inconsistent.
- debugLog($"SetCameraTentHook() @ {frameTick}");
+ debugLog($"SetCameraTentHook({unknownPtr:x}) @ {frameTick}");
#endif
if (freeCamera && vCamera != null)
{
@@ -1126,8 +1319,27 @@ namespace MHWNewCamera }
}
- // This can undoubtedly be simplified. I'm being conservative about MemoryUtil.Read() because
- // I haven't thought about or tested enough to know if it should be a performance consideration.
+ private void SetCameraCutsceneHook(nint unknownPtr)
+ {
+ if (disableMod)
+ {
+ setCameraCutsceneHook!.Original(unknownPtr);
+ return;
+ }
+#if HOOK_ORDER_ASSERTS
+ debugLog($"SetCameraCutsceneHook({unknownPtr:x}) @ {frameTick}");
+#endif
+ setCameraCutsceneHook!.Original(unknownPtr);
+ if (freeCamera && vCamera != null)
+ {
+ vCamera.Position = cameraPosition;
+ vCamera.Target = cameraTarget;
+ vCamera.FieldOfView = (float)cameraFov;
+ setCameraRoll(vCamera);
+ }
+ }
+
+ // This can undoubtedly be simplified.
private void WritePadInputHook(nint unknownPtr, nint unknownPtr2, nint unknownPtr3)
{
// Assumes the primary pad always comes first.
@@ -1142,6 +1354,10 @@ namespace MHWNewCamera return;
}
+#if HOOK_ORDER_ASSERTS
+ debugLog($"WritePadInputHook({unknownPtr:x}, {unknownPtr2:x}, {unknownPtr3:x}) @ {frameTick}");
+#endif
+
Button b1 = 0u, b2 = 0u;
// PadOld = 0x19C
uint PadDown = 0u, PadTrg = 0u, PadRel = 0u, PadChg = 0u;
@@ -1208,14 +1424,34 @@ namespace MHWNewCamera lastPadDown = PadDown;
}
+ bool blockInput = !unlockInputToggled;
+ if (buttonWasDown(Button.L2))
+ {
+ if (buttonWasReleased(Button.R1))
+ {
+ unlockInputToggled = !unlockInputToggled;
+ blockInput = true;
+ }
+ else if (buttonWasDown(Button.R1))
+ {
+ blockInput = true;
+ }
+ }
+
if ((comboButton1Down || (!disableComboButton1 && buttonWasDown(b1))) && buttonWasPressed(b2))
{
enableFreeCamera = !enableFreeCamera;
}
+ if (unlockMovementHeld && buttonWasReleased(Button.R2))
+ {
+ unlockMovementHeld = false;
+ unlockMovementPause = false;
+ }
+
if (enableFreeCamera)
{
- if (!unlockInputToggled)
+ if (blockInput)
{
if (!readInputsPostHook)
{
@@ -1248,15 +1484,11 @@ namespace MHWNewCamera MemoryUtil.WriteBytes(controllerAddr() + 0x1C1, BitConverter.GetBytes(0));
}
- if (!unlockMovementHeld && buttonWasPressed(Button.L2))
+ if (!unlockMovementHeld && buttonWasPressed(Button.R2))
{
unlockMovementHeld = true;
}
- else if (unlockMovementHeld && buttonWasReleased(Button.L2))
- {
- unlockMovementHeld = false;
- unlockMovementPause = false;
- }
+
if (unlockMovementHeld)
{
if (buttonWasPressed(Button.L1))
@@ -1264,37 +1496,54 @@ namespace MHWNewCamera unlockMovementToggled = !unlockMovementToggled;
}
// Temporarily disable for zoom mode.
- if (buttonWasDown(Button.R2))
+ if (buttonWasDown(Button.L2))
{
unlockMovementPause = true;
}
- else if (buttonWasReleased(Button.R2))
+ else if (buttonWasReleased(Button.L2))
{
unlockMovementPause = false;
}
}
- if (buttonWasDown(Button.R2) && buttonWasPressed(Button.L1))
+ if (buttonWasDown(Button.L2) && buttonWasPressed(Button.L1))
{
lockVerticalToggled = !lockVerticalToggled;
}
- if (buttonWasDown(Button.L2) && buttonWasPressed(Button.R1))
- {
- unlockInputToggled = !unlockInputToggled;
- }
-
- if (buttonWasDown(Button.R2) && buttonWasPressed(Button.R1))
+ if (blockInput)
{
- if (uiToggled)
+ if (buttonWasDown(Button.Triangle))
{
- jmpOverUi.Disable();
+ if (buttonWasPressed(Button.Down))
+ {
+ if (Player.MainPlayer != null)
+ {
+ // Y - 150 to approximately align the players head with the camera.
+ Player.MainPlayer.Position = new Vector3(cameraPosition.X, cameraPosition.Y - 150.0f, cameraPosition.Z);
+ }
+ }
}
- else
+ if (buttonWasDown(Button.Share))
{
- jmpOverUi.Enable();
+ if (buttonWasPressed(Button.Cross))
+ {
+ if (uiToggled)
+ {
+ jmpOverUi.Disable();
+ }
+ else
+ {
+ jmpOverUi.Enable();
+ }
+ uiToggled = !uiToggled;
+ }
+
+ if (buttonWasPressed(Button.Circle))
+ {
+ forceOffDof = !forceOffDof;
+ }
}
- uiToggled = !uiToggled;
}
}
}
@@ -1306,7 +1555,7 @@ namespace MHWNewCamera return checkMovementHook!.Original(stickValue);
}
#if HOOK_ORDER_ASSERTS
- debugLog($"CheckMovementHook() @ {frameTick}");
+ debugLog($"CheckMovementHook({stickValue}) @ {frameTick}");
#endif
if (freeCamera && !((unlockMovementHeld || unlockMovementToggled) && !unlockMovementPause))
{
@@ -1315,6 +1564,84 @@ namespace MHWNewCamera return checkMovementHook!.Original(stickValue);
}
+ private void ShadowCascadeHook(nint unknownPtr, nint unknownPtr2)
+ {
+ if (disableMod)
+ {
+ shadowCascadeHook!.Original(unknownPtr, unknownPtr2);
+ return;
+ }
+#if HOOK_ORDER_ASSERTS
+ debugLog($"ShadowCascadeHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}");
+#endif
+ nint rax = MemoryUtil.Read<nint>(unknownPtr2 + 0x170);
+ nint shadowCascadeValue = rax >> 32;
+ float biasOverride = MemoryUtil.Read<float>(unknownPtr2 + 0x17C);
+ lastShadowBias = biasOverride;
+ biasOverride += offsetBiasBy;
+ if (lowShadowDetailOverride)
+ {
+ if (shadowCascadeValue == 1)
+ {
+ biasOverride *= 2.0f;
+ MemoryUtil.WriteBytes(unknownPtr2 + 0x170, BitConverter.GetBytes((shadowCascadeValue + 1) << 32 | (rax & 0x00000000FFFFFFFF)));
+ }
+ }
+ if (shadowCascadeValue != 3)
+ {
+ lastShadowCascadeValue = shadowCascadeValue;
+ lastShadowBias = MemoryUtil.Read<float>(unknownPtr2 + 0x17C);
+ if (applyShadowBias)
+ {
+ MemoryUtil.WriteBytes(unknownPtr2 + 0x17C, BitConverter.GetBytes(biasOverride));
+ }
+ lastShadowRadius = MemoryUtil.Read<float>(unknownPtr2 + 0x1EC);
+ if (applyShadowRadius)
+ {
+ MemoryUtil.WriteBytes(unknownPtr2 + 0x1EC, BitConverter.GetBytes(lastShadowRadius + offsetRadiusBy));
+ }
+ lastShadowSampleNum = MemoryUtil.Read<float>(unknownPtr2 + 0x1E4);
+ /*
+ if (applyShadowSampleNum)
+ {
+ MemoryUtil.WriteBytes(unknownPtr2 + 0x1E4, BitConverter.GetBytes(lastShadowSampleNum + offsetSampleNumBy));
+ }
+ */
+ }
+ shadowCascadeHook!.Original(unknownPtr, unknownPtr2);
+ }
+
+ private void EvalDepthOfFieldHook(nint unknownPtr, nint unknownPtr2)
+ {
+ if (disableMod || (skipDofHook = !skipDofHook))
+ {
+ evalDepthOfFieldHook!.Original(unknownPtr, unknownPtr2);
+ return;
+ }
+#if HOOK_ORDER_ASSERTS
+ debugLog($"EvalDepthOfFieldHook({unknownPtr}, {unknownPtr2}) @ {frameTick}");
+#endif
+ // Possibly of interest: +0x1DE, +0x1DF.
+ dofPointer = unknownPtr;
+ if (!forceOffDof)
+ {
+ if (wasDofAllowed != null)
+ {
+ MemoryUtil.WriteBytes(dofPointer + 0x1DD, ((bool)wasDofAllowed) ? [0x1] : [0x0]);
+ wasDofAllowed = null;
+ }
+ }
+ else
+ {
+ if (wasDofAllowed == null)
+ {
+ wasDofAllowed = MemoryUtil.Read<byte>(dofPointer + 0x1DD) == 0x1;
+ }
+ MemoryUtil.WriteBytes(dofPointer + 0x1DD, [0x0]);
+ }
+ evalDepthOfFieldHook!.Original(unknownPtr, unknownPtr2);
+ }
+
private void disableAllCollisionHooks()
{
if (disableExtraGravity)
@@ -1339,11 +1666,218 @@ namespace MHWNewCamera }
}
+ private void drawViewportInfo(int i, float width, Config config, bool debug)
+ {
+ Viewport vp = CameraSystem.GetViewport(i);
+ if (debug)
+ {
+ ImGui.Text($"Pointer: {vp.Instance:x}");
+ ImGui.Text($"Visible: {vp.Visible}");
+ ImGui.Text($"Region: {vp.Region.X} {vp.Region.Y} {vp.Region.Width} {vp.Region.Height}");
+ }
+ else
+ {
+ ImGui.Text($"Resolution: {vp.Region.Width}x{vp.Region.Height}");
+ }
+ if (vp.Visible)
+ {
+ bool disableFadingObjects = getDisableFadingObjects(i);
+ if (ImGui.Checkbox("Disable Fading Objects When Close to Camera", ref disableFadingObjects))
+ {
+ setDisableFadingObjects(i, disableFadingObjects);
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Credit to Otis_Inf.");
+ ImGui.EndTooltip();
+ }
+ }
+ if (vp.Camera != null)
+ {
+ var camera = vp.Camera;
+ if (debug) ImGui.Text($"Camera Pointer: {camera.Instance:x}");
+ if (ImGui.DragFloat("FOV", ref camera.FieldOfView, 0.1f))
+ {
+ if (freeCamera && i == vCameraViewportIndex)
+ {
+ cameraFov = camera.FieldOfView;
+ }
+ }
+ if (camera == pCamera)
+ {
+ ImGui.Text($"Internal FOV: {previousFov}");
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("What the FOV would be if not set by us.");
+ ImGui.EndTooltip();
+ }
+ }
+ if (debug) ImGui.InputFloat("Aspect Ratio", ref camera.AspectRatio);
+ ImGui.InputFloat("Near Clip", ref camera.NearClip);
+ ImGui.InputFloat("Far Clip", ref camera.FarClip);
+ if (freeCamera && i == vCameraViewportIndex)
+ {
+ ImGui.DragFloat3("Position", ref cameraPosition, 0.45f);
+ }
+ else
+ {
+ ImGui.DragFloat3("Position", ref camera.Position, 0.45f);
+ }
+ ImGui.DragFloat3("Target", ref camera.Target, 0.45f);
+ ImGui.DragFloat3("Up", ref camera.Up, 0.45f);
+ ImGui.PushItemWidth(width * 0.15f);
+ ImGui.InputText("##Position Name", ref typedPositionName, 99);
+ ImGui.SameLine();
+ if (ImGui.Button("Save"))
+ {
+ string name = typedPositionName;
+ if (name != "")
+ {
+ Config.SavedPosition pos = new Config.SavedPosition();
+ pos.PosX = camera.Position.X;
+ pos.PosY = camera.Position.Y;
+ pos.PosZ = camera.Position.Z;
+ pos.TargetX = camera.Target.X;
+ pos.TargetY = camera.Target.Y;
+ pos.TargetZ = camera.Target.Z;
+ pos.Roll = cameraRoll;
+ if (config.Positions.ContainsKey(name))
+ {
+ config.Positions[name] = pos;
+ }
+ else
+ {
+ config.Positions.Add(name, pos);
+ }
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ }
+ ImGui.SameLine();
+ if (ImGui.BeginCombo("##Positions", selectedPositionName))
+ {
+ Dictionary<string, Config.SavedPosition>.KeyCollection positionKeys = config.Positions.Keys;
+ for (int j = 0; j < positionKeys.Count + 1; j++)
+ {
+ if (j == 0)
+ {
+ if (ImGui.Selectable("(Deselect)"))
+ {
+ selectedPositionName = "";
+ }
+ continue;
+ }
+ string positionKey = positionKeys.ElementAt(j - 1);
+ if (ImGui.Selectable(positionKey))
+ {
+ Config.SavedPosition pos = config.Positions[positionKey];
+ selectedPositionName = positionKey;
+ cameraPosition = new Vector3(pos.PosX, pos.PosY, pos.PosZ);
+ cameraTarget = new Vector3(pos.TargetX, pos.TargetY, pos.TargetZ);
+ Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget));
+ cameraYaw = Double.RadiansToDegrees(Math.Atan2(forward.Z, forward.X));
+ cameraPitch = Double.RadiansToDegrees(Math.Asin(forward.Y));
+ camera.Position = cameraPosition;
+ camera.Target = cameraTarget;
+ cameraRoll = pos.Roll;
+ }
+ }
+ ImGui.EndCombo();
+ }
+ ImGui.PopItemWidth();
+ ImGui.SameLine();
+ if (ImGui.Button("Delete"))
+ {
+ if (selectedPositionName != "")
+ {
+ config.Positions.Remove(selectedPositionName);
+ selectedPositionName = "";
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ }
+ bool move = camera.Move;
+ if (ImGui.Checkbox("Move", ref move))
+ {
+ camera.Move = move;
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Uncheck this to allow manually overriding the camera position.\nIf your camera is frozen, make sure this is checked.");
+ ImGui.EndTooltip();
+ }
+ if (debug)
+ {
+ ImGui.SameLine();
+ bool fix = camera.Fix;
+ if (ImGui.Checkbox("Fix", ref fix))
+ {
+ camera.Fix = fix;
+ }
+ }
+ if (camera == vCamera)
+ {
+ float yaw = (float)cameraYaw;
+ if (ImGui.DragFloat("Yaw", ref yaw, 0.25f))
+ {
+ cameraYaw = yaw;
+ }
+ float pitch = (float)cameraPitch;
+ if (ImGui.DragFloat("Pitch", ref pitch, 0.25f))
+ {
+ cameraPitch = pitch;
+ }
+ float offsetRoll = (float)cameraRoll;
+ if (ImGui.DragFloat("Roll", ref offsetRoll, 0.25f))
+ {
+ cameraRoll = offsetRoll;
+ }
+ if (camera == pCamera && !freeCamera)
+ {
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
+ }
+
+ ImGui.Text("Offset:");
+ float offsetForward = 0.0f;
+ if (ImGui.DragFloat("Forward", ref offsetForward, 0.45f))
+ {
+ Quaternion forward = getForward(camera.Position, camera.Target);
+ forward = Quaternion.Normalize(forward);
+ camera.Position.X += forward.X * offsetForward;
+ camera.Position.Y += forward.Y * offsetForward;
+ camera.Position.Z += forward.Z * offsetForward;
+ cameraPosition = camera.Position;
+ }
+ float offsetRight = 0.0f;
+ if (ImGui.DragFloat("Right", ref offsetRight, 0.45f))
+ {
+ Quaternion forward = getForward(camera.Position, camera.Target);
+ Quaternion right = getRight(forward);
+ forward = Quaternion.Normalize(forward);
+ right = Quaternion.Normalize(right);
+ camera.Position.X += right.X * offsetRight;
+ camera.Position.Z += right.Z * offsetRight;
+ cameraPosition = camera.Position;
+ }
+ if (camera == pCamera && !freeCamera)
+ {
+ ImGui.PopStyleVar();
+ }
+ }
+ }
+ }
+
public void OnImGuiRender()
{
+#if HOOK_ORDER_ASSERTS
+ debugLog($"OnImGuiRender() @ {frameTick}");
+#endif
+
Config config = ConfigManager.GetConfig<Config>(this);
float width = ImGui.GetWindowWidth();
+ // If we use vCamera or pCamera here, we need to verify they're not invalid.
+ Player? player = checkPlayerChange();
+ checkCurrentVisibleCamera(player);
+
if (ImGui.Checkbox("Disable Mod", ref disableMod))
{
if (disableMod)
@@ -1360,9 +1894,8 @@ namespace MHWNewCamera {
vp.Camera.Move = true;
}
- setFadeObjects(i, true);
+ setDisableFadingObjects(i, false);
}
- Player? player = Player.MainPlayer;
if (player != null)
{
player.Rotation.X = 0.0f;
@@ -1372,21 +1905,13 @@ namespace MHWNewCamera {
setLodFactors(false);
}
- if (doubleShadowRes)
+ if (tripleShadowRes)
{
- doubleShadowResDisable();
+ tripleShadowResDisable();
}
- if (largerShadowRange)
+ if (disableLodLimits)
{
- shadowRes4.Disable();
- }
- if (slightlySofterShadows)
- {
- slightlyHigherMinThreshold.Disable();
- }
- if (softerShadows)
- {
- higherMinThreshold.Disable();
+ disableLodLimitsDisable();
}
if (largerFoliageSwayRange)
{
@@ -1403,36 +1928,27 @@ namespace MHWNewCamera {
setLodFactors(true);
}
- if (doubleShadowRes)
- {
- doubleShadowResEnable();
- }
- if (largerShadowRange)
+ if (tripleShadowRes)
{
- shadowRes4.Enable();
+ tripleShadowResEnable();
}
- if (slightlySofterShadows)
+ if (disableLodLimits)
{
- slightlyHigherMinThreshold.Enable();
- }
- if (softerShadows)
- {
- higherMinThreshold.Enable();
+ disableLodLimitsEnable();
}
if (largerFoliageSwayRange)
{
addressHigherValueForFoliageSway.Enable();
}
- if (pCamera != null)
+ if (pCameraViewportIndex >= 0)
{
- setFadeObjects(pCameraViewportIndex, fadeObjects);
+ setDisableFadingObjects(pCameraViewportIndex, disableFading);
}
if (disableCharacterFade)
{
noopCharacterFade.Enable();
}
}
-
config.DisableMod = disableMod;
ConfigManager.SaveConfig<Config>(this);
}
@@ -1463,6 +1979,7 @@ namespace MHWNewCamera }
ImGui.PushID("Perspective");
+ ImGui.PushItemWidth(width * 0.6f);
float singleFov = (float)cameraFov;
if (ImGui.DragFloat("Field of View", ref singleFov, 0.4f, 1.0f, 179.0f))
{
@@ -1480,19 +1997,28 @@ namespace MHWNewCamera preDetachRoll = roll;
}
}
- if (ImGui.Checkbox("Fade Objects When Close to Camera", ref fadeObjects))
+ if (freeCamera)
{
- if (pCamera != null)
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
+ }
+ ImGui.PopItemWidth();
+ if (ImGui.Checkbox("Disable Fading", ref disableFading))
+ {
+ if (pCameraViewportIndex >= 0)
{
- setFadeObjects(pCameraViewportIndex, fadeObjects);
+ setDisableFadingObjects(pCameraViewportIndex, disableFading);
}
- setCharacterFade(fadeObjects);
+ setDisableCharacterFade(disableFading);
}
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Applies to Objects, Characters and Palicos. Credit to Otis_Inf for Objects.");
+ ImGui.Text("Disable transparency fading when the camera gets close to something.\nApplies to Objects, Players, Palicos and NPCs. Credit to Otis_Inf for Objects.\nEnabled by default while in free camera.");
ImGui.EndTooltip();
}
+ if (freeCamera)
+ {
+ ImGui.PopStyleVar();
+ }
if (ImGui.Button("Default"))
{
cameraFov = DEFAULT_FOV;
@@ -1506,12 +2032,12 @@ namespace MHWNewCamera {
preDetachRoll = cameraRoll;
}
- fadeObjects = true;
- if (pCamera != null)
+ disableFading = false;
+ if (pCameraViewportIndex >= 0)
{
- setFadeObjects(pCameraViewportIndex, fadeObjects);
+ setDisableFadingObjects(pCameraViewportIndex, false);
}
- setCharacterFade(fadeObjects);
+ setDisableCharacterFade(false);
config.Selected = "";
ConfigManager.SaveConfig<Config>(this);
}
@@ -1530,7 +2056,7 @@ namespace MHWNewCamera preset.Right = cameraRight;
preset.Up = cameraYOffset;
preset.Roll = cameraRoll;
- preset.FadeObjects = (pCamera != null) ? getFadeObjects(pCameraViewportIndex) : true;
+ preset.DisableFading = (pCameraViewportIndex >= 0) ? getDisableFadingObjects(pCameraViewportIndex) : false;
if (config.Presets.ContainsKey(name))
{
config.Presets[name] = preset;
@@ -1559,18 +2085,20 @@ namespace MHWNewCamera cameraFov = preset.FOV;
cameraForward = preset.Forward;
cameraRight = preset.Right;
+ cameraXOffset = 0.0f;
cameraYOffset = preset.Up;
+ cameraZOffset = 0.0f;
cameraRoll = preset.Roll;
if (preDetachRoll != null)
{
preDetachRoll = cameraRoll;
}
- fadeObjects = preset.FadeObjects;
- if (pCamera != null)
+ disableFading = preset.DisableFading;
+ if (pCameraViewportIndex >= 0)
{
- setFadeObjects(pCameraViewportIndex, fadeObjects);
+ setDisableFadingObjects(pCameraViewportIndex, disableFading);
}
- setCharacterFade(fadeObjects);
+ setDisableCharacterFade(disableFading);
}
if (isSelected) ImGui.SetItemDefaultFocus();
}
@@ -1590,30 +2118,26 @@ namespace MHWNewCamera ImGui.PopID();
ImGui.PushID("Settings");
+ ImGui.PushItemWidth(width * 0.6f);
ImGui.DragFloat("Camera Speed", ref cameraSpeed, 0.01f, 0.0f);
if (ImGui.BeginItemTooltip())
{
ImGui.Text("Movement speed in free camera.");
ImGui.EndTooltip();
}
- ImGui.DragFloat("Zoom Speed", ref cameraZoomSpeed, 0.01f, 0.0f);
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("Rate of camera zoom.");
- ImGui.EndTooltip();
- }
ImGui.DragFloat("Speed Modifier", ref cameraSpeedModifier, 0.01f, 0.0f);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Value to multiply speed by when RT is held.");
+ ImGui.Text("Value to multiply speed by when LT is held.");
ImGui.EndTooltip();
}
ImGui.DragFloat("Camera Sensitivity", ref cameraSensitivity, 0.0025f, 0.0f);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Camera look sensitivity in free camera.");
+ ImGui.Text("Look sensitivity in free camera.");
ImGui.EndTooltip();
}
+ ImGui.DragFloat("Zoom Speed", ref cameraZoomSpeed, 0.01f, 0.0f);
float pitchLimit = (float)cameraPitchLimit;
if (ImGui.InputFloat("Pitch Limit", ref pitchLimit, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue))
{
@@ -1629,12 +2153,13 @@ namespace MHWNewCamera ImGui.EndTooltip();
}
ImGui.InputInt("Stick Deadzone", ref stickDeadzone, 10);
+ ImGui.PopItemWidth();
if (ImGui.Button("Default"))
{
cameraSpeed = Config.Settings.DEFAULT_SPEED;
- cameraZoomSpeed = Config.Settings.DEFAULT_ZOOM_SPEED;
cameraSpeedModifier = Config.Settings.DEFAULT_SPEED_MODIFIER;
cameraSensitivity = Config.Settings.DEFAULT_SENSITIVITY;
+ cameraZoomSpeed = Config.Settings.DEFAULT_ZOOM_SPEED;
cameraPitchLimit = Config.Settings.DEFAULT_PITCH_LIMIT;
stickDeadzone = Config.Settings.DEFAULT_DEADZONE;
}
@@ -1643,9 +2168,9 @@ namespace MHWNewCamera {
Config.Settings settings = config.CameraSettings;
cameraSpeed = settings.CameraSpeed;
- cameraZoomSpeed = settings.CameraZoomSpeed;
cameraSpeedModifier = settings.CameraSpeedModifier;
cameraSensitivity = settings.CameraSensitivity;
+ cameraZoomSpeed = settings.CameraZoomSpeed;
cameraPitchLimit = settings.CameraPitchLimit;
stickDeadzone = settings.StickDeadzone;
}
@@ -1654,9 +2179,9 @@ namespace MHWNewCamera {
Config.Settings settings = config.CameraSettings;
settings.CameraSpeed = cameraSpeed;
- settings.CameraZoomSpeed = cameraZoomSpeed;
settings.CameraSpeedModifier = cameraSpeedModifier;
settings.CameraSensitivity = cameraSensitivity;
+ settings.CameraZoomSpeed = cameraZoomSpeed;
settings.CameraPitchLimit = cameraPitchLimit;
settings.StickDeadzone = stickDeadzone;
config.CameraSettings = settings;
@@ -1664,7 +2189,10 @@ namespace MHWNewCamera }
ImGui.PopID();
+ ImGui.Separator();
+
ImGui.PushID("Toggles");
+ ImGui.Text("Toggles");
if (!freeCamera)
{
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
@@ -1672,19 +2200,19 @@ namespace MHWNewCamera ImGui.Checkbox("Unlock Player Movement", ref unlockMovementToggled);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("LT+LB");
+ ImGui.Text("Hold RT + Press LB.");
ImGui.EndTooltip();
}
- ImGui.Checkbox("Lock Vertical Movement", ref lockVerticalToggled);
+ ImGui.Checkbox("Unlock Input to the Game", ref unlockInputToggled);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("RT+LB. Will also lock Speed Modifier on.");
+ ImGui.Text("Hold LT + Press RB.");
ImGui.EndTooltip();
}
- ImGui.Checkbox("Unlock Input", ref unlockInputToggled);
+ ImGui.Checkbox("Lock Vertical Movement and Apply Speed Modifier", ref lockVerticalToggled);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("LT+RB");
+ ImGui.Text("Hold LT + Press LB.");
ImGui.EndTooltip();
}
if (!freeCamera)
@@ -1704,11 +2232,63 @@ namespace MHWNewCamera }
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("RT+RB. The scoutfly marker on menus will still be visible.");
+ ImGui.Text("Hold Select + Press A. The scoutfly marker on menus will still be visible.");
+ ImGui.EndTooltip();
+ }
+ ImGui.Checkbox("Force Depth of Field Off", ref forceOffDof);
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Hold Select + Press B. Works to disable depth of field in cutscenes. Credit to Otis_Inf.");
ImGui.EndTooltip();
}
+ if (vCamera != null)
+ {
+ bool reducedNearClip = vCamera.NearClip == 0.5f;
+ if (ImGui.Checkbox("Reduce Near Clip", ref reducedNearClip))
+ {
+ if (reducedNearClip)
+ {
+ vCamera.NearClip = 0.5f;
+ }
+ else
+ {
+ vCamera.NearClip = DEFAULT_NEAR_CLIP;
+ }
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Hold Select + Press X. Allows you to get the camera closer to things without clipping but breaks rendering farther from the camera.");
+ ImGui.EndTooltip();
+ }
+ }
ImGui.PopID();
+ ImGui.Separator();
+
+ ImGui.Text("When Close to the Camera");
+ if (vCameraViewportIndex >= 0)
+ {
+ bool disableFadingObjects = getDisableFadingObjects(vCameraViewportIndex);
+ if (ImGui.Checkbox("Disable Fading Objects", ref disableFadingObjects))
+ {
+ setDisableFadingObjects(vCameraViewportIndex, disableFadingObjects);
+ }
+ }
+
+ if (ImGui.Checkbox("Disable Fading Player/Palico/NPCs", ref disableCharacterFade))
+ {
+ if (disableCharacterFade)
+ {
+ noopCharacterFade.Enable();
+ }
+ else
+ {
+ noopCharacterFade.Disable();
+ }
+ }
+
+ ImGui.Separator();
+
ImGui.PushID("Binds");
if (ImGui.CollapsingHeader("Binds"))
{
@@ -1750,150 +2330,392 @@ namespace MHWNewCamera ConfigManager.SaveConfig<Config>(this);
}
}
+ ImGui.SameLine();
if (ImGui.Checkbox("Disable Button 1 Unless Button 2 is Held", ref disableComboButton1))
{
comboButton1Down = false;
config.DisableComboButton1UnlessButton2Held = disableComboButton1;
ConfigManager.SaveConfig<Config>(this);
}
- }
- ImGui.PopID();
-
- ImGui.PushID("Debug");
- if (ImGui.CollapsingHeader("DEBUG/Extras"))
- {
- ImGui.Checkbox("Debug Button", ref debugButton);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Currently toggles how early camera Y position and FOV are set (off = earlier).\nIf you want to see why: Go out, set a large \"Up\" offset, aim in your slinger and click this button on and off.");
+ ImGui.Text("For example, if bound to \"RStick+LT\", right stick presses will ignored by the game unless you're holding the left trigger.\nIn that case, it can let you avoid switching the targeted monster when toggling free camera.");
ImGui.EndTooltip();
}
-
- if (pCamera != null)
+ ImGui.Text("While in Free Camera");
+ if (ImGui.BeginItemTooltip())
{
- ImGui.Separator();
- ImGui.Text($"Player Camera: {pCamera.Instance:x}");
- ImGui.Text($"Applying Offset: {applyPerspective}");
- ImGui.Text($"previousCameraAnimState: {previousCameraAnimState}");
+ ImGui.Text("Set Camera Mouse Controls to Off in Options -> Camera for a better experience.");
+ ImGui.EndTooltip();
}
+ if (ImGui.BeginTable("Binds", 2, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.Borders))
+ {
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold RT (+ Press LB; Toggle)");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Unlock Player Movement and Freeze Camera Movement");
- ImGui.Separator();
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold LT (+ Press LB; Toggle)");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Lock Vertical Camera Movement and Apply Speed Modifier");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold LT + Press RB");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Toggle Unlock Input to the Game");
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Applies to every controller input except left stick player movement.");
+ ImGui.EndTooltip();
+ }
+ ImGui.EndTable();
+ }
+ ImGui.Text("Disabled While Input to the Game is Unlocked");
+ if (ImGui.BeginTable("More Binds", 2, ImGuiTableFlags.SizingStretchProp | ImGuiTableFlags.Borders))
+ {
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold Select + Press A");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Toggle UI");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold Select + Press B");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Toggle Depth of Field");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold Select + Press X");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Toggle Reduced Near Clip (16.0 -> 0.5)");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("D-Pad Up/Down");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Translate Camera Up/Down");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("D-Pad Left/Right");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Roll Camera");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold Y + Press D-Pad Left/Right");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Reset Roll");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold LT & RT");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Zoom with Left Stick Up/Down");
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("If you have DOF (Depth of Field) enabled in Advanced Graphics Settings, this will also move the focal point.");
+ ImGui.EndTooltip();
+ }
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold Y + Press D-Pad Up");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Reset Zoom");
+
+ ImGui.TableNextRow();
+ ImGui.TableSetColumnIndex(0);
+ ImGui.Text("Hold Y + Press D-Pad Down");
+ ImGui.TableSetColumnIndex(1);
+ ImGui.Text("Teleport Player to Camera Position");
+
+ ImGui.EndTable();
+ }
+ }
+ ImGui.PopID();
- if (ImGui.Checkbox("2x Shadow Resolution (Requires Reload)", ref doubleShadowRes))
+ ImGui.PushID("Player");
+ if (ImGui.CollapsingHeader("Player") && player != null)
+ {
+ ImGui.DragFloat3("Position", ref player.Position, 0.5f);
+ Vector3 forward;
+ forward.X = player.Forward.X;
+ forward.Y = player.Forward.Y;
+ forward.Z = player.Forward.Z;
+ ImGui.DragFloat3("Forward", ref forward, 0.0f);
+ Vector4 rotation;
+ rotation.X = player.Rotation.X;
+ rotation.Y = player.Rotation.Y;
+ rotation.Z = player.Rotation.Z;
+ rotation.W = player.Rotation.W;
+ if (ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f))
+ {
+ player.Rotation.X = rotation.X;
+ player.Rotation.Y = rotation.Y;
+ player.Rotation.Z = rotation.Z;
+ player.Rotation.W = rotation.W;
+ }
+ if (ImGui.Button("Reset"))
+ {
+ player.Rotation.X = 0.0f;
+ player.Rotation.Z = 0.0f;
+ }
+ if (ImGui.Checkbox("Disable Collision", ref disableCollision))
{
- if (doubleShadowRes)
+ if (disableCollision)
{
- doubleShadowResEnable();
+ disableCollisionEnable();
}
else
{
- doubleShadowResDisable();
+ if (disableExtraGravity)
+ {
+ disableExtraGravity = false;
+ disableExtraGravityDisable();
+ }
+ if (disableGravity)
+ {
+ disableGravity = false;
+ disableGravityDisable();
+ }
+ if (disableExtraCollision)
+ {
+ disableExtraCollision = false;
+ disableExtraCollisionDisable();
+ }
+ disableCollisionDisable();
}
- config.DoubleShadowResolution = doubleShadowRes;
- ConfigManager.SaveConfig<Config>(this);
}
- if (ImGui.BeginItemTooltip())
+ if (!disableCollision)
{
- ImGui.Text("Reload shadows by toggling \"Shadow Quality\" in the options.");
- ImGui.EndTooltip();
+ ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
}
-
- if (ImGui.Checkbox("Larger Shadow Range (Requires Reload)", ref largerShadowRange))
+ if (ImGui.Checkbox("Disable Another Y Collision", ref disableExtraCollision))
{
- if (largerShadowRange)
+ if (disableExtraCollision)
{
- shadowRes4.Enable();
+ disableExtraCollisionEnable();
}
else
{
- shadowRes4.Disable();
+ if (disableExtraGravity)
+ {
+ disableExtraGravity = false;
+ disableExtraGravityDisable();
+ }
+ if (disableGravity)
+ {
+ disableGravity = false;
+ disableGravityDisable();
+ }
+ disableExtraCollisionDisable();
}
- config.LargerShadowRange = largerShadowRange;
- ConfigManager.SaveConfig<Config>(this);
}
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("This only seems to affect far shadows and not the very close fade-to-blob range.");
+ ImGui.Text("This will make your legs goofy, but is needed to get on top of some things.");
ImGui.EndTooltip();
}
-
- if (softerShadows)
+ if (!disableCollision)
+ {
+ ImGui.PopItemFlag();
+ ImGui.PopStyleVar();
+ }
+ if (!disableExtraCollision)
{
ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
}
- if (ImGui.Checkbox("Slightly Softer Shadows", ref slightlySofterShadows))
+ if (ImGui.Checkbox("Disable Y Gravity", ref disableGravity))
{
- if (slightlySofterShadows)
+ if (disableGravity)
{
- slightlyHigherMinThreshold.Enable();
+ disableGravityEnable();
}
else
{
- slightlyHigherMinThreshold.Disable();
+ if (disableExtraGravity)
+ {
+ disableExtraGravity = false;
+ disableExtraGravityDisable();
+ }
+ disableGravityDisable();
}
- config.SlightlySofterShadows = slightlySofterShadows;
- ConfigManager.SaveConfig<Config>(this);
}
- if (softerShadows)
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Avoid falling when going too high (Y axis).");
+ ImGui.EndTooltip();
+ }
+ if (!disableExtraCollision)
{
ImGui.PopItemFlag();
ImGui.PopStyleVar();
}
-
- if (slightlySofterShadows)
+ if (!disableGravity)
{
ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
}
- if (ImGui.Checkbox("Softer Shadows", ref softerShadows))
+ if (ImGui.Checkbox("Disable More Gravity", ref disableExtraGravity))
{
- if (softerShadows)
+ if (disableExtraGravity)
{
- higherMinThreshold.Enable();
+ disableExtraGravityEnable();
}
else
{
- higherMinThreshold.Disable();
+ disableExtraGravityDisable();
}
- config.SofterShadows = softerShadows;
- ConfigManager.SaveConfig<Config>(this);
}
- if (slightlySofterShadows)
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("This can stop you from falling when going out of bounds and/or rotating.");
+ ImGui.EndTooltip();
+ }
+ if (!disableGravity)
{
ImGui.PopItemFlag();
ImGui.PopStyleVar();
}
+ }
+ ImGui.PopID();
+
+ ImGui.PushID("Viewport");
+ if (ImGui.CollapsingHeader("Viewport") && vCameraViewportIndex >= 0)
+ {
+ drawViewportInfo(vCameraViewportIndex, width, config, false);
+ }
+ ImGui.PopID();
+
+ ImGui.PushID("Graphics");
+ if (ImGui.CollapsingHeader("Graphical Enhancements"))
+ {
+ if (ImGui.Checkbox("3x Shadow Resolution (Requires Reload)", ref tripleShadowRes))
+ {
+ if (tripleShadowRes)
+ {
+ tripleShadowResEnable();
+ }
+ else
+ {
+ tripleShadowResDisable();
+ }
+ config.TripleShadowResolution = tripleShadowRes;
+ ConfigManager.SaveConfig<Config>(this);
+ }
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("When 2x shadow resolution is enabled and \"Shadow Quality\" is set to \"High\", this matches the original \"High\" setting.");
+ ImGui.Text("In-Game Settings:\n - High: 1.0 -> 3.0\n - Mid: 0.7 -> 2.1\n - Low: 0.5 -> 1.5\nReload shadows by toggling Shadow Quality in Options -> Display -> Advanced Graphics Settings.");
ImGui.EndTooltip();
}
- ImGui.InputFloat("Unknown LOD Factor 1", ref unknownLod1);
+ ImGui.PushItemWidth(width * 0.125f);
+ if (ImGui.Checkbox("##Apply Larger Shadow Range", ref applyShadowBias))
+ {
+ config.ApplyShadowRange = applyShadowBias;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ ImGui.SameLine();
+ if (ImGui.InputFloat("Shadow Range", ref offsetBiasBy, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue))
+ {
+ config.ShadowRangeOffset = offsetBiasBy;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("This will inversely reduce the detail of shadows closer to the camera (like the player shadow), so it's a trade-off.\nValue is an offset. Recommended: 0.5.");
+ ImGui.EndTooltip();
+ }
+ if (ImGui.Checkbox("##Apply Radius", ref applyShadowRadius))
+ {
+ config.ApplyShadowRadius = applyShadowRadius;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ ImGui.SameLine();
+ if (ImGui.InputFloat("Shadow Radius", ref offsetRadiusBy, 0.0f, 0.0f, "%.5f", ImGuiInputTextFlags.EnterReturnsTrue))
+ {
+ config.ShadowRadiusOffset = offsetRadiusBy;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Amount of softening for realtime shadows.\nValue is an offset. Recommended: 0.0005.");
+ ImGui.EndTooltip();
+ }
+ /*
+ ImGui.Checkbox("##Apply SampleNum", ref applyShadowSampleNum);
+ ImGui.SameLine();
+ ImGui.InputFloat("Offset Shadow SampleNum", ref offsetSampleNumBy, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue);
+ */
+ ImGui.PopItemWidth();
+
+ if (ImGui.Checkbox("Higher Shadow Detail in Hoarfrost Reach/Seliana Gathering Hub", ref lowShadowDetailOverride))
+ {
+ config.HigherShadowDetailInHoarfrost = lowShadowDetailOverride;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("Disable reduced detail/range shadows in Hoarfrost Reach and Seliana Gathering Hub.");
+ ImGui.EndTooltip();
+ }
+
+ if (ImGui.Checkbox("Disable Player/Palico/NPC LOD Limit in Gameplay", ref disableLodLimits))
+ {
+ if (disableLodLimits)
+ {
+ disableLodLimitsEnable();
+ }
+ else
+ {
+ disableLodLimitsDisable();
+ }
+ config.DisableLodLimits = disableLodLimits;
+ ConfigManager.SaveConfig<Config>(this);
+ }
+ if (ImGui.BeginItemTooltip())
+ {
+ ImGui.Text("This will make the default (gameplay) LOD limits equivalent to View Mode. Disabling the limit on:\n - Player Models & Shadows\n - Palico Models & Shadows\n - NPC Models & Shadows\n - Simple NPC Models & Shadows\nAlso equivalent to the settings applied in your room with the addition of disabled \"Simple NPC\" limits.");
+ ImGui.EndTooltip();
+ }
+
+ ImGui.PushItemWidth(width * 0.1f);
+ ImGui.InputFloat("##Foliage LOD Bias", ref foliageLodBias, 0.0f, 0.0f, "%.2f");
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Default: 1.0, Best Quality: 0.0.");
+ ImGui.Text("In-Game Settings:\n - High: 3.0\n - Mid: 1.0\n - Low: 0.9\n - Variable: -1.0\nHigher value = Farther distance before plants switch to a lower LOD.");
ImGui.EndTooltip();
}
- ImGui.InputFloat("Unknown LOD Factor 2", ref unknownLod2);
+ ImGui.SameLine();
+ ImGui.InputFloat("Foliage LOD Bias", ref foliageLodFactor, 0.0f, 0.0f, "%.2f");
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Seems to control whether some objects are still drawn when very far from the camera.\nDefault: 1.0, Best Quality: 0.0.");
+ ImGui.Text("Controls the distance at which the game decides to no longer render some plants.\nCan be effectively overridden by a high first value.\nDefault: 1.0, Best Quality: 0.0.");
ImGui.EndTooltip();
}
- ImGui.InputFloat("Foliage LOD Factor", ref foliageLodFactor);
+ ImGui.InputFloat("##Terrain/Object LOD Bias", ref terrainLodBias, 0.0f, 0.0f, "%.2f");
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("This can sometimes look a bit off when set >1.0.\nDefault: 1.0, Best Quality: 64.0.");
+ ImGui.Text("In-Game Settings:\n - High: 3.0\n - Mid: 1.0\n - Low: 0.9\n - Variable: -1.0\nHigher value = Farther distance before objects switch to a lower LOD.");
ImGui.EndTooltip();
}
- ImGui.InputFloat("Terrain/Object LOD Factor", ref terrainLodFactor);
+ ImGui.SameLine();
+ ImGui.InputFloat("Terrain/Object LOD Bias", ref terrainLodFactor, 0.0f, 0.0f, "%.2f");
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Default: 1.0, Best Quality: 64.0.");
+ ImGui.Text("Controls the distance at which the game decides to no longer render some objects.\nCan be effectively overridden by a high first value.\nDefault: 1.0, Best Quality: 0.0.");
ImGui.EndTooltip();
}
+ ImGui.PopItemWidth();
bool lodsSet = areLodFactorsSet();
bool disableLodButton = lodsSet && areLodFactorsDefault();
if (disableLodButton)
@@ -1902,14 +2724,14 @@ namespace MHWNewCamera ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
lodsSet = false;
}
- if (ImGui.Checkbox("Apply LOD Factors", ref lodsSet))
+ if (ImGui.Checkbox("Apply LOD Biases", ref lodsSet))
{
setLodFactors(lodsSet);
config.ApplyLodFactors = lodsSet && !areLodFactorsDefault();
if (lodsSet)
{
- config.LodFactor1 = unknownLod1;
- config.LodFactor2 = unknownLod2;
+ config.FoliageLodBias = foliageLodBias;
+ config.TerrainLodBias = terrainLodBias;
config.FoliageLodFactor = foliageLodFactor;
config.TerrainLodFactor = terrainLodFactor;
}
@@ -1939,171 +2761,36 @@ namespace MHWNewCamera config.LargerFoliageSwayRange = largerFoliageSwayRange;
ConfigManager.SaveConfig<Config>(this);
}
-
- ImGui.Separator();
-
- if (ImGui.Checkbox("Disable Character/Palico Fade", ref disableCharacterFade))
+ if (ImGui.BeginItemTooltip())
{
- if (disableCharacterFade)
- {
- noopCharacterFade.Enable();
- }
- else
- {
- noopCharacterFade.Disable();
- }
+ ImGui.Text("Increase the distance at which Foliage Sway is still applied to lower priority plants.");
+ ImGui.EndTooltip();
}
+ }
+ ImGui.PopID();
- ImGui.Separator();
+ ImGui.PushID("Debug");
+ if (ImGui.CollapsingHeader("DEBUG"))
+ {
+ if (pCamera != null)
+ {
+ ImGui.Text($"Player Camera: {pCamera.Instance:x}");
+ ImGui.Text($"Applying Offset: {applyPerspective}");
+ ImGui.Text($"previousCameraAnimState: {previousCameraAnimState}");
+ ImGui.Text($"dofPointer: {dofPointer:x}");
+ ImGui.Text($"shadowCascadeValue: {lastShadowCascadeValue}");
+ ImGui.Text($"shadowBias: {lastShadowBias}");
+ ImGui.Text($"shadowRadius: {lastShadowRadius}");
+ ImGui.Text($"shadowSampleNum: {lastShadowSampleNum}");
+ ImGui.Separator();
+ }
- ImGui.PushID("Player");
- Player? player = Player.MainPlayer;
- if (ImGui.CollapsingHeader("Player") && player != null)
+ if (player != null)
{
- ImGui.Text("Player:");
+ ImGui.PushID("Player");
+ ImGui.Text("Player");
ImGui.Text($"Pointer: {player.Instance:x}");
- ImGui.DragFloat3("Position", ref player.Position, 0.5f);
- Vector3 forward;
- forward.X = player.Forward.X;
- forward.Y = player.Forward.Y;
- forward.Z = player.Forward.Z;
- ImGui.DragFloat3("Forward", ref forward, 0.0f);
- if (ImGui.Checkbox("Disable Collision", ref disableCollision))
- {
- if (disableCollision)
- {
- disableCollisionEnable();
- }
- else
- {
- if (disableExtraGravity)
- {
- disableExtraGravity = false;
- disableExtraGravityDisable();
- }
- if (disableGravity)
- {
- disableGravity = false;
- disableGravityDisable();
- }
- if (disableExtraCollision)
- {
- disableExtraCollision = false;
- disableExtraCollisionDisable();
- }
- disableCollisionDisable();
- }
- }
- if (!disableCollision)
- {
- ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
- ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
- }
- if (ImGui.Checkbox("Disable Another Y Collision", ref disableExtraCollision))
- {
- if (disableExtraCollision)
- {
- disableExtraCollisionEnable();
- }
- else
- {
- if (disableExtraGravity)
- {
- disableExtraGravity = false;
- disableExtraGravityDisable();
- }
- if (disableGravity)
- {
- disableGravity = false;
- disableGravityDisable();
- }
- disableExtraCollisionDisable();
- }
- }
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("This will make your legs goofy, but it's needed to get on top of some things.");
- ImGui.EndTooltip();
- }
- if (!disableCollision)
- {
- ImGui.PopItemFlag();
- ImGui.PopStyleVar();
- }
- if (!disableExtraCollision)
- {
- ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
- ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
- }
- if (ImGui.Checkbox("Disable Y Gravity", ref disableGravity))
- {
- if (disableGravity)
- {
- disableGravityEnable();
- }
- else
- {
- if (disableExtraGravity)
- {
- disableExtraGravity = false;
- disableExtraGravityDisable();
- }
- disableGravityDisable();
- }
- }
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("Avoid falling when going too high (Y axis).");
- ImGui.EndTooltip();
- }
- if (!disableExtraCollision)
- {
- ImGui.PopItemFlag();
- ImGui.PopStyleVar();
- }
- if (!disableGravity)
- {
- ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
- ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
- }
- if (ImGui.Checkbox("Disable More Gravity", ref disableExtraGravity))
- {
- if (disableExtraGravity)
- {
- disableExtraGravityEnable();
- }
- else
- {
- disableExtraGravityDisable();
- }
- }
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("This can stop you from starting to fall when going out of bounds and/or rotating.");
- ImGui.EndTooltip();
- }
- if (!disableGravity)
- {
- ImGui.PopItemFlag();
- ImGui.PopStyleVar();
- }
- Vector4 rotation;
- rotation.X = player.Rotation.X;
- rotation.Y = player.Rotation.Y;
- rotation.Z = player.Rotation.Z;
- rotation.W = player.Rotation.W;
- if (ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f))
- {
- player.Rotation.X = rotation.X;
- player.Rotation.Y = rotation.Y;
- player.Rotation.Z = rotation.Z;
- player.Rotation.W = rotation.W;
- }
- if (ImGui.Button("Reset"))
- {
- player.Rotation.X = 0.0f;
- player.Rotation.Z = 0.0f;
- }
+
ActionInfo currentActionInfo = player.ActionController.CurrentAction;
SharpPluginLoader.Core.Actions.Action? currentAction = null;
if (currentActionInfo.ActionSet >= 0 && currentActionInfo.ActionSet <= 3)
@@ -2135,13 +2822,13 @@ namespace MHWNewCamera nint offset = MemoryUtil.Read<nint>(0x1451C4640);
if (offset != 0)
{
- offset += 0x13FD0;
- offset = MemoryUtil.Read<nint>(offset);
- if (offset != 0)
- {
- offset += 0xB734;
- playerInMenu = MemoryUtil.Read<int>(offset) == 1;
- }
+ offset += 0x13FD0;
+ offset = MemoryUtil.Read<nint>(offset);
+ if (offset != 0)
+ {
+ offset += 0xB734;
+ playerInMenu = MemoryUtil.Read<int>(offset) == 1;
+ }
}
ImGui.Text($"In Menu: {playerInMenu}");
*/
@@ -2156,191 +2843,29 @@ namespace MHWNewCamera {
player.Fix = fix;
}
- }
- ImGui.PopID();
+ ImGui.PopID();
- ImGui.Separator();
+ ImGui.Separator();
- ImGui.PushID("Palico");
- ImGui.Text("Palico/Otomo:");
- ImGui.Text($"Pointer: {sOtomo.Instance:x}");
- ImGui.PopID();
+ ImGui.PushID("Palico");
+ ImGui.Text("Palico/Otomo");
+ ImGui.Text($"Pointer: {sOtomo.Instance:x}");
+ ImGui.PopID();
+ }
ImGui.Separator();
-
ImGui.PushID("Camera");
- ImGui.Text("Camera/Viewport:");
+ ImGui.Text("Perspective Camera");
+ ImGui.DragFloat("X Offset", ref cameraXOffset, 0.45f);
+ ImGui.DragFloat("Y Offset", ref cameraYOffset, 0.45f);
+ ImGui.DragFloat("Z Offset", ref cameraZOffset, 0.45f);
+ ImGui.Text("Viewports");
for (int i = 0; i < 8; i++)
{
ImGui.PushID($"Viewport{i}");
- Viewport vp = CameraSystem.GetViewport(i);
- if (ImGui.CollapsingHeader($"Viewport #{i} ({(vp.Visible ? "visible" : "inactive")})"))
+ if (ImGui.CollapsingHeader($"Viewport #{i} ({((i == vCameraViewportIndex) ? "visible" : "inactive")})"))
{
- ImGui.Text($"Pointer: {vp.Instance:x}");
- ImGui.Text($"Visible: {vp.Visible}");
- ImGui.Text($"Region: {vp.Region.X} {vp.Region.Y} {vp.Region.Width} {vp.Region.Height}");
- bool fadingObjects = getFadeObjects(i);
- if (ImGui.Checkbox("Fade Objects When Close to Camera", ref fadingObjects))
- {
- setFadeObjects(i, fadingObjects);
- }
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("Credit to Otis_Inf.");
- ImGui.EndTooltip();
- }
- if (vp.Camera != null)
- {
- ImGui.InputFloat("X Offset", ref cameraXOffset);
- ImGui.InputFloat("Y Offset", ref cameraYOffset);
- ImGui.InputFloat("Z Offset", ref cameraZOffset);
- var camera = vp.Camera;
- ImGui.Text($"Camera Pointer: {camera.Instance:x}");
- ImGui.DragFloat("FOV", ref camera.FieldOfView, 0.45f);
- if (camera == pCamera)
- {
- ImGui.Text($"Internal FOV: {previousFov}");
- if (ImGui.BeginItemTooltip())
- {
- ImGui.Text("What the FOV would be if not set by us.");
- ImGui.EndTooltip();
- }
- }
- ImGui.InputFloat("Aspect Ratio", ref camera.AspectRatio);
- ImGui.InputFloat("Far Clip", ref camera.FarClip);
- ImGui.InputFloat("Near Clip", ref camera.NearClip);
- ImGui.DragFloat3("Position", ref camera.Position, 0.45f);
- ImGui.DragFloat3("Target", ref camera.Target, 0.45f);
- ImGui.DragFloat3("Up", ref camera.Up, 0.45f);
- ImGui.PushItemWidth(width * 0.15f);
- ImGui.InputText("##Position Name", ref typedPositionName, 99);
- ImGui.SameLine();
- if (ImGui.Button("Save"))
- {
- string name = typedPositionName;
- if (name != "")
- {
- Config.SavedPosition pos = new Config.SavedPosition();
- pos.PosX = camera.Position.X;
- pos.PosY = camera.Position.Y;
- pos.PosZ = camera.Position.Z;
- pos.TargetX = camera.Target.X;
- pos.TargetY = camera.Target.Y;
- pos.TargetZ = camera.Target.Z;
- pos.Roll = cameraRoll;
- if (config.Positions.ContainsKey(name))
- {
- config.Positions[name] = pos;
- }
- else
- {
- config.Positions.Add(name, pos);
- }
- ConfigManager.SaveConfig<Config>(this);
- }
- }
- ImGui.SameLine();
- if (ImGui.BeginCombo("##Positions", selectedPositionName))
- {
- Dictionary<string, Config.SavedPosition>.KeyCollection positionKeys = config.Positions.Keys;
- for (int j = 0; j < positionKeys.Count + 1; j++)
- {
- if (j == 0)
- {
- if (ImGui.Selectable("(Deselect)"))
- {
- selectedPositionName = "";
- }
- continue;
- }
- string positionKey = positionKeys.ElementAt(j - 1);
- if (ImGui.Selectable(positionKey))
- {
- Config.SavedPosition pos = config.Positions[positionKey];
- selectedPositionName = positionKey;
- cameraPosition = new Vector3(pos.PosX, pos.PosY, pos.PosZ);
- cameraTarget = new Vector3(pos.TargetX, pos.TargetY, pos.TargetZ);
- Quaternion forward = Quaternion.Normalize(getForward(cameraPosition, cameraTarget));
- cameraYaw = Double.RadiansToDegrees(Math.Atan2(forward.Z, forward.X));
- cameraPitch = Double.RadiansToDegrees(Math.Asin(forward.Y));
- camera.Position = cameraPosition;
- camera.Target = cameraTarget;
- cameraRoll = pos.Roll;
- }
- }
- ImGui.EndCombo();
- }
- ImGui.PopItemWidth();
- ImGui.SameLine();
- if (ImGui.Button("Delete"))
- {
- if (selectedPositionName != "")
- {
- config.Positions.Remove(selectedPositionName);
- selectedPositionName = "";
- ConfigManager.SaveConfig<Config>(this);
- }
- }
- if (camera == vCamera)
- {
- float yaw = (float)cameraYaw;
- if (ImGui.DragFloat("Yaw", ref yaw, 0.25f))
- {
- cameraYaw = yaw;
- }
- float pitch = (float)cameraPitch;
- if (ImGui.DragFloat("Pitch", ref pitch, 0.25f))
- {
- cameraPitch = pitch;
- }
- float offsetRoll = (float)cameraRoll;
- if (ImGui.DragFloat("Roll", ref offsetRoll, 0.25f))
- {
- cameraRoll = offsetRoll;
- }
- if (camera == pCamera && !freeCamera)
- {
- ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
- }
- ImGui.Text("Offset:");
- float offsetForward = 0.0f;
- if (ImGui.DragFloat("Forward", ref offsetForward, 0.45f))
- {
- Quaternion forward = getForward(camera.Position, camera.Target);
- forward = Quaternion.Normalize(forward);
- camera.Position.X += forward.X * offsetForward;
- camera.Position.Y += forward.Y * offsetForward;
- camera.Position.Z += forward.Z * offsetForward;
- cameraPosition = camera.Position;
- }
- float offsetRight = 0.0f;
- if (ImGui.DragFloat("Right", ref offsetRight, 0.45f))
- {
- Quaternion forward = getForward(camera.Position, camera.Target);
- Quaternion right = forward * Quaternion.CreateFromRotationMatrix(Matrix4x4.CreateRotationY(Single.DegreesToRadians(180.0f)));
- forward = Quaternion.Normalize(forward);
- right = Quaternion.Normalize(right);
- camera.Position.X += right.X * offsetRight;
- camera.Position.Z += right.Z * offsetRight;
- cameraPosition = camera.Position;
- }
- if (camera == pCamera && !freeCamera)
- {
- ImGui.PopStyleVar();
- }
- }
- bool move = camera.Move;
- if (ImGui.Checkbox("Move", ref move))
- {
- camera.Move = move;
- }
- ImGui.SameLine();
- bool fix = camera.Fix;
- if (ImGui.Checkbox("Fix", ref fix))
- {
- camera.Fix = fix;
- }
- }
+ drawViewportInfo(i, width, config, true);
}
ImGui.PopID();
}
@@ -2349,7 +2874,7 @@ namespace MHWNewCamera ImGui.Separator();
ImGui.PushID("Pad");
- ImGui.Text("Pad:");
+ ImGui.Text("Pad");
ImGui.Text($"Pointer: {controllerAddr():x}");
int PadRx = MemoryUtil.Read<int>(controllerAddr() + 0x1B0);
int PadRy = MemoryUtil.Read<int>(controllerAddr() + 0x1B4);
|