| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775 |
- /*******************************************************************************
- Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
- NOTICE:All information contained herein is, and remains the property of
- PICO Technology Co., Ltd. The intellectual and technical concepts
- contained herein are proprietary to PICO Technology Co., Ltd. and may be
- covered by patents, patents in process, and are protected by trade secret or
- copyright law. Dissemination of this information or reproduction of this
- material is strictly forbidden unless prior written permission is obtained from
- PICO Technology Co., Ltd.
- *******************************************************************************/
- using System;
- using System.Runtime.InteropServices;
- using UnityEngine;
- using UnityEngine.Rendering;
- namespace Unity.XR.PXR
- {
- public class PXR_OverlayManager : MonoBehaviour
- {
- private void OnEnable()
- {
- #if UNITY_2019_1_OR_NEWER
- if (GraphicsSettings.renderPipelineAsset != null)
- {
- RenderPipelineManager.beginFrameRendering += BeginRendering;
- RenderPipelineManager.endFrameRendering += EndRendering;
- }
- else
- {
- Camera.onPreRender += OnPreRenderCallBack;
- Camera.onPostRender += OnPostRenderCallBack;
- }
- #endif
- }
- private void OnDisable()
- {
- #if UNITY_2019_1_OR_NEWER
- if (GraphicsSettings.renderPipelineAsset != null)
- {
- RenderPipelineManager.beginFrameRendering -= BeginRendering;
- RenderPipelineManager.endFrameRendering -= EndRendering;
- }
- else
- {
- Camera.onPreRender -= OnPreRenderCallBack;
- Camera.onPostRender -= OnPostRenderCallBack;
- }
- #endif
- }
- private void Start()
- {
- // external surface
- if (PXR_OverLay.Instances.Count > 0)
- {
- foreach (var overlay in PXR_OverLay.Instances)
- {
- if (overlay.isExternalAndroidSurface)
- {
- overlay.CreateExternalSurface(overlay);
- }
- }
- }
- }
- private void BeginRendering(ScriptableRenderContext arg1, Camera[] arg2)
- {
- foreach (Camera cam in arg2)
- {
- if (cam != null && Camera.main == cam)
- {
- OnPreRenderCallBack(cam);
- }
- }
- }
- private void EndRendering(ScriptableRenderContext arg1, Camera[] arg2)
- {
- foreach (Camera cam in arg2)
- {
- if (cam != null && Camera.main == cam)
- {
- OnPostRenderCallBack(cam);
- }
- }
- }
- private void OnPreRenderCallBack(Camera cam)
- {
- // There is only one XR main camera in the scene.
- if (null == Camera.main) return;
- if (cam == null || cam != Camera.main || cam.stereoActiveEye == Camera.MonoOrStereoscopicEye.Right) return;
- //CompositeLayers
- int boundaryState = PXR_Plugin.Boundary.UPxr_GetSeeThroughState();
- if (null == PXR_OverLay.Instances) return;
- if (PXR_OverLay.Instances.Count > 0 && boundaryState != 2)
- {
- foreach (var overlay in PXR_OverLay.Instances)
- {
- if (!overlay.isActiveAndEnabled) continue;
- if (null == overlay.layerTextures) continue;
- if (!overlay.isClones && overlay.layerTextures[0] == null && overlay.layerTextures[1] == null && !overlay.isExternalAndroidSurface) continue;
- if (overlay.overlayTransform != null && !overlay.overlayTransform.gameObject.activeSelf) continue;
- overlay.CreateTexture();
- PXR_Plugin.Render.UPxr_GetLayerNextImageIndex(overlay.overlayIndex, ref overlay.imageIndex);
- }
- }
- }
- private void OnPostRenderCallBack(Camera cam)
- {
- // There is only one XR main camera in the scene.
- if (null == Camera.main) return;
- if (cam == null || cam != Camera.main || cam.stereoActiveEye == Camera.MonoOrStereoscopicEye.Right) return;
- int boundaryState = PXR_Plugin.Boundary.UPxr_GetSeeThroughState();
- if (null == PXR_OverLay.Instances) return;
- if (PXR_OverLay.Instances.Count > 0 && boundaryState != 2)
- {
- PXR_OverLay.Instances.Sort();
- foreach (var compositeLayer in PXR_OverLay.Instances)
- {
- if (null == compositeLayer) continue;
- compositeLayer.UpdateCoords();
- if (!compositeLayer.isActiveAndEnabled) continue;
- if (null == compositeLayer.layerTextures) continue;
- if (!compositeLayer.isClones && compositeLayer.layerTextures[0] == null && compositeLayer.layerTextures[1] == null && !compositeLayer.isExternalAndroidSurface) continue;
- if (compositeLayer.overlayTransform != null && null == compositeLayer.overlayTransform.gameObject) continue;
- if (compositeLayer.overlayTransform != null && !compositeLayer.overlayTransform.gameObject.activeSelf) continue;
- Vector4 colorScale = compositeLayer.GetLayerColorScale();
- Vector4 colorBias = compositeLayer.GetLayerColorOffset();
- bool isHeadLocked = false;
- if (compositeLayer.overlayTransform != null && compositeLayer.overlayTransform.parent == transform)
- {
- isHeadLocked = true;
- }
- if (!compositeLayer.isExternalAndroidSurface && !compositeLayer.CopyRT()) continue;
- if (null == compositeLayer.cameraRotations || null == compositeLayer.modelScales || null == compositeLayer.modelTranslations) continue;
- // set color matrics
- PXR_Plugin.Render.UPxr_SetConfigFloatArray(ConfigType.SetSubmitLayerEXTItemColorMatrix, compositeLayer.colorMatrix, 18);
- if (compositeLayer.overlayShape == PXR_OverLay.OverlayShape.Quad)
- {
- PxrLayerQuad2 layerSubmit2 = new PxrLayerQuad2();
- layerSubmit2.header.layerId = compositeLayer.overlayIndex;
- layerSubmit2.header.colorScaleX = colorScale.x;
- layerSubmit2.header.colorScaleY = colorScale.y;
- layerSubmit2.header.colorScaleZ = colorScale.z;
- layerSubmit2.header.colorScaleW = colorScale.w;
- layerSubmit2.header.colorBiasX = colorBias.x;
- layerSubmit2.header.colorBiasY = colorBias.y;
- layerSubmit2.header.colorBiasZ = colorBias.z;
- layerSubmit2.header.colorBiasW = colorBias.w;
- layerSubmit2.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit2.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit2.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit2.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit2.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit2.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit2.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit2.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- layerSubmit2.header.layerShape = PXR_OverLay.OverlayShape.Quad;
- layerSubmit2.header.useLayerBlend = (UInt32)(compositeLayer.useLayerBlend ? 1 : 0);
- layerSubmit2.header.layerBlend.srcColor = compositeLayer.srcColor;
- layerSubmit2.header.layerBlend.dstColor = compositeLayer.dstColor;
- layerSubmit2.header.layerBlend.srcAlpha = compositeLayer.srcAlpha;
- layerSubmit2.header.layerBlend.dstAlpha = compositeLayer.dstAlpha;
- layerSubmit2.header.useImageRect = (UInt32)(compositeLayer.useImageRect ? 1 : 0);
- layerSubmit2.header.imageRectLeft = compositeLayer.getPxrRectiLeft(true);
- layerSubmit2.header.imageRectRight = compositeLayer.getPxrRectiLeft(false);
- layerSubmit2.sizeLeft.x = compositeLayer.modelScales[0].x;
- layerSubmit2.sizeLeft.y = compositeLayer.modelScales[0].y;
- layerSubmit2.sizeRight.x = compositeLayer.modelScales[0].x;
- layerSubmit2.sizeRight.y = compositeLayer.modelScales[0].y;
- if (isHeadLocked)
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseLeft.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseLeft.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseRight.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseRight.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseRight.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace |
- PxrLayerSubmitFlags.PxrLayerFlagHeadLocked);
- }
- else
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseLeft.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseLeft.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseRight.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseRight.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseRight.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- }
- if (compositeLayer.isPremultipliedAlpha)
- {
- layerSubmit2.header.layerFlags |= (UInt32)PxrLayerSubmitFlags.PxrLayerFlagPremultipliedAlpha;
- }
- if (compositeLayer.useImageRect)
- {
- layerSubmit2.poseLeft.position.x += -0.5f + compositeLayer.dstRectLeft.x + 0.5f * Mathf.Min(compositeLayer.dstRectLeft.width, 1 - compositeLayer.dstRectLeft.x);
- layerSubmit2.poseLeft.position.y += -0.5f + compositeLayer.dstRectLeft.y + 0.5f * Mathf.Min(compositeLayer.dstRectLeft.height, 1 - compositeLayer.dstRectLeft.y);
- layerSubmit2.poseRight.position.x += -0.5f + compositeLayer.dstRectRight.x + 0.5f * Mathf.Min(compositeLayer.dstRectRight.width, 1 - compositeLayer.dstRectRight.x);
- layerSubmit2.poseRight.position.y += -0.5f + compositeLayer.dstRectRight.y + 0.5f * Mathf.Min(compositeLayer.dstRectRight.height, 1 - compositeLayer.dstRectRight.y);
- layerSubmit2.sizeLeft.x = compositeLayer.modelScales[0].x * Mathf.Min(compositeLayer.dstRectLeft.width, 1 - compositeLayer.dstRectLeft.x);
- layerSubmit2.sizeLeft.y = compositeLayer.modelScales[0].y * Mathf.Min(compositeLayer.dstRectLeft.height, 1 - compositeLayer.dstRectLeft.y);
- layerSubmit2.sizeRight.x = compositeLayer.modelScales[0].x * Mathf.Min(compositeLayer.dstRectRight.width, 1 - compositeLayer.dstRectRight.x);
- layerSubmit2.sizeRight.y = compositeLayer.modelScales[0].y * Mathf.Min(compositeLayer.dstRectRight.height, 1 - compositeLayer.dstRectRight.y);
- }
- if (PXR_Plugin.Render.UPxr_SubmitLayerQuad2(layerSubmit2))
- {
- PxrLayerQuad layerSubmit = new PxrLayerQuad();
- layerSubmit.header.layerId = compositeLayer.overlayIndex;
- layerSubmit.header.colorScaleX = colorScale.x;
- layerSubmit.header.colorScaleY = colorScale.y;
- layerSubmit.header.colorScaleZ = colorScale.z;
- layerSubmit.header.colorScaleW = colorScale.w;
- layerSubmit.header.colorBiasX = colorBias.x;
- layerSubmit.header.colorBiasY = colorBias.y;
- layerSubmit.header.colorBiasZ = colorBias.z;
- layerSubmit.header.colorBiasW = colorBias.w;
- layerSubmit.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- if (isHeadLocked)
- {
- layerSubmit.pose.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit.pose.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit.pose.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit.pose.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit.pose.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit.pose.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit.pose.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace |
- PxrLayerSubmitFlags.PxrLayerFlagHeadLocked);
- }
- else
- {
- layerSubmit.pose.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit.pose.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit.pose.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit.pose.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit.pose.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit.pose.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit.pose.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- }
- layerSubmit.width = compositeLayer.modelScales[0].x;
- layerSubmit.height = compositeLayer.modelScales[0].y;
- PXR_Plugin.Render.UPxr_SubmitLayerQuad(layerSubmit);
- }
- }
- else if (compositeLayer.overlayShape == PXR_OverLay.OverlayShape.Cylinder)
- {
- PxrLayerCylinder2 layerSubmit2 = new PxrLayerCylinder2();
- layerSubmit2.header.layerId = compositeLayer.overlayIndex;
- layerSubmit2.header.colorScaleX = colorScale.x;
- layerSubmit2.header.colorScaleY = colorScale.y;
- layerSubmit2.header.colorScaleZ = colorScale.z;
- layerSubmit2.header.colorScaleW = colorScale.w;
- layerSubmit2.header.colorBiasX = colorBias.x;
- layerSubmit2.header.colorBiasY = colorBias.y;
- layerSubmit2.header.colorBiasZ = colorBias.z;
- layerSubmit2.header.colorBiasW = colorBias.w;
- layerSubmit2.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit2.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit2.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit2.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit2.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit2.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit2.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit2.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- layerSubmit2.header.layerShape = PXR_OverLay.OverlayShape.Cylinder;
- layerSubmit2.header.useLayerBlend = (UInt32)(compositeLayer.useLayerBlend ? 1 : 0);
- layerSubmit2.header.layerBlend.srcColor = compositeLayer.srcColor;
- layerSubmit2.header.layerBlend.dstColor = compositeLayer.dstColor;
- layerSubmit2.header.layerBlend.srcAlpha = compositeLayer.srcAlpha;
- layerSubmit2.header.layerBlend.dstAlpha = compositeLayer.dstAlpha;
- layerSubmit2.header.useImageRect = (UInt32)(compositeLayer.useImageRect ? 1 : 0);
- layerSubmit2.header.imageRectLeft = compositeLayer.getPxrRectiLeft(true);
- layerSubmit2.header.imageRectRight = compositeLayer.getPxrRectiLeft(false);
- if (isHeadLocked)
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseLeft.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseLeft.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseRight.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseRight.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseRight.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace |
- PxrLayerSubmitFlags.PxrLayerFlagHeadLocked);
- }
- else
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseLeft.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseLeft.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseRight.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseRight.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseRight.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- }
- if (compositeLayer.isPremultipliedAlpha)
- {
- layerSubmit2.header.layerFlags |= (UInt32)PxrLayerSubmitFlags.PxrLayerFlagPremultipliedAlpha;
- }
- if (compositeLayer.modelScales[0].z != 0)
- {
- layerSubmit2.centralAngleLeft = compositeLayer.modelScales[0].x / compositeLayer.modelScales[0].z;
- layerSubmit2.centralAngleRight = compositeLayer.modelScales[0].x / compositeLayer.modelScales[0].z;
- }
- else
- {
- Debug.LogError("PXRLog scale.z is 0");
- }
- layerSubmit2.heightLeft = compositeLayer.modelScales[0].y;
- layerSubmit2.heightRight = compositeLayer.modelScales[0].y;
- layerSubmit2.radiusLeft = compositeLayer.modelScales[0].z;
- layerSubmit2.radiusRight = compositeLayer.modelScales[0].z;
- if (PXR_Plugin.Render.UPxr_SubmitLayerCylinder2(layerSubmit2))
- {
- PxrLayerCylinder layerSubmit = new PxrLayerCylinder();
- layerSubmit.header.layerId = compositeLayer.overlayIndex;
- layerSubmit.header.colorScaleX = colorScale.x;
- layerSubmit.header.colorScaleY = colorScale.y;
- layerSubmit.header.colorScaleZ = colorScale.z;
- layerSubmit.header.colorScaleW = colorScale.w;
- layerSubmit.header.colorBiasX = colorBias.x;
- layerSubmit.header.colorBiasY = colorBias.y;
- layerSubmit.header.colorBiasZ = colorBias.z;
- layerSubmit.header.colorBiasW = colorBias.w;
- layerSubmit.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- if (isHeadLocked)
- {
- layerSubmit.pose.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit.pose.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit.pose.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit.pose.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit.pose.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit.pose.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit.pose.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace |
- PxrLayerSubmitFlags.PxrLayerFlagHeadLocked);
- }
- else
- {
- layerSubmit.pose.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit.pose.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit.pose.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit.pose.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit.pose.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit.pose.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit.pose.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- }
- if (compositeLayer.modelScales[0].z != 0)
- {
- layerSubmit.centralAngle = compositeLayer.modelScales[0].x / compositeLayer.modelScales[0].z;
- }
- else
- {
- Debug.LogError("PXRLog scale.z is 0");
- }
- layerSubmit.height = compositeLayer.modelScales[0].y;
- layerSubmit.radius = compositeLayer.modelScales[0].z;
- PXR_Plugin.Render.UPxr_SubmitLayerCylinder(layerSubmit);
- }
- }
- else if (compositeLayer.overlayShape == PXR_OverLay.OverlayShape.Equirect)
- {
- PxrLayerEquirect2 layerSubmit2 = new PxrLayerEquirect2();
- layerSubmit2.header.layerId = compositeLayer.overlayIndex;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- layerSubmit2.header.colorScaleX = colorScale.x;
- layerSubmit2.header.colorScaleY = colorScale.y;
- layerSubmit2.header.colorScaleZ = colorScale.z;
- layerSubmit2.header.colorScaleW = colorScale.w;
- layerSubmit2.header.colorBiasX = colorBias.x;
- layerSubmit2.header.colorBiasY = colorBias.y;
- layerSubmit2.header.colorBiasZ = colorBias.z;
- layerSubmit2.header.colorBiasW = colorBias.w;
- layerSubmit2.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit2.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit2.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit2.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit2.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit2.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit2.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit2.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- layerSubmit2.header.layerShape = (PXR_OverLay.OverlayShape)4;
- layerSubmit2.header.useLayerBlend = (UInt32)(compositeLayer.useLayerBlend ? 1 : 0);
- layerSubmit2.header.layerBlend.srcColor = compositeLayer.srcColor;
- layerSubmit2.header.layerBlend.dstColor = compositeLayer.dstColor;
- layerSubmit2.header.layerBlend.srcAlpha = compositeLayer.srcAlpha;
- layerSubmit2.header.layerBlend.dstAlpha = compositeLayer.dstAlpha;
- layerSubmit2.header.useImageRect = (UInt32)(compositeLayer.useImageRect ? 1 : 0);
- layerSubmit2.header.imageRectLeft = compositeLayer.getPxrRectiLeft(true);
- layerSubmit2.header.imageRectRight = compositeLayer.getPxrRectiLeft(false);
- layerSubmit2.poseLeft.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseLeft.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseLeft.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseRight.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseRight.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseRight.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.radiusLeft = compositeLayer.radius;
- layerSubmit2.radiusRight = compositeLayer.radius;
- layerSubmit2.centralHorizontalAngleLeft = compositeLayer.dstRectLeft.width * 2 * Mathf.PI;
- layerSubmit2.centralHorizontalAngleRight = compositeLayer.dstRectRight.width * 2 * Mathf.PI;
- layerSubmit2.upperVerticalAngleLeft = (compositeLayer.dstRectLeft.height + compositeLayer.dstRectLeft.y - 0.5f) * Mathf.PI;
- layerSubmit2.upperVerticalAngleRight = (compositeLayer.dstRectRight.height + compositeLayer.dstRectRight.y - 0.5f) * Mathf.PI;
- layerSubmit2.lowerVerticalAngleLeft = (compositeLayer.dstRectLeft.y - 0.5f) * Mathf.PI;
- layerSubmit2.lowerVerticalAngleRight = (compositeLayer.dstRectRight.y - 0.5f) * Mathf.PI;
- if (compositeLayer.isPremultipliedAlpha)
- {
- layerSubmit2.header.layerFlags |= (UInt32)PxrLayerSubmitFlags.PxrLayerFlagPremultipliedAlpha;
- }
- if (PXR_Plugin.Render.UPxr_SubmitLayerEquirect2(layerSubmit2))
- {
- PxrLayerEquirect layerSubmit = new PxrLayerEquirect();
- layerSubmit.header.layerId = compositeLayer.overlayIndex;
- layerSubmit.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- layerSubmit.header.colorScaleX = colorScale.x;
- layerSubmit.header.colorScaleY = colorScale.y;
- layerSubmit.header.colorScaleZ = colorScale.z;
- layerSubmit.header.colorScaleW = colorScale.w;
- layerSubmit.header.colorBiasX = colorBias.x;
- layerSubmit.header.colorBiasY = colorBias.y;
- layerSubmit.header.colorBiasZ = colorBias.z;
- layerSubmit.header.colorBiasW = colorBias.w;
- layerSubmit.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- layerSubmit.header.layerShape = PXR_OverLay.OverlayShape.Equirect;
- layerSubmit.header.useLayerBlend = (UInt32)(compositeLayer.useLayerBlend ? 1 : 0);
- layerSubmit.header.layerBlend.srcColor = compositeLayer.srcColor;
- layerSubmit.header.layerBlend.dstColor = compositeLayer.dstColor;
- layerSubmit.header.layerBlend.srcAlpha = compositeLayer.srcAlpha;
- layerSubmit.header.layerBlend.dstAlpha = compositeLayer.dstAlpha;
- layerSubmit.header.useImageRect = (UInt32)(compositeLayer.useImageRect ? 1 : 0);
- layerSubmit.header.imageRectLeft = compositeLayer.getPxrRectiLeft(true);
- layerSubmit.header.imageRectRight = compositeLayer.getPxrRectiLeft(false);
- layerSubmit.poseLeft.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit.poseLeft.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit.poseLeft.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit.poseLeft.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit.poseLeft.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit.poseLeft.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit.poseLeft.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit.poseRight.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit.poseRight.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit.poseRight.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit.poseRight.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit.poseRight.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit.poseRight.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit.poseRight.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit.radiusLeft = compositeLayer.radius;
- layerSubmit.radiusRight = compositeLayer.radius;
- layerSubmit.scaleXLeft = 1 / compositeLayer.dstRectLeft.width;
- layerSubmit.scaleXRight = 1 / compositeLayer.dstRectRight.width;
- layerSubmit.scaleYLeft = 1 / compositeLayer.dstRectLeft.height;
- layerSubmit.scaleYRight = 1 / compositeLayer.dstRectRight.height;
- layerSubmit.biasXLeft = -compositeLayer.dstRectLeft.x / compositeLayer.dstRectLeft.width;
- layerSubmit.biasXRight = -compositeLayer.dstRectRight.x / compositeLayer.dstRectRight.width;
- layerSubmit.biasYLeft = 1 + (compositeLayer.dstRectLeft.y - 1) / compositeLayer.dstRectLeft.height;
- layerSubmit.biasYRight = 1 + (compositeLayer.dstRectRight.y - 1) / compositeLayer.dstRectRight.height;
- if (compositeLayer.isPremultipliedAlpha)
- {
- layerSubmit.header.layerFlags |= (UInt32)PxrLayerSubmitFlags.PxrLayerFlagPremultipliedAlpha;
- }
- PXR_Plugin.Render.UPxr_SubmitLayerEquirect(layerSubmit);
- }
- }
- else if (compositeLayer.overlayShape == PXR_OverLay.OverlayShape.Cubemap)
- {
- PxrLayerCube2 layerSubmit2 = new PxrLayerCube2();
- layerSubmit2.header.layerId = compositeLayer.overlayIndex;
- layerSubmit2.header.colorScaleX = colorScale.x;
- layerSubmit2.header.colorScaleY = colorScale.y;
- layerSubmit2.header.colorScaleZ = colorScale.z;
- layerSubmit2.header.colorScaleW = colorScale.w;
- layerSubmit2.header.colorBiasX = colorBias.x;
- layerSubmit2.header.colorBiasY = colorBias.y;
- layerSubmit2.header.colorBiasZ = colorBias.z;
- layerSubmit2.header.colorBiasW = colorBias.w;
- layerSubmit2.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit2.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit2.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit2.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit2.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit2.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit2.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit2.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- layerSubmit2.header.layerShape = PXR_OverLay.OverlayShape.Cubemap;
- layerSubmit2.header.useLayerBlend = (UInt32)(compositeLayer.useLayerBlend ? 1 : 0);
- layerSubmit2.header.layerBlend.srcColor = compositeLayer.srcColor;
- layerSubmit2.header.layerBlend.dstColor = compositeLayer.dstColor;
- layerSubmit2.header.layerBlend.srcAlpha = compositeLayer.srcAlpha;
- layerSubmit2.header.layerBlend.dstAlpha = compositeLayer.dstAlpha;
- if (isHeadLocked)
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseLeft.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseLeft.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseRight.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseRight.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseRight.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace |
- PxrLayerSubmitFlags.PxrLayerFlagHeadLocked);
- }
- else
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseLeft.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseLeft.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseRight.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseRight.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseRight.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- }
- if (compositeLayer.isPremultipliedAlpha)
- {
- layerSubmit2.header.layerFlags |= (UInt32)PxrLayerSubmitFlags.PxrLayerFlagPremultipliedAlpha;
- }
- PXR_Plugin.Render.UPxr_SubmitLayerCube2(layerSubmit2);
- }
- else if (compositeLayer.overlayShape == PXR_OverLay.OverlayShape.Eac)
- {
- PxrLayerEac2 layerSubmit2 = new PxrLayerEac2();
- layerSubmit2.header.layerId = compositeLayer.overlayIndex;
- layerSubmit2.header.colorScaleX = colorScale.x;
- layerSubmit2.header.colorScaleY = colorScale.y;
- layerSubmit2.header.colorScaleZ = colorScale.z;
- layerSubmit2.header.colorScaleW = colorScale.w;
- layerSubmit2.header.colorBiasX = colorBias.x;
- layerSubmit2.header.colorBiasY = colorBias.y;
- layerSubmit2.header.colorBiasZ = colorBias.z;
- layerSubmit2.header.colorBiasW = colorBias.w;
- layerSubmit2.header.compositionDepth = compositeLayer.layerDepth;
- layerSubmit2.header.headPose.orientation.x = compositeLayer.cameraRotations[0].x;
- layerSubmit2.header.headPose.orientation.y = compositeLayer.cameraRotations[0].y;
- layerSubmit2.header.headPose.orientation.z = -compositeLayer.cameraRotations[0].z;
- layerSubmit2.header.headPose.orientation.w = -compositeLayer.cameraRotations[0].w;
- layerSubmit2.header.headPose.position.x = (compositeLayer.cameraTranslations[0].x + compositeLayer.cameraTranslations[1].x) / 2;
- layerSubmit2.header.headPose.position.y = (compositeLayer.cameraTranslations[0].y + compositeLayer.cameraTranslations[1].y) / 2;
- layerSubmit2.header.headPose.position.z = -(compositeLayer.cameraTranslations[0].z + compositeLayer.cameraTranslations[1].z) / 2;
- layerSubmit2.header.layerShape = PXR_OverLay.OverlayShape.Eac;
- layerSubmit2.header.useLayerBlend = (UInt32)(compositeLayer.useLayerBlend ? 1 : 0);
- layerSubmit2.header.layerBlend.srcColor = compositeLayer.srcColor;
- layerSubmit2.header.layerBlend.dstColor = compositeLayer.dstColor;
- layerSubmit2.header.layerBlend.srcAlpha = compositeLayer.srcAlpha;
- layerSubmit2.header.layerBlend.dstAlpha = compositeLayer.dstAlpha;
- layerSubmit2.header.useImageRect = (UInt32)(compositeLayer.useImageRect ? 1 : 0);
- layerSubmit2.header.imageRectLeft = compositeLayer.getPxrRectiLeft(true);
- layerSubmit2.header.imageRectRight = compositeLayer.getPxrRectiLeft(false);
- if (isHeadLocked)
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseLeft.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseLeft.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.overlayTransform.localRotation.x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.overlayTransform.localRotation.y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.overlayTransform.localRotation.z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.overlayTransform.localRotation.w;
- layerSubmit2.poseRight.position.x = compositeLayer.overlayTransform.localPosition.x;
- layerSubmit2.poseRight.position.y = compositeLayer.overlayTransform.localPosition.y;
- layerSubmit2.poseRight.position.z = -compositeLayer.overlayTransform.localPosition.z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace |
- PxrLayerSubmitFlags.PxrLayerFlagHeadLocked);
- }
- else
- {
- layerSubmit2.poseLeft.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseLeft.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseLeft.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseLeft.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseLeft.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseLeft.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseLeft.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.poseRight.orientation.x = compositeLayer.modelRotations[0].x;
- layerSubmit2.poseRight.orientation.y = compositeLayer.modelRotations[0].y;
- layerSubmit2.poseRight.orientation.z = -compositeLayer.modelRotations[0].z;
- layerSubmit2.poseRight.orientation.w = -compositeLayer.modelRotations[0].w;
- layerSubmit2.poseRight.position.x = compositeLayer.modelTranslations[0].x;
- layerSubmit2.poseRight.position.y = compositeLayer.modelTranslations[0].y;
- layerSubmit2.poseRight.position.z = -compositeLayer.modelTranslations[0].z;
- layerSubmit2.header.layerFlags = (UInt32)(
- PxrLayerSubmitFlags.PxrLayerFlagUseExternalHeadPose |
- PxrLayerSubmitFlags.PxrLayerFlagLayerPoseNotInTrackingSpace);
- }
- layerSubmit2.offsetPosLeft.x = compositeLayer.offsetPosLeft.x;
- layerSubmit2.offsetPosLeft.y = compositeLayer.offsetPosLeft.y;
- layerSubmit2.offsetPosLeft.z = compositeLayer.offsetPosLeft.z;
- layerSubmit2.offsetPosRight.x = compositeLayer.offsetPosRight.x;
- layerSubmit2.offsetPosRight.y = compositeLayer.offsetPosRight.y;
- layerSubmit2.offsetPosRight.z = compositeLayer.offsetPosRight.z;
- layerSubmit2.offsetRotLeft.x = compositeLayer.offsetRotLeft.x;
- layerSubmit2.offsetRotLeft.y = compositeLayer.offsetRotLeft.y;
- layerSubmit2.offsetRotLeft.z = compositeLayer.offsetRotLeft.z;
- layerSubmit2.offsetRotLeft.w = compositeLayer.offsetRotLeft.w;
- layerSubmit2.offsetRotRight.x = compositeLayer.offsetRotRight.x;
- layerSubmit2.offsetRotRight.y = compositeLayer.offsetRotRight.y;
- layerSubmit2.offsetRotRight.z = compositeLayer.offsetRotRight.z;
- layerSubmit2.offsetRotRight.w = compositeLayer.offsetRotRight.w;
- layerSubmit2.degreeType = (uint)compositeLayer.eacModelType;
- layerSubmit2.overlapFactor = compositeLayer.overlapFactor;
- layerSubmit2.timestamp = compositeLayer.timestamp;
- if (compositeLayer.isPremultipliedAlpha)
- {
- layerSubmit2.header.layerFlags |= (UInt32)PxrLayerSubmitFlags.PxrLayerFlagPremultipliedAlpha;
- }
- PXR_Plugin.Render.UPxr_SubmitLayerEac2(layerSubmit2);
- }
- }
- }
- }
- }
- }
|