Public Member Functions | Private Member Functions | Private Attributes

Wiiheadtrack Class Reference

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 $m$ and $d$ of the linear function $f(x) = m \cdot x + d$ for mapping the eye-distance to the position-distance.
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

Detailed Description

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.

Author:
Daniel Wunderlich (d.wunderlich@stud.uni-heidelberg.de)
Christian Rohrbeck (c.rohrbec@stud.uni-heidelberg.de)
Version:
0.1
Date:
2010-09-06

Constructor & Destructor Documentation

Wiiheadtrack::Wiiheadtrack ( WiihtMode  mode,
unsigned int  noWiimotes 
)

Constructor of the Wiiheadtrack-class.

Parameters:
noWiimotes The number of Wiimotes you want to connect.
mode There are two modes, you can Wiiheadtrack use with:

  • Object-mode: The virtual camera moves on the surface of a imaginary sphere, looking at the object in its center.
  • Room-mode: The virtual camera moves on a plane, simulating the user watching through the monitor as a window into a "room" behind it.
Returns:
A Wiiheadtrack-object.
See also:
The two modes
Wiiheadtrack::~Wiiheadtrack (  ) 

Deconstructor of the Wiiheadtrack-class.


Member Function Documentation

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.

See also:
Computation of the position
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.

See also:
Computation of the position
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.

See also:
getPos()
getPosRel()
Computation of the position
void Wiiheadtrack::computePosDistPar (  )  [private]

Computes the parameters $m$ and $d$ of the linear function $f(x) = m \cdot x + d$ for mapping the eye-distance to the position-distance.

See also:
The Sensitivity
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.

See also:
Computation of the position
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].

Returns:
A pointer to the 2-dimensional array saving the eye-distance.
See also:
The Sensitivity
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().

Returns:
A pointer to the 3-dimensional array saving the current position.
See also:
computePos()
Computation of the position
float * Wiiheadtrack::getPosDist (  ) 

This function is used for getting the position-distance posDist[2].

Returns:
A pointer to the 2-dimensional array saving the position-distance.
See also:
The Sensitivity
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().

Returns:
A pointer to the 3-dimensional array saving the current relative position.
See also:
computePos()
Computation of the position
float Wiiheadtrack::getSensitivity (  ) 

Get the sensitivity of Wiiheadtrack.

Returns:
The (x/y-)sensitivity of the Wiiheadtrack.
See also:
setSensitivity(float)
Sensitivity
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 (  ) 
void Wiiheadtrack::setCameraPos ( WiihtCamPos  pos  ) 

Set the position of the camera -- above or below the monitor.

Parameters:
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.

Parameters:
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.
See also:
setPosDist(float, float)
The Sensitivity
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.

Parameters:
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
See also:
setEyeDist(float, float);
The Sensitivity
void Wiiheadtrack::setScanTime ( unsigned int  time  ) 

Set the time (seconds) the program tries to connect to the wiimote. (Default: 5 seconds).

Parameters:
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.

Parameters:
sensitivity The new sensitivity. Must be greater 0.

Field Documentation

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]).

See also:
setEyeDist(float, float)
Sensitivity
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.

See also:
invertY()

The mode you want to use the Wiiheadtrack.

See also:
Wiiheadtrack(WiihtMode, unsigned int)
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.

See also:
setPosDist(float, float)
Sensitivity
float Wiiheadtrack::posDistPar[2] [private]

Parameters $m$ and $d$ of the linear function $f(x) = m \cdot x + d$ for mapping the eye-distance to the position-distance.

See also:
computePosDistPar()
Sensitivity
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.

See also:
setSensitivity(float)
Sensitivity
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.


The documentation for this class was generated from the following files:
 All Data Structures Files Functions Variables Enumerations Enumerator