OpenGL 1.1
Overview
In this project I have focused on procedurally generated shapes while utilising various OpenGL techniques like: lighting, transparency, planar shadows, stencil buffer, texturing and texture filtering. As well as 3 different cameras; FPP camera, which allows unrestricted movement, in any direction, around the scene with mouse and keyboard control, top down camera (GTA like) and fixed-security camera. All three cameras inherit from a virtual ‘Camera’ class which allows for a single camera call in the ‘Scene’ class and easy switching between them. Also, makes adding different types of cameras, easier.
Camera setting
Procedural Shape Generation
The ‘Shape’ class handles all procedural shape generation and rendering functions. All shapes in the scene are procedurally generated and textured using UV coordinates of one texture only for each shape. This proved some challenges especially when it came to UV texturing of a cylinder but in the end I was really pleased with the result and managed to map all shapes with one texture. And all shapes are rendered with triangle primitives. The ‘Shape’ class allows for a procedural generation of the following shapes: a sphere, a cylinder, a cone, a disk, a torus and a butterfly curve. Here’s an example of a shape building function call and its render function call.
Camera setting
This way of building shapes, which puts all vertices, normals and texture coordinates into separate vectors of floats allows for a single rendering function call which uses drawing arrays.
Features
6 lights - 5 controllable by the user and 1 animated
- point light
- spot light
- directional light
- low attenuation light
- red point light
- green point light
- animated blue light
3 cameras
- ‘FPP camera’ - allows the user to control X, Y and Z axes with the keyboard and pitch and yaw with the mouse.
- ‘Security Camera’ - procedural camera lerping 80 units to the left and 80 units back to the right. The user can take control over the camera and move it within the clamped area. It is also possible to control the camera while in the procedural mode. When the camera is set back to the procedural mode it picks up from where the user left it.
- ‘Top down camera’ - fixed top down view. The user can move the camera along the X and Z axes. Y axis is fixed.
Procedurally generated shapes
- sphere
- torus
- cylinder
- cone
- disc
- circle
- butterfly
Solar system and use of
- the matrix stack for hierarchical modelling and animation through hierarchical means.
- the stencil buffer - the entire solar system is reflected in the scene’s floor.
More
- Procedural UV texturing and dynamic texture filtering
- Transparency effects / Alpha blending
- Vertex arrays
- Models loaded in from an external file
- Dynamic shadows
- User interaction
- Wireframe mode
Instructions
You will start with a free camera which allows you to freely explore the scene. Use WSAD
and mouse
to control the free camera. Press 1
whenever you want to choose this camera.
Press 2
to switch to an automatic security camera. You can control it with WSAD when it is in an automatic mode or not. Press ‘C’ to toggle between the automatic mode.
Press 3
to switch to a top down camera. Use WSAD
to control it.
Press keys F1
, F2
, F3
, F4
, F5
, F6
to toggle lights 0 - 5 on and off. Light number 6 is an animated point light with medium attenuation and blue colour.
Use Arrow Keys to control the lights. Press G
or Page Up
to move in the positive direction on the z axis. Press T
or Page Down
to move in the negative direction on the z axis.
Keys F6
to F12
control texture filtering which is applied only to the quad above the scene with the grass texture.
F1
- Light 0 - spot light in -y direction and 45.0 degree cut off
F2
- Light 1 - directional light in positive x direction
F3
- Light 2 - low attenuation light
F4
- Light 3 - point light
F5
- Light 4 - point light - medium attenuation - red colour
F6
- Light 5 - point light - medium attenuation - green colour
F7
- Toggle Point Sampling
F8
- Toggle Bilinear Filtering
F9
- Toggle Mipmapping Filtering
F10
- Toggle Half Mipmapping Filtering
F11
- Toggle Half Trilinear Filtering
F12
- Toggle Trilinear Filtering
B
- toggle blend mode
M
- toggle wireframe mode
D
, E
, V
(press at the same time) - hide/show UI