- 联系我们
- 技术支持: vrsupport@qiyi.com
- 商务合作: business@iqiyismart.com
- 人才招聘: 查看职位 >
- 公司地址:北京市朝阳区宏泰东街绿地中心B座11层
注视点相关API,在Utils类中有如下两个方法:
/// <summary>
/// 设置注释点渲染等级
/// </summary>
/// <param name="level">-1关闭,0-2分别是低中高三个等级</param>
public static void SetFoveationLevel(int level)
{
NativeMethods.SetFoveationLevel(level);
}
/// 设置注释点渲染参数
/// </summary>
/// <param name="foveationGainX">水平方向外围像素的缩减率,值越大缩减的越多</param>
/// <param name="foveationGainY">竖直方向外围像素的缩减率</param>
/// <param name="foveationArea">注视点周围分辨率不降范围,值越大,中心不缩减区域越大</param>
/// <param name="foveationMinimum">默认最小像素密度</param>
public static void SetFoveationParameters(float foveationGainX, float foveationGainY, float foveationArea, float foveationMinimum)
{
NativeMethods.SetFoveationParameters(foveationGainX, foveationGainY, foveationArea, foveationMinimum);
}
UnityXR提供了以下接口:
UnityEngine.XR.InputDevices.GetDeviceAtXRNode(UnityEngine.XR.XRNode.Head).subsystem.TryGetBoundaryPoints(List<Vector3> boundaryPoints)
UnityEngine.XR.InputDevices.GetDeviceAtXRNode(UnityEngine.XR.XRNode.Head).subsystem.boundaryChanged
对于UnityXR未提供的接口,QiyuBoundary类开放了更多功能的接口,供开发者使用。
public static bool GetConfigured()
public static BoundaryTestResult TestNode(Node node)
public static QiyuBoundary.BoundaryTestResult TestPoint(Vector3 point)
public static Vector3[] GetGeometry()
public static Vector3 GetDimensions()
public static bool GetVisible()
public static void SetVisible(bool value)
SDK提供设备信息接口,用于获取设备厂商、名称、唯一码等信息。开发者可使用UnityXR标准接口或奇遇接口GetDeviceInfo()。
设备 | 奇遇3 | 奇遇Dream | 奇遇Dream Pro | 奇遇 MIX |
---|---|---|---|---|
厂商 | Dreamagic | Dreamagic | Dreamagic | Dreamagic |
头显 | QiyuHMD-3 | QiyuHMD-Dream | QiyuHMD-DreamPro | QiyuHMD-MIX |
左手柄 | Qiyu Controller-Left-3 | Qiyu Controller-Left-Dream | Qiyu Controller-Left-Dream | Qiyu Controller-Left-MIX |
右手柄 | Qiyu Controller-Right-3 | Qiyu Controller-Right-Dream | Qiyu Controller-Right-Dream | Qiyu Controller-Right-MIX |
XR.InputDevice(https://docs.unity.cn/cn/2020.3/ScriptReference/XR.InputDevice.html (opens new window))
Unity.XR.Qiyu.QiyuXRCore.GetDeviceInfo()
返回如下结构:
public struct QiyuDeviceInfo
{
public string Name_HMD;//头显名称
public string Name_CtrL;//左手柄名称
public string Name_CtrR;//右手柄名称
public string Manufacturer;//厂商
public string SN_HMD;//头显SN号
public string SN_CtrL;//左手柄SN号(目前为空)
public string SN_CtrR;//右手柄SN号(目前为空)
};
注:以上内容可以参考Sample里的ButtonTest场景。
/// <summary>
/// 设置3dof模式,1:3dof,0:6dof
/// </summary>
/// <returns></returns>
public static void SetAppTrackingMode(int mode)
{
if (!QiyuPlatform.IsAndroid)
return;
QiyuXRCorePlugin.QVR_SetAppTrackingMode(mode);
}
屏幕刷新率代表VR设备屏幕每秒刷新次数。刷新率越高,可以支持应用实现更高的帧率、更稳定的追踪和更高的清晰度。奇遇设备上应用默认刷新率为72,即开发者在不设置或者修改刷新率时,应用以72Hz刷新屏幕。如果您想以更高刷新率运行应用,可通过下面的接口设置刷新率。需要注意的是,高刷新率要求应用每帧所消耗的时间更低,应用需确保运行期间的性能,稳定的维持高刷新率,否则可能无法通过奇遇商店的上线审核。奇遇各型号设备支持的刷新率情况如下:
设备型号 | 支持的刷新率 |
---|---|
奇遇 MIX | 72Hz、90Hz |
奇遇 DreamPro | 72Hz、90Hz |
奇遇 Dream | 72Hz |
奇遇 3 | 72Hz |
///<summary>
///设置屏幕刷新率
///</summary>
///<paramname="refreshRate">刷新率</param>
///<returns></returns>
publicstaticboolTrySetDisplayRefreshRate(floatrefreshRate)
{
if(!QiyuPlatform.IsAndroid)
returnfalse;
returnQiyuXRCorePlugin.QVR_SetDisplayRefreshRate(refreshRate);
}
///<summary>
///获取屏幕刷新率
///</summary>
///<paramname="refreshRate">返回值</param>
///<returns></returns>
publicstaticboolTryGetDisplayRefreshRate(outfloatrefreshRate)
{
if(!QiyuPlatform.IsAndroid)
{
refreshRate=72;
returntrue;
}
floatrate=0;
if(QiyuXRCorePlugin.QVR_GetDisplayRefreshRate(refrate))
{
refreshRate=rate;
returntrue;
}
else
{
refreshRate=rate;
returnfalse;
}
}
///<summary>
///获取可用刷新率列表
///</summary>
///<paramname="refreshRates">返回列表</param>
///<returns></returns>
publicstaticboolTryGetAvailableDisplayRefreshRates(outfloat[]refreshRates)
{
if(!QiyuPlatform.IsAndroid)
{
refreshRates=newfloat[]{72,90};
returntrue;
}
intcount=0;
QiyuXRCorePlugin.QVR_GetAvailableDisplayRefreshRates(IntPtr.Zero,refcount);
if(count>0)
{
if(cachedRefreshRatesBuffer.GetCapacity()<count)
cachedRefreshRatesBuffer.Reset(count);
if(cachedRefreshRatesManagedBuffer.Length<count)
cachedRefreshRatesManagedBuffer=newfloat[count];
QiyuXRCorePlugin.QVR_GetAvailableDisplayRefreshRates(cachedRefreshRatesBuffer.GetPointer(),ref
count);
Marshal.Copy(cachedRefreshRatesBuffer.GetPointer(),cachedRefreshRatesManagedBuffer,
0,count);
refreshRates=newfloat[count];
for(inti=0;i<count;i++)
{
refreshRates[i]=cachedRefreshRatesManagedBuffer[i];
}
returntrue;
}
else
{
refreshRates=newfloat[0];
returnfalse;
}
}
获取Passthrough 能力
public static PassthroughCapabilities GetPassthroughCapabilities()
{
if (!QiyuPlatform.IsAndroid)
return PassthroughCapabilities.NotSupport;
return (PassthroughCapabilities)QiyuXRCorePlugin.QVR_GetPassthroughCapabilities();
}
public enum PassthroughCapabilities : int
{
NotSupport = 0,//不支持passthrough
Mono = 1,//支持黑白passthrough
Color = 2//支持彩色passthrough
}
开启/关闭Passthrough背景
public static void EnableSeeThrough(bool visible)
{
if (QiyuPlatform.IsAndroid)
{
QiyuXRCorePlugin.QVR_EnableSeeThrough(visible);
}
}
开启/关闭Passthrough背景回调函数的注册和反注册:
public static void RegisterSeeThroughCallback(Action<int> callback)
{
if (seethrough_callback == null)
{
seethrough_callback = callback;
if (QiyuPlatform.IsAndroid)
{
SeeThroughCallBack callback_delegate = OnSeeThroughChanged;
QiyuXRCorePlugin.QVR_SetSeeThroughCallback(Marshal.GetFunctionPointerForDelegate(callback_delegate));
}
}
else
{
seethrough_callback += callback;
UnityEngine.Debug.Log("User RegisterSeeThroughCallback!");
}
}
public static void UnRegisterSeeThroughCallback(Action<int> callback)
{
if (seethrough_callback != null)
{
seethrough_callback -= callback;
UnityEngine.Debug.Log("User UnRegisterSeeThroughCallback!");
}
}
调用示例:
var deviceInfo = Unity.XR.Qiyu.QiyuXRCore.GetDeviceInfo();
if (deviceInfo.Name_HMD != "QiyuHMD-3" && deviceInfo.Name_HMD != "QiyuHMD-Dream" && deviceInfo.Name_HMD != "QiyuHMD-Dream Pro")
{
//passthrough现阶段只支持MIX及以后新机型,需要排除老机型后开启,否则开启后是黑的。
QiyuSeeThrough.EnableSeeThrough(true);
}