Skip to content

Latest commit

 

History

History
244 lines (176 loc) · 13.8 KB

README.md

File metadata and controls

244 lines (176 loc) · 13.8 KB

Water-Saving Cleaning Robot – OpenGL Modeling Project

1. Project Overview

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.

EcoMop Pro rendered in a room with airflow particles 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”.

At a glance

  • 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.

2. Project Concept

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.

Design motivation

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 EcoMop Pro sketch with component labels and water reuse concept

Original design sketch showing the relationship between the water tank, cleaning components, and air inlets and outlets.


3. Implementation Environment

  • 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.

Repository layout

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

4. Graphics Techniques Used

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

Implementation details

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.


5. Model Structure

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.

Model views

Underside and cleaning components Water tank view
Underside showing twin mopping pads, brushes, wheels, and intake Rear view showing the blue water tank and ground shadow

Original screenshots from the coursework report. The underside view exposes components normally hidden by the floor.


6. How to Run the Project

6.1 Prepare the dependencies

  1. Clone or download the repository.
  2. Set up a Windows C++ compiler, OpenGL / GLU, and GLUT or FreeGLUT.
  3. Obtain stb_image.h from the upstream stb repository, then place it beside opengl_test.cpp or add its directory to the compiler include path. This header is currently not included in the repository. The source already defines STB_IMAGE_IMPLEMENTATION.
  4. Keep tilefloor.jpg and wall.jpg in the program's working directory. Both are loaded by relative filename.

6.2 Run with Code::Blocks

  1. Open Code::Blocks and create a C++ project. No Code::Blocks .cbp file is included, so add opengl_test.cpp to the new project.
  2. Configure the include and library paths for GLUT / FreeGLUT and stb_image.h.
  3. Link OpenGL, GLU, and the GLUT library that matches your compiler and architecture. A MinGW setup with FreeGLUT commonly uses freeglut, opengl32, and glu32.
  4. If using a dynamic GLUT / FreeGLUT build, make its matching runtime DLL available beside the executable or through PATH.
  5. 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.

6.3 Run with Visual Studio

  1. Open opengl_test.sln with Visual Studio and the C++ desktop build tools installed.
  2. The project specifies the v143 platform toolset. Install it or retarget the project to an installed compatible toolset.
  3. Restore the FreeGLUT NuGet package listed in packages.config: package ID freeglut.3.0.0.v140, version 1.0.2.
  4. Replace the existing machine-specific stb-master include path in the project settings with your local header location, or place stb_image.h beside the source file.
  5. 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.
  6. Set Debugging → Working Directory to $(ProjectDir) so the JPEG textures can be found, then build and run.

6.4 Controls

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.

6.5 Common setup issues

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.

7. Notes

  • 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.

8. Author

Coursework for Computer Graphics
Implemented using C++ and OpenGL in Code::Blocks

Project credits

  • 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.