changeset 24:b339acf124df

new box - not really rendering properly
author Robert Tubb <rt300@eecs.qmul.ac.uk>
date Mon, 27 Oct 2014 17:40:05 +0000
parents 055e0c43afe5
children 8eb530e0601b
files MessageOrganiser.h MessageOrganiser.mm SearchMessageOrganiser.h TrainingMessageOrganiser.h UI code/3DboxGL.h UI code/6Dbox.h UI code/6Dbox.mm testApp.h testApp.mm
diffstat 9 files changed, 204 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/MessageOrganiser.h	Mon Oct 27 15:52:04 2014 +0000
+++ b/MessageOrganiser.h	Mon Oct 27 17:40:05 2014 +0000
@@ -27,6 +27,7 @@
 //#include "testApp.h"
 #include "targetSymbol.h"
 #include "3Dbox.h"
+#include "6Dbox.h"
 #include "TextPanel.h"
 #include "CountdownText.h"
 #include "buttonPanel.h"
@@ -67,6 +68,7 @@
     void setBottomPanel(ButtonPanel * ntb);
     void setIconPanel(IconPanel * ip);
     void setInstructionPanel(TextPanel * ip);
+    void setBox(Leap6DBox * box);
     //-----------------------------------------------------------------------------
     void hideMyPanels();
     void showMyPanels();
@@ -79,6 +81,7 @@
     
     IconPanel* presetIconPanel;
     TextPanel* instructionPanel;
+    Leap6DBox* box6D;
     
     map<int,UIElement*> currentMapping; // could get more sophisticated if not 1-1 ?
     
--- a/MessageOrganiser.mm	Mon Oct 27 15:52:04 2014 +0000
+++ b/MessageOrganiser.mm	Mon Oct 27 17:40:05 2014 +0000
@@ -28,6 +28,9 @@
 void MessageOrganiser::setIconPanel(IconPanel * ip){
     presetIconPanel = ip;
 }
+void MessageOrganiser::setBox(Leap6DBox * box){
+    box6D = box;
+}
 void MessageOrganiser::setInstructionPanel(TextPanel * ip){
     instructionPanel = ip;
     instructionPanel->show();
--- a/SearchMessageOrganiser.h	Mon Oct 27 15:52:04 2014 +0000
+++ b/SearchMessageOrganiser.h	Mon Oct 27 17:40:05 2014 +0000
@@ -255,29 +255,7 @@
 
 
 protected:
-    
-    
-    TimeController altPlaybackController;
-    
-    TestController* testController;
-    Buttron* newTestButton;
-    //Buttron* submitButton;
-    
 
-    Buttron* targetPlayButton; // so we can hide target in memory test. this pointer stuff is getting out of hand
-    CountdownText* countdownPanel;
-    TargetSymbol* targetSymbol;
-    Leap3DBoxGL* box3D;
-    TextPanel* scorePanel;
-    TextPanel* finishPanel;
-  
-    //int scoreRunningTotal;
-    TimerID currentSoundPlayTimer;
-    
-    int alternationSpeed; // ms between cand and target
-    bool playingAlternating;
-    
-    bool okToGetLeapMidi;
     
     
 // protected methods
@@ -564,6 +542,29 @@
         panel->setHintColor(c);
     };
  
+    
+    
+    TimeController altPlaybackController;
+    
+    TestController* testController;
+    Buttron* newTestButton;
+    //Buttron* submitButton;
+    
+    
+    Buttron* targetPlayButton; // so we can hide target in memory test. this pointer stuff is getting out of hand
+    CountdownText* countdownPanel;
+    TargetSymbol* targetSymbol;
+    Leap3DBoxGL* box3D;
+    TextPanel* scorePanel;
+    TextPanel* finishPanel;
+    
+    //int scoreRunningTotal;
+    TimerID currentSoundPlayTimer;
+    
+    int alternationSpeed; // ms between cand and target
+    bool playingAlternating;
+    
+    bool okToGetLeapMidi;
 
 };
 
--- a/TrainingMessageOrganiser.h	Mon Oct 27 15:52:04 2014 +0000
+++ b/TrainingMessageOrganiser.h	Mon Oct 27 17:40:05 2014 +0000
@@ -16,6 +16,7 @@
 #include "IconPanel.h"
 #include "TextPanel.h"
 #include "TrainingScoreManager.h"
