Implementation
Implementing the lookat/lookfrom/vup viewing scheme
(1) Translate by -lookfrom, bring focal point to origin
(2) Rotate lookat-lookfrom to the z-axis with matrix R:
- v = (lookat-lookfrom) (normalized) and z = [0,0,1]
- rotation axis: a = (vxz)/|vxz|
- rotation angle: cos? = v•z and sin? = |vxz|
or: glRotate(?, ax, ay, az)
(3) Rotate about z-axis to get vup parallel to the y-axis
- watch out if vup is along the z-axis