User Tools

Site Tools


super_mario_64:custom_object

This is an old revision of the document!


Custom object (decomp)

This page describes how to create a custom object with custom 3D model and custom behavior using the Super Mario 64 decompilation project.

Export 3D model (Fast64)

In Blender, install the Fast64 plugin, select your object you want to export, open the Fast64 menu and expand SM64 Geolayout Exporter. Ensure to select C as the export.

Choose Actor Data as the export type.

Choose a group name you want to add your actor to, such as common0.

Choose a unique folder name. It's recommended to add the word custom to the name, for example custom_platform.

Choose a unique geolayout name, such as custom_platform_geo.

Ensure the newly created model.inc.c file is included in actors/<group>.c file, such as in actors/common0.c.

Ensure the newly created geo_header.h file is included in actors/<group>.h file, such as in actors/common0.h.

Ensure the newly created geo.inc.c file is included in actors/<group>_geo.c file, such as in actors/common0_geo.c.

Load custom model

It's a good idea to give your 3D model a unique name, such as MODEL_CUSTOM_COIN, and an ID from 0x00 to 0xFF. Define it in include/model_ids.h. Ensure it does not share an ID with another model that might be loaded in the same level.

In your level script file (such as levels/bob/script.c) or in a global script located in levels/scripts.c, add a LOAD_MODEL_FROM_GEO command, such as LOAD_MODEL_FROM_GEO(MODEL_CUSTOM_COIN, custom_coin_geo).

Create behavior script

Open data/behavior_data.c in your favorite code editor. You may want to add a dedicated file, such as data/custom_coin.inc.c and include this in data/behavior_data.c.

The easiest way to create your own behavior script is to copy an existing one that's most closely to what you want. Copy the related lines and rename the variable accordingly.

Create native code

If you need new native C code, create a new code file in src/game/behaviors, such as src/game/behaviors/custom_coin.inc.c, and include that file in src/game/obj_behaviors.c. You might want to copy an existing behavior code for reference. However, make sure all variables and function names are unique in the source code. For example, rename bhv_yelow_coin_loop to bhv_custom_coin_loop.

Add object to level (Fast64)

In your level inside Blender, add an Empty. Set object type to Object.

Set model to Custom and model ID to your defined ID from include/model_ids.h, such as MODEL_CUSTOM_COIN.

Set behavior to Custom and behavior name to your defined name in data/behavior_data.c, such as bhvCustomCoin.

super_mario_64/custom_object.1604288379.txt.gz · Last modified: 2020/11/02 03:39 by Tenry