|
From: Tapio V. <aa...@us...> - 2009-11-23 20:19:45
|
Module: performous
Branch: dance
Commit: 877e10969f6a0d3dca76b29d9dc59b9704547d71
Author: Tapio Vierros <tap...@gm...>
Date: Mon Nov 23 22:17:23 2009 +0200
Initial graphics side support for long hold notes.
---
game/dancegraph.cc | 56 ++++++++++---
game/dancegraph.hh | 1 +
themes/default/arrow_hold.svg | 178 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 221 insertions(+), 14 deletions(-)
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index 269e066..c3fa6bf 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -2,6 +2,7 @@
#include "fs.hh"
#include "notes.hh"
+#include "surface.hh"
#include <boost/lexical_cast.hpp>
#include <stdexcept>
@@ -39,6 +40,7 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_song(song),
m_input(input::GUITAR), // TODO: to be replaced by DANCEPAD
m_arrow(getThemePath("arrow.svg")),
+ m_arrow_hold(getThemePath("arrow_hold.svg")),
m_cx(0.0, 0.2),
m_width(0.5, 0.4),
m_stream(),
@@ -141,9 +143,14 @@ glutil::Color const& DanceGraph::color(int arrow_i) const {
}
namespace {
+ const float arrowScale = 0.6f;
const float arrowRotations[4] = { 270.0f, 180.0f, 0.0f, 90.0f };
-
-
+ const float holdWidth = 0.3;
+
+ void vertexPair(float x, float y, float ty) {
+ glTexCoord2f(0.0f, ty); glVertex2f(x - holdWidth, y);
+ glTexCoord2f(1.0f, ty); glVertex2f(x + holdWidth, y);
+ }
}
void DanceGraph::drawArrow(int arrow_i, float x, float y, float scale) {
@@ -190,36 +197,57 @@ void DanceGraph::draw(double time) {
glutil::Color c = color(arrow_i);
c.r += l; c.g += l; c.b +=l;
glColor4fv(c);
- drawArrow(arrow_i, x, time2y(0.0), 0.6 * s);
+ drawArrow(arrow_i, x, time2y(0.0), arrowScale * s);
}
// Draw the notes
- float tBeg, tEnd = 0.0f;
for (DanceNotes::iterator it = m_notes.begin(); it != m_notes.end(); ++it) {
- tBeg = it->note.begin - time;
- tEnd = it->note.end - time;
+ float tBeg = it->note.begin - time;
+ float tEnd = it->note.end - time;
+
+ // TODO: Remove me (temporary hack to test hold note drawing)
+ //tEnd += 0.6;
+
if (tEnd < past) continue;
if (tBeg > future) break;
-
+
int arrow_i = it->note.note;
float x = -1.5f + arrow_i;
- float s = 0.6f;
+ float s = arrowScale;
float yBeg = time2y(tBeg);
float yEnd = time2y(tEnd);
glutil::Color c = color(arrow_i);
double glow = it->hitAnim.get();
//c.a = std::sqrt(1.0 - glow);
- c.a = 1.0 - glow;
c.r += glow *.5;
c.g += glow *.5;
c.b += glow *.5;
- s += glow;
-
- glColor4fv(c);
- drawArrow(arrow_i, x, yBeg, s);
- //drawNote(it->note.note, c, tBeg, tEnd);
+ if (tEnd - tBeg > 0.1) {
+ // Draw holds
+ glColor4fv(c);
+ if (it->isHit) {
+ // TODO: What if hold is ended prematurely?
+ yBeg = std::max(time2y(0.0), yBeg);
+ yEnd = std::max(time2y(0.0), yEnd);
+ glColor3f(1.0f, 1.0f, 1.0f);
+ }
+ {
+ UseTexture tblock(m_arrow_hold);
+ glutil::Begin block(GL_TRIANGLE_STRIP);
+ vertexPair(x, yEnd, 1.0f);
+ vertexPair(x, yBeg, 0.0f);
+ }
+ // Draw begin
+ drawArrow(arrow_i, x, yBeg, s);
+ } else {
+ // Draw short note
+ c.a = 1.0 - glow;
+ s = arrowScale + glow;
+ glColor4fv(c);
+ drawArrow(arrow_i, x, yBeg, s);
+ }
}
// To test arrow coordinate positioning
diff --git a/game/dancegraph.hh b/game/dancegraph.hh
index 83095d1..c8866b3 100644
--- a/game/dancegraph.hh
+++ b/game/dancegraph.hh
@@ -60,6 +60,7 @@ class DanceGraph {
DanceNotes m_notes;
DanceNotes::iterator m_notesIt;
Surface m_arrow;
+ Texture m_arrow_hold;
AnimValue m_cx, m_width;
std::size_t m_stream;
struct Event {
diff --git a/themes/default/arrow_hold.svg b/themes/default/arrow_hold.svg
new file mode 100644
index 0000000..27249d5
--- /dev/null
+++ b/themes/default/arrow_hold.svg
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="64"
+ height="64"
+ id="svg2463"
+ sodipodi:version="0.32"
+ inkscape:version="0.47pre4 r22446"
+ version="1.0"
+ sodipodi:docname="arrow_hold.svg"
+ inkscape:output_extension="org.inkscape.output.svg.inkscape">
+ <defs
+ id="defs2465">
+ <linearGradient
+ id="linearGradient3789">
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0.25098041;"
+ offset="0"
+ id="stop3791" />
+ <stop
+ id="stop3797"
+ offset="0.5"
+ style="stop-color:#ffffff;stop-opacity:1;" />
+ <stop
+ style="stop-color:#ffffff;stop-opacity:0.25098041;"
+ offset="1"
+ id="stop3793" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3767">
+ <stop
+ style="stop-color:#800000;stop-opacity:1;"
+ offset="0"
+ id="stop3769" />
+ <stop
+ id="stop3779"
+ offset="0.5"
+ style="stop-color:#800000;stop-opacity:0.49803922;" />
+ <stop
+ style="stop-color:#800000;stop-opacity:0;"
+ offset="1"
+ id="stop3771" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3262">
+ <stop
+ style="stop-color:#f5f5f5;stop-opacity:0.22680412;"
+ offset="0"
+ id="stop3264" />
+ <stop
+ style="stop-color:#f5f5f5;stop-opacity:0.96078432;"
+ offset="1"
+ id="stop3266" />
+ </linearGradient>
+ <linearGradient
+ id="linearGradient3751"
+ inkscape:collect="always">
+ <stop
+ id="stop3753"
+ offset="0"
+ style="stop-color:black;stop-opacity:1;" />
+ <stop
+ id="stop3755"
+ offset="1"
+ style="stop-color:black;stop-opacity:0;" />
+ </linearGradient>
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective2471" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3751"
+ id="linearGradient3272"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.3868046,0,0,0.3868046,40.335717,481.59837)"
+ x1="665.12128"
+ y1="684.16162"
+ x2="381.28015"
+ y2="449.80624" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3751"
+ id="linearGradient2406"
+ gradientUnits="userSpaceOnUse"
+ gradientTransform="matrix(0.3868046,0,0,0.3868046,43.114888,485.8841)"
+ x1="665.12128"
+ y1="684.16162"
+ x2="381.28015"
+ y2="449.80624" />
+ <inkscape:perspective
+ id="perspective2838"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <inkscape:perspective
+ id="perspective3735"
+ inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+ inkscape:vp_z="1 : 0.5 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_x="0 : 0.5 : 1"
+ sodipodi:type="inkscape:persp3d" />
+ <linearGradient
+ inkscape:collect="always"
+ xlink:href="#linearGradient3789"
+ id="linearGradient3795"
+ x1="111.10967"
+ y1="803.5119"
+ x2="173.60966"
+ y2="803.5119"
+ gradientUnits="userSpaceOnUse" />
+ </defs>
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#f5f5f5"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ gridtolerance="10000"
+ guidetolerance="10"
+ objecttolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="5.6"
+ inkscape:cx="30.50978"
+ inkscape:cy="36.330452"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ inkscape:window-width="1021"
+ inkscape:window-height="720"
+ inkscape:window-x="377"
+ inkscape:window-y="55"
+ inkscape:snap-grids="true"
+ inkscape:snap-page="true"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata2468">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-110.35967,-771.51188)">
+ <rect
+ style="fill:url(#linearGradient3795);fill-opacity:1.0;fill-rule:nonzero;stroke:none;stroke-width:1.50000000000000000;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+ id="rect3749"
+ width="62.5"
+ height="62.5"
+ x="111.10967"
+ y="772.2619" />
+ <path
+ style="fill:none;stroke:#000000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="m 142.39167,772.01188 0,63 -0.032,0"
+ id="path2834" />
+ </g>
+</svg>
|