Skip to content

Commit 11f81ac

Browse files
committed
Release 1.4.1
Added height offset configurable setting (3rd person cam)
1 parent edf23e7 commit 11f81ac

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

CustomCameraVPlus.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
[3rdPersonView]
22
fov = 77.5
3+
4+
# Determines the distance of the thrid person camera
5+
# Higher values increase the distance, lower decrease it. Can be positive or negative number
36
distanceOffset = 0.0
47

8+
# Determines the height of the thrid person camera
9+
# Higher values increase the height, lower decrease it. Can be positive or negative number
10+
heightOffset = 0.0
11+
512
# Determines the angle between the car and the camera, in deggress (this value can be increased if you want to see 'more road')
613
# Higher values will place the camera higher and looking down (to the vehicle)
714
#

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.4.1
2+
3+
* Added an option to set the height of the third person camera. (Configurable in settings)
4+
15
1.4
26

37
* Added an option to set the angle of the thrid person camera! (Configurable in settings)

script.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ float fov3P = 77.5f;
6060
float fov1P = 75.F;
6161
float fov1PAiming = 60.f;
6262
float fov3PAiming = 60.f;
63-
float distanceOffset = 0.f;
63+
float distanceOffset3p = 0.f;
64+
float heightOffset3p = 0.f;
6465
float cameraAngle3p = 3.5f;
6566
const float PI = 3.1415926535897932f;
6667
int lastVehHash = -1;
6768
bool isBike = false;
6869

6970
bool isInVehicle = false;
7071

71-
float longitudeOffset3P = 0.f;
72-
float heightOffset3P = 0.f;
72+
float calcLongitudeOffset3P = 0.f;
73+
float calcHeightOffset3P = 0.f;
7374

7475
float heightIcrementCalc = 0.f;
7576

@@ -588,7 +589,8 @@ void ReadSettings(bool notify)
588589
lookLeftKey = strdup(ini.GetValue("keyMappings", "lookLeftKey", "B"));
589590
lookRightKey = strdup(ini.GetValue("keyMappings", "lookRightKey", "N"));
590591

591-
distanceOffset = (float) ini.GetDoubleValue("3rdPersonView", "distanceOffset", 0.0);
592+
distanceOffset3p = (float)ini.GetDoubleValue("3rdPersonView", "distanceOffset", 0.0);
593+
heightOffset3p = (float) ini.GetDoubleValue("3rdPersonView", "heightOffset", 0.0);
592594
cameraAngle3p = clamp((float)ini.GetDoubleValue("3rdPersonView", "cameraAngle", 3.5), 0.f, 20.f);
593595

594596
fov3P = (float) ini.GetDoubleValue("3rdPersonView", "fov", 77.5);
@@ -996,30 +998,30 @@ void updateVehicleProperties()
996998
isBike = vehClass == eVehicleClass::VehicleClassCycles || vehClass == eVehicleClass::VehicleClassMotorcycles;
997999
isSuitableForCam = vehClass != eVehicleClass::VehicleClassTrains && vehClass != eVehicleClass::VehicleClassPlanes && vehClass != eVehicleClass::VehicleClassHelicopters && vehClass != eVehicleClass::VehicleClassBoats;
9981000

999-
longitudeOffset3P = getVehicleLongitudeFromCenterBack(veh) + 0.7f;
1001+
calcLongitudeOffset3P = getVehicleLongitudeFromCenterBack(veh) + 0.7f;
10001002

1001-
heightOffset3P = clamp(getVehicleHeightFromCenterUp(veh) + 0.5f, 0.f, 2.0f);
1003+
calcHeightOffset3P = clamp(getVehicleHeightFromCenterUp(veh) + 0.5f, 0.f, 2.0f);
10021004
//ShowNotification(std::to_string(heightOffset3P).c_str());
10031005

1004-
if (heightOffset3P > 1.75f)
1006+
if (calcHeightOffset3P > 1.75f)
10051007
{
1006-
extraAngleCamHeight = clamp(lerp(0.1f, 2.0f, unlerp(1.75f, 2.00f, heightOffset3P)), 0.f, 3.0f);
1007-
heightOffset3P += (extraAngleCamHeight * 0.5f);
1008-
longitudeOffset3P += extraAngleCamHeight;
1008+
extraAngleCamHeight = clamp(lerp(0.1f, 2.0f, unlerp(1.75f, 2.00f, calcHeightOffset3P)), 0.f, 3.0f);
1009+
calcHeightOffset3P += (extraAngleCamHeight * 0.5f);
1010+
calcLongitudeOffset3P += extraAngleCamHeight;
10091011

10101012
extraAngleCamHeight = clamp(extraAngleCamHeight, 0.f, 2.25f);
10111013
}
10121014
else
10131015
extraAngleCamHeight = 0.0f;
10141016

10151017
if (isBike) {
1016-
longitudeOffset3P += 1.f;
1017-
heightOffset3P = 1.38f;
1018+
calcLongitudeOffset3P += 1.f;
1019+
calcHeightOffset3P = 1.38f;
10181020
}
10191021

1020-
longitudeOffset3P += 1.45f + distanceOffset;
1022+
calcLongitudeOffset3P += 1.45f + distanceOffset3p;
10211023

