Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
openFrameworks for iOSでデバイスの姿勢を取得する http://blog.hoppenichu.com/cpp/64
#import <CoreMotion/CoreMotion.h>
class testApp : public ofxiOSApp {
CMMotionManager *motionManager;
public:
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