summaryrefslogtreecommitdiff
path: root/src/viewpoint.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/viewpoint.cpp')
-rw-r--r--src/viewpoint.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/viewpoint.cpp b/src/viewpoint.cpp
index 5d61f1f..0c7fe8a 100644
--- a/src/viewpoint.cpp
+++ b/src/viewpoint.cpp
@@ -1,7 +1,8 @@
#include "viewpoint.h"
#define DEBUG 0
-void viewpoint::setup(float w, float h, float x, float y) {
+void viewpoint::setup(int ln,float w, float h, float x, float y) {
+ lightNum=ln;
window=ofRectangle(w,h,x,y);
distortFactor=0.0;
renderFBO.allocate(window.width,window.height,GL_RGB);
@@ -13,20 +14,37 @@ void viewpoint::setup(float w, float h, float x, float y) {
far=20;
camera.setParent(target);
-
vars=new keyVar[8];
//void set(char _keyInc,char _keyDec,float _val,float _speed,float _accel,float accelTime);
vars[0].set('w','s',17.25,0.5,2.0,3.0);
vars[1].set('g','d',0.0,10,3.0,3.0);
- vars[2].set('r','v',0.0,10,3.0,3.0);
+ vars[2].set('r','v',112,10,3.0,3.0);
vars[3].set('t','c',0.0,10,3.0,3.0);
vars[4].set('u','n',0.0,1.0,3.0,3.0);
vars[5].set('j','h',0.0,1.0,3.0,3.0);
vars[6].set('o','l',1000.0,10,3.0,3.0);
vars[7].set('q','a',0,0.0001,2.0,3.0);
- //camera.setPosition(0,0,vars[6].getVal());
+ camera.setPosition(0,0,vars[6].getVal());
+}
+//--------------------------------------------------------------
+void viewpoint::setLight(){
+ target.setPosition(vars[1].getVal(),vars[2].getVal(),vars[3].getVal());
+ /*
+ target.rotate(vars[4].getInc(),1,0,0);
+ target.rotate(vars[5].getInc(),0,1,0);
+ camera.setPosition(0,0,vars[6].getVal());
+ */
+
+ camera.orbit(vars[4].getVal(), vars[5].getVal(), vars[6].getVal(), target);
+
+ ofVec3f lp=camera.getGlobalPosition();
+ GLfloat lightPosition[] = {lp.x, lp.y, lp.z};
+ GLfloat lightColour[] = {0.99, 0.99, 0.99, 0.5};
+ glLightfv(lightNum, GL_POSITION, lightPosition);
+ glLightfv(lightNum, GL_DIFFUSE, lightColour);
+ glEnable(lightNum);
}
//--------------------------------------------------------------
void viewpoint::begin(){
@@ -38,11 +56,8 @@ void viewpoint::begin(){
camera.begin();
camera.setFov(vars[0].getVal());
- target.setPosition(vars[1].getVal(),vars[2].getVal(),vars[3].getVal());
- target.rotate(vars[4].getInc(),1,0,0);
- target.rotate(vars[5].getInc(),0,1,0);
- camera.setPosition(0,0,vars[6].getVal());
-
+
+
}
//--------------------------------------------------------------