This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Professional (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Materials and Shaders
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Containers
Common Functionality
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine::Controls Class

Header: #include <UnigineControls.h>

Handles input from the user (keyboard, mouse, joystick or gamepad). It can be used instead of the default engine.controls in one of the two possible ways:

See Also#

Controls Class

Enums

TYPE#

NameDescription
CONTROLS_APP = 0ControlsApp instance.
CONTROLS_DUMMY = 1ControlsDummy instance.
CONTROLS_GAMEPAD = 2Gamepad controller (e.g., XBox 360, Sixaxis, etc.) as the input device.
CONTROLS_JOYSTICK = 3Joystick as the input device.

Members


static ControlsPtr create ( int type ) #

Creates a smart pointer to Controls.

Arguments

  • int type - Type of the controls to be created.

void setMouseDX ( float mousedx ) #

Updates a screen position change of the mouse pointer along the X axis.

Arguments

  • float mousedx - Change of the X coordinate.

float getMouseDX ( ) const#

Returns a screen position change of the mouse pointer along the X axis during the previous frame.

Return value

Change of the X coordinate.

void setMouseDY ( float mousedy ) #

Updates a screen position change of the mouse pointer along the Y axis.

Arguments

  • float mousedy - Change of the Y coordinate.

float getMouseDY ( ) const#

Returns a screen position change of the mouse pointer along the Y axis during the previous frame.

Return value

Change of the Y coordinate.

void setState ( int state, int value ) #

Toggles the state of the given control on or off.

Arguments

  • int state - Control state number to update. Possible values are in range [STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls:: Enumeration at the end of the article.
  • int value - State value: positive value to "press" the control; 0 to release it.

int getState ( int state ) const#

Returns the state of a given control (pressed or unpressed).

Arguments

  • int state - Control state number. Possible values are in range [STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls:: Enumeration at the end of the article.

Return value

1 if the control is pressed; otherwise, 0.

int getStateByName ( const char * name ) const#

Returns the state of a given control (pressed or unpressed) by the control state name.

Arguments

  • const char * name - Name of the control state. For full list of available controls see Unigine::Controls:: Enumeration at the end of the article.

Return value

1 if the control is pressed; otherwise, 0.

const char * getStateName ( int state ) const#

Returns the name of a given control state as a string.

Arguments

  • int state - Control state number. Possible values are in range [STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls:: Enumeration at the end of the article.

Return value

Name of the control state.

Controls::TYPE getType ( ) const#

Returns the type of input controls.

Return value

Controls type (one of CONTROLS_* variables):
  1. CONTROLS_APP = 0
  2. CONTROLS_DUMMY
  3. CONTROLS_GAMEPAD
  4. CONTROLS_JOYSTICK

const char * getTypeName ( ) const#

Returns a type name of input controls.

Return value

Type name.

int clearState ( int state ) #

Returns a control state and clears it to 0 (not pressed). This function allows to handle control only once even if it is kept pressed over several frames.

Arguments

  • int state - Control state number. Possible values are in range [STATE_FORWARD;NUM_STATES]. For full list of available controls see Unigine::Controls:: Enumeration at the end of the article.

Return value

Returns the state of the given control: 1 if the control is pressed; otherwise,0.

bool saveState ( const Ptr<Stream> & stream ) const#

Saves controls settings into the stream.

Example using saveState() and restoreState() methods:

Source code (C++)
// Get the instance of default engine controls and set its state
controls = Engine::getControls();
controls->setMouseDX(5.0f);

// save state
BlobPtr blob_state = Blob::create();
controls->saveState(blob_state);

// change state
controls->setMouseDX(1.0f);

// restore state
blob_state->seekSet(0);				// returning the carriage to the start of the blob
controls->restoreState(blob_state);

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.

Return value

true if the controls settings are saved successfully; otherwise, false.

bool restoreState ( const Ptr<Stream> & stream ) #

Restores controls settings from the stream.

Example using saveState() and restoreState() methods:

Source code (C++)
// Get the instance of default engine controls and set its state
controls = Engine::getControls();
controls->setMouseDX(5.0f);

// save state
BlobPtr blob_state = Blob::create();
controls->saveState(blob_state);

// change state
controls->setMouseDX(1.0f);

// restore state
blob_state->seekSet(0);				// returning the carriage to the start of the blob
controls->restoreState(blob_state);

Arguments

  • const Ptr<Stream> & stream - Stream smart pointer.

Return value

true if the controls settings are restored successfully; otherwise, false.
Last update: 10.10.2022
Build: ()