This project is a Computer Graphics (CG) course assignment implemented using C++ with OpenGL in Code::Blocks.
The objective of this assignment is to practice 3D modeling, transformation, and rendering techniques using OpenGL.
The modeled object is a water-saving floor cleaning robot, designed with an environmental protection concept:
- The robot can collect moisture from the air and convert it into water for floor mopping.
- The dry air output is reused to blow-dry the floor after cleaning.
The project focuses on visual modeling and graphics implementation, rather than physical simulation or hardware control.
The project is named EcoMop Pro in the application and accompanying design materials. It presents a robot assembled from procedural geometry in an interactive room scene, with camera controls, animated cleaning components, airflow particles, lighting, textures, and a ground shadow.
Original OpenGL screenshot from the coursework report. The archived screenshots use the earlier window title “Cleaning Vacuum”; the current source uses “EcoMop Pro”.
- Model: circular body, transparent water tank, wheels, side brushes, twin mopping pads, vents, sensors, and a control panel.
- Rendering: fixed-function OpenGL lighting, material properties, texture mapping, alpha blending, and a stencil-assisted planar shadow.
- Animation: rotating brushes and wheels, oscillating mopping pads, and a pool of 500 airflow and dust particles.
- Interaction: mouse-controlled viewing, keyboard movement, and separate display and animation toggles.
The design concept of the robot combines floor cleaning and water conservation:
- Moisture absorption module
Simulates the idea of extracting water vapor from the air and storing it as a water source for mopping. - Mopping module
Uses the collected water to clean the floor surface. - Drying module
Releases dry air to accelerate floor drying after mopping.
This concept is represented visually through 3D geometric modeling in OpenGL.
The starting point is to reuse the water produced by dehumidification for floor cleaning. The accompanying coursework and PIID materials develop this into a broader air-and-floor-care concept, including humidification and air purification. These are intended product functions; this repository implements their visual representation.
The main conceptual flow is humid air → moisture collection → water tank → mopping, with dry air reused for floor drying.
Original design sketch showing the relationship between the water tank, cleaning components, and air inlets and outlets.
- Programming Language: C++
- Graphics Library: OpenGL
- IDE: Code::Blocks
- Platform: Desktop (Windows)
The original coursework used Code::Blocks. The files currently included in this repository are a Visual Studio solution and C++ project, so both setup routes are described below.
| Dependency | Role |
|---|---|
| OpenGL | Geometry, transforms, lighting, materials, textures, and blending |
| GLU | Perspective projection and camera setup through gluPerspective and gluLookAt |
| GLUT / FreeGLUT | Window creation, input callbacks, timers, and solid primitives |
stb_image.h |
Loading the JPEG floor and wall textures |
| Windows C++ toolchain | Compiling the source, which includes windows.h |
The renderer uses legacy immediate-mode OpenGL (glBegin / glEnd) and the fixed-function pipeline. It needs a context that supports those APIs.
OpenGL_Modeling_Project/
├── opengl_test.cpp # Model, rendering, animation, and input
├── opengl_test.sln # Visual Studio solution
├── opengl_test.vcxproj # Visual Studio C++ build settings
├── opengl_test.vcxproj.filters # Visual Studio file grouping
├── packages.config # FreeGLUT NuGet dependency
├── CppProperties.json # Editor / IntelliSense configuration
├── tilefloor.jpg # Floor texture
├── wall.jpg # Wall texture
├── docs/images/ # Project illustrations and screenshots
└── README.md
The project applies basic computer graphics techniques taught in the course, including:
- Primitive-based modeling (cubes, cylinders, etc.)
- Hierarchical object composition
- Geometric transformations:
- Translation
- Rotation
- Scaling
- Color and simple material settings
- Coordinate system and viewpoint control
- Rendering pipeline using OpenGL
| Technique | Application in this project |
|---|---|
| Procedural geometry | drawPartialCylinder() builds curved surfaces with quad strips; drawDisk() builds circles and sectors with triangle fans. |
| Hierarchical transformations | glPushMatrix() / glPopMatrix() isolate each component's translation, rotation, and scaling before assembly. |
| Curved vent modeling | drawWidePolarBezierWithHoles() uses quadratic Bézier interpolation of the polar angle to place a curved band and repeated openings. |
| Lighting and materials | Three lights, surface normals, smooth shading, and ambient, diffuse, specular, and shininess settings distinguish the shell, wheels, and tank. |
| Transparency | Alpha blending and temporary depth-write changes represent the blue water and transparent tank shell. |
| Texture mapping | stb_image loads the floor and wall JPEGs for the room scene. |
| Planar shadow | shadowMatrix() projects simplified robot geometry onto a ground plane; the stencil buffer masks the blended shadow. |
| Particle effects | Four particle groups visualize vacuum intake, vacuum exhaust, dehumidifier intake, and dehumidifier exhaust. Each particle has position, velocity, color, size, and lifetime. |
| Animation | A timer requests updates every 16 ms. Brushes and wheels rotate, mopping pads oscillate, and particles move and fade. This is an update interval, not a measured frame-rate guarantee. |
| Camera and overlays | Perspective viewing uses gluLookAt(); an orthographic overlay displays the title and keyboard help. |
The main rendering sequence is camera and lights → room → robot and particles → ground shadow → text overlay.
The robot model is composed of multiple parts, such as:
- Main body
- Water collection module
- Mopping component
- Air outlet for drying
- Wheels / base structure
Each component is modeled separately and combined using transformation matrices to form the complete robot.
| Component | Modeling approach |
|---|---|
| Main body and water tank | Partial cylinders and disks form the shell, covers, tank sector, and visible water surface. |
| Drive wheels and caster | Tori, spheres, and transformed subcomponents represent the wheels and steering assembly. |
| Side brushes | Repeated, scaled cube segments form the bristles; local rotation animates each brush. |
| Twin mopping pads | Flattened spheres form the pads, with small oscillating translations. |
| Air inlets and outlets | Repeated vent slots and a curved band communicate the airflow paths. |
| Bumper | Segmented curved geometry wraps around the body. |
| Camera, IR sensors, and control panel | Small geometric details identify the proposed sensing and user interface components. |
| Underside and cleaning components | Water tank view |
|---|---|
![]() |
![]() |
Original screenshots from the coursework report. The underside view exposes components normally hidden by the floor.
- Clone or download the repository.
- Set up a Windows C++ compiler, OpenGL / GLU, and GLUT or FreeGLUT.
- Obtain
stb_image.hfrom the upstream stb repository, then place it besideopengl_test.cppor add its directory to the compiler include path. This header is currently not included in the repository. The source already definesSTB_IMAGE_IMPLEMENTATION. - Keep
tilefloor.jpgandwall.jpgin the program's working directory. Both are loaded by relative filename.
- Open Code::Blocks and create a C++ project. No Code::Blocks
.cbpfile is included, so addopengl_test.cppto the new project. - Configure the include and library paths for GLUT / FreeGLUT and
stb_image.h. - Link OpenGL, GLU, and the GLUT library that matches your compiler and architecture. A MinGW setup with FreeGLUT commonly uses
freeglut,opengl32, andglu32. - If using a dynamic GLUT / FreeGLUT build, make its matching runtime DLL available beside the executable or through
PATH. - Set the execution working directory to the repository root, then build and run.
The 3D model will be displayed in an 800 × 600 OpenGL window titled EcoMop Pro.
- Open
opengl_test.slnwith Visual Studio and the C++ desktop build tools installed. - The project specifies the v143 platform toolset. Install it or retarget the project to an installed compatible toolset.
- Restore the FreeGLUT NuGet package listed in
packages.config: package IDfreeglut.3.0.0.v140, version1.0.2. - Replace the existing machine-specific
stb-masterinclude path in the project settings with your local header location, or placestb_image.hbeside the source file. - Check the include paths, linked libraries, and runtime DLL for the selected Win32 or x64 configuration. The bundled FreeGLUT package is older than the configured compiler toolset; if restoring it is insufficient, configure a compatible FreeGLUT build manually.
- Set Debugging → Working Directory to
$(ProjectDir)so the JPEG textures can be found, then build and run.
| Input | Action |
|---|---|
W / S |
Raise / lower the camera |
A / D |
Rotate the camera horizontally around the scene origin |
Q / E |
Move the camera closer / farther away |
| Left mouse drag | Rotate the camera horizontally and vertically |
↑ / ↓ |
Move the robot forward / backward along its current heading |
← / → |
Turn the robot and adjust the caster angle |
1 |
Show / hide the ground, wall, and ground shadow |
2 |
Pause / resume component animation and particle updates |
3 or uppercase P |
Toggle particle effects |
H |
Show / hide the title and control help |
R |
Reset the camera, robot position and heading, and component animation values |
Esc |
Exit |
Letter controls accept either case except the particle shortcut, which is specifically uppercase P; 3 is the simplest alternative. Resetting with R does not change the visibility or animation toggles.
Suggested walkthrough: inspect the room view, use the arrow keys to move and turn, then press 1 and drag the camera below the robot to inspect its underside. Toggle 3 to compare airflow views, and press H to hide the main help overlay for screenshots.
| Symptom | Check |
|---|---|
stb_image.h cannot be found |
Add the missing header and correct its include path. |
GL/glut.h cannot be found |
Configure the GLUT / FreeGLUT include directory. |
| Unresolved OpenGL, GLU, or GLUT symbols | Check linker libraries and ensure compiler and library architectures match. |
| Missing GLUT / FreeGLUT DLL at launch | Make the matching runtime DLL available to the executable. |
| Floor or wall texture is missing | Check the working directory and the exact filenames tilefloor.jpg and wall.jpg. |
| Visual Studio reports a missing NuGet import | Restore the package specified in packages.config or update the project to a manually configured FreeGLUT installation. |
- This project is intended for academic and learning purposes only.
- The robot’s functionality is conceptual and visual, not a physical simulation.
- The focus of the assignment is on 3D modeling and rendering, rather than real-world feasibility.
- Navigation is controlled manually with the keyboard. The camera and IR sensor models are visual components; the source does not implement autonomous navigation, obstacle detection, or hardware sensing.
- Airflow particles illustrate the concept. They do not calculate humidity, condensation, water consumption, or cleaning performance; the displayed water level is a fixed value.
- Broader features discussed in the design materials, such as voice control, automatic humidity regulation, and air purification, remain product concepts.
- The code includes no measured water-saving or energy-efficiency results.
- The screenshots and sketch above come from the original coursework materials, rather than a new build of the current repository. Build instructions describe the checked-in source and configuration; a clean build has not been verified for this README update.
Coursework for Computer Graphics
Implemented using C++ and OpenGL in Code::Blocks
- Project members: He Bolin and Bai Wuchen
- Course: SWE206 Computer Graphics, Xiamen University Malaysia
- Academic session: 2025/04
- Supervisor: Dr. Burra Venkata Durga Kumar
The EcoMop Pro concept is also documented in the team's PIID 2025 extended abstract. The implementation details in this README refer to the C++ source in this repository.



