From 3badbcdf8d8a0005543521849694fa481dfce628 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 22 Mar 2012 17:44:49 +0000 Subject: ray hit working --- rayhit/rayhit.layout | 7 +++-- rayhit/src/testApp.cpp | 84 ++++++++++++++++++++++++++++++++++++-------------- rayhit/src/testApp.h | 8 +++-- 3 files changed, 71 insertions(+), 28 deletions(-) diff --git a/rayhit/rayhit.layout b/rayhit/rayhit.layout index e2e5d2f..52f6b25 100644 --- a/rayhit/rayhit.layout +++ b/rayhit/rayhit.layout @@ -7,8 +7,11 @@ - - + + + + + diff --git a/rayhit/src/testApp.cpp b/rayhit/src/testApp.cpp index 750287c..78a3890 100644 --- a/rayhit/src/testApp.cpp +++ b/rayhit/src/testApp.cpp @@ -2,19 +2,34 @@ //-------------------------------------------------------------- void testApp::setup(){ - ofVec3f centre=ofVec3f(ofGetWidth()/2,ofGetHeight(),0); - ofVec3f normal=ofVec3f(0,0,1); + ofVec3f centre=ofVec3f(ofGetWidth()/2,0,0); + ofVec3f normal=ofVec3f(0,0,-1); ray=ofRay(); plane=ofPlane(centre,normal); - - projector=ofProjector(ofGetWidth(),ofGetHeight()); - + plane.color=ofColor(255,255,255); + + //Projector::Projector(float throwRatio, const ofVec2f& lensOffset, int width, int height) + projector=ofProjector(1.535f, ofVec2f(0.0f, 0.5f),ofGetWidth(),ofGetHeight()); + projector.setPosition(ofGetWidth()/2,ofGetHeight()/2,ofGetHeight()); + pos=ofVec3f(ofGetWidth()/2,ofGetHeight()/2,0); + + cam=ofCamera(); + //cam defaults to (0,0,0); + cam.setPosition(ofGetWidth()/2,ofGetHeight()/2,ofGetHeight()); + //cam.setOrientation(ofVec3f(0,0,1)); + cam.lookAt(ofVec3f(ofGetWidth()/2,ofGetHeight()/2,0)); + cam.setFov(54.13); + //ofVec3f campoint=cam.getLookAtDir(); + //printf("camera at %f,%f,%f looking %f,%f,%f\n",cam.getX(),cam.getY(),cam.getZ(),campoint.x,campoint.y,campoint.z); + cam_angle=0; + + //projector=ofProjector(cam.getProjectionMatrix(ofRectangle(0,0,ofGetWidth(),ofGetHeight())),ofGetWidth(),ofGetHeight()); } //-------------------------------------------------------------- void testApp::update(){ - + } @@ -22,30 +37,41 @@ void testApp::update(){ //-------------------------------------------------------------- void testApp::draw(){ ofBackground(0,0,0); + + cam.begin(); + plane.draw(); - - float gap=ofGetHeight()-ofGetWidth(); - + ofPushMatrix(); - ofTranslate(0,ofGetHeight(),0); + //ofTranslate(0,ofGetHeight(),0); ofRotate(cam_angle,1,0,0); - ofTranslate(0,-ofGetHeight(),0); + //ofTranslate(0,-ofGetHeight(),0); for (float i=0;i