Jump to content

Heads Up Display HUD


Sora Skyward
 Share

You are about to reply to a thread that has been inactive for 1541 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I would like to learn how to script a heads up display for a cockpit or maybe hire someone to do it.

All im looking for would be:

-Heading in degrees

-Forward/Backwards velocity in m/s

-Altitude in meters

I know how to script all this for for hover text and its not that hard to do. However I want to do away with the hover text part of it and make an interactive cockpit heads up display like a modern jet fighter.

The data for heading, speed, and altitude would be displayed on mesh with material IDs setup on them. It would be like digital clock display if that makes much since. I know how to do the grid arrangement of the numbers in the texture and mesh/uv the mesh that would make up the hud. It would half to work within a linkset.

Im looking to specifically take llGetVel() on the X axis and display that data on a mesh plane with 3 materials IDs. Each material ID will have a number texture on it that will be changed using the offsets for textures. I need help on how to translate for example if llGetVel() returns the speed 15m/s the mesh plane will change the texture to show 015. for example.

Any help would much appreciated.

Edited by Sora Skyward
Link to comment
Share on other sites

8 hours ago, Mollymews said:

Sora, if you haven't already post this in Wanted on here.  Is quite a few scripters-for-hire who look for work in that forum

I'm wanting to learn but may hire someone if no one is willing to help. I'm not looking for someone to make a script for me. I want to learn to make it myself.

Link to comment
Share on other sites

I scripted a wind I indicator.. inside a prim. I have it scripted to Touch and it gives wind direction and speed in Local Chat. Not what you're seeking... But from my inventory I can rez it on ground, attach to me as an outfit item, or Attach to display UI where it appears as a HUD. It works same in all positions.. touch give reading in Local. 

 

Link to comment
Share on other sites

1 hour ago, TechDave said:

I scripted a wind I indicator.. inside a prim. I have it scripted to Touch and it gives wind direction and speed in Local Chat. Not what you're seeking... But from my inventory I can rez it on ground, attach to me as an outfit item, or Attach to display UI where it appears as a HUD. It works same in all positions.. touch give reading in Local. 

 

From what it sounds like, that is just a prim you wear or rez with a touch_start to get the wind speed and direction and puts that data in local using llSay or the like. Im looking at non wearable hud but it would be linked to the cockpit of my jet and work on mesh faces with number for the heading, altitude, and velocity.

Link to comment
Share on other sites

16 hours ago, Sora Skyward said:

The data for heading, speed, and altitude would be displayed on mesh with material IDs setup on them. It would be like digital clock display if that makes much since.

What you are describing is a pretty common thing. A group of face/material slots combined to show one character of text per face. Recently, an old thread was revived and has links to some example and freebie applications on the market place that could be along this train of thought. See it here.

Speaking in very general terms, you place your characters on a texture, evenly divided into cells or frames as if it were an animation. Then for each face in sequence, you manually set the texture offsets to display the desired character for that face. If you're just using numbers, you can simplify the process greatly and use the actual number as part of an index into your texture's frames. Not a direct index of course, you'll need to use a formula to get the right offsets. But it's not extraordinarily hard to accomplish.

Assuming you set up your texture such that you have a single horizontal row of ten characters (one for each number, starting with 0 as the first frame), then you only need two things to calculate the offset (assuming we stick to the same horizontal row): the size of a single frame, and the offset for showing frame zero centered on the face.

Find the offset that will center frame 0 on your target face. Let's call it the leftEdge (assuming it's the leftmost frame). This is your starting point. To that, add the horizontal size of a frame multiplied by X, where X is the number 0-9 you wish to display on that face. We're basically saying "shift X frames to the right". If the number is zero, then we're effectively adding zero to the leftEdge so we stay displaying frame zero. This example only works with one single digit at a time, so you'd have to break the number up into each digit. I will cryptically mention that it is possible to make this work on a full number without breaking it apart, but that's a tad advanced using additional math to manipulate the number. For now, I would focus on getting a single digit to work and build up from there.

I leave the rest to you. Good luck!

Edited by Fenix Eldritch
Link to comment
Share on other sites

Thank your for your long detailed reply Fenix Elderich. Unfortunately all of this information is about how to setup mesh faces, shich i already understand how to format correctly.

What i do not understand is the LSL code involved in taking the speed or altitude and making it move the Texture on the mesh face accordingly.

Edited by Sora Skyward
Link to comment
Share on other sites

3 hours ago, Sora Skyward said:

Thank your for your long detailed reply Fenix Elderich. Unfortunately all of this information is about how to setup mesh faces, shich i already understand how to format correctly.

What i do not understand is the LSL code involved in taking the speed or altitude and making it move the Texture on the mesh face accordingly.

