Final project developed for the Computer Graphics (CG) course at the University of Minho.
Final Grade: 18 / 20
This repository implements a small real-time 3D graphics system built with C++, OpenGL, GLUT/GLEW, DevIL, and TinyXML2. The project evolved across four phases, starting with procedural generation of geometric primitives and culminating in a textured solar-system scene with hierarchical transformations, camera interaction, XML-based scene configuration, and animated rendering.
- Overview
- Demo
- Main Features
- Project Evolution
- Repository Structure
- Technologies
- Build and Run
- Generator Usage
- Solar System Example
- Learning Outcomes
- Authors
The goal of this project was to design and implement a complete graphics application capable of:
- generating 3D geometry procedurally;
- storing generated models in
.3dfiles; - loading scene descriptions from XML configuration files;
- rendering 3D scenes using OpenGL;
- applying geometric transformations, materials, textures, and camera controls;
- simulating a hierarchical animated solar system.
The final version combines a model generator and an OpenGL rendering engine. The generator produces primitive meshes such as planes, boxes, cones, spheres, tori, circles, and Bezier patches. The engine reads generated geometry and XML scene files, then renders the configured 3D world interactively.
The original Phase 4 README included the project demonstration assets. They are now surfaced directly in the main README.
The command-line generator can create multiple 3D objects and save them as .3d model files:
- plane;
- box;
- cone;
- sphere;
- torus;
- circle/orbit paths;
- Bezier patch surfaces.
Generated models are saved in the tests/ directory and can be loaded by the rendering engine.
The OpenGL engine supports:
- loading
.3dmodel files; - XML-based scene configuration;
- real-time rendering;
- camera/view manipulation;
- hierarchical transformations;
- translation, rotation and scaling;
- animated transformations;
- Catmull-Rom curves;
- textured models;
- material and lighting support;
- solar-system style scene composition.
The Phase 4 run.sh script provides a terminal menu for:
- cleaning and rebuilding the project;
- generating figures;
- viewing generated figures;
- running predefined test scenes;
- launching solar-system configurations.
The project is organized into progressive development phases:
| Phase | Focus |
|---|---|
Phase 1 |
Initial geometry generation and basic rendering pipeline |
Phase2 |
Interactive usage workflow and expanded primitive generation |
Phase3 |
Solar-system simulation and hierarchical scene structure |
Phase4 |
Textures, Bezier patches, improved engine structure, CMake build, XML parsing, and final demo |
CG-Project/
├── Phase 1/ # Initial project phase
├── Phase2/ # Second development phase
├── Phase3/ # Solar-system simulation phase
├── Phase4/ # Final version of the project
│ ├── engine/ # OpenGL rendering engine
│ ├── generator/ # 3D model generator
│ ├── external/tinyxml2/ # XML parser dependency
│ ├── patches/ # Bezier patch files
│ ├── tests/ # Generated/test .3d models
│ ├── CMakeLists.txt # CMake build configuration
│ ├── run.sh # Interactive build/run script
│ ├── Readme.md # Original Phase 4 notes and demo links
│ └── *.gif / *.jpeg # Demo media
├── test files/ # Additional test resources
├── Trabalho CG.eng.pdf # Project statement/report material
└── README.md # Main repository documentation
- C++11
- OpenGL
- GLUT
- GLEW
- DevIL / IL / ILU / ILUT for texture loading
- TinyXML2 for XML parsing
- CMake
- Shell scripting
The final implementation is located in Phase4/.
git clone https://github.com/diogocsilva12/CG-Project.git
cd CG-Project/Phase4On Ubuntu/Debian-like systems:
sudo apt update
sudo apt install build-essential cmake freeglut3-dev libglew-dev libdevil-devOn macOS with Homebrew:
brew install cmake freeglut glew devilchmod +x run.sh
./run.shThe script can clean/build the project, generate figures, view generated models, and run predefined scene configurations.
mkdir -p build
cd build
cmake ..
makeThis creates the main executables:
generator/generator— procedural model generator;build/engine— OpenGL rendering engine.
General form:
./generator <primitive> <parameters> <output_file.3d>Examples:
# Plane
./generator plane 1 3 ../tests/plane_1_3.3d
# Box
./generator box 2 3 ../tests/box_2_3.3d
# Sphere
./generator sphere 1 10 10 ../tests/sphere_1_10_10.3d
# Cone
./generator cone 1 2 16 8 ../tests/cone_1_2_16_8.3d
# Torus
./generator torus 1 0.5 16 8 ../tests/torus_1_0.5_16_8.3d
# Bezier patch
./generator bezier ../patches/teapot.patch 10 ../tests/bezier_teapot_10.3dThe final phase includes a solar-system simulation using generated spheres, orbit curves, hierarchical transformations, and textures.
Example model generation commands:
# Generate sphere for celestial bodies
./generator sphere 1 8 8 sphere_1_8_8.3d
# Generate torus for Saturn's rings
./generator torus 1 0.5 16 8 torus_1_0.5_16_8.3d
# Generate circles for orbits
./generator circle 30 64 circle_30_64.3d # Mercury orbit
./generator circle 40 64 circle_40_64.3d # Venus orbit
./generator circle 50 64 circle_50_64.3d # Earth orbit
./generator circle 3 32 circle_3_32.3d # Moon orbit
./generator circle 60 64 circle_60_64.3d # Mars orbit
./generator circle 2.5 32 circle_2.5_32.3d # Phobos orbit
./generator circle 3.5 32 circle_3.5_32.3d # Deimos orbit
./generator circle 75 64 circle_75_64.3d # Jupiter orbit
./generator circle 4 32 circle_4_32.3d # Various moon orbits
./generator circle 90 64 circle_90_64.3d # Saturn orbit
./generator circle 102 64 circle_102_64.3d # Uranus orbit
./generator circle 110 64 circle_110_64.3d # Neptune orbitThe Phase 4 engine can then load XML scene files from engine/configs/, including static and dynamic solar-system configurations.
This project demonstrates practical knowledge of:
- procedural mesh generation;
- real-time 3D rendering;
- graphics pipeline organization;
- OpenGL transformations and camera control;
- hierarchical modelling;
- XML-driven scene descriptions;
- texture mapping;
- Bezier surface tessellation;
- interactive graphics application development in C++.
- Diogo Coelho da Silva
- Eduardo Pereira
- Pedro Oliveira
- João Barbosa
BSc in Computer Science
University of Minho
Developed as part of the Computer Graphics (CG) course at the University of Minho.
Final Grade: 18 / 20


