protected override void OnUpdateEyePose(AirXRClientConfig config, Vector3 centerEyePosition, Quaternion centerEyeOrientation) { if (needToUpdateTrackingSpace()) { updateTrackingSpace(); } if (_tracker != null) { Quaternion worldHeadOrientation = HMDTrackingRootRotation * centerEyeOrientation; centerEyeAnchor.rotation = leftEyeAnchor.rotation = rightEyeAnchor.rotation = worldHeadOrientation; Vector3 cameraRigScale = centerEyeAnchor.parent.lossyScale; leftEyeAnchor.position = _tracker.position + worldHeadOrientation * (Vector3.Scale(Vector3.left, cameraRigScale) * 0.5f * config.ipd); centerEyeAnchor.position = _tracker.position; rightEyeAnchor.position = _tracker.position + worldHeadOrientation * (Vector3.Scale(Vector3.right, cameraRigScale) * 0.5f * config.ipd); } else { centerEyeAnchor.localRotation = leftEyeAnchor.localRotation = rightEyeAnchor.localRotation = centerEyeOrientation; leftEyeAnchor.localPosition = centerEyeOrientation * (Vector3.left * 0.5f * config.ipd); centerEyeAnchor.localPosition = Vector3.zero; rightEyeAnchor.localPosition = centerEyeOrientation * (Vector3.right * 0.5f * config.ipd); } }
public AirXRServerMediaStream(int playerID, AirXRClientConfig config, int cameraCount) { currentFramebufferIndex = 0; _cameraCount = cameraCount; _framebuffers = new RenderTexture[FramebufferCount * cameraCount]; IntPtr[] framebuffers = new IntPtr[FramebufferCount * cameraCount]; for (int f = 0; f < FramebufferCount; f++) { for (int t = 0; t < cameraCount; t++) { RenderTexture texture = new RenderTexture(config.videoWidth / cameraCount, config.videoHeight, 24); texture.antiAliasing = 1; texture.autoGenerateMips = false; texture.useMipMap = false; texture.filterMode = FilterMode.Bilinear; texture.anisoLevel = 0; texture.format = RenderTextureFormat.ARGB32; texture.Create(); _framebuffers[f * cameraCount + t] = texture; framebuffers[f * cameraCount + t] = texture.GetNativeTexturePtr(); } } AXRServerPlugin.RegisterFramebufferTextures(playerID, framebuffers, cameraCount, FramebufferCount); }
// implements AirXRTrackingModel protected override void OnUpdateEyePose(AirXRClientConfig config, Vector3 centerEyePosition, Quaternion centerEyeOrientation) { centerEyeAnchor.localRotation = leftEyeAnchor.localRotation = rightEyeAnchor.localRotation = centerEyeOrientation; leftEyeAnchor.localPosition = centerEyePosition + centerEyeOrientation * (Vector3.left * 0.5f * config.ipd); centerEyeAnchor.localPosition = centerEyePosition; rightEyeAnchor.localPosition = centerEyePosition + centerEyeOrientation * (Vector3.right * 0.5f * config.ipd); }
protected override void OnUpdateEyePose(AirXRClientConfig config, Pose leftEyePose, Pose rightEyePose) { centerEyeAnchor.localPosition = (leftEyePose.position + rightEyePose.position) / 2; centerEyeAnchor.localRotation = leftEyePose.rotation; leftEyeAnchor.localPosition = leftEyePose.position; leftEyeAnchor.localRotation = leftEyePose.rotation; rightEyeAnchor.localPosition = rightEyePose.position; rightEyeAnchor.localRotation = rightEyePose.rotation; }
// implements AirXRCameraRigManager.EventHandler public void AirXRCameraRigWillBeBound(int clientHandle, AirXRClientConfig config, List <AirXRCameraRig> availables, out AirXRCameraRig selected) { selected = availables.Count > 0 ? availables[0] : null; if (selected) { music.Play(); } }
internal void UnbindPlayer() { Assert.IsTrue(isBoundToClient); playerID = AXRServerPlugin.InvalidPlayerID; _config = null; _cameraEventEmitter.Unbind(); }
public void UpdateEyePose(AirXRClientConfig config, Vector3 centerEyePosition, Quaternion centerEyeOrientation) { OnUpdateEyePose(config, centerEyePosition, centerEyeOrientation); Transform trackingRoot = centerEyeAnchor.parent; HMDSpaceToWorldMatrix = Matrix4x4.TRS(trackingRoot.localToWorldMatrix.MultiplyPoint(centerEyeAnchor.localPosition - centerEyePosition), HMDTrackingRootRotation, trackingRoot.lossyScale); }
public void UpdateEyePose(AirXRClientConfig config, Pose leftEyePose, Pose rightEyePose) { OnUpdateEyePose(config, leftEyePose, rightEyePose); var centerEyePosition = (leftEyePose.position + rightEyePose.position) / 2; var trackingRoot = centerEyeAnchor.parent; HMDSpaceToWorldMatrix = Matrix4x4.TRS(trackingRoot.localToWorldMatrix.MultiplyPoint(centerEyeAnchor.localPosition - centerEyePosition), HMDTrackingRootRotation, trackingRoot.lossyScale); }
protected override void updateControllerTransforms(AirXRClientConfig config) { var pose = inputStream.GetPose((byte)AXRInputDeviceID.LeftHandTracker, (byte)AXRHandTrackerControl.Pose); leftHandAnchor.localPosition = pose.position; leftHandAnchor.localRotation = pose.rotation; pose = inputStream.GetPose((byte)AXRInputDeviceID.RightHandTracker, (byte)AXRHandTrackerControl.Pose); rightHandAnchor.localPosition = pose.position; rightHandAnchor.localRotation = pose.rotation; }
internal void BindPlayer(int playerID) { Assert.IsFalse(isBoundToClient); Assert.IsNull(_config); this.playerID = playerID; _config = AirXRClientConfig.Get(playerID); Assert.IsNotNull(_config); _cameraEventEmitter.Bind(playerID); }
protected override void updateControllerTransforms(AirXRClientConfig config, AirXRPredictedMotionProvider motionProvider, bool bypassPrediction) { var pose = inputStream.GetPose((byte)AXRInputDeviceID.LeftHandTracker, (byte)AXRHandTrackerControl.Pose); leftHandAnchor.localPosition = pose.position; leftHandAnchor.localRotation = pose.rotation; pose = motionProvider == null || bypassPrediction?inputStream.GetPose((byte)AXRInputDeviceID.RightHandTracker, (byte)AXRHandTrackerControl.Pose) : motionProvider.rightHand; rightHandAnchor.localPosition = pose.position; rightHandAnchor.localRotation = pose.rotation; }
// implements AirXRCameraRigMananger.EventHandler public void AirXRCameraRigWillBeBound(int clientHandle, AirXRClientConfig config, List <AirXRCameraRig> availables, out AirXRCameraRig selected) { if (availables.Contains(_primaryCameraRig)) { selected = _primaryCameraRig; } else if (availables.Count > 0) { selected = availables[0]; } else { selected = null; } }
protected override void updateCameraProjection(AirXRClientConfig config, float[] projection) { var projectionMatrix = AirXRClientConfig.CalcCameraProjectionMatrix(projection, camera.nearClipPlane, camera.farClipPlane); #if UNITY_2018_2_OR_NEWER var props = AirXRClientConfig.CalcPhysicalCameraProps(projection); camera.usePhysicalProperties = true; camera.focalLength = props.focalLength; camera.sensorSize = props.sensorSize; camera.lensShift = props.lensShift; camera.aspect = props.aspect; camera.gateFit = Camera.GateFitMode.None; #else camera.projectionMatrix = projectionMatrix; #endif }
protected override void updateCameraProjection(AirXRClientConfig config, Rect leftRenderProj, Rect rightRenderProj, Rect leftEncodingProj, Rect rightEncodingProj) { float[] leftRenderProjection = { leftRenderProj.xMin, leftRenderProj.yMax, leftRenderProj.xMax, leftRenderProj.yMin }; float[] rightRenderProjection = { rightRenderProj.xMin, rightRenderProj.yMax, rightRenderProj.xMax, rightRenderProj.yMin }; leftEyeCamera.projectionMatrix = AirXRClientConfig.CalcCameraProjectionMatrix(leftRenderProjection, leftEyeCamera.nearClipPlane, leftEyeCamera.farClipPlane); rightEyeCamera.projectionMatrix = AirXRClientConfig.CalcCameraProjectionMatrix(rightRenderProjection, rightEyeCamera.nearClipPlane, rightEyeCamera.farClipPlane); leftEyeCamera.rect = new Rect(0.5f - leftRenderProj.width / leftEncodingProj.width / 2, 0.5f - leftRenderProj.height / leftEncodingProj.height / 2, leftRenderProj.width / leftEncodingProj.width, leftRenderProj.height / leftEncodingProj.height); rightEyeCamera.rect = new Rect(0.5f - rightRenderProj.width / rightEncodingProj.width / 2, 0.5f - rightRenderProj.height / rightEncodingProj.height / 2, rightRenderProj.width / rightEncodingProj.width, rightRenderProj.height / rightEncodingProj.height); }
private AirXRCameraRig notifyCameraRigWillBeBound(int playerID) { var config = AirXRClientConfig.Get(playerID); var cameraRigs = new List <AirXRCameraRig>(); _cameraRigList.GetAvailableCameraRigs(config.type, cameraRigs); AirXRCameraRig selected = null; if (Delegate != null) { Delegate.AirXRCameraRigWillBeBound(playerID, config, cameraRigs, out selected); AirXRClientConfig.Set(playerID, config); } else if (cameraRigs.Count > 0) { selected = cameraRigs[0]; } return(selected); }
protected override void setupCamerasOnBound(AirXRClientConfig config) { var projection = config.GetCameraProjectionMatrix(camera.nearClipPlane, camera.farClipPlane); if (projection == Matrix4x4.zero) { return; } #if UNITY_2018_2_OR_NEWER var props = config.physicalCameraProps; camera.usePhysicalProperties = true; camera.focalLength = props.focalLength; camera.sensorSize = props.sensorSize; camera.lensShift = props.lensShift; camera.aspect = props.aspect; camera.gateFit = Camera.GateFitMode.None; #else camera.projectionMatrix = projection; #endif }
protected override void setupCamerasOnBound(AirXRClientConfig config) { #if UNITY_2018_2_OR_NEWER var props = config.physicalCameraProps; leftEyeCamera.usePhysicalProperties = true; leftEyeCamera.focalLength = props.focalLength; leftEyeCamera.sensorSize = props.sensorSize; leftEyeCamera.lensShift = props.leftLensShift; leftEyeCamera.aspect = props.aspect; leftEyeCamera.gateFit = Camera.GateFitMode.None; rightEyeCamera.usePhysicalProperties = true; rightEyeCamera.focalLength = props.focalLength; rightEyeCamera.sensorSize = props.sensorSize; rightEyeCamera.lensShift = props.rightLensShift; rightEyeCamera.aspect = props.aspect; rightEyeCamera.gateFit = Camera.GateFitMode.None; #else leftEyeCamera.projectionMatrix = config.GetLeftEyeCameraProjection(leftEyeCamera.nearClipPlane, leftEyeCamera.farClipPlane); rightEyeCamera.projectionMatrix = config.GetRightEyeCameraProjection(rightEyeCamera.nearClipPlane, rightEyeCamera.farClipPlane); #endif }
protected override void OnUpdateEyePose(AirXRClientConfig config, Pose leftEyePose, Pose rightEyePose) { OnUpdateEyePose(config, leftEyePose.position, leftEyePose.rotation); }
protected override void updateCameraProjection(AirXRClientConfig config, float[] projection) { // do nothing; a stereoscopic camera must keep its inherent projection }
protected virtual void updateControllerTransforms(AirXRClientConfig config, AirXRPredictedMotionProvider motionProvider, bool bypassPrediction) { }
protected override void updateCameraProjection(AirXRClientConfig config, Rect leftRenderProj, Rect rightRenderProj, Rect leftEncodingProj, Rect rightEncodingProj) { // do nothing }
protected override void updateCameraTransforms(AirXRClientConfig config, Vector3 centerEyePosition, Quaternion centerEyeOrientation) { _cameraAnchor.localRotation = centerEyeOrientation; _cameraAnchor.localPosition = centerEyePosition; }
protected override void updateCameraTransforms(AirXRClientConfig config, Pose leftEyePose, Pose rightEyePose) { // do nothing }
// implements AirXRTrackingModel protected override void OnUpdateEyePose(AirXRClientConfig config, Vector3 centerEyePosition, Quaternion centerEyeOrientation) { centerEyeAnchor.localRotation = leftEyeAnchor.localRotation = rightEyeAnchor.localRotation = centerEyeOrientation; }
protected virtual void updateControllerTransforms(AirXRClientConfig config) { }
protected override void updateCameraTransforms(AirXRClientConfig config, Vector3 centerEyePosition, Quaternion centerEyeOrientation) { updateTrackingModel(); _trackingModelObject.UpdateEyePose(config, centerEyePosition, centerEyeOrientation); }
protected override void updateCameraTransforms(AirXRClientConfig config, Pose leftEyePose, Pose rightEyePose) { updateTrackingModel(); _trackingModelObject.UpdateEyePose(config, leftEyePose, rightEyePose); }
protected abstract void OnUpdateEyePose(AirXRClientConfig config, Vector3 centerEyePosition, Quaternion centerEyeOrientation);
protected abstract void OnUpdateEyePose(AirXRClientConfig config, Pose leftEyePose, Pose rightEyePose);
protected abstract void updateCameraTransforms(AirXRClientConfig config, Pose leftEyePose, Pose rightEyePose);