In addition, before clipping, it is common to have the following calcluation simulate the effect of a movable camera: Every points coordinates get subtracted with the coordinates of a camera:
Pin so called "camera space" = Pin 3d-coordinate system - Ccamera position
Here you are (example of one point being transformed in order to resolve the effect of a mathematically defined camera location)
is a bit harder to understand. With the means i just talked about, we are now already able to create a little geometry together with the possibility to move the camera around. Swaying the camera is not made possible already since we did not talk about the mathematics for that already - we need to explain geometry rotation in 3d space for that. Ok great, let's start.
draw()
which manages drawing a few points and drawPoint()
which is called repeatedly from there - for every point that needs to get drawn.And here's the result:
You can move around the camera with the buttons
Can you guess the coordinates of the green point? The red dot is the origin. (You'll also find the answer in the code (listed below)).
As you already see, (...?)
Nevermind if you dont understand the code fully, please go to the next lesson: Lets continue 3d: 'V': drawing Edges.