mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-03 14:11:10 +00:00
Add custom box model example
This commit is contained in:
parent
68f3203587
commit
580c5baeb3
6 changed files with 138 additions and 1 deletions
Binary file not shown.
After Width: | Height: | Size: 538 B |
|
@ -0,0 +1,15 @@
|
||||||
|
// 0x0F0005D0
|
||||||
|
const GeoLayout custom_box_geo[] = {
|
||||||
|
GEO_CULLING_RADIUS(500),
|
||||||
|
GEO_OPEN_NODE(),
|
||||||
|
GEO_SHADOW(SHADOW_SQUARE_PERMANENT, 0xB4, 240),
|
||||||
|
GEO_OPEN_NODE(),
|
||||||
|
GEO_SWITCH_CASE(2, geo_switch_anim_state),
|
||||||
|
GEO_OPEN_NODE(),
|
||||||
|
GEO_DISPLAY_LIST(LAYER_OPAQUE, custom_box_seg8_dl_08012D20),
|
||||||
|
GEO_DISPLAY_LIST(LAYER_OPAQUE, custom_box_seg8_dl_08012D48),
|
||||||
|
GEO_CLOSE_NODE(),
|
||||||
|
GEO_CLOSE_NODE(),
|
||||||
|
GEO_CLOSE_NODE(),
|
||||||
|
GEO_END(),
|
||||||
|
};
|
|
@ -0,0 +1,97 @@
|
||||||
|
// Breakable Box
|
||||||
|
|
||||||
|
// 0x08011A78
|
||||||
|
static const Lights1 custom_box_seg8_lights_08011A80 = gdSPDefLights1(
|
||||||
|
0x3f, 0x3f, 0x3f,
|
||||||
|
0xff, 0xff, 0xff, 0x28, 0x28, 0x28
|
||||||
|
);
|
||||||
|
|
||||||
|
// 0x08011A90
|
||||||
|
ALIGNED8 static const Texture custom_box_texture[] = {
|
||||||
|
#include "actors/custom_box/custom_box_surface.rgba16.inc.c"
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0x08012A90
|
||||||
|
static const Vtx custom_box_seg8_vertex_08012A90[] = {
|
||||||
|
{{{ -100, 0, -100}, 0, { 992, 0}, {0x81, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 0, 100}, 0, { 992, 992}, {0x81, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 200, 100}, 0, { 0, 992}, {0x81, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 0, 100}, 0, { 0, 992}, {0x00, 0x00, 0x7f, 0xff}}},
|
||||||
|
{{{ 100, 0, 100}, 0, { 992, 992}, {0x00, 0x00, 0x7f, 0xff}}},
|
||||||
|
{{{ 100, 200, 100}, 0, { 992, 0}, {0x00, 0x00, 0x7f, 0xff}}},
|
||||||
|
{{{ -100, 200, 100}, 0, { 0, 0}, {0x00, 0x00, 0x7f, 0xff}}},
|
||||||
|
{{{ 100, 0, -100}, 0, { 992, 0}, {0x00, 0x81, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 0, 100}, 0, { 0, 0}, {0x00, 0x81, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 0, 100}, 0, { 0, 992}, {0x00, 0x81, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 0, -100}, 0, { 992, 992}, {0x00, 0x81, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 200, -100}, 0, { 0, 0}, {0x7f, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 200, 100}, 0, { 0, 992}, {0x7f, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 0, 100}, 0, { 992, 992}, {0x7f, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 0, -100}, 0, { 992, 0}, {0x7f, 0x00, 0x00, 0xff}}},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0x08012B80
|
||||||
|
static const Vtx custom_box_seg8_vertex_08012B80[] = {
|
||||||
|
{{{ -100, 200, 100}, 0, { 0, 0}, {0x00, 0x7f, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 200, -100}, 0, { 992, 992}, {0x00, 0x7f, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 200, -100}, 0, { 992, 0}, {0x00, 0x7f, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 200, 100}, 0, { 0, 992}, {0x00, 0x7f, 0x00, 0xff}}},
|
||||||
|
{{{ 100, 200, -100}, 0, { 0, 0}, {0x00, 0x00, 0x81, 0xff}}},
|
||||||
|
{{{ 100, 0, -100}, 0, { 0, 992}, {0x00, 0x00, 0x81, 0xff}}},
|
||||||
|
{{{ -100, 0, -100}, 0, { 992, 992}, {0x00, 0x00, 0x81, 0xff}}},
|
||||||
|
{{{ -100, 200, -100}, 0, { 992, 0}, {0x00, 0x00, 0x81, 0xff}}},
|
||||||
|
{{{ -100, 0, -100}, 0, { 992, 0}, {0x81, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 200, 100}, 0, { 0, 992}, {0x81, 0x00, 0x00, 0xff}}},
|
||||||
|
{{{ -100, 200, -100}, 0, { 0, 0}, {0x81, 0x00, 0x00, 0xff}}},
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0x08012C30 - 0x08012CD8
|
||||||
|
const Gfx custom_box_seg8_dl_08012C30[] = {
|
||||||
|
gsSPLight(&custom_box_seg8_lights_08011A80.l, 1),
|
||||||
|
gsSPLight(&custom_box_seg8_lights_08011A80.a, 2),
|
||||||
|
gsSPVertex(custom_box_seg8_vertex_08012A90, 15, 0),
|
||||||
|
gsSP2Triangles( 0, 1, 2, 0x0, 3, 4, 5, 0x0),
|
||||||
|
gsSP2Triangles( 3, 5, 6, 0x0, 7, 8, 9, 0x0),
|
||||||
|
gsSP2Triangles( 7, 9, 10, 0x0, 11, 12, 13, 0x0),
|
||||||
|
gsSP1Triangle(11, 13, 14, 0x0),
|
||||||
|
gsSPVertex(custom_box_seg8_vertex_08012B80, 11, 0),
|
||||||
|
gsSP2Triangles( 0, 1, 2, 0x0, 0, 3, 1, 0x0),
|
||||||
|
gsSP2Triangles( 4, 5, 6, 0x0, 4, 6, 7, 0x0),
|
||||||
|
gsSP1Triangle( 8, 9, 10, 0x0),
|
||||||
|
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
|
||||||
|
gsDPPipeSync(),
|
||||||
|
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
|
||||||
|
gsSPSetGeometryMode(G_SHADING_SMOOTH),
|
||||||
|
gsSPEndDisplayList(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0x08012CD8 - 0x08012D20
|
||||||
|
const Gfx custom_box_seg8_dl_08012CD8[] = {
|
||||||
|
gsDPPipeSync(),
|
||||||
|
gsDPSetCombineMode(G_CC_MODULATERGB, G_CC_MODULATERGB),
|
||||||
|
gsSPClearGeometryMode(G_SHADING_SMOOTH),
|
||||||
|
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, G_TX_NOMASK, G_TX_NOLOD),
|
||||||
|
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
|
||||||
|
gsDPTileSync(),
|
||||||
|
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD),
|
||||||
|
gsDPSetTileSize(0, 0, 0, (32 - 1) << G_TEXTURE_IMAGE_FRAC, (32 - 1) << G_TEXTURE_IMAGE_FRAC),
|
||||||
|
gsSPEndDisplayList(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0x08012D20 - 0x08012D48
|
||||||
|
const Gfx custom_box_seg8_dl_08012D20[] = {
|
||||||
|
gsSPDisplayList(custom_box_seg8_dl_08012CD8),
|
||||||
|
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, custom_box_texture),
|
||||||
|
gsDPLoadSync(),
|
||||||
|
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
|
||||||
|
gsSPBranchList(custom_box_seg8_dl_08012C30),
|
||||||
|
};
|
||||||
|
|
||||||
|
// 0x08012D20 - 0x08012D70
|
||||||
|
const Gfx custom_box_seg8_dl_08012D48[] = {
|
||||||
|
gsSPDisplayList(custom_box_seg8_dl_08012CD8),
|
||||||
|
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, custom_box_texture),
|
||||||
|
gsDPLoadSync(),
|
||||||
|
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
|
||||||
|
gsSPBranchList(custom_box_seg8_dl_08012C30),
|
||||||
|
};
|
BIN
docs/lua/examples/custom-box-model/actors/custom_box_geo.bin
Normal file
BIN
docs/lua/examples/custom-box-model/actors/custom_box_geo.bin
Normal file
Binary file not shown.
24
docs/lua/examples/custom-box-model/main.lua
Normal file
24
docs/lua/examples/custom-box-model/main.lua
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
-- name: Custom Box Model
|
||||||
|
-- description: Press DPAD+down to spawn a box
|
||||||
|
|
||||||
|
E_MODEL_CUSTOM_BOX = smlua_model_util_get_id("custom_box_geo")
|
||||||
|
|
||||||
|
function mario_update_local(m)
|
||||||
|
if (m.controller.buttonPressed & D_JPAD) ~= 0 then
|
||||||
|
print('spawning box: ', id_bhvBreakableBox, E_MODEL_CUSTOM_BOX)
|
||||||
|
-- spawn breakable box
|
||||||
|
spawn_sync_object(
|
||||||
|
id_bhvBreakableBoxSmall,
|
||||||
|
E_MODEL_CUSTOM_BOX,
|
||||||
|
m.pos.x, m.pos.y, m.pos.z,
|
||||||
|
nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function mario_update(m)
|
||||||
|
if m.playerIndex == 0 then
|
||||||
|
mario_update_local(m)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
hook_event(HOOK_MARIO_UPDATE, mario_update)
|
|
@ -15,7 +15,7 @@ Lua scripts you make can be placed either the `mods` folder in the base director
|
||||||
- When developing Lua mods, run the game from a console. Lua errors and logs will appear there.
|
- When developing Lua mods, run the game from a console. Lua errors and logs will appear there.
|
||||||
- You can use the `print()` command when debugging. Your logs will show up in the console.
|
- You can use the `print()` command when debugging. Your logs will show up in the console.
|
||||||
- [Setting up Visual Studio Code](vs-code-setup.md) will give you autocomplete and other nice things.
|
- [Setting up Visual Studio Code](vs-code-setup.md) will give you autocomplete and other nice things.
|
||||||
|
- You can create a folder within the mods folder containing multiple lua scripts as long as one script is called `main.lua`. Dynos actors can be placed inside this mod folder under `<your mod folder>/actors/`.
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
## Sections
|
## Sections
|
||||||
|
@ -54,3 +54,4 @@ All of this is a holdover from when there were only two players. It was a reason
|
||||||
- [Replace Goomba Behavior](examples/behavior-replace-goomba.lua)
|
- [Replace Goomba Behavior](examples/behavior-replace-goomba.lua)
|
||||||
- [Add to Goomba Behavior](examples/behavior-add-to-goomba.lua)
|
- [Add to Goomba Behavior](examples/behavior-add-to-goomba.lua)
|
||||||
- [Behavior with Surface Collisions](examples/behavior-surface-collisions.lua)
|
- [Behavior with Surface Collisions](examples/behavior-surface-collisions.lua)
|
||||||
|
- [Custom Box Model](examples/custom-box-model)
|
||||||
|
|
Loading…
Reference in a new issue