daviscook477 / kparser

Conversion tool between Klei animation files and Spriter projects
MIT License
23 stars 6 forks source link

K-Parser

A bidirectional converter between scml projects and klei animation files.

Please take a look at an updated version by skairunner here. It is a convenient to use standalone program with additional features like interpolating between keyframes

For the direction (klei animation files -> scml project) this tool must be used in tandem with a unity asset extractor. You will have to use the asset extractor to get the game files - specifically you are looking for the atlas file (a single png that contains image data for an animation) and the corresponding (they have the same name) *.build and *.anim file. Then this tool can convert that into an scml project.

For the direction (scml project -> klei animation files) this tool must be used in tandem with an actual full unity install. Use version 2018 because that is the version that Oxygen not included runs on. This is because after this tool creates the klei animation files from your scml project you will need to use unity to create an asset bundle that contains the atlas file (*.png file), the build file (*.build) and the animation file (*.anim).

The conversion from (klei animation files -> scml project) is a lossy conversion because klei animation format is more powerful than spriter (main limitation is skew transforms aren't part of spriter). But the conversion from (scml project -> klei animation file) is correct.

Both directions have been tested and confirmed to work. A more clear tutorial on how to use this tool to create asset mods for Oxygen not included will be made.

Spriter Project Warning - IMPORTANT - MUST READ

Because of limitations of the klei animation format you cannot convert all Spriter projects to klei animations. The requiremets for a Spriter project to be converted to a klei animation are listed here. If you do not exactly follow these requirements in your Spriter project it will not convert to a klei animation properly and you will be sad and I will be unable to help.

Usage Guide

Extracting an SCML Project

  1. Install uTinyRipper from here. Image of download button
  2. Extract uTinyRipper from the zip file Image of extraction
  3. Run uTinyRipper from the exe file Image of exe
  4. With uTinyRipper running open your file system and navigate to your OxygenNotIncluded_Data folder. On Windows it should be located at "C:\Program Files (x86)\Steam\steamapps\common\OxygenNotIncluded\OxygenNotIncludedData". You are looking for "sharedassets0.assets", "sharedassets1.assets", and "sharedassets2.assets" Image of files
  5. Now you will need to drag and drop "sharedassets0.assets" onto your uTinyRipper application window. Image of uTinyRipper application landing screen with drag-n-drop
  6. Now your uTinyRipper should look like this with a large export button in the middle. When you click this button it will prompt you to find a location to put the exported files in. I would recommend putting it in a new folder called "ONI-Exports" under your user's "Documents" directory. Image of uTinyRipper export button
  7. After uTinyRipper has exported "sharedassets0.assets" you may go ahead and export the the other two "sharedassets" files or you can leave that for later and continue with the tutorial for now. You will need to bring up that directory in which your exported the ONI game files. Image of directory with exported files
  8. In the "Assets" folder of one of the "sharedassets" directories you will find two folders. These are "TextAsset" and "Texture2D". A Klei animation is composed of three files - 1st an image file that contains the raw picture data for the animation (this is considered a Texture2D), 2nd and 3rd are two binary files called the build and animation files (both are considered a TextAsset). Image of the TextAsset and Texture2D folders
  9. Now we can actually bring together all the files that make up a Klei animation. For this example we will look at the Klei animation called "airconditioner". In the game, this animation is used for the building called the "Thermo Regulator". The files you will need for the "airconditioner" animation are "Texture2D/airconditioner_0.png", "TextAsset/airconditioner_build.bytes", and "TextAsset/airconditioner_anim.bytes". Image of the texture file Image of the binary files
  10. All of the files for the "airconditioner" animation together looks like this. Image of the directory of the files together
  11. Now download the jar version of K-Parser from the releases section of this github repository. Click here to download it. Put the jar somewhere useful. I recommend putting it near your folder containing the animation files. Image of the kparser jar
  12. For this next step you will need to be using at least java 9. Run the jar file with the animation files as the parameters to create the scml file. Note the order of the parameters. They must be in this order: image, build, anim. Image of command to run
  13. Now you will have the "scml" project file contained inside the new "scml" directory. Additional the original texture file will have been split into its component pieces. Image of the directory with the scml file
  14. Next open the scml file in Spriter. You can now examine and edit the Klei animation as a spriter project. Image of Spriter opening the scml file

Compiling Klei Animation Files

  1. Assuming you have K-Parser installed already (if not see step 11 of the scml extraction section of this tutorial) it is simple to run the compiler on the single scml file. Image of command to run
  2. Now you will have created your three Klei animation files in the same directory as the scml project. Image of created files
  3. The final step before you can use this new animation you have created in an ONI mod is to copy these three Klei animation files to the "anim/assets" folder of your mod. All animations in that folder will automatically be loaded as Klei animations in ONI that are. All animations have _kanim appended to the end of them when referenced in your mod code. For example if you copied your three Klei animation files to a directory called "anim/assets/mysupercoolanimation" then in game you will refer to that as "mysupercoolanimation_kanim".