I have a cube and 4x4 transformation matrix Cube is rotated randomly I need to find the nearest face of cube regarding to camera and rotate the cube by aligning that face to the camera.
How can I do that. Thanks in advance.
I have a cube and 4x4 transformation matrix Cube is rotated randomly I need to find the nearest face of cube regarding to camera and rotate the cube by aligning that face to the camera.
How can I do that. Thanks in advance.
Copyright © 2021 JogjaFile Inc.
Find the vertex closest to the camera.
There are three faces containing that vertex. Compute the dot product of the normal to each face with the vector from the vertex to the camera. The one with the largest dot product is the face that is closest (because $A\cdot B =||A||\ ||B|| \cos \theta $).
You then want to rotate that face so its normal points directly at the camera.