This repository contains the source code for the practical assignment of Computer Graphics course at Universidade do Minho.
The assignment had the requirement to implement an engine using OpenGL 2 capable of loading and rendering arbitrary worlds defined in a custom XML format, ultimately creating a complete solar system with planets, comets and orbit rotations.
The generator program, which was also part of the assignment, allows the creation of 3D models to be used in scene files loaded by the engine. The engine supports both the custom .3d format and Wavefront .obj files. The program outputs vertex positions, normals, texture coordinates, and vertex indices to a text file in the custom .3d format. This generator can also create complete scenes like the solar system.
Usage: generator <command> <args> <output file>
Commands:
generator plane <length> <divisions> <output file>
generator sphere <radius> <slices> <stacks> <output file>
generator cone <radius> <height> <slices> <stacks> <output file>
generator box <length> <divisions> <output file>
generator cylinder <radius> <height> <slices> <output file>
generator patch <patch_file> <tesselation> <output file>
generator solar-system <sun size scale factor> <planet distance scale factor> <scene scale factor> <number of asteroids> <output file>
- Toggle settings: lights, v-sync, backface culling, wireframe mode, MSAA, frustum culling, render axes, display normals, show AABB for frustum culling, show temporal translation path, and display light models.
- Control simulation: pause, resume, and adjust speed.
- Camera configuration (also possible with WASD + Space + Ctrl): modify position, FOV, acceleration, friction, and more.
- Manage lights: add, remove and list all lights in the scene.
- Edit world models: view and modify material properties and transformations of each model in the scene graph.
- Display vertex information of a model in a table format.
Implemented frustum culling using AABB intersection with view planes. The AABB dynamically updates with object scaling and rotation. No space partition optimization is currently implemented.
AABB.mp4
First-person and third-person camera views with smooth acceleration and deceleration for nice transitions between motion states with many parameters configurable.
Camera.mp4
More features can be found in the four project reports. While they are written in Portuguese, they include additional images that may still be useful to non-Portuguese readers.
Prerequisites:
- Open the project in CLion.
- If prompted to install the toolchain, click
Install
. - Navigate to
File
->Settings
->Build, Execution, Deployment
->CMake
and add the following flag toCMake options
:You can find this path by running-DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
vcpkg integrate install
and looking at the output. - Reload the CMake project.
$ cd cg-solar-system
$ cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=[path to vcpkg]/scripts/buildsystems/vcpkg.cmake
$ cmake --build build
$ .\build\engine\Debug\cg-solar-system.exe <scene> # For running the engine
$ .\build\generator\Debug\cg-generator.exe <args> # For running the generator
You can find the [path to vcpkg]
by running vcpkg integrate install
and looking at the output.