Skip to content

Commit 456e01d

Browse files
committed
Release 1.0 work (mostly ready)
Changelog: * Reworked 3rd person camera algorithm (completely rewritten) * 3rd person camera rotation doesn't get affected by suspension bounciness * Look around/aim/shoot has been reimplemented and now supports gamepad as well as keyboard * Progressive deadzone implemented when looking with gamepad, for better aim precision * Look left/right quickly by pressing hotkeys (configurable via ini file) * Support to look left/right/back from steering wheel! Requires an AppVeyor build of Manual Transmission Mod by @ikt (link below): https://ci.appveyor.com/project/E66666666/gtavmanualtransmission/build/artifacts * Other minor fixes and improvements Release soon
1 parent a3de220 commit 456e01d

File tree

4 files changed

+61
-20
lines changed

4 files changed

+61
-20
lines changed

CustomCameraVPlus.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ lookRightAngle = 80.0
1313

1414
[general]
1515

16-
# Support Look left/right/behind from Manual Transmission mod by ikt (Requires latest AppVeyor build of Manual Transmission Mod)
16+
# Support Look left/right/behind from Manual Transmission mod by ikt (Requires latest AppVeyor build of Manual Transmission Mod)
1717
#
18-
# https://ci.appveyor.com/project/E66666666/gtavmanualtransmission/build/artifacts
18+
# https://ci.appveyor.com/project/E66666666/gtavmanualtransmission/build/artifacts
1919
#
2020
# Set to 1 to enable, 0 to disable
2121
GetInputFromGearsAsi = 1

Install.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Usage:
1313
* Enter on any vehicle (except boat, helis and planes) and custom camera will be automatically enabled
1414
* Look around, aim and shoot just like with the built-in camera.
1515
* Switch between 3rd and 1st person view by pressing V (or other key mapped to switch views)
16+
* Look left by pressing B, look right by pressing N
1617
* Look behind by pressing C (or other key mapped to look behind)
1718
* Toggle mod enabled by pressing 1.
1819
* Reload ini settings by pressing F10.
20+
21+
* Lots of settings are configurable (check CustomCameraVPlus.ini)

changelog.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
1.0:
3+
4+
* Reworked 3rd person camera algorithm (completely rewritten)
5+
* 3rd person camera rotation doesn't get affected by suspension bounciness
6+
* Look around/aim/shoot has been reimplemented and now supports gamepad as well as keyboard
7+
* Progressive deadzone implemented when looking with gamepad, for better aim precision
8+
* Look left/right quickly by pressing hotkeys (configurable via ini file)
9+
* Support to look left/right/back from steering wheel!
10+
Requires an AppVeyor build of Manual Transmission Mod by @ikt (link below):
11+
https://ci.appveyor.com/project/E66666666/gtavmanualtransmission/build/artifacts
12+
13+
* Other minor fixes and improvements

script.cpp

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ Vector3f cachedSurfaceNormal;
9191
Vector3f smoothSurfaceNormal;
9292

9393
Vector3f smoothVelocity = Vector3f();
94+
Vector3f ultraSmoothVelocity = Vector3f();
9495
Quaternionf velocityQuat3P = Quaternionf();
9596
Quaternionf smoothQuat3P = Quaternionf();
96-
Quaternionf ultraSmoothQuat3P = Quaternionf();
97+
Quaternionf ultraSmoothVelocity3P = Quaternionf();
9798
Vector3f smoothRotSeat = Vector3f();
9899
Quaternionf smoothQuatSeat = Quaternionf();
99100
float smoothIsInAir = 0.f;
@@ -554,6 +555,9 @@ void showText(float x, float y, float scale, const char* text, int font, const C
554555
UI::END_TEXT_COMMAND_DISPLAY_TEXT(x, y);
555556
}
556557

558+
void showText(int index, const char* text) {
559+
showText(0.1f, 0.03f * (float)index, 0.3f, text, 0, solidWhite, true);
560+
}
557561

