#include <Control.h>
Public Types | |
enum | ESwitchId { NONE = 0, FORWARD, BACKWARD, LEFT, RIGHT, STRAFE_LEFT, STRAFE_RIGHT, UP, DOWN, ROLL_LEFT, ROLL_RIGHT, JUMP, CROUCH, FAST_TOGGLE, ALWAYS_FAST, FASTER, SLOWER, FIRE1, FIRE2, FIRE3, FIRE4, FIRE5, WEAPON_NEXT, WEAPON_PREV, WEAPON_TOGGLE, WEAPON1, WEAPON2, WEAPON3, WEAPON4, WEAPON5, WEAPON6, WEAPON7, WEAPON8, WEAPON9, WEAPON10, WEAPON11, WEAPON12, WEAPON13, WEAPON14, WEAPON15, WEAPON16, WEAPON17, WEAPON18, WEAPON19, WEAPON20, DROP_WEAPON, DROP_ALTERNATE, TARGET, TARGET_NEXT, TARGET_PREV, SHOW_INFO, VIEW_NEXT, VIEW_PREV, ZOOM_IN, ZOOM_OUT, VIEW1, VIEW2, VIEW3, VIEW4, VIEW5, VIEW6, VIEW7, VIEW8, VIEW9, VIEW10, VIEW11, VIEW12, VIEW13, VIEW14, VIEW15, PAUSE, SCREENSHOT, TOGGLE_FULLSCREEN, BRAKE, RESET, MENU, SCORE_MENU, OK, CANCEL, MAX_STARNDARD_SWITCH, USER_SWITCH_0 = MAX_STARNDARD_SWITCH, MAX_SWITCH = USER_SWITCH_0 + NB_USER_SWITCHES } |
Switches enum, containing 'standard' switches and room for custom (user's) ones. More... | |
enum | EAxisId { AXIS_X = 0, AXIS_Y, AXIS_Z, AXIS_SCROLL_1, AXIS_SCROLL_2, AXIS_SCROLL_3, AXIS_SCROLL_4, MAX_AXIS } |
Remember to update the textual representation (axisNames in the .cpp) of this enum when modyfing ! More... | |
Public Member Functions | |
ControlState () | |
ControlState & | operator+= (ESwitchId switchId) |
Convinience operator, same as set(switchId). | |
ControlState & | operator-= (ESwitchId switchId) |
Convinience operator, same as reset(switchId). | |
bool | operator[] (ESwitchId switchId) const |
Convinience operator, same as get(switchId). | |
void | set (ESwitchId switchId) |
Sets a switch to be enabled. | |
void | reset (ESwitchId switchId) |
Sets a switch to be disabled. | |
bool | get (ESwitchId switchId) const |
Gets the state of a switch. | |
void | resetAllSwitches () |
Resets all switches. | |
void | setAxis (EAxisId axis, float val) |
Sets an axis to a value. | |
void | addToAxis (EAxisId axis, float val) |
Adds a value to an axis' current value. | |
float | getAxis (EAxisId axis) const |
Gets an axis value. | |
void | resetAxis (EAxisId axis) |
Same as setAxis(axis, 0). | |
void | resetAllAxis () |
Same as resetAxis() for all axis. | |
bool | isAxisZero (EAxisId axis, float epsilon=0.0001f) |
Tests an axis for zero equality (with an epsilon). | |
bool | testAnySwitchOn () const |
Very quickly tests (O(1)) if any switch is on (false means all switches are reset). | |
bool | testAnyAxisOn (float epsilon=1e-4f) const |
Tests each axis (O(MAX_AXIS)) to see if anyone is non zero (Thus false means that all axis are reset). | |
bool | testAnyControlOn (float epsilon=0.0001f) const |
Convinience method that returns testAnySwitchOn() || testAnyAxisOn(epsilon). | |
void | setPointer (float pointerX, float pointerY) |
Sets the pointer to be at a given position (does not actually moves the system pointer, but changes the coordinates stored in the class). | |
void | setPointer (const osg::Vec3f &pointer) |
osg::Vec3f | getPointer () const |
Gets the pointer position. | |
float | getPointerX () const |
Convinience method to get the pointer X position. | |
float | getPointerY () const |
Convinience method to get the pointer Y position. | |
osg::Vec3f | getPickPosition () const |
Gets the pointer pick position. | |
void | setPickPosition (const osg::Vec3f &pickPos) |
Sets the pointer pick position. | |
Static Public Attributes | |
static const UINT | NB_USER_SWITCHES = 30 |
Maximum number of custom (user's) switches. These custom swithces are defined by the application. | |
Protected Attributes | |
UINT | nbSwitchesOn |
std::bitset< MAX_SWITCH > | vSwitchs |
float | pAxis [MAX_AXIS] |
osg::Vec3f | pointer |
osg::Vec3f | pickPos |
Used by piloting interfaces and IA interfaces, so they only know about controls, not inputs.
Definition at line 42 of file Control.h.
Switches enum, containing 'standard' switches and room for custom (user's) ones.
This enum declares the switches that are considered to be 'common'. To use your own custom switches, just give textual representation to functions that need it (like loadBindings()). Of course, you may want to create an enum in your application that describes those switches. In that case, be sure to set the fisrt value to USER_SWITCH_0 and not create more than NB_USER_SWITCHES switches. Remember to update the textual representation (switchesNames in the .cpp) of this enum when modyfing !
ControlState::ControlState | ( | ) |
void ControlState::addToAxis | ( | EAxisId | axis, | |
float | val | |||
) | [inline] |
Adds a value to an axis' current value.
Definition at line 108 of file Control.h.
References ASSERT.
Referenced by Controler::axisMove().
bool ControlState::get | ( | ESwitchId | switchId | ) | const [inline] |
float ControlState::getAxis | ( | EAxisId | axis | ) | const [inline] |
Gets an axis value.
Definition at line 110 of file Control.h.
References ASSERT.
Referenced by HumanMatrixGetter::handleFrame().
osg::Vec3f ControlState::getPickPosition | ( | ) | const [inline] |
Gets the pointer pick position.
The pick position is a 3D point where the mouse "points to"; that is to say the intersection between the half-line [Camera; mouse pointer) and an object.
osg::Vec3f ControlState::getPointer | ( | ) | const [inline] |
float ControlState::getPointerX | ( | ) | const [inline] |
Convinience method to get the pointer X position.
Definition at line 140 of file Control.h.
Referenced by ControlMapper::computePickPos().
float ControlState::getPointerY | ( | ) | const [inline] |
Convinience method to get the pointer Y position.
Definition at line 143 of file Control.h.
Referenced by ControlMapper::computePickPos().
bool ControlState::isAxisZero | ( | EAxisId | axis, | |
float | epsilon = 0.0001f | |||
) | [inline] |
ControlState& ControlState::operator+= | ( | ESwitchId | switchId | ) | [inline] |
ControlState& ControlState::operator-= | ( | ESwitchId | switchId | ) | [inline] |
bool ControlState::operator[] | ( | ESwitchId | switchId | ) | const [inline] |
void ControlState::reset | ( | ESwitchId | switchId | ) | [inline] |
void ControlState::resetAllAxis | ( | ) |
Same as resetAxis() for all axis.
Definition at line 46 of file Control.cpp.
References MAX_AXIS, and pAxis.
Referenced by Controler::clear(), Controler::clearAxis(), and ControlState().
void ControlState::resetAllSwitches | ( | ) | [inline] |
void ControlState::resetAxis | ( | EAxisId | axis | ) | [inline] |
void ControlState::set | ( | ESwitchId | switchId | ) | [inline] |
void ControlState::setAxis | ( | EAxisId | axis, | |
float | val | |||
) | [inline] |
void ControlState::setPickPosition | ( | const osg::Vec3f & | pickPos | ) | [inline] |
Sets the pointer pick position.
Definition at line 150 of file Control.h.
Referenced by ControlMapper::computePickPos().
void ControlState::setPointer | ( | const osg::Vec3f & | pointer | ) | [inline] |
void ControlState::setPointer | ( | float | pointerX, | |
float | pointerY | |||
) | [inline] |
Sets the pointer to be at a given position (does not actually moves the system pointer, but changes the coordinates stored in the class).
Definition at line 133 of file Control.h.
Referenced by ControlMapper::handle().
bool ControlState::testAnyAxisOn | ( | float | epsilon = 1e-4f |
) | const [inline] |
bool ControlState::testAnyControlOn | ( | float | epsilon = 0.0001f |
) | const [inline] |
Convinience method that returns testAnySwitchOn() || testAnyAxisOn(epsilon).
bool ControlState::testAnySwitchOn | ( | ) | const [inline] |
const UINT ControlState::NB_USER_SWITCHES = 30 [static] |
Maximum number of custom (user's) switches. These custom swithces are defined by the application.
Definition at line 44 of file Control.h.
Referenced by loadBindings(), and saveBindings().
UINT ControlState::nbSwitchesOn [protected] |
float ControlState::pAxis[MAX_AXIS] [protected] |
osg::Vec3f ControlState::pickPos [protected] |
osg::Vec3f ControlState::pointer [protected] |
std::bitset<MAX_SWITCH> ControlState::vSwitchs [protected] |