From 12d210327b39fec862e06fdc39967031a3930817 Mon Sep 17 00:00:00 2001 From: Jamie Allen Date: Mon, 20 Feb 2012 03:40:38 +0100 Subject: [PATCH] added STATE_SYNTHESISING - animation loop - for each analysis - comments needs cleaning up but they all seem to work... NOT SURE I'M USING THE STATES CORRECTLY!? --- example/RefractiveIndex.cpp | 6 +- src/CamNoiseAnalysis.cpp | 93 ++++++++++++++++++++++-- src/CamNoiseAnalysis.h | 7 +- src/ColorMultiAnalysis.cpp | 119 ++++++++++++++++++++++--------- src/ColorMultiAnalysis.h | 5 +- src/ColorSingleAnalysis.cpp | 93 ++++++++++++++++++++++-- src/ColorSingleAnalysis.h | 6 +- src/DiffNoiseAnalysis.cpp | 91 +++++++++++++++++++++-- src/DiffNoiseAnalysis.h | 6 +- src/IResponseAnalysis.cpp | 94 +++++++++++++++++++++--- src/IResponseAnalysis.h | 5 +- src/RelaxRateAnalysis.cpp | 105 ++++++++++++++++++++++++--- src/RelaxRateAnalysis.h | 5 +- src/ShadowScapesAnalysis.cpp | 117 +++++++++++------------------- src/ShapeFromShadingAnalysis.cpp | 96 ++++++++++++++++++++++--- src/ShapeFromShadingAnalysis.h | 6 +- src/StrobeAnalysis.cpp | 100 ++++++++++++++++++++++---- src/StrobeAnalysis.h | 7 +- 18 files changed, 765 insertions(+), 196 deletions(-) diff --git a/example/RefractiveIndex.cpp b/example/RefractiveIndex.cpp index 779c61a..1d11061 100644 --- a/example/RefractiveIndex.cpp +++ b/example/RefractiveIndex.cpp @@ -98,9 +98,9 @@ void RefractiveIndex::setup() //TODO: whichever one of these is first - it always runs twice ? - _analysisVector.push_back(new ShadowScapesAnalysis(V)); - _analysisVector.push_back(new ShadowScapesAnalysis(H)); - _analysisVector.push_back(new ShadowScapesAnalysis(D)); + // _analysisVector.push_back(new ShadowScapesAnalysis(V)); + // _analysisVector.push_back(new ShadowScapesAnalysis(H)); + // _analysisVector.push_back(new ShadowScapesAnalysis(D)); _analysisVector.push_back(new RelaxRateAnalysis()); diff --git a/src/CamNoiseAnalysis.cpp b/src/CamNoiseAnalysis.cpp index 3a0273f..d689039 100755 --- a/src/CamNoiseAnalysis.cpp +++ b/src/CamNoiseAnalysis.cpp @@ -1,8 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "CamNoiseAnalysis.h" #include "ofMain.h" @@ -28,6 +23,10 @@ void CamNoiseAnalysis::setup(int camWidth, int camHeight) _frame_cnt = 0; _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; + + int anim_time = 10; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } @@ -48,7 +47,8 @@ void CamNoiseAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); @@ -119,7 +119,8 @@ void CamNoiseAnalysis::draw() } else { - _RUN_DONE = true; + _state = STATE_SYNTHESISING; + // _RUN_DONE = true; } _frame_cnt++; @@ -130,12 +131,90 @@ void CamNoiseAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; + break; } diff --git a/src/CamNoiseAnalysis.h b/src/CamNoiseAnalysis.h index 79b1ff3..1a98100 100755 --- a/src/CamNoiseAnalysis.h +++ b/src/CamNoiseAnalysis.h @@ -27,8 +27,7 @@ public: protected: bool _RUN_DONE; - int _run_cnt, _save_cnt; - float c, _frame_cnt, _frame_cnt_max,_save_cnt_max ; - - + + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/ColorMultiAnalysis.cpp b/src/ColorMultiAnalysis.cpp index 0a8f1b5..9ac780a 100755 --- a/src/ColorMultiAnalysis.cpp +++ b/src/ColorMultiAnalysis.cpp @@ -1,35 +1,3 @@ -/* - - copyright (c) 2011 Copenhagen Institute of Interaction Design (CIID) - - all rights reserved. - - + redistribution and use in source and binary forms, with or without - + modification, are permitted provided that the following conditions - + are met: - + > redistributions of source code must retain the above copyright - + notice, this list of conditions and the following disclaimer. - + > redistributions in binary form must reproduce the above copyright - + notice, this list of conditions and the following disclaimer in - + the documentation and/or other materials provided with the - + distribution. - - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - + SUCH DAMAGE. - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "ColorMultiAnalysis.h" #include "ofMain.h" @@ -55,6 +23,10 @@ void ColorMultiAnalysis::setup(int camWidth, int camHeight) _fade_cnt=0; _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; + + int anim_time = 10; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } void ColorMultiAnalysis::acquire() @@ -74,7 +46,8 @@ void ColorMultiAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); @@ -141,8 +114,9 @@ void ColorMultiAnalysis::draw() } } else { + _state = STATE_SYNTHESISING; - _RUN_DONE = true; + //_RUN_DONE = true; } @@ -154,12 +128,89 @@ void ColorMultiAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; break; } diff --git a/src/ColorMultiAnalysis.h b/src/ColorMultiAnalysis.h index eff1c3a..c7ae204 100755 --- a/src/ColorMultiAnalysis.h +++ b/src/ColorMultiAnalysis.h @@ -22,6 +22,7 @@ public: protected: bool _RUN_DONE; - int _run_cnt, _save_cnt, _fade_cnt; - float c, _frame_cnt, _frame_cnt_max; + + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/ColorSingleAnalysis.cpp b/src/ColorSingleAnalysis.cpp index 322ae90..b3c1d5d 100755 --- a/src/ColorSingleAnalysis.cpp +++ b/src/ColorSingleAnalysis.cpp @@ -1,8 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "ColorSingleAnalysis.h" #include "ofMain.h" @@ -32,6 +27,11 @@ void ColorSingleAnalysis::setup(int camWidth, int camHeight) _fade_cnt=0; fileNameTag = ""; + + + int anim_time = 10; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } @@ -52,7 +52,8 @@ void ColorSingleAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); @@ -125,7 +126,8 @@ void ColorSingleAnalysis::draw() } } else { - _RUN_DONE = true; + _state = STATE_SYNTHESISING; + //_RUN_DONE = true; } _frame_cnt++; @@ -136,12 +138,89 @@ void ColorSingleAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; break; } diff --git a/src/ColorSingleAnalysis.h b/src/ColorSingleAnalysis.h index 0772c43..4d29533 100755 --- a/src/ColorSingleAnalysis.h +++ b/src/ColorSingleAnalysis.h @@ -28,6 +28,8 @@ protected: bool _RUN_DONE; string fileNameTag; - int _run_cnt, _save_cnt, _fade_cnt; - float r,g,b, _frame_cnt, _frame_cnt_max; + float r,g,b; + + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/DiffNoiseAnalysis.cpp b/src/DiffNoiseAnalysis.cpp index 873678c..c76b84f 100755 --- a/src/DiffNoiseAnalysis.cpp +++ b/src/DiffNoiseAnalysis.cpp @@ -1,8 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "DiffNoiseAnalysis.h" #include "ofMain.h" @@ -28,6 +23,10 @@ void DiffNoiseAnalysis::setup(int camWidth, int camHeight) _frame_cnt = 0; _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; + + int anim_time = 10; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } @@ -48,7 +47,8 @@ void DiffNoiseAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); @@ -133,7 +133,7 @@ void DiffNoiseAnalysis::draw() ofDisableAlphaBlending(); } else { - + _state = STATE_SYNTHESISING; _RUN_DONE = true; } @@ -146,12 +146,89 @@ void DiffNoiseAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; break; } diff --git a/src/DiffNoiseAnalysis.h b/src/DiffNoiseAnalysis.h index 93d57ae..a507e70 100755 --- a/src/DiffNoiseAnalysis.h +++ b/src/DiffNoiseAnalysis.h @@ -27,7 +27,7 @@ public: protected: bool _RUN_DONE; - int _run_cnt, _save_cnt, _fade_cnt; - float c, _frame_cnt, _frame_cnt_max; - + + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/IResponseAnalysis.cpp b/src/IResponseAnalysis.cpp index e251aa7..0625953 100755 --- a/src/IResponseAnalysis.cpp +++ b/src/IResponseAnalysis.cpp @@ -1,8 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "IResponseAnalysis.h" #include "ofMain.h" @@ -17,7 +12,7 @@ using Poco::Thread; void IResponseAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 100; + DELTA_T_SAVE = 50; //150 is about right NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -26,6 +21,10 @@ void IResponseAnalysis::setup(int camWidth, int camHeight) _frame_cnt = 0; _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; + + int anim_time = 5; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } @@ -46,7 +45,7 @@ void IResponseAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); @@ -80,7 +79,9 @@ void IResponseAnalysis::draw() ofRect(0, 0, ofGetWidth(), ofGetHeight()); c = 255.0 * (_frame_cnt_max*_frame_cnt_max - _frame_cnt*_frame_cnt)/(_frame_cnt_max*_frame_cnt_max); } else { - _RUN_DONE = true; + _state = STATE_SYNTHESISING; + //_RUN_DONE = true; + } _frame_cnt++; @@ -91,12 +92,89 @@ void IResponseAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; break; } diff --git a/src/IResponseAnalysis.h b/src/IResponseAnalysis.h index 07e2c95..08137a4 100755 --- a/src/IResponseAnalysis.h +++ b/src/IResponseAnalysis.h @@ -27,8 +27,7 @@ public: protected: bool _RUN_DONE; - int _run_cnt, _save_cnt; - float c, _frame_cnt, _frame_cnt_max; - + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/RelaxRateAnalysis.cpp b/src/RelaxRateAnalysis.cpp index 4f82029..6942e2e 100755 --- a/src/RelaxRateAnalysis.cpp +++ b/src/RelaxRateAnalysis.cpp @@ -1,8 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "RelaxRateAnalysis.h" #include "ofMain.h" @@ -18,7 +13,7 @@ using Poco::Thread; void RelaxRateAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 100; //300 is the correct number + DELTA_T_SAVE = 50; //300 is the correct number NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -30,6 +25,10 @@ void RelaxRateAnalysis::setup(int camWidth, int camHeight) _frame_cnt = 0; _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; + + int anim_time = 5; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } @@ -50,7 +49,7 @@ void RelaxRateAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); @@ -92,9 +91,10 @@ void RelaxRateAnalysis::draw() } } else { - cout << "RELAXRATE RUN COMPLETED" << endl; - //_state = STATE_SYNTHESISING; - _RUN_DONE = true; + + _state = STATE_SYNTHESISING; + + //_RUN_DONE = true; } _frame_cnt++; @@ -106,12 +106,97 @@ void RelaxRateAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = MIDDLE OF ANIMATION...\n"; + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + cout << "_anim_cnt = " << _anim_cnt << endl; + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADE OUT OF ANIMATION...\n"; + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + cout << "c_anim = " << c_anim << endl; + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; + cout << "RELAXRATE RUN COMPLETED" << endl; break; } diff --git a/src/RelaxRateAnalysis.h b/src/RelaxRateAnalysis.h index 0a38e5c..b804491 100755 --- a/src/RelaxRateAnalysis.h +++ b/src/RelaxRateAnalysis.h @@ -29,7 +29,6 @@ protected: bool _RUN_DONE; float _flip, _level; - int _run_cnt, _save_cnt; - float c, _frame_cnt, _frame_cnt_max; - + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/ShadowScapesAnalysis.cpp b/src/ShadowScapesAnalysis.cpp index caf53a6..f572604 100755 --- a/src/ShadowScapesAnalysis.cpp +++ b/src/ShadowScapesAnalysis.cpp @@ -1,35 +1,3 @@ -/* - - copyright (c) 2011 Copenhagen Institute of Interaction Design (CIID) - - all rights reserved. - - + redistribution and use in source and binary forms, with or without - + modification, are permitted provided that the following conditions - + are met: - + > redistributions of source code must retain the above copyright - + notice, this list of conditions and the following disclaimer. - + > redistributions in binary form must reproduce the above copyright - + notice, this list of conditions and the following disclaimer in - + the documentation and/or other materials provided with the - + distribution. - - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - + COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - + OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - + AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - + OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - + SUCH DAMAGE. - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "ShadowScapesAnalysis.h" #include "ofMain.h" @@ -47,20 +15,21 @@ using Poco::Thread; void ShadowScapesAnalysis::setup(int camWidth, int camHeight) { - - DELTA_T_SAVE = 100; + DELTA_T_SAVE = 50; NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; create_dir(); + + _speed = 100.0; // 900.0 is the correct number _scanLineWidth = 100.0; _run_cnt = 0; _save_cnt = 0; - int anim_time = 5; // 5 seconds - _anim_cnt_max = 5*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + int anim_time = 5; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames } void ShadowScapesAnalysis::acquire() @@ -197,68 +166,63 @@ void ShadowScapesAnalysis::draw() // display animation of something while the synthesis in on-going... ofEnableAlphaBlending(); ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); if(_anim_cnt < _anim_cnt_max){ ofColor aColour; int rectSizeW = ofGetWidth()/4; - int rectSizeH = ofGetWidth()/4; - int _fade_in_frames = _anim_cnt_max/10; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; int c_anim = 10; int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + if (_anim_cnt < _fade_in_frames) { cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; - + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); - cout << "fade up = " << fade << endl; - for (int i=0; i < ofGetHeight() ; i=i+rectSizeH) - { - for (int j=0; j < ofGetWidth(); j=j+rectSizeW) - { - c_anim = ofRandom(150,255); - - aColour.set(c_anim, c_anim, c_anim, fade); - ofSetColor(aColour); - ofRect(ofGetWidth()/2, ofGetHeight()/2, rectSizeW, rectSizeH); - } - } + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } } if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ - for (int i=0; i < ofGetHeight() ; i=i+rectSizeH) - { - for (int j=0; j < ofGetWidth(); j=j+rectSizeW) - { - c_anim = ofRandom(150,255); - - //c = ofRandom(0,255); - aColour.set(c_anim, c_anim, c_anim, 255); - ofSetColor(aColour); - ofRect(ofGetWidth()/2, ofGetHeight()/2, rectSizeW, rectSizeH); - - } - } + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } } - if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _frame_cnt <= _anim_cnt_max) { + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); cout << "fade down = " << fade << endl; - for (int i=0; i < ofGetHeight() ; i=i+rectSizeH) - { - for (int j=0; j < ofGetWidth(); j=j+rectSizeW) - { - c_anim = ofRandom(150,255); - //c = ofRandom(0,255); - - aColour.set(c_anim, c_anim, c_anim, 255-fade); - ofSetColor(aColour); - ofRect(ofGetWidth()/2, ofGetHeight()/2, rectSizeW, rectSizeH); - } + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); } } @@ -268,6 +232,7 @@ void ShadowScapesAnalysis::draw() _state = STATE_DISPLAY_RESULTS; _anim_cnt=0; } + ofPopMatrix(); ofSetRectMode(OF_RECTMODE_CORNER); ofDisableAlphaBlending(); break; diff --git a/src/ShapeFromShadingAnalysis.cpp b/src/ShapeFromShadingAnalysis.cpp index a23c199..04d1f23 100755 --- a/src/ShapeFromShadingAnalysis.cpp +++ b/src/ShapeFromShadingAnalysis.cpp @@ -1,8 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "ShapeFromShadingAnalysis.h" #include "ofMain.h" @@ -18,7 +13,7 @@ using Poco::Thread; void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) { - DELTA_T_SAVE = 300; //300 is about the right number + DELTA_T_SAVE = 50; //300 is about the right number NUM_PHASE = 1; NUM_RUN = 1; NUM_SAVE_PER_RUN = 100; @@ -31,9 +26,14 @@ void ShapeFromShadingAnalysis::setup(int camWidth, int camHeight) _frame_cnt_max = ofGetFrameRate() * ((DELTA_T_SAVE * NUM_SAVE_PER_RUN) / 1000); c = 0; + + int anim_time = 10; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } + void ShapeFromShadingAnalysis::acquire() { @@ -51,7 +51,8 @@ void ShapeFromShadingAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; + _animation_cnt1 = 0; _animation_cnt2 = 0; _animation_cnt3 = 0; @@ -307,8 +308,8 @@ void ShapeFromShadingAnalysis::draw() ofDisableAlphaBlending(); } else { - - _RUN_DONE = true; + _state = STATE_SYNTHESISING; + //_RUN_DONE = true; } _frame_cnt++; @@ -320,12 +321,89 @@ void ShapeFromShadingAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; break; } diff --git a/src/ShapeFromShadingAnalysis.h b/src/ShapeFromShadingAnalysis.h index e1c4b0c..3fbf877 100755 --- a/src/ShapeFromShadingAnalysis.h +++ b/src/ShapeFromShadingAnalysis.h @@ -30,7 +30,6 @@ protected: string quad; bool _RUN_DONE; float _flip, _level; - int _run_cnt, _save_cnt; int _animation_cnt1; int _animation_cnt2; int _animation_cnt3; @@ -48,6 +47,7 @@ protected: int _animation_cnt15; int _animation_cnt16; int _animation_reset; // this reset part didn't get working - so using 16 different counters! yay! - float c, _frame_cnt, _frame_cnt_max; - + + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; }; diff --git a/src/StrobeAnalysis.cpp b/src/StrobeAnalysis.cpp index 960df87..ebb76e7 100755 --- a/src/StrobeAnalysis.cpp +++ b/src/StrobeAnalysis.cpp @@ -1,8 +1,3 @@ -/* - ~ author: dviid - ~ contact: dviid@labs.ciid.dk - */ - #include "StrobeAnalysis.h" #include "ofMain.h" @@ -27,10 +22,12 @@ void StrobeAnalysis::setup(int camWidth, int camHeight) // The British Health and Safety Executive recommend that a net flash rate for a bank of strobe lights does not exceed 5 flashes per second, at which only 5% of photosensitive epileptics are at risk. It also recommends that no strobing effect continue for more than 30 seconds, due to the potential for discomfort and disorientation. - //or 20 times, every one second... - _save_cnt_max = _strobe_cnt_max*_strobe_interval/DELTA_T_SAVE; - create_dir(); + + + int anim_time = 10; // 10 seconds + _anim_cnt_max = anim_time*ofGetFrameRate(); // e.g.: 30 frames per second = 150 frames + } @@ -53,7 +50,8 @@ void StrobeAnalysis::acquire() save_timer = new Timer(0, DELTA_T_SAVE); // timing interval for saving files save_timer->start(save_callback); _RUN_DONE = false; - _frame_cnt = 0; _save_cnt = 0; + + _frame_cnt = 0; _save_cnt = 0; _anim_cnt = 0; while(!_RUN_DONE) Thread::sleep(3); @@ -98,13 +96,13 @@ void StrobeAnalysis::draw() //cout << "frame_cnt % 15: " << _frame_cnt%15 << endl; //cout << "MAIN STROBE TIME " << endl; - if (_frame_cnt%int(ofGetFrameRate()*_strobe_interval/1000) < (ofGetFrameRate()*_strobe_interval/1000)/2) + if (int(_frame_cnt)%int(ofGetFrameRate()*_strobe_interval/1000) < (ofGetFrameRate()*_strobe_interval/1000)/2) { ofSetColor(255, 255, 255); ofRect(0, 0, ofGetWidth(), ofGetHeight()); _strobe_cnt++; _strobe_on = 1; - } else if (_frame_cnt%int(ofGetFrameRate()*_strobe_interval/1000) >= (ofGetFrameRate()*_strobe_interval/1000)/2) + } else if (int(_frame_cnt)%int(ofGetFrameRate()*_strobe_interval/1000) >= (ofGetFrameRate()*_strobe_interval/1000)/2) { ofSetColor(0, 0, 0); ofRect(0, 0, ofGetWidth(), ofGetHeight()); @@ -122,7 +120,8 @@ void StrobeAnalysis::draw() ofDisableAlphaBlending(); } else { - _RUN_DONE = true; + _state = STATE_SYNTHESISING; + //_RUN_DONE = true; } _frame_cnt++; @@ -133,12 +132,89 @@ void StrobeAnalysis::draw() case STATE_SYNTHESISING: { // display animation of something while the synthesis in on-going... + + cout << "RelaxRateAnalysis = STATE_SYNTHESISING...\n"; + + // display animation of something while the synthesis in on-going... + ofEnableAlphaBlending(); + ofSetRectMode(OF_RECTMODE_CENTER); + ofPushMatrix(); + ofTranslate(ofGetWidth()/2, ofGetHeight()/2); + + if(_anim_cnt < _anim_cnt_max){ + + ofColor aColour; + int rectSizeW = ofGetWidth()/4; + int rectSizeH = ofGetHeight()/4; + int _fade_in_frames = _anim_cnt_max/2; + + int c_anim = 10; + int fade; + + //ofRotate(ofMap(_anim_cnt/2.0, 0, _anim_cnt_max, 0, 360)); + + if (_anim_cnt < _fade_in_frames) { + cout << "ShadowScapesAnalysis STATE_SYNTHESIZING = FADING IN ANIMATION...\n"; + + fade = ofMap(_anim_cnt, 0, _fade_in_frames, 0, 255); + + for (int i=0; i <= 15; i++){ + c_anim = 0+17*i; + + aColour.set(c_anim, c_anim, c_anim, fade); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt >= _fade_in_frames && _anim_cnt <= (_anim_cnt_max-_fade_in_frames)){ + + for (int i=0; i <= 15; i++){ + c_anim = 255; + aColour.set(c_anim, c_anim, c_anim, 255); + ofSetColor(aColour); + + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + } + + if (_anim_cnt > (_anim_cnt_max-_fade_in_frames) && _anim_cnt <= _anim_cnt_max) { + + cout << "_anim_cnt = " << _anim_cnt-(_anim_cnt_max-_fade_in_frames) << endl; + fade = ofMap(_anim_cnt-(_anim_cnt_max-_fade_in_frames), 0, _fade_in_frames, 0, 255); + cout << "fade down = " << fade << endl; + + for (int i=0; i <= 15; i++){ + + c_anim = (17*i); + + aColour.set(c_anim, c_anim, c_anim, 255-fade); + ofSetColor(aColour); + ofRect(0, 0, rectSizeW+10*i, rectSizeH+10*i); + ofRect(0, 0, rectSizeW-10*i, rectSizeH-10*i); + } + + } + _anim_cnt++; + + } else { + _state = STATE_DISPLAY_RESULTS; + _anim_cnt=0; + } + ofPopMatrix(); + ofSetRectMode(OF_RECTMODE_CORNER); + ofDisableAlphaBlending(); + break; } case STATE_DISPLAY_RESULTS: { // display results of the synthesis + _RUN_DONE = true; break; } diff --git a/src/StrobeAnalysis.h b/src/StrobeAnalysis.h index ca1cf93..88830e8 100755 --- a/src/StrobeAnalysis.h +++ b/src/StrobeAnalysis.h @@ -28,10 +28,11 @@ public: protected: bool _RUN_DONE; - int _strobe_cnt, _run_cnt, _strobe_cnt_max; - int _save_cnt; + int _strobe_cnt, _strobe_cnt_max; - int _frame_cnt, _frame_cnt_max, _save_cnt_max ; int _strobe_interval; bool _strobe_on; + + int _run_cnt, _save_cnt, _fade_cnt, _anim_cnt; + float c, _frame_cnt, _frame_cnt_max, _anim_cnt_max; };