A downloadable tool

Buy Now$1.99 USD or more

LOW POLY TREE GENERATOR

A tiny real-time tool for making procedural low poly trees. Tweak the sliders, watch the tree rebuild instantly, then export it as an OBJ file or as a block of C++ vertex data you can paste straight into your own OpenGL project. The complete source code is included in a single .cpp file.

FEATURES

- Fully procedural: no models or textures, every tree is generated from code

- Seed-based: the same seed always produces exactly the same tree

- Randomize button for endless variations

- Live regeneration whenever you change a parameter

- Flat shaded low poly look with a simple directional light

- Wireframe toggle to inspect the mesh

- Orbit camera with mouse wheel zoom

- Statistics window showing vertex count, triangle count, seed and FPS

CONTROLS (in the app)

- Trunk: height, radius, number of sides

- Leaves: size, height position, color

- Style: vertex jitter amount, low poly strength

- Randomization: seed value and a Randomize button

- Display: wireframe on/off

CAMERA

- Left mouse drag: orbit around the tree

- Mouse wheel: zoom in and out

EXPORT

- Export OBJ: writes a Wavefront .obj with flat face normals and vertex colors
(vertex colors use the common "v x y z r g b" extension, which Blender and MeshLab read)

- Export Vertex Text: writes a .txt containing a C++ float array

- Copy Vertex Text: copies that same array to your clipboard

USING THE C++ VERTEX DATA

The exported text is a non-indexed GL_TRIANGLES array with 9 floats per vertex:

position (x, y, z), face normal (x, y, z), color (r, g, b).

A usage comment with the glVertexAttribPointer setup and draw call is included at the top of the export, so you can paste it into your project and draw it.

SOURCE CODE

The whole application is one C++17 file: LowPolyTreeGenerator.cpp. It is organized into sections (Shader Utilities, Camera, Mesh Structures, Tree Generation, Rendering, Export, ImGui, Main) and heavily commented, so it works as a readable example of procedural mesh generation and flat shading in OpenGL 3.3 core. Shaders are embedded as raw string literals and all geometry is generated in code.

BUILDING FROM SOURCE

You need:

- A C++17 compiler

- GLFW 3

- GLAD (generated for OpenGL 3.3 Core)

- Dear ImGui (imgui.cpp, imgui_draw.cpp, imgui_tables.cpp, imgui_widgets.cpp, plus backends/imgui_impl_glfw.cpp and backends/imgui_impl_opengl3.cpp)

- GLM (header only)

Compile LowPolyTreeGenerator.cpp together with glad.c and the ImGui source files, add the include paths for all of them, and link against GLFW (plus OpenGL on Windows, or -ldl on Linux).

Example (Linux, adjust the paths to your setup):

g++ -std=c++17 LowPolyTreeGenerator.cpp glad/src/glad.c imgui/imgui*.cpp imgui/backends/imgui_impl_glfw.cpp imgui/backends/imgui_impl_opengl3.cpp -Iglad/include -Iimgui -Iimgui/backends -lglfw -ldl -o LowPolyTreeGenerator

LICENSE

[Insert your chosen license here, see the notes below.]

NOTES

- Exported files are saved in the folder the program was launched from.

- Requires a GPU/driver with OpenGL 3.3 support.

Made with C++17, OpenGL 3.3 Core, GLFW, GLAD, Dear ImGui and GLM.

Published 5 days ago
StatusIn development
CategoryTool
Authorprogrammer_jeff
Tags3D, Generator, low, opengl, proced, sour, tool, trees
AI DisclosureAI Assisted, Code, Graphics, Text

Purchase

Buy Now$1.99 USD or more

In order to download this tool you must purchase it at or above the minimum price of $1.99 USD. You will get access to the following files:

LowPolyTreeGenerator.zip 280 kB

Leave a comment

Log in with itch.io to leave a comment.