558562
Vector3f getDimensions(Hash modelHash) {
559563
Vector3 min;
@@ -941,6 +945,7 @@ void updateVehicleVars()
941945
vehForwardVector = toV3f(ENTITY::GET_ENTITY_FORWARD_VECTOR(veh));
942946
vehSpeed = ENTITY::GET_ENTITY_SPEED(veh);
943947
smoothVelocity = lerp(smoothVelocity, vehSpeed > 2.f ? vehVelocity : vehForwardVector, 10.f * getDeltaTime());
948+
ultraSmoothVelocity = lerp(ultraSmoothVelocity, vehSpeed > 2.f ? vehVelocity : vehForwardVector, 3.f * getDeltaTime());
944949

945950
if ((ENTITY::IS_ENTITY_IN_AIR(veh) || (ENTITY::GET_ENTITY_UPRIGHT_VALUE(veh) < 0.6f)) && smoothIsInAir < 0.001f)
946951
{
@@ -1471,6 +1476,13 @@ bool LastInputMethodWasMouseAndKeyboard()
14711476
return CONTROLS::_IS_INPUT_DISABLED(2);
14721477
}
14731478

1479+
Vector3f V3Reflect(Vector3f vector, Vector3f normal)
1480+
{
1481+
float dot = vector.dot(normal);
1482+
Vector3f temp = normal * dot * 2.f;
1483+
return vector - temp;
1484+
}
1485+
14741486
void updateCam3pNfsAlgorithm()
14751487
{
14761488
Vector3f extraCamHeight = up * (0.14f + extraAngleCamHeight);
@@ -1481,16 +1493,23 @@ void updateCam3pNfsAlgorithm()
14811493

14821494
Quaternionf vehQuat = getEntityQuaternion(veh);
14831495
smoothQuat3P = slerp(smoothQuat3P, vehQuat, 3.f * getDeltaTime());
1496+
14841497
velocityQuat3P = lookRotation(smoothVelocity);
1498+
ultraSmoothVelocity3P = lookRotation(ultraSmoothVelocity);
14851499

14861500
//float vehPitch = QuatToEuler(velocityQuat3P).x();
14871501

1488-
if (/*isBike && */ vehSpeed > 1.f)
1502+
float forwardness = vehForwardVector.dot(vehVelocity);
1503+
1504+
if (/*isBike && */forwardness >= 0.f && vehSpeed > 1.f)
14891505
{
1490-
Quaternionf quatVel = velocityQuat3P;
1506+
Vector3f VquatVel = QuatToEuler(ultraSmoothVelocity3P);
1507+
Vector3f sm3p;
14911508

1492-
Vector3f VquatVel = QuatToEuler(velocityQuat3P);
1493-
Vector3f sm3p = QuatToEuler(smoothQuat3P);
1509+
//if (forwardness >= 0.f)
1510+
sm3p = QuatToEuler(smoothQuat3P);
1511+
//else
1512+
// sm3p = QuatToEuler(inverseSmoothQuat3P);
14941513

14951514
VquatVel[2] = sm3p[2];
14961515

@@ -1578,10 +1597,23 @@ void updateCam3pNfsAlgorithm()
15781597
float mx = (CONTROLS::GET_CONTROL_NORMAL(2, eControl::ControlLookLeftRight)) * -5.f;
15791598
float my = (CONTROLS::GET_CONTROL_NORMAL(2, eControl::ControlLookUpDown)) * (LastInputMethodWasMouseAndKeyboard ? -5.f : 5.f);
15801599

1581-
if (!LastInputMethodWasMouseAndKeyboard())
1600+
if (!LastInputMethodWasMouseAndKeyboard()) // if gamepad
15821601
{
1583-
mx *= 0.6f;
1584-
my *= 0.6f;
1602+
mx *= 0.2f;
1603+
my *= 0.2f;
1604+
1605+
//showText(1, std::to_string(mx).c_str());
1606+
//showText(2, std::to_string(my).c_str());
1607+
1608+
float deadzone = 0.275f;
1609+
Vector2f stickInput = Vector2f(mx, my);
1610+
if (stickInput.norm() < deadzone)
1611+
stickInput = Vector2f(0.f, 0.f);
1612+
else
1613+
stickInput = stickInput.normalized() * ((stickInput.norm() - deadzone) / (1.f - deadzone));
1614+
1615+
mx = stickInput.x() * 2.f;
1616+
my = stickInput.y() * 2.f;
15851617
}
15861618

15871619
Vector3f vecLook = Vector3f(my, 0.f, mx);
@@ -1610,7 +1642,7 @@ void updateCam3pNfsAlgorithm()
16101642

16111643
float aimHeightIncrement = lerp(0.f, 0.22f, smoothIsAiming);
16121644

1613-
Vector3f camPosSmooth = posCenter + extraCamHeight + V3CurrentTowHeightIncrement + (finalQuat3P * back * ((longitudeOffset3P) + 0.15f + airDistance)) + (up * aimHeightIncrement);
1645+
Vector3f camPosSmooth = posCenter + extraCamHeight + V3CurrentTowHeightIncrement + (finalQuat3P * back * ((longitudeOffset3P) + 0.185f + airDistance)) + (up * aimHeightIncrement);
16141646
camPosSmooth += slerp(smoothQuat3P, velocityQuat3P, smoothIsInAir) * back * distIncFinal;
16151647

16161648
Vector3f camPosFinal = camPosSmooth;
@@ -1658,7 +1690,7 @@ void DisableCustomCamera()
16581690
CAM::RENDER_SCRIPT_CAMS(false, false, 3000, true, false);
16591691
camInitialized = false;
16601692
isInVehicle = false;
1661-
veh = NULL;
1693+
//veh = NULL;
16621694

16631695
haltCurrentCamera();
16641696
}
@@ -1969,17 +2001,10 @@ void update()
19692001
}
19702002

19712003
if (IsKeyJustUp(str2key(reloadKey))) {
1972-
1973-
haltCurrentCamera();
1974-
2004+
ReadSettings(true);
19752005
updateVehicleVars();
19762006
updateVehicleProperties();
1977-
19782007
setupCustomCamera();
1979-
1980-
ReadSettings(true);
1981-
1982-
setupCurrentCamera();
19832008
}
19842009

19852010
updateTimers();

0 commit comments

Comments
 (0)