Skip to content
Browse files

moved meshFromCamera camera position code from mouseMoved to update s…

…o it works before the mouse is moved
  • Loading branch information...
1 parent 18c5391 commit c0963e1a281a5d7bd9d0ef70a7233f63efe73cd4 @kylemcdonald kylemcdonald committed Apr 7, 2012
Showing with 19 additions and 25 deletions.
  1. +6 −12 examples/3d/meshFromCamera/src/main.cpp
  2. +13 −13 examples/3d/meshFromCamera/src/testApp.cpp
View
18 examples/3d/meshFromCamera/src/main.cpp
@@ -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
}
View
26 examples/3d/meshFromCamera/src/testApp.cpp
@@ -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);
}
//--------------------------------------------------------------
@@ -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);
-
}
//--------------------------------------------------------------

0 comments on commit c0963e1

Please sign in to comment.
Something went wrong with that request. Please try again.