Mercurial > hg > tweakathon2ios
changeset 31:a677c027e3a0
Demo to Simon, kinda works.
4 reps of sequence.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Fri, 21 Nov 2014 17:07:56 +0000 |
parents | 78b51f924ec1 |
children | 75202498bee9 |
files | ExplorePresetManager.mm MessageOrganiser.mm PDSynthWrapper.h SequenceController.h SequenceController.mm TrainingMessageOrganiser.h TrainingMessageOrganiser.mm TrainingScoreManager.h UI code/3DboxGL.mm UI code/6Dbox.h UI code/6Dbox.mm UI code/ButtronSlider.h UI code/ButtronSlider.mm UI code/sliderPanel.h UI code/sliderPanel.mm globalVariables.cpp globalVariables.h presetManager.h presetManager.mm |
diffstat | 19 files changed, 562 insertions(+), 152 deletions(-) [+] |
line wrap: on
line diff
--- a/ExplorePresetManager.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/ExplorePresetManager.mm Fri Nov 21 17:07:56 2014 +0000 @@ -17,6 +17,8 @@ initPresetSlots(); + makeNeutralPreset(); + } //----------------------------------------------------------------------------
--- a/MessageOrganiser.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/MessageOrganiser.mm Fri Nov 21 17:07:56 2014 +0000 @@ -174,6 +174,8 @@ typeListLog.push_back(int(SLIDER)); }else{ + + // TODO 6D box cout << "ERROR ERROR: ui type not handled my mapping function !" << endl; } }
--- a/PDSynthWrapper.h Tue Nov 04 14:37:35 2014 +0000 +++ b/PDSynthWrapper.h Fri Nov 21 17:07:56 2014 +0000 @@ -248,6 +248,20 @@ } + void setAllParamsWithoutSend(vector<int> params){ + if(params.size() != timbreParams.size()){ + cout << "Error not right number of params in set in synth" << endl; + return; + } + std::vector<SynthParam>::iterator psp; + int i=0; + for(psp = timbreParams.begin(); psp < timbreParams.end(); psp++){ + psp->setValueWithoutSend(params[i]); + i++; + } + + + } // METRONOME STUFF void registerForTicks(TickListenerFunction callback){
--- a/SequenceController.h Tue Nov 04 14:37:35 2014 +0000 +++ b/SequenceController.h Fri Nov 21 17:07:56 2014 +0000 @@ -11,15 +11,16 @@ #include <iostream> #include "ofMain.h" - -#define MIN_TARGETS_IN_SEQUENCE 1 +#include "presetManager.h" +#include "TrainingScoreManager.h" +#define MIN_TARGETS_IN_SEQUENCE 2 #define MAX_TARGETS_IN_SEQUENCE 5 #define MIN_TEMPO 60 #define MAX_TEMPO 300 #define NUM_TEMPO_STEPS 12 #define NUM_PRESETS 8 -#define SPACER_BARS true -#define NO_GUIDES_LEVEL true +#define SPACER_BARS false +#define NO_GUIDES_LEVEL false class AnimStep{ @@ -30,6 +31,8 @@ MATCHING_NEUTRAL_COUNT, PREVIEW_MOVE, PREVIEW_HIT, + GUIDED_MOVE, + GUIDED_HIT, MATCHING_MOVE, MATCHING_HIT} stepType; @@ -40,6 +43,8 @@ return 1000* (60.0/tempo); } int presetIndex; + Preset * currentTargetPreset; + Preset * nextTargetPreset; int whichInSequence; bool isLastOfAll; @@ -50,10 +55,18 @@ bool isLastOfRun; bool showsGuides; // depends on 'level' + bool showsIcons; + bool showsResultsAtEnd; vector<int> thisSequence; // so that we can show the whole sequence at the top? + + TrainingTestResult result; // only applies to steps that were scored. + + + void saveResult(TrainingTestResult result); }; +// NOT USED class Step{ public: typedef enum {COUNT_IN, PREVIEW_PREPARER, PREVIEW_DISPLAYER, MATCHING_PREPARER, MATCHING_INTERACTION, MATCHING_RESULT} stepTypes; @@ -92,10 +105,12 @@ void setAsMatchingPreparer(); void setAsMatchingInteraction(); void setAsMatchingFeedback(); + float getTimeBetweenTicks(){ return 1000. * (60.0/tempo); } + }; class SequenceController{ @@ -105,6 +120,8 @@ void setToStart(); void stepForward(); float getStartTickTime(); + void saveResultForCurrentStep(TrainingTestResult result); + TrainingTestResult getResultForPreviousStep(); private: void generateSteps(); void generateCountIn(int countInLength);
--- a/SequenceController.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/SequenceController.mm Fri Nov 21 17:07:56 2014 +0000 @@ -21,7 +21,14 @@ isLastOfAll = false; showsGuides = false; + showsIcons = true; + showsResultsAtEnd = false; } + +void AnimStep::saveResult(TrainingTestResult aresult){ + result = aresult; +} + Step::Step(){ type = COUNT_IN; @@ -185,7 +192,7 @@ for(int numInSequence = MIN_TARGETS_IN_SEQUENCE; numInSequence <= MAX_TARGETS_IN_SEQUENCE; numInSequence++){ - generateCountIn(2); + generateCountIn(1); generateARun(run, numInSequence); steps.back().isLastOfRun = true; @@ -241,6 +248,7 @@ nextStep.tempo = curTempo; nextStep.showsGuides = true; nextStep.type = AnimStep::PREVIEW_NEUTRAL_COUNT; + nextStep.showsResultsAtEnd = false; steps.push_back(nextStep); // generate a sequence of random preset indices @@ -248,7 +256,7 @@ nextStep.thisSequence = stepPresetIndices; // make preview sequence - int n = 1; + int n = 0; for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){ // put loader @@ -258,6 +266,8 @@ nextStep.whichInSequence = n; nextStep.tempo = curTempo; nextStep.showsGuides = true; + nextStep.showsIcons = true; + nextStep.showsResultsAtEnd = false; nextStep.type = AnimStep::PREVIEW_MOVE; steps.push_back(nextStep); @@ -268,22 +278,52 @@ n++; } - nextStep.type = AnimStep::MATCHING_NEUTRAL_COUNT; + // move back to neutral + nextStep.presetIndex = -1; + nextStep.type = AnimStep::PREVIEW_MOVE; + nextStep.showsResultsAtEnd = false; steps.push_back(nextStep); - // put in matching sequence + // make GUIDED sequence + n = 0; + for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){ + // put loader + + nextStep.presetIndex = *si; + nextStep.runNumber = run; + nextStep.seqNumber = seqNo; + nextStep.whichInSequence = n; + nextStep.tempo = curTempo; + nextStep.showsGuides = true; + nextStep.showsIcons = true; + nextStep.showsResultsAtEnd = true; + nextStep.type = AnimStep::GUIDED_MOVE; + steps.push_back(nextStep); + + if (SPACER_BARS){ + nextStep.type = AnimStep::GUIDED_HIT; + steps.push_back(nextStep); + } + n++; + } + // move back to neutral + nextStep.presetIndex = -1; + nextStep.type = AnimStep::GUIDED_MOVE; + nextStep.showsResultsAtEnd = false; + steps.push_back(nextStep); + + // make matching sequence with icon seq help n = 0; for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){ // put loader nextStep.presetIndex = *si; nextStep.whichInSequence = n; - if (NO_GUIDES_LEVEL){ - nextStep.showsGuides = false; - }else{ - nextStep.showsGuides = true; - } + + nextStep.showsGuides = false; + nextStep.showsIcons = true; nextStep.type = AnimStep::MATCHING_MOVE; + nextStep.showsResultsAtEnd = true; steps.push_back(nextStep); if (SPACER_BARS){ @@ -295,6 +335,40 @@ } + // move back to neutral + nextStep.presetIndex = -1; + nextStep.type = AnimStep::GUIDED_MOVE; + nextStep.showsResultsAtEnd = false; + steps.push_back(nextStep); + + // make matching sequence WITHOUT icon seq help + n = 0; + for(auto si = stepPresetIndices.begin(); si < stepPresetIndices.end(); si++){ + // put loader + + nextStep.presetIndex = *si; + nextStep.whichInSequence = n; + + nextStep.showsGuides = false; + + nextStep.type = AnimStep::MATCHING_MOVE; + nextStep.showsResultsAtEnd = true; + nextStep.showsIcons = false; + steps.push_back(nextStep); + + if (SPACER_BARS){ + nextStep.type = AnimStep::MATCHING_HIT; + steps.push_back(nextStep); + + } + n++; + + } + + nextStep.type = AnimStep::MATCHING_HIT; + nextStep.showsResultsAtEnd = false; + steps.push_back(nextStep); + steps.back().isLastOfSeq = true; curTempo += tempoInc; seqNo++; @@ -307,6 +381,22 @@ } //----------------------------------------------------------------------- +void SequenceController::saveResultForCurrentStep(TrainingTestResult result){ + (*currentStep).saveResult(result); + +} +//----------------------------------------------------------------------- +TrainingTestResult SequenceController::getResultForPreviousStep(){ + if (currentStep == steps.begin()){ + + cout << "ERROR - " << endl; + + } + return (*currentStep--).result; + + +} +//----------------------------------------------------------------------- int SequenceController::getRandomButNot(int max, vector<int> notThese){
--- a/TrainingMessageOrganiser.h Tue Nov 04 14:37:35 2014 +0000 +++ b/TrainingMessageOrganiser.h Fri Nov 21 17:07:56 2014 +0000 @@ -50,7 +50,10 @@ void showCountdown(); void hideSliders(); void showsTarget(); - + TrainingTestResult doResults(AnimStep newStep, + Preset * currentTargetPreset, + vector<int> startingPosition, + vector<int> currentPosition ); void previewNeutralCount(AnimStep newStep); void previewMove(AnimStep newStep); @@ -58,11 +61,16 @@ void matchingNeutralCount(AnimStep newStep); void matchingMove(AnimStep newStep); void matchingHit(AnimStep newStep); - + void guidedMove(AnimStep newStep); + void guidedHit(AnimStep newStep); + + void flashResult(TrainingTestResult r); ofColor interactableColor; ofColor nonInteractableColor; int downCounter; + + vector<int> oldTargetValues; //----------------------------------------------------------------------------- TextPanel* middlePanel; SequenceController sequenceController;
--- a/TrainingMessageOrganiser.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/TrainingMessageOrganiser.mm Fri Nov 21 17:07:56 2014 +0000 @@ -24,7 +24,7 @@ setupDefaultMapping(whichInterfaceAreWeUsing); - + controlPanel->setValues(zeros<int>(TOTAL_NUM_PARAMS)); } //---------------------------------------------------------------------------------------- void TrainingMessageOrganiser::setMiddlePanel(TextPanel* tp){ @@ -138,15 +138,44 @@ } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::onNextTickAnim(int tickNumber){ + static AnimStep oldStep; + static vector<int> lastPosition; cout << "TICK " << tickNumber << endl; downCounter = 4 - tickNumber % 4; updateCountdown(downCounter); // only first beat in bar is active one (at the moment) - if ( tickNumber % 4 != 0) return; + // TODO send next target values again and again + if ( tickNumber % 4 != 0) { + if (tickNumber % 4 == 3){ + targetSynth.sendAllParams(); + } + return; + }; + Preset* previousTargetPreset; + vector<int> curCandidateSettings = candidateSynth.getAllParamValues(); + if (oldStep.showsResultsAtEnd){ + + // store results + if(oldStep.presetIndex == -1){ + previousTargetPreset = expPresetManager.getNeutralPreset(); + cout << "SHOULDNT SCORE NEUTRAL??" << endl; + }else{ + + previousTargetPreset = expPresetManager.getPresetAtIndex(oldStep.presetIndex); + } + previousTargetPreset = expPresetManager.getPresetAtIndex(oldStep.presetIndex); + TrainingTestResult result = doResults(oldStep, + previousTargetPreset, + lastPosition, + curCandidateSettings); + + flashResult(result); + } + AnimStep newStep = sequenceController.getNextStep(); if(newStep.isLastOfAll){ @@ -179,8 +208,20 @@ case AnimStep::MATCHING_HIT : matchingHit( newStep); break; + case AnimStep::GUIDED_MOVE : + guidedMove( newStep); + break; + + case AnimStep::GUIDED_HIT : + guidedHit( newStep); + break; + default: + break; } + oldStep = newStep; + lastPosition = curCandidateSettings; + } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::updateCountdown(int n){ @@ -189,12 +230,11 @@ //----------------------------------------------------------------------------- void TrainingMessageOrganiser::previewNeutralCount(AnimStep newStep){ + middlePanel->hide(); Preset * currentTargetPreset; - - // show eveything at start? - showMyPanels(); + // your 'hand' is hidden controlPanel->showValueIndicators(false); @@ -204,35 +244,52 @@ vector<int> newTargetValues = currentTargetPreset->getValues(); presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false); presetIconPanel->show(); - + controlPanel->setValues(newTargetValues); controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage()); - + controlPanel->setActive(false); targetSynth.setAllParams(newTargetValues); candidateSynth.setAllParams(newTargetValues); displayInstructions("preview Neutral Count"); + + oldTargetValues = newTargetValues; } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::previewMove(AnimStep newStep){ + controlPanel->setValues(oldTargetValues); + targetSynth.trigger(); // PLAYS LAST TARGET (but it doesn't?) Preset * currentTargetPreset; - currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); + if(newStep.presetIndex == -1){ + currentTargetPreset = expPresetManager.getNeutralPreset(); + }else{ + + currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); + } vector<int> newTargetValues = currentTargetPreset->getValues(); - targetSynth.setAllParams(newTargetValues); + targetSynth.setAllParamsWithoutSend(newTargetValues); + // show icon and guides presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false); - presetIconPanel->show(); + if (newStep.showsIcons){ + presetIconPanel->show(); + }else{ + presetIconPanel->hide(); + } controlPanel->show(); - // your hand is hidden - controlPanel->showValueIndicators(false); - // guide animates to next target - - //controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage()); - controlPanel->animateToNewHintValues(newTargetValues, newStep.getTimeBetweenTicks()*4, currentTargetPreset->getImage()); + + controlPanel->showValueIndicators(true); + controlPanel->setActive(false); + + // show where we're going + controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage()); + + // show how to get there + controlPanel->animateToNewValues(newTargetValues, newStep.getTimeBetweenTicks()*4); displayInstructions("preview Move"); - targetSynth.trigger(); + oldTargetValues = newTargetValues; } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::previewHit(AnimStep newStep){ @@ -255,6 +312,66 @@ displayInstructions("Preview HIT"); } + +//----------------------------------------------------------------------------- +void TrainingMessageOrganiser::guidedMove(AnimStep newStep){ + targetSynth.trigger(); // PLAYS LAST TARGET (?) + + middlePanel->hide(); + + Preset * currentTargetPreset; + if(newStep.presetIndex == -1){ + currentTargetPreset = expPresetManager.getNeutralPreset(); + }else{ + + currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); + } + + vector<int> newTargetValues = currentTargetPreset->getValues(); + + targetSynth.setAllParamsWithoutSend(newTargetValues); + + + controlPanel->setActive(true); + // show icon and guide markers + presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false); + presetIconPanel->show(); + + controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage()); + + + // show your hand and allow movement + controlPanel->showValueIndicators(true); + okToGetMidi = true; + + displayInstructions("GUIDED MOVE"); + + oldTargetValues = newTargetValues; +} + +//====================================================================== +void TrainingMessageOrganiser::guidedHit(AnimStep newStep){ + Preset * currentTargetPreset; + currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); + vector<int> newTargetValues = currentTargetPreset->getValues(); + + sendSynthValuesAgain(); + + // show your hand and allow movement (so you can set off to next target??) + + controlPanel->showValueIndicators(true); + okToGetMidi = true; + + targetSynth.setAllParamsWithoutSend(newTargetValues); + triggerCandidateSound(); + + displayInstructions("GUIDED HIT"); + vector<int> startPosition = expPresetManager.getNeutralPreset()->getValues(); + + oldTargetValues = newTargetValues; +} +//----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- void TrainingMessageOrganiser::matchingNeutralCount(AnimStep newStep){ Preset * currentTargetPreset = expPresetManager.getNeutralPreset(); @@ -272,38 +389,53 @@ okToGetMidi = true; displayInstructions("Match Count"); + + oldTargetValues = newTargetValues; } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::matchingMove(AnimStep newStep){ + + middlePanel->hide(); Preset * currentTargetPreset; - currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); + if(newStep.presetIndex == -1){ + currentTargetPreset = expPresetManager.getNeutralPreset(); + }else{ + + currentTargetPreset = expPresetManager.getPresetAtIndex(newStep.presetIndex); + } + vector<int> newTargetValues = currentTargetPreset->getValues(); targetSynth.setAllParams(newTargetValues); + + // if showing guides show the hint hand - controlPanel->setHintColor(ofColor::white); - - // if showing guides show all the targets as transparent ghosts if (newStep.showsGuides){ + controlPanel->setHintNoShow(newTargetValues, currentTargetPreset->getImage()); + controlPanel->showHint(true); + }else{ + // + controlPanel->showHint(false); + } + if (newStep.showsIcons){ presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false); presetIconPanel->show(); - - controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage()); }else{ presetIconPanel->hide(); - controlPanel->showHint(false); } - // show your hand and allow movement //controlPanel->showIndicator(true); okToGetMidi = true; displayInstructions("Match MOVE"); + // trigger where we're at at the moment triggerCandidateSound(); + oldTargetValues = newTargetValues; + } //----------------------------------------------------------------------------- void TrainingMessageOrganiser::matchingHit(AnimStep newStep){ @@ -320,29 +452,37 @@ targetSynth.setAllParams(newTargetValues); triggerCandidateSound(); - displayInstructions("Match HIT"); + displayInstructions("Match FINISHED"); vector<int> startPosition = expPresetManager.getNeutralPreset()->getValues(); - + controlPanel->setHintNoShow(newTargetValues, currentTargetPreset->getImage()); + + oldTargetValues = newTargetValues; +} +//----------------------------------------------------------------------------- + +TrainingTestResult TrainingMessageOrganiser::doResults(AnimStep newStep, + Preset * targetPreset, + vector<int> startingPosition, + vector<int> currentPosition){ TrainingTestResult result = - trainingScoreManager.getScoreForAnswer(candidateSynth.getAllParamValues(), - startPosition, - newTargetValues, + trainingScoreManager.getScoreForAnswer(currentPosition, + startingPosition, + targetPreset->getValues(), newStep.getTimeBetweenTicks()); + sequenceController.saveResultForCurrentStep(result); + instructionPanel->setColor(result.colorBand); + + + displayInstructions(result.displayText); - //middlePanel->setLabel(result.displayText); - instructionPanel->setColor(result.colorBand); - //middlePanel->setText(result.displayText); - - // show where you should have been - controlPanel->setHintColor(result.colorBand); - presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), false); - presetIconPanel->show(); - controlPanel->setAndShowHint(newTargetValues, currentTargetPreset->getImage()); - - controlPanel->flashResultLight(result.colorBand, newStep.getTimeBetweenTicks()); - middlePanel->show(); - displayInstructions(result.displayText); + return result; } -//----------------------------------------------------------------------------- \ No newline at end of file +void TrainingMessageOrganiser::flashResult(TrainingTestResult r){ + + // stick a colored number over target position + controlPanel->flashResultLight(r.colorBand, 30); + + +}
--- a/TrainingScoreManager.h Tue Nov 04 14:37:35 2014 +0000 +++ b/TrainingScoreManager.h Fri Nov 21 17:07:56 2014 +0000 @@ -11,7 +11,7 @@ #include <iostream> #include "ofMain.h" -#include "SequenceController.h" +//#include "SequenceController.h" #include "algorithms.h" #include "globalVariables.h" //-------------------------------------------------------------
--- a/UI code/3DboxGL.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/UI code/3DboxGL.mm Fri Nov 21 17:07:56 2014 +0000 @@ -20,8 +20,8 @@ { indicatorColor = ofColor(123, 123, 220); // how much to rotate the box - angleX = -25; - angleY = -24; + angleX = -25; // elevation + angleY = -14; // yaw depth = width; // its a cube
--- a/UI code/6Dbox.h Tue Nov 04 14:37:35 2014 +0000 +++ b/UI code/6Dbox.h Fri Nov 21 17:07:56 2014 +0000 @@ -95,8 +95,10 @@ void setHintValue(int which, int val); void setHintTexture(ofImage* img); void update(); - void animateHintToNewValues(vector<int> targetValues, float timeToTake, ofImage* newTexture); + void animateHintToNewValues(vector<int> targetValues, float timeToTake, ofImage* newTexture = NULL); + void animateToNewValues(vector<int> targetValues, float timeToTake, ofImage* newTexture = NULL); void animateHintToNewValues(Node targetValues, float timeToTake); + void animateToNewValues(Node targetValues, float timeToTake); void setHintValues(vector<int> vals); void setValues(vector<int> vals); @@ -104,7 +106,7 @@ void showValueIndicator(bool showing){ indicatorShowing = showing; }; - + void flashScore(int score, ofColor col); private: @@ -117,10 +119,12 @@ float rollVal, pitchVal, yawVal; ofMatrix4x4 getRotationQuat(float roll, float pitch, float yaw); - ofVec3f curPos; - ofVec3f curRot; + ofVec3f curPos, curHintPos; + ofVec3f curRot, curHintRot; ofVec3f posAnimIncr; ofVec3f rotAnimIncr; + ofVec3f hintposAnimIncr; + ofVec3f hintrotAnimIncr; ofMesh handMesh; ofImage* defaultHandTextureRef; @@ -134,7 +138,9 @@ float minAngVal, maxAngVal; bool indicatorShowing; - bool animating; + bool animatingHint; + bool animatingIndicator; + int showScoreForFrames; };
--- a/UI code/6Dbox.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/UI code/6Dbox.mm Fri Nov 21 17:07:56 2014 +0000 @@ -15,19 +15,19 @@ Leap6DBox::Leap6DBox(float ax, - float ay, - float awidth, - float aheight, - float azx, - float azy, - const UIProps& props) : - Leap3DBoxGL(ax,ay,awidth, aheight, azx, azy, props) + float ay, + float awidth, + float aheight, + float azx, + float azy, + const UIProps& props) : +Leap3DBoxGL(ax,ay,awidth, aheight, azx, azy, props) { - + rollVal = 0.0; pitchVal = 0.0; yawVal = 0.0; - + // set up hand mesh // width 0.5 // length 1 @@ -40,7 +40,7 @@ string fname = ofFilePath::getAbsolutePath(ofToDataPath("buttron.jpeg")); defaultImage.loadImage(fname); - fname = ofFilePath::getAbsolutePath(ofToDataPath("bakedbeans.jpeg")); + fname = ofFilePath::getAbsolutePath(ofToDataPath("white.jpeg")); hintImage.loadImage(fname); setTexture(&defaultImage); @@ -50,11 +50,11 @@ showHint(true); myType = LEAP6D; - + showScoreForFrames = 0; } void Leap6DBox::setHintValues(vector<int> vals){ - animating = false; + animatingHint = false; if (vals.size() != 6){ cout << "ERROR: need 6 vals for 6dof box set hint" << endl; @@ -65,6 +65,7 @@ } } void Leap6DBox::setValues(vector<int> vals){ + animatingIndicator = false; if (vals.size() != 6){ cout << "ERROR: need 6 vals for 6dof box set hint" << endl; } @@ -110,12 +111,12 @@ handMesh.addTexCoord(texCoordLB); handMesh.addVertex(RB); handMesh.addTexCoord(texCoordRB); - + handMesh.addVertex(LT); handMesh.addTexCoord(texCoordLT); - + handMesh.addVertex(RB); handMesh.addTexCoord(texCoordRB); handMesh.addVertex(RT); @@ -130,10 +131,10 @@ ofPoint rbf = ofPoint(hw, -hh, hl); ofPoint lbf = ofPoint(-hw, -hh, hl); ofPoint ltf = ofPoint(-hw, hh, hl); - + int imageWidth = 259; int imageHeight = 254; - + // back makeTexFace(ltr, rtr, rbr, lbr); @@ -153,13 +154,13 @@ makeTexFace(lbf, rbf, rbr, lbr); setUpThumb(ltf, lbf); - + handMesh.setupIndicesAuto(); setNormals(handMesh); } void Leap6DBox::setUpThumb(ofPoint baseTR, ofPoint baseBR){ // 3 triangles - + ofPoint baseTL = baseTR; ofPoint baseBL = baseBR; baseTL.z -= 0.9*hl; @@ -181,17 +182,17 @@ handMesh.addTexCoord(texCoordRB); handMesh.addVertex(baseBR); handMesh.addTexCoord(texCoordLB); - + // top - + handMesh.addVertex(baseTL); handMesh.addTexCoord(texCoordLB); handMesh.addVertex(tip); handMesh.addTexCoord(texCoordRB); handMesh.addVertex(baseTR); handMesh.addTexCoord(texCoordLT); - + // back handMesh.addVertex(baseTL); handMesh.addTexCoord(texCoordLT); @@ -199,8 +200,8 @@ handMesh.addTexCoord(texCoordLB); handMesh.addVertex(tip); handMesh.addTexCoord(texCoordRB); - - + + // left handMesh.addVertex(baseBL); handMesh.addTexCoord(texCoordLT); @@ -208,10 +209,10 @@ handMesh.addTexCoord(texCoordLB); handMesh.addVertex(tip); handMesh.addTexCoord(texCoordRB); - - - + + + } @@ -250,7 +251,7 @@ ofTranslate( x+width/2, y+height/2, camTrans); ofRotate( angleX, 1, 0, 0 ); ofRotate( angleY, 0, 1, 0 ); - + ofScale(0.7,0.7,0.7); ofSetColor(foregroundHi); boxMesh.draw(); @@ -261,27 +262,29 @@ ofDisableDepthTest(); - drawLabels(); + //drawLabels(); }; void Leap6DBox::drawIndicator(){ - if (hintShowing && (hintZ > zVal)){ - hintColor = calculateHintColor(); + if (hintShowing){ + draw3DCrossHairs(hintX, hintY, hintZ,hintColor, true); } + if (showScoreForFrames > 0){ + + //draw3DCrossHairs(hintX, hintY, hintZ,hintColor, true); + showScoreForFrames--; + }else{ + hintColor = foregroundHi; + } // draw indicator if(indicatorShowing){ draw3DCrossHairs(xVal,yVal,zVal, indicatorColor); } - - if (hintShowing && hintZ <= zVal){ - hintColor = calculateHintColor(); - draw3DCrossHairs(hintX, hintY, hintZ,hintColor, true); - - } + } void Leap6DBox::draw3DCrossHairs(float x , float y, float z, ofColor c, bool isHint){ @@ -304,27 +307,24 @@ drawIndicatorBlob(ix,iy,iz,c, isHint); // line to front (a bit wierde?) ofLine(ix,iy,iz,ix,iy,front); - + + + } void Leap6DBox::drawIndicatorBlob(float x, float y, float z, ofColor c, bool isHint){ ofImage * atexImg; - if(isHint){ - atexImg = hintImageRef; + if (isHint){ + draw6DOFIndicatorBlob(x, y, z, c, hintRoll, hintPitch, hintYaw, hintImageRef); + }else{ - atexImg = defaultHandTextureRef; - } - - if (isHint){ - draw6DOFIndicatorBlob(x, y, z, c, hintRoll, hintPitch, hintYaw, atexImg); - }else{ - draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal, atexImg); - + draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal, defaultHandTextureRef); + } } void Leap6DBox::draw6DOFIndicatorBlob(float x, float y, float z, ofColor c, float r, float p, float yaw, ofImage* atexImg){ - + static ofMatrix4x4 m; @@ -340,8 +340,11 @@ ofSetColor(255,255,255); // render + if (showScoreForFrames == 0){ (*atexImg).bind(); - + }else{ + ofSetColor(hintColor); + } handMesh.draw(); (*atexImg).unbind(); @@ -357,45 +360,92 @@ return rot; } void Leap6DBox::animateHintToNewValues(vector<int> targetValues, float timeToTake , ofImage* newTexture){ - + Node targ; targ.setFromCC(targetValues); animateHintToNewValues(targ, timeToTake); } - + +void Leap6DBox::animateToNewValues(vector<int> targetValues, float timeToTake , ofImage* newTexture){ + + Node targ; + targ.setFromCC(targetValues); + + animateToNewValues(targ, timeToTake); +} +//-------------------------------------------------------------------- void Leap6DBox::animateHintToNewValues(Node target, float timeToTake){ - curPos = ofVec3f(hintX,hintY,hintZ); - curRot = ofVec3f(hintRoll,hintPitch,hintYaw); - + curHintPos = ofVec3f(hintX,hintY,hintZ); + curHintRot = ofVec3f(hintRoll,hintPitch,hintYaw); + ofVec3f targPos = target.getPositionVector(); ofVec3f targRot = target.getEulerRotVector(); float amtPerFrame = 1000./(ofGetFrameRate() * timeToTake); + + hintposAnimIncr = (targPos - curHintPos)*amtPerFrame; + hintrotAnimIncr = (targRot - curHintRot)*amtPerFrame; + + animatingHint = true; +} +//-------------------------------------------------------------------- +void Leap6DBox::animateToNewValues(Node target, float timeToTake){ + + curPos = ofVec3f(xVal,yVal,zVal); + curRot = ofVec3f(rollVal ,pitchVal,yawVal); + + ofVec3f targPos = target.getPositionVector(); + ofVec3f targRot = target.getEulerRotVector(); + + float amtPerFrame = 1000./(ofGetFrameRate() * timeToTake); + posAnimIncr = (targPos - curPos)*amtPerFrame; rotAnimIncr = (targRot - curRot)*amtPerFrame; - animating = true; + animatingIndicator = true; } +//-------------------------------------------------------------------- // for animation void Leap6DBox::update(){ - if(!animating) return; - - curPos += posAnimIncr; - curRot += rotAnimIncr; - - hintX = curPos.x; - hintY =curPos.y; - hintZ = curPos.z; - - hintRoll = curRot.x; - hintPitch = curRot.y; - hintYaw = curRot.z; - + if(animatingHint){ + + curHintPos += hintposAnimIncr; + curHintRot += hintrotAnimIncr; + + + + hintX = curHintPos.x; + hintY =curHintPos.y; + hintZ = curHintPos.z; + + hintRoll = curHintRot.x; + hintPitch = curHintRot.y; + hintYaw = curHintRot.z; + + } + if(animatingIndicator){ + + curPos += posAnimIncr; + curRot += rotAnimIncr; + + xVal = curPos.x; + yVal =curPos.y; + zVal = curPos.z; + + rollVal = curRot.x; + pitchVal = curRot.y; + yawVal = curRot.z; + } // show and shit } +//-------------------------------------------------------------------- +void Leap6DBox::flashScore(int score, ofColor col){ + showScoreForFrames = 20; + hintColor = col; +}
--- a/UI code/ButtronSlider.h Tue Nov 04 14:37:35 2014 +0000 +++ b/UI code/ButtronSlider.h Fri Nov 21 17:07:56 2014 +0000 @@ -75,6 +75,7 @@ maxVal = hi; } void animateHintToNewValue(int newVal, float timeToTake); + void animateToNewValue(int newVal, float timeToTake); void update(); private: void drawIndicator(double proportion); @@ -84,7 +85,12 @@ SliderType sliderType; float value; // [0. 1.] float hintValue; + + float hintTargVal; + float targVal; + float posAnimIncr; + float hintPosAnimIncr; bool hintShowing; bool indicatorShowing; ofColor hintColor;
--- a/UI code/ButtronSlider.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/UI code/ButtronSlider.mm Fri Nov 21 17:07:56 2014 +0000 @@ -85,16 +85,31 @@ } void ButtronSlider::animateHintToNewValue(int newVal, float timeToTake){ - float targVal = (newVal - minVal)/(maxVal - minVal); + hintTargVal = (newVal - minVal)/(maxVal - minVal); float amtPerFrame = 1000./(ofGetFrameRate() * timeToTake); - posAnimIncr = (targVal - hintValue )*amtPerFrame; + hintPosAnimIncr = (hintTargVal - hintValue )*amtPerFrame; animating = true; } - +void ButtronSlider::animateToNewValue(int newVal, float timeToTake){ + targVal = (newVal - minVal)/(maxVal - minVal); + + float amtPerFrame = 1000./(ofGetFrameRate() * timeToTake); + posAnimIncr = (targVal - value )*amtPerFrame; + animating = true; +} void ButtronSlider::update(){ if (!animating) return; - hintValue += posAnimIncr; + value += posAnimIncr; + hintValue += hintPosAnimIncr; + + // TODO when we've hit the target stop. +// if (abs(targVal - value) < 0.01){ +// animating = false; +// } +// if (abs(hintTargVal - hintValue) < 0.01){ +// animating = false; +// } } //---------------------------------------------------------------------
--- a/UI code/sliderPanel.h Tue Nov 04 14:37:35 2014 +0000 +++ b/UI code/sliderPanel.h Fri Nov 21 17:07:56 2014 +0000 @@ -38,6 +38,7 @@ vector<controllerType> elemList); void setAndShowHint(vector<int> values, ofImage* texture); + void setHintNoShow(vector<int> values, ofImage* texture); void showHint(bool value); // @@ -53,6 +54,7 @@ void setHintTexture(ofImage* texture); void setIndicatorTexture(ofImage* texture); void animateToNewHintValues(vector<int> newTargetValues, float timeToTake, ofImage* newTexture); + void animateToNewValues(vector<int> newTargetValues, float timeToTake); void showValueIndicators(bool show); void update(); controlPanelType getPanelType(){
--- a/UI code/sliderPanel.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/UI code/sliderPanel.mm Fri Nov 21 17:07:56 2014 +0000 @@ -149,7 +149,7 @@ int i = 0; for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); - thisSlider->setValue(vals[i]); + thisSlider->setValueAndScale(vals[i]); i++; } } @@ -246,6 +246,13 @@ showHint(true); } +void SliderPanel::setHintNoShow(vector<int> values, ofImage* texture){ + animating = false; + setHintValues(values); + setHintTexture(texture); + showHint(false); + +} //------------------------------------------ void SliderPanel::setHintTexture(ofImage* texture){ if (thisPanelType == LEAP6DOF){ // yeuch @@ -290,6 +297,27 @@ } //--------------------------------------------- +void SliderPanel::animateToNewValues(vector<int> newTargetValues, float timeToTake){ + animating = true; + + if(thisPanelType == LEAP6DOF){ + if (subElements[0]->getType() == LEAP6D){ + Leap6DBox * box = (Leap6DBox*)subElements[0]; + + box->animateToNewValues(newTargetValues, timeToTake); + } + }else if(thisPanelType == ALL_SLIDERS){ + int i = 0; + for(auto UIitr = subElements.begin(); UIitr < subElements.end(); UIitr++){ + ButtronSlider* thisSlider = (ButtronSlider *)(*UIitr); + + thisSlider->animateToNewValue(newTargetValues[i], timeToTake); + i++; + } + } + +} +//--------------------------------------------- void SliderPanel::update(){ if(!animating) return; @@ -318,6 +346,16 @@ TimerCallbackFunction tcb; tcb = boost::bind(&SliderPanel::turnOffResultLight, this); timeController.scheduleEvent(tcb, howLong); + if(thisPanelType == LEAP6DOF){ + if (subElements[0]->getType() == LEAP6D){ + Leap6DBox * box = (Leap6DBox*)subElements[0]; + + box->flashScore(5, c); + } + }else if(thisPanelType == ALL_SLIDERS){ + + } + } void SliderPanel::turnOffResultLight(){
--- a/globalVariables.cpp Tue Nov 04 14:37:35 2014 +0000 +++ b/globalVariables.cpp Fri Nov 21 17:07:56 2014 +0000 @@ -1,3 +1,2 @@ #include "globalVariables.h" -
--- a/globalVariables.h Tue Nov 04 14:37:35 2014 +0000 +++ b/globalVariables.h Fri Nov 21 17:07:56 2014 +0000 @@ -31,7 +31,7 @@ // globles #define TOTAL_NUM_PARAMS 6 -#define TARGET_SCORE_CC_BAND 6 // number of cc vals per target band in dartboard +#define TARGET_SCORE_CC_BAND 8 // number of cc vals per target band in dartboard typedef enum {TOUCH_DOWN, TOUCH_MOVED, TOUCH_UP} touchType; typedef enum {INTRO,QUESTIONNAIRE, HELP, TEST_IN_PROGRESS, SCORE_AND_HINT, COUNT_DOWN, READY_FOR_NEXT} interfaceType; @@ -45,3 +45,16 @@ typedef enum {SMALLFONT, MEDIUMFONT, LARGEFONT} FontSize; typedef boost::function<void(int)> TickListenerFunction; + + +// USEFUL FUNCTIONS + +template <typename T> +vector<T> zeros(int numElements){ + vector<T> v; + for(int i = 0; i< numElements; i++){ + v.push_back(0); + } + return v; + +}
--- a/presetManager.h Tue Nov 04 14:37:35 2014 +0000 +++ b/presetManager.h Fri Nov 21 17:07:56 2014 +0000 @@ -160,7 +160,7 @@ void loadPresetsFromJsonFile(const string &jsonFile); void updatePresetFile(); void showNameDialog(); - + void makeNeutralPreset(); Preset neutralPreset; };
--- a/presetManager.mm Tue Nov 04 14:37:35 2014 +0000 +++ b/presetManager.mm Fri Nov 21 17:07:56 2014 +0000 @@ -42,22 +42,28 @@ presetAlertShowing = false; + cout << "ofGetTimestampString: " << ts << '\n'; } -//------------------------------------------------------------------------- -Preset* PresetManager::getNeutralPreset(){ - +void PresetManager::makeNeutralPreset(){ vector<int> middleVals; for(int i = 0; i < TOTAL_NUM_PARAMS ; i++){ middleVals.push_back(64); } + neutralPreset = Preset(middleVals, - "Neutral", - 999, - "whocares", - 999, - "buttron.png"); + "Neutral", + 999, + "whocares", + 999, + "buttron.png"); + +} +//------------------------------------------------------------------------- +Preset* PresetManager::getNeutralPreset(){ + + return &neutralPreset; } @@ -218,7 +224,9 @@ } //--------------------------------------------------------------------------- Preset* PresetManager::getPresetAtIndex(int index){ - +// if (index == -1){ +// cout << " RETURNING NEUTRAL PRESET " << endl; +// } if (index >= thePresets.size()){ cout << "ERROR: index " << index << " exceeds number of presets " << thePresets.size() << endl; cout << " YOU HAVENT DONE EXP STAGE??" << endl;