This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

VrpnTrackerDevice Class

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

See Also

VrpnTrackerDevice Class

Members


VrpnTrackerDevice (string name)

Constructor.

Arguments

  • string name - Path to the device in the format device_name@server_address.

string 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.

string 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.

string 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 setAccelerationCallback (string name)

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

Arguments

  • string 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);
}

void setTransformCallback (string name)

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

Arguments

  • string 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);
}

void setVelocityCallback (string name)

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

Arguments

  • string 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);
}

void update ()

Updates the internal state of the device and receives input data.
Notice
This function should be called each frame.
Last update: 2017-07-03
Build: ()