• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Graphics Blender to GameMaker Exporter

Bart

WiseBart
Blender to GameMaker:Studio Exporter (current release v1.0.10)
Note to the moderators viewing this topic: I spoke with @Nocturne about this and got approval to put it here

Introduction

After quite a few years I am happy to announce the updated version of my Blender exporter add-on that I posted on the old forums. (yeah, it's been a while)
The exporter now works with Blender 2.8 and also has a compatibility version for Blender versions below 2.8 (currently not entirely up-to-date).

This add-on is entirely free to use and I hope it can make life quite a bit easier for anyone who wants to use 3D models from Blender in GameMaker.
At least that's the goal I had when I started developing this for my own use a couple of years ago.

The add-on itself does not come with any code for GameMaker but I'm going to make an extensive example project to show a couple of interesting vertex formats from basic to advanced (passthrough, basic vertex formats, static batches, dynamic batches, morph animations, "tiny" vertex formats, texture atlas/group, ...)
I'm also planning to add documentation to the wiki, although this will be more focused on the Blender side.

Features
  • Highly customizable vertex format: many properties can be added, including tangents, bitangents, all types of normals (vertex, loop and face), vertex group indices, vertex weights, ...
  • Choose the format to write to the buffer and optionally execute a "pre-processing" function to modify the value that's being written.
  • Write interpolated values for attributes up to 1 frame back in time (this could be increased, but it takes a lot of memory) - for e.g. morph animations
  • Presets so you don't have to do that configuration all over again
  • Hopefully a few more in the not too distant future, see the issues list for more info

Importing in GameMaker

The exporter generates a .vbx file that contains the (vertex) buffer data and a .json file with some additional info on the data.
Both are optional, so you can choose to export vertex buffer data and/or metadata.

The code to import from a file is the following:
GML:
var buffer = buffer_load("vertex_data.vbx");
vertex_buffer = vertex_create_buffer_from_buffer(buffer, vertex_format);
vertex_freeze(vertex_buffer);
You can define the vertex format yourself in gml if you know what format you used to export from Blender.
A description of the vertex format is also added to the .json file.
I currently don't have "standard" gml code to read it. That may get added later.

Example Project

Blender Exporter Examples YYZ

This is an early work in progress. More examples will be added when I find the time.

(To open the .blend file straight from the IDE, right-click and select Open Externally)

Setup

This is described in the wiki, see Installation.

In the end, it should look like this:



Introduction to defining vertex formats

The main feature of this add-on is the ability to define custom vertex formats.
Since these are quite customizable this can easily get pretty complex.
Because of that, here's a short introduction to this:

The vertex format that the exporter uses is defined under Mesh Data:



The leftmost dropdown allows you to select the source for the data. This can be the vertex, the face, the material, the uv or another property in the list.
The one next to it contains the properties at that source and is updated dynamically. Some types of properties are filtered out, such as strings and enums.
For example, Mesh Vertex contains the following properties:



The next two inputs may not be obvious at first sight.
Fmt defines the format to be written for this property, the full list for that can be found under Format Characters in the Python docs.
When you select the property to be used in the second column this will automatically be updated based on the metadata in Blender.
When one or more asterisks * are shown it means the add-on doesn't know what type to make of it.

You can override this suggestion by replacing it with your own format string.
In practice, you'll probably use one of these:
  • f: a single 32 bit float
  • i: a single signed int (32 bit)
  • ?: a boolean as a byte (perhaps the most confusing one)
The dropdown to the right of the format, Func, allows you to select a "pre-processing" function before the value is converted to binary format.

In the end, basically, per property/per line of the vertex format, the exporter does this:

Get value of property > Pre-processing function if not None > Conversion to format

A couple of functions are provided already but you can add your own to the file conversions.py in the add-on's directory.

The Int input can be changed from 0 to 1 and is the number of frames to go back when exporting multiple frames. It basically means "take the value of this property at index [frame-i]" and allows for interpolation of properties for e.g. morph animations.

Known bugs/Issues/Improvements/Feedback

These can be found under Issues in the repository on GitHub.

If you encounter any bugs, feel free to let me know here or add an issue to the list.

Also any other feedback on this add-on is more than welcome!
 
Last edited:

Bart

WiseBart
Updated the add-on to version 1.0.3 which has a couple of important bugfixes and useability improvements:
  • Vertex colors are now actually included (they could be selected but weren't written)
  • Selection is properly filtered
  • Sequences are now truncated to the length of the format string. So this means you can now e.g. create 2D (x, y) values from a 3D (x, y, z) by simply changing the format from 'fff' to 'ff'. No need to write a custom function for this.
  • Passthrough preset now has reverse looping through triangle indices set by default, since in GM you'll probably invert y. Also, texture uv's v is inverted (1-v).
  • A couple of important bugfixes
The example project is now also up! (currently no GMS 2.3 yet)
It contains the first very basic examples that show how to define and import a variety of vertex formats for static models, including very basic shaders showing how to work with them and the exporter presets used to export them.
 

Bart

WiseBart
Hi! Thanks for trying out the addon.
For some reason I can't open the attachment you posted so can't have a further look at it at the moment.
Could you post it again? Then I'll check to see what's wrong.
 

rayloi

Member
Hi! Thanks for trying out the addon.
For some reason I can't open the attachment you posted so can't have a further look at it at the moment.
Could you post it again? Then I'll check to see what's wrong.
"scripts\addons\blender-gms-vtx-buffer-1.0.4 " not work

rename to" scripts\addons\blender-gms-vtx-buffer "is work

i fixed ;)
 

Attachments

Bart

WiseBart
Ah, alright, nice! But that's an odd one. It shouldn't require fixing in the first place :)
How did you install the add-on? From the zip file?
 

