Skip to content

Conversation

@Yanis002
Copy link
Collaborator

@Yanis002 Yanis002 commented Nov 20, 2025

Still a draft but I feel like I'm getting close to the end, this PR adds the following:

  • 7 new animated material types
  • an "event manager" that can trigger drawing a type based on certain things happening in-game, currently it supports flags, time of day, the age, health, rupee count, magic meter amount, any quest item and any inventory item including the equipment
  • the possibility to attach an event to any animated material type
  • misc stuff like certain settings that can change the screen's behavior (shaking and jabu-style bobbing)
Details about the event manager

The event manager I made can be used for anything, I have a lot of ideas of usage that can't be done here since it's unrelated but it'll do more cool stuff in the future! To setup one for animated materials it's very simple:

EventData eventEntries[] = {
    EVENT_SWITCH_FLAG(0x01),

    // other examples:
    // EVENT_AGE(EVENT_COND_EQUAL, LINK_AGE_CHILD),
    // EVENT_RUPEES(EVENT_COND_LESS, 80),
    // EVENT_ITEM(ITEM_DEKU_STICK, false),
    // EVENT_ITEM_AMMO(EVENT_COND_LESS, ITEM_DEKU_NUT, 15),
    // EVENT_EQUIPMENT(ITEM_SWORD_KOKIRI, false),
    // EVENT_EQUIPMENT_BGS(EVENT_COND_SUPERIOR_T, 4),
    // EVENT_EQUIPMENT_UPG(EVENT_COND_EQUAL, UPG_WALLET, 2),
    // EVENT_GS_TOKEN(EVENT_COND_SUPERIOR, 10),
    // EVENT_QUEST_ITEM(QUEST_MEDALLION_FOREST, false),
    // EVENT_TIME_CLOCK(EVENT_COND_SUPERIOR, 15, 00),
    // EVENT_TIME_CONDITIONAL(EVENT_COND_SUPERIOR, 14, 30, EVENT_COND_LESS, 16, 00),
    // EVENT_TIME_DAY(),

    EVENT_END(),
};

EventScriptEntry events = { eventEntries, EVENT_FREEZE_TYPE_NONE };

as you can see it's very similar to how cutscene works (don't mind EVENT_FREEZE_TYPE_NONE yet it's started by unfinished), you just need to do that then in this case use events in the AnimatedMaterial entry like:

AnimatedMaterial anim_mats_test_scene_header00_AnimatedMaterial[] = {
    { LAST_MATERIAL_SEGMENT_NUM(8), ANIM_MAT_TYPE_TWO_TEX_SCROLL, myAnimatedMaterialTwoTexScrollParams, &events, ANIM_MAT_CAMERA_TYPE_NONE }
};

to use that anywhere you only need to setup the data then run EventManager_ProcessScript, it will return true or false depending on if the events to watch are completed

Details about the new animated material types

As stated earlier, this adds new types of animated materials:

  • ANIM_MAT_TYPE_COLOR_CYCLE: same as the original ANIM_MAT_TYPE_COLOR except this can take a keyframe array to set the duration of the displayed colors
  • ANIM_MAT_TYPE_TEX_TIMED_CYCLE: exact same principle as above except it's textures instead of colors
  • ANIM_MAT_TYPE_TEXTURE: draws a simple texture, makes more sense to use with an attached event to allow you to swap between 2 textures, it can be useful for time of day-based entrances like vanilla OoT does
  • ANIM_MAT_TYPE_MULTITEXTURE: this one can do many things depending on how you're using it, the basics of this type is it can be same as above except you can blend the textures to make a smooth transition and you can also change the opacity of the textures, this allows you to have a lot of possibilities
  • ANIM_MAT_TYPE_EVENT: this will draw the material only when the events are completed, it's unfinished/untested but I think it should work assuming the mesh's DL is correct
  • ANIM_MAT_TYPE_SURFACE_SWAP: this allows you to swap surface types, you can use it just for that purpose or you can also provide a list of tris, that will allow you to change the surface types they're attached to but also change the polygon's flags
  • ANIM_MAT_TYPE_OSCILLATING_TWO_TEX: this is exactly like the original two texture scroll except this adds oscillation instead of moving forever in the same direction (provided by kenton)

I'm not done yet but I'm making good progress, also I'll have to update Fast64 but I'll do that when I'll be satisfied with my types


These new types and the event manager are both based on z64rom, thanks to them for such creativity! (and letting me making my own implementation based on their work)


related Fast64 PR: Fast-64/fast64#623

@Yanis002 Yanis002 marked this pull request as ready for review November 24, 2025 17:10
@Yanis002 Yanis002 changed the title [Draft] New Animated Material types New Animated Material types Nov 24, 2025
@Yanis002
Copy link
Collaborator Author

should be ready now, I don't think I want to add anything else

Copy link
Contributor

@Reonu Reonu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature needs to be documented in a wiki or similar when you have time because it's pretty complex and easy to mess up. But the PR itself looks good to me, it works.

@Yanis002 Yanis002 added the merge soon The pull request will be merged in 24 hours if nothing else comes up label Nov 25, 2025
@Yanis002
Copy link
Collaborator Author

will merge tomorrow at the same time we'll merge the fast64 PR

@Yanis002 Yanis002 merged commit 3505a2e into HackerN64:main Nov 26, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge soon The pull request will be merged in 24 hours if nothing else comes up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants