Git Product home page Git Product logo

sc-file's Introduction

SC FILE

Utility and Library for decoding and converting stalcraft assets files, such as models and textures into well-known formats.

Designed for artworks creation and the like.

Note

There is not and will not be encoding back into game formats.

Warning

Do not use game assets directly.
Any changes in game client can be detected.

You can use executable program from Releases page.

๐Ÿ“ Formats

Type Source Output
Model .mcsa / .mcvd .dae, .obj, ms3d, .txt
Texture .ol .dds
Image .mic .png

Models

  • Versions supported: 7.0, 8.0, 10.0, 11.0
  • Skeleton and Animations currently unsupported

Textures

  • Formats supported: DXT1, DXT3, DXT5, RGBA8, BGRA8, DXN_XY
  • Formats unsupported: RGBA32F, Cubemaps
  • Some normal map (DXN_XY) textures can be inverted

๐Ÿ’ป CLI Utility

Usage

From bash:

scfile [FILES]... [OPTIONS]

Tip

You can just drag and drop one or multiple files onto scfile.exe.

Arguments

  • FILES: List of file paths to be converted. Multiple files should be separated by spaces. Accepts both full and relative paths. Does not accept directory.

Options

  • -O, --output: One path to output directory. If not specified, file will be saved in same directory with a new suffix.

Examples

  1. Convert a single file:

    scfile file.mcsa

    Will be saved in same directory with a new suffix.

  2. Convert multiple files to a specified directory:

    scfile file1.mcsa file2.mcsa --output path/to/dir
  3. Convert all .mcsa files in current directory:

    scfile *.mcsa

    Subdirectories are not included.

  4. Convert all .mcsa files with subdirectories to a specified directory:

    scfile **/*.mcsa -O path/to/dir

    With --output specified, directory structure is not duplicated.

๐Ÿ“š Library

Install

Pip

pip install sc-file -U

Manual

git clone [email protected]:onejeuu/sc-file.git
cd sc-file
poetry install

Usage

Simple

from scfile import convert

# Output path is optional.
# Defaults to source path with new suffix.
convert.mcsa_to_obj("path/to/model.mcsa", "path/to/model.obj")
convert.ol_to_dds("path/to/texture.ol", "path/to/texture.dds")
convert.mic_to_png("path/to/image.mic", "path/to/image.png")

# Skeleton support via MilkShape3D
convert.mcsa_to_ms3d("path/to/model.mcsa", "path/to/model.ms3d")
convert.mcsa_to_ms3d_ascii("path/to/model.mcsa", "path/to/model.txt")

# Or determinate it automatically
convert.auto("path/to/model.mcsa")

Advanced

  • Default
from scfile.file.data import ModelData
from scfile.file import McsaDecoder, ObjEncoder

mcsa = McsaDecoder("model.mcsa")
data: ModelData = mcsa.decode()
mcsa.close() # ? Necessary to close

obj = ObjEncoder(data)
obj.encode().save("model.obj") # ? Encoder closes after saving
  • Use encoded content bytes
obj = ObjEncoder(data)
obj.encode()

with open("model.obj", "wb") as fp:
    fp.write(obj.content)

obj.close() # ? Necessary to close
  • Use convert methods
mcsa = McsaDecoder("model.mcsa")
mcsa.convert_to(ObjEncoder).save("model.obj")
mcsa.close() # ? Necessary to close
mcsa = McsaDecoder("model.mcsa")
mcsa.to_obj().save("model.obj")
mcsa.close() # ? Necessary to close
  • Use context manager
with McsaDecoder("model.mcsa") as mcsa:
    data: ModelData = mcsa.decode()

with ObjEncoder(data) as obj:
    obj.encode().save("model.obj")
  • Use context manager + convert methods
with McsaDecoder("model.mcsa") as mcsa:
    obj = mcsa.convert_to(ObjEncoder)
    obj.close()
with McsaDecoder("model.mcsa") as mcsa:
    mcsa.to_obj().save("model.obj")

Important

When using convert_to buffer remains open.
close() or save() or another context (with) is necessary.

  • Save multiple copies
with McsaDecoder("model.mcsa") as mcsa:
    with mcsa.to_obj() as obj:
        obj.save_as("model_1.obj")
        obj.save_as("model_2.obj")

๐Ÿ› ๏ธ Build

Important

You will need poetry to do compilation.

Tip

Recommended to create virtual environment.

poetry shell

Then install dependencies:

poetry install

And run script to compile:

python scripts/build.py

Executable file will be created in /dist directory.

sc-file's People

Contributors

onejeuu avatar n1kodim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.