summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/keyVar.cpp1
-rw-r--r--src/testApp.cpp10
-rw-r--r--src/viewpoint.cpp53
-rw-r--r--src/viewpoint.h2
4 files changed, 8 insertions, 58 deletions
diff --git a/src/keyVar.cpp b/src/keyVar.cpp
index 8a5ce9a..2c92896 100644
--- a/src/keyVar.cpp
+++ b/src/keyVar.cpp
@@ -2,6 +2,7 @@
* keyvar.cpp
generalised cushioned keyboard controller
+ //todo time based rather than onoff to get around keyrepeat issue
*/
#include "keyVar.h"
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 5bd6f0a..42f7055 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -10,19 +10,14 @@ void testApp::setup(){
//some model / light stuff
glEnable (GL_DEPTH_TEST);
glShadeModel (GL_SMOOTH);
-
- //initialize lighting
- //glEnable (GL_LIGHTING);
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);
bottle.setPosition(0, 112, 0);
-
//ofDisableArbTex();
texture.loadMovie("gradblend01.mov");
@@ -33,11 +28,8 @@ void testApp::setup(){
views=new viewpoint[1];
//todo: read this from xml
- views[0].setup(GL_LIGHT0,ofGetWidth(),ofGetHeight(),0,0);
+ views[0].setup(ofGetWidth(),ofGetHeight(),0,0);
activeView=0;
-
-
-
}
//--------------------------------------------------------------
diff --git a/src/viewpoint.cpp b/src/viewpoint.cpp
index efb6894..daca64f 100644
--- a/src/viewpoint.cpp
+++ b/src/viewpoint.cpp
@@ -1,8 +1,7 @@
#include "viewpoint.h"
#define DEBUG 0
-void viewpoint::setup(int ln,float w, float h, float x, float y) {
- lightNum=ln;
+void viewpoint::setup(float w, float h, float x, float y) {
window=ofRectangle(w,h,x,y);
distortFactor=0.0;
renderFBO.allocate(window.width,window.height,GL_RGB);
@@ -13,10 +12,8 @@ void viewpoint::setup(int ln,float w, float h, float x, float y) {
near=1;
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,1.0,3.0);
vars[1].set('g','d',0.0,10,1.0,3.0);
vars[2].set('r','v',112,10,1.0,3.0);
@@ -26,69 +23,34 @@ void viewpoint::setup(int ln,float w, float h, float x, float y) {
vars[6].set('o','l',1000.0,10,1.0,3.0);
vars[7].set('q','a',0,1,1.0,3.0);
- //camera.setPosition(0,0,vars[6].getVal());
-
- getLightPosition=new GLfloat[4];
-
light.enable();
light.setDirectional();
}
//--------------------------------------------------------------
void viewpoint::setLight(){
- //glLoadIdentity();
- //glPushMatrix();
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[5].getVal(), vars[4].getVal(), vars[6].getVal(), target);
camera.lookAt(target,ofVec3f(0,1,0));
- //glPopMatrix();
- //ofVec3f lp=camera.getGlobalPosition();
light.setPosition(camera.getGlobalPosition());
- /*
- GLfloat lightPosition[] = {lp.x, lp.y, lp.z,1};
- GLfloat lightColour[] = {0.99, 0.99, 0.99, 0.5};
-
- glLightfv(lightNum, GL_POSITION, lightPosition);
- glLightfv(lightNum, GL_DIFFUSE, lightColour);
- glEnable(lightNum);
- glGetLightfv(lightNum,GL_POSITION, getLightPosition);
- */
}
//--------------------------------------------------------------
-void viewpoint::begin(){
-
+void viewpoint::begin(){
renderFBO.begin();
ofClear(0,0,0);
- //ofPushView();
-
camera.begin();
camera.setFov(vars[0].getVal());
-
-
-
- }
+}
//--------------------------------------------------------------
-void viewpoint::end(){
-
+void viewpoint::end(){
camera.end();
- //ofPopView();
renderFBO.end();
ofPushMatrix();
bindTexture(renderFBO);
-
- //draw a grid
- //glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
ofNoFill();
-
ofSetLineWidth(1.0);
//ofSetColor(I_fade1,I_fade1,I_fade1);
int gridX=50;
@@ -97,8 +59,8 @@ void viewpoint::end(){
int yStep=ofGetHeight()/2;
ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ //todo: distort texcoords instead of vertex coords
for (float i = -1; i < 1.001; i+=(2.0f/gridY)){
-
glBegin(GL_QUAD_STRIP);
ofPoint p0;
ofPoint p1;
@@ -110,21 +72,16 @@ void viewpoint::end(){
glTexCoord2f((j+1)*0.5,(i+1)*0.5);
glVertex3f(p1.x*xStep,p1.y*yStep,-0.1);
}
-
glEnd();
- //
}
ofFill();
-
unbindTexture(renderFBO);
-
ofPopMatrix();
ofSetHexColor(0xFFFFFF);
ofDrawBitmapString("camera: "+ofToString(camera.getX(), 2)+","+ofToString(camera.getY(), 2)+","+ofToString(camera.getZ(), 2), 10, ofGetHeight()-30);
ofDrawBitmapString("light: "+ofToString(light.getX(), 2)+","+ofToString(light.getY(), 2)+","+ofToString(light.getZ(), 2), 10, ofGetHeight()-18);
-
}
//--------------------------------------------------------------
void viewpoint::keyPressed(int key){
diff --git a/src/viewpoint.h b/src/viewpoint.h
index 20da42d..e66dffa 100644
--- a/src/viewpoint.h
+++ b/src/viewpoint.h
@@ -15,7 +15,7 @@ class viewpoint {
public:
- void setup(int ln,float w, float h, float x, float y);
+ void setup(float w, float h, float x, float y);
void begin();
void end();
void keyPressed(int key);