Jump to content

[WIP] TheWriteStuff v0.9.0


CmdrThyte

Recommended Posts

TheWriteStuff v0.9.0

Customize your space ships by adding text and decals to part textures. Add text during building in the VAB or during eva using the paint bottle part.

Current beta release 0.9.0, Download.

Requires module manager and KIS for eva writing.

Main changes from 0.8.0: recompile for KSP 1.04, add support for dds textures (following sarbian's DDS texture loader) , switched to KIS to handle equipping the spacepaint bottle for EVA painting and separated out the core EVA painting code to a separate assembly.

Javascript is disabled. View full album

Source: github repo

License: Creative Commons Attribution-NonCommercial-ShareAlike 4.0

Usage:

Use the 'edit texture' option in the right click part menu to open the editing gui. Add or edit a text or decal layer(s) and then click apply to paint it to the part's texture.

For eva painting grab the paint bottle part (requires KAS) during eva, right click the paint bottle and select paint. This activates the paint brush pointer. Move the pointer over a part if the part is paintable and you are close enough (5m) the pointer will turn green then left click to start painting. Right click or escape to cancel.

To add the plugin to a part just add a module section in the part's config:


MODULE
{
name = ASPTextureEdit
}

The plugin will then use the first transform in the part with a unity material assigned and will allow writing to the whole of the associated texture. This gives highly variable results depending on the mesh uv map and texture resolution.

Plugin variables:


MODULE
{
name = ASPTextureEdit

// list of transforms - all transforms must use the same material (and thus the same texture)
// defaults to the first transform with a material and valid texture
transformNames = longtank
// USE_ALL or USE_FIRST
transformsOption = USE_ALL

// if false will compress and mark as unreadable the generated output texture
outputReadable = False

// bounding box for applying texture effect to
// defaults to whole texture if not present
// co-ordinates are in unity texture format - (0,0) is the bottom left of the texture and (w-1, h-1) is the top right pixel
ASP_BOUNDINGBOX
{
x = 18
y = 196
w = 481
h = 356
valid = True
use = True
}

// how to find the base texture
// either:
// method = AUTO to automatically find the base texture name or
// method = MULTIPLE to define multiple textures to switch between
// only define one ASP_BASETEXTURE
// defaults to method = AUTO if not ASP_BASETEXTURE is defined
ASP_BASETEXTURE
{
method = AUTO
}
ASP_BASETEXTURE
{
method = MULTIPLE
textures = steel,gold,stone
normals = flat_NRM,flat_NRM,stone_NRM
selectedTexture = 0
}

// the list of image modifiers
ASP_IMAGEMODIFIERS
{
// text
ASP_IMAGEMODIFIER
{
type = BITMAP_TEXT
x = 198
y = 275
mirror = False
alpha = 255
textureAlpha = 0
alphaOption = USE_TEXTURE
normalScale = 2
normalOption = RAISE_TEXT
blendMethod = RGB
rotation = R270
red = 0
green = 100
blue = 150
text = Valley\nForge
fontName = CAPSMALL_CLEAN
fontSize = 64
}

// colour decal
ASP_IMAGEMODIFIER
{
type = BITMAP_COLOR_DECAL
x = 176
y = 203
mirror = False
alpha = 255
textureAlpha = 0
alphaOption = USE_TEXTURE
normalScale = 2
normalOption = USE_BACKGROUND
blendMethod = RGB
rotation = R270
url = ASP/TheWriteStuff/Decals/warnings-64/warnings-64/Biohazard
}

// mono decal
ASP_IMAGEMODIFIER
{
type = BITMAP_MONO_DECAL
x = 178
y = 474
mirror = False
alpha = 255
textureAlpha = 0
alphaOption = USE_TEXTURE
normalScale = 2
normalOption = USE_BACKGROUND
blendMethod = RGB
rotation = R270
red = 0
green = 0
blue = 170
url = ASP/TheWriteStuff/Decals/nasadings-64/nasadings-64/w
}
}
}

The coordinates used are in unity texture coordinates, ie. the bottom left is 0,0.

Notes:

* For each part with text/decals written to it the plugin creates a new texture so use it sparingly if you have a lot of mods.

ChangeLog:


0.9.0
* recompile for KSP 1.04
* add support for dds textures
* switch to KIS for EVA painting
* separate out EVA painting code into separate assembly
0.8.0
* recompile for ksp 0.90
* fix decal urls (breaks 0.7.0 saves with decals)
* auto select new layer in gui
* add space paint resource for eva painting
* add gui label option
* fix gui decal selection initialisation
* move textplaque to start tech
* move paint bottle to basicRocketry
* flip raise/lower in normal maps
* fix eva painting for multiple textures

0.7.0
* add multi purpose texture editor
* add layering of effects to texture
* multiple text strings
* add mono decals
* add color decals
* rewrite gui

0.6.0
* change for single transformName to transformNames list of transforms
* add option to use first or all transforms of a given name
* add escape codes '\n' to start a new line and '\\' to print a single '\'
* add global config file
* add global debugging option
* fix nomalmap scaling
* move font setup to loading screen
* fix for unreadable font texture
* use .pngmap extension for font maps to avoid unity autoloading texture

0.5.0
* fix treatment of normal maps from mbm files
* add mirror option
* add bounding boxes for squad fuel tanks
* add option to ignore bounding box and use full texture
* lower limit for scale of 0.01 to prevent divide by zero
* deal with case of normal map being a different size to the main texture
* add support for tga textures
* fix key capture during eva

0.4.0
* add paint bottle
* add eva writing
* ignore texture alpha in preview
* add smaller font sizes
* add multiple text directions
* add blending options
* add work around for active texture management

0.3.0
* now works with mbm texture files, using Active Texture Managements MBMToTexture method
* added search for first transform in a part with a mesh if not given a transform to use
* if no bounding box given will now use whole texture
* added oswald, russo one, capsmall fonts
* fix (at least some of) the memory leaks

0.2.0
* Lowered texture resolution
* Added texture selector

0.1.0
* Initial text release

To do:


* a couple more different sized plaques for writing on
* write some proper documentation
* (long term) true type fonts
* (long term) svg decals

Edited by CmdrThyte
beta release 0.9.0
Link to comment
Share on other sites

Ohhhhh looks cool! Could It work on KW rocketry fairings?

Not at the moment, no. In principle it's possible but the devil is in the details of which transform has the texture to edit and which part of the texture maps to which bit of the model. It's much easier when it's your own part and texture.

Link to comment
Share on other sites

New version 0.3

Change log:


0.3.0
* now works with mbm texture files, using Active Texture Managements MBMToTexture method
* added search for first transform in a part with a mesh if not given a transform to use
* if no bounding box given will now use whole texture
* added oswald, russo one, capsmall fonts
* fix (at least some of) the memory leaks

To add the plugin to a part add the ASPTextWriter module in the part's config file:


MODULE
{
name = ASPTextWriter
}

The plugin will then use the first texture in the part and allow access to the whole texture for writing on. So you need to find out which bit of the texture to write to. The quality of the output text then depends on the part's texture resolution and uv mapping.

For example the jumbo 64 tank:

2mTPhMr.jpg

Note:

* For each part with text on it the plugin creates a new texture so use sparingly if you have a lot of mods.

* Not (yet) working with textures compressed using active texture management

Link to comment
Share on other sites

First beta release 0.4.0

Now with a proper name and a paint bottle part to allow writing during eva (requires KAS).

Changelog:


0.4.0
* add paint bottle
* add eva writing
* ignore texture alpha in preview
* add smaller font sizes
* add multiple text directions
* add blending options
* add work around for active texture management

Link to comment
Share on other sites

Beta release 0.5.0 (download in first post)

Changelog:


0.5.0
* fix treatment of normal maps from mbm files
* add mirror option
* add bounding boxes for squad fuel tanks
* add option to ignore bounding box and use full texture
* lower limit for scale of 0.01 to prevent divide by zero
* deal with case of normal map being a different size to the main texture
* add support for tga textures
* fix key capture during eva

Link to comment
Share on other sites

can you add variable to assign transform for ASPTextWriter? would be easier for other mods to support this. :) just pulling the 1st transform the plugin sees is a crapshoot, there's no telling what might come up

