Asset - Graphics [3D] MMK - Blender->GameMaker, fully animated 3D models, scenes and more

mMcFab

Member


Marketplace: https://marketplace.yoyogames.com/assets/7014/beta-mmk-animated-blender2gm
Price: $179.99 introductory price which will increase to $299.99 later (Price may increase as updates come out)​

Available on itch.io, with an extra demo and alternate price!

Basic Setup and Usage (Video)

Video Demos

A full test in a 3D platformer implementation [latest video]: https://cartrdge.com/maddemichael/2018-big-gif-a-showcase-of-some-fancier-3d-stuff-i-ve-done

A test in a networked 3D game - features binding other meshes to bones and multi-mesh armatures, as well as a familiar looking rocketship: https://cartrdge.com/maddemichael/3rd-person-version-of-the-client-server-test
System used in this heat distortion demo: https://cartrdge.com/maddemichael/2018-heat-distortion-effect-bubbles-too
A slightly improved early demo: https://cartrdge.com/maddemichael/cancelled-model-converter-for-gamemaker-gui
Incredibly early test from when it first worked: https://cartrdge.com/maddemichael/3d-anim-lerp-in-gamemaker

(yep, all of these are GameMaker! And they're gone because Cartrdge is gone. Now I'm sad. A good reminder to self-host, I suppose)
MMK_promo1.png
I'll probably add more screenshots and gifs soon.

Quick Function Reference
THIS IS NOW IN THE NOTES INCLUDED WITH THE EXTENSION!!
[/code]

Bugs? Questions? Suggestions? Reply to this post and I'll see what I can do!

CHANGELOG (v0.4.0)
  • Collisions.
    • Uses an octree system to keep stuff fast
    • Includes an export script for Blender
    • Has support for ellipse and ray collisions. Also includes the ability to "cast" an ellipse in a direction
    • Includes a super simple movement function to make it very easy to set up
  • Functions to enable the use of "Pose Caching" - MMK_armature_set_matrix_output_array()
  • MMK_animation_get_framecount(anim, adjust_for_gamespeed)
  • Fixed another axis-angle issue (when not using native)
  • When using native mode, a check is done GML-side to determine if an armature update is needed now. This was already done within the extension, but the call overhead was still apparantly eating up speed in YYC. Has little impact generally, but yields a very nice performance boost (I got a ~20% boost in the test project) for YYC when an armature hasn't changed pose and/or when using pose caching. (No real impact on VM at all though)
  • A few fixes and additions relating to armature transforms.
  • Fixe an export crash for when tangent export is active but the current mesh has no active UV map (zero values are added instead for now)
  • Added an export option to automatically export armatures linked with the current selection. Enabled by default.
  • Optimised a bunch of native code, fixed a different axis-angle issue within the DLL
  • Initial itch.io release! Yay!
  • New mascot and demo!
  • Added new export scripts for Blender 2.8
  • Added better armature-mesh linking to the 2.8 export script, so now they don't need to have parent-child relationships, just the modifier.
  • Extended the material system so now materials can manage GPU states individually and be ignored during certain render passes (the macro "MMK_auto_handle_gpu_resets" in MMK_models can be set to 0 to disable this). This allows materials to control whether or now they write to the zbuffer, for example. Note that global GPU states are still maintained, only those set will change.
  • Fixed bugs with the material system not always being called when there is no shader change, causing visual defects in some cases
  • Defined some undefined behaviour regarding passing bones to a shader
  • Fixed a crash with "MMK_bone_get_transform" (forgot to comment out an unused argument)
  • Added and improved armature mesh setting options, so now order can be better defined, as well as the option to check what meshes are enabled
  • Added "MMK_armature_add_meshes" and "MMK_armature_set_meshes", which accept both individual meshes and mesh arrays, to streamline adding many meshes to an armature. Note that meshes are appended and set in order.
  • Fixed default armature textures and materials not always being used as a fallback in cases where they should have
  • Added the option to pass custom UVs to armature textures, in case you need custom ones. This can also be useful if you change a texture frequently, as it removes automatic uv_clipspace calculations.
  • Made negative or < frame_1 animation setting use the first frame, which fixed an issue I believe was related to a floating point error preventing me from setting frame 0 of my test characters idle animation.
  • Added some "advanced" output-matrix fetching functions, but I implemented them for reasons that don't work because I forgot, but they may be useful down the line.
  • Default shaders now use blendweights and blendindices for GLSL ES as well, due to changes in how GameMaker passes inputs to attributes. I believe now names matter less, but the order of attributes is incredibly important
  • Native/GML code parity maintained.
