10using System.Collections.Generic;
17 public partial class LeapGraphic {
26 getFeatureDataOrThrow<LeapBlendShapeData>().amount = amount;
36 return getFeatureDataOrThrow<LeapBlendShapeData>().amount;
40 [LeapGraphicTag(
"Blend Shape")]
46 private float _amount = 0;
55 private float _scale = 1.1f;
59 private Vector3 _translation =
new Vector3(0, 0, 0.1f);
63 private Vector3 _rotation =
new Vector3(0, 0, 5);
67 private Transform _transform =
null;
79 if (value != _amount) {
99 var mesh = meshGraphic.
mesh;
106 if (mesh.blendShapeCount <= 0) {
110 Vector3[] deltaVerts =
new Vector3[mesh.vertexCount];
111 Vector3[] deltaNormals =
new Vector3[mesh.vertexCount];
112 Vector3[] deltaTangents =
new Vector3[mesh.vertexCount];
113 mesh.GetBlendShapeFrameVertices(0, 0, deltaVerts, deltaNormals, deltaTangents);
115 mesh.vertices.Query().Zip(deltaVerts.Query(), (a, b) => a + b).FillList(blendVerts);
118 Matrix4x4 transformation;
122 transformation = Matrix4x4.TRS(_translation, Quaternion.identity, Vector3.one);
125 transformation = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(_rotation), Vector3.one);
128 transformation = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * _scale);
131 if (_transform ==
null) {
134 transformation =
graphic.transform.worldToLocalMatrix * _transform.localToWorldMatrix;
137 throw new InvalidOperationException();
140 mesh.vertices.Query().Select(transformation.MultiplyPoint).FillList(blendVerts);
bool TryGetBlendShape(List< Vector3 > blendVerts)
Returns the blended vertices based on the current mesh this blend shape is attached to....
float amount
Gets or sets the amount of strength for this blend shape. The value should be in the 0-1 range,...
float GetBlendShapeAmount()
Helper method to get the blend shape amount for a blend shape data object attached to this graphic....
void SetBlendShapeAmount(float amount)
Helper method to set the blend shape amount for a blend shape data object attached to this graphic....
This class is a base class for all graphics that can be represented by a mesh object.
Mesh mesh
Returns the mesh that represents this graphic. It can have any topology, any number of uv channels,...