Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor Nametag System #3083

Merged
merged 2 commits into from
Aug 20, 2023
Merged

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Jul 18, 2023

Introducing a "nametag" system for actors!

As the name implies, this gives the ability to render floating nametags above actors that are billboarded (facing the camera always). The text leverages the in-game font textures, meaning that text is limited to what is supported by the game, but will benefit from HD textures.

Features include:

  • Multi line support (text will be left-justified)
  • Cosmetic editor support to change the global text color and textbox color (including opacity!)
  • Optional text color support per nametag
  • Actors can have multiple tags at once (by leveraging an optional y-offset value)
  • Name tags can be "tagged" allowing for easy removal of multiple nametags by a tag identifier
  • Nametags have a draw distance and will fade out at the far end (for performance reasons and because the text becomes too small to be legible)
  • Supports interpolation!

A nametag can be registered for an actor with the following methods:

void NameTag_RegisterForActorWithOptions(Actor* actor, const char* text, NameTagOptions options);

void NameTag_RegisterForActor(Actor* actor, const char* text);

Name tags are automatically removed/freed when actors are killed/destroyed, or when the play state is destroyed. So name tags have to be re-registered during/after new actors are spawned in.

The following hooks were added:

  • OnActorInit - Used by the actor viewer to register the debug name tags
  • OnPlayDestroy - Used to remove all name tags in case Actor_Destroy wasn't called for all actors
  • OnPlayDrawEnd - Used to render the name tags at the end of play draw, but still in the mirror mode boundaries to leverage mirror mode benefits

The nametag render system maintains its own display list buffer in the system heap, and then is loaded onto the XLU display buffer via a DL call. This mimics the collision viewer approach, ensuring that we do not over consume the Zelda Arena heaps. Memory is freed and cleared as necessary to ensure no leaks.

image

nametag-system.mp4

Build Artifacts

@PurpleHato
Copy link
Contributor

That's awesome! Really looking forward to it!
My only suggestion to it would be to maybe allow the customisation of the background for the nameplate (especially opacity, outside that, nothing to say!)

@Archez
Copy link
Contributor Author

Archez commented Jul 19, 2023

My only suggestion to it would be to maybe allow the customisation of the background for the nameplate (especially opacity)

Done! The global text color and textbox color can now be changed in the cosmetic editor (including opacity 😉)

Copy link
Contributor

@garrettjoecox garrettjoecox left a comment

Choose a reason for hiding this comment

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

Beautiful usage of hooks, cosmetic editor, and clear separation from the rest of the codebase. Have verified this to be working with anchor 👍

@garrettjoecox garrettjoecox merged commit f19f303 into HarbourMasters:develop Aug 20, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants