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
- JSON for exporting in json format
- β¨ Features
- π¦ Dependencies
- βοΈ How to Build
βΆοΈ Usage- π§Ύ Configuration
- π Example Output
- π Troubleshooting
- π¨βπ» Authors
- π License
β Interactive User Input
- Configure shapes through console input.
- Choose from ten different shapes:
- π΄ Sphere
- π· IcoSphere
- β Plane
- π§ Cube
- π’ Cylinder
- β¬’ Hexagon
- π¦ Cone
- πΌ Tetrahedron
- πΊ Pyramid
- π© Torus
β
ESC Key Support: Press ESC anytime to exit the program.
β
File Output: Generated shapes are saved in shape.txt, shape.obj or shape.json for later use.
β
Error Handling: Provides feedback for invalid inputs and applies sensible defaults.
- C++20 or later
- CMake 3.26 or later
- GLM Library (OpenGL Mathematics)
- FMT Library (Formatted console output)
- JSON Library (Exporting in JSON format)
-
Clone the repository:
> git clone https://github.com/Muppetsg2/Shapes-Generator.git > cd Shapes-Generator
-
Open the folder in Visual Studio (supports CMake natively).
-
CMake will configure the project and download dependencies automatically via
CPM.cmake. -
Press
βΆοΈ to build and run the app.
-
Clone the repository:
> git clone https://github.com/Muppetsg2/Shapes-Generator.git > cd Shapes-Generator
-
Install CMake and a compiler (if not installed):
> sudo apt install cmake g++ ninja-build -
Build the project:
> cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release > cmake --build build
-
Run the app:
> ./build/bin/Shapes-Generator
-
Clone the repository:
> git clone https://github.com/Muppetsg2/Shapes-Generator.git > cd Shapes-Generator
-
Install dependencies (CMake, Ninja, compiler) (if not installed):
> brew install cmake ninja -
Build the project with app bundle:
> cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release > cmake --build build
-
Run the app:
> open build/bin/Shapes-Generator.app
- Launch the program - ASCII art and a menu will appear.
- Select a shape by entering a number (1-10).
- Enter the required shape parameters, if applicable.
- The shape is generated.
- Select the file format for saving.
- The file path will be displayed in the console.
- (Optionaly) File explorer will pop up with file location.
- Exit anytime by pressing the ESC key.
The application allows you to configure the default output path and filename using the shapes.config file.
Example contents of shapes.config:
generateTangents: true
calculateBitangents: true
tangentHandednessPositive: true
saveDir: C:\my\custom\output\
fileName: my_${TYPE}-%H-%M-%S
openDirOnSave: true- generateTangents: Tells the generator whether to compute and include tangent vectors for each vertex (useful for normal mapping and advanced shading).
If
calculateBitangentsis enabled, bitangent vectors will also be generated for each vertex. - calculateBitangents: Determines whether bitangent vectors should be calculated and included in the saved file.
- tangentHandednessPositive: Defines which handedness convention should be used when calculating bitangents or when saving tangents to the file.
- saveDir: Sets the directory where shape files will be saved.
- fileName: Defines the pattern for the output file name. You can use standard time format markers
compatible with the C++ function strftime, as well as a custom placeholder
${TYPE}, which will be replaced with the name of the generated 3D object (e.g.,"Cube","Cone","Sphere"). - openDirOnSave: If enabled, instructs the application to open the system file explorer at the location of the saved file after generation.
| Marker | Description | Example |
|---|---|---|
${TYPE} |
Name of the 3D object being generated | Sphere |
π‘ If the config file is missing or malformed, defaults will be used.
βΉοΈ The path will be different depending on your operating system. Here is an example of the path for Windows
β±οΈ List of all supported time marks you can find here
When generating a Sphere, the output will look like this:
[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 β Vertices only (struct)
4) C array β Vertices only (struct)
5) std::vector β Vertices & Indices (float)
6) C array β Vertices & Indices (float)
7) std::vector β Vertices only (float)
8) C array β Vertices only (float)
9) Export β JSON β Vertices & Indices
10) Export β JSON β Vertices only
11) Export β OBJ
ββββββββββββββββββββββββββββββββββββββββββββββββββ
Enter your choice (1 - 11): 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...βΉοΈ This example is shown on a Windows system. It may vary on other systems.
β Issues? Try this:
- Ensure all dependencies are installed.
- Check console messages for errors.
- Verify you're using C++20 or later.
βΉοΈ If you cannot see or understand the error, open an issue.
π Marceli Antosik (Muppetsg2)
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 file for details.