Creating a deformation volume to warp a list of vertices locations

So I’ve never done this before. I’ve recently created a obj imported so I can now import any mesh I make externally directly into my c++ containers, and then into a Runtime Mesh Component. Now I’d like to add some functionality to warp and distort these objects on the fly. I know from using Maya that volumes are used to deform meshes. For my purposes I would like to start with a Volume triangle (I imagine this is the easiest). If anyone knows of some sources that I could read up on I would greatly appreciate it. Any input or advice on how to approach this is appreciated, thanks!

I would imagine this is a cut and paste type of operation. The best I’ve got figured out so far is that I need to get the new direction vector by something like…

FVector dA = deformToVertA - deformFromVertA;
FVector dB = deformToVertB - deformFromVertB;
FVector dC = deformToVertC - deformFromVertC;

Then maybe I move each sub vert in the new mesh (the mesh to be deformed) by its 0.0 - 1.0 distance to each vert using that corresponding direction vector (by the percent of distance to original vert) something like…

//Arbitrary vert in deform mesh
AVIDM += (((deformFromVertA - AVIDM).size() * dA) + ((deformFromVertB - AVIDM).size() * dB) + ((deformFromVertC - AVIDM).size() * dC)) / 3;

Someone shot me a helpful idea to use barycentric coordinates. Here. This seems very promising. FMath::ComputeBaryCentric3D will return a FVector4, each 0 - 1.0 float representing the percentage of distance towards it’s respective vertex. This is great because I could get the triangleToDeformTo barycentric center, then loop through each of the 4 verts defining this tetrahedron, get (vert - centerVert) * floatAmountForThisVert + centerVert. I wish there was an easier way to convert the bary coords to a vector, maybe that’s just wishful thinking. Also, I’ve heard there is a way to do this using matrices, does anyone know how that would work?

I believe I can accomplish the deformation using Barycentric Coordinates as someone very kindly pointed out to me. The function FMath::ComputeBaryCentric3D appears to take 4 vertices that make a tetrahedron, and one point to fetch the barycentric coordinates for. I could pre-compute this in my object type storing FVector4 instead of FVector3 for the vertices, and this way I could deform based upon the Deform to mesh. What I’m curious about now is how I could accomplish this using matrices for the transformation. In that function above I notice that they build a tetrahedron matrix like so



	const FVector B1 = (B-A);
	const FVector B2 = (C-A);
	const FVector B3 = (D-A);

	//Create a matrix of linearly independent vectors
	const FMatrix SolvMat(B1, B2, B3, FVector::ZeroVector);

https://lh3.googleusercontent.com/55_vvpe8X3mSrk23ENx_mbYj_8h4m7KwijhhMYM5zT7dv2FnUk_9LOJGguT1-Ab_ssmmsGazd7mQcZaF0sTJGDZ7_DewoX8UtkfECxBhq23inckGOXNeL2TJnY5vJW7KGdECHb5EmffhLCN3bquqmkq57A7qsJMdDYndJM28xp_gQvVYV8pRHdbEmSqOGUyO15r4EOQ82m-QgCBN6STcNF8IOsr--8lohZuTJLOpBaIGW-sQJWjHQRt3Y2MWyr2-HttNjsERCBCrI6b14hf1UvBza3W8SD4m29bYkx6Y9r9kPKx1L--HqvRZTZX7sMTpvVzlSuWrI8Tp3EOpoh2Ie6U2XmfJHh8x3BoHkv_GDqw2LZYXF7ZnBgef4v0nCsXQ2IORtU_ewNt3zxVRSN6Wg3HmtIuyq1Ach_XHJ3vafYFAMCDyif5N13Cs72HjqkRsdQwy4r9F7Qk3XzQUHx5rDMqQHnkCcFcRrWWCWC_dDfYTW8HW3FVj2kuuXuezMhfQzJ6r6n3mn_pGKBe8TAKnzhJdujNdYd0NVWAJQ-ALr7tgx0E8dlfOvpU3hjQvNOKdWpxAEAwX0B-OLjVyit0jzx-KDQOo2TskNhC1LXN_gMONKIHWtw1t=w1000-h764-no

This leads me to believe that the I could use matrices to do the warping for the vertices. Attached is a drawing of what I’m trying to accomplish. I’m very new to Matrices so any help is appreciated. One advantage I’m guessing to using matrices for this is that I could use them to fix the normal of the vertices too, so I don’t have to manually compute them and set them. Although I don’t know that it’s much difference in performance. Maybe not even as performant. It may be best to precompute the barycentric coordinates, offset the vertices, and just compute the normal adjustment for them. One problem I keep running into is figuring out which verts belong to which matrix.

https://lh3.googleusercontent.com/mIFEVUU5MKXyzkAhSMgETcqgpVOSg9n17E_GadKc95SlW7h6FBmdWAS6tqxlkpDnuGtHFZVldIc9x8ABelMLDQ-R93RcUKBGk9zCWUembj8pjSadnXzJ8KzA2JplBddc_SSDyr8oozhcmdP0rNhLZyepA8C0ye4fnqUMGgpuZ2IISBS7PryyBz_opTDfbsrdfkSGQWZcdKBvsRDmfFmzZJ0husT9Uf7iShBCLGrLBESrgYiGvXn0q--bVzSxSzPuIX5sWa3zd3f3r2K4N541dIw_dPrewB5Sy4tx6Rgf_lFny0PhANXmf0y4kyiwUuvinai5sidP4PdvDjpEKSzWPtAd0KA4viVEViP1iMUlgpKdZpaxqID7bOZVbo4PEX4CK1il5BJ_d9iArePMjN1H_cgOPq8s62DXyjeOOzjlEWhWp0HRPCcDFC8Jb_E4KCA-gU7UCzp23X0hQGH0WH-X3h-Fl5fLsegckBX4Ke-EwBcKH5RhC8liwQiuNViHT9R1SxjUSp6dq5Iih9m3gMmnJl4T5J0R4M1zOC2K4ueKoa3hqj1aRLCgG2BcZ7dNhm0ubT3W2qZFYBrA7LjeaqVd8N_w87pFsLvUMwaGQ9hynt921Zoi=w600-h410-no