Awesome
libsm64-godot
Addon that binds libsm64 to godot via GDExtention, allowing to integrate mario into any Godot 4 project.
Projects using libsm64-godot
Infinite Mario 64 (by TwilightPB) |
---|
Current Godot compatibility
Currently compatible with Godot 4.3.x, with binaries compiled for Windows (x86_64), macOS (universal) and Linux (x86_64). Check the Releases for the files.
How to compile the GDExtension
If you just clone the project throught Git and attempt to run it, you'll get errors complaining about the lack of the GDExtension library (the project zip file in the Releases page already has the necessary binaries packaged).
First, build libsm64 and then copy (don't move) the genereated dynamic library from the extension/libsm64/dist/
folder into addons/libsm64-godot/extension/bin
.
Setup the requirements for building Godot for your platform of choice (If compiling for Windows, use the MinGW 64 enviroment you used to compile libsm64). Then, run the following command from inside of the extension
folder to compile the GDExtension. It will automatically copy the generated binary into addons/libsm64-godot/extension/bin
.
- For debug build:
scons target=template_debug use_mingw=yes
- For release build:
scons target=template_release use_mingw=yes
Note: if you are using MSYS2
to compile, you must run this command from the MSYS2 MINGW64
terminal window.
How to use
This add-on consists of two main components:
SM64Global
: Singleton that exposes theinit()
andterminate()
functions of the libsm64 library.SM64Mario
: Extends Node3D; can have multiple in any scene.
It also adds two helper nodes:
SM64StaticSurfaceHandler
: Extends Node; provides helper functions to load all the meshes under thelibsm64_static_surfaces
group into thelibsm64
world.SM64SurfaceObjectsHandler
: Extends Node; provides helper functions to load and update all the meshes under thelibsm64_surface_objects
group into thelibsm64
world.
And a node for audio:
SM64AudioStreamPlayer
: Extends AudioStreamPlayer; plays the audio generated bylibsm64
; add this node to the scene and call theplay()
method after callingSM64Global.init()
.
This add-on requires a Super Mario 64 (USA) ROM file (for legal reasons, steps to get a ROM will not be disclosed). Make sure the ROM file has the following SHA256 hash:
17ce077343c6133f8c9f2d6d6d9a4ab62c8cd2aa57c40aea1f490b4c8bb21d91
If the SHA256 doesn't match, it will be rejected and the addon will fail to initialize.
Simple steps for basic use
When creating the scene:
- Add a
SM64StaticSurfaceHandler
node to the scene. - Add the meshes that compose the world to the
libsm64_static_surfaces
group (NOTICE: use simple, low-polycount meshes for best results). - Add a
SM64Mario
node (or as many as you want) and set its camera property with anCamera3D
node. - Create the action names that are in the
SM64Mario
node'sInput Actions
export group in the project's Input Map and bind them to the appropriate axes/buttons/keys.
Then do the following on the scene's main script:
- Feed the
SM64Global
singleton the file path to the Super Mario 64 ROM file (SM64Global.rom_filepath = "path/to/rom/file"
). - Configure the
SM64.Global.scale_factor
property if necessary (try default value first). - Call the
SM64Global.global_init()
function. - Call
StaticSurfaceHandler.load_static_surfaces()
on your instancedSM64StaticSurfaceHandler
node. - Call
SM64Mario.create()
on your instancedSM64Mario
node(s).
For more detailed instructions refer to the manual.