Skip to content

Commit

Permalink
moved meshFromCamera camera position code from mouseMoved to update s…
Browse files Browse the repository at this point in the history
…o it works before the mouse is moved
  • Loading branch information
kylemcdonald committed Apr 8, 2012
1 parent 18c5391 commit c0963e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
18 changes: 6 additions & 12 deletions examples/3d/meshFromCamera/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#include "ofMain.h"
#include "testApp.h"
#include "ofAppGlutWindow.h"

//========================================================================
int main( ){

ofAppGlutWindow window;
ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context

// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
// pass in width and height too:
ofRunApp( new testApp());

//--------------------------------------------------------------
int main(){
ofAppGlutWindow window; // create a window
// set width, height, mode (OF_WINDOW or OF_FULLSCREEN)
ofSetupOpenGL(&window, 1024, 768, OF_WINDOW);
ofRunApp(new testApp()); // start the app
}
26 changes: 13 additions & 13 deletions examples/3d/meshFromCamera/src/testApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ void testApp::update(){
mainMesh.setColor(i, sampleColor);
}
}

//let's move the camera when you move the mouse
float rotateAmount = ofMap(ofGetMouseY(), 0, ofGetHeight(), 0, 360);


//move the camera around the mesh
ofVec3f camDirection(0,0,1);
ofVec3f centre(vidGrabber.getWidth()/2.f,vidGrabber.getHeight()/2.f, 255/2.f);
ofVec3f camDirectionRotated = camDirection.rotated(rotateAmount, ofVec3f(1,0,0));
ofVec3f camPosition = centre + camDirectionRotated * extrusionAmount;

cam.setPosition(camPosition);
cam.lookAt(centre);
}

//--------------------------------------------------------------
Expand Down Expand Up @@ -121,19 +134,6 @@ void testApp::keyReleased(int key){
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){

//let's move the camera when you move the mouse
float rotateAmount = ofMap(ofGetMouseY(), 0, ofGetHeight(), 0, 360);


//move the camera around the mesh
ofVec3f camDirection(0,0,1);
ofVec3f centre(vidGrabber.getWidth()/2.f,vidGrabber.getHeight()/2.f, 255/2.f);
ofVec3f camDirectionRotated = camDirection.rotated(rotateAmount, ofVec3f(1,0,0));
ofVec3f camPosition = centre + camDirectionRotated * extrusionAmount;

cam.setPosition(camPosition);
cam.lookAt(centre);

}

//--------------------------------------------------------------
Expand Down

0 comments on commit c0963e1

Please sign in to comment.