Qualcomm_Snapdragon_VR_SDK SvrPluginAndroid脚本简介(11)

本文继续介绍SvrPluginAndroid中的GetDeviceInfo方法:

public override int GetPredictedPose(ref Quaternion orientation, ref Vector3 position, int frameIndex)  
{  
       orientation.z = -orientation.z;  
       position.x = -position.x;  
       position.y = -position.y;  
  
       int rv = SvrGetPredictedPose(ref orientation.x, ref orientation.y, ref orientation.z, ref orientation.w,  
                        ref position.x, ref position.y, ref position.z, frameIndex);  
  
    orientation.z = -orientation.z;  
       position.x = -position.x;  
       position.y = -position.y;  
  
       return rv;  
}  
  
public override DeviceInfo GetDeviceInfo()  
{  
    DeviceInfo info = new DeviceInfo();  
  
    SvrGetDeviceInfo (ref info.displayWidthPixels,  
                      ref info.displayHeightPixels,  
                      ref info.displayRefreshRateHz,  
                      ref info.targetEyeWidthPixels,  
                      ref info.targetEyeHeightPixels,  
                      ref info.targetFovXRad,  
                      ref info.targetFovYRad,  
                         ref info.targetFrustumLeft.left, ref info.targetFrustumLeft.right, ref info.targetFrustumLeft.bottom, ref info.targetFrustumLeft.top, ref info.targetFrustumLeft.near, ref info.targetFrustumLeft.far,  
                         ref info.targetFrustumRight.left, ref info.targetFrustumRight.right, ref info.targetFrustumRight.bottom, ref info.targetFrustumRight.top, ref info.targetFrustumRight.near, ref info.targetFrustumRight.far);  
  
    return info;  
}  

在这个方法中首先创建了DeviceInfo类型的变量info。

之后调用底层的SvrGetDeviceInfo方法,利用ref标签的作用返回info的相关信息。

之后将info变量返回。

DeviceInfo在SvrPlugin脚本中的定义如下:

public struct DeviceInfo
	{
		public int 		displayWidthPixels;
		public int    	displayHeightPixels;
		public float  	displayRefreshRateHz;
		public int    	targetEyeWidthPixels;
		public int    	targetEyeHeightPixels;
		public float  	targetFovXRad;
		public float  	targetFovYRad;
        public ViewFrustum targetFrustumLeft;
        public ViewFrustum targetFrustumRight;
	}
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页