hand animations

This commit is contained in:
jonasty 2022-04-08 23:38:29 +03:00
parent 8727b6d949
commit 9b4be15690
22 changed files with 1265 additions and 949 deletions

View File

@ -45,7 +45,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: b883faee006af594480a183e2c37d229, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
@ -108,7 +108,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.8018868, g: 0.8018868, b: 0.8018868, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.8018868, g: 0.8018868, b: 0.8018868, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -108,7 +108,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 0}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -108,7 +108,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 0.828, g: 0.197287, b: 0, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0.828, g: 0.19728696, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
m_BuildTextureStacks: []

View File

@ -9,7 +9,7 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: Red Beam
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ShaderKeywords: _EMISSION _GLOSSINESS_FROM_BASE_ALPHA _SPECULAR_COLOR
m_ShaderKeywords: _EMISSION
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
@ -78,7 +78,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 0, b: 0, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 0, b: 0, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5}
m_BuildTextureStacks: []

View File

@ -1,5 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8963728465949884232
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -122,16 +135,3 @@ Material:
- _WavingTint: {r: 1, g: 1, b: 1, a: 1}
- _Wind: {r: 1, g: 1, b: 4, a: 8}
m_BuildTextureStacks: []
--- !u!114 &6211255873334046625
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,5 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-5303616706143254875
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -123,16 +136,3 @@ Material:
- _WavingTint: {r: 1, g: 1, b: 1, a: 1}
- _Wind: {r: 1, g: 1, b: 4, a: 8}
m_BuildTextureStacks: []
--- !u!114 &7943742790050641351
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,5 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-6151971060389309815
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -82,16 +95,3 @@ Material:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
--- !u!114 &5349969004212611957
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-2670054271726696167
--- !u!114 &-4546761639845438240
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7678057132603775348
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -194,3 +181,16 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &6673906547115129633
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7418405857753137198
--- !u!114 &-5626172717625065339
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -1,5 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-8360531026772960804
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5
--- !u!21 &2100000
Material:
serializedVersion: 6
@ -97,16 +110,3 @@ Material:
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []
--- !u!114 &4555146833379849627
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 5

View File

@ -80,7 +80,7 @@ Material:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
--- !u!114 &1366594654907158125
--- !u!114 &46078745712463018
MonoBehaviour:
m_ObjectHideFlags: 11
m_CorrespondingSourceObject: {fileID: 0}

View File

