🧊 MCSA#

MCSA Format.

Name:

Scene Assets

Type:

🧊 Model Decoder

Wiki:

https://sc-file.rtfd.io/formats.html

Suffix:

.mcsa

Support:

βœ… Full

Features:

Geometry, Skeleton, Animation

Example:

from scfile import formats

with formats.mcsa.McsaDecoder("model.mcsa") as mcsa:
    data = mcsa.decode()

Decoder#

class MeshCounts(vertices=0, polygons=0, max_influences=0, local_bones=0, blend_shapes=0)[source]#
vertices: int = 0#
polygons: int = 0#
max_influences: int = 0#
local_bones: int = 0#
blend_shapes: int = 0#
class McsaDecoder(stream, options=None)[source]#

Bases: FileDecoder[ModelContent], McsaFileIO

format: FileFormat = 'mcsa'#

Associated file format.

signature: Optional[bytes] = b'MCSA'#

Expected file signature.

order: ByteOrder = '<'#

Default byte order for pack/unpack operations.

as_obj()[source]#
as_glb()[source]#
as_fbx()[source]#
as_dae()[source]#
as_ms3d()[source]#
parse()[source]#

Parse file content into self.data. Called by decode().

close()#

Flush and close the IO object.

This method has no effect if the file is already closed.

Return type:

None

property closed: bool#
convert(encoder, options=None, output=None)#

Decode and convert to given encoder format.

Parameters:
  • encoder (Type[TypeVar(EncoderType, bound= FileEncoder)]) – Encoder class to use for conversion.

  • options (optional) – Shared handlers options.

  • output (optional) – File path or binary IO stream. Defaults to in-memory buffer.

Return type:

bytes

Returns:

Encoded file content as bytes.

convert_to(encoder, options=None, output=None)#

Decode and convert to given encoder format.

Parameters:
  • encoder (Type[TypeVar(EncoderType, bound= FileEncoder)]) – Encoder class to use for conversion.

  • options (optional) – Shared handlers options.

  • output (optional) – File path or binary IO stream. Defaults to in-memory buffer.

Return type:

TypeVar(EncoderType, bound= FileEncoder)

Returns:

Clear encoder instance.

decode(seek=True)#

Runs decoding pipeline.

Parameters:

seek (bool) – Reset stream position to the beginning after parsing.

Return type:

TypeVar(ContentType, bound= BaseContent)

Returns:

Parsed content data.

fileno()#

Returns underlying file descriptor if one exists.

OSError is raised if the IO object does not use a file descriptor.

flush()#

Flush write buffers, if applicable.

This is not implemented for read-only and non-blocking streams.

Return type:

None

getvalue()#
Return type:

bytes

is_eof()#
Return type:

bool

isatty()#

Return whether this is an β€˜interactive’ stream.

Return False if it can’t be determined.

property location: str#
prelude()#

Hook called before signature and parsing.

Return type:

None

read(size=-1)#
Return type:

bytes

readable()#

Return whether object was opened for reading.

If False, read() will raise OSError.

Return type:

bool

readline(size=-1, /)#

Read and return a line from the stream.

If size is specified, at most size bytes will be read.

The line terminator is always b’n’ for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.

readlines(hint=-1, /)#

Return a list of lines from the stream.

hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

seek(pos, whence=0)#

Change the stream position to the given byte offset.

offset

The stream position, relative to β€˜whence’.

whence

The relative position to seek from.

The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • os.SEEK_SET or 0 – start of stream (the default); offset should be zero or positive

  • os.SEEK_CUR or 1 – current stream position; offset may be negative

  • os.SEEK_END or 2 – end of stream; offset is usually negative

Return the new absolute position.

Return type:

int

seekable()#

Return whether object supports random access.

If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().

Return type:

bool

size()#
Return type:

int

skip(size)#
property suffix: str#
tell()#

Return current stream position.

Return type:

int

truncate()#

Truncate file to size bytes.

File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.

unicode_errors: str = 'replace'#

Error handling mode for UTF-8 encoding/decoding.

validate_signature()#

Validate file signature.

Raises:

EmptyFileError –

Return type:

None

writable()#

Return whether object was opened for writing.

If False, write() will raise OSError.

Return type:

bool

write(data)#
Return type:

int

writelines(lines, /)#

Write a list of lines to stream.

Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.

options: Options#

Shared handlers options.

ctx: TempContext#

IO#

Extensions for MCSA file format with custom struct-based I/O methods.

class McsaFileIO[source]#

Bases: StructIO

Versions#

SUPPORTED_VERSIONS: list[float] = [7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 15.0]#

Supported MCSA format versions.

VERSION_MAP: dict[float, list[Flag]] = {7.0: [Flag.SKELETON, Flag.UV, Flag.NORMALS, Flag.COLORS], 8.0: [Flag.SKELETON, Flag.UV, Flag.NORMALS, Flag.TANGENTS, Flag.COLORS], 9.0: [Flag.SKELETON, Flag.UV, Flag.UV2, Flag.NORMALS, Flag.TANGENTS, Flag.COLORS]}#

Mapping of MCSA versions to feature flags (version floor semantics).

Constants#

class McsaUnits[source]#

MCSA structures elements count.

POSITIONS = 4#
TEXTURES = 2#
NORMALS = 4#
TANGENTS = 4#
TRIANGLES = 3#
QUADS = 4#
BONES = 6#
FRAMES = 7#

Exceptions#

exception McsaDecodingError(location)[source]#

Bases: FileError, DecodingError

Base exception for MCSA model related errors.

prefix#
exception McsaCountsLimit(location, type, count)[source]#

Bases: McsaDecodingError, ParsingError

Raised when model exceeds allowed geometry limits (vertices/polygons count).

type: str#
count: int#
exception McsaVersionUnsupported(location, version)[source]#

Bases: McsaDecodingError, UnsupportedError

Raised when attempting to parse unsupported model version.

version: float#