Skip to content

Commit

Permalink
Merge pull request #145 from chinosk6/main
Browse files Browse the repository at this point in the history
Add Live Camera Info
  • Loading branch information
chinosk6 authored Jul 10, 2023
2 parents 6941e66 + ba8bd4e commit bfbf61c
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 116 deletions.
69 changes: 37 additions & 32 deletions src/camera/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ namespace UmaCamera {
unsigned long sleepTime = 0;
Vector3_t cameraPos{ 0.093706, 0.467159, 9.588791 };
Vector3_t homeCameraPos{ 0.0, 1.047159, -4.811181 };
Vector3_t cameraLookAt{ cameraPos.x, cameraPos.y, cameraPos.z - look_radius };

bool orig_lookat_target = g_race_freecam_lookat_umamusume;
float orig_g_race_freecam_follow_umamusume_distance = g_race_freecam_follow_umamusume_distance;
Vector3_t orig_g_race_freecam_follow_umamusume_offset{
Expand Down Expand Up @@ -399,6 +399,11 @@ namespace UmaCamera {
);

}
Vector3_t cameraLookAt{ cameraPos.x, cameraPos.y, cameraPos.z - look_radius };

void setliveCameraType(int type) {
liveCameraType = type;
}

void loadGlobalData() {
orig_g_race_freecam_follow_umamusume_distance = g_race_freecam_follow_umamusume_distance;
Expand Down Expand Up @@ -643,7 +648,7 @@ namespace UmaCamera {
}

Quaternion_t updateLookatByRotation(Quaternion_t rot) {
if (g_race_freecam_follow_umamusume && raceFollowUmaFirstPersion) {
if (g_race_freecam_follow_umamusume && raceFollowUmaFirstPerson) {
auto newRot = CameraCalc::RotateQuaternion(rot, raceFirstPersonLookAtOffset.y, CameraCalc::Vector3(1, 0, 0));
rot = CameraCalc::RotateQuaternion(newRot, raceFirstPersonLookAtOffset.x, CameraCalc::Vector3(0, 1, 0));
}
Expand All @@ -656,7 +661,7 @@ namespace UmaCamera {
}

Quaternion_t updatePosAndLookatByRotation(Vector3_t pos, Quaternion_t rot) {
if ((liveCameraType == LiveCamera_FIRST_PERSION) || raceFollowUmaFirstPersion) {
if ((liveCameraType == LiveCamera_FIRST_PERSON) || raceFollowUmaFirstPerson) {
pos = CameraCalc::GetFrontPos(pos, rot, liveFirstPersonOffset.z);
pos.y += liveFirstPersonOffset.y;
}
Expand Down Expand Up @@ -759,34 +764,34 @@ namespace UmaCamera {
switch (raceFollowStat) {
case 0: {
lookAtUmaReverse = !lookAtUmaReverse;
raceFollowUmaFirstPersion = false;
raceFollowUmaFirstPersionEnableRoll = false;
raceFollowUmaFirstPerson = false;
raceFollowUmaFirstPersonEnableRoll = false;
printf(lookAtUmaReverse ? "Race camera ahead.\n" : "Race camera behind.\n");
raceFollowStat++;
}; break;
case 1: {
lookAtUmaReverse = !lookAtUmaReverse;
raceFollowUmaFirstPersion = false;
raceFollowUmaFirstPersionEnableRoll = false;
raceFollowUmaFirstPerson = false;
raceFollowUmaFirstPersonEnableRoll = false;
printf(lookAtUmaReverse ? "Race camera ahead.\n" : "Race camera behind.\n");
raceFollowStat++;
}; break;
case 2: {
raceFollowUmaFirstPersion = true;
raceFollowUmaFirstPersionEnableRoll = true;
printf("Race first persion. Enable roll.\n");
raceFollowUmaFirstPerson = true;
raceFollowUmaFirstPersonEnableRoll = true;
printf("Race first person. Enable roll.\n");
raceFollowStat++;
}; break;

case 3: {
raceFollowUmaFirstPersion = true;
raceFollowUmaFirstPersionEnableRoll = false;
printf("Race first persion. Disable roll.\n");
raceFollowUmaFirstPerson = true;
raceFollowUmaFirstPersonEnableRoll = false;
printf("Race first person. Disable roll.\n");
raceFollowStat = 0;
}; break;

default: {
raceFollowUmaFirstPersion = false;
raceFollowUmaFirstPerson = false;
raceFollowStat = 0;
}; break;
}
Expand All @@ -797,7 +802,7 @@ namespace UmaCamera {

void camera_forward() { // 向前
if ((cameraType == CAMERA_RACE) && g_race_freecam_follow_umamusume){
if (raceFollowUmaFirstPersion) {
if (raceFollowUmaFirstPerson) {
liveFirstPersonOffset.z += 0.005;
}
else {
Expand All @@ -811,7 +816,7 @@ namespace UmaCamera {
return;
}

if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSION) {
if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSON) {
liveFirstPersonOffset.z += 0.005;
return;
}
Expand All @@ -822,7 +827,7 @@ namespace UmaCamera {

void camera_back() { // 后退
if ((cameraType == CAMERA_RACE) && g_race_freecam_follow_umamusume) {
if (raceFollowUmaFirstPersion) {
if (raceFollowUmaFirstPerson) {
liveFirstPersonOffset.z -= 0.005;
}
else {
Expand All @@ -835,7 +840,7 @@ namespace UmaCamera {
liveFollowCameraOffset.z += moveStep / 2;
return;
}
if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSION) {
if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSON) {
liveFirstPersonOffset.z -= 0.005;
return;
}
Expand Down Expand Up @@ -880,7 +885,7 @@ namespace UmaCamera {

void camera_down() { // 向下
if ((cameraType == CAMERA_RACE) && g_race_freecam_follow_umamusume) {
if (raceFollowUmaFirstPersion) {
if (raceFollowUmaFirstPerson) {
liveFirstPersonOffset.y -= 0.005;
}
else {
Expand All @@ -893,7 +898,7 @@ namespace UmaCamera {
// liveFollowCameraOffset.y -= moveStep / 2;
return;
}
if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSION) {
if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSON) {
liveFirstPersonOffset.y -= 0.005;
return;
}
Expand All @@ -916,7 +921,7 @@ namespace UmaCamera {

void camera_up() { // 向上
if ((cameraType == CAMERA_RACE) && g_race_freecam_follow_umamusume) {
if (raceFollowUmaFirstPersion) {
if (raceFollowUmaFirstPerson) {
liveFirstPersonOffset.y += 0.005;
}
else {
Expand All @@ -929,7 +934,7 @@ namespace UmaCamera {
// liveFollowCameraOffset.y += moveStep / 2;
return;
}
if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSION) {
if ((cameraType == CAMERA_LIVE) && liveCameraType == LiveCamera_FIRST_PERSON) {
liveFirstPersonOffset.y += 0.005;
return;
}
Expand Down Expand Up @@ -1110,18 +1115,18 @@ namespace UmaCamera {
printf("LIVE Follow Umamusume\n");
}
else if (liveCameraType == LiveCamera_FOLLOW_UMA) {
liveCameraType = LiveCamera_FIRST_PERSION;
printf("LIVE First Persion\n");
liveCameraType = LiveCamera_FIRST_PERSON;
printf("LIVE First Person\n");
}
else {
liveCameraType = LiveCamera_FREE;
printf("LIVE Free Camera\n");
}
}
else if (cameraType == CAMERA_CUTIN) {
if (g_enable_cutin_first_persion) {
g_cutin_first_persion = !g_cutin_first_persion;
printf("CutIn camera first person %s.\n", g_cutin_first_persion ? "enabled" : "disabled");
if (g_enable_cutin_first_person) {
g_cutin_first_person = !g_cutin_first_person;
printf("CutIn camera first person %s.\n", g_cutin_first_person ? "enabled" : "disabled");
}
}

Expand All @@ -1141,7 +1146,7 @@ namespace UmaCamera {

void changeLiveCameraLockChara(int changeIndex) {
if (cameraType != CAMERA_LIVE) return;
if ((liveCameraType != LiveCamera_FOLLOW_UMA) && (liveCameraType != LiveCamera_FIRST_PERSION)) return;
if ((liveCameraType != LiveCamera_FOLLOW_UMA) && (liveCameraType != LiveCamera_FIRST_PERSON)) return;

const auto changedData = changeIndex > 0 ? liveCharaPositionFlag.Next() : liveCharaPositionFlag.Last();
printf("Live look position flag: %s (0x%x)\n", changedData.first.c_str(), changedData.second);
Expand All @@ -1161,7 +1166,7 @@ namespace UmaCamera {
}
if (cameraType == CAMERA_RACE) {
if (g_race_freecam_follow_umamusume) {
if (raceFollowUmaFirstPersion) {
if (raceFollowUmaFirstPerson) {
if (mouse)
raceFirstPersonLookAtOffset.x -= value;
else
Expand All @@ -1180,7 +1185,7 @@ namespace UmaCamera {
}
if (cameraType == CAMERA_RACE) {
if (g_race_freecam_follow_umamusume) {
if (raceFollowUmaFirstPersion) {
if (raceFollowUmaFirstPerson) {
if (mouse)
raceFirstPersonLookAtOffset.y -= value * 16;
else
Expand All @@ -1197,7 +1202,7 @@ namespace UmaCamera {
void onMouseScroll(LONG value) {
if (value > 0) { // up
if ((cameraType == CAMERA_RACE) && g_race_freecam_follow_umamusume) {
if (!raceFollowUmaFirstPersionEnableRoll && raceFollowUmaFirstPersion) {
if (!raceFollowUmaFirstPersonEnableRoll && raceFollowUmaFirstPerson) {
if (raceFirstShakeStrength >= 1.0f) return;
raceFirstShakeStrength += 0.05;
printf("raceFirstShakeStrength: %.2f\n", raceFirstShakeStrength);
Expand All @@ -1206,7 +1211,7 @@ namespace UmaCamera {
}
else { // down
if ((cameraType == CAMERA_RACE) && g_race_freecam_follow_umamusume) {
if (!raceFollowUmaFirstPersionEnableRoll && raceFollowUmaFirstPersion) {
if (!raceFollowUmaFirstPersonEnableRoll && raceFollowUmaFirstPerson) {
if (raceFirstShakeStrength <= -1.0f) return;
raceFirstShakeStrength -= 0.05;
printf("raceFirstShakeStrength: %.2f\n", raceFirstShakeStrength);
Expand Down
3 changes: 3 additions & 0 deletions src/camera/camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#include "stdinclude.hpp"

namespace UmaCamera {
extern Vector3_t cameraLookAt;

Vector3_t getCameraPos();
Vector3_t getHomeCameraPos();
Vector3_t getCameraLookat();
Expand All @@ -19,6 +21,7 @@ namespace UmaCamera {
Quaternion_t updatePosAndLookatByRotation(Vector3_t pos, Quaternion_t rot);
Quaternion_t updatePosAndLookatByRotationStable(Vector3_t pos, Quaternion_t rot, Quaternion_t nowRot);

void setliveCameraType(int type);
int GetLiveCharaPositionFlag();
int GetLiveCameraCharaParts();
int GetLiveCharaPositionIndex();
Expand Down
Loading

0 comments on commit bfbf61c

Please sign in to comment.