Mercurial > hg > tweakathon2ios
changeset 26:8d7ae43b2edd
BLOODY FIIDDLY MOFO THIS ONE
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 28 Oct 2014 19:15:28 +0000 |
parents | 8eb530e0601b |
children | 27cdf475aa4b |
files | SequenceController.mm TrainingMessageOrganiser.h TrainingMessageOrganiser.mm UI code/3Dbox.h UI code/3DboxGL.h UI code/3DboxGL.mm UI code/6Dbox.h UI code/6Dbox.mm UI code/Buttron.mm UI code/IconPanel.mm UI code/UIElement.h UI code/UIElement.mm main.mm testApp.mm |
diffstat | 14 files changed, 267 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/SequenceController.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/SequenceController.mm Tue Oct 28 19:15:28 2014 +0000 @@ -57,7 +57,7 @@ hidesSliders = true; isPreview = true; - allowsCandidateControl = false; + allowsCandidateControl = true; playsTarget = true; playsCandidate = false; showsCountDown = true; @@ -66,14 +66,14 @@ void Step::setAsPreviewPlayer(){ type = PREVIEW_DISPLAYER; showsTargetIcon = true; - showsControlSettings = true; - showsControlGuides = false; + showsControlSettings = false; + showsControlGuides = true; showsMatchResults = false; hidesSliders = false; isPreview = true; - allowsCandidateControl = false; + allowsCandidateControl = true; playsTarget = true; playsCandidate = false; @@ -91,7 +91,7 @@ isPreview = false; - allowsCandidateControl = false; + allowsCandidateControl = true; playsTarget = true; playsCandidate = false;
--- a/TrainingMessageOrganiser.h Tue Oct 28 15:19:22 2014 +0000 +++ b/TrainingMessageOrganiser.h Tue Oct 28 19:15:28 2014 +0000 @@ -43,6 +43,14 @@ } cout << endl; } + + void lastOfAll(); + void lastOfRun(); + void showCountdown(); + void hideSliders(); + void showsTarget(); + + ofColor interactableColor; ofColor nonInteractableColor; int downCounter;
--- a/TrainingMessageOrganiser.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/TrainingMessageOrganiser.mm Tue Oct 28 19:15:28 2014 +0000 @@ -169,6 +169,7 @@ bool showTick = true; presetIconPanel->setTextAndImage(currentTargetPreset->name, currentTargetPreset->getImage(), showTick); presetIconPanel->show(); + box6D->setHintTexture(currentTargetPreset->getImage()); }else{ presetIconPanel->hide(); } @@ -186,21 +187,23 @@ // actually alters the slider values targetSynth.setAllParams(newTargetValues); setAllSlidersToValues(newTargetValues); - + box6D->setValues(newTargetValues); }else{ } panel->setHintValues(newTargetValues); - + box6D->setHintValues(newTargetValues); if(newStep.showsControlGuides){ // shows visual target lines on sliders (or target hand in VR) panel->showHint(true); + box6D->showHint(true); }else{ panel->showHint(false); + box6D->showHint(false); }
--- a/UI code/3Dbox.h Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/3Dbox.h Tue Oct 28 19:15:28 2014 +0000 @@ -26,21 +26,21 @@ const UIProps& props); void init(const UIProps& props); - void setValueAndScale(int which, int val){ + virtual void setValueAndScale(int which, int val){ if(which == 0) xVal = (val - minVal)/(maxVal - minVal); if(which == 1) yVal = (val - minVal)/(maxVal - minVal); if(which == 2) zVal = (val - minVal)/(maxVal - minVal); //cout << zVal << endl; } - void setHintValue(int which, int val){ + virtual void setHintValue(int which, int val){ if(which == 0) hintX = (val - minVal)/(maxVal - minVal); if(which == 1) hintY = (val - minVal)/(maxVal - minVal); if(which == 2) hintZ = (val - minVal)/(maxVal - minVal); }; - void draw(){ + virtual void draw(){ if(hidden)return; if(on){ ofSetColor(foregroundHi); @@ -77,7 +77,7 @@ ofLine(x+width,y,x+width,y+height); //right ofLine(x+width,y+height,x,y+height); // bottom - drawLabels(); + //drawLabels(); }; @@ -118,7 +118,7 @@ }; protected: - void drawIndicator(){ + virtual void drawIndicator(){ ofSetColor(foregroundHi); float px,py; px = x + xVal*width + zx*zVal; @@ -137,7 +137,7 @@ if(hintShowing) drawHintIndicator(); }; - void drawHintIndicator(){ + virtual void drawHintIndicator(){ ofSetColor(hintColor); float px,py; px = x + hintX*width + zx*hintZ; @@ -158,6 +158,8 @@ float xVal,yVal,zVal; + + ofVec3f posVals; float zx,zy; // how much of z and x shows up in diagonal x and y
--- a/UI code/3DboxGL.h Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/3DboxGL.h Tue Oct 28 19:15:28 2014 +0000 @@ -67,7 +67,7 @@ if (hintShowing && (hintZ > zVal)){ hintColor = calculateHintColor(); - draw3DCrossHairs(hintX, hintY, hintZ,hintColor); + draw3DCrossHairs(hintX, hintY, hintZ,hintColor, true); } @@ -79,11 +79,11 @@ if (hintShowing && hintZ <= zVal){ hintColor = calculateHintColor(); - draw3DCrossHairs(hintX, hintY, hintZ,hintColor); + draw3DCrossHairs(hintX, hintY, hintZ,hintColor, true); } } - void draw3DCrossHairs(float x , float y, float z, ofColor c){ + void draw3DCrossHairs(float x , float y, float z, ofColor c, bool isHint = false){ float ix = x*width - width/2; float iy = (1-y)*width - width/2; @@ -101,14 +101,14 @@ ofLine(ix,iy,iz,left,iy,iz); //blob - drawIndicatorBlob(ix,iy,iz,c); + drawIndicatorBlob(ix,iy,iz,c, isHint); // line to front (a bit wierde?) ofLine(ix,iy,iz,ix,iy,front); } - virtual void drawIndicatorBlob( float x, float y, float z, ofColor c){ + virtual void drawIndicatorBlob( float x, float y, float z, ofColor c, bool isHint = false){ ofSetColor(c); ofDrawIcoSphere(x,y,z,12); }
--- a/UI code/3DboxGL.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/3DboxGL.mm Tue Oct 28 19:15:28 2014 +0000 @@ -26,7 +26,7 @@ depth = width; // its a cube // where is the camera - camTrans = 200; + camTrans = 250; // cube is centred on 0,0,0 float I = width/2;
--- a/UI code/6Dbox.h Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/6Dbox.h Tue Oct 28 19:15:28 2014 +0000 @@ -9,6 +9,7 @@ #ifndef __riftathon___Dbox__ #define __riftathon___Dbox__ #include "3DboxGL.h" +#include "ofxVectormath.h" #include <iostream> class Leap6DBox : public Leap3DBoxGL { @@ -23,22 +24,44 @@ const UIProps& props); - void drawIndicatorBlob(float x, float y, float z, ofColor c); - void draw6DOFIndicatorBlob(float x, float y, float z, ofColor c, float r, float p, float yaw); + void drawIndicatorBlob(float x, float y, float z, ofColor c, bool isHint = false); + void draw6DOFIndicatorBlob(float x, float y, float z, ofColor c, float r, float p, float yaw,ofImage* texImg); void setTexture(ofImage* img); void setValue(int index, int value); void setValueAndScale(int index, int value); + + void setHintValue(int which, int val); + void setHintTexture(ofImage* img); + void update(); + void animateHintToNewValues(float x, float y, float z, float r, float p, float yaw); + void setHintValues(vector<int> vals); + void setValues(vector<int> vals); + + void draw(); + + private: - float hw, hh, hl, scale; - float minAngVal, maxAngVal; + + + void drawIndicator(); + void draw3DCrossHairs(float x , float y, float z, ofColor c, bool isHint = false); + void setUpHandMesh(); void setUpThumb(ofPoint baseTR, ofPoint baseBR); void makeTexFace(ofPoint LT, ofPoint RT, ofPoint RB, ofPoint LB); float rollVal, pitchVal, yawVal; + ofMatrix4x4 getRotationQuat(float roll, float pitch, float yaw); ofMesh handMesh; ofImage* texImg; ofImage defaultImage; + ofImage hintImage; + ofImage* hintImageRef; + ofMesh guideHandMesh; + + float hw, hh, hl, scale; + float hintRoll, hintPitch, hintYaw; + float minAngVal, maxAngVal; };
--- a/UI code/6Dbox.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/6Dbox.mm Tue Oct 28 19:15:28 2014 +0000 @@ -7,6 +7,11 @@ // #include "6Dbox.h" + +ofVec3f upUnit = ofVec3f(0.0, 1.0, 0.0); +ofVec3f fwdUnit = ofVec3f(0.0, 0.0, 1.0); +ofVec3f rightUnit = ofVec3f(1.0, 0.0, 0.0); + Leap6DBox::Leap6DBox(float ax, float ay, float awidth, @@ -30,19 +35,48 @@ hl = 1.0; scale = 40; - string fname = ofFilePath::getAbsolutePath(ofToDataPath("marble.jpeg")); - ofFile f = ofFile(fname); + string fname = ofFilePath::getAbsolutePath(ofToDataPath("turqoise.jpeg")); defaultImage.loadImage(fname); + + fname = ofFilePath::getAbsolutePath(ofToDataPath("bakedbeans.jpeg")); + hintImage.loadImage(fname); + setTexture(&defaultImage); + setHintTexture(&hintImage); setUpHandMesh(); + showHint(true); + } -void Leap6DBox::setValue(int index, int value){ - if (index == 0){ - +void Leap6DBox::setHintValues(vector<int> vals){ + if (vals.size() != 6){ + cout << "ERROR: need 6 vals for 6dof box set hint" << endl; + } + + for(int i = 0; i < 6; i++){ + Leap3DBox::setHintValue(i, vals[i]); } } +void Leap6DBox::setValues(vector<int> vals){ + if (vals.size() != 6){ + cout << "ERROR: need 6 vals for 6dof box set hint" << endl; + } + + for(int i = 0; i < 6; i++){ + Leap3DBox::setValueAndScale(i, vals[i]); + } +} + +void Leap6DBox::setHintValue(int which, int val){ + if(which == 0) hintX = (val - minVal)/(maxVal - minVal); + if(which == 1) hintY = (val - minVal)/(maxVal - minVal); + if(which == 2) hintZ = (val - minVal)/(maxVal - minVal); + + if(which == 3) hintRoll = 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); + if(which == 4) hintPitch = - 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); + if(which == 5) hintYaw = - 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); +}; void Leap6DBox::setValueAndScale(int which, int val){ @@ -53,8 +87,8 @@ // angles if(which == 3) rollVal = 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); - if(which == 4) pitchVal = 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); - if(which == 5) yawVal = 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); + if(which == 4) pitchVal = - 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); + if(which == 5) yawVal = - 57.3* (2.0*(val - minVal)/(maxVal - minVal) - 1.0); } void Leap6DBox::makeTexFace(ofPoint LT, ofPoint RT, ofPoint RB, ofPoint LB){ @@ -86,7 +120,7 @@ ofPoint ltr = ofPoint(-hw, hh, -hl); ofPoint rbr = ofPoint(hw, -hh, -hl); ofPoint rtf = ofPoint(hw, hh, hl); - ofPoint lbr = ofPoint(-hw, -hh, -hl);q + ofPoint lbr = ofPoint(-hw, -hh, -hl); ofPoint rbf = ofPoint(hw, -hh, hl); ofPoint lbf = ofPoint(-hw, -hh, hl); ofPoint ltf = ofPoint(-hw, hh, hl); @@ -122,8 +156,8 @@ ofPoint baseTL = baseTR; ofPoint baseBL = baseBR; - baseTL.z -= 0.5*hl; - baseBL.z -= 0.5*hl; + baseTL.z -= 0.9*hl; + baseBL.z -= 0.9*hl; ofPoint tip = baseBL; tip.x -= hw; tip.y += hh; @@ -173,25 +207,122 @@ } + + void Leap6DBox::setTexture(ofImage* img){ texImg = img; } - -void Leap6DBox::drawIndicatorBlob(float x, float y, float z, ofColor c){ - draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal); +void Leap6DBox::setHintTexture(ofImage* img){ + hintImageRef = img; + + } -void Leap6DBox::draw6DOFIndicatorBlob(float x, float y, float z, ofColor c, float r, float p, float yaw){ - ofVec3f up = ofVec3f(0.0, 1.0, 0.0); - ofVec3f fwd = ofVec3f(0.0, 0.0, 1.0); - ofVec3f right = ofVec3f(1.0, 0.0, 0.0); +void Leap6DBox::draw(){ + if(hidden)return; + if(on){ + ofSetColor(foregroundHi); + }else{ + ofSetColor(foregroundLo); + + } + if(inactive){ + ofSetColor(fgInactive); + } + + + + ofPushMatrix(); + ofDisableAlphaBlending(); + ofEnableDepthTest(); + // move to correct pos + + ofTranslate( x+width/2, y+height/2, camTrans); + ofRotate( angleX, 1, 0, 0 ); + ofRotate( angleY, 0, 1, 0 ); + + + ofSetColor(foregroundHi); + boxMesh.draw(); + + // draw indicators + drawIndicator(); + ofPopMatrix(); + + drawLabels(); +}; + +void Leap6DBox::drawIndicator(){ + + if (hintShowing && (hintZ > zVal)){ + hintColor = calculateHintColor(); + draw3DCrossHairs(hintX, hintY, hintZ,hintColor, true); + + } + + // draw indicator + draw3DCrossHairs(xVal,yVal,zVal, indicatorColor); + // put light in indicateor + // + + + 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){ + + float ix = x*width - width/2; + float iy = (1-y)*width - width/2; + float iz = (1-z)*width - width/2; + + float left = - width/2; + float bot = width/2; + float front = width/2; + // + ofSetColor(c); + ofSetLineWidth(2.); + // line to bottom + ofLine(ix,iy,iz,ix,bot,iz); + // line to left + ofLine(ix,iy,iz,left,iy,iz); + + //blob + 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; + }else{ + atexImg = texImg; + } + + if (isHint){ + draw6DOFIndicatorBlob(x, y, z, c, hintRoll, hintPitch, hintYaw, hintImageRef); + }else{ + draw6DOFIndicatorBlob(x, y, z, c, rollVal, pitchVal, yawVal, texImg); + + } +} +void Leap6DBox::draw6DOFIndicatorBlob(float x, float y, float z, ofColor c, float r, float p, float yaw, ofImage* atexImg){ + static ofMatrix4x4 m; - static ofMatrix4x4 rot; + m.makeScaleMatrix(scale,scale,scale); - rot.makeRotationMatrix(rollVal, fwd, pitchVal, right, yawVal, up); + + + ofMatrix4x4 rot = getRotationQuat(r, p, yaw); m.translate(x,y,z); ofPushMatrix(); @@ -200,10 +331,32 @@ ofSetColor(255,255,255); // render - (*texImg).bind(); + (*atexImg).bind(); handMesh.draw(); - (*texImg).unbind(); + (*atexImg).unbind(); ofPopMatrix(); + ofSetColor(c); } + +// TODO animation +ofMatrix4x4 Leap6DBox::getRotationQuat(float roll, float pitch, float yaw){ + static ofMatrix4x4 rot; + rot.makeRotationMatrix(roll, fwdUnit, pitch, rightUnit, yaw, upUnit); + return rot; +} +void Leap6DBox::animateHintToNewValues(float tx, float ty, float tz, float tr, float tp, float tyaw){ + ofVec3f curAnimPos = ofVec3f(hintX, hintY,hintZ); + ofVec3f animtargetPos = ofVec3f(tx, ty, tz); + + ofMatrix4x4 curRot = getRotationQuat(hintRoll, hintPitch, hintYaw); + + +} + +// for animation +void Leap6DBox::update(){ + + +}
--- a/UI code/Buttron.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/Buttron.mm Tue Oct 28 19:15:28 2014 +0000 @@ -77,11 +77,15 @@ //------------------------------------------------------------------ void Buttron::draw(){ if(hidden) return; + + ofDisableDepthTest(); //cout << "drawing button" << endl; ofFill(); UIElement::draw(); // should do background drawOutline(); drawTextLabel(); + + ofEnableDepthTest(); } //------------------------------------------------------------------ void Buttron::drawTextLabel(){ @@ -100,6 +104,7 @@ ofSetColor(fg); verdana16.drawString(labelName, x + thickness*2, y + 35); + } //------------------------------------------------------------------ void Buttron::drawOutline(){ @@ -161,6 +166,8 @@ ofRect(x+cornerSize,y+thickness,width-2*cornerSize,height-2*thickness); ofRect(x+thickness, y+cornerSize, radius, height-2*cornerSize); ofRect(x+width-cornerSize, y+cornerSize, radius, height-2*cornerSize); + + } //------------------------------------------------------------------------------ bool Buttron::handleMyTouch(int tx, int ty, touchType ttype, int touchID){
--- a/UI code/IconPanel.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/IconPanel.mm Tue Oct 28 19:15:28 2014 +0000 @@ -41,6 +41,7 @@ //drawOutline(); if(hasBeenSet){ drawTexture(); + drawTextLabel(); } @@ -72,7 +73,9 @@ void IconPanel::drawTexture(){ float z = 10; + ofSetColor(255,255,255); textureImage->draw(x+10,y+10,z,width-20,height-20); + ofSetColor(foregroundHi); } //------------------------------------------------------------------ void IconPanel::drawTextLabel(){
--- a/UI code/UIElement.h Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/UIElement.h Tue Oct 28 19:15:28 2014 +0000 @@ -104,6 +104,17 @@ void setColor(ofColor c){ background = c; } + int getZLayer(){ + return zLayer; + + } + void setZLayer(int z){ + zLayer = z; + } + void bringToFrontOf(UIElement* e){ + + setZLayer(e->getZLayer() + 1); + } protected: float x; @@ -158,6 +169,7 @@ bool isCoordInMyRegion(double x, double y); // not used + int zLayer; }; #endif /* defined(__emptyExample__UIElement__) */
--- a/UI code/UIElement.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/UI code/UIElement.mm Tue Oct 28 19:15:28 2014 +0000 @@ -56,6 +56,7 @@ hidden = false; inactive = false; + zLayer = 0; } //---------------------------------------------------------------------- void UIElement::draw(){
--- a/main.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/main.mm Tue Oct 28 19:15:28 2014 +0000 @@ -5,8 +5,8 @@ int main(){ ofAppiOSWindow * window = new ofAppiOSWindow(); - //window->enableHardwareOrientation(); - //window->enableOrientationAnimation(); + window->enableHardwareOrientation(); + window->enableOrientationAnimation(); window->enableAntiAliasing(4); window->enableDepthBuffer(); window->enableRetina();
--- a/testApp.mm Tue Oct 28 15:19:22 2014 +0000 +++ b/testApp.mm Tue Oct 28 19:15:28 2014 +0000 @@ -53,8 +53,8 @@ ofSoundStreamSetup(2, 2, this, 44100, ofxPd::blockSize()*ticksPerBuffer, 3); - if(true){ // force start - startTheExpTests(); + if(false){ // force start + startTheTrainingTests(); }else{ if(eventLogger.questionnaireCompleted){ // then show play again dialog, and log the test number @@ -145,7 +145,8 @@ playCandidateButton->setLabel("START"); trainingMessageOrganiser.mapButtonToAction(playCandidateButton, TRIGGER_CANDIDATE_ID); bottomButtonPanel->addButton(playCandidateButton); - + bottomButtonPanel->hide(); + trainingMessageOrganiser.setBottomPanel(bottomButtonPanel); UIElements.push_back(bottomButtonPanel); bottomButtonPanel->hide(); @@ -165,7 +166,7 @@ middlePanel->setFontSize(LARGEFONT); UIElements.push_back(middlePanel); trainingMessageOrganiser.setMiddlePanel(middlePanel); - middlePanel->show(); + middlePanel->hide(); } @@ -264,7 +265,7 @@ controlPanel->showBorder(true); controlPanel->hide(); - Leap6DBox * box = new Leap6DBox(300 , 210 , (*props).XYsize*0.75,(*props).XYsize*0.75,150,50, *props); + Leap6DBox * box = new Leap6DBox(400 , 210 , (*props).XYsize*0.75,(*props).XYsize*0.75,150,50, *props); searchMessageOrganiser.setBox(box); trainingMessageOrganiser.setBox(box); expMessageOrganiser.setBox(box); @@ -274,7 +275,7 @@ //-------------------------------------------------------------- void testApp::setupUIElements(){ - ofBackground((*props).generalBackground); + ofBackground(255,255,255); setupSearchViewPanels(); @@ -456,9 +457,9 @@ // do countdown etc trainingMessageOrganiser.hideMyPanels(); - + searchMessageOrganiser.hideMyPanels(); expMessageOrganiser.setup(); - expMessageOrganiser.showMyPanels(); + //expMessageOrganiser.showMyPanels(); // TODO how is testApp going to kknow whichInterfaceShowing ??? currentStage = EXPRESS;