| 23 | return program |
| 24 | |
| 25 | def lookAt(eye, center, up): |
| 26 | forward = center - eye |
| 27 | forward = forward / np.linalg.norm(forward) |
| 28 | up = up / np.linalg.norm(up) |
| 29 | right = np.cross(forward, up) |
| 30 | newUp = np.cross(forward, right) |
| 31 | |
| 32 | # view matrix |
| 33 | return np.array([ |
| 34 | [right[0], right[1], right[2], -np.dot(right, eye)], |
| 35 | [newUp[0], newUp[1], newUp[2], -np.dot(newUp, eye)], |
| 36 | [forward[0], forward[1], forward[2], -np.dot(forward, eye)], |
| 37 | [0, 0, 0, 1] |
| 38 | ]) |
| 39 | |
| 40 | def getOrthographicProjectionMatrixOpenGL(left, right, bottom, top, near, far): |
| 41 | return np.array([ |