Mercurial > hg > opencollidoscope
comparison CollidoscopeApp/src/Chunk.cpp @ 16:4dad0b810f18
Comment tidy up + attributions
author | Fiore Martin <f.martin@qmul.ac.uk> |
---|---|
date | Tue, 16 Aug 2016 14:27:53 +0100 |
parents | 75b744078d66 |
children |
comparison
equal
deleted
inserted
replaced
15:5241f96479d6 | 16:4dad0b810f18 |
---|---|
42 } | 42 } |
43 | 43 |
44 void Chunk::update( const DrawInfo &di ) | 44 void Chunk::update( const DrawInfo &di ) |
45 { | 45 { |
46 using namespace ci; | 46 using namespace ci; |
47 /* if resetting animate the chunks to shrink to 0 size */ | 47 /* if resetting animate the chunks to nicely shrink to 0 size */ |
48 if ( mResetting ){ | 48 if ( mResetting ){ |
49 if ( mAnimate > 0.0f ){ | 49 if ( mAnimate > 0.0f ){ |
50 mAnimate -= 0.1f; | 50 mAnimate -= 0.1f; |
51 if ( mAnimate <= 0.0f ){ | 51 if ( mAnimate <= 0.0f ){ |
52 mAnimate = 0.0f; | 52 mAnimate = 0.0f; |
62 if ( mAnimate > 1.0f ){ // clip to one | 62 if ( mAnimate > 1.0f ){ // clip to one |
63 mAnimate = 1.0f; | 63 mAnimate = 1.0f; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 mX = di.flipX( 1 + (mIndex * (2 + kWidth)) ); // FIXME this should happen only once when resized | 67 mX = di.flipX( 1 + (mIndex * (2 + kWidth)) ); // FIXME more efficient if it happens only once when resized |
68 } | 68 } |
69 | 69 |
70 void Chunk::draw( const DrawInfo& di, ci::gl::BatchRef &batch ){ | 70 void Chunk::draw( const DrawInfo& di, ci::gl::BatchRef &batch ){ |
71 using namespace ci; | 71 using namespace ci; |
72 | 72 |
73 gl::pushModelMatrix(); | 73 gl::pushModelMatrix(); |
74 | 74 |
75 const float chunkHeight = mAnimate * mAudioTop * di.getMaxChunkHeight(); | 75 const float chunkHeight = mAnimate * mAudioTop * di.getMaxChunkHeight(); |
76 | 76 |
77 // place the chunk in the right position brigns back the y of chunkHeight/2 so | 77 // place the chunk in the right position brings back the y of chunkHeight/2 so |
78 // so that after scaling the wave is still centered at the wave center | 78 // so that after scaling the wave is still centered at the wave center |
79 gl::translate( mX, di.getWaveCenterY() - ( chunkHeight / 2 ) - 1 ); | 79 gl::translate( mX, di.getWaveCenterY() - ( chunkHeight / 2 ) - 1 ); |
80 | 80 |
81 // FIXME todo use max between top and bottom | |
82 // scale according to audio amplitude | 81 // scale according to audio amplitude |
83 gl::scale( 1.0f, chunkHeight ); | 82 gl::scale( 1.0f, chunkHeight ); |
84 batch->draw(); | 83 batch->draw(); |
85 | 84 |
86 | 85 |