Jump to content

Manually generating ship thumbnail


Recommended Posts

Did someone figure out how to manually generate the ship thumbnails? KSP generates these automatically as soon as a ship is saved to file but I want to do it manually.

I came across CraftThumbnail.TakeSnapshop():

public static void TakeSnaphot(ShipConstruct ship, int resolution, string saveFolder, string craftName, float elevation = 45F, float azimuth = 45F, float pitch = 45F, float hdg = 45F, float fovFactor = 1F)

in class CraftThumbnail

This method is almost what I need, but it does not quite work right. The lighting is wrong as it seems to use the current scene, i.e. it changes depending with the sun rotating around Kerbin ;)

Some parts also don't render correctly, especially engine-fairings and fuel-lines, they point in wonky directions. Very wierd.. ;)

I guess I'm missing some preparations before taking the snapshop.

Link to comment
Share on other sites

If anyone is interesed, these are the parameters used by KSP to build the default thumbnails.


public static class ThumbnailHelper
{
/// <summary>
/// Generates a thumbnail exactly like the one KSP generates automatically.
/// Behaves exactly like ShipConstruction.CaptureThumbnail() but allows customizing the resolution.
/// </summary>
public static void CaptureThumbnail(ShipConstruct ship, int resolution, string saveFolder, string craftName)
{
if (ship.shipFacility != EditorFacility.VAB)
{
CraftThumbnail.TakeSnaphot(ship, resolution, saveFolder, craftName, 35, 135, 35, 135, 0.9f);
}
else
{
CraftThumbnail.TakeSnaphot(ship, resolution, saveFolder, craftName, 45, 45, 45, 45, 0.9f);
}
}


/// <summary>
/// Builds the path to the auto-generated thumbnail for the given ship.
/// </summary>
public static string GetCraftThumbnailPath(ShipConstruct ship)
{
return string.Format("thumbs/{0}_{1}_{2}.png", HighLogic.SaveFolder, ShipConstruction.GetShipsSubfolderFor(ship.shipFacility), ship.shipName);
}
}

Edited by Slother
Link to comment
Share on other sites

  • 3 months 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...