From 1815107aed160b5527876fc4e39a63b6be786efc Mon Sep 17 00:00:00 2001 From: NON906 Date: Wed, 22 Jan 2020 13:11:11 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B5=E3=83=B3=E3=83=97=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E5=A4=89=E6=9B=B4=E3=80=82=E6=89=8B=E3=81=AE=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E3=81=AA=E3=81=A9=E3=81=AE=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HandVR/Assembly-CSharp.csproj | 6 +- .../HandVR/HandVR/Scripts/HandVRMain.cs | 2 +- .../HandVR/HandVR/Scripts/HandVRSphereHand.cs | 58 +- .../Assets/HandVR/HandVRSample/Materials.meta | 8 + .../HandVRSample/Materials/GroundMaterial.mat | 77 ++ .../Materials/GroundMaterial.mat.meta | 8 + .../HandVR/HandVRSample/Scenes/Main.unity | 726 +++++++++++------- .../HandVRSample/Scripts/CanCarryObject.cs | 113 +++ .../Scripts/CanCarryObject.cs.meta | 11 + .../HandVRSample/Scripts/HandVRController.cs | 148 ++++ .../Scripts/HandVRController.cs.meta | 11 + .../HandVRSample/Scripts/IControlObject.cs | 12 + .../Scripts/IControlObject.cs.meta | 11 + .../HandVRSample/Scripts/ResetButton.cs | 91 +++ .../HandVRSample/Scripts/ResetButton.cs.meta | 11 + HandVR/ProjectSettings/DynamicsManager.asset | 6 +- HandVR/ProjectSettings/TagManager.asset | 6 +- 17 files changed, 1002 insertions(+), 303 deletions(-) create mode 100644 HandVR/Assets/HandVR/HandVRSample/Materials.meta create mode 100644 HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat create mode 100644 HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat.meta create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs.meta create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs.meta create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs.meta create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs create mode 100644 HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs.meta diff --git a/HandVR/Assembly-CSharp.csproj b/HandVR/Assembly-CSharp.csproj index 985cdad..90f45f4 100644 --- a/HandVR/Assembly-CSharp.csproj +++ b/HandVR/Assembly-CSharp.csproj @@ -71,9 +71,13 @@ + + + - + + /Users/satoharu/Documents/Unity/HandVR/Projects/HandVR_github/HandVR/HandVR/Library/ScriptAssemblies/Unity.XR.Management.dll diff --git a/HandVR/Assets/HandVR/HandVR/Scripts/HandVRMain.cs b/HandVR/Assets/HandVR/HandVR/Scripts/HandVRMain.cs index 39e49a0..47f72d9 100644 --- a/HandVR/Assets/HandVR/HandVR/Scripts/HandVRMain.cs +++ b/HandVR/Assets/HandVR/HandVR/Scripts/HandVRMain.cs @@ -135,7 +135,7 @@ public float[] GetLandmark(int id, int index) posVecArray[0] = (posVecArray[0] - 0.5f) * 0.15f * Screen.width / Screen.height; posVecArray[1] = (posVecArray[1] - 0.5f) * -0.15f; - posVecArray[2] = posVecArray[2] * 0.001f + 0.25f; + posVecArray[2] = posVecArray[2] * 0.001f + 0.5f; // posVecArray[2] * 0.001f + 0.25f; return posVecArray; } diff --git a/HandVR/Assets/HandVR/HandVR/Scripts/HandVRSphereHand.cs b/HandVR/Assets/HandVR/HandVR/Scripts/HandVRSphereHand.cs index 1713ee7..d64046f 100644 --- a/HandVR/Assets/HandVR/HandVR/Scripts/HandVRSphereHand.cs +++ b/HandVR/Assets/HandVR/HandVR/Scripts/HandVRSphereHand.cs @@ -4,20 +4,61 @@ public class HandVRSphereHand : MonoBehaviour { + public enum EitherHand + { + Left, + Right + } + public int Id; Transform[] fingers_ = new Transform[21]; bool[] fingerTracking_ = new bool[5]; - bool[] fingerOpened_ = new bool[5]; + bool[] fingerOpened_ = new bool[5]; + + public Vector3 HandCenterPosition + { + get + { + return (fingers_[0].position + fingers_[5].position + fingers_[17].position) / 3f; + } + } + + public Vector3 HandDirection + { + get; + private set; + } + + public EitherHand ThisEitherHand + { + get; + private set; + } = EitherHand.Left; - bool calcFingerOpened(Vector3 rootVec, Vector3 tipVec) + public bool IsTrackingHand + { + get + { + for (int loop = 0; loop < 5; loop++) + { + if (!fingerTracking_[loop]) + { + return false; + } + } + return true; + } + } + + bool calcFingerOpened(Vector3 rootVec, Vector3 tipVec, float targetCos) { rootVec.Normalize(); tipVec.Normalize(); float cos = rootVec.x * tipVec.x + rootVec.y * tipVec.y + rootVec.z * tipVec.z; - return cos > 0.5f; + return cos > targetCos; } void Start() @@ -52,7 +93,8 @@ void Update() if (fullTracking) { opened = calcFingerOpened(fingers_[loop * 4 + 2].position - fingers_[loop * 4 + 1].position, - fingers_[loop * 4 + 4].position - fingers_[loop * 4 + 3].position); + fingers_[loop * 4 + 4].position - fingers_[loop * 4 + 3].position, + 0.5f); } else { @@ -62,6 +104,14 @@ void Update() fingerTracking_[loop] = fullTracking; fingerOpened_[loop] = opened; } + + HandDirection = Vector3.Cross(fingers_[5].position - fingers_[0].position, fingers_[17].position - fingers_[0].position).normalized; + ThisEitherHand = EitherHand.Left; + if (Vector3.Dot(HandDirection, Camera.main.transform.forward.normalized) < 0f) + { + HandDirection *= -1f; + ThisEitherHand = EitherHand.Right; + } } public bool GetFingerTracking(int index) diff --git a/HandVR/Assets/HandVR/HandVRSample/Materials.meta b/HandVR/Assets/HandVR/HandVRSample/Materials.meta new file mode 100644 index 0000000..ba566fd --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Materials.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 10ebdd2129a41437294f960aacc18f83 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat b/HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat new file mode 100644 index 0000000..ae672be --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: GroundMaterial + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat.meta b/HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat.meta new file mode 100644 index 0000000..58b5f98 --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 77a6972edf34841b081f64a308f2015c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/HandVR/Assets/HandVR/HandVRSample/Scenes/Main.unity b/HandVR/Assets/HandVR/HandVRSample/Scenes/Main.unity index 44d2af4..b1843af 100644 --- a/HandVR/Assets/HandVR/HandVRSample/Scenes/Main.unity +++ b/HandVR/Assets/HandVR/HandVRSample/Scenes/Main.unity @@ -120,7 +120,7 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &109880628 +--- !u!1 &25444828 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -128,37 +128,37 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 109880632} - - component: {fileID: 109880631} - - component: {fileID: 109880630} - - component: {fileID: 109880629} - m_Layer: 0 - m_Name: Cube + - component: {fileID: 25444829} + - component: {fileID: 25444831} + - component: {fileID: 25444830} + m_Layer: 23 + m_Name: Quad m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!65 &109880629 -BoxCollider: +--- !u!4 &25444829 +Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 109880628} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &109880630 + m_GameObject: {fileID: 25444828} + m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 654501020} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} +--- !u!23 &25444830 MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 109880628} + m_GameObject: {fileID: 25444828} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -190,29 +190,15 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!33 &109880631 +--- !u!33 &25444831 MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 109880628} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &109880632 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 109880628} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 2.86, y: 2, z: 0} - m_LocalScale: {x: 1, y: 4, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 11 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &116133045 + m_GameObject: {fileID: 25444828} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &110345546 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -220,38 +206,39 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 116133049} - - component: {fileID: 116133048} - - component: {fileID: 116133047} - - component: {fileID: 116133046} - m_Layer: 0 - m_Name: Quad + - component: {fileID: 110345550} + - component: {fileID: 110345549} + - component: {fileID: 110345548} + - component: {fileID: 110345547} + - component: {fileID: 110345551} + - component: {fileID: 110345552} + m_Layer: 23 + m_Name: Cube m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 - m_StaticEditorFlags: 4294967295 + m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!64 &116133046 -MeshCollider: +--- !u!65 &110345547 +BoxCollider: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116133045} + m_GameObject: {fileID: 110345546} m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 3 - m_Convex: 0 - m_CookingOptions: 14 - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} ---- !u!23 &116133047 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &110345548 MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116133045} + m_GameObject: {fileID: 110345546} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -283,29 +270,59 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!33 &116133048 +--- !u!33 &110345549 MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116133045} - m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &116133049 + m_GameObject: {fileID: 110345546} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &110345550 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116133045} - m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 10, y: 10, z: 10} + m_GameObject: {fileID: 110345546} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.25, z: 1.5} + m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 9 - m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} ---- !u!1 &116696832 + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!54 &110345551 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 110345546} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 0 + m_CollisionDetection: 0 +--- !u!114 &110345552 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 110345546} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e78fd883c7e9e46b2997d2de448b32b6, type: 3} + m_Name: + m_EditorClassIdentifier: + FocusedColor: {r: 1, g: 0.92156863, b: 0.015686275, a: 1} + GrabColor: {r: 1, g: 0, b: 0, a: 1} +--- !u!1 &234962886 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -313,90 +330,97 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 116696836} - - component: {fileID: 116696835} - - component: {fileID: 116696834} - - component: {fileID: 116696833} - m_Layer: 0 - m_Name: Cube (2) + - component: {fileID: 234962887} + - component: {fileID: 234962890} + - component: {fileID: 234962889} + - component: {fileID: 234962888} + m_Layer: 5 + m_Name: Canvas m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!65 &116696833 -BoxCollider: +--- !u!224 &234962887 +RectTransform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116696832} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &116696834 -MeshRenderer: + m_GameObject: {fileID: 234962886} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -0.001} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 1764319653} + m_Father: {fileID: 654501020} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 1, y: 1} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &234962888 +MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116696832} + m_GameObject: {fileID: 234962886} m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 ---- !u!33 &116696835 -MeshFilter: + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &234962889 +MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116696832} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &116696836 -Transform: + m_GameObject: {fileID: 234962886} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &234962890 +Canvas: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 116696832} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.5, z: 3.4} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 13 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_GameObject: {fileID: 234962886} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 2 + m_Camera: {fileID: 801666494} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 --- !u!1001 &639129857 PrefabInstance: m_ObjectHideFlags: 0 @@ -471,7 +495,7 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 87aa0946790854ae1b3907f555536dc9, type: 3} ---- !u!1 &775013720 +--- !u!1 &654501016 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -479,28 +503,109 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 775013721} - m_Layer: 0 - m_Name: RightFootIK + - component: {fileID: 654501020} + - component: {fileID: 654501019} + - component: {fileID: 654501018} + - component: {fileID: 654501017} + - component: {fileID: 654501021} + m_Layer: 23 + m_Name: ResetButton m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &775013721 +--- !u!64 &654501017 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 654501016} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 3 + m_Convex: 1 + m_CookingOptions: 14 + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &654501018 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 654501016} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &654501019 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 654501016} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &654501020 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 775013720} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.197, y: 0, z: 1.272} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] + m_GameObject: {fileID: 654501016} + m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068} + m_LocalPosition: {x: 1.2, y: 0.3, z: -0} + m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} + m_Children: + - {fileID: 234962887} + - {fileID: 25444829} m_Father: {fileID: 0} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0} +--- !u!114 &654501021 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 654501016} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4319a0fc5412e4bc7879e699559eb571, type: 3} + m_Name: + m_EditorClassIdentifier: + FocusedColor: {r: 1, g: 0.92156863, b: 0.015686275, a: 1} + Resetables: + - {fileID: 110345550} --- !u!1001 &801666493 PrefabInstance: m_ObjectHideFlags: 0 @@ -570,7 +675,13 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: def53970deada674084bfb1efb26a17a, type: 3} ---- !u!1 &1376252163 +--- !u!20 &801666494 stripped +Camera: + m_CorrespondingSourceObject: {fileID: 8618147743317159187, guid: def53970deada674084bfb1efb26a17a, + type: 3} + m_PrefabInstance: {fileID: 801666493} + m_PrefabAsset: {fileID: 0} +--- !u!1 &1511143799 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -578,37 +689,129 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1376252167} - - component: {fileID: 1376252166} - - component: {fileID: 1376252165} - - component: {fileID: 1376252164} + - component: {fileID: 1511143801} + - component: {fileID: 1511143800} m_Layer: 0 - m_Name: Cube (1) + m_Name: Directional Light m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!65 &1376252164 -BoxCollider: +--- !u!108 &1511143800 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1511143799} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 0 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1511143801 +Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1376252163} + m_GameObject: {fileID: 1511143799} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1643802720 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1643802724} + - component: {fileID: 1643802723} + - component: {fileID: 1643802722} + - component: {fileID: 1643802721} + m_Layer: 22 + m_Name: Quad + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!64 &1643802721 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1643802720} m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &1376252165 + serializedVersion: 3 + m_Convex: 0 + m_CookingOptions: 14 + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1643802722 MeshRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1376252163} + m_GameObject: {fileID: 1643802720} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 @@ -619,7 +822,7 @@ MeshRenderer: m_RenderingLayerMask: 1 m_RendererPriority: 0 m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 2100000, guid: 77a6972edf34841b081f64a308f2015c, type: 2} m_StaticBatchInfo: firstSubMesh: 0 subMeshCount: 0 @@ -640,29 +843,29 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 ---- !u!33 &1376252166 +--- !u!33 &1643802723 MeshFilter: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1376252163} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &1376252167 + m_GameObject: {fileID: 1643802720} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1643802724 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1376252163} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -2.12, y: 1, z: -3.11} - m_LocalScale: {x: 1, y: 2, z: 1} + m_GameObject: {fileID: 1643802720} + m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 5, y: 5, z: 5} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 12 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1420757646 + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!1 &1730094049 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -670,29 +873,42 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1420757647} + - component: {fileID: 1730094051} + - component: {fileID: 1730094050} m_Layer: 0 - m_Name: LeftFootIK + m_Name: HandVRController m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1420757647 +--- !u!114 &1730094050 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1730094049} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 75db040ca0e4c47559861848a0a4b193, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &1730094051 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1420757646} + m_GameObject: {fileID: 1730094049} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.197, y: 0, z: 1.272} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1729921375 +--- !u!1 &1764319652 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -700,119 +916,75 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1729921376} - m_Layer: 0 - m_Name: LeftHandIK + - component: {fileID: 1764319653} + - component: {fileID: 1764319655} + - component: {fileID: 1764319654} + m_Layer: 5 + m_Name: Text m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1729921376 -Transform: +--- !u!224 &1764319653 +RectTransform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1729921375} + m_GameObject: {fileID: 1764319652} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.231, y: 1.628, z: 1.358} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.01, y: 0.01, z: 0.01} m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 4 + m_Father: {fileID: 234962887} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1756954543 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1756954545} - - component: {fileID: 1756954544} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &1756954544 -Light: + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1764319654 +MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1756954543} + m_GameObject: {fileID: 1764319652} m_Enabled: 1 - serializedVersion: 9 - m_Type: 1 - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 0 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &1756954545 -Transform: + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 0 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 32 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 53 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Reset +--- !u!222 &1764319655 +CanvasRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1756954543} - m_LocalRotation: {x: 0.10938167, y: 0.8754261, z: -0.40821788, w: 0.23456976} - m_LocalPosition: {x: 2, y: 2, z: -1} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 10 - m_LocalEulerAnglesHint: {x: 50, y: 150, z: 0} + m_GameObject: {fileID: 1764319652} + m_CullTransparentMesh: 0 --- !u!1 &1930387068 GameObject: m_ObjectHideFlags: 0 @@ -854,36 +1026,6 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &2142315090 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2142315091} - m_Layer: 0 - m_Name: RightHandIK - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &2142315091 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2142315090} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.231, y: 1.628, z: 1.358} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &5982986488725047576 diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs b/HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs new file mode 100644 index 0000000..46d7f2c --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs @@ -0,0 +1,113 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CanCarryObject : MonoBehaviour, IControlObject +{ + public Color FocusedColor = Color.yellow; + public Color GrabColor = Color.red; + + Material material_; + Color defaultColor_; + Rigidbody rigidbody_; + + HashSet focusHands_ = new HashSet(); + HashSet grabHands_ = new HashSet(); + + Transform targetTransformParent_; + Transform targetTransform_; + + void Start() + { + material_ = GetComponent().material; + defaultColor_ = material_.color; + rigidbody_ = GetComponent(); + + targetTransformParent_ = new GameObject().transform; + targetTransform_ = new GameObject().transform; + targetTransformParent_.parent = Camera.main.transform; + targetTransform_.parent = targetTransformParent_; + } + + public void StartFocus(HandVRSphereHand.EitherHand hand) + { + if (focusHands_.Count == 0) + { + material_.color = FocusedColor; + } + focusHands_.Add(hand); + } + + public void EndFocus(HandVRSphereHand.EitherHand hand) + { + focusHands_.Remove(hand); + if (focusHands_.Count == 0) + { + material_.color = defaultColor_; + } + } + + public void StartGrab(HandVRSphereHand.EitherHand hand, Vector3 centerPosition) + { + if (grabHands_.Count == 0) + { + material_.color = GrabColor; + + targetTransformParent_.position = centerPosition; + targetTransformParent_.LookAt(transform); + targetTransform_.rotation = transform.rotation; + targetTransform_.position = transform.position; + } + grabHands_.Add(hand); + } + + public void StayGrab(HandVRSphereHand.EitherHand hand, Vector3 centerPosition) + { + targetTransformParent_.position = centerPosition; + } + + public void EndGrab(HandVRSphereHand.EitherHand hand) + { + grabHands_.Remove(hand); + if (grabHands_.Count == 0) + { + if (focusHands_.Count > 0) + { + material_.color = FocusedColor; + } + else + { + material_.color = defaultColor_; + } + } + } + + void FixedUpdate() + { + if (grabHands_.Count > 0) + { + rigidbody_.useGravity = false; + + float angle1 = Vector3.Angle(transform.forward, targetTransform_.forward); + Vector3 axis1 = Vector3.Cross(transform.forward, targetTransform_.forward).normalized; + Quaternion quat1 = Quaternion.AngleAxis(angle1, axis1); + Vector3 right = quat1 * transform.right; + Vector3 rightTarget = quat1 * targetTransform_.right; + float angle2 = Vector3.Angle(right, rightTarget); + Vector3 axis2 = Vector3.Cross(right, rightTarget).normalized; + rigidbody_.AddTorque((angle1 * axis1 + angle2 * axis2) * Mathf.Deg2Rad / Time.fixedDeltaTime - rigidbody_.angularVelocity, ForceMode.VelocityChange); + + rigidbody_.AddForce((targetTransform_.position - transform.position) / Time.fixedDeltaTime - rigidbody_.velocity, ForceMode.VelocityChange); + } + else + { + rigidbody_.useGravity = true; + } + } + + void OnDestroy() + { + Destroy(targetTransform_.gameObject); + Destroy(targetTransformParent_.gameObject); + } +} diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs.meta b/HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs.meta new file mode 100644 index 0000000..7977b65 --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/CanCarryObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e78fd883c7e9e46b2997d2de448b32b6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs b/HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs new file mode 100644 index 0000000..f361ce4 --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs @@ -0,0 +1,148 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class HandVRController : MonoBehaviour +{ + HandVRSphereHand[] sphereHands_; + + IControlObject[] focusedObjects_ = new IControlObject[2]; + bool[] isGrab_ = new bool[2]; + + Coroutine[] startGrabCoroutineRunning_ = new Coroutine[2]; + Coroutine[] endGrabCoroutineRunning_ = new Coroutine[2]; + + void Start() + { + sphereHands_ = FindObjectsOfType(); + } + + void Update() + { + bool[] isDetected = new bool[2]; + + foreach (HandVRSphereHand sphereHand in sphereHands_) + { + if (!sphereHand.IsTrackingHand) + { + continue; + } + + if (isDetected[(int)sphereHand.ThisEitherHand]) + { + continue; + } + isDetected[(int)sphereHand.ThisEitherHand] = true; + + int layerMask = LayerMask.GetMask("ControlObject"); + + RaycastHit hit; + IControlObject newObject = null; + if (Physics.Raycast(sphereHand.HandCenterPosition, + (sphereHand.HandCenterPosition - Camera.main.transform.position).normalized, + out hit, Mathf.Infinity, layerMask, QueryTriggerInteraction.Collide)) + { + newObject = hit.transform.GetComponent(); + } + + int handId = (int)sphereHand.ThisEitherHand; + + if (focusedObjects_[handId] != newObject && focusedObjects_[handId] != null && !isGrab_[handId]) + { + focusedObjects_[handId].EndFocus(sphereHand.ThisEitherHand); + focusedObjects_[handId] = null; + } + + if (focusedObjects_[handId] == null && newObject != null) + { + newObject.StartFocus(sphereHand.ThisEitherHand); + focusedObjects_[handId] = newObject; + } + + if (focusedObjects_[handId] != null) + { + bool grabCountrol = true; + for (int loop = 0; loop < 2; loop++) + { + if (handId != loop && focusedObjects_[handId] == focusedObjects_[loop] && isGrab_[loop]) + { + grabCountrol = false; + } + } + + if (grabCountrol) + { + bool grabed = true; + bool opened = true; + for (int loop = 1; loop < 5; loop++) + { + if (sphereHand.GetFingerOpened(loop)) + { + grabed = false; + } + else + { + opened = false; + } + } + + if (!isGrab_[handId] && grabed) + { + startGrabCoroutineRunning_[handId] = StartCoroutine(startGrabCoroutine(sphereHand.ThisEitherHand, sphereHand.transform.TransformPoint(sphereHand.HandCenterPosition))); + isGrab_[handId] = true; + } + else if (isGrab_[handId] && grabed) + { + if (startGrabCoroutineRunning_[handId] == null) + { + focusedObjects_[handId].StayGrab(sphereHand.ThisEitherHand, sphereHand.transform.TransformPoint(sphereHand.HandCenterPosition)); + } + if (endGrabCoroutineRunning_[handId] != null) + { + StopCoroutine(endGrabCoroutineRunning_[handId]); + endGrabCoroutineRunning_[handId] = null; + } + } + else if (isGrab_[handId] && opened) + { + if (startGrabCoroutineRunning_[handId] != null) + { + StopCoroutine(startGrabCoroutineRunning_[handId]); + startGrabCoroutineRunning_[handId] = null; + } + else if (endGrabCoroutineRunning_[handId] == null) + { + endGrabCoroutineRunning_[handId] = StartCoroutine(endGrabCoroutine(sphereHand.ThisEitherHand)); + } + } + } + } + } + + for (int loop = 0; loop < 2; loop++) + { + if (!isDetected[loop] && focusedObjects_[loop] != null && !isGrab_[loop]) + { + focusedObjects_[loop].EndFocus((HandVRSphereHand.EitherHand)loop); + focusedObjects_[loop] = null; + } + } + } + + IEnumerator startGrabCoroutine(HandVRSphereHand.EitherHand hand, Vector3 centerPosition) + { + yield return new WaitForSeconds(0.1f); + + focusedObjects_[(int)hand].StartGrab(hand, centerPosition); + startGrabCoroutineRunning_[(int)hand] = null; + } + + IEnumerator endGrabCoroutine(HandVRSphereHand.EitherHand hand) + { + yield return new WaitForSeconds(0.1f); + + focusedObjects_[(int)hand].EndGrab(hand); + endGrabCoroutineRunning_[(int)hand] = null; + isGrab_[(int)hand] = false; + } +} diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs.meta b/HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs.meta new file mode 100644 index 0000000..dc8613e --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/HandVRController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 75db040ca0e4c47559861848a0a4b193 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs b/HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs new file mode 100644 index 0000000..cae1b7e --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public interface IControlObject +{ + void StartFocus(HandVRSphereHand.EitherHand hand); + void EndFocus(HandVRSphereHand.EitherHand hand); + void StartGrab(HandVRSphereHand.EitherHand hand, Vector3 centerPosition); + void StayGrab(HandVRSphereHand.EitherHand hand, Vector3 centerPosition); + void EndGrab(HandVRSphereHand.EitherHand hand); +} diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs.meta b/HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs.meta new file mode 100644 index 0000000..cbda23a --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/IControlObject.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 713629907ddea4e6aa26a8b2c1b07093 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs b/HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs new file mode 100644 index 0000000..8cb131c --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs @@ -0,0 +1,91 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ResetButton : MonoBehaviour, IControlObject +{ + public Color FocusedColor = Color.yellow; + public Transform[] Resetables; + + Material material_; + Color defaultColor_; + + HashSet focusStartHands_ = new HashSet(); + HashSet focusHands_ = new HashSet(); + + Vector3[] resetablesPosition_; + Quaternion[] resetablesRotation_; + + void Start() + { + material_ = GetComponent().material; + defaultColor_ = material_.color; + + resetablesPosition_ = new Vector3[Resetables.Length]; + resetablesRotation_ = new Quaternion[Resetables.Length]; + for (int loop = 0; loop < Resetables.Length; loop++) + { + resetablesPosition_[loop] = Resetables[loop].position; + resetablesRotation_[loop] = Resetables[loop].rotation; + } + } + + public void StartFocus(HandVRSphereHand.EitherHand hand) + { + focusStartHands_.Add(hand); + StartCoroutine(focusStartCoroutine(hand)); + } + + IEnumerator focusStartCoroutine(HandVRSphereHand.EitherHand hand) + { + yield return null; + if (focusStartHands_.Remove(hand)) + { + if (focusHands_.Count == 0) + { + material_.color = FocusedColor; + } + focusHands_.Add(hand); + } + } + + public void EndFocus(HandVRSphereHand.EitherHand hand) + { + focusHands_.Remove(hand); + focusStartHands_.Remove(hand); + if (focusHands_.Count == 0) + { + material_.color = defaultColor_; + } + } + + public void StartGrab(HandVRSphereHand.EitherHand hand, Vector3 centerPosition) + { + if (focusHands_.Contains(hand)) + { + detect(); + + focusHands_.Remove(hand); + material_.color = defaultColor_; + } + } + + public void StayGrab(HandVRSphereHand.EitherHand hand, Vector3 centerPosition) + { + + } + + public void EndGrab(HandVRSphereHand.EitherHand hand) + { + + } + + void detect() + { + for (int loop = 0; loop < Resetables.Length; loop++) + { + Resetables[loop].position = resetablesPosition_[loop]; + Resetables[loop].rotation = resetablesRotation_[loop]; + } + } +} diff --git a/HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs.meta b/HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs.meta new file mode 100644 index 0000000..2f9bca5 --- /dev/null +++ b/HandVR/Assets/HandVR/HandVRSample/Scripts/ResetButton.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4319a0fc5412e4bc7879e699559eb571 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/HandVR/ProjectSettings/DynamicsManager.asset b/HandVR/ProjectSettings/DynamicsManager.asset index 08e52eb..1e9396c 100644 --- a/HandVR/ProjectSettings/DynamicsManager.asset +++ b/HandVR/ProjectSettings/DynamicsManager.asset @@ -3,7 +3,7 @@ --- !u!55 &1 PhysicsManager: m_ObjectHideFlags: 0 - serializedVersion: 10 + serializedVersion: 13 m_Gravity: {x: 0, y: -9.81, z: 0} m_DefaultMaterial: {fileID: 0} m_BounceThreshold: 2 @@ -17,11 +17,12 @@ PhysicsManager: m_ClothInterCollisionDistance: 0 m_ClothInterCollisionStiffness: 0 m_ContactsGeneration: 1 - m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9fffffff9ffffffffffffffdfffffffcfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9fffffff9ffffffffffffffdfffffff0fffffffdfffffffdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff m_AutoSimulation: 1 m_AutoSyncTransforms: 0 m_ReuseCollisionCallbacks: 1 m_ClothInterCollisionSettingsToggle: 0 + m_ClothGravity: {x: 0, y: -9.81, z: 0} m_ContactPairsMode: 0 m_BroadphaseType: 0 m_WorldBounds: @@ -31,3 +32,4 @@ PhysicsManager: m_FrictionType: 0 m_EnableEnhancedDeterminism: 0 m_EnableUnifiedHeightmaps: 1 + m_DefaultMaxAngularSpeed: 7 diff --git a/HandVR/ProjectSettings/TagManager.asset b/HandVR/ProjectSettings/TagManager.asset index a869c5d..96a2d35 100644 --- a/HandVR/ProjectSettings/TagManager.asset +++ b/HandVR/ProjectSettings/TagManager.asset @@ -23,12 +23,12 @@ TagManager: - - - - - Model + - - ARVRBackGround - ARVRCamera - Finger - - - - + - Ground + - ControlObject - - -