From 78fec2844cc6cf8c5f0f81a685e01bc4ff23075e Mon Sep 17 00:00:00 2001 From: srl87 Date: Mon, 26 Feb 2024 13:53:59 +0800 Subject: [PATCH] 5.6.0-r.10.1 --- .../Raycast/HandRaycastPointerEditor.cs | 6 +- .../Scripts/Raycast/HandRaycastPointer.cs | 6 +- .../Essence/Raycast/RaycastEyeTracking.unity | 10 +- .../Essence/Raycast/Scripts/HandPinchArea.cs | 14 +- .../wave_essence_bodytracking.unitypackage | 4 +- .../wave_essence_bundlepreview.unitypackage | 4 +- .../wave_essence_cameratexture.unitypackage | 4 +- .../wave_essence_compositorlayer.unitypackage | 4 +- ...wave_essence_controller_model.unitypackage | 4 +- .../wave_essence_hand_model.unitypackage | 4 +- .../wave_essence_inputmodule.unitypackage | 4 +- ...wave_essence_interaction_mode.unitypackage | 4 +- ...e_essence_interaction_toolkit.unitypackage | 4 +- .../wave_essence_renderdoc.unitypackage | 4 +- .../wave_essence_sceneperception.unitypackage | 4 +- .../wave_essence_spectator.unitypackage | 4 +- .../wave_essence_trackablemarker.unitypackage | 4 +- .../wave_essence_tracker_model.unitypackage | 4 +- com.htc.upm.wave.essence/package.json | 6 +- com.htc.upm.wave.essence/package.tm1.meta | 2 +- com.htc.upm.wave.native/package.json | 4 +- com.htc.upm.wave.native/package.tm1.meta | 2 +- .../Runtime/GitIgnored/Resources.meta | 2 +- .../GitIgnored/Resources/commit_info.json | 4 +- .../Resources/commit_info.json.meta | 2 +- .../Runtime/WaveXRSpectatorCamera.cs | 6 +- .../Runtime/WaveXRSpectatorCameraHandle.cs | 718 +++++++++++------- .../wave_xrsdk_androidmanifest.unitypackage | 4 +- com.htc.upm.wave.xrsdk/package.json | 2 +- com.htc.upm.wave.xrsdk/package.tm1.meta | 2 +- 30 files changed, 509 insertions(+), 337 deletions(-) diff --git a/com.htc.upm.wave.essence/Runtime/Editor/Raycast/HandRaycastPointerEditor.cs b/com.htc.upm.wave.essence/Runtime/Editor/Raycast/HandRaycastPointerEditor.cs index 6406242f..14dab165 100644 --- a/com.htc.upm.wave.essence/Runtime/Editor/Raycast/HandRaycastPointerEditor.cs +++ b/com.htc.upm.wave.essence/Runtime/Editor/Raycast/HandRaycastPointerEditor.cs @@ -25,7 +25,7 @@ public class HandRaycastPointerEditor : UnityEditor.Editor /// HandRaycastPointer options SerializedProperty m_Hand, m_UsePose, m_PinchStrength, m_PinchRelease, m_AlwaysEnable; /// Interactive area options - SerializedProperty m_EnablePinchArea, m_LeftInteractive, m_RightInteractive, m_TopInteractive, m_ButtomInteractive; + SerializedProperty m_EnablePinchArea, m_LeftInteractive, m_RightInteractive, m_TopInteractive, m_BottomInteractive; private void OnEnable() { @@ -49,7 +49,7 @@ private void OnEnable() m_LeftInteractive = serializedObject.FindProperty("m_LeftInteractive"); m_RightInteractive = serializedObject.FindProperty("m_RightInteractive"); m_TopInteractive = serializedObject.FindProperty("m_TopInteractive"); - m_ButtomInteractive = serializedObject.FindProperty("m_ButtomInteractive"); + m_BottomInteractive = serializedObject.FindProperty("m_BottomInteractive"); } bool PhysicsRaycasterOptions = false, RayOptions = true, HandOptions = true, AreaOptions = true; public override void OnInspectorGUI() @@ -115,7 +115,7 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(m_LeftInteractive); EditorGUILayout.PropertyField(m_RightInteractive); EditorGUILayout.PropertyField(m_TopInteractive); - EditorGUILayout.PropertyField(m_ButtomInteractive); + EditorGUILayout.PropertyField(m_BottomInteractive); } EditorGUILayout.LabelField("", GUI.skin.horizontalSlider); diff --git a/com.htc.upm.wave.essence/Runtime/Scripts/Raycast/HandRaycastPointer.cs b/com.htc.upm.wave.essence/Runtime/Scripts/Raycast/HandRaycastPointer.cs index 3e1de5d2..26a1de00 100644 --- a/com.htc.upm.wave.essence/Runtime/Scripts/Raycast/HandRaycastPointer.cs +++ b/com.htc.upm.wave.essence/Runtime/Scripts/Raycast/HandRaycastPointer.cs @@ -119,8 +119,8 @@ private void Validate() public float TopInteractive { get { return m_TopInteractive; } set { m_TopInteractive = value; } } [SerializeField] [Range(0, .5f)] - private float m_ButtomInteractive = 0.3f; - public float ButtomInteractive { get { return m_ButtomInteractive; } set { m_ButtomInteractive = value; } } + private float m_BottomInteractive = 0.3f; + public float BottomInteractive { get { return m_BottomInteractive; } set { m_BottomInteractive = value; } } #endregion private Vector3 origin = Vector3.zero, direction = Vector3.zero; @@ -179,7 +179,7 @@ private bool IsInteractiveArea() { Vector3 pixelPosition = Camera.main.WorldToViewportPoint(Pointer.transform.position); return pixelPosition.x > m_LeftInteractive && pixelPosition.x < m_RightInteractive && - pixelPosition.y > m_ButtomInteractive && pixelPosition.y < m_TopInteractive; + pixelPosition.y > m_BottomInteractive && pixelPosition.y < m_TopInteractive; } return true; } diff --git a/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/RaycastEyeTracking.unity b/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/RaycastEyeTracking.unity index 429f8fd6..0c26d29d 100644 --- a/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/RaycastEyeTracking.unity +++ b/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/RaycastEyeTracking.unity @@ -190,7 +190,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: Buttom + m_Text: Bottom --- !u!222 &261203 CanvasRenderer: m_ObjectHideFlags: 0 @@ -6838,7 +6838,7 @@ GameObject: m_Component: - component: {fileID: 1652283539} m_Layer: 5 - m_Name: Buttom + m_Name: Bottom m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -10459,8 +10459,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 114305613345136316} m_HandleRect: {fileID: 224225765845599858} m_Direction: 2 - m_Value: -0.0000004455121 - m_Size: 0.5430327 + m_Value: -0.00000011137802 + m_Size: 0.5422854 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -11102,7 +11102,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -0.000019073486, y: 137.00005} + m_AnchoredPosition: {x: -0.000019073486, y: 137.00003} m_SizeDelta: {x: 0, y: 300} m_Pivot: {x: 0, y: 1} --- !u!224 &224701558979040588 diff --git a/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/Scripts/HandPinchArea.cs b/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/Scripts/HandPinchArea.cs index 9a7a93f4..e0112642 100644 --- a/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/Scripts/HandPinchArea.cs +++ b/com.htc.upm.wave.essence/Samples~/Essence/Essence/Raycast/Scripts/HandPinchArea.cs @@ -16,7 +16,7 @@ public class HandPinchArea : MonoBehaviour private Image image; private RectTransform rectTransform; private float m_Left = 0; - private float m_Buttom = 0; + private float m_Bottom = 0; private float m_Right = 0; private float m_Top = 0; private bool isShowArea = false; @@ -29,7 +29,7 @@ private void Awake() if (leftHandRay != null || rightHandRay != null) { m_Left = leftHandRay.LeftInteractive < rightHandRay.LeftInteractive ? leftHandRay.LeftInteractive : rightHandRay.LeftInteractive; - m_Buttom = leftHandRay.ButtomInteractive < rightHandRay.ButtomInteractive ? leftHandRay.ButtomInteractive : rightHandRay.ButtomInteractive; + m_Bottom = leftHandRay.BottomInteractive < rightHandRay.BottomInteractive ? leftHandRay.BottomInteractive : rightHandRay.BottomInteractive; m_Right = leftHandRay.RightInteractive > rightHandRay.RightInteractive ? leftHandRay.RightInteractive : rightHandRay.RightInteractive; m_Top = leftHandRay.TopInteractive > rightHandRay.TopInteractive ? leftHandRay.TopInteractive : rightHandRay.TopInteractive; } @@ -44,7 +44,7 @@ private void Update() return; } - rectTransform.anchorMin = new Vector2(m_Left, m_Buttom); + rectTransform.anchorMin = new Vector2(m_Left, m_Bottom); rectTransform.anchorMax = new Vector2(m_Right, m_Top); rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; @@ -58,9 +58,9 @@ public void OnLeftValueChange(float vlaue) { leftHandRay.LeftInteractive = rightHandRay.LeftInteractive = m_Left = vlaue; } - public void OnButtomValueChange(float vlaue) + public void OnBottomValueChange(float vlaue) { - leftHandRay.ButtomInteractive = rightHandRay.ButtomInteractive = m_Buttom = vlaue; + leftHandRay.BottomInteractive = rightHandRay.BottomInteractive = m_Bottom = vlaue; } public void OnRightValueChange(float vlaue) { @@ -74,9 +74,9 @@ public void OnLeftValueChange(Text text) { text.text = m_Left.ToString("F2"); } - public void OnButtomValueChange(Text text) + public void OnBottomValueChange(Text text) { - text.text = m_Buttom.ToString("F2"); + text.text = m_Bottom.ToString("F2"); } public void OnRightValueChange(Text text) { diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bodytracking.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bodytracking.unitypackage index 30402d0f..9c3c89f6 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bodytracking.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bodytracking.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:70d556e683f5f2bb803d41c138bc129179e7f930ef7cca52492dfef8ae17abc0 -size 18661984 +oid sha256:4e4517418c4df95b63fabb058ad82fba629e824bf939e56de41e3f8d88909ca8 +size 29239406 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bundlepreview.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bundlepreview.unitypackage index 9349ec84..d767451d 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bundlepreview.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_bundlepreview.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1d365c1cc7fccf7786cbd31349c451b27be6c2924f1dd2221c3248a7647014c7 -size 12788 +oid sha256:4e974526ef66e3bcd3a46550e165676bc4b3dddf21b5c1f19dcc63a8b4380767 +size 12777 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_cameratexture.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_cameratexture.unitypackage index c35eb362..35a23e1b 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_cameratexture.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_cameratexture.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e7826dea730b573908e6066f795cc6e019b50227e5f1f5411cc6d3bbec9a9450 -size 4385 +oid sha256:313961cb90caf72969bcdf3f961dacaa6cee1891166bb6acf4c61a443e9f759e +size 4390 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_compositorlayer.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_compositorlayer.unitypackage index 89678ef4..b1dc25e9 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_compositorlayer.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_compositorlayer.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a7c2b363d0533b5e46d05e42f10295d640b8b38fe8e22ee0b40d7035cdb017ee -size 206042 +oid sha256:aac1eb3a09957f9e648d872a6134432eb1df6b5b3fd12bfb9d37716459d82257 +size 3485465 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_controller_model.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_controller_model.unitypackage index df870a4e..17840173 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_controller_model.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_controller_model.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9519401accf7edd453b2fc81b2e09afe0c3b48a62616d32ff726646598360afc -size 4486751 +oid sha256:567b764a63f05ab2e2e46a31143bd06b8b5e4462607ca92c85082688429f38e0 +size 4487478 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_hand_model.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_hand_model.unitypackage index ccc66e61..807799ea 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_hand_model.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_hand_model.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12763dee1eb0fd7c549b355282849f6ce5318d8e18fdf5613710cdccb387a462 -size 1821230 +oid sha256:70814fcbf9dbff0a64568608ef0c9bf37842485b880cff6056a128addf0af581 +size 1821260 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_inputmodule.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_inputmodule.unitypackage index 3fd3b6f2..aebd3e0b 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_inputmodule.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_inputmodule.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a8f090295c434673dbd5d738945d06ea3fb6b6109182767f3c2565ed5c544522 -size 2348342 +oid sha256:28147f9e39160e0a2bf3362e70a45bfc0ec75798f50149e425b940f45f9827ea +size 2349759 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_mode.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_mode.unitypackage index 40631a67..5b7ba342 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_mode.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_mode.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db8713e362eeaee3bd65fbca1841983c1f2759100a30a240b79a045a35912908 -size 60314 +oid sha256:c247c0cd7015ba40a35d8ae2fda7e5f7ceacb91df809e6de887ecac027ce21e8 +size 60337 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_toolkit.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_toolkit.unitypackage index ec604b2e..ad4bd77b 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_toolkit.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_interaction_toolkit.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a9bcb3ab8884235c4c9855eb24743b17c2d0db75b48f9b73915e1eea32154735 -size 1474872 +oid sha256:32dc08fc5714f6be01dab06abb39dbd20f129352b7b0cd73da347f1f219d9071 +size 1474966 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_renderdoc.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_renderdoc.unitypackage index 3ce2c244..6fb00363 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_renderdoc.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_renderdoc.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:76fb5b012651e62080e9ad56054f03d9fd0a3a6b732b706503fa6c24164d8ec7 -size 7304 +oid sha256:bf54c75c76ce6d67ac2cd9486a14c87b2125268b3f0a389f34d5930bb988c951 +size 7300 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_sceneperception.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_sceneperception.unitypackage index c5653bda..822cff38 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_sceneperception.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_sceneperception.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:dabd407a3ebc27c536d6ba2ec0cefde55ddebd0db6ec68efbb336875dc0b4c46 -size 248711 +oid sha256:0f3ed71a70a7f8dba871e35c6c45eb83ac76830b99d56b11cef43bb59c78ceb5 +size 248367 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_spectator.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_spectator.unitypackage index a368a563..3fa2d432 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_spectator.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_spectator.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:83a348658519b9a744e33a778d1a47e03cc15f22dae3386884f4e4dc3f15a704 -size 175612 +oid sha256:1446eb85986c80c69a233eaa7c7adecdb730322710d13507f00f40da77383040 +size 176170 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_trackablemarker.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_trackablemarker.unitypackage index 61f13b43..2753a0a8 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_trackablemarker.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_trackablemarker.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08da9d91f8a59685f675ca38c1a7cd4953924333c1b0a5eb75f2fec5abe9aa45 -size 36490 +oid sha256:40d9f96d4c0c8de5be76acbd3de4bec93878b4a8a90f12ab310147687f979711 +size 36483 diff --git a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_tracker_model.unitypackage b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_tracker_model.unitypackage index 6d309204..9c84ed96 100644 --- a/com.htc.upm.wave.essence/UnityPackages~/wave_essence_tracker_model.unitypackage +++ b/com.htc.upm.wave.essence/UnityPackages~/wave_essence_tracker_model.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d3919e62235001f971ad60b3264d75abcd94699c49a837171604773e19f6a85 -size 8619597 +oid sha256:6937bb928f97ae0db26a300495e1fa4615085db32ba0f86957637dc8be3817d6 +size 8619810 diff --git a/com.htc.upm.wave.essence/package.json b/com.htc.upm.wave.essence/package.json index f9320b7b..60b88523 100644 --- a/com.htc.upm.wave.essence/package.json +++ b/com.htc.upm.wave.essence/package.json @@ -1,7 +1,7 @@ { "name": "com.htc.upm.wave.essence", "displayName": "VIVE Wave XR Plugin - Essence", - "version": "5.6.0-r.10", + "version": "5.6.0-r.10.1", "unity": "2019.4", "description": "The \"VIVE Wave XR Plugin - Essence\" package built on top of the \"VIVE Wave XR Plugin - Native\" package.The package provides rich features that make your developerment easier.\n\nYou can view the documentation for additional information.\n\n", "keywords": [ @@ -15,8 +15,8 @@ "url": "https://www.htc.com" }, "dependencies": { - "com.htc.upm.wave.xrsdk": "5.6.0-r.10", - "com.htc.upm.wave.native": "5.6.0-r.10" + "com.htc.upm.wave.xrsdk": "5.6.0-r.10.1", + "com.htc.upm.wave.native": "5.6.0-r.10.1" }, "samples": [ { diff --git a/com.htc.upm.wave.essence/package.tm1.meta b/com.htc.upm.wave.essence/package.tm1.meta index fe255726..ba28003f 100644 --- a/com.htc.upm.wave.essence/package.tm1.meta +++ b/com.htc.upm.wave.essence/package.tm1.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 3085a8567da6be74abe72e08cdeaae68 +guid: 9388205f34610f0468fe5e4f5d63ac5f DefaultImporter: externalObjects: {} userData: diff --git a/com.htc.upm.wave.native/package.json b/com.htc.upm.wave.native/package.json index e01ad294..b7774bc2 100644 --- a/com.htc.upm.wave.native/package.json +++ b/com.htc.upm.wave.native/package.json @@ -1,7 +1,7 @@ { "name": "com.htc.upm.wave.native", "displayName": "VIVE Wave XR Plugin - Native", - "version": "5.6.0-r.10", + "version": "5.6.0-r.10.1", "unity": "2019.4", "description": "The \"VIVE Wave XR Plugin - Native\" package provides the wraper of WaveVR.\n\nView the documentation for additional information.\n\n", "keywords": [ @@ -15,7 +15,7 @@ "url": "https://www.htc.com" }, "dependencies": { - "com.htc.upm.wave.xrsdk": "5.6.0-r.10" + "com.htc.upm.wave.xrsdk": "5.6.0-r.10.1" }, "samples": [ { diff --git a/com.htc.upm.wave.native/package.tm1.meta b/com.htc.upm.wave.native/package.tm1.meta index 22c64d2e..16e15e7a 100644 --- a/com.htc.upm.wave.native/package.tm1.meta +++ b/com.htc.upm.wave.native/package.tm1.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 01cc7e80307f7df4a93051ddac7d50de +guid: 4b077b4002e3c6c49a3ab05faa772fab DefaultImporter: externalObjects: {} userData: diff --git a/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources.meta b/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources.meta index c0de1d11..dc67aeda 100644 --- a/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources.meta +++ b/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 842da150dee94924ca5df6d297f2a38f +guid: 8d78870c4cc8c7c49951c75e4bb71395 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json b/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json index f980e842..899357b1 100644 --- a/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json +++ b/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json @@ -1,9 +1,9 @@ { - "commit": "cf093118a38a00b2363023ca0f96c5706bb792fc", + "commit": "99e1117706883d3cc49e6a0c731df33ecd3cae32", - "abbreviated_commit": "cf093118a", + "abbreviated_commit": "99e111770", "refs": "HEAD -> master, origin/master, origin/HEAD" diff --git a/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json.meta b/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json.meta index e4570a1f..bf0bd08f 100644 --- a/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json.meta +++ b/com.htc.upm.wave.xrsdk/Runtime/GitIgnored/Resources/commit_info.json.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 7401110418193f646b3fc813eee6c3b3 +guid: 0160c10819e8e8d4ebcd05c70419e95c TextScriptImporter: externalObjects: {} userData: diff --git a/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCamera.cs b/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCamera.cs index fb05e518..49c4ab49 100644 --- a/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCamera.cs +++ b/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCamera.cs @@ -1,10 +1,10 @@ using UnityEngine; -namespace Wave.XR { - +namespace Wave.XR +{ public sealed class WaveXRSpectatorCamera : MonoBehaviour { - WaveXRSpectatorCameraHandle handle; + private WaveXRSpectatorCameraHandle handle; public void SetHandle(WaveXRSpectatorCameraHandle handle) { diff --git a/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCameraHandle.cs b/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCameraHandle.cs index 6f882ff7..c180f904 100644 --- a/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCameraHandle.cs +++ b/com.htc.upm.wave.xrsdk/Runtime/WaveXRSpectatorCameraHandle.cs @@ -1,7 +1,6 @@ using System.Runtime.InteropServices; using System.Text; using UnityEngine; -using UnityEngine.Profiling; using UnityEngine.SceneManagement; using Wave.XR.Function; @@ -9,211 +8,187 @@ namespace Wave.XR { public sealed class WaveXRSpectatorCameraHandle : MonoBehaviour { - static readonly string TAG = "WXRSpecCamH"; - static WaveXRSpectatorCameraHandle instance; - uint frameCount = 0; - bool changedST = false; // change start - bool changedSR = false; // change should render - bool run = false; - bool shouldRenderFrame = false; - Camera spectatorCamera; - GameObject spectatorCameraObject; - WaveXRSpectatorCamera spectatorCameraComponent; - StringBuilder sb = new StringBuilder(300); - - System.IntPtr textureId; - RenderTexture renderTexture; - Material debugMaterial; - // These fields is used to control spectator in editor public bool debugStartCamera = false; public bool debugRenderFrame = false; - public float debugAccTime = 0; public int debugFPS = 30; + private float debugAccTime = 0; + private Material debugMaterial; + + private static WaveXRSpectatorCameraHandle instance; + + // Camera state + private bool changedST = false; // change start + private bool changedSR = false; // change should render + private bool run = false; // camera is running or not + private bool shouldRenderFrame = false; // should render the frame in current time + // Unity component + private Camera spectatorCamera; + private GameObject spectatorCameraObject; + private WaveXRSpectatorCamera spectatorCameraComponent; + private readonly StringBuilder sb = new StringBuilder(300); + + // Texture + private System.IntPtr textureId; + private RenderTexture renderTexture; + + // Override pose variables private bool hasOverridePose = false; private Vector3 overridePosition; private Quaternion overrideRotation; + // Override fov variables private bool hasOverrideFov = false; private float overrideFov = 90.0f; + // Override culling mask variables private bool hasOverrideCullingMask = false; private int overrideCullingMask = 0x0; - [StructLayout(LayoutKind.Sequential)] - public struct RenderParametersNative - { - public bool isStarted; - public bool shouldRender; - public bool isParametersValid; - public bool hasPose; - public uint width; - public uint height; - public float l; - public float r; - public float t; - public float b; - public Vector3 position; - public Quaternion rotation; - } - - public struct RenderParameters - { - public bool isStarted; - public bool shouldRender; - public bool isParametersValid; - public bool hasPose; - public int width; - public int height; - public float l; - public float r; - public float t; - public float b; - public Vector3 position; - public Quaternion rotation; - public float n; - public float f; - public Matrix4x4 proj; + // Current frame render parameters of the spectator + private RenderParameters renderParameters = new RenderParameters(); - public void Set(RenderParametersNative na) + // Render thread task + private readonly RenderThreadTask task = new RenderThreadTask( + // receiver + (queue) => { - isStarted = na.isStarted; - shouldRender= na.shouldRender; - isParametersValid = na.isParametersValid; - hasPose = na.hasPose; - width = (int)na.width; - height = (int)na.height; - l = na.l; - r = na.r; - t = na.t; - b = na.b; - proj = WaveXRSpectatorCameraHandle.Frustum(l, r, t, b, n, f); + //Debug.Log("RunInRenderThread"); + System.IntPtr nativeTexId; + lock (queue) + { + // Run in RenderThread + var msg = (RTData)queue.Dequeue(); + nativeTexId = msg.TextureId; + queue.Release(msg); + } +#if UNITY_EDITOR + if (Application.isEditor) return; +#endif + setSpectatorTexture(nativeTexId); } + ); - public void CalculateProj(float near, float far) - { - n = near; - f = far; - if (this.isParametersValid) - proj = WaveXRSpectatorCameraHandle.Frustum(l, r, t, b, n, f); - } - } + // Callback function when spectator start/stop + public OnSpectatorStartDelegate OnSpectatorStart; + public OnSpectatorStopDelegate OnSpectatorStop; + + private static IsSpectatorStartedDelegate isSpectatorStarted; + private static ShouldSpectatorRenderFrameDelegate shouldSpectatorRenderFrame; + private static SetSpectatorTextureDelegate setSpectatorTexture; + private static GetSpectatorRenderParametersDelegate getSpectatorRenderParameters; - RenderParameters renderParameters = new RenderParameters(); + // Shader property + private static readonly int MainTex = Shader.PropertyToID("_MainTex"); + #region Public function of spectator handler + + /// + /// Get the instance of WaveXRSpectatorCameraHandle + /// + /// WaveXRSpectatorCameraHandle component public static WaveXRSpectatorCameraHandle GetInstance() { return instance; } - private static void InitCheck() - { - if (instance != null) return; - var initOnLoad = WaveXRRuntimeInitializeOnLoad.GetInstance(); - instance = initOnLoad.gameObject.AddComponent(); - if (!GetFunctions()) - instance.enabled = false; - } - - public static void OnSceneLoaded(Scene scene, LoadSceneMode mode) + /// + /// Get spectator camera + /// + /// Camera component + public Camera GetCamera() { - InitCheck(); + return spectatorCamera; } - private void OnApplicationPause(bool pause) + /// + /// The event function that Unity calls after spectator camera renders the scene. + /// This will update the spectator camera texture and then submit to the render thread. + /// + public void OnCameraPostRender() { - if (pause) - { - ReleaseResource(); - } - else + if (textureId == System.IntPtr.Zero && renderTexture != null) { + textureId = renderTexture.GetNativeTexturePtr(); } + + SubmitInRenderThread(); } - public void OnEnable() + /// + /// Set the spectator camera pose by specific input position and rotation. + /// + /// The position you want to set to the spectator camera. + /// The rotation you want to set to the spectator camera. + public void SetFixedPose(Vector3 position, Quaternion rotation) { - // This only available if you put this material in Resources folder. We put it in our sample. - debugMaterial = Resources.Load("Spectator/SpectatorCaptured"); + hasOverridePose = true; + overridePosition = position; + overrideRotation = rotation; } - public void OnDisable() + /// + /// Reset the spectator camera pose and set it to the main camera pose. + /// + public void ClearFixedPose() { - ReleaseResource(); + hasOverridePose = false; } + /// + /// Set the spectator camera fov by specific input value. + /// + /// The FOV value you want to set to the spectator camera. + public void SetFixedFOV(float fov) + { + hasOverrideFov = true; + overrideFov = Mathf.Clamp(fov, 5, 130); + } - // Update is called once per frame - void Update() + /// + /// Reset the spectator camera fov value. + /// + public void ClearFixedFOV() { - StatusCheck(); - if (!run) return; - // Prepare camera before rending - if (!CheckCamera()) return; // No main camera found - spectatorCamera.enabled = false; - if (!shouldRenderFrame) return; // this frame skipped. - UpdateRenderParameters(); - frameCount++; + hasOverrideFov = false; } - private void OnDestroy() + /// + /// Set the spectator camera culling mask by specific input value. + /// + /// The culling mask you want to set to the spectator camera. + public void SetCullingMask(int cullingMask) { - ReleaseResource(); + hasOverrideCullingMask = true; + overrideCullingMask = cullingMask; } - private void CopyMainCameraParameters() + /// + /// Reset the spectator camera culling mask. + /// + public void ClearCullingMask() { - Camera main = Camera.main; - if (hasOverridePose) - { - spectatorCamera.transform.position = overridePosition; - spectatorCamera.transform.rotation = overrideRotation; - } - else - { - spectatorCamera.transform.position = main.transform.position; - spectatorCamera.transform.rotation = main.transform.rotation; - } - spectatorCamera.farClipPlane = main.farClipPlane; - spectatorCamera.nearClipPlane = main.nearClipPlane; - spectatorCamera.allowHDR = false; - spectatorCamera.allowDynamicResolution = false; - spectatorCamera.allowMSAA = main.allowMSAA; - spectatorCamera.backgroundColor = main.backgroundColor; - spectatorCamera.clearFlags = main.clearFlags; - spectatorCamera.cullingMask = hasOverrideCullingMask ? overrideCullingMask : main.cullingMask; - // No matter what depth we set, the mono camera always run before stereo camera. See Profiler to check. - spectatorCamera.depth = Camera.main.depth + 99; - spectatorCamera.depthTextureMode = main.depthTextureMode; - spectatorCamera.useOcclusionCulling = main.useOcclusionCulling; - spectatorCamera.stereoTargetEye = StereoTargetEyeMask.None; + hasOverrideCullingMask = false; } + + #endregion Public function of spectator handler - // Called when parameters are validate. - private void CheckTexture() + #region Private function of spectator handler internal usage in its lifecycle + + private static void Init() { - var rp = renderParameters; - bool changed = false; - if (renderTexture != null) + if (instance != null) { - changed = renderTexture.width != rp.width || renderTexture.height != rp.height; - if (changed) - DestroyRenderTexture(); + return; } - if (renderTexture == null) - { - renderTexture = new RenderTexture(rp.width, rp.height, 32); - changed = true; - } + var initOnLoad = WaveXRRuntimeInitializeOnLoad.GetInstance(); + instance = initOnLoad.gameObject.AddComponent(); - if (!renderTexture.IsCreated()) + if (!GetFunctions()) { - textureId = System.IntPtr.Zero; - renderTexture.Create(); - if (debugMaterial) - debugMaterial.SetTexture("_MainTex", renderTexture); + instance.enabled = false; } } @@ -225,12 +200,17 @@ private void DestroyRenderTexture() Destroy(renderTexture, 0.5f); renderTexture = null; } + textureId = System.IntPtr.Zero; } private void DestroyCamera() { - if (spectatorCamera == null) return; + if (spectatorCamera == null) + { + return; + } + spectatorCamera.targetTexture = null; spectatorCamera = null; spectatorCameraComponent = null; @@ -243,7 +223,9 @@ private void ReleaseResource() DestroyRenderTexture(); DestroyCamera(); if (debugMaterial) - debugMaterial.SetTexture("_MainTex", null); + { + debugMaterial.SetTexture(MainTex, null); + } } private bool CheckCamera() @@ -251,8 +233,11 @@ private bool CheckCamera() if (Camera.main == null) { if (spectatorCamera == null) - return false; + { + return false; + } } + if (spectatorCamera == null) { spectatorCameraObject = new GameObject("Spectator"); @@ -265,10 +250,42 @@ private bool CheckCamera() CopyMainCameraParameters(); } + return true; } - private void StatusCheck() + // Called when parameters are validate. + private void CheckTexture() + { + var rp = renderParameters; + if (renderTexture != null) + { + bool changed = renderTexture.width != (int)rp.RenderParametersNative.width || + renderTexture.height != (int)rp.RenderParametersNative.height; + if (changed) + { + DestroyRenderTexture(); + } + } + + if (renderTexture == null) + { + renderTexture = new RenderTexture((int)rp.RenderParametersNative.width, + (int)rp.RenderParametersNative.height, 32); + } + + if (!renderTexture.IsCreated()) + { + textureId = System.IntPtr.Zero; + renderTexture.Create(); + if (debugMaterial) + { + debugMaterial.SetTexture(MainTex, renderTexture); + } + } + } + + private void CheckStatus() { #if UNITY_EDITOR if (Application.isEditor) @@ -285,15 +302,27 @@ private void StatusCheck() debugAccTime += Time.unscaledDeltaTime; if (debugAccTime > (1.0f / debugFPS)) { + // This frame should render shouldRenderFrame = true; debugAccTime = 0; } + else + { + // This frame should not render due to fps setting + shouldRenderFrame = false; + } + } + else + { + // This frame should not render due to the "fps" flag statement (equal to false) + shouldRenderFrame = false; } + return; } #endif - bool isStarted = IsSpectatorStarted(); + bool isStarted = isSpectatorStarted(); changedST = run != isStarted; changedSR = false; run = isStarted; @@ -302,21 +331,31 @@ private void StatusCheck() try { if (isStarted) - onSpectatorStart(); + { + OnSpectatorStart(); + } else - onSpectatorStop(); + { + OnSpectatorStop(); + } + } + catch + { + // ignored } - catch (System.Exception) { } shouldRenderFrame = false; - frameCount = 0; } + if (changedST && !run) + { + // state change to stop ReleaseResource(); + } if (run) { - bool shouldRender = ShouldSpectatorRenderFrame(); + bool shouldRender = shouldSpectatorRenderFrame(); changedSR = shouldRenderFrame != shouldRender; shouldRenderFrame = shouldRender; } @@ -334,8 +373,8 @@ private void StatusCheck() } } - // The Matrix4x4.Frustum will imply the z-flip matrix. Use custom projection instead. - static Matrix4x4 Frustum(float left, float right, float top, float bottom, float near, float far) + // The Matrix4x4.Frustum will imply the z-flip matrix. Use custom projection instead. + private static Matrix4x4 Frustum(float left, float right, float top, float bottom, float near, float far) { float x = 2.0F / (right - left); float y = 2.0F / (top - bottom); @@ -364,44 +403,46 @@ static Matrix4x4 Frustum(float left, float right, float top, float bottom, float return m; } - // Set pose in world space - public void SetFixedPose(Vector3 position, Quaternion rotation) - { - hasOverridePose = true; - overridePosition = position; - overrideRotation = rotation; - } - - public void ClearFixedPose() - { - hasOverridePose = false; - } - - public void SetFixedFOV(float fov) + private void CopyMainCameraParameters() { - hasOverrideFov = true; - overrideFov = Mathf.Clamp(fov, 5, 130); - } + Camera main = Camera.main; + if (hasOverridePose) + { + var spectatorCameraTransform = spectatorCamera.transform; - public void ClearFixedFOV() - { - hasOverrideFov = false; - } + spectatorCameraTransform.position = overridePosition; + spectatorCameraTransform.rotation = overrideRotation; + } + else + { + if (!(main is null)) + { + var mainCameraTransform = main.transform; + var spectatorCameraTransform = spectatorCamera.transform; - public void SetCullingMask(int cullingMask) - { - hasOverrideCullingMask = true; - overrideCullingMask = cullingMask; - } + spectatorCameraTransform.position = mainCameraTransform.position; + spectatorCameraTransform.rotation = mainCameraTransform.rotation; + } + } - public void ClearCullingMask() - { - hasOverrideCullingMask = false; - } + if (!(main is null)) + { + spectatorCamera.farClipPlane = main.farClipPlane; + spectatorCamera.nearClipPlane = main.nearClipPlane; + spectatorCamera.allowMSAA = main.allowMSAA; + spectatorCamera.backgroundColor = main.backgroundColor; + spectatorCamera.clearFlags = main.clearFlags; + spectatorCamera.depth = + main.depth + + 99; // No matter what depth we set, the mono camera always run before stereo camera. See Profiler to check. + spectatorCamera.depthTextureMode = main.depthTextureMode; + spectatorCamera.useOcclusionCulling = main.useOcclusionCulling; + spectatorCamera.cullingMask = hasOverrideCullingMask ? overrideCullingMask : main.cullingMask; + } - public RenderParameters GetRenderParameters() - { - return renderParameters; + spectatorCamera.allowHDR = false; + spectatorCamera.allowDynamicResolution = false; + spectatorCamera.stereoTargetEye = StereoTargetEyeMask.None; } private void UpdateRenderParameters() @@ -419,8 +460,15 @@ private void UpdateRenderParameters() n.width = 1920; n.height = 1080; if (!Application.isEditor) + { +#endif + // Get the render parameters from native + n.isParametersValid = + getSpectatorRenderParameters(ref n.width, ref n.height, ref n.l, ref n.r, ref n.t, ref n.b); +#if UNITY_EDITOR + } #endif - n.isParametersValid = GetSpectatorRenderParameters(ref n.width, ref n.height, ref n.l, ref n.r, ref n.t, ref n.b); + renderParameters.Set(n); if (changedSR) @@ -439,49 +487,84 @@ private void UpdateRenderParameters() Application.SetStackTraceLogType(LogType.Log, t); } - if (renderParameters.isParametersValid) + if (renderParameters.RenderParametersNative.isParametersValid) { CheckTexture(); CopyMainCameraParameters(); if (hasOverrideFov) { - float aspect = renderParameters.width / (float)renderParameters.height; - spectatorCamera.projectionMatrix = Matrix4x4.Perspective(overrideFov, aspect, spectatorCamera.nearClipPlane, spectatorCamera.farClipPlane); + float aspect = renderParameters.RenderParametersNative.width / + (float)renderParameters.RenderParametersNative.height; + spectatorCamera.projectionMatrix = Matrix4x4.Perspective(overrideFov, aspect, + spectatorCamera.nearClipPlane, spectatorCamera.farClipPlane); } else { renderParameters.CalculateProj(spectatorCamera.nearClipPlane, spectatorCamera.farClipPlane); - spectatorCamera.projectionMatrix = renderParameters.proj; + spectatorCamera.projectionMatrix = renderParameters.Proj; } + spectatorCamera.targetTexture = renderTexture; spectatorCamera.enabled = true; } } - // Callback from Camera - public void OnCameraPostRender() + private RenderParameters GetRenderParameters() { - if (textureId == System.IntPtr.Zero && renderTexture != null) - { - Profiler.BeginSample("SpecTexGetNativePtr"); - textureId = renderTexture.GetNativeTexturePtr(); - Profiler.EndSample(); - } - SubmitInRenderThread(); + return renderParameters; } - public Camera GetCamera() + private static bool GetFunctions() { - return spectatorCamera; - } +#if UNITY_EDITOR + if (Application.isEditor) + return true; +#endif + bool error = true; + do + { + var ptr = FunctionsHelper.GetFuncPtr("IsSpectatorStarted"); + if (Equals(ptr, default(System.IntPtr)) || ptr == System.IntPtr.Zero) + { + break; + } + isSpectatorStarted = Marshal.GetDelegateForFunctionPointer(ptr); -#region render_thread_submit - internal class RTData : Message - { - public System.IntPtr textureId; + ptr = FunctionsHelper.GetFuncPtr("ShouldSpectatorRenderFrame"); + if (Equals(ptr, default(System.IntPtr)) || ptr == System.IntPtr.Zero) + { + break; + } + + shouldSpectatorRenderFrame = + Marshal.GetDelegateForFunctionPointer(ptr); + + ptr = FunctionsHelper.GetFuncPtr("SetSpectatorTexture"); + if (Equals(ptr, default(System.IntPtr)) || ptr == System.IntPtr.Zero) + { + break; + } + + setSpectatorTexture = Marshal.GetDelegateForFunctionPointer(ptr); + + ptr = FunctionsHelper.GetFuncPtr("GetSpectatorRenderParameters"); + if (Equals(ptr, default(System.IntPtr)) || ptr == System.IntPtr.Zero) + { + break; + } + + getSpectatorRenderParameters = + Marshal.GetDelegateForFunctionPointer(ptr); + + error = false; + } while (false); + + return !error; } + #region Render thread submit + private void SubmitInRenderThread() { #if UNITY_EDITOR && !UNITY_2021_3 @@ -499,83 +582,172 @@ private void SubmitInRenderThread() lock (queue) { var msg = queue.Obtain(); - msg.textureId = textureId; + msg.TextureId = textureId; queue.Enqueue(msg); } task.IssueEvent(); } - RenderThreadTask task = new RenderThreadTask( - // receiver - (queue) => { - //Debug.Log("RunInRenderThread"); - System.IntPtr nativeTexId; - lock (queue) - { - // Run in RenderThread - var msg = (RTData)queue.Dequeue(); - nativeTexId = msg.textureId; - queue.Release(msg); - } -#if UNITY_EDITOR - if (Application.isEditor) return; -#endif - SetSpectatorTexture(nativeTexId); - } - ); -#endregion render_thread_submit + #endregion Render thread submit -#region callback + #endregion Private function of spectator handler internal usage in its lifecycle + + #region Public callback function + + /// + /// The callback function registration when the spectator camera is started. + /// public delegate void OnSpectatorStartDelegate(); + + /// + /// The callback function registration when the spectator camera is stopped. + /// public delegate void OnSpectatorStopDelegate(); + + #endregion Public callback function - public OnSpectatorStartDelegate onSpectatorStart; - public OnSpectatorStopDelegate onSpectatorStop; -#endregion + #region Callback function for internal usage of spectator handler + + private delegate bool IsSpectatorStartedDelegate(); + private delegate bool ShouldSpectatorRenderFrameDelegate(); -#region functions - delegate bool IsSpectatorStartedDelegate(); - delegate bool ShouldSpectatorRenderFrameDelegate(); - delegate void SetSpectatorTextureDelegate(System.IntPtr ptr); - delegate bool GetSpectatorRenderParametersDelegate(ref uint w, ref uint h, ref float l, ref float r, ref float t, ref float b); + private delegate void SetSpectatorTextureDelegate(System.IntPtr ptr); - static IsSpectatorStartedDelegate IsSpectatorStarted; - static ShouldSpectatorRenderFrameDelegate ShouldSpectatorRenderFrame; - static SetSpectatorTextureDelegate SetSpectatorTexture; - static GetSpectatorRenderParametersDelegate GetSpectatorRenderParameters; + private delegate bool GetSpectatorRenderParametersDelegate( + ref uint w, + ref uint h, + ref float l, + ref float r, + ref float t, + ref float b); - static bool GetFunctions() + #endregion Callback function for internal usage of spectator handler + + #region Unity Lifecycle functions + + private void OnEnable() { -#if UNITY_EDITOR - if (Application.isEditor) - return true; -#endif - bool error = true; - do + // This only available if you put this material in Resources folder. We put it in our sample. + debugMaterial = Resources.Load("Spectator/SpectatorCaptured"); + } + + private void OnDisable() + { + ReleaseResource(); + } + + // Update is called once per frame + private void Update() + { + CheckStatus(); + + if (!run) { - System.IntPtr ptr; - ptr = FunctionsHelper.GetFuncPtr("IsSpectatorStarted"); - if (ptr == null) break; - IsSpectatorStarted = Marshal.GetDelegateForFunctionPointer(ptr); + return; + } - ptr = FunctionsHelper.GetFuncPtr("ShouldSpectatorRenderFrame"); - if (ptr == null) break; - ShouldSpectatorRenderFrame = Marshal.GetDelegateForFunctionPointer(ptr); + // Prepare camera before rendering + if (!CheckCamera()) + { + // No main camera found + return; + } - ptr = FunctionsHelper.GetFuncPtr("SetSpectatorTexture"); - if (ptr == null) break; - SetSpectatorTexture = Marshal.GetDelegateForFunctionPointer(ptr); + spectatorCamera.enabled = false; - ptr = FunctionsHelper.GetFuncPtr("GetSpectatorRenderParameters"); - if (ptr == null) break; - GetSpectatorRenderParameters = Marshal.GetDelegateForFunctionPointer(ptr); + // Check if we need to render this frame (related to fps setting) + if (!shouldRenderFrame) + { + // This frame skipped if "fps" flag is false + return; + } - error = false; - } while (false); - return !error; + UpdateRenderParameters(); + } + + private void OnApplicationPause(bool pause) + { + if (pause) + { + ReleaseResource(); + } + } + + public static void OnSceneLoaded(Scene scene, LoadSceneMode mode) + { + Init(); + } + + private void OnDestroy() + { + ReleaseResource(); + } + + #endregion Unity Lifecycle functions + + #region Structrue/Class definition + + private class RTData : Message + { + public System.IntPtr TextureId; } -#endregion functions + + [StructLayout(LayoutKind.Sequential)] + private struct RenderParametersNative + { + public bool isStarted; + public bool shouldRender; + public bool isParametersValid; + public bool hasPose; + public uint width; + public uint height; + public float l; + public float r; + public float t; + public float b; + public Vector3 position; + public Quaternion rotation; + } + + private struct RenderParameters + { + public RenderParametersNative RenderParametersNative; + public Matrix4x4 Proj; + + private float _n; + private float _f; + + public void Set(RenderParametersNative na) + { + RenderParametersNative = na; + Proj = WaveXRSpectatorCameraHandle.Frustum( + RenderParametersNative.l, + RenderParametersNative.r, + RenderParametersNative.t, + RenderParametersNative.b, + _n, + _f); + } + + public void CalculateProj(float near, float far) + { + _n = near; + _f = far; + if (RenderParametersNative.isParametersValid) + { + Proj = WaveXRSpectatorCameraHandle.Frustum( + RenderParametersNative.l, + RenderParametersNative.r, + RenderParametersNative.t, + RenderParametersNative.b, + _n, + _f); + } + } + } + + #endregion Structrue/Class definition } } \ No newline at end of file diff --git a/com.htc.upm.wave.xrsdk/UnityPackages~/wave_xrsdk_androidmanifest.unitypackage b/com.htc.upm.wave.xrsdk/UnityPackages~/wave_xrsdk_androidmanifest.unitypackage index 3bdb417f..844c9229 100644 --- a/com.htc.upm.wave.xrsdk/UnityPackages~/wave_xrsdk_androidmanifest.unitypackage +++ b/com.htc.upm.wave.xrsdk/UnityPackages~/wave_xrsdk_androidmanifest.unitypackage @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b3c0c844bdc6c2bc6505d6f0def98914bf8b53b6099359d93ab02e61f36fb52a -size 3501 +oid sha256:cf29379231c26344d1af5d25dcc84cb9a193d1d5dfe128b21b732b7376153d25 +size 3615 diff --git a/com.htc.upm.wave.xrsdk/package.json b/com.htc.upm.wave.xrsdk/package.json index 14aec8e7..ee1c5959 100644 --- a/com.htc.upm.wave.xrsdk/package.json +++ b/com.htc.upm.wave.xrsdk/package.json @@ -1,7 +1,7 @@ { "name": "com.htc.upm.wave.xrsdk", "displayName": "VIVE Wave XR Plugin", - "version": "5.6.0-r.10", + "version": "5.6.0-r.10.1", "unity": "2019.4", "description": "The \"VIVE Wave XR Plugin\" package serves as a bridge between VIVE moblile devices and Unity.\nBy communicuating with Unity's \"XR Plugin Management\" package, this package allows your application to run on VIVE mobile devices.\n\nView the documentation for additional information.\n\n", "keywords": [ diff --git a/com.htc.upm.wave.xrsdk/package.tm1.meta b/com.htc.upm.wave.xrsdk/package.tm1.meta index 74c30a92..93a16eeb 100644 --- a/com.htc.upm.wave.xrsdk/package.tm1.meta +++ b/com.htc.upm.wave.xrsdk/package.tm1.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 52484a7ec8c89be42a7a8fb2e9992eb3 +guid: 319b15859ab8da947a94f3050a096723 DefaultImporter: externalObjects: {} userData: