diff options
| -rwxr-xr-x | Config.cs | 11 | ||||
| -rwxr-xr-x | Plugin.cs | 614 |
2 files changed, 366 insertions, 259 deletions
@@ -55,7 +55,7 @@ namespace MHWNewCamera }
public String Name => "MHWNewCamera";
- public String Version => "2.0";
+ public String Version => "2.1";
private static Dictionary<string, Button> buttonMap = new Dictionary<string, Button>
{
@@ -104,12 +104,15 @@ namespace MHWNewCamera public String Selected { get; set; } = "";
public Dictionary<String, SavedPosition> Positions { get; set; } = new Dictionary<String, SavedPosition>();
- public bool DisableCharacterFade { get; set; } = false;
-
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 HigherLods { 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; } = 1.0f;
+ public float TerrainLodFactor { get; set; } = 32.0f;
public bool LargerFoliageSwayRange { get; set; } = false;
}
}
@@ -17,14 +17,19 @@ using System.Diagnostics; #endif
// @TODO:
+// - Thoroughly test "Disable Mod".
+// - Improve AOB scans.
// - White vase thing in research base still fades when close.
-// - Shadow cache size? or shadow map count?
+// - How to change closer shadow "fade" range.
// - Display equiped armor in the debug UI.
// - Manully set freecam viewport index.
// - Override in-game viewmode.
// - +right and +forward to move character.
// - Special case freecam for cutscenes and canteen animations.
+// Steam proton launch command:
+// env DOTNET_ROOT="" WINEDLLOVERRIDES="msvcrt,dinput8=n,b" %command%
+
// Test cases:
// Offset Perspective:
// - For all cases roll should an extra consideration.
@@ -159,13 +164,14 @@ namespace MHWNewCamera private Patch noopCharacterFade;
private bool doubleShadowRes = false;
+ private bool largerShadowRange = false;
private Patch shadowRes1;
+ private Patch shadowRes1_1;
private Patch shadowRes1_2;
private Patch shadowRes1_3;
private Patch shadowRes2;
private Patch shadowRes3;
private Patch shadowRes4;
- private Patch shadowRes4_2;
private bool softerShadows = false;
private bool slightlySofterShadows = false;
private Patch higherMinThreshold;
@@ -174,29 +180,27 @@ namespace MHWNewCamera private void doubleShadowResEnable()
{
shadowRes1.Enable();
+ shadowRes1_1.Enable();
shadowRes1_2.Enable();
shadowRes1_3.Enable();
shadowRes2.Enable();
shadowRes3.Enable();
- shadowRes4.Enable();
- shadowRes4_2.Enable();
}
private void doubleShadowResDisable()
{
shadowRes1.Disable();
+ shadowRes1_1.Disable();
shadowRes1_2.Disable();
shadowRes1_3.Disable();
shadowRes2.Disable();
shadowRes3.Disable();
- shadowRes4.Disable();
- shadowRes4_2.Disable();
}
- private float unknownLod1 = 0.0f;
- private float unknownLod2 = 0.0f;
- private float foliageLodFactor = 1.565f;
- private float terrainLodFactor = 64.0f;
+ private float unknownLod1 = 1.0f;
+ private float unknownLod2 = 1.0f;
+ private float foliageLodFactor = 1.0f;
+ private float terrainLodFactor = 1.0f;
private bool largerFoliageSwayRange = false;
private Patch addressHigherValueForFoliageSway;
@@ -317,9 +321,8 @@ namespace MHWNewCamera fadeObjects = preset.FadeObjects;
}
- disableCharacterFade = config.DisableCharacterFade;
-
doubleShadowRes = config.DoubleShadowResolution;
+ largerShadowRange = config.LargerShadowRange;
slightlySofterShadows = config.SlightlySofterShadows;
if (slightlySofterShadows && config.SofterShadows)
{
@@ -401,8 +404,10 @@ 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);
#endif
shadowRes1 = new Patch(addr + 0x8, [0xCC, 0xF3, 0xAC, 0x02]);
+ 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
@@ -435,15 +440,17 @@ namespace MHWNewCamera Trace.Assert(addr == 0x142288B00);
#endif
shadowRes4 = new Patch(addr + 0x29, [
- 0xB8, 0x00, 0x16, 0x00, 0x00, 0xEB, 0x21, // "Primary shadow range". The game only ever addresses this case.
+ 0xB8, 0x00, 0x16, 0x00, 0x00, 0xEB, 0x21 // "Primary shadow range". This value is used for Low, Medium and High in-game.
]);
- // Multiply even on "High" because it's now 2.0 not 1.0.
- shadowRes4_2 = new Patch(addr + 0x5E, [0x90, 0x90]);
if (doubleShadowRes && !disableMod)
{
doubleShadowResEnable();
}
+ if (largerShadowRange && !disableMod)
+ {
+ shadowRes4.Enable();
+ }
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"));
#if ADDR_ASSERTS
@@ -523,7 +530,11 @@ namespace MHWNewCamera public void OnLoad()
{
Config config = ConfigManager.GetConfig<Config>(this);
- if (config.HigherLods)
+ unknownLod1 = config.LodFactor1;
+ unknownLod2 = config.LodFactor2;
+ foliageLodFactor = config.FoliageLodFactor;
+ terrainLodFactor = config.TerrainLodFactor;
+ if (config.ApplyLodFactors)
{
setLodFactors(true);
}
@@ -542,6 +553,25 @@ namespace MHWNewCamera MemoryUtil.WriteBytes(vp.Instance + 0x21, fadeOut ? [0x1] : [0x0]);
}
+ private void setCharacterFade(bool fadeOut)
+ {
+ if (fadeOut && disableCharacterFade)
+ {
+ noopCharacterFade.Disable();
+ disableCharacterFade = false;
+ }
+ else if (!fadeOut && !disableCharacterFade)
+ {
+ noopCharacterFade.Enable();
+ disableCharacterFade = true;
+ }
+ }
+
+ private bool areLodFactorsDefault()
+ {
+ return unknownLod1 == 1.0f && unknownLod2 == 1.0f && foliageLodFactor == 1.0f && terrainLodFactor == 1.0f;
+ }
+
private bool areLodFactorsSet()
{
nint baseAddr = MemoryUtil.Read<nint>(0x1451C4368);
@@ -571,6 +601,31 @@ namespace MHWNewCamera }
}
+ private void checkPlayerChange()
+ {
+ Player? player = Player.MainPlayer;
+ if (player != lastPlayer)
+ {
+ pCamera = null;
+ pCameraViewportIndex = -1;
+ lastPlayer = player;
+ }
+ }
+
+ public void OnUpdate(float deltaTime)
+ {
+ if (disableMod) return;
+
+#if HOOK_ORDER_ASSERTS
+ Trace.Assert(hookOrder == 0 || hookOrder == 3);
+ hookOrder = 0;
+ frameTick++;
+#endif
+
+ // Consider that pCamera could become an invalid pointer.
+ checkPlayerChange();
+ }
+
private static Quaternion getForward(Vector3 pos, Vector3 target)
{
return new Quaternion(target.X - pos.X, target.Y - pos.Y, target.Z - pos.Z, 0.0f);
@@ -618,7 +673,7 @@ namespace MHWNewCamera camera.Position = pos;
if (debugButton && cameraFov != DEFAULT_FOV)
{
- camera.FieldOfView = (float)((cameraFov * previousFov) / DEFAULT_FOV);
+ camera.FieldOfView = (float)Math.Clamp((cameraFov * previousFov) / DEFAULT_FOV, 1.0, 179.0);
}
}
@@ -657,6 +712,7 @@ namespace MHWNewCamera {
setFadeObjects(pCameraViewportIndex, fadeObjects);
}
+ setCharacterFade(fadeObjects);
swapMinimapFollowsCamera.Disable();
}
@@ -725,11 +781,11 @@ namespace MHWNewCamera }
if (buttonWasDown(Button.Left))
{
- cameraRoll -= buttonOffset;
+ cameraRoll -= buttonOffset / 2.0;
}
if (buttonWasDown(Button.Right))
{
- cameraRoll += buttonOffset;
+ cameraRoll += buttonOffset / 2.0;
}
}
@@ -806,17 +862,6 @@ namespace MHWNewCamera camera.FieldOfView = (float)cameraFov;
}
- private void checkPlayerChange()
- {
- Player? player = Player.MainPlayer;
- if (player != lastPlayer)
- {
- pCamera = null;
- pCameraViewportIndex = -1;
- lastPlayer = player;
- }
- }
-
private int getVisibleCamera()
{
for (int i = 0; i < 8; i++)
@@ -991,7 +1036,7 @@ namespace MHWNewCamera pCamera!.Position.Y += cameraYOffset;
if (cameraFov != DEFAULT_FOV)
{
- pCamera!.FieldOfView = (float)((cameraFov * previousFov) / DEFAULT_FOV);
+ pCamera!.FieldOfView = (float)Math.Clamp((cameraFov * previousFov) / DEFAULT_FOV, 1.0, 179.0);
}
}
@@ -1028,6 +1073,7 @@ namespace MHWNewCamera // we don't enable freecam until after applying a offset on this update.
cameraFov = vCamera.FieldOfView;
setFadeObjects(vCameraViewportIndex, false);
+ setCharacterFade(false);
swapMinimapFollowsCamera.Enable();
}
}
@@ -1193,14 +1239,23 @@ namespace MHWNewCamera PadChg = MemoryUtil.Read<uint>(controllerAddr() + 0x1A8);
readInputsPostHook = true;
}
- PadDown &= ~((uint)Button.Up | (uint)Button.Down | (uint)Button.Left | (uint)Button.Right);
- PadDown &= ~((uint)Button.Cross | (uint)Button.Circle | (uint)Button.Square | (uint)Button.Triangle);
+ uint FaceButtonMask = (uint)Button.Cross | (uint)Button.Circle | (uint)Button.Square | (uint)Button.Triangle;
+ uint DPadMask = (uint)Button.Up | (uint)Button.Down | (uint)Button.Left | (uint)Button.Right;
+ if (enableCombo && freeCameraCombo != null)
+ {
+ uint b1 = (uint)freeCameraCombo[0];
+ uint b2 = (uint)freeCameraCombo[1];
+ FaceButtonMask &= ~(b1 | b2);
+ DPadMask &= ~(b1 | b2);
+ }
+ PadDown &= ~DPadMask;
+ PadDown &= ~FaceButtonMask;
//PadDown &= ~((uint)Button.R1 | (uint)Button.L1);
- PadTrg &= ~((uint)Button.Up | (uint)Button.Down | (uint)Button.Left | (uint)Button.Right);
- PadTrg &= ~((uint)Button.Cross | (uint)Button.Circle | (uint)Button.Square | (uint)Button.Triangle);
+ PadTrg &= ~DPadMask;
+ PadTrg &= ~FaceButtonMask;
//PadTrg &= ~((uint)Button.R1 | (uint)Button.L1);
- PadChg &= ~((uint)Button.Up | (uint)Button.Down | (uint)Button.Left | (uint)Button.Right);
- PadChg &= ~((uint)Button.Cross | (uint)Button.Circle | (uint)Button.Square | (uint)Button.Triangle);
+ PadChg &= ~DPadMask;
+ PadChg &= ~FaceButtonMask;
//PadChg &= ~((uint)Button.R1 | (uint)Button.L1);
MemoryUtil.WriteBytes(controllerAddr() + 0x198, BitConverter.GetBytes(PadDown));
MemoryUtil.WriteBytes(controllerAddr() + 0x1A0, BitConverter.GetBytes(PadTrg));
@@ -1273,6 +1328,7 @@ namespace MHWNewCamera {
vp.Camera.Move = true;
}
+ setFadeObjects(i, true);
}
Player? player = Player.MainPlayer;
if (player != null)
@@ -1280,8 +1336,7 @@ namespace MHWNewCamera player.Rotation.X = 0.0f;
player.Rotation.Z = 0.0f;
}
- bool higherLodsEnabled = areLodFactorsSet();
- if (higherLodsEnabled)
+ if (areLodFactorsSet() && !areLodFactorsDefault())
{
setLodFactors(false);
}
@@ -1289,6 +1344,10 @@ namespace MHWNewCamera {
doubleShadowResDisable();
}
+ if (largerShadowRange)
+ {
+ shadowRes4.Disable();
+ }
if (slightlySofterShadows)
{
slightlyHigherMinThreshold.Disable();
@@ -1301,10 +1360,14 @@ namespace MHWNewCamera {
addressHigherValueForFoliageSway.Disable();
}
+ if (disableCharacterFade)
+ {
+ noopCharacterFade.Disable();
+ }
}
else
{
- if (config.HigherLods)
+ if (config.ApplyLodFactors && !areLodFactorsDefault())
{
setLodFactors(true);
}
@@ -1312,6 +1375,10 @@ namespace MHWNewCamera {
doubleShadowResEnable();
}
+ if (largerShadowRange)
+ {
+ shadowRes4.Enable();
+ }
if (slightlySofterShadows)
{
slightlyHigherMinThreshold.Enable();
@@ -1324,6 +1391,14 @@ namespace MHWNewCamera {
addressHigherValueForFoliageSway.Enable();
}
+ if (pCamera != null)
+ {
+ setFadeObjects(pCameraViewportIndex, fadeObjects);
+ }
+ if (disableCharacterFade)
+ {
+ noopCharacterFade.Enable();
+ }
}
config.DisableMod = disableMod;
@@ -1379,10 +1454,11 @@ namespace MHWNewCamera {
setFadeObjects(pCameraViewportIndex, fadeObjects);
}
+ setCharacterFade(fadeObjects);
}
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Credit to Otis_Inf.");
+ ImGui.Text("Applies to Objects, Characters and Palicos. Credit to Otis_Inf for Objects.");
ImGui.EndTooltip();
}
if (ImGui.Button("Default"))
@@ -1403,6 +1479,7 @@ namespace MHWNewCamera {
setFadeObjects(pCameraViewportIndex, fadeObjects);
}
+ setCharacterFade(fadeObjects);
config.Selected = "";
ConfigManager.SaveConfig<Config>(this);
}
@@ -1461,6 +1538,7 @@ namespace MHWNewCamera {
setFadeObjects(pCameraViewportIndex, fadeObjects);
}
+ setCharacterFade(fadeObjects);
}
if (isSelected) ImGui.SetItemDefaultFocus();
}
@@ -1653,37 +1731,66 @@ namespace MHWNewCamera ImGui.EndTooltip();
}
+ if (pCamera != null)
+ {
+ ImGui.Separator();
+ ImGui.Text($"Player Camera: {pCamera.Instance:x}");
+ ImGui.Text($"Applying Offset: {applyPerspective}");
+ ImGui.Text($"previousCameraAnimState: {previousCameraAnimState}");
+ }
+
+ ImGui.Separator();
+
ImGui.InputFloat("Unknown LOD Factor 1", ref unknownLod1);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Default: 1.0.");
+ ImGui.Text("Default: 1.0, Best Quality: 0.0.");
ImGui.EndTooltip();
}
ImGui.InputFloat("Unknown LOD Factor 2", ref unknownLod2);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Seems to control whether some objects are still drawn when very far from the camera.\nDefault: 1.0.");
+ 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.EndTooltip();
}
ImGui.InputFloat("Foliage LOD Factor", ref foliageLodFactor);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("This can sometimes look a bit off when set high.\nDefault: 1.0.");
+ ImGui.Text("This can sometimes look a bit off when set >1.0.\nDefault: 1.0, Best Quality: 64.0.");
ImGui.EndTooltip();
}
ImGui.InputFloat("Terrain/Object LOD Factor", ref terrainLodFactor);
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("Default: 1.0.");
+ ImGui.Text("Default: 1.0, Best Quality: 64.0.");
ImGui.EndTooltip();
}
- bool higherLodsEnabled = areLodFactorsSet();
- if (ImGui.Checkbox("Higher LODs", ref higherLodsEnabled))
+ bool lodsSet = areLodFactorsSet();
+ bool disableLodButton = lodsSet && areLodFactorsDefault();
+ if (disableLodButton)
{
- setLodFactors(higherLodsEnabled);
- config.HigherLods = higherLodsEnabled;
+ ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
+ ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f);
+ lodsSet = false;
+ }
+ if (ImGui.Checkbox("Apply LOD Factors", ref lodsSet))
+ {
+ setLodFactors(lodsSet);
+ config.ApplyLodFactors = lodsSet && !areLodFactorsDefault();
+ if (lodsSet)
+ {
+ config.LodFactor1 = unknownLod1;
+ config.LodFactor2 = unknownLod2;
+ config.FoliageLodFactor = foliageLodFactor;
+ config.TerrainLodFactor = terrainLodFactor;
+ }
ConfigManager.SaveConfig<Config>(this);
}
+ if (disableLodButton)
+ {
+ ImGui.PopItemFlag();
+ ImGui.PopStyleVar();
+ }
if (ImGui.BeginItemTooltip())
{
ImGui.Text("Credit to Otis_Inf.");
@@ -1709,6 +1816,25 @@ namespace MHWNewCamera ImGui.EndTooltip();
}
+ if (ImGui.Checkbox("Larger Shadow Range (Requires Reload)", ref largerShadowRange))
+ {
+ if (largerShadowRange)
+ {
+ shadowRes4.Enable();
+ }
+ else
+ {
+ shadowRes4.Disable();
+ }
+ 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 lower resolution range.");
+ ImGui.EndTooltip();
+ }
+
if (softerShadows)
{
ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true);
@@ -1758,7 +1884,7 @@ namespace MHWNewCamera }
if (ImGui.BeginItemTooltip())
{
- ImGui.Text("When 2x shadow resolution is enabled, this matches the original in-game \"High\" setting.");
+ ImGui.Text("When 2x shadow resolution is enabled and \"Shadow Quality\" is set to \"High\", this matches the original \"High\" setting.");
ImGui.EndTooltip();
}
@@ -1776,193 +1902,6 @@ namespace MHWNewCamera ConfigManager.SaveConfig<Config>(this);
}
- ImGui.PushID("Camera");
- if (pCamera != null)
- {
- ImGui.Text($"Player Camera: {pCamera.Instance:x}");
- ImGui.Text($"Applying Offset: {applyPerspective}");
- ImGui.Text($"previousCameraAnimState: {previousCameraAnimState}");
- }
-
- ImGui.Separator();
-
- ImGui.Text("Camera/Viewport:");
- 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")})"))
- {
- 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;
- }
- }
- }
- ImGui.PopID();
- }
- ImGui.PopID();
-
ImGui.Separator();
if (ImGui.Checkbox("Disable Character/Palico Fade", ref disableCharacterFade))
@@ -1975,15 +1914,14 @@ namespace MHWNewCamera {
noopCharacterFade.Disable();
}
- config.DisableCharacterFade = disableCharacterFade;
- ConfigManager.SaveConfig<Config>(this);
}
+ ImGui.Separator();
+
ImGui.PushID("Player");
Player? player = Player.MainPlayer;
- if (player != null)
+ if (ImGui.CollapsingHeader("Player") && player != null)
{
- ImGui.Separator();
ImGui.Text("Player:");
ImGui.Text($"Pointer: {player.Instance:x}");
ImGui.DragFloat3("Position", ref player.Position, 0.5f);
@@ -2192,6 +2130,186 @@ namespace MHWNewCamera ImGui.Separator();
+ ImGui.PushID("Camera");
+ ImGui.Text("Camera/Viewport:");
+ 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")})"))
+ {
+ 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;
+ }
+ }
+ }
+ ImGui.PopID();
+ }
+ ImGui.PopID();
+
+ ImGui.Separator();
+
ImGui.PushID("Pad");
ImGui.Text("Pad:");
ImGui.Text($"Pointer: {controllerAddr():x}");
@@ -2215,19 +2333,5 @@ namespace MHWNewCamera }
ImGui.PopID();
}
-
- public void OnUpdate(float deltaTime)
- {
- if (disableMod) return;
-
-#if HOOK_ORDER_ASSERTS
- Trace.Assert(hookOrder == 0 || hookOrder == 3);
- hookOrder = 0;
- frameTick++;
-#endif
-
- // Consider that pCamera could become an invalid pointer.
- checkPlayerChange();
- }
}
}
|