Jump to content

Vessel name printed on it


juvilado

Recommended Posts

11 hours ago, fourfa said:

Make a custom flag with the name just for that craft?

Thats a bit annoying, doing it EVERY time you make a new vessel. Thats exactly what i want to avoid...

 

14 hours ago, Van Disaster said:

Could probably procedurally generate flag textures, or something along those lines. The problem with "make vessels display their name" is *where do you print it*.

A custom part could be made with just the name, or just replace the flag with the vessel´s name, or any other option someone invents.

Link to comment
Share on other sites

9 minutes ago, TheSaint said:

There is a decal mod, but it hasn't been updated since 0.25:

I too would be stoked if someone would take up the mantle and update it.

It shouldn't need updating.  Just update Firespitter and I bet it would work.

Link to comment
Share on other sites

6 hours ago, juvilado said:

A custom part could be made with just the name, or just replace the flag with the vessel´s name, or any other option someone invents.

If it's a custom part that's a bit different, can just render the name to a texture then & there's a few things you can do at that point, like send it to a custom shader that'll wrap it on the part, or just send it to a particular quad like a flag. Automatically printing the name on a suitable part of a vessel made of random components is not trivial :)

Link to comment
Share on other sites

This can be done, and will require a little code to do so; and I'm tempted because I wouldn't mind something similar. So I would do the following:

- Create a part, similar to a flag poly, that will hold a transparent texture with the ship name.
- Create a module, in which the user can generate a decal based on the ship name in the editor for said part.

This will mean that a texture is generated within the editor and used permanently on the craft with the part attached; textures will be small and won't impact performance when used. There may bit a little spike upon generation of the initial texture.

I'm going to look into this further.

Link to comment
Share on other sites

Deep into coding this as a Part, Part Module and Plugin; here's a snippet of how I'm painting text via a Font Map.  Can't test it until I'm home though, and I'll still need to add the full alphabet to that Dictionary.

public Texture2D CreateLabel(string vesselName)
{
    // Dictionary of characters that can be used, with a Rect coordinate relating to the position on Arial_Font_Map.png
    Dictionary<char, Rect> fontCoordinates = new Dictionary<char, Rect>()
    {
        { 'a', new Rect(16, 0, 16, 16) }, { 'b', new Rect(32, 0, 16, 16) }, { 'c', new Rect(48, 0, 16, 16) }, { 'd', new Rect(64, 0, 16, 16) }
    };

    // Split the vesselName string into an array of characters.
    char[] Characters = vesselName.ToCharArray();

    // Create a reference to our return texture which we're about to edit.
    Texture2D labelTexture = new Texture2D(512, 512, TextureFormat.ARGB32, false);

    // Reference the index of the character we're currently painting.
    int characterIndex = 0;

    foreach (char character in Characters)
    {
        // Grab the coordinate of the character from the dictionary, if it doesn't exist we default to a blank space.
        Rect characterCoordinate = fontCoordinates.ContainsKey(character) ? fontCoordinates[character] : new Rect(0, 0, 16, 16);

        // Grab the pixels for the character from the FontMap using the above coordinate.
        Color[] characterPixels = FontMap.GetPixels((int)characterCoordinate.x, (int)characterCoordinate.y, (int)characterCoordinate.width, (int)characterCoordinate.height);

        // Reference the index of the color we'll be applying from characterPixels.
        int colorIndex = 0;

        // Loop through the pixels in the current characterCoordinate, row by row.
        for (int y = 0; y < characterCoordinate.height; y++)
        {
            // Loop through the pixels in the current characterCoordinate, column by column.
            for (int x = 0; x < characterCoordinate.width; x++)
            {
                // Apply the color from the characterPixels array, pixel by pixel.
                labelTexture.SetPixel(characterIndex * 16, 0, characterPixels[colorIndex]);

                // Increase the index count for the Pixel as we're done with this one.
                colorIndex++;
            }
        }

        // Increase the index count for the Characters as we're done with this one.
        characterIndex++;
    }

    // Apply the changes to the texture as we've finished editing it; this will possibly cause a momentary spike of lag.
    labelTexture.Apply();

    // Return the labelTexture to the function requesting it.
    return labelTexture;
}

Edit: I should probably create a Dev thread for this.

Edited by udk_lethal_d0se
Made a whoopsie.
Link to comment
Share on other sites

4 hours ago, udk_lethal_d0se said:

Deep into coding this as a Part, Part Module and Plugin; here's a snippet of how I'm painting text via a Font Map.  Can't test it until I'm home though, and I'll still need to add the full alphabet to that Dictionary.


