https://github.com/muppetsg2/shapes-generator
This project is a console-based Shape Generator program written in C++. It allows the user to create and save a variety of 3D shapes.
https://github.com/muppetsg2/shapes-generator
3d 3d-shapes console-application cpp generator shapes shapes-generator
Last synced: 9 months ago
JSON representation
This project is a console-based Shape Generator program written in C++. It allows the user to create and save a variety of 3D shapes.
- Host: GitHub
- URL: https://github.com/muppetsg2/shapes-generator
- Owner: Muppetsg2
- License: mit
- Created: 2024-07-04T09:34:56.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-03T22:04:02.000Z (about 1 year ago)
- Last Synced: 2025-05-03T23:18:15.524Z (about 1 year ago)
- Topics: 3d, 3d-shapes, console-application, cpp, generator, shapes, shapes-generator
- Language: C++
- Homepage:
- Size: 504 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Shapes Generator 1.3.0
## ๐ Description
This project is a console-based **Shape Generator** written in **C++**. It allows users to create and save various **3D shapes** such as:
๐ด Sphere | ๐ท IcoSphere | โญ Plane | ๐ง Cube | ๐ข Cylinder | โฌข Hexagon | ๐ฆ Cone | ๐ผ Tetrahedron | ๐บ Pyramid | ๐ฉ Torus
The program dynamically generates the shape based on user input and exports the shape data to a file.
> ๐งญ Note: All shapes use the counterclockwise order for listing vertices, which ensures consistency and simplifies rendering in most 3D engines.
> ๐บ Note: Each shape is constructed using triangles.
๐ **Technologies used:**
- **GLM** (OpenGL Mathematics) for vector operations
- **FMT** for formatted output
## ๐ Table of Contents
- [โจ Features](#-features)
- [๐ฆ Dependencies](#-dependencies)
- [โ๏ธ How to Build](#%EF%B8%8F-how-to-build)
- [๐ฅ๏ธ Windows](#%EF%B8%8F-windows)
- [๐ง Linux](#-linux)
- [๐ MacOS](#-macos)
- [โถ๏ธ Usage](#%EF%B8%8F-usage)
- [๐งพ Configuration](#-configuration)
- [๐ Example Output](#-example-output)
- [๐ Troubleshooting](#-troubleshooting)
- [๐จโ๐ป Authors](#-authors)
- [๐ License](#-license)
## โจ Features
โ
**Interactive User Input**
- Configure shapes through console input.
- Choose from **ten** different shapes:
1. ๐ด Sphere
2. ๐ท IcoSphere
3. โญ Plane
4. ๐ง Cube
5. ๐ข Cylinder
6. โฌข Hexagon
7. ๐ฆ Cone
8. ๐ผ Tetrahedron
9. ๐บ Pyramid
10. ๐ฉ Torus
โ
**ESC Key Support**: Press **ESC** anytime to exit the program.
โ
**File Output**: Generated shapes are saved in `shape.txt` or `shape.obj` for later use.
โ
**Error Handling**: Provides feedback for invalid inputs and applies sensible defaults.
## ๐ฆ Dependencies
- **C++20** or later
- **CMake 3.21** or later
- **GLM** Library (OpenGL Mathematics)
- **FMT** Library (Formatted console output)
## โ๏ธ How to Build
### ๐ฅ๏ธ Windows
1. **Clone the repository:**
```bash
> git clone https://github.com/Muppetsg2/Shapes-Generator.git
> cd Shapes-Generator
```
2. **Open the folder in Visual Studio** (supports CMake natively).
3. CMake will **configure** the project and **download** dependencies automatically via `CPM.cmake`.
4. **Press โถ๏ธ** to build and run the app.
### ๐ง Linux
1. **Clone the repository:**
```bash
> git clone https://github.com/Muppetsg2/Shapes-Generator.git
> cd Shapes-Generator
```
2. **Install CMake and a compiler** (if not installed):
```bash
> sudo apt install cmake g++ ninja-build
```
3. **Build the project**:
```bash
> cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
> cmake --build build
```
4. **Run the app**:
```bash
> ./build/bin/Shapes-Generator
```
### ๐ MacOS
1. **Clone the repository:**
```bash
> git clone https://github.com/Muppetsg2/Shapes-Generator.git
> cd Shapes-Generator
```
2. **Install dependencies (CMake, Ninja, compiler)** (if not installed):
```bash
> brew install cmake ninja
```
3. **Build the project with app bundle**:
```bash
> cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
> cmake --build build
```
4. **Run the app**:
```bash
> open build/bin/Shapes-Generator.app
```
## โถ๏ธ Usage
1. **Launch the program** - ASCII art and a menu will appear.
2. **Select a shape** by entering a number (1-10).
3. **Enter the required shape parameters**, if applicable.
4. **The shape is generated**.
5. **Select the file format** for saving.
6. **The file path** will be displayed in the console.
7. **Exit anytime** by pressing the **ESC** key.
## ๐งพ Configuration
The application allows you to configure the default output path and filename using the `shapes.config` file.
**Example contents** of `shapes.config`:
```bash
generateTangents: true
saveDir: C:\my\custom\output\
fileName: my_shape
```
- **generateTangents**: Tells the generator whether to compute and include tangent and bitangent \
vectors for each vertex (useful for normal mapping and advanced shading).
- **saveDir**: Sets the directory where shape files will be saved.
- **fileName**: Sets the base name of the output file (e.g., `my_shape.txt`, `my_shape.obj`).
> ๐ก If the config file is missing or malformed, defaults will be used.\
:information_source: The path will be different depending on your operating system. Here is an example of the path for Windows
## ๐ Example Output
When generating a **Sphere**, the output will look like this:
```mathematica
[OK] Start Generating Sphere...
[OK] Sphere Generated Successfully!
[INFO] Shape successfully generated in 4.51e-05s!
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[FILE] Select the save format:
1) std::vector - Vertices & Indices (struct)
2) C array - Vertices & Indices (struct)
3) std::vector - Only Vertices (struct)
4) C array - Only Vertices (struct)
5) std::vector - Vertices & Indices (float)
6) C array - Vertices & Indices (float)
7) std::vector - Only Vertices (float)
8) C array - Only Vertices (float)
9) Save as OBJ file
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Enter your choice (1 - 9): 1
[OK] Start Saving Sphere to file...
[SAVED] Shape saved successfully in 0.0013585s!
[PATH] File path: C:\my\custom\output\my_shape.txt
Press Enter to exit...
```
> :information_source: This example is shown on a Windows system. It may vary on other systems.
## ๐ Troubleshooting
โ **Issues? Try this:**
- Ensure **all dependencies** are installed.
- Check **console messages** for errors.
- Verify you're using **C++20** or later.
> :information_source: If you cannot see or understand the error, [open an issue](https://github.com/Muppetsg2/Shapes-Generator/issues).
## ๐จโ๐ป Authors
๐ **Marceli Antosik (Muppetsg2)**
## ๐ License
This project is **open-source** under the **MIT License**.
๐ **MIT License Overview:**
- โ
Free to use, modify, and distribute.
- โ
Can be used in **commercial** and **non-commercial** projects.
- โ Must include original license and copyright.
See the [LICENSE](./LICENSE) file for details.