Browse Source
Further mesh conversion research: animation frames are now converted into blend shape animations, which can be played back either with or without smoothing.
console
Further mesh conversion research: animation frames are now converted into blend shape animations, which can be played back either with or without smoothing.
console
4 changed files with 104 additions and 14 deletions
-
6Assets/Scripts/Data/QExtensions.cs
-
33Assets/Scripts/Modules/AliasModelAnimator.cs
-
3Assets/Scripts/Modules/AliasModelAnimator.cs.meta
-
76Assets/Scripts/Modules/RenderModule.cs
@ -0,0 +1,33 @@ |
|||
using System.Collections; |
|||
using UnityEngine; |
|||
|
|||
public class AliasModelAnimator : MonoBehaviour |
|||
{ |
|||
//private int frameNumber = 0;
|
|||
private float frameNumber = 0; |
|||
|
|||
IEnumerator Start() |
|||
{ |
|||
var meshRenderer = GetComponent<SkinnedMeshRenderer>(); |
|||
if (!meshRenderer) |
|||
{ |
|||
Destroy(this); |
|||
yield break; |
|||
} |
|||
|
|||
var mesh = meshRenderer.sharedMesh; |
|||
int numFrames = mesh.GetBlendShapeFrameCount(0); |
|||
|
|||
while (true) |
|||
{ |
|||
float blendWeight = (float)frameNumber / numFrames; |
|||
meshRenderer.SetBlendShapeWeight(0, blendWeight); |
|||
|
|||
//yield return new WaitForSeconds(0.1f); // Animate at 10 fps
|
|||
yield return null; |
|||
|
|||
//frameNumber = (frameNumber + 1) % numFrames;
|
|||
frameNumber = (frameNumber + Time.deltaTime * 10) % numFrames; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 7ff59a2f3571489c92ba4dc81d3df990 |
|||
timeCreated: 1618590871 |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue