Auto-orient primitive Task
We have a plate defined by coordinates of it's center in the world space, and coordinates of it's 4 vertices given in the model space.
We have a camera defined by it's position in world space, direction vector and up-vector (orientation).
Need GLSL code to rotate the plate to face the camera, preserving same orientation as camera.
vec3 plate_origin; // world space
vec3 plate_vertices; // model space, assuming origin is (0,0,0)
vec3 camera_position; // world space
vec3 camera_poi; // point of interest, world space
vec3 camera_up; // up vector, world space normalised
// GLSL code here to rotate plate_vertices to make plate face the camera
Note: We do have view and projection matrices but we do not want to do a billboard projection at this stage. We want to rotate vertices instead because further pipeline work requires world space coordinates, not clip space coordinates.