Default bounds
1 -1
| /
| /
| /
|/
-1 --------------- 1
/|
/ |
/ |
/ |
1 -1
Matrices
model: transforms each object separately
view: transforms the whole world
for instance, a positive x translation moves either one object or all objects on the screen to the right a certain distance.
If you want to transform the camera position or rotation, it should be the inverse of the transformations the view matrix is applying.
projection: Here's where the fun stuff begins
Viewing Frustum diagram is on page 99
I need to first implement the click detection function without applying the projection matrix
The click detection function uses ray tracing to figure out which object we hit
First, we need to generate the equation for the ray that starts at the camera position and through the point the user clicked. To do that, we need to turn the 2d point of the click into a 3d point on the near clipping plane.
Ray Equation:
R(t) = O+Dt
where R(t) defines all the points on the ray, O is the camera origin,
and D is the direction of the ray.
In this case, D = P-O, where P is the point the user clicked on in 3D space
Camera position = (0, 0, 0)
BUFFER FUNCTIONS
-----------------
glGenBuffers creates a buffer
glBindBuffer sets the currently active buffer
glBufferData populates the buffer with data
glGenVertexArrays creates a vao
glBindVertexArray sets the currently active vao
glEnableVertexAttribArray sets the active index in the vao
glVertexAttribPointer determines the layout of a buffer in a VAO
-The last params (often NULL), specifies the offset in the buffer