diff options
Diffstat (limited to 'src/testApp.cpp')
| -rw-r--r-- | src/testApp.cpp | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp index c2772aa..6f8b00f 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -6,6 +6,8 @@ testApp::~testApp(){ //-------------------------------------------------------------- void testApp::setup(){ + loadSettings("settings.xml"); + ofBackground(0,0,0); ///ofSetVerticalSync(true); @@ -16,16 +18,21 @@ void testApp::setup(){ glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable (GL_COLOR_MATERIAL); + printf("loading %s at %f,%f,%f",model_name.c_str(),model_x,model_y,model_z); + //load the bottle model - the 3ds and the texture file need to be in the same folder - bottle.loadModel("tigerbottle.3DS", 1); - bottle.setRotation(0, 180, 1, 0, 0); - bottle.setPosition(0, 101, 0); + + model.loadModel(model_name, 1); + model.setRotation(0, 180, 1, 0, 0); + //model.setRotation(0, 90, 0, 1, 0); + model.setPosition(model_x, model_y, model_z); + //ofDisableArbTex(); mode=DISPLAY; - loadSettings("settings.xml"); + whichClip=0; texture.loadMovie(clips[whichClip]); @@ -54,11 +61,17 @@ void testApp::draw(){ switch(mode) { case CALIBRATE: drawBoard(0,225,0); - bottle.draw(); + ofPushMatrix(); + ofRotate(90,0,1,0); + model.draw(); + ofPopMatrix(); break; case DISPLAY: bindTexture(texture); - bottle.draw(); + ofPushMatrix(); + ofRotate(90,0,1,0); + model.draw(); + ofPopMatrix(); unbindTexture(texture); break; case NOTHING: @@ -82,6 +95,15 @@ void testApp::keyPressed(int key){ if (activeView<0) for (int i=0;i<numViews;i++) views[i].keyPressed(key); else if (activeView<numViews) views[activeView].keyPressed(key); switch (key) { + //'vertigo effect' always affects ALL VIEWPOINTS + case 'i': + for (int i=0;i<numViews;i++) views[i].keyPressed('o'); + for (int i=0;i<numViews;i++) views[i].keyPressed('s'); + break; + case 'k': + for (int i=0;i<numViews;i++) views[i].keyPressed('l'); + for (int i=0;i<numViews;i++) views[i].keyPressed('w'); + break; case '8': mode=CALIBRATE; break; @@ -125,15 +147,34 @@ void testApp::keyPressed(int key){ light=!light; printf(light?"LIGHT ON\n":"LIGHT OFF\n"); break; - } - } +//-------------------------------------------------------------- +void testApp::keyReleased(int key){ + if (activeView<0) for (int i=0;i<numViews;i++) views[i].keyReleased(key); + else if (activeView<numViews) views[activeView].keyReleased(key); + switch (key) { + //'vertigo effect' always affects ALL VIEWPOINTS + case 'i': + for (int i=0;i<numViews;i++) views[i].keyReleased('o'); + for (int i=0;i<numViews;i++) views[i].keyReleased('s'); + break; + case 'k': + for (int i=0;i<numViews;i++) views[i].keyReleased('l'); + for (int i=0;i<numViews;i++) views[i].keyReleased('w'); + break; + } +} + void testApp::loadSettings(string filename){ //viewport settings are float/ normalised to 0..1 if( !XML.loadFile(filename) ){ printf("unable to load %s check data/ folder\n",filename.c_str()); }else{ + model_name=XML.getAttribute("map4","model","none",0); + model_x=ofToFloat(XML.getAttribute("map4","x","none",0)); + model_y=ofToFloat(XML.getAttribute("map4","y","none",0)); + model_z=ofToFloat(XML.getAttribute("map4","z","none",0)); if(XML.pushTag("map4")) { numViews=XML.getNumTags("view"); if(numViews) { @@ -196,11 +237,6 @@ void testApp::saveSettings(string filename){ XML.saveFile(filename); printf("saved %s\n",filename.c_str()); } -//-------------------------------------------------------------- -void testApp::keyReleased(int key){ - if (activeView<0) for (int i=0;i<numViews;i++) views[i].keyReleased(key); - else if (activeView<numViews) views[activeView].keyReleased(key); -} //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ |
