Permalink
Browse files

Added automatic camera rotation.

If the directory bounds becomes portrait the view will rotate
clockwise until it returns to a rectangular orientation.
  • Loading branch information...
1 parent 43108db commit ca5806cc7967ffc866f20625588b82ca9323a834 @acaudwell committed Apr 22, 2010
Showing with 55 additions and 14 deletions.
  1. +3 −0 README
  2. +3 −0 data/gource.1
  3. +31 −5 src/gource.cpp
  4. +15 −6 src/gource_settings.cpp
  5. +3 −3 src/gource_settings.h
View
3 README
@@ -173,6 +173,9 @@ options:
--camera-mode MODE
Camera mode (overview,track).
+ --disable-auto-rotate
+ Disable automatic camera rotation.
+
--hide DISPLAY_ELEMENT
Hide display element (bloom,date,dirnames,files,filenames,mouse,progress,tree,
users,usernames).
View
@@ -145,6 +145,9 @@ Change scale of users.
\fB\-\-camera\-mode MODE\fR
Camera mode (overview,track).
.TP
+\fB\-\-disable\-auto\-rotate\fR
+Disable automatic camera rotation.
+.TP
\fB\-\-hide DISPLAY_ELEMENT\fR
Hide display element (bloom,date,dirnames,files,filenames,mouse,progress,tree,users,usernames).
View
@@ -105,7 +105,7 @@ Gource::Gource(FrameExporter* exporter) {
if(exporter!=0) setFrameExporter(exporter, gGourceSettings.output_framerate);
//if recording a video or in demo mode, the slider is initially hidden
- if(exporter==0 && !gGourceSettings.demo) slider.show();
+ if(exporter==0) slider.show();
}
RCommitLog* Gource::determineFormat(std::string logfile) {
@@ -1182,12 +1182,17 @@ void Gource::updateTime() {
void Gource::updateCamera(float dt) {
//camera tracking
+ Bounds2D cambounds;
+
+ bool auto_rotate = !gGourceSettings.disable_auto_rotate;
if(backgroundSelected) {
Bounds2D mousebounds;
mousebounds.update(backgroundPos);
- camera.adjust(mousebounds);
+ cambounds = mousebounds;
+
+ auto_rotate = false;
} else if(track_users && (selectedFile !=0 || selectedUser !=0)) {
Bounds2D focusbounds;
@@ -1197,13 +1202,34 @@ void Gource::updateCamera(float dt) {
if(selectedUser !=0) focusbounds.update(selectedUser->getPos());
if(selectedFile !=0) focusbounds.update(selectedFile->getAbsolutePos());
- camera.adjust(focusbounds);
+ cambounds = focusbounds;
} else {
- if(track_users && idle_time==0) camera.adjust(user_bounds);
- else camera.adjust(dir_bounds);
+ if(track_users && idle_time==0) cambounds = user_bounds;
+ else cambounds = dir_bounds;
}
+ camera.adjust(cambounds);
+
camera.logic(dt);
+
+ //automatically rotate camera
+ if(auto_rotate) {
+
+ float dratio = 0.95f;
+
+ Uint8 ms = SDL_GetMouseState(0,0);
+ bool rightmouse = ms & SDL_BUTTON(SDL_BUTTON_RIGHT);
+
+ if(!rightmouse && dir_bounds.area() > 10000.0f) {
+
+ float ratio = dir_bounds.width() / dir_bounds.height();
+
+ if(ratio<dratio) {
+ //rotate up to 90 degrees a second
+ rotate_angle = 90.0f * (dratio-ratio) * dt * DEGREES_TO_RADIANS;
+ }
+ }
+ }
}
void Gource::logic(float t, float dt) {
View
@@ -26,7 +26,7 @@ void GourceSettings::help(bool extended_help) {
SDLAppCreateWindowsConsole();
//resize window to fit help message
- SDLAppResizeWindowsConsole(970);
+ SDLAppResizeWindowsConsole(750);
#endif
printf("Gource v%s\n", GOURCE_VERSION);
@@ -80,22 +80,24 @@ void GourceSettings::help(bool extended_help) {
if(extended_help) {
printf("Extended Options:\n\n");
- printf(" -b, --background-colour FFFFFF Background colour in hex\n");
- printf(" --background-image IMAGE Set a background image\n\n");
+ printf(" -b, --background-colour FFFFFF Background colour in hex\n");
+ printf(" --background-image IMAGE Set a background image\n\n");
printf(" --bloom-multiplier Adjust the amount of bloom (default: 1.0)\n");
printf(" --bloom-intensity Adjust the intensity of the bloom (default: 0.75)\n\n");
printf(" --crop AXIS Crop view on an axis (vertical,horizontal)\n");
printf(" --camera-mode MODE Camera mode (overview,track)\n\n");
+ printf(" --disable-auto-rotate Disable automatic camera rotation\n\n");
+
printf(" --date-format FORMAT Specify display date string (strftime format)\n\n");
printf(" --font-size SIZE Font size\n");
printf(" --font-colour FFFFFF Font colour in hex\n\n");
- printf(" --hide DISPLAY_ELEMENT bloom,date,dirnames,files,filenames,mouse,progress,tree,\n");
- printf(" users,usernames\n\n");
+ printf(" --hide DISPLAY_ELEMENT bloom,date,dirnames,files,filenames,mouse,progress,\n");
+ printf(" tree,users,usernames\n\n");
printf(" --logo IMAGE Logo to display in the foreground\n");
printf(" --logo-offset XxY Offset position of the logo\n\n");
@@ -180,7 +182,8 @@ GourceSettings::GourceSettings() {
arg_types["hide-bloom"] = "bool";
arg_types["hide-mouse"] = "bool";
- arg_types["disable-auto-skip"] = "bool";
+ arg_types["disable-auto-rotate"] = "bool";
+ arg_types["disable-auto-skip"] = "bool";
arg_types["git-log-command"]= "bool";
arg_types["cvs-exp-command"]= "bool";
@@ -251,6 +254,8 @@ void GourceSettings::setGourceDefaults() {
stop_at_end = false;
dont_stop = false;
+ disable_auto_rotate = false;
+
auto_skip_seconds = 3.0f;
days_per_second = 0.1f; // TODO: check this is right
file_idle_time = 60.0f;
@@ -457,6 +462,10 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
date_format = entry->getString();
}
+ if(gource_settings->getBool("disable-auto-rotate")) {
+ disable_auto_rotate=true;
+ }
+
if(gource_settings->getBool("disable-auto-skip")) {
auto_skip_seconds = -1.0;
}
View
@@ -34,8 +34,6 @@ class GourceSettings : public SDLAppSettings {
protected:
void commandLineOption(const std::string& name, const std::string& value);
public:
- bool demo;
-
bool hide_date;
bool hide_users;
bool hide_tree;
@@ -47,6 +45,8 @@ class GourceSettings : public SDLAppSettings {
bool hide_bloom;
bool hide_mouse;
+ bool disable_auto_rotate;
+
std::string load_config;
std::string save_config;
std::string path;
@@ -85,7 +85,7 @@ class GourceSettings : public SDLAppSettings {
std::string background_image;
std::string title;
-
+
int font_size;
vec3f font_colour;

0 comments on commit ca5806c

Please sign in to comment.