VRPN 客户端插件
您应该升级到
Virtual Reality Peripheral Network (VRPN) is a device-independent system for accessing virtual reality peripherals in VR applications. The VRPN system consists of programming interfaces for both the client application and the hardware drivers and a server application that communicates with the hardware devices. The DTrack application often goes as a server application.Virtual Reality Peripheral Network (VRPN) 是一个独立于设备的系统,用于访问 VR 应用程序中的虚拟现实外围设备。 VRPN 系统由客户端应用程序和硬件驱动程序的编程接口以及与硬件设备通信的服务器应用程序组成。 DTrack 应用程序通常用作服务器应用程序。
The Virtual Reality Peripheral Network (VRPN) plugin represents the client application which is connected to the server and used for receiving input data from different input devices (joysticks, 3D motion and orientation tracking sensors and so on) via the Network.Virtual Reality Peripheral Network (VRPN) 插件代表客户端应用程序,它连接到服务器并用于通过网络从不同的输入设备(操纵杆、3D 运动和方向跟踪传感器等)接收输入数据。
For example, by using the VRPN Client plugin, you can implement an application that processes input data from ART controls.例如,通过使用 VRPN Client 插件,您可以实现处理来自 ART 控件的输入数据的应用程序。
See Also也可以看看#
- VrpnAnalogDevice classVrpnAnalogDevice 类
- VrpnButtonDevice classVrpnButtonDevice 类
- VrpnTackerDevice classVrpnTackerDevice 类
-
Samples on the plugin usage:插件使用示例:
- <UnigineSDK>/data/samples/plugins/vrpn_client_00 that demonstrates receiving data from the FlyStick device and two sensors, tracking this device and a head. The data is presented as a text.<UnigineSDK>/data/samples/plugins/vrpn_client_00 演示从 FlyStick 设备和两个传感器接收数据,跟踪该设备和头部。数据以文本形式呈现。
- <UnigineSDK>/data/samples/plugins/vrpn_client_01 that demonstrates receiving data from the virtual FlyStick device and two sensors, tracking this device and a head, inside the UNIGINE scene.<UnigineSDK>/data/samples/plugins/vrpn_client_01 演示了从虚拟 FlyStick 设备和两个传感器接收数据,在 UNIGINE 场景中跟踪该设备和头部。
The samples are available if you add the VRPN Client plugin to your project via UNIGINE SDK Browser.如果您通过 UNIGINE SDK 浏览器将 VRPN Client 插件添加到您的项目,则这些示例可用。
Launching VRPN Client Plugin启动 VRPN 客户端插件#
To use the VRPN Client plugin, you should specify the extern_plugin command line option on the application start-up:要使用 VRPN Client 插件,您应该在应用程序启动时指定 extern_plugin 命令行选项:
main_x64 -extern_plugin "VrpnClient"
Implementing Application Using VRPN Client Plugin使用 VRPN 客户端插件实现应用程序#
When the VRPN Client plugin is loaded, the following classes are added to UnigineScript:加载 VRPN Client 插件后,以下类将添加到 UnigineScript:
- VrpnAnalogDevice that receives data about input devices sticks.VrpnAnalogDevice 接收有关输入设备棒的数据。
- VrpnButtonDevice that receives data about input devices buttons states.VrpnButtonDevice 接收有关输入设备按钮状态的数据。
- VrpnTrackerDevice that receives about position, orientation, velocity and acceleration of tracked objects from 3D tracking sensors.VrpnTrackerDevice 从 3D 跟踪传感器接收有关被跟踪对象的位置、方向、速度和加速度。
When implementing an application using the plugin, instances of the classes listed above should be created on engine initialization.使用插件实现应用程序时,应在引擎初始化时创建上面列出的类的实例。
For example, if the VRPN server is set on the PC via the DTrack application, the following should be passed: DTrack@localhost. If the server is set on another PC, instead of the localhost, you should specify the PC's IP address. You should also call the update() method for each initialized device on engine update.For example, if the VRPN server is set on the PC via the DTrack application, the following should be passed: DTrack@localhost. If the server is set on another PC, instead of the localhost, you should specify the PC's IP address. You should also call the update() method for each initialized device on engine update.For example, if the VRPN server is set on the PC via the DTrack application, the following should be passed: DTrack@localhost. If the server is set on another PC, instead of the localhost, you should specify the PC's IP address. You should also call the Update() method for each initialized device on engine update.例如,如果通过 DTrack 应用程序在 PC 上设置 VRPN 服务器,则应传递以下内容:DTrack@localhost。如果服务器设置在另一台 PC 上,而不是 localhost,您应该指定 PC 的 IP 地址。您还应该在引擎更新时为每个初始化的设备调用 update() 方法。
#ifdef HAS_VRPN_CLIENT
VrpnTrackerDevice tracker;
VrpnButtonDevice button;
VrpnAnalogDevice analog;
int init() {
tracker = new VrpnTrackerDevice("DTrack@localhost");
button = new VrpnButtonDevice("DTrack@localhost");
analog = new VrpnAnalogDevice("DTrack@localhost");
return 1;
}
int shutdown() {
delete tracker;
delete button;
delete analog;
return 1;
}
int update() {
tracker.update();
button.update();
analog.update();
return 1;
}
#else
int init() {
log.warning("No VRPN Client plugin detected\n");
return 1;
}
int shutdown() {
return 1;
}
#endif