trying to read vertex positions from an animated alembic mesh, so far i’ve only managed to get the initial positions
...
ale = GetComponent<AlembicStreamPlayer>();
ale.CurrentTime = 5f;
mf = GetComponentInChildren<MeshFilter>();
Mesh mesh = mf.mesh;
Vector3[ ] vertices = mesh.vertices;
...
setting currentTime only works for the original meshRenderer, mesh.vertices gives initial vertex positions regardless…
Would somehow reading directly from the MeshRenderer’s VertexBuffer work or is there a less complicated solution?
Hi MischmeisterM,
Looking at the code sample, a few things could be causing this issue. Only setting the current time does not trigger an update of the vertices - you need to call UpdateImmediately instead. Also, make sure you get the MeshFilter you want, because there might be more than one.
Here is an updated code sample that might work:
ale = GetComponent<AlembicStreamPlayer>();
// Set current time to 5 + update animation
ale.UpdateImmediately(5);
// Assuming the name of the meshfilter you are looking for is `LiquidEmitter`
mesh = GetComponentsInChildren<MeshFilter>().First(x => x.name == "LiquidEmitter").mesh;
Vector3[] vertices = mesh.vertices;
(You can also use GetComponentsInChildren() to get an array of all the different meshes)
Let me know if that helps!
1 Like
wonderful, that’s the one… apparently was looking at the wrong docs…
much appreciated!
2 Likes