+#include "6Dbox.h"
 extern ExplorePresetManager expPresetManager;
 
 class TrainingMessageOrganiser : public MessageOrganiser {
@@ -49,5 +50,6 @@
     TextPanel* middlePanel;
     SequenceController sequenceController;
     TrainingScoreManager trainingScoreManager;
+    
 };
 #endif /* defined(__riftathon__TrainingMessageOrganiser__) */
--- a/UI code/3DboxGL.h	Mon Oct 27 15:52:04 2014 +0000
+++ b/UI code/3DboxGL.h	Mon Oct 27 17:40:05 2014 +0000
@@ -13,7 +13,6 @@
 #include "3Dbox.h"
 #include "UIElement.h"
 
-#endif /* defined(__tweakathlon___DboxGL__) */
 
 //Universal function which sets normals for the triangle meshvoid
 void setNormals( ofMesh &mesh );
@@ -234,3 +233,4 @@
     
 };
 
+#endif /* defined(__tweakathlon___DboxGL__) */
--- a/UI code/6Dbox.h	Mon Oct 27 15:52:04 2014 +0000
+++ b/UI code/6Dbox.h	Mon Oct 27 17:40:05 2014 +0000
@@ -21,7 +21,20 @@
                 float azx,
                 float azy,
                 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 setTexture(ofImage* img);
+private:
+    float hw, hh, hl, scale;
+    void setUpHandMesh();
+    
+    float roll, pitch, yaw;
+    
+    ofMesh handMesh;
+    ofImage* texImg;
+    ofImage defaultImage;
 };
 
 
--- a/UI code/6Dbox.mm	Mon Oct 27 15:52:04 2014 +0000
+++ b/UI code/6Dbox.mm	Mon Oct 27 17:40:05 2014 +0000
@@ -17,6 +17,150 @@
 Leap3DBoxGL(ax,ay,awidth, aheight, azx, azy, props)
 {
 
+    roll = 0.0;
+    pitch = 0.0;
+    yaw = 0.0;
+    
     // set up hand mesh
+    // width 0.5
+    // length 1
+    // height 0.25
+    hw = 0.5;
+    hh = 0.25;
+    hl = 1.0;
+    scale = 0.1;
     
-}
\ No newline at end of file
+    string fname = ofFilePath::getAbsolutePath(ofToDataPath("perf.jpeg"));
+    ofFile f = ofFile(fname);
+    defaultImage.loadImage(fname);
+    setTexture(&defaultImage);
+    setUpHandMesh();
+    
+}
+
+void Leap6DBox::setUpHandMesh(){
+    ofPoint rtr = ofPoint(hw, hh, hl);
+    ofPoint ltr = ofPoint(-hw, hh, hl);
+    ofPoint rbr = ofPoint(hw, -hh, hl);
+    ofPoint rtf = ofPoint(hw, hh, -hl);
+    ofPoint lbr = ofPoint(-hw, -hh, hl);
+    ofPoint rbf = ofPoint(hw, -hh, -hl);
+    ofPoint lbf = ofPoint(-hw, -hh, -hl);
+    ofPoint ltf = ofPoint(-hw, hh, -hl);
+ 
+    int imageWidth = 259;
+    int imageHeight = 254;
+    
+    ofPoint texCoordLT = ofPoint(0, 0);
+    ofPoint texCoordLB = ofPoint(0, imageHeight);
+    ofPoint texCoordRT = ofPoint(imageWidth, 0);
+    ofPoint texCoordRB = ofPoint(imageWidth, imageHeight);
+    
+    
+    // now build faces
+    // rear
+    // now build faces
+    // rear
+    handMesh.addVertex(ltr);
+    handMesh.addTexCoord(texCoordLT);
+    
+    handMesh.addVertex(rtr);
+    handMesh.addTexCoord(texCoordRT);
+    handMesh.addVertex(rbr);
+    handMesh.addTexCoord(texCoordRB);
+    
+    handMesh.addVertex(ltr);
+    handMesh.addTexCoord(texCoordLT);
+    handMesh.addVertex(rbr);
+    handMesh.addTexCoord(texCoordRB);
+    handMesh.addVertex(lbr);
+    handMesh.addTexCoord(texCoordLB);
+    
+    // left
+    handMesh.addVertex(ltf);
+    handMesh.addVertex(ltr);
+    handMesh.addVertex(lbr);
+    
+    handMesh.addVertex(ltf);
+    handMesh.addVertex(lbr);
+    handMesh.addVertex(lbf);
+    
+    // bottom
+    handMesh.addVertex(lbf);
+    handMesh.addVertex(lbr);
+    handMesh.addVertex(rbr);
+    
+    handMesh.addVertex(lbf);
+    handMesh.addVertex(rbr);
+    handMesh.addVertex(rbf);
+
+    // top
+    handMesh.addVertex(ltf);
+    handMesh.addVertex(ltr);
+    handMesh.addVertex(rtf);
+    
+    handMesh.addVertex(ltr);
+    handMesh.addVertex(rtr);
+    handMesh.addVertex(rtf);
+    
+    // right
+    handMesh.addVertex(rbf);
+    handMesh.addVertex(rtf);
+    handMesh.addVertex(rbr);
+    
+    handMesh.addVertex(rtf);
+    handMesh.addVertex(rtr);
+    handMesh.addVertex(rbr);
+ 
+    // front
+    handMesh.addVertex(ltf);
+    handMesh.addTexCoord(texCoordLT);
+    
+    handMesh.addVertex(rtf);
+    handMesh.addTexCoord(texCoordRT);
+    handMesh.addVertex(rbf);
+    handMesh.addTexCoord(texCoordRB);
+    
+    handMesh.addVertex(ltf);
+    handMesh.addTexCoord(texCoordLT);
+    handMesh.addVertex(rbf);
+    handMesh.addTexCoord(texCoordRB);
+    handMesh.addVertex(lbf);
+    handMesh.addTexCoord(texCoordLB);
+    // TODO now make triange thumb
+    
+    
+    handMesh.setupIndicesAuto();
+}
+
+void Leap6DBox::setTexture(ofImage* img){
+    texImg = img;
+    
+    
+}
+
+void Leap6DBox::drawIndicatorBlob(float x, float y, float z, ofColor c){
+    draw6DOFIndicatorBlob(x, y, z, c, roll, pitch, yaw);
+}
+
+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);
+    
+    static ofMatrix4x4 m;
+    static ofMatrix4x4 rot;
+	m.makeScaleMatrix(scale,scale,scale);
+    rot.makeRotationMatrix(roll, fwd, pitch, right, yaw, up);
+	m.translate(x,y,z);
+    
+    ofPushMatrix();
+    ofMultMatrix(m);
+    ofMultMatrix(rot);
+    // render
+    (*texImg).bind();
+    boxMesh.draw();
+    (*texImg).unbind();
+    ofPopMatrix();
+    
+}
--- a/testApp.h	Mon Oct 27 15:52:04 2014 +0000
+++ b/testApp.h	Mon Oct 27 17:40:05 2014 +0000
@@ -35,6 +35,7 @@
 #include <buttonPanel.h>
 #include "targetSymbol.h"
 #include "3Dbox.h"
