summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-01-12 13:11:28 +0000
committerTim Redfern <tim@eclectronics.org>2012-01-12 13:11:28 +0000
commit1641253a1f8f6c5e7e7efa676c27e24c82893dfb (patch)
tree91e0404c771093e6aab5e9bf9d3bd1e21c9a4407
parent6eb389d8c8b9a6f75e291d359a7708d2944a156d (diff)
fixed gymbal lock, light on-off
-rw-r--r--map4.layout10
-rw-r--r--src/testApp.cpp8
-rw-r--r--src/testApp.h2
-rw-r--r--src/viewpoint.cpp13
4 files changed, 25 insertions, 8 deletions
diff --git a/map4.layout b/map4.layout
index 406cfcd..75b17ee 100644
--- a/map4.layout
+++ b/map4.layout
@@ -19,14 +19,14 @@
<File name="src/mapUtils.h" open="0" top="0" tabpos="6">
<Cursor position="165" topLine="0" />
</File>
- <File name="src/testApp.cpp" open="1" top="0" tabpos="2">
- <Cursor position="1528" topLine="35" />
+ <File name="src/testApp.cpp" open="1" top="1" tabpos="2">
+ <Cursor position="2650" topLine="92" />
</File>
<File name="src/testApp.h" open="1" top="0" tabpos="1">
- <Cursor position="787" topLine="15" />
+ <Cursor position="1432" topLine="29" />
</File>
- <File name="src/viewpoint.cpp" open="1" top="1" tabpos="5">
- <Cursor position="2288" topLine="33" />
+ <File name="src/viewpoint.cpp" open="1" top="0" tabpos="5">
+ <Cursor position="2656" topLine="0" />
</File>
<File name="src/viewpoint.h" open="1" top="0" tabpos="4">
<Cursor position="426" topLine="7" />
diff --git a/src/testApp.cpp b/src/testApp.cpp
index ab0987b..37717fa 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -29,6 +29,8 @@ void testApp::setup(){
mode=CALIBRATE;
loadSettings();
+
+ light=true;
}
//--------------------------------------------------------------
@@ -41,6 +43,8 @@ void testApp::draw(){
for (int i=0;i<numViews;i++) {
views[i].setLight();
}
+ if (light) glEnable(GL_LIGHTING);
+ else glDisable(GL_LIGHTING);
for (int i=0;i<numViews;i++) {
views[i].begin();
ofSetColor(255, 255, 255, 255);
@@ -98,6 +102,10 @@ void testApp::keyPressed(int key){
saveSettings();
printf("saved settings.xml\n");
break;
+ case '/':
+ light=!light;
+ printf(light?"LIGHT ON\n":"LIGHT OFF\n");
+ break;
}
diff --git a/src/testApp.h b/src/testApp.h
index dadad43..07c043f 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -62,4 +62,6 @@ class testApp : public ofBaseApp{
int mode;
ofxXmlSettings XML;
+
+ bool light;
};
diff --git a/src/viewpoint.cpp b/src/viewpoint.cpp
index 1635cfd..6a12c99 100644
--- a/src/viewpoint.cpp
+++ b/src/viewpoint.cpp
@@ -48,8 +48,15 @@ double viewpoint::getSetting(const string& setting){
//--------------------------------------------------------------
void viewpoint::setLight(){
target.setPosition(vars[1].getVal(),vars[2].getVal(),vars[3].getVal());
- camera.orbit(vars[5].getVal(), vars[4].getVal(), vars[7].getVal(), target);
- camera.lookAt(target,ofVec3f(0,1,0).rotate(vars[6].getVal(),ofVec3f(0,0,1)));
+ //camera.orbit(vars[5].getVal(), vars[4].getVal(), vars[7].getVal(), target);
+ ofVec3f p(0, 0, vars[7].getVal());
+ //p.rotate(ofClamp(vars[2].getVal(), -89, 89), ofVec3f(1, 0, 0));
+ p.rotate(vars[4].getVal(), ofVec3f(1, 0, 0));
+ p.rotate(vars[5].getVal(), ofVec3f(0, 1, 0));
+ p += target.getPosition();
+ camera.setPosition(p);
+
+ camera.lookAt(target,ofVec3f(0,1,0).rotate(vars[6].getVal(),ofVec3f(0,0,1)).rotate(vars[5].getVal(),ofVec3f(0,1,0)));
light.setPosition(camera.getGlobalPosition());
}
void viewpoint::setDefaults(){
@@ -111,7 +118,7 @@ void viewpoint::end(bool showStats){
if (showStats) {
ofSetHexColor(0xFFFFFF);
- ofDrawBitmapString("camera: "+ofToString(camera.getX(), 2)+","+ofToString(camera.getY(), 2)+","+ofToString(camera.getZ(), 2), window.x+10, window.y+window.height-30);
+ ofDrawBitmapString("camera: "+ofToString(camera.getX(), 2)+","+ofToString(camera.getY(), 2)+","+ofToString(camera.getZ(), 2)+" "+ofToString(vars[5].getVal())+"deg", window.x+10, window.y+window.height-30);
ofDrawBitmapString("light: "+ofToString(light.getX(), 2)+","+ofToString(light.getY(), 2)+","+ofToString(light.getZ(), 2), window.x+10, window.y+window.height-18);
}
}