public Texture2D CreateLabel(string vesselName)
{
    // Dictionary of characters that can be used, with a Rect coordinate relating to the position on Arial_Font_Map.png
    Dictionary<char, Rect> fontCoordinates = new Dictionary<char, Rect>()
    {
        { 'a', new Rect(16, 0, 16, 16) }, { 'b', new Rect(32, 0, 16, 16) }, { 'c', new Rect(48, 0, 16, 16) }, { 'd', new Rect(64, 0, 16, 16) }
    };

    // Split the vesselName string into an array of characters.
    char[] Characters = vesselName.ToCharArray();

    // Create a reference to our return texture which we're about to edit.
    Texture2D labelTexture = new Texture2D(512, 512, TextureFormat.ARGB32, false);

    // Reference the index of the character we're currently painting.
    int characterIndex = 0;

    foreach (char character in Characters)
    {
        // Grab the coordinate of the character from the dictionary, if it doesn't exist we default to a blank space.
        Rect characterCoordinate = fontCoordinates.ContainsKey(character) ? fontCoordinates[character] : new Rect(0, 0, 16, 16);

        // Grab the pixels for the character from the FontMap using the above coordinate.
        Color[] characterPixels = FontMap.GetPixels((int)characterCoordinate.x, (int)characterCoordinate.y, (int)characterCoordinate.width, (int)characterCoordinate.height);

        // Reference the index of the color we'll be applying from characterPixels.
        int colorIndex = 0;

        // Loop through the pixels in the current characterCoordinate, row by row.
        for (int y = 0; y < characterCoordinate.height; y++)
        {
            // Loop through the pixels in the current characterCoordinate, column by column.
            for (int x = 0; x < characterCoordinate.width; x++)
            {
                // Apply the color from the characterPixels array, pixel by pixel.
                labelTexture.SetPixel(characterIndex * 16, 0, characterPixels[colorIndex]);

                // Increase the index count for the Pixel as we're done with this one.
                colorIndex++;
            }
        }

        // Increase the index count for the Characters as we're done with this one.
        characterIndex++;
    }

    // Apply the changes to the texture as we've finished editing it; this will possibly cause a momentary spike of lag.
    labelTexture.Apply();

    // Return the labelTexture to the function requesting it.
    return labelTexture;
}

Edit: I should probably create a Dev thread for this.

Do it do it!! ^^

Anyway if you dont mind notify us if you open a new thread about the development of this feature, thanks

Link to comment
Share on other sites

So, I've been working on this for a few hours now after playing with pseudo-code (above) and probably won't need a development thread because I'll release by the morning. Here's a GIF of what I've created in action.

TognvNN.gif

Note: The final texture wont have a white background, it'll all be transparent, I've just kept it white for testing purposes. I'll also refine the part. Finally, as with Squad's FlagModule, I'll make it so modders can use the module to add a vessel name to their own parts.

Link to comment
Share on other sites

Can't wait to see "Thor V" plastered on the side of my mighty Mun rocket soon...  Also could this mod somehow support a different name for the spacecraft?  I.e. My Einherjar missions use a Thor V as the lifting vehicle so it would be cool if the rocket said "Thor V" and the capsule could say something like "Einherjar _" where the blank is the number of that particular mission.  I basically do the Apollo/Saturn thing where the capsule and the rocket have different names if that wasn't making sense.

Link to comment
Share on other sites

I'm investigating rendering decals in the main texture shader at the moment, you'd not get anything rendered across seperate parts though - to do that you'd have to create a new mesh out of all the part meshes & render onto that, and then track if parts fell off, etc etc. That is a lot of work for some letters :P

Link to comment
Share on other sites

9 minutes ago, Van Disaster said:

I'm investigating rendering decals in the main texture shader at the moment, you'd not get anything rendered across seperate parts though - to do that you'd have to create a new mesh out of all the part meshes & render onto that, and then track if parts fell off, etc etc. That is a lot of work for some letters :P

It's worth it for those letters to me :wink: .

Link to comment
Share on other sites

On 14/09/2016 at 1:59 AM, Chiron0224 said:

Can't wait to see "Thor V" plastered on the side of my mighty Mun rocket soon...  Also could this mod somehow support a different name for the spacecraft?  I.e. My Einherjar missions use a Thor V as the lifting vehicle so it would be cool if the rocket said "Thor V" and the capsule could say something like "Einherjar _" where the blank is the number of that particular mission.  I basically do the Apollo/Saturn thing where the capsule and the rocket have different names if that wasn't making sense.

Yes, I've set up a text editor so you can use whatever text you wish, rather than that of the editor ship name. 

Won't be long until I'm done and ready to release. 

Link to comment
Share on other sites

On 15-9-2016 at 5:44 AM, ZooNamedGames said:

Yeah I'd like one that would print a name on part of the vessel. Specifically like the names of the orbiter's on the wings and at the rear of the cockpit.

1400523116427.jpg

Would be great for my Saturn Shuttle. Hopefully without a part however :sealed: .

But then.. try and get Helvetica on your pc. 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...