Skip to content

Making a prop for RasterPropMonitor

Eugene Medvedev edited this page Jul 31, 2014 · 19 revisions

Creating a model

You need a model for your screen. If it's to have buttons, they need to be named colliders. In no circumstances those colliders can be open mesh colliders, by the way, Unity hates that whenever transparent internals are involved, even if your pod itself is not transparent. The screen must be a named transform, arranged in such a way that the texture's 0,1 coordinates are the top left corner of the screen. Whatever shader you have selected for it will remain unchanged. It must already have a texture in the layer you name (_MainTex, _Emissive, etc) that the plugin will replace, or KSP will refuse to load the model. To save memory, that placeholder texture should be the minimum size possible, which for KSP appears to be 32x32 pixels. It's not entirely clear why KSP needs a placeholder texture in there, but it definitely does.

There are no restrictions whatsoever on the shape of the screen, and the mapping of the texture is not touched, so if you want a bulging screen, or a screen animated using some other included module, or some other plugin entirely, it's not a problem at all to make one.

It is likewise not a problem to have a transparent screen -- to do it, you just need to create a prop using KSP/Alpha/Unlit transparent shader for the object that will be the screen, and direct RPM to use it's _MainTex layer. If you require it to be 'not completely' transparent, you can place another plane beneath it with a glass texture, or make use of various background color options.

Creating a bitmap font

You can always use one of the fonts provided in RasterPropMonitor/Library/Fonts, but there's a lot to be said for making your own. The plugin treats fonts as if they were fixed width, so it's best to take a fixed width font to start with. CBFG works for generation of bitmaps from a regular TrueType font, though it isn't ideal, and Fixedsys Excelsior is a nice font, but there are other programs to do the same thing and probably fonts more suited to your taste.

Every letter is assumed to occupy a block of fontLetterWidth by fontLetterHeight pixels on the bitmap. Font texture size must be evenly divisible by fontLetterWidth/fontLetterHeight respectively. For Unity reasons, the font bitmap has to have sizes that are a power of 2, but it doesn't have to be square. Characters are read from the font left to right, top to bottom.

Which bitmap location corresponds to which character in the font bitmap -- as well as the total list of characters available -- is determined by the font definition configuration parameter. The default font definition presumes that fonts start with character number u0020 (space) and continue on to character u007e. u007f is unprintable, which is why it's place is taken by u0394 (greek Delta). Characters u0080-009f are also unprintable and skipped entirely, the next symbol defined is u260a (ascending node). The list proceeds with u00a1-00ac, but the place of the unprintable u00ad is taken over by u260b (descending node). The table continues unmolested with u00ae-00bf. You can see which characters are which on the Wikipedia page describing Unicode characters.

You can, if you wish, override the font definition entirely, so that your font contains Cyrillic, Thai, or any of Unicode-supported glyphs, which can be helpful when editing page definition files. For that, you need to create a text file in UTF-8 encoding, which contains, in order, on a single line, every character you wish your font to have, and supply it's URL in the fontDefinition parameter when configuring the monitor. For your convenience, the default font definition is included in the fontDefinition.txt file in the Library, even though it's unnecessary there, since it directly repeats the built-in font definition string. If characters repeat in your font definition, only the first instance of the character will actually be used and repeating characters will be ignored.

Be aware, that RPM internally uses the symbol u00b5 (greek letter 'mu') as a SI prefix when converting values to kilo-mega-milli-whatever for display, and you want your font to have it in any case.