Hey all, for a particular project I'm doing, I need to create a dynamic mesh to emulate the affects of linerenderers on a large scale. The problem I'm running into is that I'm not really sure how to go about have the 4 vertices rotate around the origin so the 2 triangles are oriented at the camera. Basically, I'm just trying to come up with a function that takes 4 vertices and an origin, than transforms them so that the faces created by them are at the camera (like the line renderer does). Any help would be greatly appreciated! No, I can't just use the linerender class itself, because this will need to be highly optimized on a mobile device to limit both drawcalls and function mesh update calls. Edit: I'm inquiring as to the quaternion math itself, not the theory or technicality involved in rotating points in 3d space.
Code (CSharp): for (int n = 0; n < vertices.Length; n++) { vertices[n] = rotation * (vertices[n] - centerPoint) + centerPoint; } Where vertices[n] is the vertex you want to rotate, rotation is a quaternion describing the rotation (duh) and the centerPoint is the point you want to rotate around. Yes, I know this is close to three years old
Good stuff. 1) Reversing Matrices operation "Transform Move" by (vertices[n] - centerPoint). 2) Applying rotation via rotation *. 3) Applying "Transform Move" back again with + centerPoint. Very good and useful.
if anyone is looking, this tool allows you to transform vertices of a mesh and position vertices by handle manipulation or by directly entering the x,y,z coordinates of each vertex. https://assetstore.unity.com/packages/slug/166155