+#include "6Dbox.h"
 #include "TextPanel.h"
 //#define OSC_HOST "169.254.1.1"
 //#define OSC_PORT 12345
--- a/testApp.mm	Mon Oct 27 15:52:04 2014 +0000
+++ b/testApp.mm	Mon Oct 27 17:40:05 2014 +0000
@@ -33,6 +33,10 @@
     initialiseMIDI();
     setupUIElements();
 
+    light.setSpotlight(45. , 1.);
+    light.enable();
+    ofEnableSeparateSpecularLight();
+    
     ofEnableDepthTest();
     ofEnableAlphaBlending();
 
@@ -162,6 +166,7 @@
     trainingMessageOrganiser.setMiddlePanel(middlePanel);
     middlePanel->show();
     
+    
 }
 //--------------------------------------------------------------
 // gui for the old style tweakathlon  stage
@@ -240,7 +245,7 @@
 }
 //--------------------------------------------------------------
 void testApp::setupSliderPanel(){
-    UIProps p;
+
     vector<controllerType> sl2;
     sl2.push_back(SLIDER);
     
@@ -256,6 +261,13 @@
     trainingMessageOrganiser.setControlPanel(controlPanel);
     expMessageOrganiser.setControlPanel(controlPanel);
     controlPanel->showBorder(true);
+
+    Leap6DBox * box = new Leap6DBox(300 , 210 , (*props).XYsize*0.75,(*props).XYsize*0.75,150,50, *props);
+    searchMessageOrganiser.setBox(box);
+    trainingMessageOrganiser.setBox(box);
+    expMessageOrganiser.setBox(box);
+    UIElements.push_back(box);
+    box->show();
 }
 //--------------------------------------------------------------
 void testApp::setupUIElements(){