SLProject 4.0.000
|
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-SLProject/android and app_demo_slproject/ios how the sensor data is generated and passed to this object hold by AppDemo. 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).
SLDeviceRotation::SLDeviceRotation | ( | ) |
|
inline |
void SLDeviceRotation::init | ( | ) |
|
inline |
void SLDeviceRotation::isUsed | ( | SLbool | isUsed | ) |
Setter that turns on the device rotation sensor.
|
inline |
void SLDeviceRotation::numAveraged | ( | SLint | numAvg | ) |
Returns the device rotation averaged over multple frames.
|
inline |
|
inline |
SLstring SLDeviceRotation::offsetModeStr | ( | ) | const |
Returns the rotation offset mode as string.
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)
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
Flag for the first sensor values.
|
private |
Flag if device rotation is used.
|
private |
Rotation offset mode.
|
private |
Device pitch angle in radians.
|
private |
|
private |
Device roll angle in radians.
|
private |
Mobile device rotation as matrix.
|
private |
Initial yaw angle after _zeroYawAfterSec in radians.
|
private |
Calculate roll pitch yaw in onRotationQUAT.
|
private |
Device yaw angle in radians.
|
private |
Quaternion rotation that is set by IMU.
Flag if yaw angle should be zeroed at sensor start