@ -0,0 +1,111 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
using UnityEngine.XR.Interaction.Toolkit;
using TMPro; // Add the TextMesh Pro namespace to access the various functions.
using System.Linq;
using UnityEngine.InputSystem;
using System;
public class HandAnim : MonoBehaviour
{
public Animator m_animator = null;
[Header("Input")]
[SerializeField] public InputActionProperty GripAction;
[SerializeField] public InputActionProperty TriggerAction;
[SerializeField] public InputActionProperty IndexAction;
[SerializeField] public InputActionProperty ThumbAction;
public const string ANIM_LAYER_NAME_POINT = "Point Layer";
public const string ANIM_LAYER_NAME_THUMB = "Thumb Layer";
public const string ANIM_PARAM_NAME_FLEX = "Flex";
public const string ANIM_PARAM_NAME_POSE = "Pose";
private int m_animLayerIndexThumb = -1;
private int m_animLayerIndexPoint = -1;
private int m_animParamIndexFlex = -1;
private int m_animParamIndexPose = -1;
private Collider[] m_colliders = null;
public float anim_frames = 4f;
private float grip_state = 0f;
private float trigger_state = 0f;
private float triggerCap_state = 0f;
private float thumbCap_state = 0f;
private void Reset()
{
m_animator = GetComponentInChildren<Animator>();
}
private void Awake()
{
GripAction.action.performed += GripActionPerformed;
TriggerAction.action.performed += TriggerActionPerformed;
IndexAction.action.performed += IndexActionPerformed;
ThumbAction.action.performed += ThumbActionPerformed;
GripAction.action.Enable();
TriggerAction.action.Enable();
IndexAction.action.Enable();
ThumbAction.action.Enable();
}
void Start()
{
m_colliders = this.GetComponentsInChildren<Collider>().Where(childCollider => !childCollider.isTrigger).ToArray();
for (int i = 0; i < m_colliders.Length; ++i)
{
Collider collider = m_colliders[i];
// collider.transform.localScale = new Vector3(COLLIDER_SCALE_MIN, COLLIDER_SCALE_MIN, COLLIDER_SCALE_MIN);
collider.enabled = true;
}
m_animLayerIndexPoint = m_animator.GetLayerIndex(ANIM_LAYER_NAME_POINT);
m_animLayerIndexThumb = m_animator.GetLayerIndex(ANIM_LAYER_NAME_THUMB);
m_animParamIndexFlex = Animator.StringToHash(ANIM_PARAM_NAME_FLEX);
m_animParamIndexPose = Animator.StringToHash(ANIM_PARAM_NAME_POSE);
}
private void ThumbActionPerformed(InputAction.CallbackContext obj)
{
CalculateState(obj.ReadValue<float>(), ref thumbCap_state);
m_animator.SetLayerWeight(m_animLayerIndexThumb, 1f - thumbCap_state);
}
private void IndexActionPerformed(InputAction.CallbackContext obj)
{
CalculateState(obj.ReadValue<float>(), ref triggerCap_state);
m_animator.SetLayerWeight(m_animLayerIndexPoint, 1f - triggerCap_state);
}
private void TriggerActionPerformed(InputAction.CallbackContext obj)
{
CalculateState(obj.ReadValue<float>(), ref trigger_state);
m_animator.SetFloat("Pinch", trigger_state);
}
private void GripActionPerformed(InputAction.CallbackContext obj)
{
Debug.Log("grip");
CalculateState(obj.ReadValue<float>(), ref grip_state);
m_animator.SetFloat(m_animParamIndexFlex, grip_state);
}
private void CalculateState(float value, ref float state)
{
var delta = value - state;
if (delta > 0f)
{
state = Mathf.Clamp(state + 1 / anim_frames, 0f, value);
}
else if (delta < 0f)
{
state = Mathf.Clamp(state - 1 / anim_frames, value, 1f);
}
else
{
state = value;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 158ebba8614f70a47b5379affd3d7b17
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because one or more lines are too long

View File

@ -90,19 +90,19 @@ Material:
- _HorizonCloudSize: 4.91
- _HorizonCloudStartPosition: -0.1
- _HorizonCloudStep: 25
- _HorizonExponent: 3.4805284
- _HorizonExponent: 3.5942678
- _HorizonStep: 500
- _HorizonThickness: 1
- _MoonGlow: 0
- _MoonLightIntensity: 0.000000031173318
- _MoonLightIntensity: 0.0000017226253
- _MoonSize: 0
- _MoonSoftEdge: 0
- _OverheadCloudAltitude: 1000
- _OverheadCloudAnimationSpeed: 50
- _OverheadCloudFlowDirectionX: 1
- _OverheadCloudFlowDirectionZ: 1
- _OverheadCloudRemapMax: 1.1112865
- _OverheadCloudRemapMin: 0.13994561
- _OverheadCloudRemapMax: 1.1636536
- _OverheadCloudRemapMin: 0.17352435
- _OverheadCloudSize: 10
- _OverheadCloudStep: 2
- _StarsDensity0: 0.4
@ -121,25 +121,25 @@ Material:
- _StarsTwinkle1: 6
- _StarsTwinkle2: 2
- _SunGlow: 0.45
- _SunLightIntensity: 0.2670978
- _SunLightIntensity: 0.3235639
- _SunSize: 0.1
- _SunSoftEdge: 0.5
m_Colors:
- _DetailOverlayTintColor: {r: 0, g: 0, b: 0, a: 0}
- _FogColor: {r: 0, g: 0, b: 0, a: 0}
- _GroundColor: {r: 0.41449818, g: 0.39506137, b: 0.43270952, a: 1}
- _GroundColor: {r: 0.4197886, g: 0.40155447, b: 0.4368731, a: 1}
- _HorizonCloudColor: {r: 1, g: 1, b: 1, a: 1}
- _HorizonColor: {r: 0.9036482, g: 0.8581607, b: 0.75300163, a: 1}
- _HorizonColor: {r: 0.9013359, g: 0.86518586, b: 0.7664721, a: 1}
- _MoonColor: {r: 1, g: 1, b: 1, a: 0}
- _MoonDirection: {r: 1, g: 1, b: 1, a: 0}
- _MoonLightColor: {r: 0, g: 0, b: 0, a: 0}
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.970343}
- _SkyColor: {r: 0.21347235, g: 0.37525713, b: 0.61244774, a: 1}
- _OverheadCloudColor: {r: 1, g: 1, b: 1, a: 0.97789806}
- _SkyColor: {r: 0.22325411, g: 0.40054125, b: 0.6415545, a: 1}
- _StarsColor0: {r: 0.96470594, g: 0.9450981, b: 0.76470596, a: 1}
- _StarsColor1: {r: 1, g: 0.5294118, b: 0.93725497, a: 1}
- _StarsColor2: {r: 0, g: 0.92549026, b: 1, a: 1}
- _SunColor: {r: 0.97335076, g: 0.9293781, b: 0.8568232, a: 1}
- _SunDirection: {r: 0, g: -0.32017863, b: 0.9473572, a: 0}
- _SunColor: {r: 0.97226846, g: 0.92651, b: 0.8510085, a: 1}
- _SunDirection: {r: 0, g: -0.39213187, b: 0.919909, a: 0}
- _SunLightColor: {r: 1, g: 0.9929226, b: 0.9009434, a: 1}
m_BuildTextureStacks: []
--- !u!114 &11400000

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -27,17 +27,17 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorBlend:
m_Texture: {fileID: -8382209597607994568, guid: b6bbea2e1167a7346822545139402874,
m_Texture: {fileID: 4486364280468590767, guid: b6bbea2e1167a7346822545139402874,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorByHeight:
m_Texture: {fileID: -5418273104343767497, guid: b6bbea2e1167a7346822545139402874,
m_Texture: {fileID: -6132796285478058653, guid: b6bbea2e1167a7346822545139402874,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorByNormal:
m_Texture: {fileID: 4448014153531656217, guid: b6bbea2e1167a7346822545139402874,
m_Texture: {fileID: 3199764949803142271, guid: b6bbea2e1167a7346822545139402874,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

View File

@ -40,17 +40,17 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorBlend:
m_Texture: {fileID: -3679002471302179906, guid: 726ce83d589353742be6b48ff467fc48,
m_Texture: {fileID: -2860239040901424018, guid: 726ce83d589353742be6b48ff467fc48,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorByHeight:
m_Texture: {fileID: 5517573790230051661, guid: 726ce83d589353742be6b48ff467fc48,
m_Texture: {fileID: -3232554691702025502, guid: 726ce83d589353742be6b48ff467fc48,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorByNormal:
m_Texture: {fileID: -2372503177267332067, guid: 726ce83d589353742be6b48ff467fc48,
m_Texture: {fileID: -5185881309555919389, guid: 726ce83d589353742be6b48ff467fc48,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}

View File

@ -40,17 +40,17 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorBlend:
m_Texture: {fileID: -7655403243227739187, guid: 7f589c682d367b442b8cf75918f5aa55,
m_Texture: {fileID: -5888029387489397053, guid: 7f589c682d367b442b8cf75918f5aa55,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorByHeight:
m_Texture: {fileID: 5273791656863379916, guid: 7f589c682d367b442b8cf75918f5aa55,
m_Texture: {fileID: 4685624439979389760, guid: 7f589c682d367b442b8cf75918f5aa55,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ColorByNormal:
m_Texture: {fileID: 2126150020230490587, guid: 7f589c682d367b442b8cf75918f5aa55,
m_Texture: {fileID: 5590498550304044854, guid: 7f589c682d367b442b8cf75918f5aa55,
type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}