3d Meshes

3D objects are represented as polygonal meshes; e.g. a whole lot of 3D polygons are positioned to form the outside/skin of the object.

E.g. a cube is 6 polygons.


3D shapes need to have correctly set normals in order for lighting to work correctly. Normals are typically set per vertex (although face normals would be done by lerping between vertices), and the desired normal angle depends on the type of shape/face.

Flat surfaces should have perpendicular normals, whilst curved surfaces should have tilted normals to give the illusion of curvature.

Vertex Order

Vertices in each face are drawn so that the front of the polgyon faces outwards so the cube (e.g. if the normal were calculated it would point away from the cube.

If we consider a right-handed 3D space this means drawing the vertices anti-clockwise.

Calculating Normals

Normals can be calculated in a number of ways, the two simplest are Newell’s Method and a pure Cross Product.


Typically a call to normalise would be included at the end, although with GL_NORMALIZE enabled this is unnecessary.


An object mesh needs to } be stored somehow (in order for calculations to be easily performed). One method of this is lists/arrays of vertices and normals, with a list of face-connections for easy referencing, e.g.

[[ missing photo :( ]]

In this example face 0 would go to vertices[0] and normals[0]


Extrusion is the process of taking a 2d object, then scaling and rotating it along a path in 3d space. The simplest extrusion is no scale and no rotate. eg extruding a square to a cube. A Frustam is an example of a scale. I can’t think of an easy rotate example. Use your imagination.

You can think of it like the parametric form of a specific polygon. We can take in a point representing a position in space and return a cross section of the polygon at that point. This can be thought of like lerping except that rotation kinda fucks the lerp up.