Blog

Blog

PHODAL

Mac OS Oculus DK 2 node-hmd 安装及Hello,World

node-hmd是一个用于头戴显示设备的模块。

This module serves to act as a common interface for communicating with a variety of head mounted displays (HMDs).

一开始想的是安装这个设备应该很简单,后来发现在Mac OS安装它是一个痛苦的过程——主要是编译器的原因。

用默认的编译器,即XCode和GCC都会有各种问题。。

如GCC不支持Clang的libc++。。 XCode不支持GCC的libstdc++。

最后只能用Clang,export这些编译器,然后再编译:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
npm install node-hdm --save

反正都会报错。。

object file (Release/obj.target/hmd/src/platform/mac/LibOVR/Src/Util/Util_ImageWindow.o) was built for newer OSX version (10.7) than being linked (10.5)ld: warning:
ld: warning: object file (Release/obj.target/hmd/src/platform/mac/LibOVR/Src/Util/Util_Interface.o) was built for newer OSX version (10.7) than being linked (10.5)object file (Release/obj.target/hmd/src/platform/mac/LibOVR/Src/Util/Util_LatencyTest2Reader.o) was built for newer OSX version (10.7) than being linked (10.5)
ld: warning:
object file (Release/obj.target/hmd/src/platform/mac/LibOVR/Src/Util/Util_Render_Stereo.o) was built for newer OSX version (10.7) than being linked (10.5)
node-hmd@0.2.1 node_modules/node-hmd

如果经常了上面那一步,那么我想你可以试试,hello,world

var hmd = require('node-hmd');

var supportedDevices = hmd.getSupportedDevices();

console.log(supportedDevices);

var manager = hmd.createManager("oculusrift");

manager.getDeviceInfo(function(err, deviceInfo) {
    if(!err) {
        console.log(deviceInfo);
    }
    else {
        console.error("Unable to retrieve device information.");
    }
});

manager.getDeviceOrientation(function(err, deviceOrientation) {
    if(!err) {
        console.log(deviceOrientation);
    }
    else {
        console.error("Unable to retrieve device orientation.");
    }
});

manager.getDevicePosition(function(err, devicePosition) {
    devicePosition; // -> [object HMDDevicePosition]
    console.log(devicePosition)
});

需要注意的是要将设备改为oculusrift,而不能是default。执行后,会有类似下面的结果:

                                         10:12:49
[ 'default', 'oculusrift' ]
{ roll: 0, pitch: 0, yaw: 0 }
{ z: 0, y: 0, x: 0 }
{ CameraFrustumFarZInMeters: 2.5,
  CameraFrustumHFovInRadians: 1.29154372215271,
  CameraFrustumNearZInMeters: 0.4000000059604645,
  CameraFrustumVFovInRadians: 0.942477822303772,
  DefaultEyeFov:
   [ { RightTan: 1.0923680067062378,
       LeftTan: 1.0586576461791992,
       DownTan: 1.3292863368988037,
       UpTan: 1.3292863368988037 },
     { RightTan: 1.0586576461791992,
       LeftTan: 1.0923680067062378,
       DownTan: 1.3292863368988037,
       UpTan: 1.3292863368988037 } ],
  DisplayDeviceName: '',
  DisplayId: 880804035,
  DistortionCaps: 66027,
  EyeRenderOrder: [ 1, 0 ],
  FirmwareMajor: 2,
  FirmwareMinor: 12,
  HmdCaps: 4745,
  Manufacturer: 'Oculus VR',
  MaxEyeFov:
   [ { RightTan: 1.0923680067062378,
       LeftTan: 1.0586576461791992,
       DownTan: 1.3292863368988037,
       UpTan: 1.3292863368988037 },
     { RightTan: 1.0586576461791992,
       LeftTan: 1.0923680067062378,
       DownTan: 1.3292863368988037,
       UpTan: 1.3292863368988037 } ],
  ProductId: 33,
  ProductName: 'Oculus Rift DK2',
  Resolution: { h: 1080, w: 1920 },
  SerialNumber: '2057XE005W8G',
  TrackingCaps: 112,
  VendorId: 10291,

关于我

Github: @phodal     微博:@phodal     知乎:@phodal    

微信公众号(Phodal)

围观我的Github Idea墙, 也许,你会遇到心仪的项目

QQ技术交流群: 321689806
comment

Feeds

RSS / Atom

最近文章

关于作者

Phodal Huang

Engineer, Consultant, Writer, Designer

ThoughtWorks 技术专家

工程师 / 咨询师 / 作家 / 设计学徒

开源深度爱好者

出版有《前端架构:从入门到微前端》、《自己动手设计物联网》、《全栈应用开发:精益实践》

联系我: h@phodal.com

微信公众号: 最新技术分享

标签