Skip to content

Commit

Permalink
Fix camera speedup and update associated files to reflect a new version
Browse files Browse the repository at this point in the history
  • Loading branch information
WAUthethird committed Dec 12, 2024
1 parent 523dbdd commit c7aaaa2
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 52 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
project(MarbleMarcher VERSION "1.4.5")
cmake_minimum_required(VERSION 3.10)
project(MarbleMarcher VERSION "1.4.6")
set(CMAKE_CXX_STANDARD 17)

configure_file(src/config.h.in config.h)
Expand Down Expand Up @@ -143,7 +143,7 @@ elseif(UNIX)
set(CPACK_PACKAGE_VERSION "${MM_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "4")
set(CPACK_PACKAGE_VERSION_PATCH "7")
set(CPACK_PACKAGE_VERSION_PATCH "6")

SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "KK") #required
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Marble Marcher: Community Edition

### Version 1.4.5
### Version 1.4.6

![Logo](https://github.com/WAUthethird/Marble-Marcher-Community-Edition/blob/master/doc/LOGO.PNG)

Expand Down
4 changes: 2 additions & 2 deletions build_on_windows.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
This is a short and easy tutorial for building Marble Marcher: Community Edition on Windows. This tutorial (the command line parts) can be followed with Git Bash, though you'll need a developer CMD in administrator mode for at least one process.

1. Make sure you have [CMake x64](https://cmake.org/download/), [OpenAL](https://www.openal.org/), and [Visual Studio 2019](https://visualstudio.microsoft.com/vs/) (in addition to the 2015 and/or 2017 VS build tools, if one does not work, try installing the other) installed.
1. Make sure you have [CMake x64](https://cmake.org/download/), [OpenAL](https://www.openal.org/), and [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) installed.

2. Download the CE edition to a folder of your choice and unzip it: [https://github.com/WAUthethird/Marble-Marcher-Community-Edition](https://github.com/WAUthethird/Marble-Marcher-Community-Edition) or `git clone https://github.com/WAUthethird/Marble-Marcher-Community-Edition.git`.

Expand All @@ -15,7 +15,7 @@ This is a short and easy tutorial for building Marble Marcher: Community Edition
6. Download and unzip AntTweakBar to the `Libraries` folder: [http://anttweakbar.sourceforge.net](http://anttweakbar.sourceforge.net)
* Inside the resulting unzipped folder should be just a folder called `AntTweakBar`. Move this folder outside its parent folder, into `Libraries`. Delete the now empty parent folder.

7. Download and unzip GLM to the `Libraries` folder: [https://github.com/g-truc/glm/releases/latest](https://github.com/g-truc/glm/releases/latest)
7. Download and unzip GLM to the `Libraries` folder. I used the .zip version of the 0.9.9.8 release: [https://github.com/g-truc/glm/releases/tag/0.9.9.8](https://github.com/g-truc/glm/releases/tag/0.9.9.8)
* Inside the resulting unzipped folder should be just a folder called `glm`. Move this folder outside its parent folder, into `Libraries`. Delete the now empty parent folder.

8. Download and unzip GLEW to the `Libraries` folder. I used the 2.1.0 Windows binaries: [http://glew.sourceforge.net/](http://glew.sourceforge.net/)
Expand Down
100 changes: 56 additions & 44 deletions src/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,8 @@ void Scene::UpdateCamera(float dx, float dy, float dz, bool speedup) {
}
}
} else if (cam_mode == DEORBIT) {
for (int i = 0; i < iters; i++) {
UpdateDeOrbit(dx, dy, dz);
if (cam_mode != DEORBIT) {
break;
}
}
//For deorbit, speedup is handled by the function called, not by calling the function multiple times
UpdateDeOrbit(dx, dy, dz, iters);
} else if (cam_mode == MARBLE) {
UpdateNormal(dx, dy, dz);
} else if (cam_mode == GOAL || cam_mode == FINAL || cam_mode == MIDPOINT) {
Expand Down Expand Up @@ -715,48 +711,64 @@ void Scene::UpdateOrbit() {
}
}

void Scene::UpdateDeOrbit(float dx, float dy, float dz) {
//Update the timer
const float t = timer * orbit_speed;
float b = std::min(float(std::max(timer - frame_orbit, 0)) / float(frame_deorbit - frame_orbit), 1.0f);
b *= b/(2*b*(b - 1) + 1);
timer += 1;
sum_time += 1;

void Scene::UpdateDeOrbit(float dx, float dy, float dz, int iters) {
if (timer > frame_deorbit + 1) {
for (int i = 0; i < iters; i++) {
//Update the timer
timer += 1;
sum_time += 1;

if (cam_mode != DEORBIT) {
break;
}
}
//Camera during countdown is not sped up
UpdateCameraOnly(dx, dy, dz);
} else {
//Get marble location and rotational parameters
const float orbit_dist = level_copy.orbit_dist;
const Eigen::Vector3f orbit_pt(0.0f, orbit_dist, 0.0f);
const Eigen::Vector3f perp_vec(std::sin(t), 0.0f, std::cos(t));
const Eigen::Vector3f orbit_cam_pos = orbit_pt + perp_vec * (orbit_dist * 2.5f);
cam_pos = cam_pos*orbit_smooth + orbit_cam_pos*(1 - orbit_smooth);

//Solve for the look direction
const float start_look_x = level_copy.start_look_x;
cam_look_x = std::atan2(cam_pos.x(), cam_pos.z());
ModPi(cam_look_x, start_look_x);

//Solve for the look direction
cam_look_x_smooth = cam_look_x*(1 - b) + start_look_x*b;

//Update look smoothing
cam_look_y = -0.3f;
cam_look_y_smooth = cam_look_y_smooth*orbit_smooth + cam_look_y*(1 - orbit_smooth);

//Update the camera rotation matrix
MakeCameraRotation();

//Update the camera position
Eigen::Vector3f marble_cam_pos = marble_pos + cam_mat.block<3, 3>(0, 0) * Eigen::Vector3f(0.0f, 0.0f, marble_rad * cam_dist_smooth);
marble_cam_pos += Eigen::Vector3f(0.0f, marble_rad * cam_dist_smooth * 0.1f, 0.0f);
cam_pos_smooth = cam_pos*(1 - b) + marble_cam_pos*b;
cam_mat.block<3, 1>(0, 3) = cam_pos_smooth;
for (int i = 0; i < iters; i++) {
//Update the timer
const float t = timer * orbit_speed;
float b = std::min(float(std::max(timer - frame_orbit, 0)) / float(frame_deorbit - frame_orbit), 1.0f);
b *= b/(2*b*(b - 1) + 1);
timer += 1;
sum_time += 1;

//Get marble location and rotational parameters
const float orbit_dist = level_copy.orbit_dist;
const Eigen::Vector3f orbit_pt(0.0f, orbit_dist, 0.0f);
const Eigen::Vector3f perp_vec(std::sin(t), 0.0f, std::cos(t));
const Eigen::Vector3f orbit_cam_pos = orbit_pt + perp_vec * (orbit_dist * 2.5f);
cam_pos = cam_pos*orbit_smooth + orbit_cam_pos*(1 - orbit_smooth);

//Solve for the look direction
const float start_look_x = level_copy.start_look_x;
cam_look_x = std::atan2(cam_pos.x(), cam_pos.z());
ModPi(cam_look_x, start_look_x);

//Solve for the look direction
cam_look_x_smooth = cam_look_x*(1 - b) + start_look_x*b;

//Update look smoothing
cam_look_y = -0.3f;
cam_look_y_smooth = cam_look_y_smooth*orbit_smooth + cam_look_y*(1 - orbit_smooth);

//Update the camera rotation matrix
MakeCameraRotation();

//Update the camera position
Eigen::Vector3f marble_cam_pos = marble_pos + cam_mat.block<3, 3>(0, 0) * Eigen::Vector3f(0.0f, 0.0f, marble_rad * cam_dist_smooth);
marble_cam_pos += Eigen::Vector3f(0.0f, marble_rad * cam_dist_smooth * 0.1f, 0.0f);
cam_pos_smooth = cam_pos*(1 - b) + marble_cam_pos*b;
cam_mat.block<3, 1>(0, 3) = cam_pos_smooth;

//Required for a smooth transition later on
cam_look_x = cam_look_x_smooth;
cam_look_y = cam_look_y_smooth;

//Required for a smooth transition later on
cam_look_x = cam_look_x_smooth;
cam_look_y = cam_look_y_smooth;
if (cam_mode != DEORBIT) {
break;
}
}
}

//When done deorbiting, transition to play
Expand Down
2 changes: 1 addition & 1 deletion src/Scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Scene {

void UpdateIntro(bool ssaver);
void UpdateOrbit();
void UpdateDeOrbit(float dx, float dy, float dz);
void UpdateDeOrbit(float dx, float dy, float dz, int iters);
void UpdateNormal(float dx, float dy, float dz);
void UpdateCameraOnly(float dx, float dy, float dz);
void UpdateGoal();
Expand Down
2 changes: 1 addition & 1 deletion src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
#define PROJECT_VER_MAJOR "@PROJECT_VERSION_MAJOR@"
#define PROJECT_VER_MINOR "@PROJECT_VERSION_MINOR@"
#define PROJECT_VER_PATCH "@PROJECT_VERSION_PATCH@"
#define YEAR "©2021"
#define YEAR "©2024"

#endif // INCLUDE_GUARD

0 comments on commit c7aaaa2

Please sign in to comment.