You can use:


MODULE
{
name = ASPTextWriter
transformName = xxxxx
}

This is the unity transform name displayed in the unity editor. I'll add the info to the first post.

Link to comment
Share on other sites

nice! will it write to all transforms with the same name? or just the first one it finds?

Just the first transform. I can change this easily enough but both transforms would need to share the same texture. The single texture assumption would need a re write to change. Can you point me to a part that has multiple transforms like this so I can do some testing?

Link to comment
Share on other sites

This looks interesting. I have a request:

Allowing players to change the specularity of the text.

It's not documented yet, but it's already in the code. There are options in the gui to change the alpha value of the text (or use the background texture alpha). If the transform uses a specular shader then the changing the alpha value will change the specularity of the text (or the transparency if the shader has transparency instead). If the shader doesn't have specularity or transparency then the alpha value gets ignored.

The corresponding variables of the module section are:


alpha = 255
alphaOption = TEXT_ONLY

where alpha runs between the traditional 0 to 255 and alphaOption can have the values TEXT_ONLY, USE_TEXTURE, WHOLE_TEXTURE

Link to comment
Share on other sites

This occures when I start typing text. Mod is installed right.

Text of exception in output log:

UnityException: Texture 'ASP/TheWriteStuff/Fonts/CAPSMALL_CLEAN-32' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.

at (wrapper managed-to-native) UnityEngine.Texture2D:GetPixels (int,int,int,int,int)

at UnityEngine.Texture2D.GetPixels (Int32 x, Int32 y, Int32 blockWidth, Int32 blockHeight) [0x00000] in <filename unknown>:0

