Skip to content

This project is a console-based (CLI) Shape Generator program written in C++. It allows the user to create and save a variety of 3D shapes.

License

Notifications You must be signed in to change notification settings

Muppetsg2/Shapes-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

73 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Logo

    Shapes Generator 1.4.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
  • JSON for exporting in json format

πŸ“‹ Table of Contents

✨ 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, shape.obj or shape.json for later use.
βœ… Error Handling: Provides feedback for invalid inputs and applies sensible defaults.

πŸ“¦ Dependencies

  • C++20 or later
  • CMake 3.26 or later
  • GLM Library (OpenGL Mathematics)
  • FMT Library (Formatted console output)
  • JSON Library (Exporting in JSON format)

βš™οΈ How to Build

πŸ–₯️ Windows

  1. Clone the repository:

    > 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:

    > git clone https://github.com/Muppetsg2/Shapes-Generator.git
    > cd Shapes-Generator
  2. Install CMake and a compiler (if not installed):

    > sudo apt install cmake g++ ninja-build
  3. Build the project:

    > cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
    > cmake --build build
  4. Run the app:

    > ./build/bin/Shapes-Generator

🍏 MacOS

  1. Clone the repository:

    > git clone https://github.com/Muppetsg2/Shapes-Generator.git
    > cd Shapes-Generator
  2. Install dependencies (CMake, Ninja, compiler) (if not installed):

    > brew install cmake ninja
  3. Build the project with app bundle:

    > cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
    > cmake --build build
  4. Run the app:

    > 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. (Optionaly) File explorer will pop up with file location.
  8. 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:

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 calculateBitangents is 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.

🧩 Custom markers

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

πŸ“œ Example Output

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.

πŸ›  Troubleshooting

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

πŸ‘¨β€πŸ’» 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 file for details.

About

This project is a console-based (CLI) Shape Generator program written in C++. It allows the user to create and save a variety of 3D shapes.

Topics

Resources

License

Stars

Watchers

Forks