• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    C++
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A procedural mesh generator for Godot build as a GDNative plugin

Procedural Mesh Generation GDNative module

This is my attempt at creating a procedural mesh generator for the Godot Game Engine.

example

The "normal" way of creating 3D assets for your game involves using modeling software such as Maya, Blender, 3DSMax or any of the other tools out there and for many of the assets you'll want to use in your game this is by far the prefered way of creating assets. There is however one limitation to using these types of software to create 3D assets and that is that they are essentially static. Yes you can animate them but if you create a 2 story house, you'll have to create a new asset if you wish to have a 3 story house.

This is the type of problem procedural modeling attempts to solve. Instead of focussing on an end result the goal is to tell the computer how an asset is to be constructed. This is best explained with a video: Timelapse - Procedural modeling in Godot

That video shows the construction of a simple rope bridge where the length and width can be adjusted and instead of the bridge getting stretched, as would happen if you scale the bridge, it actually adds ropes and boards.

You will need Godot 3.1 or later to run this module. A copy of the 64bit Windows DLL is included in the demo folder, use at your own risk.

Downloading and compiling

You will need a C++ compiler, python and scons installed on your machine, same build tools as Godot so see compiling. Instructions below have only been tested on Windows and the scons file may need tweaking on other platforms.

It is best to clone this repository from a terminal like so:

git clone --recursive https://github.com/BastiaanOlij/gdprocmesh.git
cd gdprocmesh

This project relies on godot_headers and godot-cpp which have been submoduled in this repository.

These dependencies will need to be compiled:

cd godot-cpp
scons platform=windows generate_bindings=yes
cd ..

(custom api is temporary as we needed a newer api file)

You can add -j<n> to this to speed up compiling, replace <n> with the number of cores your machine has.

Now we can compile our module:

scons platform=windows

Note that you may want to compile both godot-cpp and our module with the added switch target=release to create a release build.

Trying out the test project

After successful compilation the dynamic library should be placed in the addons folder of the example demo project. Again I've only configured things for windows so you may need to tweak the gdprocmesh.gdnlib file for other platforms.

Simply import the demo project into Godot and have fun.

If you want to use this for your own projects, simply copy the addons folder into your project and make sure that the plugin is turned on.

Now create a MeshInstance and create an ArrayMesh for this node. You can now drag the gdprocmesh.gdns file into the script property of the ArrayMesh. This will create a simple box as a starting template. Simply re-select the ArrayMesh in the property manager and you'll see that you're given a new graph editor.

Everything is an array

Well, almost everything. Most nodes are designed to take arrays as input and you can do some funky things with this.

For instance, on face value GDProcScale will scale an array of vertices. So your input is an array of vertices, you specify a vertex by which to scale this input, and your output results in an array of vertices that have been scaled according to the 2nd input. However the 2nd input can be an array too. Let's say you input 5 vertices with 3 scales: Vertice 1 will be scaled by the first scale Vertice 2 will be scaled by the second scale Vertice 3 will be scaled by the third scale Vertice 4 will be scaled by the first scale Vertice 5 will be scaled by the second scale So the scales are applied in order and it simply repeats the pattern until all vertices are scaled.

Many of the nodes work in this way where the different input arrays are combined to create the output.

Similarly primitives like the vector and euler nodes will output arrays if the input is an array of value.

Rotation

To rotate elements of your mesh there are various nodes that take a rotation as input. The current input options all center around euler angles but internally these are converted to quaternions. Due to lacking a quaternion array construct we're using a vec3 array and passing uniform quaternions around where w is assumed to be sqrt(1.0 - (x² + y² + z²)). It is then these quaternions that are passed from node to node. Additional nodes will be added in the near future that will allow you to construct rotations on other inputs like a rotation around an axis.

License

I've made the source in this repository available under an MIT license. If you find it useful, it would always be nice to get a mention.

The following 3rd party libraries are used:

We also make use of the algorithm explained here:

Note that for the demo:

Please visit these sites for further license details

About this repository

This repository was created by and is maintained by Bastiaan Olij a.k.a. Mux213

