SLProject
4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
|
Encapsulation of a mobile device rotation set by the device's IMU sensor. More...
#include <SLDeviceRotation.h>
Public Member Functions | |
SLDeviceRotation () | |
void | init () |
void | onRotationQUAT (SLfloat quatX, SLfloat quatY, SLfloat quatZ, SLfloat quatW) |
void | isUsed (SLbool isUsed) |
Setter that turns on the device rotation sensor. More... | |
void | hasStarted (SLbool started) |
void | zeroYawAtStart (SLbool zeroYaw) |
void | numAveraged (SLint numAvg) |
Returns the device rotation averaged over multple frames. More... | |
void | offsetMode (SLRotOffsetMode rom) |
void | updateRPY (SLbool doUpdate) |
SLbool | isUsed () const |
SLMat3f | rotation () const |
SLMat3f | rotationAveraged () |
SLQuat4f | quaternion () const |
SLfloat | pitchRAD () const |
SLfloat | pitchDEG () const |
SLfloat | yawRAD () const |
SLfloat | yawDEG () const |
SLfloat | rollRAD () const |
SLfloat | rollDEG () const |
SLbool | zeroYawAtStart () const |
SLfloat | startYawRAD () const |
SLint | numAveraged () |
SLRotOffsetMode | offsetMode () |
SLstring | offsetModeStr () const |
Returns the rotation offset mode as string. More... | |
SLbool | updateRPY () const |
Private Attributes | |
SLbool | _isUsed |
Flag if device rotation is used. More... | |
SLbool | _isFirstSensorValue |
Flag for the first sensor values. More... | |
SLfloat | _pitchRAD |
Device pitch angle in radians. More... | |
SLfloat | _yawRAD |
Device yaw angle in radians. More... | |
SLfloat | _rollRAD |
Device roll angle in radians. More... | |
SLMat3f | _rotation |
Mobile device rotation as matrix. More... | |
Averaged< SLMat3f > | _rotationAvg |
Component wise averaged rotation matrix. More... | |
SLQuat4f | _quaternion |
SLbool | _zeroYawAtStart |
Quaternion rotation that is set by IMU. More... | |
SLfloat | _startYawRAD |
Initial yaw angle after _zeroYawAfterSec in radians. More... | |
SLRotOffsetMode | _offsetMode |
Rotation offset mode. More... | |
SLbool | _updateRPY |
Calculate roll pitch yaw in onRotationQUAT. More... | |
Encapsulation of a mobile device rotation set by the device's IMU sensor.
This class is only used if SLProject runs on a mobile device. Check out the app-demo/android and app_demo_slproject/ios how the sensor data is generated and passed to this object hold by AppCommon. It stores the devices rotation that it gets from its IMU (inertial measurement unit) sensor. This is a fused orientation that is calculated from the magnetometer, the accelerometer and the gyroscope. The device rotation can be used in the active camera to apply it to the scene camera (s. SLCamera::setView).
Definition at line 39 of file SLDeviceRotation.h.
SLDeviceRotation::SLDeviceRotation | ( | ) |
Definition at line 14 of file SLDeviceRotation.cpp.
Definition at line 50 of file SLDeviceRotation.h.
void SLDeviceRotation::init | ( | ) |
Definition at line 19 of file SLDeviceRotation.cpp.
|
inline |
Definition at line 57 of file SLDeviceRotation.h.
Setter that turns on the device rotation sensor.
Definition at line 105 of file SLDeviceRotation.cpp.
|
inline |
Definition at line 69 of file SLDeviceRotation.h.
Returns the device rotation averaged over multple frames.
Definition at line 114 of file SLDeviceRotation.cpp.
|
inline |
Definition at line 70 of file SLDeviceRotation.h.
|
inline |
Definition at line 53 of file SLDeviceRotation.h.
SLstring SLDeviceRotation::offsetModeStr | ( | ) | const |
void SLDeviceRotation::onRotationQUAT | ( | SLfloat | quatX, |
SLfloat | quatY, | ||
SLfloat | quatZ, | ||
SLfloat | quatW | ||
) |
onRotationQUAT: Event handler for rotation change of a mobile device from a rotation quaternion. This function will only be called in an Android or iOS project. See e.g. onSensorChanged in GLES3Activity.java in the Android project. This handler is only called if the flag SLScene::_usesRotation is true. If so the mobile device turns on it's IMU sensor system. The device rotation is so far only used in SLCamera::setView if the cameras animation is on CA_deciveRotYUp. If _zeroYawAfterStart is true the start yaw value is subtracted. This means that the magnetic north will be ignored. The angles should be:
Roll from -halfpi (ccw) to zero (horizontal) to +halfpi (clockwise)
Pitch from -halfpi (down) to zero (horizontal) to +halfpi (up)
Yaw from -pi (south) to zero (north) to +pi (south)
Definition at line 47 of file SLDeviceRotation.cpp.
|
inline |
Definition at line 62 of file SLDeviceRotation.h.
|
inline |
Definition at line 61 of file SLDeviceRotation.h.
|
inline |
Definition at line 60 of file SLDeviceRotation.h.
|
inline |
Definition at line 66 of file SLDeviceRotation.h.
|
inline |
Definition at line 65 of file SLDeviceRotation.h.
|
inline |
Definition at line 58 of file SLDeviceRotation.h.
|
inline |
Definition at line 59 of file SLDeviceRotation.h.
|
inline |
Definition at line 68 of file SLDeviceRotation.h.
|
inline |
Definition at line 72 of file SLDeviceRotation.h.
Definition at line 54 of file SLDeviceRotation.h.
|
inline |
Definition at line 64 of file SLDeviceRotation.h.
|
inline |
Definition at line 63 of file SLDeviceRotation.h.
|
inline |
Definition at line 67 of file SLDeviceRotation.h.
Definition at line 51 of file SLDeviceRotation.h.
|
private |
Flag for the first sensor values.
Definition at line 76 of file SLDeviceRotation.h.
|
private |
Flag if device rotation is used.
Definition at line 75 of file SLDeviceRotation.h.
|
private |
Rotation offset mode.
Definition at line 85 of file SLDeviceRotation.h.
|
private |
Device pitch angle in radians.
Definition at line 77 of file SLDeviceRotation.h.
|
private |
Definition at line 82 of file SLDeviceRotation.h.
|
private |
Device roll angle in radians.
Definition at line 79 of file SLDeviceRotation.h.
|
private |
Mobile device rotation as matrix.
Definition at line 80 of file SLDeviceRotation.h.
Component wise averaged rotation matrix.
Definition at line 81 of file SLDeviceRotation.h.
|
private |
Initial yaw angle after _zeroYawAfterSec in radians.
Definition at line 84 of file SLDeviceRotation.h.
|
private |
Calculate roll pitch yaw in onRotationQUAT.
Definition at line 86 of file SLDeviceRotation.h.
|
private |
Device yaw angle in radians.
Definition at line 78 of file SLDeviceRotation.h.
|
private |
Quaternion rotation that is set by IMU.
Flag if yaw angle should be zeroed at sensor start
Definition at line 83 of file SLDeviceRotation.h.