Last active
January 17, 2019 19:46
-
-
Save chuganzy/8194504 to your computer and use it in GitHub Desktop.
openFrameworks for iOSでデバイスの姿勢を取得する http://blog.ganzy.jp/cpp/64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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