Difference between revisions of "Creating HUDs"

From Second Life Wiki
Jump to navigation Jump to search
m (Added a note about mesh use in constructing HUDs.)
 
(32 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{KBmaster}} {{TOCright}}
{{TOCright}}


== What's a HUD? ==
This article describes how to create your own HUDs. For basic information about HUDs, see [http://community.secondlife.com/t5/English-Knowledge-Base/Heads-up-displays-HUDs/ta-p/700083 Heads-up displays (HUDs)]


'''In Second Life, [[object]]s can be worn on one of the eight HUD (short for [http://en.wikipedia.org/wiki/HUD_%28video_gaming%29 heads-up display]) attachment points). HUDs are essential to understand, since every SL Resident eventually comes across them sooner or later.'''
=== Building and Texturing HUDs ===


A HUD typically consists of a control panel with different buttons you can click on to do context-specific stuff. Some HUDs are "passive" and only meant to be looked at, not touched.
It is easiest to keep the root prim rotation at <0., 0., 0.> while building. That way, you can know that the west side of the object will be the one facing the screen when attached. For a box prim, that is [[face]] 4.


While general [[attachment|attachments]] appear on your avatar's body and other Residents can see them, HUDs are only visible to you and have a fixed viewpoint, similar to how they're used in video games and apps. However, the ''scripted effects'' of a HUD, like [[:Category:LSL_Chat|emitted]] chat, can be visible to other Residents and objects.
Since an update about 2012 ({{JIRA|SH-2646}}), HUD attachments are always rendered as full bright.


HUDs are an evolution of user interaction in SL: before HUDs, Residents were limited to typing commands in chat or [[DialogMenus|touch dialogs]] (pop-up windows with choices to click on). These methods are still used — sometimes in tandem with HUDs — but HUDs are often more visually attractive and user-friendly, making them approachable.
Prim alpha and texture transparency work as expected. If you want your HUD to be totally transparent, consider making only the front faces that way. The flat projection will keep the other sides hidden, and it will be easier for residents to find the object if accidentally dropped or forgotten on the ground.


Objects specifically designed to be used like that may have "HUD" in their name to tell you where they'll appear, or they may have "(wear me)" in their name.
HUD objects will capture mouse clicks, even on their transparent parts. If you are using a round interface element, a cylinder would not be a bad choice of prim, so it does not use more space than it needs.


{{red|Video coming from [[Torley]] in the future...}}
Shiny works on the HUD, this can help to give an almost-3D appearance to some shapes, like spheres or sculpts. Not everybody enables shiny, so textured shading could still be your best bet.
 
== What are HUDs used for? ==
 
<gallery widths=160px>
File:5051340497_2a56c5d291_o.jpeg|This HUD controls a futuristic gun. Notice how ammo, size and color, animations, and more are shown within a fun, grungy interface.
File:4118625707_f1b11f5977_o.jpeg|In the upper-left, an intricate game HUD. In the lower-right, both an AO and multi-tool (gray circles) HUD are shown.
File:3457764773_b71024b98f_o.jpeg|This is a vehicle HUD that controls whether the car is flying.
File:2558870465_e92202e452_o.jpeg|"Frame" HUDs can be partially transparent to allow for ominous letterboxing effects.
</gallery>
 
HUDs are used in many kinds of products where information needs to be directly communicated to you. Popular uses:
 
* '''[[AO|Animation overrides]]''' - Click buttons to change how your avatar looks when moving. Turn off the AO if animations conflict with sitting on furniture.
* '''Books''' - HUDs are useful for viewing info that may be tricky to camera-zoom in on, or you simply don't want others to see it.
* '''[[Combat|Combat systems]] and games''' - See your health, stamina, experience points, and other relevant in-game info. Use special powers (cast spells in an RPG) to attack enemies. An HUD can be a whole game experience, similar to [http://en.wikipedia.org/wiki/Casual_game casual gaming] in a web browser. (In fact, with [[Shared Media]], an HUD can show Flash-based games.)
* '''Customizable attachments''' - Click color swatches to change your hair, clothes, shoes, or more exotic accessories like [http://en.wikipedia.org/wiki/Catgirl neko] tail and ears. Make particle effects (like fire and smoke).
* '''Multi-tools''' - Gadgets that have a lot of practical functionality in one HUD. Be alerted when other avatars are nearby (including when you want privacy). Eject intruders from your land. Get region performance stats. And many more.
* '''Photo enhancements''' - Show a fancy frame around your Viewer window to add an ornamental touch when [[taking snapshots]].
* '''Vehicles''' - Dashboards with speedometers and remaining fuel. Camera angles can be changed. Some cars even have a "turbo" or ''Back To The Future''-esque "fly" button.
 
{{KBtip|You can browse and buy many HUDs on the [http://bit.ly/gHFpCI Second Life Marketplace].}}
 
== How do I use an HUD? ==
 
Details depend on the specific HUD but since it's broadly useful to know how things typically behave here: after you get a HUD (and [[Marketplace/Opening boxes|unpack]] it if necessary), it appears in your inventory, perhaps in a folder (with {{xref|notecard}} instructions and a {{xref|landmark}} to the store it came from). If the creator's been thoughtful, they've provided help for its further use, whether that's the aforementioned notecard — or the help is accessed by clicking a help button on the HUD itself.
 
Right-click the HUD and select '''Wear''' to automatically attach it to the point the HUD creator set when they made it. If there are buttons, they may be labeled, and you can often safely explore by clicking them to see what they do.
 
== Can any object be attached as a HUD? ==
 
Yes. ''Any'' Second Life object can be attached to ''any'' attachment point, including HUD ones. However, attaching something that's not designed as an HUD may not be very useful. For example, attaching a house object may show up as a big, wood-textured square that obscures your field of view.
 
== Troubleshooting HUDs ==
 
=== How do I move my HUDs? ===
 
HUDs are usually positioned towards a corner so they don't obscure your field of view (unless that's desired).
 
Once an HUD is worn:
 
# Right-click the HUD onscreen (not in your inventory) and select '''Edit'''.
# Drag the arrowheads to reposition the HUD.
 
The HUD remembers where it is the next time you login. In some circumstances (like a sudden Viewer crash), the HUD may forget its position, so use this workaround in addition to the above:
 
# Right-click the HUD and select '''Detach'''.
# Find the HUD in your inventory, right-click it and select '''Wear'''.
 
=== Why does wearing one HUD make another HUD disappear? ===
 
These HUDs are being worn on the same attachment point. There are eight HUD attachment points: '''Center 2''', '''Top Right''', '''Top''', '''Top Left''', '''Center''', '''Bottom Left''', '''Bottom''', and '''Bottom Right'''. Despite their names, these only indicate where an HUD is initially positioned when you first wear it — as described above, you can always move them around as you wish.
 
To solve this:
 
# In your inventory, right-click one of the HUD and select '''Attach To HUD'''. In brackets, it shows you which point(s) other HUD(s) are currently attached to. Select a different attachment point that isn't already occupied.
# Move the HUD according to your taste using the above steps.
 
=== I can't see my HUD! ===
 
There are a couple possible solutions:
 
==== The HUD is off-screen ====
 
HUDs scale depending on your Viewer window resolution. For example, if you shrink the window, they become smaller. Since you may not have the same window resolution another Resident does, wearing the same HUDs may look very different in size and position. HUDs can also be rendered off-screen. To see it again:
 
# Right-click the HUD in your inventory and select '''Detach From Yourself'''.
# Right-click the HUD again and select '''Attach To HUD''' and choose a different attachment point than the one it was attached to before. This will attach it to the default position for that point, then you can move it back to where you prefer it.
 
==== The HUD is hidden ====
 
If you have the [[Advanced menu|'''Advanced''' menu]] open, there's a '''Show HUD Attachments''' option (that can be toggled with a shortcut, even if '''Advanced''' isn't enabled). If this is the case, simply relog to show HUDs again. Or:
 
# Toggle '''Advanced''' menu > '''Highlighting and Visibility''' > '''Show HUD Attachments'''.
 
=== How do I show HUDs in snapshots? ===
 
# Click the '''Snapshot''' (camera icon) button on the bottom bar.
# In the {{win|Snapshot Preview}} window, click '''More'''.
# Check '''HUDs''' (under "Capture:").
# Click the '''Refresh''' button. The snapshot preview should now show your HUDs.
 
== Advanced usage ==
 
The below details are for Residents who want to create their own HUDs.


=== Scripting HUDs ===
=== Scripting HUDs ===


{{red|Please cleanup and update this!}}
Most scripted functionality works with HUDs. They mostly work like any other attachment, but there are some special exceptions. A page with an [[HTML_HUD_Demo]] can be found on this wiki as well.
 
Most scripted functionality works with HUDs. They mostly work like any other attachment, but there are some special exceptions.


==== Differences in behavior ====
==== Differences in behavior ====
* If a sound is triggered using [[llPlaySound]](), only the HUD wearer will hear it. If the land parcel they're over restricts sound entry/exit, the sound will not play.
* If a sound is triggered using [[llPlaySound|llPlaySound()]], only the HUD wearer will hear it. If the land parcel they're over restricts sound entry/exit, the sound will not play.
** If a sound is triggered using [[llTriggerSound]](), the wearer and any bystanders will hear it.
** If a sound is triggered using [[llTriggerSound|llTriggerSound()]], the wearer and any bystanders will hear it.
* Like with all attachments, [[llSensor|llSensor()]] will not detect the attachment or its wearer.
* Particles do not generally work. Since Viewer 1.23 there is an experimental debug setting '''RenderHUDParticles''' that you can try, but it is incomplete and switched off by default. On very old viewers (before 1.23) HUD particles would show in world, at (0, 0, 0) globally within the region (the southwest corner). <sup>{{Jira|SVC-2396}}</sup>
* [[Glow]] is not supported on HUD attachments. <sup>{{Jira|VWR-3167}}</sup>
* [[llSetText|llSetText()]] is supported, but be aware that the text does not scale with the HUD or screen size, and the text size is under user control. Despite the limitations, some HUD objects use it to great advantage.
* [[Shared Media]] works on the HUD in Viewer 2.2 and later. On earlier 2.x viewers, clicks and audio may not be available.


* Like with all attachments, [[llSensor]] will not detect its wearer.
==== Differences in coordinates ====
[[Image:HUD-center-coordinates 2.jpg|thumb|300px|HUD center coordinates]]
[[Image:300px-HUD-bottomright-coordinates.jpg|thumb|right|300px|HUD bottom right coordinates]]
HUD attachments are rendered with an orthographic projection, meaning that everything looks flat and there is no perspective. The objects are still 3D, and they can move in XYZ space and be rotated.
* The X coordinate moves away from and toward the wearer, a higher number is farther away and can hide a HUD prim behind others. You can use X changes in a single HUD object to reveal and hide buttons, for one example. There is no good way to grab the red X axis with the viewer editor, but scripts do not have this problem.
* Y moves right to left on the screen; a higher number is more to the left.
* Z moves bottom to top on the screen; a higher number is, well, higher up!


* Particles do not generally work. Since Viewer 1.23 there is an experimental debug setting '''RenderHUDParticles''' that you can try, but it is incomplete and switched off by default. On very old viewers (before 1.23) HUD particles would show in world, at (0, 0, 0) in the region.
In HUD space, 1 meter is the height of the viewer window, ''including'' the menus and tool bar. The (0,0,0) position depends on the HUD attachment point. For the Center and Center 2 points, zero is the center of the screen. For the four corner HUD points, zero is that corner of the viewer window. Zero for the top and bottom is centered on the window, again hidden behind the menu or toolbar. There is no way provided to learn the ''width'' of the viewer window, or the pixel dimensions. (The [[FindScreenWidth]] script example can return the display width on touch, if the attachment is on one of the corner HUD slots.)


==== Difference in coordinates ====
If '''Move & View''' > '''Automatic position for: Sidebar''' is ''checked'', the HUD coordinates will automatically be scaled to exclude the sidebar when it is open. If this feature is ''unchecked'', the entire window width is used regardless. (Some third-party themes may ignore this setting.)
[[Image:HUD-center-coordinates.png|thumb|300px|HUD center coordinates]]
[[Image:HUD-bottomright-coordinates.png|thumb|right|300px|HUD bottom right coordinates]]
HUD attachments are rendered with an orthographic projection, meaning that everything looks flat and there is no perspective. The objects are still 3D, and they can move in XYZ space and be rotated.
* The X coordinate moves toward and away from the wearer, a higher number is farther away and and hide a HUD prim behind others. You can use X changes in a single HUD object to reveal and hide buttons, for one example. There is no good way to grab the red X axis with the viewer editor, but scripts do not have this problem.
* Y moves right to left on the screen, a higher number is more to the left.
* Z moves bottom to top on the screen, a higher number is, well, higher up!


In HUD space, 1 meter is the height of the viewer window, ''including'' the menus and tool bar.  The <0., 0., 0.> position depends on the HUD attachment point. For the Center and Center 2 points, home is the center of the screen. For the four corner HUD points, zero is that corner of the viewer window. Zero for the top and bottom is centered on the window, again hidden behind the menu or toolbar. There is no way provided to learn the ''width'' of the viewer window, or the pixel dimensions.
Since standard prim HUD attachments cannot be clicked through even if they're invisible, the common solutions to getting them out of the way are moving, shrinking, or rotating.


Since HUD attachments cannot be clicked through even if they're invisible, the common solutions to getting them out of the way are moving, shrinking, or rotating.
HUD attachments can be made from mesh in such a way as to have a side that will present no face to the screen when rotated, which allows them to be clicked through. Small buttons can be included in their construction to trigger the rotation.


Use [[llGetLocalPos|llGetLocalPos()]] to learn an attachment's position on the screen, [[llSetPos|llSetPos()]] to move it. ([[llGetPos|llGetPos()]]) looks tempting, but for attachments that tells us the ''avatar's'' position.)
Use [[llGetLocalPos|llGetLocalPos()]] to learn an attachment's position on the screen, [[llSetPos|llSetPos()]] to move it. ([[llGetPos|llGetPos()]] looks tempting, but for attachments that tells us the ''avatar's'' position.)


This example moves the HUD away from the wearer, possibly behind other HUD attachments:
This example moves the HUD away from the wearer, possibly behind other HUD attachments:


<lsl>llSetPos(llGetLocalPos() + (<0.25,0,0> * llGetLocalRot()));</lsl>
<syntaxhighlight lang="lsl2">llSetPos(llGetLocalPos() + (<0.25, 0.0, 0.0> * llGetLocalRot()));</syntaxhighlight>
 
 
[[Category:Content creation]]

Latest revision as of 16:55, 27 July 2024

This article describes how to create your own HUDs. For basic information about HUDs, see Heads-up displays (HUDs)

Building and Texturing HUDs

It is easiest to keep the root prim rotation at <0., 0., 0.> while building. That way, you can know that the west side of the object will be the one facing the screen when attached. For a box prim, that is face 4.

Since an update about 2012 (SH-2646), HUD attachments are always rendered as full bright.

Prim alpha and texture transparency work as expected. If you want your HUD to be totally transparent, consider making only the front faces that way. The flat projection will keep the other sides hidden, and it will be easier for residents to find the object if accidentally dropped or forgotten on the ground.

HUD objects will capture mouse clicks, even on their transparent parts. If you are using a round interface element, a cylinder would not be a bad choice of prim, so it does not use more space than it needs.

Shiny works on the HUD, this can help to give an almost-3D appearance to some shapes, like spheres or sculpts. Not everybody enables shiny, so textured shading could still be your best bet.

Scripting HUDs

Most scripted functionality works with HUDs. They mostly work like any other attachment, but there are some special exceptions. A page with an HTML_HUD_Demo can be found on this wiki as well.

Differences in behavior

  • If a sound is triggered using llPlaySound(), only the HUD wearer will hear it. If the land parcel they're over restricts sound entry/exit, the sound will not play.
    • If a sound is triggered using llTriggerSound(), the wearer and any bystanders will hear it.
  • Like with all attachments, llSensor() will not detect the attachment or its wearer.
  • Particles do not generally work. Since Viewer 1.23 there is an experimental debug setting RenderHUDParticles that you can try, but it is incomplete and switched off by default. On very old viewers (before 1.23) HUD particles would show in world, at (0, 0, 0) globally within the region (the southwest corner). SVC-2396
  • Glow is not supported on HUD attachments. VWR-3167
  • llSetText() is supported, but be aware that the text does not scale with the HUD or screen size, and the text size is under user control. Despite the limitations, some HUD objects use it to great advantage.
  • Shared Media works on the HUD in Viewer 2.2 and later. On earlier 2.x viewers, clicks and audio may not be available.

Differences in coordinates

HUD center coordinates
HUD bottom right coordinates

HUD attachments are rendered with an orthographic projection, meaning that everything looks flat and there is no perspective. The objects are still 3D, and they can move in XYZ space and be rotated.

  • The X coordinate moves away from and toward the wearer, a higher number is farther away and can hide a HUD prim behind others. You can use X changes in a single HUD object to reveal and hide buttons, for one example. There is no good way to grab the red X axis with the viewer editor, but scripts do not have this problem.
  • Y moves right to left on the screen; a higher number is more to the left.
  • Z moves bottom to top on the screen; a higher number is, well, higher up!

In HUD space, 1 meter is the height of the viewer window, including the menus and tool bar. The (0,0,0) position depends on the HUD attachment point. For the Center and Center 2 points, zero is the center of the screen. For the four corner HUD points, zero is that corner of the viewer window. Zero for the top and bottom is centered on the window, again hidden behind the menu or toolbar. There is no way provided to learn the width of the viewer window, or the pixel dimensions. (The FindScreenWidth script example can return the display width on touch, if the attachment is on one of the corner HUD slots.)

If Move & View > Automatic position for: Sidebar is checked, the HUD coordinates will automatically be scaled to exclude the sidebar when it is open. If this feature is unchecked, the entire window width is used regardless. (Some third-party themes may ignore this setting.)

Since standard prim HUD attachments cannot be clicked through even if they're invisible, the common solutions to getting them out of the way are moving, shrinking, or rotating.

HUD attachments can be made from mesh in such a way as to have a side that will present no face to the screen when rotated, which allows them to be clicked through. Small buttons can be included in their construction to trigger the rotation.

Use llGetLocalPos() to learn an attachment's position on the screen, llSetPos() to move it. (llGetPos() looks tempting, but for attachments that tells us the avatar's position.)

This example moves the HUD away from the wearer, possibly behind other HUD attachments:

llSetPos(llGetLocalPos() + (<0.25, 0.0, 0.0> * llGetLocalRot()));