It might be easier if you posted the source so we understood where the gaps are. I'm not sure, for example, if the difficulty is in knowing how to scale and offset on a face a texture full of digits ("making it move the Texture on the mesh face"). Thing is, Fenix just described that to you in words, and for this there are free open source scripts on Marketplace cited in the thread to which he linked, so you could use those off-the-shelf or as examples to develop your own code.

And so I'm guessing this isn't the difficulty, but I'm not sure what it might be. (Maybe... llGetVel returns a vector, so probably you want llVecMag of that, or maybe you want to extract the forward component... and there's a bit of geometry in finding the heading from either the velocity or the vehicle rotation... but I doubt any of this is the problem either.)

 

Link to comment
Share on other sites

4 hours ago, Qie Niangao said:

It might be easier if you posted the source so we understood where the gaps are. I'm not sure, for example, if the difficulty is in knowing how to scale and offset on a face a texture full of digits ("making it move the Texture on the mesh face"). Thing is, Fenix just described that to you in words, and for this there are free open source scripts on Marketplace cited in the thread to which he linked, so you could use those off-the-shelf or as examples to develop your own code.

And so I'm guessing this isn't the difficulty, but I'm not sure what it might be. (Maybe... llGetVel returns a vector, so probably you want llVecMag of that, or maybe you want to extract the forward component... and there's a bit of geometry in finding the heading from either the velocity or the vehicle rotation... but I doubt any of this is the problem either.)

 

default
{
state_entry()
{
llListen(0,"","","");
llSetTimerEvent(.25);
}
listen(integer channel, string name, key id, string msg)
    {
    if(msg == "reset ins")
    {
    llResetScript();
    }
}
timer()
{
vector pos = llGetPos();
float vel = llVecMag(llGetVel());
llSetText("Speed : " + (string)((integer)vel) + "\n" + "Alt : " + (string)((integer)pos.z) + "\n" +  "Hdg : " + (string)llRound(get_heading(-90))  + " " + "\n \n \n", <1,1,1>, 1);
}
on_rez(integer start_param)
    {
    llResetScript();
    }
}

 

I wrote this script to get Vel, altitude, and heading. Essentially  I want to convert the data that's in llSetText from the the code I posted to view that information on a 3 face mesh plane. So for example if my heading was 120 it would display the texture numbers 120 where face one would be 0, face 1, would be 2, and face 2 would be 0. I want to do the same for speed. Now Altitude would be a 4 face mesh to compensate for 0000 - 4096.

I know how to script all this for hover text. Its not hard but what I don't understand how to take that information instead of using hover, make it move a Texture on a mesh Face.

Yes I know that code gives a syntax error but you get the idea.

 

Link to comment
Share on other sites

I guess I'd still recommend using an off-the-shelf script for displaying text, such as the FURWARE Text linked in the cited thread. Nonetheless, just in case it's useful, I found an ancient nixie tube script I wrote years ago, simplified it for a unit-image UV per face and to be a little more explicit about what it's doing -- I can only hope I didn't break it too badly in the process:

// Script by Qie Niangao, script PUBLIC DOMAIN, 2020
//
// Original nixie tube images in NIXIE_TEXTURE are distributed under Creative Commons:
// "By Hellbus (Own work) [CC-BY-SA-3.0 (www.creativecommons.org/licenses/by-sa/3.0) 
// or GFDL (www.gnu.org/copyleft/fdl.html)], via Wikimedia Commons"
// (so that attribution would need to be included on any work using this texture, too.)

key NIXIE_TEXTURE = "5570b8b7-093c-b4b1-9c42-51914894b410";

showInt(integer int, list faces)
{   // faces from most- to least-significant digit position
    list rules;
    integer faceCount = llGetListLength(faces);
    integer faceIdx;
    for (; faceCount > faceIdx; ++faceIdx)
    {   // ignores overflow digits
        integer dig = (int / (integer)llPow(10.0, (float)(faceCount-1-faceIdx))) % 10;
        rules +=    // TOTALLY DEPENDENT on layout of nixie_texture
            [ PRIM_TEXTURE, llList2Integer(faces, faceIdx), NIXIE_TEXTURE
            , <0.1, 1, 0> // repeats
            , <-0.45 + dig * 0.1, 0, 0> // offsets
            , 0.0   // rotation in radians
            ];
        // llOwnerSay((string)dig+" on face "+(string)llList2Integer(faces,faceIdx))
    }
    llSetLinkPrimitiveParamsFast(LINK_THIS, rules);
}

default
{
    state_entry()
    {
        llSetTexture(TEXTURE_BLANK, ALL_SIDES); // testing setup: start empty
        showInt(42, [0, 1, 2, 3]);
    }
}

 

Edited by Qie Niangao
The commented-out debug code spoke of faceIdx but meant the faceIdx entry in faces list
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1541 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...