public void SetShapeKeyWeight(Mesh mesh, float weight, MeshAnimationAttachment attachment) { if (!_meshes.TryGetValue(mesh, out var entry)) { return; } var positions = entry.Geometry.Positions; var normals = entry.Geometry.Normals; for (int i = 0; i < attachment.VertexCount; i++) { var oldPos = mesh.Vertices[i].AsVector3(); var keyPos = attachment.Vertices[i].AsVector3(); if ((keyPos - oldPos).LengthSquared() > 0.001) { var newPos = Vector3.Lerp( oldPos, keyPos, weight); positions[i] = newPos.AsPoint3D(); } var oldNormal = mesh.Normals[i].AsVector3(); var keyNormal = attachment.Normals[i].AsVector3(); if ((keyNormal - oldNormal).LengthSquared() > 0.001) { var newNormal = Vector3.Lerp( oldNormal, keyNormal, weight); normals[i] = newNormal.AsMVector3D(); } } }
public ShapeKey(Mesh mesh, MeshAnimationAttachment attachment) { Mesh = mesh; Attachment = attachment; }
public void SetShapeKeyWeight(Mesh mesh, float weight, MeshAnimationAttachment attachment) { }