You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: Yoda-JM <yo...@us...> - 2009-11-10 12:58:22
|
Module: performous
Branch: master
Commit: f17251a3feae7bc5244608ce7f1f526aa30a5040
Author: Vincent Le Ligeour <yo...@us...>
Date: Tue Nov 10 13:58:03 2009 +0100
Fixed some more pathes search
---
data/schema.xml | 23 +++++++----------------
game/configuration.cc | 3 +--
game/fs.cc | 29 ++++++-----------------------
3 files changed, 14 insertions(+), 41 deletions(-)
diff --git a/data/schema.xml b/data/schema.xml
index 9313de9..c1f6160 100644
--- a/data/schema.xml
+++ b/data/schema.xml
@@ -216,16 +216,6 @@ to save the current settings to XML.
</entry>
<!-- System preferences -->
- <entry name="system/path_data" type="string_list">
- <stringvalue>/usr/local/share/games/performous/</stringvalue>
- <stringvalue>/usr/share/games/performous/</stringvalue>
- <stringvalue>../</stringvalue><!-- For Windows where the program is started in bin/ -->
- <stringvalue>~/.performous/</stringvalue>
- <locale name="C">
- <short>Data folders</short>
- <long>Where Performous data are stored.</long>
- </locale>
- </entry>
<entry name="system/path_songs" type="string_list">
<stringvalue>/usr/local/share/games/ultrastar/songs/</stringvalue>
<stringvalue>/usr/share/games/ultrastar/songs/</stringvalue>
@@ -236,13 +226,14 @@ to save the current settings to XML.
<long>Where to recursively look for songs.</long>
</locale>
</entry>
- <entry name="system/path_share" type="string_list">
- <stringvalue>~/.local/share/performous</stringvalue>
- <stringvalue>../share</stringvalue><!-- For Windows where the program is started in bin/ -->
- <stringvalue>~/.performous/share</stringvalue>
+ <entry name="system/path_themes" type="string_list">
+ <stringvalue>/usr/local/share/games/performous/themes</stringvalue>
+ <stringvalue>/usr/share/games/performous/themes</stringvalue>
+ <stringvalue>../themes/</stringvalue><!-- For Windows where the program is started in bin/ -->
+ <stringvalue>~/.performous/themes/</stringvalue>
<locale name="C">
- <short>Data folders</short>
- <long>Where Performous data are stored.</long>
+ <short>Theme folders</short>
+ <long>Where to look for themes.</long>
</locale>
</entry>
<entry name="system/path_pictures" type="string_list">
diff --git a/game/configuration.cc b/game/configuration.cc
index b144c2b..522393d 100644
--- a/game/configuration.cc
+++ b/game/configuration.cc
@@ -337,8 +337,7 @@ void readConfig() {
// Adding some default pathes
char const* env_data_dir = getenv("PERFORMOUS_DATA_DIR");
if (env_data_dir) {
- config["system/path_data"].sl().push_back(std::string(env_data_dir));
- config["system/path_share"].sl().push_back(std::string(env_data_dir));
+ config["system/path_themes"].sl().push_back(std::string(env_data_dir) + "/themes/");
config["system/path_songs"].sl().push_back(std::string(env_data_dir) + "/songs/");
config["system/path_pictures"].sl().push_back(std::string(env_data_dir) + "/pictures/");
config["system/path_backgrounds"].sl().push_back(std::string(env_data_dir) + "/backgrounds/");
diff --git a/game/fs.cc b/game/fs.cc
index 82a5f93..c9a3039 100644
--- a/game/fs.cc
+++ b/game/fs.cc
@@ -31,10 +31,9 @@ std::string getThemePath(std::string const& filename) {
if (theme.empty()) throw std::runtime_error("Configuration value game/theme is empty");
// Figure out theme folder (if theme name rather than path was given)
if (theme.find('/') == std::string::npos) {
- ConfigItem::StringList sd = config["system/path_data"].sl();
+ ConfigItem::StringList sd = config["system/path_themes"].sl();
for (std::vector<std::string>::const_iterator it = sd.begin(); it != sd.end(); ++it) {
fs::path p = *it;
- p /= "themes/";
p /= theme;
if (fs::is_directory(p)) { theme = p.string(); break; }
}
@@ -44,26 +43,10 @@ std::string getThemePath(std::string const& filename) {
}
std::string getDataPath(std::string const& filename) {
- // Figure out theme folder (if theme name rather than path was given)
- std::string data_dir;
- ConfigItem::StringList sd = config["system/path_data"].sl();
- for (std::vector<std::string>::const_iterator it = sd.begin(); it != sd.end(); ++it) {
- fs::path p = *it;
- p = pathMangle(p);
- if (fs::is_directory(p)) { data_dir = p.string(); break; }
- }
- return data_dir + "/" + filename;
-}
-
-std::string getSharePath(std::string const& filename) {
- // Figure out theme folder (if theme name rather than path was given)
- std::string data_dir;
- ConfigItem::StringList sd = config["system/path_share"].sl();
- for (std::vector<std::string>::const_iterator it = sd.begin(); it != sd.end(); ++it) {
- fs::path p = *it;
- p = pathMangle(p);
- if (fs::is_directory(p)) { data_dir = p.string(); break; }
+ char const* env_data_dir = getenv("PERFORMOUS_DATA_DIR");
+ if (env_data_dir) {
+ return std::string(env_data_dir)+filename;
+ } else {
+ return std::string(filename);
}
- return data_dir + "/" + filename;
}
-
|
|
From: Yoda-JM <yo...@us...> - 2009-11-10 12:44:05
|
Module: performous
Branch: master
Commit: 6854f19c8b9ba586b319773fbb0d187b8838cfa9
Author: Vincent Le Ligeour <yo...@us...>
Date: Tue Nov 10 13:42:35 2009 +0100
Fixed performous pathes not using PERFORMOUS_DATA_DIR env
---
game/backgrounds.cc | 6 ------
game/configuration.cc | 10 ++++++++++
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/game/backgrounds.cc b/game/backgrounds.cc
index 8450234..22a3e99 100644
--- a/game/backgrounds.cc
+++ b/game/backgrounds.cc
@@ -17,12 +17,6 @@ void Backgrounds::reload() {
if (m_loading) return;
// Copy backgrounddirs from config into m_bgdirs
ConfigItem::StringList sd = config["system/path_backgrounds"].sl();
- char const* env_data_dir = getenv("PERFORMOUS_DATA_DIR");
- if (env_data_dir) {
- std::string background_dir(env_data_dir);
- background_dir.append("/backgrounds/");
- sd.push_back(background_dir);
- }
m_bgs.clear();
std::transform(sd.begin(), sd.end(), std::inserter(m_bgdirs, m_bgdirs.end()), pathMangle);
// Run loading thread
diff --git a/game/configuration.cc b/game/configuration.cc
index 6c0d6be..b144c2b 100644
--- a/game/configuration.cc
+++ b/game/configuration.cc
@@ -333,5 +333,15 @@ void readConfig() {
readConfigXML(schemafile, 0); // Read schema and defaults
readConfigXML(systemConfFile, 1); // Update defaults with system config
readConfigXML(userConfFile, 2); // Read user settings
+
+ // Adding some default pathes
+ char const* env_data_dir = getenv("PERFORMOUS_DATA_DIR");
+ if (env_data_dir) {
+ config["system/path_data"].sl().push_back(std::string(env_data_dir));
+ config["system/path_share"].sl().push_back(std::string(env_data_dir));
+ config["system/path_songs"].sl().push_back(std::string(env_data_dir) + "/songs/");
+ config["system/path_pictures"].sl().push_back(std::string(env_data_dir) + "/pictures/");
+ config["system/path_backgrounds"].sl().push_back(std::string(env_data_dir) + "/backgrounds/");
+ }
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-10 11:40:23
|
Module: web Branch: master Commit: 04d90a556ed32d149545ab0a0c09a97f4987e074 Author: Lasse Karkkainen <tro...@tr...> Date: Tue Nov 10 13:40:31 2009 +0200 Various updates --- htdocs-source/AWC-cfg.txt | 3 +-- htdocs-source/develop.txt | 2 +- htdocs-source/install.txt | 4 +++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs-source/AWC-cfg.txt b/htdocs-source/AWC-cfg.txt index c8c8907..a365c06 100644 --- a/htdocs-source/AWC-cfg.txt +++ b/htdocs-source/AWC-cfg.txt @@ -16,10 +16,9 @@ .http://cia.vc/stats/project/performous CIA.vc .http://www.facebook.com/performous Facebook .awstats/awstats.pl Site stats -% Competing projects: +% Similar projects: .http://sourceforge.net/projects/ultrastardx/ UltraStar Deluxe .http://singthegame.com/ SingSong -.http://sinatra.nu/ Sinatra .http://www.canta-game.org/ Canta .http://www.karaokeparty.com/ KaraokeParty diff --git a/htdocs-source/develop.txt b/htdocs-source/develop.txt index 714fea5..1d91ab8 100644 --- a/htdocs-source/develop.txt +++ b/htdocs-source/develop.txt @@ -27,7 +27,7 @@ Fedora: OS X: - <strong>sudo port install</strong> git cmake help2man libsdl cairo librsvg portaudio libxmlxx2 boost +complete imagemagick ffmpeg +avfilter libsamplerate + <strong>sudo port install</strong> git-core cmake help2man libsdl glew cairo librsvg portaudio libxmlxx2 boost +complete imagemagick ffmpeg +avfilter libsamplerate We try to keep these lists accurate and up-to-date with the development version. If you find that something is missing or that there are unnecessary package installs, please let us know. diff --git a/htdocs-source/install.txt b/htdocs-source/install.txt index 90d3374..d28f6ce 100644 --- a/htdocs-source/install.txt +++ b/htdocs-source/install.txt @@ -23,10 +23,12 @@ None yet, but it compiles on Microsoft Visual Studio and we'll probably get some No software bundle currently available, but we expect one of the Mac users to package one shortly. -:h2:Other systems +:h2:Other systems and development version Source code: <a href="http://sourceforge.net/projects/performous/files/performous/Performous-0.3.2-Source.tar.bz2">universal</a> + The very latest source code is available in our Git repository. See the <strong>hacking</strong> page for more information. + :h2:Troubleshooting If you have previously installed from source, be sure to erase any files left over from that or otherwise Performous may use wrong files. Clear the following files/folders: |
|
From: Tapio V. <aa...@us...> - 2009-11-10 09:06:22
|
Module: performous
Branch: master
Commit: 9295099d8c70d14a317652207a0a90eef8d0c0bf
Author: Tapio Vierros <tap...@gm...>
Date: Tue Nov 10 11:04:40 2009 +0200
Exception handling for loading 3d objects.
---
game/3dobject.cc | 1 +
game/3dobject.hh | 12 ++++++++----
game/guitargraph.cc | 10 ++++++++--
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/game/3dobject.cc b/game/3dobject.cc
index c17db3e..f4e5a2e 100644
--- a/game/3dobject.cc
+++ b/game/3dobject.cc
@@ -87,6 +87,7 @@ void Object3d::loadWavefrontObj(std::string filepath, float scale) {
void Object3d::generateDisplayList() {
+ if (m_displist != 0) glDeleteLists(m_displist, 1);
m_displist = glGenLists(1);
glutil::DisplayList displist(m_displist, GL_COMPILE);
//UseTexture tex(*m_texture);
diff --git a/game/3dobject.hh b/game/3dobject.hh
index d4dfce0..771f197 100644
--- a/game/3dobject.hh
+++ b/game/3dobject.hh
@@ -47,16 +47,20 @@ class Object3d: boost::noncopyable {
void generateDisplayList();
public:
/// constructors
- Object3d();
+ Object3d(): m_displist(0) {};
Object3d(std::string filepath, float scale = 1.0): m_displist(0) {
- //m_texture.reset(new Texture("button.svg"));
- loadWavefrontObj(filepath, scale);
- generateDisplayList();
+ load(filepath, scale);
}
/// destructor
~Object3d() {
if (m_displist != 0) glDeleteLists(m_displist, 1);
}
+ /// load a new object file
+ void load(std::string filepath, float scale = 1.0) {
+ //m_texture.reset(new Texture("button.svg"));
+ loadWavefrontObj(filepath, scale);
+ generateDisplayList();
+ }
/// draws the object
void draw(float x = 0, float y = 0, float z = 0) const {
glTranslatef(x, y, z);
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 1032250..7e2b00b 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -5,6 +5,7 @@
#include "3dobject.hh"
#include <cmath>
#include <cstdlib>
+#include <stdexcept>
#include <boost/lexical_cast.hpp>
@@ -51,8 +52,6 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
m_button("button.svg"),
m_button_l("button_l.svg"),
m_tap("tap.svg"),
- m_fretObj(getThemePath("fret.obj"), 1.0f),
- m_tappableObj(getThemePath("fret_tap.obj"), 1.0f),
m_drums(track=="drums"),
m_use3d(config["graphic/3d_notes"].b()),
m_cx(0.0, 0.2),
@@ -68,6 +67,13 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
m_streak(),
m_longestStreak()
{
+ try {
+ m_fretObj.load(getThemePath("fret.obj"));
+ m_tappableObj.load(getThemePath("fret_tap.obj"));
+ } catch (std::exception const& e) {
+ std::cout << e.what() << std::endl;
+ m_use3d = false;
+ }
unsigned int sr = m_audio.getSR();
if (g_samplesD.empty()) {
g_samplesD.push_back(Sample(getDataPath("sounds/drum_bass.ogg"), sr));
|
|
From: Tapio V. <aa...@us...> - 2009-11-10 09:06:20
|
Module: performous
Branch: master
Commit: 7b12d4d0934d84002736a2e7f10cc92d3e584def
Author: Tapio Vierros <tap...@gm...>
Date: Tue Nov 10 10:49:51 2009 +0200
Changed enable/disableLighting to UseLighting RAII wrapper.
---
game/glutil.hh | 25 +++++++++++++++++++++++++
game/guitargraph.cc | 25 +------------------------
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/game/glutil.hh b/game/glutil.hh
index a3c7cd1..94cc921 100644
--- a/game/glutil.hh
+++ b/game/glutil.hh
@@ -31,6 +31,31 @@ namespace glutil {
~DisplayList() { glEndList(); }
};
+ /// wrapper struct for RAII
+ struct UseLighting {
+ /// enable lighting and depth test for 3d objects
+ UseLighting(bool doit = true) {
+ if (doit) {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+
+ GLfloat light_position[] = { -50.0, 15.0, -5.0, 1.0 };
+ glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+ glEnable(GL_LIGHT0);
+ }
+ }
+ ~UseLighting() {
+ glDisable(GL_LIGHT0);
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_DEPTH_TEST);
+ }
+ };
+
/// struct to store color information
struct Color {
float r, ///< red component
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 663c13f..1032250 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -354,28 +354,6 @@ glutil::Color const& GuitarGraph::color(int fret) const {
return fretColors[fret];
}
-namespace {
- void enableLighting() {
- glClear(GL_DEPTH_BUFFER_BIT);
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
-
- GLfloat light_position[] = { -50.0, 15.0, -5.0, 1.0 };
- glLightfv(GL_LIGHT0, GL_POSITION, light_position);
-
- glEnable(GL_DEPTH_TEST);
- glEnable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
- glEnable(GL_LIGHT0);
- }
-
- void disableLighting() {
- glDisable(GL_LIGHT0);
- glDisable(GL_COLOR_MATERIAL);
- glDisable(GL_LIGHTING);
- glDisable(GL_DEPTH_TEST);
- }
-}
-
void GuitarGraph::draw(double time) {
Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
dimensions.screenBottom().middle(m_cx.get()).fixedWidth(m_width.get());
@@ -423,7 +401,7 @@ void GuitarGraph::draw(double time) {
}
}
// Draw the notes
- if (m_use3d) enableLighting();
+ glutil::UseLighting lighting(m_use3d);
for (Chords::const_iterator it = m_chords.begin(); it != m_chords.end(); ++it) {
float tBeg = it->begin - time;
float tEnd = it->end - time;
@@ -481,7 +459,6 @@ void GuitarGraph::draw(double time) {
m_tap.draw();
}
}
- if (m_use3d) disableLighting();
glColor3f(1.0f, 1.0f, 1.0f);
}
|
|
From: Tapio V. <aa...@us...> - 2009-11-10 09:06:19
|
Module: performous
Branch: master
Commit: 0ca83ba16a2c7cf8b61293244f6e2e33a14b4561
Author: Tapio Vierros <tap...@gm...>
Date: Tue Nov 10 10:37:41 2009 +0200
3d objects drawn with display lists.
---
game/3dobject.cc | 11 ++++++-----
game/3dobject.hh | 19 ++++++++++++++++---
game/glutil.hh | 7 +++++++
3 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/game/3dobject.cc b/game/3dobject.cc
index 1bac829..c17db3e 100644
--- a/game/3dobject.cc
+++ b/game/3dobject.cc
@@ -12,7 +12,6 @@
#include <cmath>
-// TODO: use display lists for drawing?
// TODO: test & fix faces that doesn't have texcoords in the file
// TODO: group handling for loader
@@ -87,7 +86,9 @@ void Object3d::loadWavefrontObj(std::string filepath, float scale) {
}
-void Object3d::draw(float x, float y, float z) const {
+void Object3d::generateDisplayList() {
+ m_displist = glGenLists(1);
+ glutil::DisplayList displist(m_displist, GL_COMPILE);
//UseTexture tex(*m_texture);
std::vector<Face>::const_iterator it;
// Iterate through faces
@@ -113,9 +114,9 @@ void Object3d::draw(float x, float y, float z) const {
m_normals[it->normals[i]].z);
// Vertices
glVertex3f(
- m_vertices[it->vertices[i]].x+x,
- m_vertices[it->vertices[i]].y+y,
- m_vertices[it->vertices[i]].z+z);
+ m_vertices[it->vertices[i]].x,
+ m_vertices[it->vertices[i]].y,
+ m_vertices[it->vertices[i]].z);
}
}
}
diff --git a/game/3dobject.hh b/game/3dobject.hh
index 9baef99..d4dfce0 100644
--- a/game/3dobject.hh
+++ b/game/3dobject.hh
@@ -6,6 +6,7 @@
#include <stdexcept>
#include <string>
+#include <boost/noncopyable.hpp>
#include "surface.hh"
#include "glutil.hh"
@@ -32,22 +33,34 @@ struct Face {
};
-class Object3d {
+class Object3d: boost::noncopyable {
private:
std::vector<Vertex> m_vertices;
std::vector<TexCoord> m_texcoords;
std::vector<Vertex> m_normals;
std::vector<Face> m_faces;
+ GLuint m_displist;
//boost::scoped_ptr<Texture> m_texture;
/// load a Wavefront .obj 3d object file
void loadWavefrontObj(std::string filepath, float scale = 1.0);
+ /// generates a display list for the object
+ void generateDisplayList();
public:
/// constructors
Object3d();
- Object3d(std::string filepath, float scale = 1.0) {
+ Object3d(std::string filepath, float scale = 1.0): m_displist(0) {
//m_texture.reset(new Texture("button.svg"));
loadWavefrontObj(filepath, scale);
+ generateDisplayList();
+ }
+ /// destructor
+ ~Object3d() {
+ if (m_displist != 0) glDeleteLists(m_displist, 1);
}
/// draws the object
- void draw(float x = 0, float y = 0, float z = 0) const;
+ void draw(float x = 0, float y = 0, float z = 0) const {
+ glTranslatef(x, y, z);
+ glCallList(m_displist);
+ glTranslatef(-x, -y, -z);
+ }
};
diff --git a/game/glutil.hh b/game/glutil.hh
index 3ce9949..a3c7cd1 100644
--- a/game/glutil.hh
+++ b/game/glutil.hh
@@ -24,6 +24,13 @@ namespace glutil {
~Begin() { glEnd(); }
};
+ /// wrapper struct for RAII
+ struct DisplayList {
+ /// call glNewList with given list id and mode
+ DisplayList(GLuint id, GLenum mode) { glNewList(id, mode); }
+ ~DisplayList() { glEndList(); }
+ };
+
/// struct to store color information
struct Color {
float r, ///< red component
|
|
From: Tapio V. <aa...@us...> - 2009-11-09 22:14:08
|
Module: performous
Branch: master
Commit: 53072bd173d5ea816fc1220c1cf723a0c2f30bcb
Author: Tapio Vierros <tap...@gm...>
Date: Tue Nov 10 00:10:25 2009 +0200
Smoother 3d note appearing.
---
game/guitargraph.cc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 7d94ff6..663c13f 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -512,7 +512,7 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
float y = yBeg + fretWid;
if (m_use3d) {
y -= fretWid;
- glColor4fv(c);
+ c.a = clamp(time2a(tBeg)*2.0f,0.0f,1.0f); glColor4fv(c);
obj->draw(x, y, 0.0f);
y -= fretWid;
} else {
@@ -542,7 +542,7 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
} else {
// Too short note: only render the ring
if (m_use3d) {
- glColor4fv(c);
+ c.a = clamp(time2a(tBeg)*2.0f,0.0f,1.0f); glColor4fv(c);
obj->draw(x, time2y(tBeg), 0.0f);
} else {
c.a = time2a(tBeg); glColor4fv(c);
|
|
From: Tapio V. <aa...@us...> - 2009-11-09 22:14:07
|
Module: performous
Branch: master
Commit: 0fdaaf4f7d7d0ad2536feec0dd05ddfbca7fffcb
Author: Tapio Vierros <tap...@gm...>
Date: Tue Nov 10 00:04:36 2009 +0200
Face normal for drawBar()
---
game/guitargraph.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 89219fb..7d94ff6 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -522,7 +522,6 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
vertexPair(x, y, c, 1.0f);
y -= 2 * fretWid;
vertexPair(x, y, c, 0.5f);
-
}
// Render the middle
UseTexture tblock(m_button_l);
@@ -555,6 +554,7 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
void GuitarGraph::drawBar(double time, float h) {
glutil::Begin block(GL_TRIANGLE_STRIP);
+ glNormal3f(0.0f, 1.0f, 0.0f);
glVertex2f(-2.5f, time2y(time + h));
glVertex2f(2.5f, time2y(time + h));
glVertex2f(-2.5f, time2y(time - h));
|
|
From: Tapio V. <aa...@us...> - 2009-11-09 22:14:04
|
Module: performous Branch: master Commit: 223a7099afabd797b7d210a34c33ec7933ed6a8e Author: Tapio Vierros <tap...@gm...> Date: Tue Nov 10 00:00:33 2009 +0200 Added config variable to toggle between 2d/3d instrument notes. 3d enabled by default for now (for easier testing). --- data/schema.xml | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/data/schema.xml b/data/schema.xml index 400fe54..9313de9 100644 --- a/data/schema.xml +++ b/data/schema.xml @@ -118,6 +118,12 @@ to save the current settings to XML. <long>Allows completely disabling background videos. It is recommended to leave this enabled as Performous will still smoothly fade out the video if your computer is not fast enough.</long> </locale> </entry> + <entry name="graphic/3d_notes" type="bool" value="true"> + <locale name="C"> + <short>3D notes</short> + <long>Draw instrument notes as 3-dimensional objects. May hurt performance on older hardware.</long> + </locale> + </entry> <entry name="graphic/svg_lod" type="float" value="1.0"> <ui unit="x" /> <limits min="0.5" max="3.0" step="0.1" /> |
|
From: Tapio V. <aa...@us...> - 2009-11-09 22:14:01
|
Module: performous
Branch: master
Commit: 91437700f7060fcd47c702759c39f7985e3b48af
Author: Tapio Vierros <tap...@gm...>
Date: Mon Nov 9 23:59:52 2009 +0200
Notes can be rendered in 2d or 3d.
---
game/guitargraph.cc | 54 +++++++++++++++++++++++++++++++++++++++-----------
game/guitargraph.hh | 1 +
2 files changed, 43 insertions(+), 12 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 0b0507f..89219fb 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -54,6 +54,7 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
m_fretObj(getThemePath("fret.obj"), 1.0f),
m_tappableObj(getThemePath("fret_tap.obj"), 1.0f),
m_drums(track=="drums"),
+ m_use3d(config["graphic/3d_notes"].b()),
m_cx(0.0, 0.2),
m_width(0.5, 0.4),
m_stream(),
@@ -422,7 +423,7 @@ void GuitarGraph::draw(double time) {
}
}
// Draw the notes
- enableLighting();
+ if (m_use3d) enableLighting();
for (Chords::const_iterator it = m_chords.begin(); it != m_chords.end(); ++it) {
float tBeg = it->begin - time;
float tEnd = it->end - time;
@@ -451,6 +452,14 @@ void GuitarGraph::draw(double time) {
c.g += glow;
c.b += glow;
drawNote(fret, c, tBeg, tEnd, whammy, it->tappable);
+
+ if (!m_use3d && it->tappable) {
+ float l = std::max(0.5, m_correctness.get());
+ glColor3f(l, l, l);
+ float x = -2.0f + fret;
+ m_tap.dimensions.center(time2y(tBeg)).middle(x);
+ m_tap.draw();
+ }
}
}
// Draw the cursor
@@ -462,9 +471,17 @@ void GuitarGraph::draw(double time) {
float x = -2.0f + fret - 0.5f * m_drums;
float l = m_hit[fret + !m_drums].get();
glColor4fv(color(fret));
- m_fretObj.draw(x, time2y(0.0), (1.0-l)/8.0);
+ if (m_use3d) {
+ m_fretObj.draw(x, time2y(0.0), (1.0-l)/8.0);
+ } else {
+ m_button.dimensions.center(time2y(0.0)).middle(x);
+ m_button.draw();
+ glColor3f(l, l, l);
+ m_tap.dimensions = m_button.dimensions;
+ m_tap.draw();
+ }
}
- disableLighting();
+ if (m_use3d) disableLighting();
glColor3f(1.0f, 1.0f, 1.0f);
}
@@ -491,14 +508,22 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
float yEnd = time2y(tEnd);
if (yBeg - 2 * fretWid >= yEnd) {
if (yEnd > yBeg - 3 * fretWid) yEnd = yBeg - 3 * fretWid; // Short note: render minimum renderable length
- //c.a = time2a(tBeg);
- glColor4fv(c);
// Render the ring
float y = yBeg + fretWid;
- //vertexPair(x, y, c, 1.0f);
- y -= fretWid;
- obj->draw(x, y, 0.0f);
- y -= fretWid;
+ if (m_use3d) {
+ y -= fretWid;
+ glColor4fv(c);
+ obj->draw(x, y, 0.0f);
+ y -= fretWid;
+ } else {
+ UseTexture tblock(m_button_l);
+ glutil::Begin block(GL_TRIANGLE_STRIP);
+ c.a = time2a(tBeg); glColor4fv(c);
+ vertexPair(x, y, c, 1.0f);
+ y -= 2 * fretWid;
+ vertexPair(x, y, c, 0.5f);
+
+ }
// Render the middle
UseTexture tblock(m_button_l);
glutil::Begin block(GL_TRIANGLE_STRIP);
@@ -517,9 +542,14 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
vertexPair(x, yEnd, c, 0.0f);
} else {
// Too short note: only render the ring
- //c.a = time2a(tBeg);
- glColor4fv(c);
- obj->draw(x, time2y(tBeg), 0.0f);
+ if (m_use3d) {
+ glColor4fv(c);
+ obj->draw(x, time2y(tBeg), 0.0f);
+ } else {
+ c.a = time2a(tBeg); glColor4fv(c);
+ m_button.dimensions.center(time2y(tBeg)).middle(x);
+ m_button.draw();
+ }
}
}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index b0b4782..f706090 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -73,6 +73,7 @@ class GuitarGraph {
AnimValue m_hit[6];
boost::scoped_ptr<Texture> m_neck;
bool m_drums;
+ bool m_use3d;
AnimValue m_cx, m_width;
std::size_t m_stream;
TrackMapConstPtr m_track_map;
|
|
From: Tapio V. <aa...@us...> - 2009-11-09 22:13:59
|
Module: performous
Branch: master
Commit: 6428b3986c1450420de0220061e578e998f67746
Author: Tapio Vierros <tap...@gm...>
Date: Mon Nov 9 23:07:44 2009 +0200
Notes drawn as colored 3d objects with lighting.
---
game/guitargraph.cc | 80 ++++++++++++++++++++++++++++++++------------------
game/guitargraph.hh | 5 ++-
game/video_driver.cc | 2 +
3 files changed, 57 insertions(+), 30 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index edafa3b..0b0507f 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -2,6 +2,7 @@
#include "fs.hh"
#include "song.hh"
+#include "3dobject.hh"
#include <cmath>
#include <cstdlib>
@@ -50,6 +51,8 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
m_button("button.svg"),
m_button_l("button_l.svg"),
m_tap("tap.svg"),
+ m_fretObj(getThemePath("fret.obj"), 1.0f),
+ m_tappableObj(getThemePath("fret_tap.obj"), 1.0f),
m_drums(track=="drums"),
m_cx(0.0, 0.2),
m_width(0.5, 0.4),
@@ -338,9 +341,9 @@ glutil::Color const& GuitarGraph::color(int fret) const {
static glutil::Color fretColors[5] = {
glutil::Color(0.0f, 0.9f, 0.0f),
glutil::Color(0.9f, 0.0f, 0.0f),
- glutil::Color(0.8f, 0.8f, 0.0f),
+ glutil::Color(0.9f, 0.9f, 0.0f),
glutil::Color(0.0f, 0.0f, 1.0f),
- glutil::Color(0.8f, 0.4f, 0.0f)
+ glutil::Color(0.9f, 0.4f, 0.0f)
};
if (fret < 0 || fret > 4) throw std::logic_error("Invalid fret number in GuitarGraph::getColor");
if (m_drums) {
@@ -350,6 +353,28 @@ glutil::Color const& GuitarGraph::color(int fret) const {
return fretColors[fret];
}
+namespace {
+ void enableLighting() {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+
+ GLfloat light_position[] = { -50.0, 15.0, -5.0, 1.0 };
+ glLightfv(GL_LIGHT0, GL_POSITION, light_position);
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+ glEnable(GL_LIGHT0);
+ }
+
+ void disableLighting() {
+ glDisable(GL_LIGHT0);
+ glDisable(GL_COLOR_MATERIAL);
+ glDisable(GL_LIGHTING);
+ glDisable(GL_DEPTH_TEST);
+ }
+}
+
void GuitarGraph::draw(double time) {
Dimensions dimensions(1.0); // FIXME: bogus aspect ratio (is this fixable?)
dimensions.screenBottom().middle(m_cx.get()).fixedWidth(m_width.get());
@@ -390,11 +415,14 @@ void GuitarGraph::draw(double time) {
tEnd = future;
}
glColor4f(1.0f, 1.0f, 1.0f, time2a(tEnd));
+ glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, texCoord); glVertex2f(-w, time2y(tEnd));
+ glNormal3f(0.0f, 1.0f, 0.0f);
glTexCoord2f(1.0f, texCoord); glVertex2f(w, time2y(tEnd));
}
}
// Draw the notes
+ enableLighting();
for (Chords::const_iterator it = m_chords.begin(); it != m_chords.end(); ++it) {
float tBeg = it->begin - time;
float tEnd = it->end - time;
@@ -422,15 +450,7 @@ void GuitarGraph::draw(double time) {
c.r += glow;
c.g += glow;
c.b += glow;
- drawNote(fret, c, tBeg, tEnd, whammy);
-
- if (it->tappable) {
- float l = std::max(0.5, m_correctness.get());
- glColor3f(l, l, l);
- float x = -2.0f + fret;
- m_tap.dimensions.center(time2y(tBeg)).middle(x);
- m_tap.draw();
- }
+ drawNote(fret, c, tBeg, tEnd, whammy, it->tappable);
}
}
// Draw the cursor
@@ -440,14 +460,11 @@ void GuitarGraph::draw(double time) {
// Fret buttons on cursor
for (int fret = m_drums; fret < 5; ++fret) {
float x = -2.0f + fret - 0.5f * m_drums;
- glColor4fv(color(fret));
- m_button.dimensions.center(time2y(0.0)).middle(x);
- m_button.draw();
float l = m_hit[fret + !m_drums].get();
- glColor3f(l, l, l);
- m_tap.dimensions = m_button.dimensions;
- m_tap.draw();
+ glColor4fv(color(fret));
+ m_fretObj.draw(x, time2y(0.0), (1.0-l)/8.0);
}
+ disableLighting();
glColor3f(1.0f, 1.0f, 1.0f);
}
@@ -455,12 +472,14 @@ namespace {
const float fretWid = 0.5f;
void vertexPair(float x, float y, glutil::Color c, float ty) {
c.a = y2a(y); glColor4fv(c);
- glTexCoord2f(0.0f, ty); glVertex2f(x - fretWid, y);
- glTexCoord2f(1.0f, ty); glVertex2f(x + fretWid, y);
+ glNormal3f(0.0f,1.0f,0.0f); glTexCoord2f(0.0f, ty); glVertex2f(x - fretWid, y);
+ glNormal3f(0.0f,1.0f,0.0f); glTexCoord2f(1.0f, ty); glVertex2f(x + fretWid, y);
}
}
-void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, float whammy) {
+void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, float whammy, bool tappable) {
+ Object3d* obj = &m_fretObj;
+ if (tappable) obj = &m_tappableObj;
float x = -2.0f + fret;
if (m_drums) x -= 0.5f;
if (m_drums && fret == 0) {
@@ -472,15 +491,18 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
float yEnd = time2y(tEnd);
if (yBeg - 2 * fretWid >= yEnd) {
if (yEnd > yBeg - 3 * fretWid) yEnd = yBeg - 3 * fretWid; // Short note: render minimum renderable length
- UseTexture tblock(m_button_l);
- glutil::Begin block(GL_TRIANGLE_STRIP);
- c.a = time2a(tBeg); glColor4fv(c);
+ //c.a = time2a(tBeg);
+ glColor4fv(c);
// Render the ring
float y = yBeg + fretWid;
- vertexPair(x, y, c, 1.0f);
- y -= 2 * fretWid;
- vertexPair(x, y, c, 0.5f);
+ //vertexPair(x, y, c, 1.0f);
+ y -= fretWid;
+ obj->draw(x, y, 0.0f);
+ y -= fretWid;
// Render the middle
+ UseTexture tblock(m_button_l);
+ glutil::Begin block(GL_TRIANGLE_STRIP);
+ vertexPair(x, y, c, 0.5f);
if (whammy > 0.1) {
while ((y -= fretWid) > yEnd + fretWid) {
// The sin formula is pure magic
@@ -495,9 +517,9 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
vertexPair(x, yEnd, c, 0.0f);
} else {
// Too short note: only render the ring
- c.a = time2a(tBeg); glColor4fv(c);
- m_button.dimensions.center(time2y(tBeg)).middle(x);
- m_button.draw();
+ //c.a = time2a(tBeg);
+ glColor4fv(c);
+ obj->draw(x, time2y(tBeg), 0.0f);
}
}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index c20b95e..b0b4782 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -9,6 +9,7 @@
#include "joystick.hh"
#include "surface.hh"
#include "opengl_text.hh"
+#include "3dobject.hh"
class Song;
@@ -67,6 +68,8 @@ class GuitarGraph {
Surface m_button;
Texture m_button_l;
Surface m_tap;
+ Object3d m_fretObj;
+ Object3d m_tappableObj;
AnimValue m_hit[6];
boost::scoped_ptr<Texture> m_neck;
bool m_drums;
@@ -99,7 +102,7 @@ class GuitarGraph {
int m_dead;
glutil::Color const& color(int fret) const;
void drawBar(double time, float h);
- void drawNote(int fret, glutil::Color, float tBeg, float tEnd, float whammy = 0);
+ void drawNote(int fret, glutil::Color, float tBeg, float tEnd, float whammy = 0, bool tappable = false);
void nextTrack();
void difficultyAuto(bool tryKeepCurrent = false);
bool difficulty(Difficulty level);
diff --git a/game/video_driver.cc b/game/video_driver.cc
index dcb0f5a..0fb7ddb 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -86,6 +86,8 @@ void Window::resize() {
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+ glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
// Set projection
glMatrixMode(GL_PROJECTION);
|
|
From: Tapio V. <aa...@us...> - 2009-11-09 22:13:57
|
Module: performous
Branch: master
Commit: 4beb4de2a8d4a3b95c8d15f7e206601e46bbe1f4
Author: Tapio Vierros <tap...@gm...>
Date: Mon Nov 9 23:03:04 2009 +0200
3d object class and simple Wavefront Obj file format parser.
---
game/3dobject.cc | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
game/3dobject.hh | 53 +++++++++++++++++++++++
2 files changed, 174 insertions(+), 0 deletions(-)
diff --git a/game/3dobject.cc b/game/3dobject.cc
new file mode 100644
index 0000000..1bac829
--- /dev/null
+++ b/game/3dobject.cc
@@ -0,0 +1,121 @@
+#include "3dobject.hh"
+#include "surface.hh"
+#include "glutil.hh"
+
+#include <vector>
+#include <map>
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <stdexcept>
+#include <string>
+#include <cmath>
+
+
+// TODO: use display lists for drawing?
+// TODO: test & fix faces that doesn't have texcoords in the file
+// TODO: group handling for loader
+
+
+namespace {
+ /// Returns a word (delimited by delim) in a string st at position pos (1-based)
+ std::string getWord(std::string& st, size_t pos, char delim) {
+ std::istringstream iss(st);
+ std::string ret;
+ for (size_t i = 1; i <= pos; i++)
+ getline(iss, ret, delim);
+ return ret;
+ }
+}
+
+
+void Object3d::loadWavefrontObj(std::string filepath, float scale) {
+ std::string row;
+ std::ifstream file(filepath.c_str());
+ if (!file.is_open()) throw std::runtime_error("Couldn't open object file "+filepath);
+ m_vertices.clear();
+ m_faces.clear();
+ m_texcoords.clear();
+ while (!file.eof()) {
+ getline(file, row);
+ std::istringstream srow(row);
+ float x,y,z;
+ std::string tempst;
+ if (row.substr(0,2) == "v ") { // Vertices
+ srow >> tempst >> x >> y >> z;
+ m_vertices.push_back(Vertex(x*scale,y*scale,z*scale));
+ } else if (row.substr(0,2) == "vt") { // Texture Coordinates
+ srow >> tempst >> x >> y;
+ m_texcoords.push_back(TexCoord(x,y));
+ } else if (row.substr(0,2) == "vn") { // Normals
+ srow >> tempst >> x >> y >> z;
+ double sum = std::abs(x)+std::abs(y)+std::abs(z);
+ if (sum == 0) throw std::runtime_error("Object "+filepath+" has invalid normal(s).");
+ x /= sum; y /= sum; z /= sum;
+ m_normals.push_back(Vertex(x,y,z));
+ } else if (row.substr(0,2) == "f ") { // Faces
+ Face f;
+ srow >> tempst;
+ int v_id;
+ // Parse face point's coordinate references
+ while (!srow.eof()) {
+ srow >> tempst;
+ for (size_t i = 1; i <= 3; i++) {
+ std::string st_id(getWord(tempst,i,'/'));
+ if (!st_id.empty()) {
+ std::istringstream conv_int(st_id);
+ conv_int >> v_id;
+ switch (i) {
+ // Vertex indices are 1-based in the file
+ case 1: f.vertices.push_back(v_id-1); break;
+ case 2: f.texcoords.push_back(v_id-1); break;
+ case 3: f.normals.push_back(v_id-1); break;
+ }
+ }
+ }
+ }
+ // Face must have equal number of v, vt, vn or none of a kind
+ if (f.vertices.size() > 0
+ && (f.texcoords.empty() || (f.texcoords.size() == f.vertices.size()))
+ && (f.normals.empty() || (f.normals.size() == f.vertices.size()))) {
+ m_faces.push_back(f);
+ } else {
+ throw std::runtime_error("Object "+filepath+" has invalid face(s).");
+ }
+ }
+ }
+}
+
+
+void Object3d::draw(float x, float y, float z) const {
+ //UseTexture tex(*m_texture);
+ std::vector<Face>::const_iterator it;
+ // Iterate through faces
+ for (it = m_faces.begin(); it != m_faces.end(); it++) {
+ // Select a suitable primitive
+ GLenum polyType = GL_POLYGON;
+ switch (it->vertices.size()) {
+ case 3: polyType = GL_TRIANGLES; break;
+ case 4: polyType = GL_QUADS; break;
+ }
+ glutil::Begin block(polyType);
+ // Iterate through face's points
+ std::vector<int>::const_iterator it2;
+ for (size_t i = 0; i < it->vertices.size(); i++) {
+ // Texture coordinates
+ if (!it->texcoords.empty())
+ glTexCoord2f(m_texcoords[it->texcoords[i]].s, m_texcoords[it->texcoords[i]].t);
+ // Normals
+ if (!it->normals.empty())
+ glNormal3f(
+ m_normals[it->normals[i]].x,
+ m_normals[it->normals[i]].y,
+ m_normals[it->normals[i]].z);
+ // Vertices
+ glVertex3f(
+ m_vertices[it->vertices[i]].x+x,
+ m_vertices[it->vertices[i]].y+y,
+ m_vertices[it->vertices[i]].z+z);
+ }
+ }
+}
diff --git a/game/3dobject.hh b/game/3dobject.hh
new file mode 100644
index 0000000..9baef99
--- /dev/null
+++ b/game/3dobject.hh
@@ -0,0 +1,53 @@
+#pragma once
+
+#include <vector>
+#include <map>
+#include <iostream>
+#include <stdexcept>
+#include <string>
+
+#include "surface.hh"
+#include "glutil.hh"
+
+// TODO: Exception handling
+// TODO: Texture loading
+
+struct Vertex {
+ Vertex(float x = 0, float y = 0, float z = 0): x(x), y(y), z(z) {}
+ float x;
+ float y;
+ float z;
+};
+
+struct TexCoord {
+ TexCoord(float s = 0, float t = 0): s(s), t(t) {}
+ float s;
+ float t;
+};
+
+struct Face {
+ std::vector<int> vertices;
+ std::vector<int> texcoords;
+ std::vector<int> normals;
+};
+
+
+class Object3d {
+ private:
+ std::vector<Vertex> m_vertices;
+ std::vector<TexCoord> m_texcoords;
+ std::vector<Vertex> m_normals;
+ std::vector<Face> m_faces;
+ //boost::scoped_ptr<Texture> m_texture;
+ /// load a Wavefront .obj 3d object file
+ void loadWavefrontObj(std::string filepath, float scale = 1.0);
+ public:
+ /// constructors
+ Object3d();
+ Object3d(std::string filepath, float scale = 1.0) {
+ //m_texture.reset(new Texture("button.svg"));
+ loadWavefrontObj(filepath, scale);
+ }
+ /// draws the object
+ void draw(float x = 0, float y = 0, float z = 0) const;
+};
|
|
From: Tapio V. <aa...@us...> - 2009-11-09 22:13:56
|
Module: performous Branch: master Commit: 73e194be65657f56de27c7340f4be9533e5bf7ac Author: Tapio Vierros <tap...@gm...> Date: Mon Nov 9 23:00:30 2009 +0200 Added 3d fret objects (Wavefront Obj format). --- themes/CMakeLists.txt | 2 +- themes/default/fret.obj | 515 +++++++++++++++++++++++++++++++++++++ themes/default/fret_tap.obj | 599 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1115 insertions(+), 1 deletions(-) |
|
From: Jaakko N. <jni...@us...> - 2009-11-09 19:53:44
|
Module: performous
Branch: dance
Commit: 8318e0a6681e4907b4737d0f9c908e9f6d158808
Author: Jaakko Nikkola <jaa...@tk...>
Date: Mon Nov 9 21:36:10 2009 +0200
Some code added to songparser-sm.cc, yet not enough to work correctly.
The beginning of songparser-sm works as songparser-txt reading information
connected to the song. The notes are read in a vector of note "lines", each
line in form of another vector (size of 4) or map.
Additions to songparser.hh and song.hh needed and (most of them)
explained in the file.
---
game/songparser-sm.cc | 137 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 137 insertions(+), 0 deletions(-)
diff --git a/game/songparser-sm.cc b/game/songparser-sm.cc
index e318b61..f090c86 100644
--- a/game/songparser-sm.cc
+++ b/game/songparser-sm.cc
@@ -1 +1,138 @@
#include "songparser.hh"
+
+#include <boost/lexical_cast.hpp>
+#include <boost/algorithm/string.hpp>
+#include <algorithm>
+#include <stdexcept>
+#include <map>
+
+/// @file
+/// Functions used for parsing the StepMania SM format
+
+//needs additions to songparser.hh: smCheck, smParseNote, smParseField
+//needs additions to song.hh: typedef std::vector<std::map<int, Note> > d_notes or std::vector<std::vector<Note> > d_notes or similar
+
+namespace {
+ void assign(int& var, std::string const& str) {
+ try {
+ var = boost::lexical_cast<int>(str);
+ } catch (...) {
+ throw std::runtime_error("\"" + str + "\" is not valid integer value");
+ }
+ }
+ void assign(double& var, std::string str) {
+ std::replace(str.begin(), str.end(), ',', '.'); // Fix decimal separators
+ try {
+ var = boost::lexical_cast<double>(str);
+ } catch (...) {
+ throw std::runtime_error("\"" + str + "\" is not valid floating point value");
+ }
+ }
+ void assign(bool& var, std::string const& str) {
+ if (str == "YES" || str == "yes" || str == "1") var = true;
+ else if (str == "NO" || str == "no" || str == "0") var = false;
+ else throw std::runtime_error("Invalid boolean value: " + str);
+ }
+}
+
+
+
+bool SongParser::smCheck(std::vector<char> const& data) { return data[0] == '#' && data[1] >= 'A' && data[1] <= 'Z' && data.back() == ';'; }
+
+void SongParser::smParse() {
+ Song& s = m_song;
+ std::string line;
+ while (getline(line) && smParseField(line)) {}
+ if (s.title.empty() || s.artist.empty()) throw std::runtime_error("Required header fields missing");
+ if (m_bpm != 0.0) addBPM(0, m_bpm);
+ while (getline(line) && smParseNote(line)) {}
+ // Workaround for the terminating : 1 0 0 line, written by some converters
+/* if (!s.notes.empty() && s.notes.back().type != Note::SLEEP && s.notes.back().begin == s.notes.back().end) s.notes.pop_back();
+*/
+}
+
+bool SongParser::smParseField(std::string& line) {
+ if (line.empty()) return true;
+ if (line[0] == '/' && line[1] == '/') return true; //jump over possible comments
+ std::string::size_type pos = line.find(':');
+ if (pos == std::string::npos) throw std::runtime_error("Invalid format, should be #key:value");
+ std::string key = boost::trim_copy(line.substr(1, pos - 1));
+ if (key == "NOTES") {
+ /*note values need to be analyzed here, because of different kind of
+ representation. Values are:
+ <NotesType>:
+ <Description>:
+ <DifficultyClass>:
+ <DifficultyMeter>:
+ <RadarValues>:
+ <NoteData>*/
+ return false; // after taking note values, jumps to "NoteData"
+ }
+ std::string value = boost::trim_copy(line.substr(pos + 1));
+ value.erase(value.size() -1); // compared to txtParseField, here last character(';') is eliminated
+ if (value.empty()) return true;
+ if (key == "TITLE") m_song.title = value.substr(value.find_first_not_of(" :"));
+ else if (key == "ARTIST") m_song.artist = value.substr(value.find_first_not_of(" "));
+ else if (key == "BANNER") m_song.cover = value;
+ else if (key == "MUSIC") m_song.music["background"] = m_song.path + value;
+ else if (key == "BACKGROUND") m_song.background = value;
+ else if (key == "OFFSET") assign(m_song.start, value);
+ else if (key == "BPMS"){
+ std::replace(value.begin(), value.end(), ';', ','); // replacing the last ';'
+ std::istringstream iss(value);
+ std::string ts, bpm; //ts is the timestamp of the bpm
+ while(std::getline(iss, ts, '=') && std::getline(iss, bpm, ','))
+ if(atof(ts.c_str()) == 0) assign(m_bpm, bpm);
+ else addBPM(atof(ts.c_str()), atof(bpm.c_str()));
+ }
+ /*additionally .sm fileformat has following constants:
+ #SUBTITLE
+ #TITLETRANSLIT
+ #SUBTITLETRANSLIT
+ #ARTISTTRANSLIT
+ #CREDIT
+ #CDTITLE
+ #SAMPLESTART
+ #SAMPLELENGTH
+ #SELECTABLE
+ #STOPS
+ #BGCHANGE
+ */
+ return true;
+}
+
+bool SongParser::smParseNote(std::string& line){
+ if(line.empty()) return true;
+ if(line[0] == '#') throw std::runtime_error("Key found in the middle of notes");
+ if(line[0] == ';') return false; //end mark
+
+ //reading the notes into m_song.dance_notes
+ //int lcount; //line counter for bpm
+ int tm = 0; //time counter
+ if(line[0] == ',') {
+ /*TODO Counting the timestamp of each note
+ tm +=
+ count new bpm
+ lcount =0;*/
+ return true;
+ }
+ std::istringstream iss(line);
+ std::map<int, Note> d_beat;
+ for(int i =1; i <= 4; i++){
+ if(iss.get() == '0') {
+ Note note;
+ //@TODO Note should be NULL or something...
+ d_beat[i] = note;
+ continue;
+ }
+ else { //if(iss.get() == '1')
+ Note note;
+ note.begin = tm;
+ note.end = tm;
+ d_beat[i] = note;
+ }
+ //@TODO hold etc. notes
+ m_song.d_notes.push_back(d_beat); //d_notes must be in song.hh
+ }
+ return true;
+}
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:19
|
Module: performous Branch: dance Commit: 5a4dc686d4c233afdd2232f4bcddbd26cbaac207 Author: Tapio Vierros <tap...@gm...> Date: Sun Nov 8 10:28:35 2009 +0200 Merge branch 'master' into dance --- |
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:17
|
Module: performous
Branch: dance
Commit: 31abba01e0f1f2c9b3d82174d3230c966ba4f948
Author: Tapio Vierros <tap...@gm...>
Date: Sun Nov 8 10:27:24 2009 +0200
Some basis for dance graph.
---
game/dancegraph.cc | 51 +++++++++++++++++++++++++++++++++++++++++++++
game/dancegraph.hh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
game/joystick.hh | 2 +-
3 files changed, 110 insertions(+), 1 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 46e002f..3a4777b 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -1 +1,52 @@
#include "dancegraph.hh"
+#include "fs.hh"
+
+/// Constructor
+DanceGraph::DanceGraph(Audio& audio, Song const& song):
+ m_audio(audio),
+ m_song(song),
+ m_input(input::DANCEPAD),
+ m_arrow("arrow.svg"),
+ m_cx(0.0, 0.2),
+ m_width(0.5, 0.4),
+ m_stream(),
+ m_dead(1000),
+ m_text(getThemePath("sing_timetxt.svg"), config["graphic/text_lod"].f()),
+ m_correctness(0.0, 5.0),
+ m_score(),
+ m_scoreFactor(),
+ m_streak(),
+ m_longestStreak()
+{
+ //TODO
+
+
+}
+
+
+/// Handles input
+void DanceGraph::engine() {
+ //TODO
+
+}
+
+
+/// Handles scoring and such
+void DanceGraph::dance(double time, input::Event const& ev) {
+ //TODO:
+
+}
+
+
+/// Draws the dance graph
+void DanceGraph::draw(double time) {
+ //TODO
+
+}
+
+
+/// Draws a single note (or hold)
+void DanceGraph::drawNote(int fret, glutil::Color, float tBeg, float tEnd) {
+ //TODO
+
+}
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 6f70f09..a3f146b 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -1 +1,59 @@
#pragma once
+
+#include <vector>
+
+#include <boost/ptr_container/ptr_map.hpp>
+#include "animvalue.hh"
+#include "notes.hh"
+#include "audio.hh"
+#include "joystick.hh"
+#include "surface.hh"
+#include "opengl_text.hh"
+
+class Song;
+
+/// handles drawing of notes
+class DanceGraph {
+ public:
+ /// constructor
+ DanceGraph(Audio& audio, Song const& song);
+ /** draws DanceGraph
+ * @param time at which time to draw
+ */
+ void draw(double time);
+ void engine();
+ void position(double cx, double width) { m_cx.setTarget(cx); m_width.setTarget(width); }
+ double dead(double time) const { return time > -0.5 && m_dead > 50; }
+ unsigned stream() const { return m_stream; }
+ double correctness() const { return m_correctness.get(); }
+ int getScore() const { return m_score * m_scoreFactor; }
+ private:
+ void dance(double time, input::Event const& ev);
+ void drawNote(int fret, glutil::Color, float tBeg, float tEnd);
+ Audio& m_audio;
+ input::InputDev m_input;
+ Song const& m_song;
+ Surface m_arrow;
+ AnimValue m_cx, m_width;
+ std::size_t m_stream;
+ struct Event {
+ double time;
+ AnimValue glow;
+ int type; // 0 = miss (pick), 1 = tap, 2 = pick
+ int fret;
+ Duration const* dur;
+ double holdTime;
+ Event(double t, int ty, int f = -1, Duration const* d = NULL): time(t), glow(0.0, 5.0), type(ty), fret(f), dur(d), holdTime(d ? d->begin : getNaN()) { if (type > 0) glow.setValue(1.0); }
+ };
+ typedef std::vector<Event> Events;
+ Events m_events;
+ unsigned m_holds[4];
+ int m_dead;
+ SvgTxtTheme m_text;
+ AnimValue m_correctness;
+ double m_score;
+ double m_scoreFactor;
+ int m_streak;
+ int m_longestStreak;
+};
+
diff --git a/game/joystick.hh b/game/joystick.hh
index f3ee06b..ea59fc8 100644
--- a/game/joystick.hh
+++ b/game/joystick.hh
@@ -16,7 +16,7 @@
#endif
namespace input {
- enum DevType { GUITAR, DRUMS };
+ enum DevType { GUITAR, DRUMS, DANCEPAD };
static const std::size_t BUTTONS = 6;
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:15
|
Module: performous
Branch: dance
Commit: 1f319d424719882f2d5299def9860fc36da81abd
Author: Tapio Vierros <tap...@gm...>
Date: Sat Nov 7 18:07:27 2009 +0200
Moved RNG seeding to main()
---
game/backgrounds.cc | 2 --
game/main.cc | 2 ++
game/songs.cc | 1 -
3 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/game/backgrounds.cc b/game/backgrounds.cc
index a854442..8450234 100644
--- a/game/backgrounds.cc
+++ b/game/backgrounds.cc
@@ -12,7 +12,6 @@
#include <sstream>
#include <stdexcept>
#include <cstdlib>
-#include <ctime>
void Backgrounds::reload() {
if (m_loading) return;
@@ -48,7 +47,6 @@ void Backgrounds::reload_internal() {
m_loading = false;
{
boost::mutex::scoped_lock l(m_mutex);
- std::srand(time(NULL));
random_shuffle(m_bgs.begin(), m_bgs.end());
m_dirty = false;
m_bgiter = 0;
diff --git a/game/main.cc b/game/main.cc
index 6748fc5..5341fd5 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -27,6 +27,7 @@
#include <fstream>
#include <string>
#include <vector>
+#include <cstdlib>
volatile bool g_quit = false;
@@ -197,6 +198,7 @@ int main(int argc, char** argv) {
std::signal(SIGINT, quit);
std::signal(SIGTERM, quit);
std::ios::sync_with_stdio(false); // We do not use C stdio
+ std::srand(std::time(NULL));
// Parse commandline options
std::vector<std::string> mics;
std::vector<std::string> pdevs;
diff --git a/game/songs.cc b/game/songs.cc
index 0dbe269..f98ce87 100644
--- a/game/songs.cc
+++ b/game/songs.cc
@@ -134,7 +134,6 @@ void Songs::randomize_internal() {
rnd::mt19937 gen(gendev); // Make Mersenne Twister random number generator, seeded with random_device.
for (SongVector::const_iterator it = m_filtered.begin(); it != m_filtered.end(); ++it) (*it)->randomIdx = gen();
*/
- std::srand(std::time(NULL));
// Assign the songs randomIdx that is used for sorting in the "random" mode
for (SongVector::const_iterator it = m_filtered.begin(); it != m_filtered.end(); ++it) (*it)->randomIdx = std::rand();
m_order = 0; // Use randomIdx sort mode
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:13
|
Module: performous
Branch: dance
Commit: d810cb85072925167709eb6cfd9c2403b81cc901
Author: Tapio Vierros <tap...@gm...>
Date: Sat Nov 7 16:03:47 2009 +0200
Seed the rng with time(), so that the backgrounds are randomized differently on each run.
---
game/backgrounds.cc | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/game/backgrounds.cc b/game/backgrounds.cc
index 8450234..a854442 100644
--- a/game/backgrounds.cc
+++ b/game/backgrounds.cc
@@ -12,6 +12,7 @@
#include <sstream>
#include <stdexcept>
#include <cstdlib>
+#include <ctime>
void Backgrounds::reload() {
if (m_loading) return;
@@ -47,6 +48,7 @@ void Backgrounds::reload_internal() {
m_loading = false;
{
boost::mutex::scoped_lock l(m_mutex);
+ std::srand(time(NULL));
random_shuffle(m_bgs.begin(), m_bgs.end());
m_dirty = false;
m_bgiter = 0;
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:11
|
Module: performous
Branch: dance
Commit: 0ba3edc9c97959e8d5822512468a6608be8e9421
Author: Tapio Vierros <tap...@gm...>
Date: Tue Nov 3 22:32:26 2009 +0200
Added support for rhythm and coop guitar tracks plus some broken track detection.
Additional guitar tracks are displayed in the song browser by interlaced guitar icons.
---
game/screen_sing.cc | 12 +++++++++++-
game/screen_songs.cc | 27 +++++++++++++++++----------
game/songparser-ini.cc | 16 +++++++++++++---
3 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 1cf8429..f4c85f8 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -53,6 +53,8 @@ void ScreenSing::enter() {
// Here we load alternatively guitar/bass tracks until no guitar controler is available
// then we load all the drums tracks until no drum controler is available (and place them in second position)
bool no_guitar = false;
+ bool no_guitar2 = false;
+ bool no_guitar3 = false;
bool no_bass = false;
while (1) {
try {
@@ -61,9 +63,17 @@ void ScreenSing::enter() {
} catch (std::runtime_error&) {no_guitar = true;}
try {
Instruments::iterator it = m_instruments.end();
+ m_instruments.insert(it, new GuitarGraph(m_audio, *m_song, "coop guitar"));
+ } catch (std::runtime_error&) {no_guitar2 = true;}
+ try {
+ Instruments::iterator it = m_instruments.end();
m_instruments.insert(it, new GuitarGraph(m_audio, *m_song, "bass"));
} catch (std::runtime_error&) {no_bass = true;}
- if( no_guitar && no_bass ) break;
+ try {
+ Instruments::iterator it = m_instruments.end();
+ m_instruments.insert(it, new GuitarGraph(m_audio, *m_song, "rhythm guitar"));
+ } catch (std::runtime_error&) {no_guitar3 = true;}
+ if( no_guitar && no_guitar2 && no_guitar3 && no_bass ) break;
}
while(1) {
try {
diff --git a/game/screen_songs.cc b/game/screen_songs.cc
index 1b79007..7c0e6de 100644
--- a/game/screen_songs.cc
+++ b/game/screen_songs.cc
@@ -245,16 +245,23 @@ void ScreenSongs::draw() {
glTexCoord2f(0.25f, 1.0f); glVertex2f(x, dim.y2());
}
{
- // guitar
- alpha = (isTrackInside(song_display.track_map,"guitar")) ? 1.00 : 0.25;
- glutil::Begin block(GL_TRIANGLE_STRIP);
- glColor4f(1.0, 1.0, 1.0, alpha);
- x = dim.x1()+0.25*(dim.x2()-dim.x1());
- glTexCoord2f(0.25f, 0.0f); glVertex2f(x, dim.y1());
- glTexCoord2f(0.25f, 1.0f); glVertex2f(x, dim.y2());
- x = dim.x1()+0.50*(dim.x2()-dim.x1());
- glTexCoord2f(0.50f, 0.0f); glVertex2f(x, dim.y1());
- glTexCoord2f(0.50f, 1.0f); glVertex2f(x, dim.y2());
+ // guitars
+ alpha = 1.0;
+ int guitarCount = 0;
+ if (isTrackInside(song_display.track_map,"guitar")) guitarCount++;
+ if (isTrackInside(song_display.track_map,"coop guitar")) guitarCount++;
+ if (isTrackInside(song_display.track_map,"rhythm guitar")) guitarCount++;
+ if (guitarCount == 0) { guitarCount = 1; alpha = 0.25; }
+ for (int i = guitarCount-1; i >= 0; i--) {
+ glutil::Begin block(GL_TRIANGLE_STRIP);
+ glColor4f(1.0, 1.0, 1.0, alpha);
+ x = dim.x1()+(0.25+i*0.04)*(dim.x2()-dim.x1());
+ glTexCoord2f(0.25f, 0.0f); glVertex2f(x, dim.y1());
+ glTexCoord2f(0.25f, 1.0f); glVertex2f(x, dim.y2());
+ x = dim.x1()+(0.50+i*0.04)*(dim.x2()-dim.x1());
+ glTexCoord2f(0.50f, 0.0f); glVertex2f(x, dim.y1());
+ glTexCoord2f(0.50f, 1.0f); glVertex2f(x, dim.y2());
+ }
}
{
// bass
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 4b53e57..a55d489 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -49,8 +49,8 @@ void SongParser::iniParse() {
// These are added features (not part of FoF)
else if (key == "cover") s.cover = value;
else if (key == "background") s.background = value;
- else if (key == "video") m_song.video = value;
- else if (key == "videogap") assign(m_song.videoGap, value);
+ else if (key == "video") s.video = value;
+ else if (key == "videogap") assign(s.videoGap, value);
// End of added features
}
if (s.title.empty() || s.artist.empty()) throw std::runtime_error("Required header fields missing");
@@ -94,7 +94,8 @@ void SongParser::iniParse() {
else if (name == "T1 GEMS") name = "guitar"; // Some old MIDI files have a track named T1 GEMS
else if (name.substr(0, 5) != "PART ") continue;
else name.erase(0, 5);
- if (name == "GUITAR COOP") continue; // TODO: do something with these? They don't work in current version
+ if (name == "GUITAR COOP") name = "coop guitar";
+ if (name == "RHYTHM") name = "rhythm guitar";
if (name == "DRUM") name = "drums";
if (name == "DRUMS") name = "drums";
if (name == "BASS") name = "bass";
@@ -102,6 +103,7 @@ void SongParser::iniParse() {
// Process non-vocal tracks
if (name != "VOCALS") {
bool drums = (name == "drums");
+ int durCount = 0;
s.track_map.insert(make_pair(name,Track(name)));
NoteMap& nm2 = s.track_map.find(name)->second.nm;
for (MidiFileParser::NoteMap::const_iterator it2 = it->notes.begin(); it2 != it->notes.end(); ++it2) {
@@ -114,8 +116,16 @@ void SongParser::iniParse() {
if (beg > end) throw std::runtime_error("Reversed notes");
if (drums) end = beg;
dur.push_back(Duration(beg, end));
+ durCount++;
}
}
+ // If a track has only 20 or less frets it's most likely b0rked.
+ // This number has been extracted from broken song tracks, but
+ // it is probably DIFFICULTYCOUNT * different_frets.
+ if (durCount <= 20) {
+ nm2.clear();
+ s.track_map.erase(name);
+ }
continue;
}
// Process vocal tracks
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:09
|
Module: performous Branch: dance Commit: 3c1d6b4f1b3aeae5fe505bf8fc7d6949cc681669 Author: Lasse Karkkainen <tro...@tr...> Date: Tue Nov 3 08:16:39 2009 +0200 Removing hardcoded paths and making Performous behave better in non-standard installation location and when the installation is relocated. Changes include relative RPATH and detecting data path from executable location. Also some cleanup to plugin++ DLL code. --- game/CMakeLists.txt | 7 +++++ game/config.cmake.hh | 2 + game/configuration.cc | 30 ++++++++++++--------- game/main.cc | 2 - game/selfpath.hh | 7 ----- libs/plugin++/CMakeLists.txt | 9 +++--- libs/plugin++/include/plugin++/execname.hpp | 9 ++++++ libs/plugin++/src/dll-posix.cpp | 17 ------------ libs/plugin++/src/dll-windows.cpp | 17 ------------ libs/plugin++/src/dll.cc | 29 ++++++++++++++++++++ game/selfpath.cc => libs/plugin++/src/execname.cc | 26 +++++++++--------- 11 files changed, 81 insertions(+), 74 deletions(-) |
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:07
|
Module: performous
Branch: dance
Commit: e0ed3045c236aec1d7dffffdd9e618a6c35c3a7e
Author: Lasse Karkkainen <tro...@tr...>
Date: Tue Nov 3 05:38:36 2009 +0200
Do not assume that all the funny things that SDL reports are drumsets
---
game/joystick.cc | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index afbca00..741426a 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -109,13 +109,20 @@ void input::SDL::init() {
}
unsigned int nbjoysticks = SDL_NumJoysticks();
- std::cout << "Detecting " << nbjoysticks << " joysticks..." << std::endl;
-
for (unsigned int i = 0 ; i < nbjoysticks ; ++i) {
- input::SDL::sdl_devices[i] = SDL_JoystickOpen(i);
std::string name = SDL_JoystickName(i);
- std::cout << "Id: " << i << std::endl;
- std::cout << " Name: " << name << std::endl;
+ std::cout << "SDL joystick: " << name << std::endl;
+ SDL_Joystick* joy = SDL_JoystickOpen(i);
+ if (SDL_JoystickNumButtons(joy) == 0) {
+ std::cout << " Not suitable for Performous" << std::endl;
+ SDL_JoystickClose(joy);
+ continue;
+ }
+ input::SDL::sdl_devices[i] = joy;
+ std::cout << SDL_JoystickNumAxes(joy) << std::endl;
+ std::cout << SDL_JoystickNumBalls(joy) << std::endl;
+ std::cout << SDL_JoystickNumButtons(joy) << std::endl;
+ std::cout << SDL_JoystickNumHats(joy) << std::endl;
if( forced_type.find(i) != forced_type.end() ) {
switch(forced_type[i]) {
case input::Private::GUITAR_GH:
@@ -156,8 +163,7 @@ void input::SDL::init() {
// Here we should send an event to have correct state buttons
init_devices();
// Adding keyboard instrument
- std::cout << "Id: " << input::Private::KEYBOARD_ID << std::endl;
- std::cout << " Name: Keyboard (emulated guitar): " << (config["game/keyboard_guitar"].b() ? "disabled":"enabled") << std::endl;
+ std::cout << "Keyboard as guitar controller: " << (config["game/keyboard_guitar"].b() ? "disabled":"enabled") << std::endl;
input::SDL::sdl_devices[input::Private::KEYBOARD_ID] = NULL;
input::Private::devices[input::Private::KEYBOARD_ID] = input::Private::InputDevPrivate(input::Private::GUITAR_GH);
}
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:05
|
Module: performous
Branch: dance
Commit: 3be2d201398b4e6baba09495c66c17bfa07ab84c
Author: Lasse Karkkainen <tro...@tr...>
Date: Tue Nov 3 04:13:27 2009 +0200
Add a function for finding where the executable is
---
game/selfpath.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
game/selfpath.hh | 7 +++++++
2 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/game/selfpath.cc b/game/selfpath.cc
new file mode 100644
index 0000000..69cfca3
--- /dev/null
+++ b/game/selfpath.cc
@@ -0,0 +1,52 @@
+#include "selfpath.hh"
+
+#if defined(_WIN32)
+#include <windows.h>
+boost::filesystem::path selfpath() {
+ char buf[1024];
+ DWORD ret = GetModuleFileName(NULL, buf, sizeof(buf));
+ if (ret == 0 || ret == sizeof(buf)) return boost::filesystem::path();
+ return buf;
+}
+#elif defined(__APPLE__) // Not tested
+#include <mach-o/dyld.h>
+boost::filesystem::path selfpath() {
+ char buf[1024];
+ uint32_t size = sizeof(buf);
+ int ret = _NSGetExecutablePath(buf, &size);
+ if (ret != 0) return boost::filesystem::path();
+ return buf;
+}
+#elif defined(sun) || defined(__sun)
+#include <stdlib.h>
+boost::filesystem::path selfpath() {
+ return getexecname();
+}
+#elif defined(__FreeBSD__)
+#include <sys/sysctl.h>
+boost::filesystem::path selfpath() {
+ int mib[4];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = -1;
+ char buf[1024];
+ size_t size = sizeof(buf);
+ sysctl(mib, 4, buf, &size, NULL, 0);
+ if (size == 0 || size == sizeof(buf)) return boost::filesystem::path();
+ return std::string(buf, size);
+}
+#elif defined(__linux__)
+#include <unistd.h>
+boost::filesystem::path selfpath() {
+ char buf[1024];
+ ssize_t ret = readlink("/proc/self/exe", buf, sizeof(buf));
+ if (ret == 0 || ret == sizeof(buf)) return boost::filesystem::path();
+ return std::string(buf, ret);
+}
+#else
+boost::filesystem::path selfpath() {
+ return boost::filesystem::path();
+}
+#endif
+
diff --git a/game/selfpath.hh b/game/selfpath.hh
new file mode 100644
index 0000000..5acbd12
--- /dev/null
+++ b/game/selfpath.hh
@@ -0,0 +1,7 @@
+#pragma once
+#include <boost/filesystem.hpp>
+
+/// Get the current executable name with path. Returns empty path if the name
+/// cannot be found. May return absolute or relative paths.
+boost::filesystem::path selfpath();
+
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:31:01
|
Module: performous
Branch: dance
Commit: 155603f268a0cc2dc2abeb9cd019b9f78620d559
Author: Tapio Vierros <tap...@gm...>
Date: Sun Nov 1 18:15:57 2009 +0200
Assume that an instrument difficulty level that has only one chord is broken (so don't show it).
---
game/guitargraph.cc | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index a0704b1..edafa3b 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -323,8 +323,14 @@ bool GuitarGraph::difficulty(Difficulty level) {
int fail = 0;
for (int fret = 0; fret < 5; ++fret) if (nm.find(basepitch + fret) == nm.end()) ++fail;
if (fail == 5) return false;
+ Difficulty prevLevel = m_level;
m_level = level;
updateChords();
+ if (m_chords.size() <= 1) { // If there is only one chord, it's probably b0rked
+ m_level = prevLevel;
+ updateChords();
+ return false;
+ }
return true;
}
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:30:58
|
Module: performous
Branch: dance
Commit: eb0dc5d398b3390ade0bf1526360c263317ffbe3
Author: Tapio Vierros <tap...@gm...>
Date: Sun Nov 1 17:10:03 2009 +0200
Small optimization for note drawing when no whammy is used.
---
game/guitargraph.cc | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 8bf38c3..a0704b1 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -475,13 +475,13 @@ void GuitarGraph::drawNote(int fret, glutil::Color c, float tBeg, float tEnd, fl
y -= 2 * fretWid;
vertexPair(x, y, c, 0.5f);
// Render the middle
- while ((y -= fretWid) > yEnd + fretWid) {
- if (whammy < 0.1) {
- vertexPair(x, y, c, 0.5f);
- } else {
+ if (whammy > 0.1) {
+ while ((y -= fretWid) > yEnd + fretWid) {
// The sin formula is pure magic
vertexPair(x+sin((whammy-0.75)*6.0 + (yBeg-tEnd)/y)/3.0, y, c, 0.5f);
}
+ } else {
+ while ((y -= 10.0) > yEnd + fretWid) vertexPair(x, y, c, 0.5f);
}
// Render the end
y = yEnd + fretWid;
|
|
From: Tapio V. <aa...@us...> - 2009-11-08 08:30:56
|
Module: performous
Branch: dance
Commit: 5318971840e5e2733d0b786a09b2b092fa264f60
Author: Tapio Vierros <tap...@gm...>
Date: Sun Nov 1 16:48:41 2009 +0200
If there is no separate music tracks for instruments, don't completely kill off the audio when playing wrong.
---
game/screen_sing.cc | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 397b543..1cf8429 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -106,6 +106,7 @@ void ScreenSing::instrumentLayout(double time) {
} else {
CountSum cs = volume[it->first];
if (cs.first > 0) level = cs.second / cs.first;
+ if (m_song->music.size() <= 1) level = std::max(0.333, level);
m_audio.streamFade(it->first, level);
}
}
|