We had our first on-line lecture.
I focused on showing you what it might be like to
work with a fully implemented 3D modeler.
You won't be able to do exactly what I did in class yet,
because we have not implemented object hierarchy.
But you can look at the code
HERE.
I have added more comments to make
it easier to read.
The code you will need to get started on the next homework assigment,
which I mostly implemented during a lecture
the week before last,
is at:
hw5.zip
Homework -- due before start of class on Thursday Mar 26
For homework,
you need to build an interesting 3D scene
using three "primitives":
- spheres
- squares
- cylindrical tubes
Each of these primitives will be represented as a single triangle strip,
and each will be drawn by a single draw call,
after setting material properties and doing suitable matrix transformations.
Using the codebase I implemented in class the week before last,
I've already implemented a sphere primitive for you,
and a working example that uses only spheres.
In order to implement any particular primitive as a triangle strip, you need to
convert any parametric value of (u,v),
where 0 ≤ u ≤ 1 and 0 ≤ v ≤ 1,
into six numbers.
Those six numbers represent a surface point P and a surface normal N.
In order to implement a square primitive as a triangle strip, you need to
convert the following math into code:
P = [ 2u-1 , 2v-1 , 0 ]
N = [ 0 , 0 , 1 ]
In order to implement a cylindrical tube primitive as a triangle strip, you need to
convert the following math into code:
let θ = 2 π u
P = [ cos(θ) , sin(θ) , 2v-1 ]
N = [ cos(θ) , sin(θ) , 0 ]
If you are feeling ambitious, feel free to try to
create other kinds 3D primitives as well.
For example, a torus is given by:
let θ = 2 π u
let φ = 2 π v
P = [ cos(θ) (1 + r cos(φ) , sin(θ) (1 + r cos(φ) , r sin(φ) ]
N = [ cos(θ) cos(φ) , sin(θ) cos(φ) , sin(φ) ]
Once you have implemente your primitive shapes,
you can use matrices to transform them
any way you like
by successive translation, rotation and scaling.
For example, you can make a landscape of trees,
transforming the square into a ground plane
and maybe fences,
the tubes into brown tree trunks,
and the spheres into a suggestion of green tree tops.
But it's really up to you what scene you want to create.
Have fun with this assignment.
As usual, be creative.
Use your imagination.
Impress me. :-)