This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
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
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Unigine::Plugins::VrpnTrackerDevice Class

Warning
The functionality described in this article is not available in the Community SDK edition.
You should upgrade to Sim SDK edition to use it.
Header: #include <plugins/Unigine/VrpnClient/UnigineVrpnClient.h>

A class for the VRPN Plugin that allows receiving data about position, orientation, velocity and acceleration of tracked objects from 3D tracking sensors.

See Also#

  • Article on VRPN Plugin
  • A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/plugins/ folder:
    • vrpn_client_00
    • vrpn_client_01

VrpnTrackerDevice Class

Members


VrpnTrackerDevice ( const char * name ) #

Constructor.

Arguments

  • const char * name - Path to the device in the format device_name@server_address.

void setAccelerationCallback ( const char * name ) #

Sets the world script callback function that receives data about acceleration of tracked objects.

Arguments

  • const char * name - Callback function name.

Examples

Source code (UnigineScript)
VrpnTrackerDevice vrpn_tracker;

int init() {
	vrpn_tracker = new VrpnTrackerDevice("device_name@server_addr");
	vrpn_tracker.setAccelerationCallback("acceleration_callback");
	
	return 1;
}

int shutdown() {
	delete vrpn_tracker;
	return 1;
}

int update() {
	vrpn_tracker.update();
	return 1;
}
// a callback function
void acceleration_callback(int sensor,vec3 acceleration,quat orientation,float ifps) {
	log.message("Device sensor %d: acceleration %s, orientation %s, ifps %f\n",sensor,acceleration,orientation,ifps);
}

const char * getAccelerationCallback ( ) #

Returns a name of the world script callback function that receives data about acceleration of tracked objects. The callback function should be defined in the world script and receive 4 arguments:
  1. Sensor number (int)
  2. Linear acceleration (vec3 for the float precision version, or dvec3 for the double precision version)
  3. Acceleration of orientation change (an analog of angular acceleration; quat)
  4. Acceleration measurement time (float for the float precision version, or double for the double precision version)
Source code (UnigineScript)
// float precision
void callback_func(int sensor,vec3 acceleration,quat acceleration_orientation,float ifps) {
	// function logic
}
// double precision
void callback_func(int sensor,dvec3 acceleration,quat acceleration_orientation,double ifps) {
	// function logic
}

Return value

Callback function name.

void setTransformCallback ( const char * name ) #

Sets the world script callback function that receives data about position and orientation of tracked objects.

Arguments

  • const char * name - Callback function name.

Examples

Source code (UnigineScript)
VrpnTrackerDevice vrpn_tracker;

int init() {
	vrpn_tracker = new VrpnTrackerDevice("device_name@server_addr");
	vrpn_tracker.setTransformCallback("transform_callback");

	return 1;
}

int shutdown() {
	delete vrpn_tracker;
	return 1;
}

int update() {
	vrpn_tracker.update();
	return 1;
}
// a callback function
void transform_callback(int sensor,vec3 position,quat orientation) {
	log.message("Device sensor %d: position %s, orientation %s\n",sensor,position,orientation);
}

const char * getTransformCallback ( ) #

Returns a name of the world script callback function that receives data about position and orientation of tracked objects. The callback function should be defined in the world script and receive 3 arguments:
  1. Sensor number (int)
  2. Position (vec3 for the float precision version, or dvec3 for the double precision version)
  3. Orientation (quat)
Source code (UnigineScript)
// float precision
void callback_func(int sensor,vec3 acceleration,quat acceleration_orientation,float ifps) {
	// function logic
}
// double precision
void callback_func(int sensor,dvec3 acceleration,quat acceleration_orientation,double ifps) {
	// function logic
}

Return value

Callback function name.

void setVelocityCallback ( const char * name ) #

Sets the world script callback function that receives data about velocity of tracked objects.

Arguments

  • const char * name - Callback function name.

Examples

Source code (UnigineScript)
VrpnTrackerDevice vrpn_tracker;

int init() {
	vrpn_tracker = new VrpnTrackerDevice("device_name@server_addr");
	vrpn_tracker.setVelocityCallback("velocity_callback");
	
	return 1;
}

int shutdown() {
	delete vrpn_tracker;
	return 1;
}

int update() {
	vrpn_tracker.update();
	return 1;
}

// a callback function
void velocity_callback(int sensor,vec3 velocity,quat orientation,float velocity_ifps) {
	log.message("Device sensor %d: velocity %s, orientation %s, ifps %f\n",sensor,velocity,orientation,ifps);
}

const char * getVelocityCallback ( ) #

Returns a name of the world script callback function that receives data about velocity of tracked objects. The callback function should be defined in the world script and receive 4 arguments:
  1. Sensor number (int)
  2. Linear velocity (vec3 for the float precision version, or dvec3 for the double precision version)
  3. Velocity of orientation change (an analog of angular velocity; quat)
  4. Velocity measurement time (float for the float precision version, or double for the double precision version)
Source code (UnigineScript)
// float precision
void callback_func(int sensor,vec3 velocity,quat velocity_orientation,float ifps) {
	// function logic
}
// double precision
void callback_func(int sensor,dvec3 velocity,quat velocity_orientation,double ifps) {
	// function logic
}

Return value

Callback function name.

void update ( ) #

Updates the internal state of the device and receives input data.
Notice
This function should be called each frame.

int getNumSensors ( ) const#

Returns the total number of sensors.

Return value

The total number of sensors.

Math::Vec3 getSensorPosition ( int num ) const#

Returns the specified sensor position.

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Sensor position.

Math::quat getSensorRotation ( int num ) const#

Returns the specified sensor rotation.

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Sensor rotation.

Math::Vec3 getSensorVelocity ( int num ) const#

Returns the current sensor velocity (m/s2).

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Sensor velocity, in units per second.

Math::quat getSensorVelocityOrientation ( int num ) const#

Returns the orientation of the specified sensor after the delta time.

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Orientation of the sensor velocity.

Math::Scalar getSensorVelocityIFps ( int num ) const#

Returns the delta time (in seconds) for the sensor velocity.

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Delta time (in seconds).

Math::Vec3 getSensorAcceleration ( int num ) const#

Returns the current sensor acceleration (m/s2).

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Sensor acceleration.

Math::quat getSensorAccelerationOrientation ( int num ) const#

Returns the orientation of the specified sensor after the delta time.

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Orientation of the sensor acceleration.

Math::Scalar getSensorAccelerationIFps ( int num ) const#

Returns delta time (in seconds) for the sensor acceleration.

Arguments

  • int num - Sensor index number in range [0; NUM_SENSORS - 1 ].

Return value

Delta time (in seconds).
Last update: 15.03.2023
Build: ()