3D Underwater World (using OpenGL and SDL)
Copyright Tristan Aubrey-Jones January 2008.
This is an example OpenGL SDL application
which creates an animated 3D underwater world
(screenshot), with "Thunderbird 4"
with headlights moving on a spline path, a randomly generated sand terrain, sunken ship/submarine/treasure chest models, and swaying fish
and seaweed. It is designed to demonstrate basic OpenGL features, and the structure is as follows:
- global.h - Global constants
- main.cpp - Main method
-
game.h
game.cpp
- Game class handling key presses, event loop and holding the World object.
-
world.h
world.cpp
- World class containing simulated enviroment with lighting setup, simulation functions and rendering code.
-
clipping.h
clipping.cpp
- contains the CameraView class holding the current camera position
and orientation, and the FrustrumClipper class which uses hyperplanes
to calculate whether a point is in view or not, so only objects inview
are drawn.
-
primitives.h
primitives.cpp
- primitive functions for drawing simple geometric shapes, like quadrangles, and texturing them.
-
regulargrid.h
regulargrid.cpp
- contains a textured grid of elevations for use in the terrain
-
terrain.h
terrain.cpp
- generates a random fractal landscape using the diamond square function
-
splines.h
splines.cpp
- contains SplineCurve class and MotionPath class for holding a 3D path
for an object to move along. The camera uses two, one for its position
and one for its viewing object
-
textures.h
textures.cpp
- contains texture loading function, courtesy for John Carter and a Texture
class to wrap common functionality.
-
vectors.h
vectors.cpp
- contains my own bespoke 3D vector class Vec3, 4D matrix class Mat4 (with
transformation functions, and hyperplane class.
-
worldobjects.h
worldobjects.cpp
- holds base classes for world objects which contain class definitions and implementation of objects that are drawn and
the animation functionality
Home
(
Download ZIP Archive )