Bart

WiseBart
Ah, you found that one, too :)
The Blender to SMF is a work in progress, animations aren't working properly yet. I'm still looking into that.
But the code is public already so anyone who wants to can use it.
 

Bart

WiseBart
It's on hold at the moment but I plan to resume work on it soon.
The main difficulty with that export are all the coordinate system conversions that need to happen when going from Blender to SMF.
Still waiting for the 'Eureka' moment there.

I can definitely add an animation example to the current example project.
I'll see if I can get it done soon.
 

Bart

WiseBart
Fixed a bug with the triangulation that caused the vertices of triangles in morph animations to jump from one position to another between frames.
The current version of the add-on with this bug fixed is now version 1.0.5.

I also updated the example project with two new examples: dynamic batching and morph animations.
The example project also comes with new presets for the exporter. These can be used as a basis for similar exports (tinier vertex formats, added normals, tangents, bitangents, ...).
 
Last edited:

Bart

WiseBart
Blender Rigid Body Exporter and Import Scripts for GM:Studio

Introduction

This Blender add-on exports a 2D representation of the current scene's rigid body world to a file, including simulation settings and fixtures and joints.
The import scripts for GameMaker:Studio allow you to read the contents of the file and create a Box2D physics world out of them.
While this obviously doesn't provide true 3D collisions to agame it can work for those many cases where a 2D representation of the game world is enough.

I mainly wrote these scripts for my own convenience but since they could be of use to everyone I decided to also share them here.
A couple more scripts will get added at one point to provide easy access to other functionality, such as joints.

Setup

This is identical to the setup of the model exporter.

Usage

Using the import scripts you can access a file's contents like this:
GML:
map_data = brb_open("physics_rbworld.phy");
lst_objects = brb_objects(map_data);
map_obj_data = lst_objects[| 0];
body = brb_get_body(map_obj_data, 0, 1);
brb_close(map_data);
brb_bind_body(body, id);
brb_delete_body(body);
The current documentation for the Blender add-on can be found in the wiki.

Feel free to use these scripts and build your own version of them.
(Tiny) feature requests may get added, though no guarantees on that.
Also, suggestions and feedback are more than welcome!
 
Last edited:

Bart

WiseBart
Updated the Vertex Buffer Exporter to version 1.0.6 because of a required bugfix.

Starting with this release you also no longer need to install directly from the zipped source code.
This could cause issues when installing from a release (not from master) because of GitHub's version naming and the way Blender installs its plugins.

From now on there are two files provided for the Blender add-on:
  • blender-gms-vtx-buffer.zip - The add-on zip package which can be installed directly in Blender using Add-ons > Install... under Preferences
  • presets.zip - The package with export presets for the add-on, currently only passthrough
 

Bart

WiseBart
Last week I finally updated the original Blender Vertex Buffer Exporter to a new version. This latest version is now version 1.0.10.

It comes with a couple of useability updates, mostly minor things that I discovered when using the exporter for jams. These are:
  • Switched to panels instead of including all draw code in the __init__.py file
  • Different default export settings: General, Mesh Data and Transforms panels open by default
  • Mesh-like types can now be exported (text, meta-ball, etc.)
  • No file extension is added anymore in the file selection window and the file filter is now set to include both "*.vbx" and "*.json"
  • A custom file extension can now be set in case you want to use one, e.g. ".bin", ".dat", ".buf", etc.
This will probably be the latest update of this Blender exporter as it is in need of a substantial update or - more likely - a major rewrite.
 
Top