i’m new to openFrameworks, but it seems really easy. i have a little experience with Processing, and decided to start playing around with openFrameworks for the iPhone.
the first day i coded a simple app (a clock… not to complex, but i’m taking baby steps here).
it’s working great, but want it to change when the iphone is sideways or upside down, so that the numbers rotate to become legible. is there any special function to detect this, or do i need to use objective C to detect the change in orientation?
waht i am looking for is a function that would give me a value like left, right, up or down (could also be an angle like 90, -90, 180) so i know wich way to rotate the letters…
any hints?
many thanks,
Bruno
p.s. i really loved the cat pictures in the registration process
it seems it is a ofPoint type value that is returned. i don’t find any references to ofPoint in the API Documentation in the wiki.
i am a bit lost here, and it seems to be quite simple.
i’d really appreciate some tips.
hey, the full comments for that function in ofxAccelerometer.h should be:
// returns current orientation in degrees (x: pitch, y: roll, z: not used)
ofPoint &getOrientation() {
updateOrientation();
return orientation;
}
so you can use it by doing (in your testApp.cpp or any other cpp):
ofPoint orientation = ofxAccelerometer.getOrientation();
orientation.x is the pitch
orientation.y is the roll
Note, if you want to use the iphone orientation to orient a 3D object in 3D space you are better off using getMatrix(); This returns a float* which contains the orientation matrix which you can pass directly to opengl using glMultMatrixf
“Note, if you want to use the iphone orientation to orient a 3D object in 3D space you are better off using getMatrix(); This returns a float* which contains the orientation matrix which you can pass directly to opengl using glMultMatrixf” <- this seems way out of my league… i’m just starting with open frameworks.
my purpose is to rotate the elements on-screen like the iphone safari does, if it’s sideways, it rotates the screen elements sideways in order to be more legible. (it’s a series of clocks i’m making, so when sideways or upside down, you can read the numbers / text / drawings to see the time).
ah, for that you don’t even need to check the accelerometer and do fancy math to see the device orientation. You can simply (using objective c - rename your .cpp to .mm) check
You can check the orientation every frame and draw accordingly, but if you want you can also register for the device orientation notification and not check every frame. More info at http://developer.apple.com/iphone/libra-…-evice.html