Skip to content

Instantly share code, notes, and snippets.



Last active Jan 17, 2019
What would you like to do?
openFrameworks for iOSでデバイスの姿勢を取得する
#import <CoreMotion/CoreMotion.h>
class testApp : public ofxiOSApp {
CMMotionManager *motionManager;
void setup();
void update();
void draw();
void exit();
void touchDown(ofTouchEventArgs & touch);
void touchMoved(ofTouchEventArgs & touch);
void touchUp(ofTouchEventArgs & touch);
void touchDoubleTap(ofTouchEventArgs & touch);
void touchCancelled(ofTouchEventArgs & touch);
void lostFocus();
void gotFocus();
void gotMemoryWarning();
void deviceOrientationChanged(int newOrientation);
void testApp::setup() {
motionManager = [[CMMotionManager alloc] init];
[motionManager startDeviceMotionUpdates];
void testApp::update() {
cout << motionManager.deviceMotion.attitude.pitch * RAD_TO_DEG << endl; // X軸回転
cout << motionManager.deviceMotion.attitude.roll * RAD_TO_DEG << endl; // Y軸回転
cout << motionManager.deviceMotion.attitude.yaw * RAD_TO_DEG << endl; // Z軸回転
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment