C++-class for using the Nintento Wii Remote (Wiimote) in combination with IR-LEDs attached to the user's head as a headtracking-system in graphic libraries. More...
#include <wiiheadtrack.h>
Public Member Functions | |
Wiiheadtrack (WiihtMode mode, unsigned int noWiimotes) | |
Constructor of the Wiiheadtrack-class. | |
~Wiiheadtrack () | |
Deconstructor of the Wiiheadtrack-class. | |
void | computePos () |
Computes the current position (plane or spherical) of the user depending on the mode in 3 dimensions. | |
void | connect () |
Sets up the connection to the Wiimote. | |
void | enable () |
Enable Wiiheadtrack. | |
void | disable () |
Disable Wiiheadtrack. | |
void | invertY () |
Because some systems invert the y-value of the current position, this function allows to invert the y-Axis position. | |
bool | isConnected () |
Indicates, if Wiiheadtrack is connected to one or more Wiimote(s). | |
bool | isEnabled () |
Indicates, if Wiiheadtrack is enabled. | |
void | printStatus () |
Prints several information about the current status of the Wiiheadtracker on cammand-line. | |
float * | getEyeDist () |
This function is used for getting the eye-distance eyeDist[2]. | |
float * | getPosDist () |
This function is used for getting the position-distance posDist[2]. | |
float * | getPos () |
This function is used for accessing the current position (plane or spherical) of the user depending on the mode. | |
float * | getPosRel () |
This function is used for accessing the current relative position (plane or spherical) of the user depending on the mode. | |
float | getSensitivity () |
Get the sensitivity of Wiiheadtrack. | |
void | setCameraPos (WiihtCamPos pos) |
Set the position of the camera -- above or below the monitor. | |
void | setEyeDist (float distCenter, float distNear) |
Set the "normal" an the smallest distance between the eyes/user an the camera. | |
void | setScanTime (unsigned int time) |
Set the time (seconds) the program tries to connect to the wiimote. (Default: 5 seconds). | |
void | setSensitivity (float sensitivity) |
Set the sensitivity of Wiiheadtrack. (Default: 60.0 (object-mode), 1.0 (room-mode)). | |
void | setPosDist (float distCenter, float distNear) |
Set the "normal" an the smallest distance between the (virtual) position an the (virtual) camera-center. | |
Private Member Functions | |
void | computeEyePos () |
Detects the position of the user on the imaginary screen seen by the "camera". | |
void | computePlanePos () |
Transforms the position of the user detected by computeEyePos() to a virtual position on a plane, regarding the sensitivity. Used in room-mode. | |
void | computePosDistPar () |
Computes the parameters ![]() ![]() ![]() | |
void | computeSpherePos () |
Maps the position of the user detected by computeEyePos() to a virtual position on a sphere, regarding the sensitivity. Used in object-mode. | |
Private Attributes | |
WiihtMode | mode |
wiimote ** | wiimotes |
bool | connected |
bool | enabled |
int | invY |
unsigned int | noWiimotes |
unsigned int | foundWiimotes |
unsigned int | connectedWiimotes |
unsigned int | scanTime |
float | eyeDist [2] |
float | posDist [2] |
float | posDistPar [2] |
float | eyeL [2] |
float | eyeR [2] |
float | eyeC [2] |
float | eyeZ |
float | pos [3] |
float | posRel [3] |
const int | wiimoteCamNo |
float | sensitivity |
float | phi |
float | theta |
float | radius |
C++-class for using the Nintento Wii Remote (Wiimote) in combination with IR-LEDs attached to the user's head as a headtracking-system in graphic libraries.
Wiiheadtrack::Wiiheadtrack | ( | WiihtMode | mode, | |
unsigned int | noWiimotes | |||
) |
Constructor of the Wiiheadtrack-class.
noWiimotes | The number of Wiimotes you want to connect. | |
mode | There are two modes, you can Wiiheadtrack use with:
|
Wiiheadtrack::~Wiiheadtrack | ( | ) |
Deconstructor of the Wiiheadtrack-class.
void Wiiheadtrack::computeEyePos | ( | ) | [private] |
Detects the position of the user on the imaginary screen seen by the "camera".
After detecting the position of the left (eyeL) and the right (eyeR) eye, the function calculates the point between the eyes. It also detects the z-value of the position of the users eyes seen by the Wiimote-camera.
void Wiiheadtrack::computePlanePos | ( | ) | [private] |
Transforms the position of the user detected by computeEyePos() to a virtual position on a plane, regarding the sensitivity. Used in room-mode.
void Wiiheadtrack::computePos | ( | ) |
Computes the current position (plane or spherical) of the user depending on the mode in 3 dimensions.
The results are are saved in a private array. For getting access to the results, use the getPos()- or getPosRel()-function.
void Wiiheadtrack::computePosDistPar | ( | ) | [private] |
Computes the parameters and
of the linear function
for mapping the eye-distance to the position-distance.
void Wiiheadtrack::computeSpherePos | ( | ) | [private] |
Maps the position of the user detected by computeEyePos() to a virtual position on a sphere, regarding the sensitivity. Used in object-mode.
void Wiiheadtrack::connect | ( | ) |
Sets up the connection to the Wiimote.
After searching for available Wiimotes, the function tries to connect to them. It also sets the default position for the "camera" (WIIHT_BELOW) and enables the IR-tracking. You can set the time it tries connect with the help of setScanTime(unsigned int).
void Wiiheadtrack::disable | ( | ) |
Disable Wiiheadtrack.
Calling computePos() will not change the position anymore.
void Wiiheadtrack::enable | ( | ) |
Enable Wiiheadtrack.
After connecting to a Wiimote, Wiiheadtrack is enabled by default.
float * Wiiheadtrack::getEyeDist | ( | ) |
This function is used for getting the eye-distance eyeDist[2].
float * Wiiheadtrack::getPos | ( | ) |
This function is used for accessing the current position (plane or spherical) of the user depending on the mode.
The position previously must be computed by computePos().
float * Wiiheadtrack::getPosDist | ( | ) |
This function is used for getting the position-distance posDist[2].
float * Wiiheadtrack::getPosRel | ( | ) |
This function is used for accessing the current relative position (plane or spherical) of the user depending on the mode.
The position previously must be computed by computePos().
float Wiiheadtrack::getSensitivity | ( | ) |
Get the sensitivity of Wiiheadtrack.
void Wiiheadtrack::invertY | ( | ) |
Because some systems invert the y-value of the current position, this function allows to invert the y-Axis position.
bool Wiiheadtrack::isConnected | ( | ) |
Indicates, if Wiiheadtrack is connected to one or more Wiimote(s).
bool Wiiheadtrack::isEnabled | ( | ) |
Indicates, if Wiiheadtrack is enabled.
void Wiiheadtrack::printStatus | ( | ) |
Prints several information about the current status of the Wiiheadtracker on cammand-line.
It prints: Wiiheadtrack::connected, Wiiheadtrack::mode, Wiiheadtrack::eyeDist, Wiiheadtrack::posDist, Wiiheadtrack::sensitivity, Wiiheadtrack::eyeL, Wiiheadtrack::eyeC, Wiiheadtrack::eyeR, Wiiheadtrack::eyeZ, Wiiheadtrack::phi, Wiiheadtrack::theta, Wiiheadtrack::pos, Wiiheadtrack::posRel.
void Wiiheadtrack::setCameraPos | ( | WiihtCamPos | pos | ) |
Set the position of the camera -- above or below the monitor.
pos | A WiihtCamPos-value. |
void Wiiheadtrack::setEyeDist | ( | float | distCenter, | |
float | distNear | |||
) |
Set the "normal" an the smallest distance between the eyes/user an the camera.
The distances are used for configuring the sensitivity in z-direction.
distCenter | The "normal" distance between the eye/user and the camera. Must be greater than distNear and greater than 0. | |
distNear | The smallest distance between the eye/user and the camera. Must be greater than 0. |
void Wiiheadtrack::setPosDist | ( | float | distCenter, | |
float | distNear | |||
) |
Set the "normal" an the smallest distance between the (virtual) position an the (virtual) camera-center.
The distances are used for configuring the sensitivity in z-direction.
distCenter | The "normal" distance between the camera and the center. Must be greater than distNear and greater than 0. | |
distNear | The smallest distance between the camera and the center. Must be greater than or equal to 0 |
void Wiiheadtrack::setScanTime | ( | unsigned int | time | ) |
Set the time (seconds) the program tries to connect to the wiimote. (Default: 5 seconds).
time | The time in seconds. |
void Wiiheadtrack::setSensitivity | ( | float | sensitivity | ) |
Set the sensitivity of Wiiheadtrack. (Default: 60.0 (object-mode), 1.0 (room-mode)).
The sensitivity describes, how intense the camera moves depending on the head-movement.
sensitivity | The new sensitivity. Must be greater 0. |
bool Wiiheadtrack::connected [private] |
Indicates, if Wiiheadtrack is connected to one or more Wiimote(s)
unsigned int Wiiheadtrack::connectedWiimotes [private] |
Number of Wiimotes connected with in the connect()-function.
bool Wiiheadtrack::enabled [private] |
Indicates, if Wiiheadtracking is enabled.
float Wiiheadtrack::eyeC[2] [private] |
2-dimensional position of the point between the user's eyes on the imaginary screen seen by the camera.
float Wiiheadtrack::eyeDist[2] [private] |
Distance between the eye/user and the camera: "normal" distance (eyeDist[0]), nearest position to the camera (eyeDist[1]).
float Wiiheadtrack::eyeL[2] [private] |
2-dimensional position of the user's left eye on the imaginary screen seen by the camera.
float Wiiheadtrack::eyeR[2] [private] |
2-dimensional position of the user's right eye on the imaginary screen seen by the camera.
float Wiiheadtrack::eyeZ [private] |
Distance between the Wiimote-camera and the user's eyes.
unsigned int Wiiheadtrack::foundWiimotes [private] |
Number of Wiimotes found by scanning in the connect()-function.
int Wiiheadtrack::invY [private] |
Some systems invert the y-Value. This variable helps to fix this error. Inverted=-1, not inverted=1.
WiihtMode Wiiheadtrack::mode [private] |
The mode you want to use the Wiiheadtrack.
unsigned int Wiiheadtrack::noWiimotes [private] |
Number of Wiimotes you want to connect. Default: 1
float Wiiheadtrack::phi [private] |
float Wiiheadtrack::pos[3] [private] |
Position computed by computePos(), depending on the mode.
float Wiiheadtrack::posDist[2] [private] |
Distance between the "normal" virtual position an the nearest virtual position.
float Wiiheadtrack::posDistPar[2] [private] |
Parameters and
of the linear function
for mapping the eye-distance to the position-distance.
float Wiiheadtrack::posRel[3] [private] |
Change of pos[3] since the last call of computePos() (relative Position).
float Wiiheadtrack::radius [private] |
Values for calculating the spherical coordinates of the virtual camera/position.
unsigned int Wiiheadtrack::scanTime [private] |
Time (seconds) Wiiheadtrack searches for Wiimotes in the connect()-function.
float Wiiheadtrack::sensitivity [private] |
A factor which declares, how intense the movement (left/right, up/down) of the user moves the virtual camera.
float Wiiheadtrack::theta [private] |
const int Wiiheadtrack::wiimoteCamNo [private] |
Indicates, which of the connected Wiimotes is used as the camera. Default: 1.
wiimote** Wiiheadtrack::wiimotes [private] |
Array of the Wiimotes.