Older versions
v0.3.3 Scene Update
  • A tiny fix for pointlights in the diffuse shader
  • Object animations now seem to be correct for both right-handed and left-handed export (note that, for consistency with appearance in Blender, Apply Transforms must be disabled or the targets anchor point should be at O) [This is an update to the export script only]
  • Right-Handed euler rotations for bones have been tweaked. Now they seem correct [This is an update to the export script only]
  • Axis-Angle rotations remain untested
  • MMK_JsonSceneExporter - A GameMaker-compatible JSON scene exporter for Blender, giving it the capability of being a level editor for GameMaker. Exports useful data like object transforms, names, types, and a lot of specific data for things like lights, cameras and more. (You may want to encode the output if you don't want people meddling with your scenes though)
  • MMK_load_scene(file) - Used to load the new JSON scenes. Returns scene index. Remove scenes you're done with using ds_map_destroy()
  • MMK_scene_generate_lighting(scene) - Resets and loads in lighting from the scene into GameMaker's built-in lighting system
  • MMK_scene_generate_instances(map, ob_map) - Generate instances based on the "base_name" of an object in a scene (the name before the first dot - so "Object.003" would be just "Object") - and ob_map is a ds_map of base names to instance IDs. Basic for now, but still useful
  • MMK_object_create_defaults() - Generate default variables used by 3D objects loaded by scenes
  • MMK_matrix_object_local - A macro for generating a matrix for the current object using variables created from MMK_object_create_defaults() or from MMK_scene_generate_instances(), assuming rotations are YXZ
  • MMK_matrix_object_world - A macro for generating a matrix fot the current object, with respect for transforms inherited from parents. This does weirdness if "Export Transforms as Local" is disabled (though I think I can fix this)
  • MMK_object_get_world_matrix(instance) - A function that does the same thing as the above macro, but allows targeting a specific instance.
  • MMK_scene_get_main_camera(scene)
  • MMK_scene_camera_get_lookat(scene_cam)
  • MMK_scene_camera_get_proj(scene_cam, view_index)
  • MMK_is_drawing_armature - a macro that returns true if an armature is currently being drawn. Useful for materials that can work with and without armatures.
  • MMK_current_armature - a macro that stores the current armature being drawn (only valid in materials - check "MMK_is_drawing_armature" first)
  • MMK_current_vbuffer - a macro that stores the ID of the current vbuffer being rendered by the armature (only valid in armature materials)
  • MMK_current_bonedata - a macro that stores an array of bonedata normally automatically passed to the shader (only valid in armature materials)
  • MMK_material_full_update - a macro which replaces the old argument to make non-armature materials easier to work with. Included materials have been updated to reflect this change. This defaults to "true" outside of armature drawing to make static-compatible materials simpler to produce
  • The macros are NOT read-only, but if you change them, please remember to reset them after you need them with MMK_reset_model_macros();
  • MMK_matrix_inverse() and MMK_matrix_transpose() - Added until YYG add native versions, useful for materials that need to generate a normal-matrix
  • Renamed python scripts and put them in a group. Also stopped them being included in export by default
  • Updated the function reference in the notes.
  • Moved blend-info to the end of meshes to make them more compatible with other shaders
  • MMK_begin_3D() - A super simple function that just sets up basic 3D state stuff.
  • Material script arguments have been updated for single argument materials - they are now passed directly instead of in an array.
  • Added a new demo material: MMK_material_outline_unlit(outline_size). A simple unlit shader that uses vertex-based outlining using normals. This is primarily to demo the new macros
  • Also added "MMK_material_outline_diffuse(outline_size)", which is functionally the same as the above material, but uses diffuse lighting. Also shows how materials can be combined in certain cases.

  • It is likely I'll add more scene functions in the future, including 3D path generation

v0.2.3 Micro-Patch
  • Tweaked the export script to allow appending ".MaterialName" to even single material meshes to make dynamic material assignment consistently possible. An option to disable this behaviour has also been added
v0.2.1
  • Fixed a nativemode bug with updating child bones when they were not changed directly
  • Added MMK_armature_bone_get_inverse_bind_matrix(arm, boneID)
  • Added MMK_armature_get_matrix_output_array(arm)
  • Added MMK_armature_bone_inherit_parent_transform(armature, bone, enable) - this makes the target bone and all children use the same matrix as the first bones parent. This is primarily for animation LODs as it saves time calculating and updating matrices, but does stop the results of MMK_armature_bone_get_matrix for this bone and its descendants from updating correctly until transform inheritance is disabled again. This cannot be applied to root bones.
  • Added MMK_armature_bone_get_child_ids(arm, boneID) - returns either -1 if a bone has no children, otherwise, an array of child IDs.
  • Added MMK_armature_bone_get_parent_id(arm, boneID)
  • Added the quick function reference to the "Notes" of the extension
  • Fix for importing models with trailing empty data in the buffer. Now shows an error in the console and stops reading any additional data. This was not a problem if you loaded the file directly. Models using the old version of the script need to be re-exported.
  • Tweaked the export script to add a terminating value to the end of the data block to reduce the risk of the above error message being shown when not necessary. Also adjusted read values in general for a little bit of extra safety
  • Tidied up the export options and labelling - MMK mode is default now, redundant or incompatible options are hidden and handy labels are shown with info about the export
  • The export script is now capable of exporting material indices for both Static and MMK mode. Cool! This is either added as a 3rd entry to texcoord if UVs are exported, otherwise it's added as a single float texcoord to the end of the vertex format (after tangent data).
  • The exporter has the option to split meshes by material when in MMK mode. ".MaterialName" is appended to the split mesh names - this disables the option of exporting material indices as vertex data as it would be redundant
  • The importer and exporter handle missing or empty meshes better and their assosiation with armatures
  • Added a simple fragment-shader diffuse material that uses the built-in lighting system (MMK_material_diffuse). A blinn-phong variant will be added soon™
  • Added safety to MMK_armature_draw just in case the shader a material uses changes within the same draw call.
v0.2.0
  • Added native support for Windows, yielding performance boosts of up to 125%
  • Fixed a bug that meant axis-angle animation keyframes were never applied.
  • Tweaked the way initial keyframes are handled when animations are blended but only apply to certain bones each.
  • Added a template material script (MMK_demo_material - uses the default shader but just provides a base to build from)
v0.1.3
  • Initial release

UPCOMING (v0.?.X)
  • Morph Targets/Blend Shapes
  • Multiple UV maps per mesh
  • Platformer Demo

What is MaddeModelKit?

MaddeModelKit (or MMK for short) is my personal animation system that allows me to export fully animated and rigged models from Blender and load them directly into GameMaker Studio 2. Because apparently I missed the memo that GMS2 is a 2D game engine :p

It supports multiple animations, meshes and armatures in a single file, with keyframe interpolation and even the option to blend between multiple animations to smooth transitions.
I posted a few screenshots over the last few years and it gained a little bit of interest, so I figured I'd tidy it up, optimise and release it!

If you want to get into 3D with GMS2 but aren't sure where to get started, check out my guide on that (Demo Project Included): https://forum.yoyogames.com/index.p...arted-with-3d-in-gms2-project-download.12145/

I also have a free static model export script available too (Now with Tangent Support!): https://marketplace.yoyogames.com/assets/5839/export-3d-blendertogm

Main Features
  • No interim converter programs - just export the model and use it! This makes iteration and testing very simple and fast
  • About as cross-platform as GameMaker itself
  • Very simple to use - you can set up and animate a model within about 10 minutes! (As seen in the setup guide)
  • Names used in the system are the same as those used in Blender to make it easy to get the right information.
  • Exports animations from actions made in Blender - both armature and object animations supported!
  • Animations and meshes can be applied from separate model files
  • Support for location, scale and rotation (quaternion, YXZ euler and axis-angle) keyframes
  • Blender Export supports: Position, Normals, Colors, UVs, Tangents/Bitangents (or binormals, depending on who you ask), Blend Weights/Indices and material indices (It can also split meshes by material)
  • A fairly simple material system using scripts+shader combos, which can be assigned to armature instances
  • Default shaders to drive the models - they even include a UV correction system so you can use any sprite straight away (No separate texture page required!)
  • A scene exporter to enable using Blender as a level editor
  • A native extension to speed up animation of armatures on certain platforms
  • All functions and globals are prepended with MMK_ to reduce risk of name collisions
  • You can manually assign or add extra transforms to bones to allow cool effects suchas making a character look towards a target dynamically. This has minimal cost due to how the system works internally
  • I've tested it working on Windows, Mac, iOS and Android, both VM and YYC. Unfortunately, HTML5 isn't working quite right (see bug: https://bugs.yoyogames.com/view.php?id=28850) UPDATE: GameMaker Bug is fixed, but HTML5 is still bad and I haven't got it working yet.
Why BETA?
Although the system is technically feature-complete (It does everything I need it to), there's room for improvement and, like all things, probably has a bunch of bugs I just haven't noticed. It also gives me a good reason to actually get the system finished.
There's also a few other features I might like to add, but I'm not sure yet.

Included Stuff
  • Shaders
    • MMK_ES_skin/MMK_HLSL_skin - a pair of base shaders that skin and texture a model. Use these as a base for custom materials. MMK_ES_skin is required as the system uses it as a default fallback
    • MMK_ES_skin_diffuse_PS - A pixel-shader diffuse shader used by the material
    • MMK_ES_skin_outline - A shader that displaces vertices by their normals and makes the colour black. May be updated to allow colour choosing.
  • Scripts
    • MMK_demo_material - A simple demo material to use as a base for custom materials
    • MMK_material_diffuse - A simple pixel-shader bsaed diffuse lighting material using GameMaker's built-in lighting system
    • MMK_material_outline_unlit(outline_size) - A simple outine material
    • MMK_material_outline_diffuse(outline_size) - A simple outine material that uses simple diffuse lighting
  • Extensions
    • MaddeModelKit - Contains all the GML and Native functions needed to run the system
  • Included FIles
    • MMK_AdvancedModelExport_VX_X_X.py - Install this into Blender to enable export of animated ".mmod" files
    • MMK_JsonSceneExporte_vXXX.py - Install this into Blender to enable the export of JSON scene files.
  • Notes
    • A quick function reference
Materials
I decided to add a kind of "material" system to make the assigning and updating of shaders per mesh much simpler. It's not quite the same as a material you'd see in Unreal or Unity as it uses a GML script-Shader combo, but it's still pretty useful.
I encourage users of MMK to make compatible custom materials and shaders and share them! The more of them available, the more accessible MMK becomes to other GameMaker users. You're free to use the included demo shaders and material scripts as a base.
As of 0.4.X, materials can even manage GPU states and skip rendering completely, making them much more powerful.
I plan to release a few compatible material packs as MMK nears completion myself.

If you have made a compatible material, let me know as I want to link to it via a list that will be here.

Possible Upcoming stuff
Short Version:
  • v0.3.X - The Scene Update Done
  • v0.4.X - The Collision Update
  • v0.5.X - The Particle Update - I'm conflicted here. I made a system that works, but theSnidr's looks way better, so I might skip it.
  • v0.6.X - The Skybox Integration (small, but handy)
  • v0.7.X - To-Be-Determined, but I'm sure there's something...
  • v0.8.X - A bunch of bug fixes and safety probably
  • v0.9.X - The Full Native Update - Finally integrate native-mode on all viable platforms
  • v1.0.X - At this point, the system will likely be complete. New updates are optional, but still a possibility
3D path tools will be added at some point, just not sure when in the timeline.

More Detailed Version
  • Full written documentation and function reference.
  • Video tutorials and a simple "Making a 3D game in GMS2 with MMK" series
  • Bugfixes galore.
  • Native Extensions for: OSX, Linux, Android, iOS
  • A kind of blendshape generator (this won't be a main feature, but a nice extra if it works)
  • Per-keyframe interpolation modes instead of global - this is gonna take a bit of a rework of the GML code (less so of the native stuff) so it might be a while. UPDATE: The sheer amount of logic and edge cases this presents means it isn't really feasible for me to do right now. Luckily, baking keyframes pretty much solves this anyway.
  • debug_mode only safety checks - to help save time checking stuff in release mode, but help you identify crashes otherwise. This is more important for Native mode as it may crash without a useful message if an invalid index is passed anywhere.
  • Possibly an implementation of dual quaternion skinning on a per-armature-instance basis, which would potentially improve performance and increase bone-count cap by about 33% as well as reduce skin-collapsing artifacts, but at the cost of no scaling or axis/euler rotations. This would generally be better suited to organic-looking models (like humanoids and dogs)
  • Try to get armatures working in HTML5. Get YYG to fix that shader bug...
  • Update the GML code to use "structs" when they are added to GML to tidy up the code.
  • (Depending on how the future IDE plugins work) A visual material editor to make materials more accessible, an in-IDE model previewer, do that thing Unity does and automatically convert ".blend" files if added to the project.
  • Add the option to add material index to texcoord info via the exporter Done for v0.2.1
  • Allow the exporter to split meshes up by material Done for v0.2.1
  • Add a way to make the children of a bone use the same transform as the parent - reduces update and animation time and effectively produces a way to make skeleton LODs at runtime Done for v0.2.1! Turns out the performance boost is noticeable in both GML and Native.
  • Add more default materials! Blinn-phong, cubemap reflections, etc. They are already made, but just need tidying for the public system.
  • Integrate my shader-driven 3D particle system, port the optional z-sorting to native
  • Add some more screenshots to this post :p
  • Export light layouts for points and suns Done for the scene exporter
  • Export camera information Done for the scene exporter
  • Maybe add spot lights as part of the system?
  • Include MMK_Skybox as part of the Kit
  • Add export support for Blender's Curves as well as a system to get a position along the curve - integrating into scene exporter - Curves could be used to move cameras - how handy! Export completed for scene exporter
  • Optimise and integrate the collision system and mesh exporter Done for v0.4
  • Port collisions to native code and see if we get a performance boost (Spoiler: we should!)
  • Create the object data exporter Done
  • Create a room generator and other convenience systems that use the JSON scene exporter Done!
  • Make some kind of wrapper for Bullet Physics, perhaps. This may be a long-term sort of thing (beyond v1.0) that may never even happen. I'd include a way to automatically turn an armature instance into a ragdoll.
  • I guess turn this into a full-3D engine, not just an animation driver
  • Make a demo platformer project once everything else is done to showcase the system
  • Some kind of a basic implementation of inverse kinematics for armatures (probably allows specification of target bone, chain length, armature-space target position, twistangle, twistroot/cumulitive?)
  • Instance to instance 3D collisions
  • Potentially more collision shapes (currently there is only ellipse and ray)

Current Limitations
Due to shader limitations, the maximum number of bones for a cross-platform model is around 64 (66 was the max I got working in an ES shader). Shaders with many other uniform variables will have a lower cap. You may be allowed more bones in HLSL11 shaders, depending on the shader model GameMaker decides to use, but this may result in compatibility issues with older graphics cards.
Based on the shader limits (and the size of a byte), there is also a hard limit of 256 bones per armature. This many bones would likely be bad for performance anyway.

If you need more bones, you could likely break an armature and assosiated meshes up in Blender.
Disabling bone transform inheritance in Blender is not currently supported by the system and can produce odd results if not accounted for.

HTML5 is kinda broken. Models load and meshes can be drawn, but armatures do not animate or render properly. One reason is this GameMaker bug with submitting uniform arrays: https://bugs.yoyogames.com/view.php?id=28850 but some matrices are filled with NaN too, which is a problem either with GM or somewhere in my code.

You MUST check if shaders are supported by the current device if using armatures, as they are shader driven. I could add CPU-side skinning, but it would likely be too slow to be worthwhile, especially for devices that don't have a GPU anyway.

For models imported without the "hlsl" import option, UVs, Tangent data and Blendweight/indices are all stored as Texcoords - which means you have to be careful with your materials! When imported with the "hlsl" option, data is stored with the valid semantics which makes this a non-issue, but the models are then only compatible with HLSL shaders until YYG add the other attribute types to GLSL ES

Native Extension
The native extension passes armature animation and updating - the most intensive part of the system - to a C++ extension to help boost performance. The code is an optimised port of the GML code and the results should always be the same (if not, it's a bug).

This has the advantage of animating models more quickly, but does have a small cost - an increase in memory usage occurs as animation and armature instance data is stored in both the extension and in GML. Model loading and armature instantiation times are slightly increased too as data is copied over to the extension at these times.

Personally, I believe the small memory and initialization time cost is worth it for the overall speed gain.
In the demo project from the video guide, I gained an average rfps increase of 124% in VM and a 23% increase in YYC by using the native version.
In one practical project, I gained an FPS increase of around 20% in VM and a gain of 10% in YYC whe using Native vs GML.
These improvements are likely to have more of an important impact if you have complex armatures or many armature instances updating simultaniously.

If, however, you do wish to disable the native extension, simply call "MMK_disable_nativemode()". This should be called before any model loading, otherwise it will likely leave "dead" inaccessible memory in the extension.
Note that native mode cannot be re-enabled during the same run due to the nature of how the data is copied.
Given the lack of reason to disable native mode, it's likely the option to disable it will be removed. If this happens, I can remove the additional memory cost by only storing the data in the extension, instead of having duplicate data.

Current Native Targets
Windows .DLL (Which likely also works with UWP and Xbox One, but I cannot test these platforms. If it doesn't work, it should automatically fall back to GML)
Hopefully Upcoming Native Targets: Mac, Linux, Android, iOS

Tips to Improve Performance
  • Armature animation is potentially slow. This is actually true for pretty much all games and engines. What's important is how you optimise when and how animation are done. Here a some tips to try to improve performance in your game:
  • Pool armature instances where possible instead of creating a new one for every object. Reduces initialization time and memory allocations.
  • If drawing many armatures in a dense area, consider using only a few armature instances and just reposition and reskin them per mesh to reduce animation calculations. This is good for crowds, for example.
  • Only animate armatures that are within the view frustum
  • Only animate armatures close enough to the camera to have a real, visible effect. You can also opt to only animate an armature once every few frames, depending on how close it is to the camera. This means you can still animate far away stuff at a lower cost.
  • Use the native extension! There are no limitations to using it compared to GML mode and it gives a great speed boost.
  • Use YYC! Whether you use the native extension or not, some of the code must be run within the GML side. YYC speeds up the rest of this, keeping FPS much higher.
  • If using frame skipping techniques, only apply animations during visible frames. This may be undesirable if you use current bone transforms for certain events (e.g., calculating the position of a gun barrel)
  • When animating, use fewer keyframes and only assign types you need within Blender! While baking animations and setting all keyframe types gives a more consistent result, it makes the system spend more time calculating frames. Fewer keyframes and keytypes means faster calculation
  • Use armature LODs! For example, if not animating hands right now, use an armature without finger bones and a mesh with a static pose. Even idle bones add to the cost of updating an armature. You can achieve a similar effect and performance gain using the new "MMK_armature_bone_inherit_parent_transform" function
  • Use "Pose Caching" where possible - by making use of "MMK_armature_set/get_matrix_output_array(armature, matrix)", you can cache and reset armature transforms with a single operation. This saves potentially thousands of operations while still having the animations looking perfect. It does mean that dynamic bone transforms are not accurate until an animation or transform is properly set without being overridden by the set_matrix_output function. In the simple demo scene, pose caching increased my average FPS real from abut 1300 to 2060 in VM. That's pretty significant!
  • Increase the sleep margin! At the default of 1, I got all my results above. By raising it, my results increased by about 1000fps. *Note that this should be an option as higher sleep margins usually mean more power consumption when running your game, which isn't great for mobile.

Bugs? Questions? Suggestions? Reply to this post and I'll see what I can do!

Thanks for giving me a chance.
 
Last edited:

mMcFab

Member
v0.3.3 - The Scenic Update

Here's the first BIG update to MMK! The last update added material options to the export, but this one goes further! This is the start of MMK changing from being an animating system into a 3D engine that utilises Blender as the primary tool.
Among a bunch of QoL changes and fixes, this update brings the first version of scenes!

What are scenes?

In this case, scenes are collections of data that describe a 3D environment. We can export them from Blender for use with GameMaker really easily.
While this doesn't include mesh data (You'll need to export that separately), it includes other useful bits of information such as location, rotation, scale, current animation, parent-child relationships, lighting, cameras, custom object properties and much, much more!
The scenes are stored as GameMaker-friendly JSON, which makes it very easy to read info and check what is stored and how.

To get started with scenes, first install the new "MMK_JsonSceneExporter_v1_0_0.py" from the included files into Blender (via User Preferences->Add-ons->Install Add-on From File) and enable it.

Once installed, select everything in the scene that you wish to export data for. Navigate to "File->Export->MMK Data Map (.json)"
The default settings should be acceptable for most projects. You may want to enable "Pretty Print JSON" if you wish to examine the data. You may also want to adjust the scale to match the units of your game.

Once exported, just add the *.json file to your included files. You can then load a map with MMK_load_scene(). e.g:
Code:
this_scene = MMK_load_scene("scene_intro.json");
Once done with a scene (all instances generated by it must be destroyed as they have assosiations), you can free its memory with ds_map_destroy(scene)
*As a fun side note, MMK_load_scene() is actually a general JSON file loader, named simply to avoid conflicts and aid in making the system more intutive. i

Now that a scene is loaded, there's a few things you can do with it (There's probably more to come, but this should get you started)
You can generate lighting for the scene with:
Code:
MMK_scene_generate_lighting(this_scene);
This will generate lighting for up to 8 point and sun lights using GameMakers built-in lighting functions. If no lights are present in the scene, lighting will be automatically disabled.

You can generate instances with:
Code:
MMK_scene_generate_instances(this_scene, name_to_object_map);
"name_to_object_map" is a ds_map containing base name keys to object indices. "Base names" are the object name in Blender up until the first dot (.) to make it easier to just duplicate objects and move them around.
A sample object map would be something like this:
Code:
name_to_object_map = ds_map_create();
name_to_object_map[? "player"] = obj_player;
name_to_object_map[? "enemy_1"] = obj_enemy1;
name_to_object_map[? "enemy_2"] = obj_enemy2;
name_to_object_map[? "coin"] = obj_coin;
These maps are case-sensitive!
Objects generated from these maps will have a bunch of default variables set.
These are:
Code:
z;
zstart;
zprevious;
x_rotation;
y_rotation;
z_rotation;
x_scale;
y_scale;
z_scale;
MMK_name;//Full name
MMK_base_name;//base name
MMK_parent;//noone or parent ID
MMK_children;//-1 or an array of children
MMK_scene_data;//Map of assosiated scene data
You can also generate these default variables with MMK_object_create_defaults();
Objects created this way have access to 2 useful macros: MMK_matrix_object_world and MMK_matrix_object_local, which return world and local transform matrices respectively (world considers parent transforms, local is relative to the parent). This are useful for both rendering and collision.

Another useful thing scenes can currently do is setup some basic camera stuff. You can get the main camera of a scene with:
Code:
scene_cam = MMK_scene_get_main_camera(this_scene);
This either returns undefined if the camera is unavailable, or a reference to the DS map containing info about the camera.
You can then generate two matrices for these cameras
Code:
lookat_matrix = MMK_scene_camera_get_lookat(scene_cam);
This generates a lookat matrix based on what the camera data was at export [Note: Blender's Tracking Constraints do not work with the system]
Code:
projection_matrix = MMK_scene_camera_get_proj(scene_cam);
This generates a projection matrix for the camera. Works with both ortho and perspective. Note that perspective projections are based on the y-FOV, while ortho are based on view width.
The above functions instead return undefined if an invalid camera was passed. Use "is_undefined()" to check stuff
You can then use these matrices with the normal camera_set_view/proj_mat functions. Cool!
These functions should really help reduce the hassle of fine-tuning cameras, even if you're just after a nice FOV

Cameras include enough other data for you to be able to generate new lookat matrices without too much hassle - remember to Pretty-Print and check out the JSON if you're unsure as to what's being stored. Better camera functions are likely upcoming too.

This gif shows a quick demo of a scene being updated just via Blender (The camera we view from in this scene is even carried over to GameMaker!):


Optionally, you may want to create a method of encrypting the JSON so people can't edit your scenes super easily.

On top of scenes, world-animations for the animated models have been fixed in many cases and some euler rotations in right-handed-space armatures have also been fixed.. You'll also find the exporter has had a huge facelift with better organization as well as hiding incompatible and redundant options.
An update has been made to the material system as well, which makes it easier to create fancier materials by providing access to current armature data through macros.
Now possible materials include those like this outline material:
outlineDemo.gif
(This material is now included with the system by default, for both unlit and diffuse lighting. It uses vertex-displacement for the effect and looks best with smooth normals)

A few convenience functions have been added too (matrix_inverse/transpose and MMK_begin_3D())

Limitations
  • 2D collisions will not instantly play nicely with nested objects due to how x, y and z become relative to the parent. Using MMK_matrix_object_world can help, though. This will be less of a concern after the next update, I think...

Complete Changelog:
  • A tiny fix for pointlights in the diffuse shader
  • Object animations now seem to be correct for both right-handed and left-handed export (note that, for consistency with appearance in Blender, Apply Transforms must be disabled or the targets anchor point should be at O) [This is an update to the export script only]
  • Right-Handed euler rotations for bones have been tweaked. Now they seem correct [This is an update to the export script only]
  • Axis-Angle rotations remain untested
  • MMK_JsonSceneExporter - A GameMaker-compatible JSON scene exporter for Blender, giving it the capability of being a level editor for GameMaker. Exports useful data like object transforms, names, types, and a lot of specific data for things like lights, cameras and more. (You may want to encode the output if you don't want people meddling with your scenes though)
  • MMK_load_scene(file) - Used to load the new JSON scenes. Returns scene index. Remove scenes you're done with using ds_map_destroy()
  • MMK_scene_generate_lighting(scene) - Resets and loads in lighting from the scene into GameMaker's built-in lighting system
  • MMK_scene_generate_instances(map, ob_map) - Generate instances based on the "base_name" of an object in a scene (the name before the first dot - so "Object.003" would be just "Object") - and ob_map is a ds_map of base names to instance IDs. Basic for now, but still useful
  • MMK_object_create_defaults() - Generate default variables used by 3D objects loaded by scenes
  • MMK_matrix_object_local - A macro for generating a matrix for the current object using variables created from MMK_object_create_defaults() or from MMK_scene_generate_instances(), assuming rotations are YXZ
  • MMK_matrix_object_world - A macro for generating a matrix fot the current object, with respect for transforms inherited from parents. This does weirdness if "Export Transforms as Local" is disabled (though I think I can fix this)
  • MMK_object_get_world_matrix(instance) - A function that does the same thing as the above macro, but allows targeting a specific instance.
  • MMK_scene_get_main_camera(scene)
  • MMK_scene_camera_get_lookat(scene_cam)
  • MMK_scene_camera_get_proj(scene_cam, view_index)
  • MMK_is_drawing_armature - a macro that returns true if an armature is currently being drawn. Useful for materials that can work with and without armatures.
  • MMK_current_armature - a macro that stores the current armature being drawn (only valid in materials - check "MMK_is_drawing_armature" first)
  • MMK_current_vbuffer - a macro that stores the ID of the current vbuffer being rendered by the armature (only valid in armature materials)
  • MMK_current_bonedata - a macro that stores an array of bonedata normally automatically passed to the shader (only valid in armature materials)
  • MMK_material_full_update - a macro which replaces the old argument to make non-armature materials easier to work with. Included materials have been updated to reflect this change. This defaults to "true" outside of armature drawing to make static-compatible materials simpler to produce
  • The macros are NOT read-only, but if you change them, please remember to reset them after you need them with MMK_reset_model_macros();
  • MMK_matrix_inverse() and MMK_matrix_transpose() - Added until YYG add native versions, useful for materials that need to generate a normal-matrix
  • Renamed python scripts and put them in a group. Also stopped them being included in export by default
  • Updated the function reference in the notes.
  • Moved blend-info to the end of meshes to make them more compatible with other shaders
  • MMK_begin_3D() - A super simple function that just sets up basic 3D state stuff.
  • Material script arguments have been updated for single argument materials - they are now passed directly instead of in an array.
  • Added a new demo material: MMK_material_outline_unlit(outline_size). A simple unlit shader that uses vertex-based outlining using normals. This is primarily to demo the new macros
  • Also added "MMK_material_outline_diffuse(outline_size)", which is functionally the same as the above material, but uses diffuse lighting. Also shows how materials can be combined in certain cases.
  • MMK_armature_get_bone_count(arm) - Returns the number of bones an armature has
  • MMK_generate_identity_output(bone_count) - Generates an array of dummy identity values that can be passed to a skinning shader to have no deformation. You're probably better off using a uniform boolean to check if skinning should be done though.

What's Next?
v0.4.X, the Collision Update, that's what!
It's actually already fully functional (see this: https://cartrdge.com/maddemichael/2018-mmk-is-finally-public), but it needs a little optimise, a couple of extra functions and a port to native code to speed things up. Should be ready in the next week or two.

Also, a Question!
Would anybody be interested if I ported this back to GameMaker: Studio 1.4? It seems a LOT of people still use it and I may be limiting access by not supporting it. It wouldn't be a humongous task to port back, since most of the functions are compatible, but it would still take some work that would only be worthwhile if there is interest.
 
M

Misty

Guest
Not a big fan of blender so if you could somehow get this to run with Milkshape you'd have my money.
 

mMcFab

Member
Not a big fan of blender so if you could somehow get this to run with Milkshape you'd have my money.
If Milkshape has decent plugin support (which it seems to, from a quick Google), it's certainly a possibility (Post-1.0 though, since that's when file formats will be finalised and porting export code will be less of a hassle)
The system doesn't technically depend on Blender, it's just the only place I've written an exporter so far.
For now though, I'm focusing on Blender more for know since it's where I have more experience.

I'll be sure to let you know if I add support!
 
M

Misty

Guest
If Milkshape has decent plugin support (which it seems to, from a quick Google), it's certainly a possibility (Post-1.0 though, since that's when file formats will be finalised and porting export code will be less of a hassle)
The system doesn't technically depend on Blender, it's just the only place I've written an exporter so far.
For now though, I'm focusing on Blender more for know since it's where I have more experience.

I'll be sure to let you know if I add support!
One more thing it is neccesary in GM to have some kind of real-time bone operations in game. Will this support bone operations in Game Maker or only preset animations preloaded into game maker.
 

mMcFab

Member
One more thing it is neccesary in GM to have some kind of real-time bone operations in game. Will this support bone operations in Game Maker or only preset animations preloaded into game maker.
I can happily tell you that the system does allow real-time bone operations in GM!
"MMK_armature_bone_add_transform(armature, bone_id, matrix)" and "MMK_armature_bone_set_transform(armature, bone_id, matrix)" allow this behaviour. I've used it to implement stuff like head tracking already.
Here's a little gif of that in action:

There are also functions for getting transform information for a bone, to allow stuff like creating a projectile in the right place, or binding a weapon to a hand, or a helmet to a head, for example. This isn't the best image, but it shows me using this to bind a sword and shield to a hand and arm:
notthebest.PNG

Amazing work !!
Waow, good job ;)
Thanks, I appreciate it!
 
N

NeutralD

Guest
I can happily tell you that the system does allow real-time bone operations in GM!
"MMK_armature_bone_add_transform(armature, bone_id, matrix)" and "MMK_armature_bone_set_transform(armature, bone_id, matrix)" allow this behaviour. I've used it to implement stuff like head tracking already.
Here's a little gif of that in action:

There are also functions for getting transform information for a bone, to allow stuff like creating a projectile in the right place, or binding a weapon to a hand, or a helmet to a head, for example. This isn't the best image, but it shows me using this to bind a sword and shield to a hand and arm:
View attachment 19231


Thanks, I appreciate it!
Hi,
bought your asset and it works fine so far! Any chance to see inverse kinematics when I do real-time bone operations?
 

mMcFab

Member
Hi,
bought your asset and it works fine so far! Any chance to see inverse kinematics when I do real-time bone operations?
Thanks for asking!

Inverse Kinematics is something I'm very interested in adding, given the possiblities it offers.
I've got a few ideas in mind (as well as a previous implementation), so I just need to test some stuff out.
I don't know when it'll be done, but it should eventually be in. Hopefully before the 1.0 release, but I can't be 100% certain.
On a similar note, I *think* it's technically possible to create an IK system with the current tools available, but it'd take a bit of math. I could certainly make it simpler to do though.

To summarise; Yeah! I'm looking to add some form of IK at some point.

Thank you super much for trying MMK!
 

mMcFab

Member
After putting the project on hold while I worked on my new game, Too Many Birds!™ (Which is out now, by the way!), I'm back with an update!

Collisions have been inserted, functions and materials have been improved, Blender 2.8 is supported, and it's been released on itch.io for a better price! (Because reduced marketplace fees). The itch.io page includes a windows executable so you can see it run on your PC, as well as downloadable source code for the demo project so you can see how it works!
If you already own the kit, message me with your order number and I'll get you an itch link (preferably via twitter, email or itch as I don't check the GMC very often. I just found a message from January. That's how bad I am at checking it)

Oh, we also have a new masot, who is not just a test dummy:

Here she is in motion (GameMaker capture, naturally. From the demo project):

CHANGELOG (v0.4.0)
  • Collisions.
    • Uses an octree system to keep stuff fast
    • Includes an export script for Blender
    • Has support for ellipse and ray collisions. Also includes the ability to "cast" an ellipse in a direction
    • Includes a super simple movement function to make it very easy to set up, though it's a little sticky sometimes in lightly concave areas. Could be a precision issue, but I'm not sure yet
  • Functions to enable the use of "Pose Caching" - MMK_armature_set/get_matrix_output_array()
  • MMK_animation_get_framecount(anim, adjust_for_gamespeed)
  • Fixed another axis-angle issue (when not using native)
  • When using native mode, a check is done GML-side to determine if an armature update is needed now. This was already done within the extension, but the external call overhead itself was still apparantly eating up speed in YYC. Has little impact generally, but yields a very nice performance boost (I got a ~20% boost in the test project) for YYC when an armature hasn't changed pose and/or when using pose caching. (No real impact on VM at all though)
  • A few fixes and additions relating to armature transforms.
  • Fixe an export crash for when tangent export is active but the current mesh has no active UV map (zero values are added instead for now)
  • Added an export option to automatically export armatures linked with the current selection. Enabled by default.
  • Optimised a bunch of native code, fixed a different axis-angle issue within the DLL
  • Initial itch.io release! Yay!
  • New mascot and demo!
  • Added new export scripts for Blender 2.8
  • Added better armature-mesh linking to the 2.8 export script, so now they don't need to have parent-child relationships, just the modifier.
  • Extended the material system so now materials can manage GPU states individually and be ignored during certain render passes (the macro "MMK_auto_handle_gpu_resets" in MMK_models can be set to 0 to disable this). This allows materials to control whether or now they write to the zbuffer, for example. Note that global GPU states are still maintained, only those set will change.
  • Fixed bugs with the material system not always being called when there is no shader change, causing visual defects in some cases
  • Defined some undefined behaviour regarding passing bones to a shader
  • Fixed a crash with "MMK_bone_get_transform" (forgot to comment out an unused argument)
  • Added and improved armature mesh setting options, so now order can be better defined, as well as the option to check what meshes are enabled
  • Added "MMK_armature_add_meshes" and "MMK_armature_set_meshes", which accept both individual meshes and mesh arrays, to streamline adding many meshes to an armature. Note that meshes are appended and set in order.
  • Fixed default armature textures and materials not always being used as a fallback in cases where they should have
  • Added the option to pass custom UVs to armature textures, in case you need custom ones. This can also be useful if you change a texture frequently, as it removes automatic uv_clipspace calculations.
  • Made negative or < frame_1 animation setting use the first frame, which fixed an issue I believe was related to a floating point error preventing me from setting frame 0 of my test characters idle animation.
  • Added some "advanced" output-matrix fetching functions, but I implemented them for reasons that don't work because I forgot, but they may be useful down the line.
  • Default shaders now use blendweights and blendindices for GLSL ES as well, due to changes in how GameMaker passes inputs to attributes. I believe now names matter less, but the order of attributes is incredibly important
  • Native/GML code parity maintained.

Ok, love you bye!
 
Top