From 7ff3ebe50cd272176daff0de4aee32c1dc0f3320 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 9 Jan 2012 16:36:57 +0000 Subject: xmlising settings --- src/testApp.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 11 deletions(-) (limited to 'src/testApp.cpp') diff --git a/src/testApp.cpp b/src/testApp.cpp index 2094c34..b93f4be 100644 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -1,10 +1,13 @@ #include "testApp.h" - +//-------------------------------------------------------------- +testApp::~testApp(){ + saveSettings(); +} //-------------------------------------------------------------- void testApp::setup(){ + ofBackground(0,0,0); - ///ofSetVerticalSync(true); //some model / light stuff @@ -12,7 +15,7 @@ void testApp::setup(){ glShadeModel (GL_SMOOTH); glColorMaterial (GL_FRONT_AND_BACK, GL_DIFFUSE); glEnable (GL_COLOR_MATERIAL); - + //load the bottle model - the 3ds and the texture file need to be in the same folder bottle.loadModel("bottle.3DS", 1); bottle.setRotation(0, 180, 1, 0, 0); @@ -25,13 +28,7 @@ void testApp::setup(){ mode=CALIBRATE; - views=new viewpoint[2]; - - //todo: read this from xml - numViews=2; - views[0].setup(ofGetWidth()/2,ofGetHeight(),0,0); - views[1].setup(ofGetWidth()/2,ofGetHeight(),ofGetWidth()/2,0); - activeView=0; + loadSettings(); } //-------------------------------------------------------------- @@ -95,11 +92,61 @@ void testApp::keyPressed(int key){ case '3': activeView=1; break; - + } } +void testApp::loadSettings(){ + //viewport settings are float/ normalised to 0..1 + if( !XML.loadFile("settings.xml") ){ + printf("unable to load settings.xml check data/ folder\n"); + }else{ + if(XML.pushTag("map4")) { + numViews=XML.getNumTags("view"); + if(numViews) { + views=new viewpoint[numViews]; + for (int i=0;ikeys; + XML.getAttributeNames("settings", keys, 0); + mapsettings; + for (int k=0;kkeys; + XML.getAttributeNames("settings", keys, 0); + for (int k=0;k