Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
サンプルの変更。手の位置などの調整
Browse files Browse the repository at this point in the history
  • Loading branch information
NON906 committed Jan 22, 2020
1 parent 6873bac commit 1815107
Show file tree
Hide file tree
Showing 17 changed files with 1,002 additions and 303 deletions.
6 changes: 5 additions & 1 deletion HandVR/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@
<Compile Include="Assets\HandVR\HandVR\Scripts\HandVRSphereHand.cs" />
<Compile Include="Assets\HandVR\HandVR\Scripts\SetParentMainCamera.cs" />
<Compile Include="Assets\HandVR\HandVRSample\Scripts\BackButtonExit.cs" />
<Compile Include="Assets\HandVR\HandVRSample\Scripts\CanCarryObject.cs" />
<Compile Include="Assets\HandVR\HandVRSample\Scripts\HandVRController.cs" />
<Compile Include="Assets\HandVR\HandVRSample\Scripts\IControlObject.cs" />
<Compile Include="Assets\HandVR\HandVRSample\Scripts\License.cs" />
<Compile Include="Assets\HandVR\HandVRSample\Scripts\Menu.cs" />
<None Include="Assets\HandVR\HandVR\Plugins\iOS\このディレクトリについて.txt" />
<Compile Include="Assets\HandVR\HandVRSample\Scripts\ResetButton.cs" />
<None Include="Assets\HandVR\HandVR\Plugins\iOS\このディレクトリについて.txt" />
<None Include="Assets\StreamingAssets\palm_detection_labelmap.txt" />
<Reference Include="Unity.XR.Management">
<HintPath>/Users/satoharu/Documents/Unity/HandVR/Projects/HandVR_github/HandVR/HandVR/Library/ScriptAssemblies/Unity.XR.Management.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion HandVR/Assets/HandVR/HandVR/Scripts/HandVRMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
58 changes: 54 additions & 4 deletions HandVR/Assets/HandVR/HandVR/Scripts/HandVRSphereHand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
{
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions HandVR/Assets/HandVR/HandVRSample/Materials.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 77 additions & 0 deletions HandVR/Assets/HandVR/HandVRSample/Materials/GroundMaterial.mat
Original file line number Diff line number Diff line change
@@ -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}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1815107

Please sign in to comment.