at UnityEngine.ASP_Texture2D_Extension.GetPixels (UnityEngine.Texture2D texture, ASP.Rectangle pos) [0x00000] in <filename unknown>:0

at UnityEngine.ASP_Texture2D_Extension.DrawText (UnityEngine.Texture2D texture, System.String text, ASP.MappedFont font, Color color, Int32 offsetX, Int32 offsetY, Boolean mirror, TextDirection direction, ASP.Rectangle boundingBox, BlendMethod blend, Boolean applyAlpha, Single alpha) [0x00000] in <filename unknown>:0

at UnityEngine.ASP_Texture2D_Extension.DrawText (UnityEngine.Texture2D texture, System.String text, ASP.MappedFont font, Color color, Int32 offsetX, Int32 offsetY, Boolean mirror, TextDirection direction) [0x00000] in <filename unknown>:0

at ASP.TextEntryGUI.drawTexture () [0x00000] in <filename unknown>:0

at ASP.TextEntryGUI.drawWindow (Int32 windowID) [0x00000] in <filename unknown>:0

at UnityEngine.GUILayout+LayoutedWindow.DoWindow (Int32 windowID) [0x00000] in <filename unknown>:0

at UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) [0x00000] in <filename unknown>:0

xDWgKz6.jpg

Link to comment
Share on other sites

This occures when I start typing text. Mod is installed right.

Text of exception in output log:

UnityException: Texture 'ASP/TheWriteStuff/Fonts/CAPSMALL_CLEAN-32' is not readable, the texture memory can not be accessed from scripts. You can make the texture readable in the Texture Import Settings.

at (wrapper managed-to-native) UnityEngine.Texture2D:GetPixels (int,int,int,int,int)

The error is unity speak for 'I can't read pixels from the texture' - by default many of the unity texture types tend not to be readable or writable to at run time. The fonts are png textures which should still be readable. Do you have any other mods installed? Thinking about it active texture management in aggressive mode might do this.

Link to comment
Share on other sites

Beta release 0.6.0 (download in first post)

The font bitmap loading has been reworked to side step the normal texture loading process. This should fix the reported problem with unreadable font textures. The transformName variable has been changed from a single transform to transformNames which is now a comma separated list of transform to use. This assumes the given transforms all use the some material (and thus the same texture).

Changelog:


0.6.0
* change for single transformName to transformNames list of transforms
* add option to use first or all transforms of a given name
* add escape codes '\n' to start a new line and '\\' to print a single '\'
* add global config file
* add global debugging option
* fix nomalmap scaling
* move font setup to loading screen
* fix for unreadable font texture
* use .pngmap extension for font maps to avoid unity autoloading texture

Link to comment
Share on other sites

This is awesome. Finally got to try it out.

I tried two TextWriter modules, each pointed to a different transform and different texture. the first one (higher up in the part cfg) works as expected. the 2nd one applies it's own texture to the entire part when applying the new text. seems strange to me, since the 1st one doesn't displace other textures.

Link to comment
Share on other sites

This is awesome. Finally got to try it out.

I tried two TextWriter modules, each pointed to a different transform and different texture. the first one (higher up in the part cfg) works as expected. the 2nd one applies it's own texture to the entire part when applying the new text. seems strange to me, since the 1st one doesn't displace other textures.

It's a side affect in the current version for allowing a choice from multiple base textures. The base texture then comes from either the prefab texture (if it's readable) or from disc if the texture isn't readable. So both the modules start from the same base texture, hence the overwrite. The next version will get around this by allowing for writing multiple strings (and other effects as they're coded) to the same texture. There's also the potential in the next version to vary the way the base texture is obtained so it could in principle try to use an existing texture and then fall back to loading the texture if required.

Link to comment
Share on other sites

Beta release 0.7.0 (download in first post)

The plugin logic has been rewritten to allow for multiple effects to be applied to the same texture. Currently three effects are defined: text, mono decals and colour decals. All of which can be applied to a texture multiple times. Due to the rewrite this version is incompatible with previous beta releases.

Changelog:


0.7.0
* add multi purpose texture editor
* add layering of effects to texture
* multiple text strings
* add mono decals
* add color decals
* rewrite gui

Link to comment
Share on other sites

Beta release 0.8.0 (download in first post)

Hopefully the last beta release before the 1.0.0 release. Recompiled for KSP 0.90 and some bug fixes (breaks some saves using 0.7.0).

Changelog:


0.8.0
* recompile for ksp 0.90
* fix decal urls (breaks 0.7.0 saves with decals)
* auto select new layer in gui
* add space paint resource for eva painting
* add gui label option
* fix gui decal selection initialisation
* move textplaque to start tech
* move paint bottle to basicRocketry
* flip raise/lower in normal maps
* fix eva painting for multiple textures

Link to comment
Share on other sites

  • 3 weeks later...
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...