An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          


Logo




    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.