User Tools

Site Tools


super_mario_64:custom_object

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
super_mario_64:custom_object [2020/11/02 00:45]
Tenry created
super_mario_64:custom_object [2020/11/05 17:44]
Tenry
Line 1: Line 1:
 +====== Custom object (decomp) ======
 +
 This page describes how to create a custom object with custom 3D model and custom behavior using the [[Decompilation project|Super Mario 64 decompilation project]]. This page describes how to create a custom object with custom 3D model and custom behavior using the [[Decompilation project|Super Mario 64 decompilation project]].
  
-== Export 3D model (Fast64) ==+===== 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. 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 **Actor Data** as the export type and provide ​a group name such as **common0**. ​The exported model requires ​a unique folder name such as **custom_platform**. ​For the geolayout name, it's advised to use the same as the folder name and "​_geo"​ appended, such as **custom_platform_geo**.
- +
-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 model.inc.c file is included in actors/<​group>​.c file, such as in **actors/​common0.c** ​(should be done by Fast64 exporter).
  
-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_header.h file is included in actors/<​group>​.h file, such as in **actors/​common0.h** ​(should be done by Fast64 exporter).
  
-Ensure the newly created geo.inc.c file is included in actors/<​group>​_geo.c file, such as in **actors/​common0_geo.c**.+Ensure the newly created geo.inc.c file is included in actors/<​group>​_geo.c file, such as in **actors/​common0_geo.c** ​(should be done by Fast64 exporter).
  
-== Load custom model ==+===== 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. 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.
Line 25: Line 21:
 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)**. 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 ==+===== 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.+Open **data/​behavior_data.c** in your favorite code editor. You may want to add a dedicated file, such as **data/​custom_coin.c** ​(it is automatically found and included by the Makefile). Also add your new behavior name as a declaration ​in a header file, such as in **include/​behavior_data.h**.
  
 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. 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 ==+===== 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**.+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**. Declare your custom functions in a suitable header file, such as in **src/​game/​obj_behaviors.h** or **src/​game/​behavior_actions.h**.
  
-== Add object to level (Fast64) ==+===== Add object to level (Fast64) ​=====
  
 In your level inside Blender, add an Empty. Set object type to **Object**. In your level inside Blender, add an Empty. Set object type to **Object**.
super_mario_64/custom_object.txt · Last modified: 2020/11/05 17:44 by Tenry