summaryrefslogtreecommitdiff
path: root/src/testApp.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-01-02 01:40:11 +0000
committerTim Redfern <tim@eclectronics.org>2012-01-02 01:40:11 +0000
commit8b005ba4cebd9909496e0d032770efe9844b5675 (patch)
tree963ab648ba0876099830edbbd93d9becee96259c /src/testApp.cpp
parenta728ca18def61a13bbd7d0680dfab011d7ea20ac (diff)
camera light orbiting not working
Diffstat (limited to 'src/testApp.cpp')
-rw-r--r--src/testApp.cpp78
1 files changed, 9 insertions, 69 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp
index 10dbdf4..0d42e85 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -1,11 +1,5 @@
#include "testApp.h"
-GLfloat lightOnePosition[] = {40.0, 40, 100.0, 0.0};
-GLfloat lightOneColor[] = {0.99, 0.99, 0.99, 0.5};
-
-GLfloat lightTwoPosition[] = {-40.0, 40, 100.0, 0.0};
-GLfloat lightTwoColor[] = {0.99, 0.99, 0.99, 0.5};
-
//--------------------------------------------------------------
void testApp::setup(){
ofBackground(0,0,0);
@@ -17,43 +11,27 @@ void testApp::setup(){
glShadeModel (GL_SMOOTH);
/* initialize lighting */
- glLightfv (GL_LIGHT0, GL_POSITION, lightOnePosition);
- glLightfv (GL_LIGHT0, GL_DIFFUSE, lightOneColor);
- glEnable (GL_LIGHT0);
- glLightfv (GL_LIGHT1, GL_POSITION, lightTwoPosition);
- glLightfv (GL_LIGHT1, GL_DIFFUSE, lightTwoColor);
- glEnable (GL_LIGHT1);
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);
- board.loadModel("box.3DS", 1);
bottle.setRotation(0, 180, 1, 0, 0);
- board.setRotation(0, 180, 1, 0, 0);
+ bottle.setPosition(0, 112, 0);
- //you can create as many rotations as you want
- //choose which axis you want it to effect
- //you can update these rotations later on
- //bottleModel.setRotation(0, -90, 1, 0, 0);
- //bottleModel.setRotation(1, 270, 0, 0, 1);
- //bottleModel.setScale(0.9, 0.9, 0.9);
- bottle.setPosition(0, 0, -50);
- board.setPosition(0, 0, -50);
//ofDisableArbTex();
texture.loadMovie("gradblend01.mov");
texture.play();
- mode=NOTHING;
+ mode=CALIBRATE;
views=new viewpoint[1];
//todo: read this from xml
- views[0].setup(ofGetWidth(),ofGetHeight(),0,0);
-
+ views[0].setup(GL_LIGHT0,ofGetWidth(),ofGetHeight(),0,0);
activeView=0;
@@ -61,75 +39,37 @@ void testApp::setup(){
//--------------------------------------------------------------
void testApp::update(){
- board.setRotation(1, 270 + ofGetElapsedTimef() * 60, 0, 1, 0);
texture.idleMovie();
}
//--------------------------------------------------------------
void testApp::draw(){
- //ofPushView();
- //glMatrixMode(GL_PROJECTION);
- //glLoadIdentity();
- //gluPerspective(fov,aspect,near,far);
- // glTranslatef(0,0,-1000);
- //glMatrixMode(GL_MODELVIEW);
- // glLoadMatrixf(ofMatrix4x4::getInverseOf(getGlobalTransformMatrix()).getPtr());
-
- //glEnable(GL_LIGHTING);
- //ofRectangle vp=ofRectangle(0,0,ofGetWidth(),ofGetHeight());
- //camera.setFov(fov);
-
-
- views[0].begin();
+ views[0].setLight();
+ views[0].begin();
ofSetColor(255, 255, 255, 255);
ofFill();
-
switch(mode) {
case CALIBRATE:
-
- int cx,cz;
-
- glFrontFace(GL_CW);
- glBegin(GL_QUADS);
- for (int i=0;i<8;i++) {
- for (int j=0;j<4;j++) {
- cx=((i%2)*16)+(j*32)-56;
- cz=(i*16)-56;
- glVertex3f(cx+8, 0, cz-8);
- glVertex3f(cx+8, 0, cz+8);
- glVertex3f(cx-8, 0, cz+8);
- glVertex3f(cx-8, 0, cz-8);
-
- }
- }
- glEnd();
-
+ drawBoard(0,225,0);
bottle.draw();
-
break;
case DISPLAY:
-
- board.draw();
bindTexture(texture);
bottle.draw();
unbindTexture(texture);
break;
- case NOTHING:
-
+ case NOTHING:
bindTexture(texture);
- glPushMatrix();
+ glPushMatrix();
drawBox(50.0f);
unbindTexture(texture);
- glPopMatrix();
+ glPopMatrix();
break;
}
-
views[0].end();
-
ofSetHexColor(0xFFFFFF);
ofDrawBitmapString("fps: "+ofToString(ofGetFrameRate(), 2), 10, 15);
-
}
//--------------------------------------------------------------