You can follow me on Twitter for regular updates.

Videos about my work with Godot can by found on my Youtube page

More Repositories

1

vehicle-demo

Godot VehicleBody demo project
GDScript
126
star
2

godot-sky-asset

New asset for rendering a panoramic sky texture based on rayleigh and mie scattering
GDScript
97
star
3

gdnative_cpp_example

GDNative C++ example for tutorial
Python
62
star
4

godot-terrain-edit

A GPU based terrain editor written in the Godot game engine
GDScript
49
star
5

shader_tutorial

WIP, shader tutorial I'm working on with some friends
GLSL
31
star
6

godot4_openxr_demo

Crappy test project to test Godot 4s OpenXR implementation with
GDScript
28
star
7

godot-worley-shader

Example of a shader that creates a worley noise texture and then uses that for some raymarching..
GDScript
28
star
8

godot-grass-tutorial

Example project related to my grass tutorial video
GLSL
25
star
9

godot-vr-weapons

Supporting project for my vr weapons tutorial
C++
21
star
10

godot_dungeon

My dungeon crawler experiment
GDScript
19
star
11

godot3_test_projects

Collection of test projects for Godot 3.0
GDScript
18
star
12

SimpleKinematicCharacter

A very basic kinematic character implemented in godot
GDScript
16
star
13

godot_camera_360

360 degree camera implementation
GDScript
15
star
14

skybox_to_panorama

Godot project that converts images from a skybox to a panorama
GDScript
15
star
15

godot_vr_climbing_demo

Godot VR Climbing demo
GDScript
13
star
16

godot-noise-texture-asset

Asset containing fast noise texture generators implemented as shaders
GDScript
13
star
17

gdvnc

Godot GDNative plugin implementing a VNC client
C
12
star
18

godot_background_loading

Example project for my background loading tutorial
GDScript
12
star
19

glfw-tutorial

Files for my little GLFW-tutorial series
C
11
star
20

gdpose

Plugin to make skeletons poseable in the editor
GDScript
9
star
21

gdtest

Nativescript 1.1 video introduction example
Python
8
star
22

vr-demo

VR demo project for youtube tutorials
GDScript
7
star
23

godot-object-interaction-vr

Support files for my Object Interaction VR tutorial series
GDScript
7
star
24

godot_physics_tutorial

Example project for my physics tutorial
GDScript
6
star
25

ARVRSimple

Reference implementation of an ARVR GDNative module for Godot
C
6
star
26

godot_multimesh_example

Example project for smoke and mirrors part 3
GDScript
6
star
27

gdleapmotion-asset

Compiled GDLeapmotion driver for the Godot Asset Library
GDScript
5
star
28

Trees

My implementation of the Space Colonization Algorithm
C++
5
star
29

godot_3dtv

Using the ARVR server implementation to implement support for 3D TVs and 3D monitors
C++
5
star
30

omnis.xcomp.framework

Framework classes for building Omnis Studio XCOMPs
C++
5
star
31

godot-xr-tools-tutorial

Godot XR Tools tutorial
GDScript
5
star
32

bcompiler

Copy of bcompiler with small fixes, origin: http://pecl.php.net/package/bcompiler
C
4
star
33

TestOpenVR

Testing OpenVR extensions to Godot
GDScript
3
star
34

godot_move_along_path

3D platformer where character moves along a loosely defined path
GDScript
3
star
35

StereoCameraTest

Godot project file to test stereoscopic rendering additions to Godot
GDScript
2
star
36

godot_test_passthrough

Godot 4 OpenXR Passthrough test project
GDScript
2
star
37

EurOmnis

Published files related to EurOmnis sessions I've given
PLpgSQL
1
star
38

LensDistortion

Example for applying a lens distortion shader in Godot for Mobile VR
GDScript
1
star
39

omnis_bezier_curve

Example of how to display a bezier curve by using a number of line objects strung together
1
star
40

omnis.xcomp.widget

Misc widgets and objects or Omnis Studio
C++
1
star
41

omnis.xcomp.bgwidgets

xcomp containing an assortment of background widgets
C++
1
star