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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:12
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:10
|
Module: performous
Branch: dance
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-14 18:43:09
|
Module: performous
Branch: dance
Commit: 12a6cc32cd7e931ce8cd41d992534178cb666625
Author: Markus Raab <un...@ma...>
Date: Tue Nov 10 13:30:31 2009 +0100
packaging for debian lenny added
also ignore build32 and build64 folders
ignore database.xml in game folder
---
.gitignore | 2 ++
cmake/performous-packaging.cmake | 3 +++
game/.gitignore | 1 +
3 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
index 378eac2..4497982 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
build
+build32
+build64
diff --git a/cmake/performous-packaging.cmake b/cmake/performous-packaging.cmake
index acc3027..256aad1 100644
--- a/cmake/performous-packaging.cmake
+++ b/cmake/performous-packaging.cmake
@@ -62,6 +62,9 @@ if(UNIX)
if("${LSB_DISTRIB}" MATCHES "Ubuntu9.10")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-thread1.38.0, libboost-program-options1.38.0, libboost-regex1.38.0, libboost-filesystem1.38.0, libboost-date-time1.38.0, libavcodec52, libavformat52, libswscale0, libmagick++1, libxml++2.6-2, libglew1.5")
endif("${LSB_DISTRIB}" MATCHES "Ubuntu9.10")
+ if("${LSB_DISTRIB}" MATCHES "Debian5.*")
+ set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl1.2debian, libcairo2, librsvg2-2, libboost-dev, libavcodec51, libavformat52, libswscale0, libmagick++10, libxml++2.6-2, libglew1.5")
+ endif("${LSB_DISTRIB}" MATCHES "Ubuntu9.10")
if(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
message("WARNING: ${LSB_DISTRIB} not supported yet.\nPlease set deps in cmake/performous-packaging.cmake before packaging.")
endif(NOT CPACK_DEBIAN_PACKAGE_DEPENDS)
diff --git a/game/.gitignore b/game/.gitignore
index 314577e..22bc235 100644
--- a/game/.gitignore
+++ b/game/.gitignore
@@ -7,6 +7,7 @@ config.hh
database
performous.xml
+database.xml
highscore
highscore.txt
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:07
|
Module: performous
Branch: dance
Commit: b4c3e59b029e5aec08b9e1bd0fffd5d47ad6b174
Author: Markus Raab <un...@ma...>
Date: Tue Nov 10 11:45:19 2009 +0100
reading/writing players database
---
game/database.cc | 22 +++++++++++++++-------
game/players.cc | 3 ++-
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/game/database.cc b/game/database.cc
index c3b1422..510807a 100644
--- a/game/database.cc
+++ b/game/database.cc
@@ -8,12 +8,17 @@ Database::Database(fs::path filename) :
m_filename(filename)
{
try { load(); }
- catch(...) { std::cerr << "Could not load " << file() << ", will create" << std::endl; }
+ catch(std::exception const& e) {
+ std::cerr << "Could not load " << file() << ": " << e.what() << std::endl;
+ std::cerr << "will try to create" << std::endl;
+ }
}
Database::~Database() {
try { save(); }
- catch (...) { std::cerr << "Could not save players to " << file() << std::endl; }
+ catch (std::exception const& e) {
+ std::cerr << "Could not save " << file() << ": " << e.what() << std::endl;
+ }
}
void Database::load() {
@@ -31,7 +36,11 @@ void Database::save() {
m_players.save(players);
- create_directory(m_filename.parent_path());
+ if (!exists(m_filename.parent_path()) && !m_filename.parent_path().empty())
+ {
+ std::cout << "Will create directory: " << m_filename.parent_path() << std::endl;
+ create_directory(m_filename.parent_path());
+ }
doc.write_to_file_formatted(m_filename.string(), "UTF-8");
}
@@ -39,9 +48,8 @@ std::string Database::file() {
return m_filename.string();
}
-/*
-
// Test program for Database
int main()
-{}
-*/
+{
+ Database ("database.xml");
+}
diff --git a/game/players.cc b/game/players.cc
index 175624e..5935dc2 100644
--- a/game/players.cc
+++ b/game/players.cc
@@ -22,7 +22,6 @@ Players::~Players()
{ }
void Players::load(xmlpp::NodeSet n) {
-
for (xmlpp::NodeSet::const_iterator it = n.begin(); it != n.end(); ++it)
{
xmlpp::Element& element = dynamic_cast<xmlpp::Element&>(**it);
@@ -64,6 +63,7 @@ void Players::addPlayer (std::string const& name, std::string const& picture) {
if (pi.picture != "") // no picture, so don't search path
{
+ /* TODO: add again
ConfigItem::StringList const& sl = config["system/path_pictures"].sl();
typedef std::set<fs::path> dirs;
dirs d;
@@ -76,6 +76,7 @@ void Players::addPlayer (std::string const& name, std::string const& picture) {
if (pi.path != "") std::cout << "Found " << pi.picture << " in " << pi.path << std::endl;
else std::cout << "Not found " << pi.picture << std::endl;
+ */
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:05
|
Module: performous
Branch: dance
Commit: 1d5f09481ef98bc23f2a3cf456dcd316488fdd4b
Author: Markus Raab <un...@ma...>
Date: Tue Nov 10 10:27:38 2009 +0100
added some old files
---
data/database.xml | 19 ++++++
game/unused/folderview.cpp | 138 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 157 insertions(+), 0 deletions(-)
diff --git a/data/database.xml b/data/database.xml
new file mode 100644
index 0000000..8116110
--- /dev/null
+++ b/data/database.xml
@@ -0,0 +1,19 @@
+<performous>
+ <songs> <!-- a list of songs -->
+ <song id="123" artist="ABBA" title="Dancing Queen">
+ <!-- extra song details -->
+ </song>
+ </songs>
+ <players> <!-- a list of players -->
+ <player id="123" name="Markus">
+ <picture>markus.jpg</picture> <!-- optional picture shown at players selection -->
+ </player>
+ </players>
+ <hiscores> <!-- a list of highscores -->
+ <hiscore songid="123" playerid="123" track="VOCALS">600</hiscore>
+ </hiscores>
+</performous>
+<!--
+id of songs: collateByTitle (?)
+id of players: ?
+-->
diff --git a/game/unused/folderview.cpp b/game/unused/folderview.cpp
new file mode 100644
index 0000000..c2a92f7
--- /dev/null
+++ b/game/unused/folderview.cpp
@@ -0,0 +1,138 @@
+#include <boost/shared_ptr.hpp>
+#include <boost/filesystem.hpp>
+#include <algorithm>
+#include <iostream>
+#include <vector>
+
+namespace fs = boost::filesystem;
+
+class Song
+{
+ public:
+ Song(std::string const& path_, std::string const& filename_ = "") :
+ path(path_), filename(filename_)
+ {}
+
+ std::string path; ///< path of songfile
+ std::string filename; ///< name of songfile
+};
+
+namespace {
+ class IsFolder: public std::unary_function<boost::shared_ptr<Song>,bool> {
+ public:
+ bool operator() (boost::shared_ptr<Song> const song) const
+ {
+ return song->filename.empty();
+ }
+ };
+ class IsDirectBelow: public std::unary_function<boost::shared_ptr<Song>,bool> {
+ public:
+ IsDirectBelow(fs::path path) :
+ m_path(path)
+ {}
+ bool operator() (boost::shared_ptr<Song> const song) const
+ {
+ fs::path base (song->path);
+ base.remove_leaf();
+ // std::cout << "base: " << base << "\tm_path: " << m_path << std::endl;
+ return base == m_path;
+ }
+ private:
+ fs::path m_path;
+ };
+ class IsBelow: public std::unary_function<boost::shared_ptr<Song>,bool> {
+ public:
+ IsBelow(fs::path path) :
+ m_path(path)
+ {}
+ bool operator() (boost::shared_ptr<Song> const song) const
+ {
+ fs::path path (song->path);
+ while (!path.empty())
+ {
+ path.remove_leaf();
+ if (path == m_path) return true;
+ }
+ return false;
+ }
+ private:
+ fs::path m_path;
+ };
+}
+
+class Songs
+{
+ public:
+ typedef std::vector<boost::shared_ptr<Song> > SongVector;
+
+ Songs() :
+ m_songs()
+ {
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/protected")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/protected/Demo", "Demo")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/protected/Great", "Great")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/protected/Sub")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/protected/Sub/Song", "Yeah")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/free")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/free/Demo", "Demo")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/home/songs/free/Great", "Great")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/media/performous")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/media/performous/Internet")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/media/performous/Internet/Song", "Song")));
+ m_songs.push_back(boost::shared_ptr<Song>(new Song("/media/performous/Hits")));
+ }
+ void only_folders()
+ {
+ m_songs.erase(std::remove_if(m_songs.begin(), m_songs.end(), std::not1(IsFolder())), m_songs.end());
+ }
+ void only_songs()
+ {
+ m_songs.erase(std::remove_if(m_songs.begin(), m_songs.end(), IsFolder()), m_songs.end());
+ }
+ void only_path(std::string path)
+ {
+ m_songs.erase(std::remove_if(m_songs.begin(), m_songs.end(), std::not1(IsDirectBelow (path))), m_songs.end());
+ }
+ void only_root()
+ {
+ SongVector::iterator end = m_songs.end();
+ for (SongVector::const_iterator it = m_songs.begin(); it != end; ++it)
+ {
+ std::cout << "Removing below: " << (*it)->path << std::endl;
+ end = std::remove_if(m_songs.begin(), end, IsBelow ((*it)->path));
+ }
+ m_songs.erase(end, m_songs.end());
+ }
+ ~Songs()
+ { }
+ friend std::ostream & operator<< (std::ostream & os, Songs const& s);
+ private:
+ SongVector m_songs;
+
+};
+
+std::ostream & operator<< (std::ostream & os, Songs const& s)
+{
+ for (Songs::SongVector::const_iterator it = s.m_songs.begin(); it!= s.m_songs.end(); ++it)
+ {
+ os << "Song " << (*it)->path << "/ " << (*it)->filename << std::endl;
+ }
+ return os;
+}
+
+class ScreenSongs
+{};
+
+int main(int argc, char**argv)
+{
+ /*
+ if (argc!=2) return 1;
+ std::string path = argv[1];
+ */
+ Songs songs;
+ songs.only_root();
+ // songs.only_path(path);
+ // songs.only_songs();
+ std::cout << songs;
+}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:02
|
Module: performous
Branch: dance
Commit: 767480bc6a747c540c715574588c7073a180c021
Author: Markus Raab <un...@ma...>
Date: Tue Nov 10 10:05:14 2009 +0100
first compiling version
do not expect performous to run
lots of renames highscore ->hiscore
simple design: a single database access ->may redesign later
players (and other parts of database) get their chance for loading
when database reloads
---
game/.gitignore | 9 ++++
game/database.cc | 47 +++++++++++++++++++++
game/database.hh | 32 ++++++++++++++
game/{highscore.cc => hiscore.cc} | 7 +++-
game/{highscore.hh => hiscore.hh} | 6 +++
game/main.cc | 11 +++--
game/players.cc | 51 +++--------------------
game/players.hh | 19 ++++-----
game/{screen_highscore.cc => screen_hiscore.cc} | 5 +-
game/{screen_highscore.hh => screen_hiscore.hh} | 2 +-
game/screen_players.cc | 3 +-
game/screen_players.hh | 2 +-
game/screen_songs.cc | 2 +-
13 files changed, 128 insertions(+), 68 deletions(-)
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:43:00
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:58
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:57
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:55
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:53
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:51
|
Module: performous Branch: dance 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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:50
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:48
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:46
|
Module: performous
Branch: dance
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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:44
|
Module: performous Branch: dance 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: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:42:44
|
Module: performous
Branch: dance
Commit: 232a3e1f57c414faeb6479d1d18b1aa4a28ec5d2
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Nov 7 19:37:02 2009 +0100
Applied Spruit_elf hack for properfly parsing multiplayer txt files
---
game/songparser-txt.cc | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/game/songparser-txt.cc b/game/songparser-txt.cc
index 5204204..9ba1c67 100644
--- a/game/songparser-txt.cc
+++ b/game/songparser-txt.cc
@@ -85,6 +85,7 @@ bool SongParser::txtParseNote(std::string line) {
addBPM(ts, bpm);
return true;
}
+ if (line[0] == 'P') return true; //We ignore player information for now (multiplayer hack)
Note n;
n.type = Note::Type(iss.get());
unsigned int ts = m_prevts;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:24:59
|
Module: performous Branch: master Commit: 839f4c1a6f7c3ab7114216bf1cd1434a16de320b Author: Lasse Karkkainen <tro...@tr...> Date: Sat Nov 14 20:25:22 2009 +0200 Update Packaging.txt --- docs/Packaging.txt | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-) diff --git a/docs/Packaging.txt b/docs/Packaging.txt index 0710c07..651f816 100644 --- a/docs/Packaging.txt +++ b/docs/Packaging.txt @@ -5,7 +5,7 @@ cmake/performous-packaging.cmake. Source packages: -- Remove any extra files in source tree (the ones from SVN and build folder can be kept) +- Remove any extra files in source tree (the ones from Git and an the build folder can be kept) cmake ../ make package_source @@ -18,8 +18,3 @@ Binary packages: cmake ../ make package - -Ubuntu 8.04 needs special care: -- CMake 2.4 cannot package for Debian, so install 2.6 from backports -- Be sure not to install anything else from backports if you intend plain 8.04 package - |
|
From: Jaakko N. <jni...@us...> - 2009-11-14 18:13:41
|
Module: performous
Branch: dance
Commit: 47c5caf8a783460db23503a653dc149c5236b62f
Author: Jaakko Nikkola <jaa...@tk...>
Date: Sat Nov 14 20:13:07 2009 +0200
Some more fixes...
---
game/songparser-sm.cc | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/game/songparser-sm.cc b/game/songparser-sm.cc
index d24afc8..64a89af 100644
--- a/game/songparser-sm.cc
+++ b/game/songparser-sm.cc
@@ -49,24 +49,23 @@ bool SongParser::smCheck(std::vector<char> const& data) {
void SongParser::smParse() {
Song& s = m_song;
std::string line;
+ int lcount = 0; //line counter for note duration
+ int count = 0; //total lines counter
+ bool readable = false; //makes sure that other values are read before notes
+ int tm = 0; //time counter
+ int dur; //note duration
+ std::string notestype;
+ std::string description;
+ DanceDifficulty danceDifficulty;
+ DanceDifficultyMap danceDifficultyMap;
+ DanceChords chords;
while (getline(line)) {
-
- int lcount = 0; //line counter for note duration
- int count = 0; //total lines counter
- bool readable = false; //makes sure that other values are read before notes
- int tm = 0; //time counter
- int dur; //note duration
- std::string notestype;
- std::string description;
- DanceDifficulty danceDifficulty;
- DanceDifficultyMap danceDifficultyMap;
- DanceChords chords;
if (line.empty() || line == "\r") continue;
if (line[0] == '/' && line[1] == '/') continue; //jump over possible comments
//reading of the values
- if (!readable && isNote(line[0]) ) {
+ if (readable && isNote(line[0]) ) {
//reading notes into a chord
std::istringstream iss(line);
DanceChord chord;
@@ -83,7 +82,7 @@ void SongParser::smParse() {
}
continue;
}
- if (readable && isNote(line[0]) ) throw std::runtime_error("Notes outside NoteData");
+ if (!readable && isNote(line[0]) ) throw std::runtime_error("Notes outside NoteData");
if (line[0] == ',') {
/*Counting the timestamp of each note*/
dur = 4 * ( 1/(m_bpm/60) ) / lcount; //counts one note duration in seconds;
@@ -185,6 +184,8 @@ void SongParser::smParse() {
*/
continue;
}
+ if (m_song.danceTracks.empty() ) throw std::runtime_error("No note data in the file");
if (s.title.empty() || s.artist.empty()) throw std::runtime_error("Required header fields missing");
if (m_bpm != 0.0) addBPM(0, m_bpm);
+
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:04:42
|
Module: performous
Branch: master
Commit: 67a36855f2414d5679ae0e7cb249817ff5ce6d8c
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Nov 14 20:05:02 2009 +0200
Update TODO
---
docs/TODO.txt | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/docs/TODO.txt b/docs/TODO.txt
index 4cc6347..496eb21 100644
--- a/docs/TODO.txt
+++ b/docs/TODO.txt
@@ -7,22 +7,19 @@ Structural:
* Also playback and Vorbis + MP3 decoding
* Mixer and samplerate conversion inside
- Get rid of ScreenManager in favor of recursive approach?
-- Switch to Clanlib?
+- Switch to Clanlib or SFML?
- Switch to GStreamer? (both the ripper and the game)
Big features:
- Add compose screen (using features discussed on mailing list)
-- Multiplayer duet (needs XML song format)
+- Multiplayer duet (needs XML or MIDI song format)
- Recording performances
* Internet highscore
-- Ingame Singstar DVD support (integrated ripping + ffmpeg feeding + XML song format)
-- Playing and dancing
- * Guitar code from Silky Strings project (needs some love, but should be quite usable)
- * Drum code from scratch? [currently has testing mode in practice screen]
- * Dance code from scratch?
- Mic effects (reduce volume for bad singers, perfect pitch, reverb, etc)
+- Ingame Singstar DVD support (integrated ripping + ffmpeg feeding + XML song format)
+- Dance game [WIP]
Features:
|
|
From: Jaakko N. <jni...@us...> - 2009-11-14 17:43:42
|
Module: performous Branch: dance Commit: f7b0c3dc9287da9a08356e2136365db40f5e598b Author: Jaakko Nikkola <jaa...@tk...> Date: Sat Nov 14 19:40:22 2009 +0200 Functions smParseField and smParseNotes fusioned to smParse. --- game/songparser-sm.cc | 257 ++++++++++++++++++++++++++----------------------- game/songparser.hh | 2 - 2 files changed, 137 insertions(+), 122 deletions(-) |
|
From: Jaakko N. <jni...@us...> - 2009-11-14 17:43:38
|
Module: performous Branch: dance Commit: 5a8a1a43aba280e9aaba7a20c6de6ad742656d0d Author: Jaakko Nikkola <jaa...@tk...> Date: Sat Nov 14 15:57:26 2009 +0200 Merge branch 'dance' of jni...@gi...:/gitroot/performous/performous into dance --- |
|
From: Jaakko N. <jni...@us...> - 2009-11-14 17:43:37
|
Module: performous
Branch: dance
Commit: 4a046a4fe623fb2ba81516bc41088c3184896c93
Author: Jaakko Nikkola <jaa...@tk...>
Date: Sat Nov 14 15:56:52 2009 +0200
some function parameters to references
---
game/songparser.hh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/game/songparser.hh b/game/songparser.hh
index b95e93c..d874d5e 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -96,8 +96,8 @@ class SongParser {
void iniParse();
bool smCheck(std::vector<char> const& data);
void smParse();
- bool smParseField(std::string line);
- bool smParseNote(std::string line, DanceChords chords);
+ bool smParseField(std::string& line);
+ bool smParseNote(std::string& line, DanceChords& chords);
double m_prevtime;
unsigned int m_prevts;
unsigned int m_relativeShift;
|
|
From: Jaakko N. <jni...@us...> - 2009-11-14 17:43:35
|
Module: performous
Branch: dance
Commit: 302bcad6b6a1f5b7186d8996052718ac76251dee
Author: Jaakko Nikkola <jaa...@tk...>
Date: Sat Nov 14 15:55:53 2009 +0200
some function parameters into references
---
game/songparser-sm.cc | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/game/songparser-sm.cc b/game/songparser-sm.cc
index c501e57..3669a4a 100644
--- a/game/songparser-sm.cc
+++ b/game/songparser-sm.cc
@@ -42,15 +42,11 @@ void SongParser::smParse() {
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);
-
- // 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) {
+bool SongParser::smParseField(std::string& line) {
if (line.empty()) return true;
- if (line[0] == '/' && line[1] == '/') return true; //jump over possible comments
+ if (line[0] == '/') 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));
@@ -129,7 +125,7 @@ bool SongParser::smParseField(std::string line) {
return true;
}
-bool SongParser::smParseNote(std::string line, DanceChords chords){
+bool SongParser::smParseNote(std::string& line, DanceChords& chords){
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
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 17:23:07
|
Module: performous
Branch: master
Commit: fad338dde91edd99262e642fe8ee1f8acd0a674b
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Nov 14 19:23:24 2009 +0200
No global variables for failsamples (this should avoid the mutex assertion failure on exit)
---
game/guitargraph.cc | 32 +++++++++++++++-----------------
game/guitargraph.hh | 1 +
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index eff9119..ed011d3 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -41,8 +41,6 @@ namespace {
return score;
}
- std::vector<Sample> g_samplesG, g_samplesD;
-
}
GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
@@ -75,19 +73,20 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
m_use3d = false;
}
unsigned int sr = m_audio.getSR();
- if (g_samplesD.empty()) {
- g_samplesD.push_back(Sample(getPath("sounds/drum_bass.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_snare.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_hi-hat.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_tom1.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_cymbal.ogg"), sr));
- //g_samplesD.push_back(Sample(getPath("sounds/drum_tom2.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail1.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail2.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail3.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail4.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail5.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail6.ogg"), sr));
+ if (m_drums) {
+ m_samples.push_back(Sample(getPath("sounds/drum_bass.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_snare.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_hi-hat.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_tom1.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_cymbal.ogg"), sr));
+ //m_samples.push_back(Sample(getPath("sounds/drum_tom2.ogg"), sr));
+ } else {
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail1.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail2.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail3.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail4.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail5.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail6.ogg"), sr));
}
unsigned int i = 0;
for (TrackMap::const_iterator it = m_song.track_map.begin(); it != m_song.track_map.end(); ++it,++i) {
@@ -193,8 +192,7 @@ void GuitarGraph::fail(double time, int fret) {
if (fret == -2) return; // Tapped note
m_events.push_back(Event(time, 0, fret));
if (fret < 0) fret = std::rand();
- std::vector<Sample> const& samples = (m_drums ? g_samplesD : g_samplesG);
- m_audio.play(samples[unsigned(fret) % samples.size()], "audio/fail_volume");
+ m_audio.play(m_samples[unsigned(fret) % m_samples.size()], "audio/fail_volume");
m_score -= 50;
m_streak = 0;
}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index 8adaafc..b4a6a15 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -73,6 +73,7 @@ class GuitarGraph {
Object3d m_fretObj;
Object3d m_tappableObj;
AnimValue m_hit[6];
+ std::vector<Sample> m_samples;
boost::scoped_ptr<Texture> m_neck;
bool m_drums;
bool m_use3d;
|