A (probably simple) question, but after hours of thinking, i barely can wrap my mind around it anymore. Short: i am stuck.
Background: i am developing a small feature to cut one mesh into two new meshes at runtime, using a customizable plane. This works well so far. Method is: create two copys of the original mesh and “collapse” the vertices, which are on the off-side of the plane relative to the new meshes side, onto the plane. The method is not part of the question, its just background information.
For this method to look nice and clean, i have to recalculate some UV-coodrinates in the cut-process and thats were things get tricky.
Consider the following:
I have a minimalistic mesh, containing 3 Vector3s A, B and C, forming a single triangle in 3D-space (see image below). Their respective world- and UV-coordinates are known. A 4. Vector3 D is calculated at runtime, its coordinates (world coordinates, as well as distance to A, B and C) are known. This new Vector3 D is guaranteed to be on the plane, which is spun up by A, B and C. The only thing unknown is the UV-coordinates of D, which have to be relative to the distance of D to A, B and C.
How do I calculate the UV-coordinates of D (relative to A, B and C) using the Positions of A, B, C and D, UV-Coordinates of A, B and C and the Distances AD, BD and CD?