1022-
heightIcrementCalc = longitudeOffset3P * tan(cameraAngle3p * PI / 180.0);
1024+
heightIcrementCalc = calcLongitudeOffset3P * tan(cameraAngle3p * PI / 180.0);
10231025

10241026
vehHasTowBone = vehHasBone("tow_arm");
10251027
vehHasTrailerBone = vehHasBone("attach_female");
@@ -1072,7 +1074,7 @@ void setupCurrentCamera() {
10721074
dirQuat3P = lookQuat;
10731075
smoothQuat3P = lookQuat;
10741076

1075-
prevCamPos = (vehPos + (up * heightOffset3P)) + (up * (0.14f + extraAngleCamHeight)) + ((lookQuat) * back * (longitudeOffset3P + currentTowLongitudeIncrement));
1077+
prevCamPos = (vehPos + (up * calcHeightOffset3P)) + (up * (0.14f + extraAngleCamHeight)) + ((lookQuat) * back * (calcLongitudeOffset3P + currentTowLongitudeIncrement));
10761078
}
10771079

10781080
CAM::SET_FOLLOW_VEHICLE_CAM_VIEW_MODE(1);
@@ -1406,7 +1408,7 @@ Vector3f V3Reflect(Vector3f vector, Vector3f normal)
14061408

14071409
void updateCam3pNfsAlgorithm()
14081410
{
1409-
float heigthOffset = 0.15f + heightIcrementCalc;
1411+
float calcHeigthOffset = heightOffset3p + 0.15f + heightIcrementCalc;
14101412

14111413
currentTowHeightIncrement = lerp(currentTowHeightIncrement, towHeightIncrement, 1.45f * getDeltaTime());
14121414
currentTowLongitudeIncrement = lerp(currentTowLongitudeIncrement, towLongitudeIncrement, 1.75f * getDeltaTime());
@@ -1444,7 +1446,7 @@ void updateCam3pNfsAlgorithm()
14441446

14451447
float airDistance = lerp(0.f, 2.5f, smoothIsInAirNfs * (lerp(0.6f, 1.2f, smoothIsInAirNfs)));
14461448

1447-
Vector3f posCenter = vehPos + (up * heightOffset3P) + (vehForwardVector * finalPivotFrontOffset);
1449+
Vector3f posCenter = vehPos + (up * calcHeightOffset3P) + (vehForwardVector * finalPivotFrontOffset);
14481450

14491451
semiDelayedVehSpeed = lerp(semiDelayedVehSpeed, vehSpeed, clamp01(max(2.5f, vehSpeed) * getDeltaTime()));
14501452
delayedVehSpeed = lerp(delayedVehSpeed, semiDelayedVehSpeed, clamp01(max(0.5f, semiDelayedVehSpeed * 0.75f) * getDeltaTime()));
@@ -1457,7 +1459,7 @@ void updateCam3pNfsAlgorithm()
14571459

14581460
float highSpeedFactor = unlerp(hightSpeedMin, highSpeedMax, clamp(vehSpeed, hightSpeedMin, highSpeedMax)) * 0.020f;
14591461

1460-
Vector3f targetPos = vehPos + (up * heightOffset3P) + ((currentTowHeightIncrement + heigthOffset) * up) + (vehForwardVector * finalPivotFrontOffset);
1462+
Vector3f targetPos = vehPos + (up * calcHeightOffset3P) + ((currentTowHeightIncrement + calcHeigthOffset) * up) + (vehForwardVector * finalPivotFrontOffset);
14611463
targetPos += /*smoothQuat3P*/ dirQuat3P * back * distIncFinal /* * (0.5f * (clamp01(vehSpeed * 0.7f)))*/;
14621464

14631465
targetPos += smoothVelocity * highSpeedFactor * (1.f - smoothIsInAir) * max(((vehAcceleration * VEHICLE::GET_VEHICLE_ACCELERATION(veh)) * 250.f), 0.f) * 0.45f;
@@ -1543,7 +1545,7 @@ void updateCam3pNfsAlgorithm()
15431545

15441546
float pivotInfluenceLook = lerp(finalPivotFrontOffset, -0.2f, clamp01(abs(lookHorizontalAngle * 0.00277f))) * 1.f - smoothIsInAir;
15451547

1546-
Vector3f camPosSmooth = posCenter + V3CurrentTowHeightIncrement + ((finalQuat3P) * back * (longitudeOffset3P + currentTowLongitudeIncrement + pivotInfluenceLook + (airDistance - finalPivotFrontOffset) + distIncFinal )) + (up * (aimHeightIncrement + heigthOffset/* + heightInc */));
1548+
Vector3f camPosSmooth = posCenter + V3CurrentTowHeightIncrement + ((finalQuat3P) * back * (calcLongitudeOffset3P + currentTowLongitudeIncrement + pivotInfluenceLook + (airDistance - finalPivotFrontOffset) + distIncFinal )) + (up * (aimHeightIncrement + calcHeigthOffset/* + heightInc */));
15471549

15481550
//camPosSmooth += /*smoothQuat3P*/ dirQuat3P * back * distIncFinal /* * (0.25f * clamp01(vehSpeed * 0.7f)) */;
15491551

0 commit comments

Comments
 (0)