I'm working on an annotation system that allows a user to click on a mesh to attach a pin with a label hanging off it.
It must be possible to pin an annotation on an object that's being morphed with keyframe morph targets, so that the pin will move with the surface of the mesh.
It's mainly pretty simple, where I do a ray-intersect to find the pin position on the mesh, for the shape of the mesh at the current time within the morph targets.
Then I have, for that time instance:
- the 3D coordinates of the pin
- the triangle (ie. the indices and vertex positions of the triangle's vertices) that the pin is within
- the time instant
Now, if I had the 3D coordinates of the pin at each of the morph's targets, then I can simply tween the pin position, to animate it in synch with the morph.
However, the challenge I is to somehow compute the position of the pin at each of the morph targets, from these three pieces of information.
Intuitively, it seems to be a matter of somehow finding some sort of coefficient (or set of coefficients) that indicates the pin's position relative to the vertices of its enclosing triangle, at the instant within the morph sequence that we attach the pin.
Then, for each other target within the morph sequence, given the morphed positions of the triangle vertices, which could be anything, somehow use the coefficient(s) to find the updated pin position, relative to the triangle's current vertex positions.
Anybody got any ideas? Math pointers etc?
cheers!