No project description provided
Project description
ssbh_data_py
Python bindings to the ssbh_data Rust library. ssbh_data_py provides a higher level abstraction over the binary data stored in SSBH files such as a "model.numshb". SSBH files can be created from scratch or modified from existing files entirely in Python.
Report bugs and request new features in issues. Check the requirements before reporting on any installation issues.
Supported Formats
Format | Supported Versions (major.minor) | Read | Save |
---|---|---|---|
Modl (.numdlb , .nusrcmdlb ) |
1.7 | :heavy_check_mark: | :heavy_check_mark: |
Mesh (.numshb ) |
1.8, 1.9, 1.10 | :heavy_check_mark: | :heavy_check_mark: |
Skel (.nusktb ) |
1.0 | :heavy_check_mark: | :heavy_check_mark: |
Anim (.nuanmb ) |
2.0, 2.1 | :heavy_check_mark: | :heavy_check_mark: (2.0 only) |
Matl (.numatb ) |
1.5, 1.6 | :heavy_check_mark: | :heavy_check_mark: |
Hlpb (.nuhlpb ) |
1.1 | :heavy_check_mark: | :heavy_check_mark: |
Adj (.adjb ) |
:heavy_check_mark: | :heavy_check_mark: | |
MeshEx (.numshexb ) |
:heavy_check_mark: | :heavy_check_mark: |
Installing
The package can be installed for a supported python version using pip
on the latest version of Windows, Linux, or MacOS. The prebuilt wheels (.whl
files) are included only for situations where pip
might not be available such as for plugin development for applications.
Installing: pip install ssbh_data_py
Updating: pip install ssbh_data_py --upgrade
The minimum supported pip version is 20.3.
Requirements
The package is available on PyPi for Python 3.7, 3.8, 3.9, and 3.10 for newer versions of Windows, Linux, and Mac OS. Apple Silicon support is currently only available for Python 3.9 and 3.10. For other Python versions, build ssbh_data_py from source.
Getting Started
Each supported SSBH type has an associated data struct that can be created reading from a file.
Some files like meshes support reading the data as numpy arrays. Enabling numpy support in the read functions substantially reduces the overhead of converting the file data to Python. This requires the numpy
package to be installed in the current Python environment when enabled.
import ssbh_data_py
mesh = ssbh_data_py.mesh_data.read_mesh("model.numshb", use_numpy=True)
modl = ssbh_data_py.modl_data.read_modl("model.numdlb")
skel = ssbh_data_py.skel_data.read_skel("model.nusktb")
It's also possible to construct new objects. Specify the major and minor version to use a particular file format revision. Note that this only impacts the binary output when calling the save method. Not all versions are supported, so it's recommended to use the default values.
mesh = ssbh_data_py.mesh_data.MeshData(major_version=1, minor_version=8)
modl = ssbh_data_py.modl_data.ModlData()
skel = ssbh_data_py.skel_data.SkelData()
ssbh_data_py uses standard Python types whenever possible. Conversion to the appropriate binary format is handled automatically on saving. For example, the 4x4 transformation matrix for bone data is simply a list of lists of floats.
for bone in skel.bones:
bone.transform[2][1] = 0.5
Standard Python operations will work, but lists should always have the same type for each element.
for bone in skel.bones:
# Create a 4x4 matrix of all 0's.
bone.transform = [[0.0] * 4] * 4
# Python allows this, but this will cause an exception when saving.
bone.transform = [0, 'abc', []]
# ssbh_data_py found an unexpected type, so this line will fail.
skel.save("skel.nustkb")
Numpy's ndarray
type is supported for fields and arguments that expect matrices or lists of floats or integers.
import numpy as np
# Assign the identity transform to each bone.
for bone in skel.bones:
bone.transform = np.eye((4))
# Convert the positions to a numpy array.
for o in mesh.objects:
o.positions[0].data = np.array(o.positions[0].data)
After making any changes, the results can be saved back to a file. Using the same path used to read the files will overwrite the file. Even if no edits are made, the resulting file will likely not be binary identical with the original due to floating point rounding errors or the use of different algorithms. Numpy arrays use a faster exporting code path compared to Python lists or tuples. Using numpy arrays mainly benefits export time for larger lists like mesh vertex attributes. This works the best when the data is already a numpy array since converting from lists may be slow.
mesh.save("model_new.numshb")
modl.save("model_new.numdlb")
skel.save("model_new.nusktb")
Documentation
The Python API is best summarized by the type stub (.pyi) files, which can be found here. The Python API matches the underlying Rust types and functions as closely as possible. The Rust documentation has much more detailed documentation and can be found at https://docs.rs/ssbh_data. For more advanced sample Python scripts, see the examples.
Building
Requires a recent version of Rust. The builds published to PyPi are built using Maturin. Aftering succesfully installing Maturin, running maturin develop
or maturin develop --release
will build and install the module into the current virtual environment.
maturin build --release
builds the ssbh_data_py
module that can be imported into Python. The resulting binary can only be used with the current Python version, processor type, and operating system. Rename the .dll
to .pyd
on Windows and the .dylib
to .so
on Linux or MacOS.
If the import fails, check that the .pyd
or .so
file exists in the appropriate location. Importing may also fail if ssbh_data_py
was built from source for an operating system or Python interpreter version that isn't compatible with the current Python environment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file ssbh_data_py-0.8.4-cp312-none-win_amd64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp312-none-win_amd64.whl
- Upload date:
- Size: 816.5 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34031c46b86b4303b0cae269e81045557cdc082f1c08aaf6e6f1fa7dbbd6ad2f |
|
MD5 | adfa3bc8d91be46dce2fffbe140f3444 |
|
BLAKE2b-256 | 8e73fa5af79c08e4b7cc893ff89f9ba96fbff845cc9d2904d67e20c6aac3ef33 |
File details
Details for the file ssbh_data_py-0.8.4-cp312-cp312-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 756b4905646a082f2c72a516b462feab1d2fa28b216c32dcc9a79a054684a854 |
|
MD5 | c0a21072eae6db56c9a8487cb24cada9 |
|
BLAKE2b-256 | 21178590207f1d80aaa7d86559467e1f730788dd01e34843a8c540bb83c8ba14 |
File details
Details for the file ssbh_data_py-0.8.4-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 793.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55e2e7dcd4bfca36ec854ade1ac307f929f7cefe2f9337257fcdf9d7b52af5cf |
|
MD5 | 9145a49940dc3176cea0616c79b56432 |
|
BLAKE2b-256 | 2491cde8e70658f4a5676bf91b5dc0b012537a1747c257f23c6da89da4937622 |
File details
Details for the file ssbh_data_py-0.8.4-cp312-cp312-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 842.6 kB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93ffa1c7c51e2cb19146c88b82a5717a97267a7d7469cb0b399252c0386a5756 |
|
MD5 | 66c9170c4ece981f85e7786d711b2b3c |
|
BLAKE2b-256 | 64802dfa88544557f32de04493d7c0b647d6c9180dc8c1042ea1449c17403e34 |
File details
Details for the file ssbh_data_py-0.8.4-cp311-none-win_amd64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp311-none-win_amd64.whl
- Upload date:
- Size: 816.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4457e23950f99489ca6c9fcd9651d2f8d6f6d7ac4b7d6fa379e8c9a889c326f |
|
MD5 | 977e61b2edb2eb6f903e396570fc7a79 |
|
BLAKE2b-256 | 013c48fe98fd3060d6b42dcd0fc8f81b37b1bdb8b20a993ef1555c4753fce7f8 |
File details
Details for the file ssbh_data_py-0.8.4-cp311-cp311-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp311-cp311-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51fd81cb55f9e9d09a97bc98897153d67b2668f3a809e33f71346a632597281c |
|
MD5 | 60b2c397e6685637081ad9a7cc98559b |
|
BLAKE2b-256 | 6887f3eff1f5a34cbe83df95d5bcbeb06a3e727ac67f8e98a6d8da108a2db126 |
File details
Details for the file ssbh_data_py-0.8.4-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 800.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ee26608a720f72e63c09b4baefc28421eda33555dfbc6b54e803fe7dc5bdf70 |
|
MD5 | d9520a4573ef6acc6552230fe7795611 |
|
BLAKE2b-256 | 5c4591fe29c3179ea2c80df802490a0b1619a27f40613d7463ce26a658794392 |
File details
Details for the file ssbh_data_py-0.8.4-cp311-cp311-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 860.8 kB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59ab9b49894c1e5500bd80a6e859d0fc01893da1d2a974c5ac0bda4248c1c6c1 |
|
MD5 | 3c316667a975adf0c448f922f0d28452 |
|
BLAKE2b-256 | f8e5f3e65a1d02af0a49aaee2e487e236a5d304c3f2b57787d77b7fa9872b8fe |
File details
Details for the file ssbh_data_py-0.8.4-cp310-none-win_amd64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp310-none-win_amd64.whl
- Upload date:
- Size: 814.4 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 750444a101eda0948b83925f349945aff20f9a49864f0b55ae862ebe0322b290 |
|
MD5 | 258b3acbb0a79c5f5c21dd5465d5ff6e |
|
BLAKE2b-256 | 095ab43f3721c89618cf6285f8e6a9f5a0b25ae6e564b0860b4c9bd8eb6cf8be |
File details
Details for the file ssbh_data_py-0.8.4-cp310-cp310-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp310-cp310-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eb8be1381059050a70c77d7ac1f40d88f9d7bb78b351cca43137a798c4a99d6 |
|
MD5 | 2d0b4d6d2460075158b952f2b633c5f0 |
|
BLAKE2b-256 | c9671f924accf4f6249d2f3f4b020aaa18277e884023bb84bdd5c4508f3b8ac0 |
File details
Details for the file ssbh_data_py-0.8.4-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 800.8 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5001dd1b007e0b5c551a358c82ca10b4b1052a2d6dd49a7fa365be7401d6b6a |
|
MD5 | a21a8e7a0b916433fc9a012d22ce0d28 |
|
BLAKE2b-256 | f18c3ac1480b47cec612efa0687c7a9a048a799cd9250bc25c17b852c4e3b73c |
File details
Details for the file ssbh_data_py-0.8.4-cp310-cp310-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp310-cp310-macosx_10_12_x86_64.whl
- Upload date:
- Size: 860.6 kB
- Tags: CPython 3.10, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b018d1156dd82eb6678208810d46489d54f17a69532baf9d8e8e1a25326c2ab |
|
MD5 | 6ef3a69938e7f52a6d8c4ad615af20fe |
|
BLAKE2b-256 | 641c419b2dc86b85cb785b3355c387acfe1ebb4d8333471d5cc946d25d59afdc |
File details
Details for the file ssbh_data_py-0.8.4-cp39-none-win_amd64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp39-none-win_amd64.whl
- Upload date:
- Size: 814.5 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bd918e07d0a261567295f753cd16f227e862ea9b5e09e42e571e406c9d4bcef |
|
MD5 | 7c44e21f6e84add09f71aa9d7454edd5 |
|
BLAKE2b-256 | 0dd9e5f0c09ef53487629c30e975023c69d33fd958d45cfaa91c4a63d921bf42 |
File details
Details for the file ssbh_data_py-0.8.4-cp39-cp39-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp39-cp39-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | edd8f8b400904ba427ac6f3d8ba34b7e74a63b8b0593ea1a1f17da1546df0f46 |
|
MD5 | d13323896f2557cd7838fc7980b42740 |
|
BLAKE2b-256 | e0e3b60980ade6cde968babf1c71dbd87b3c94edd8d31effcbaea39dbb5d036e |
File details
Details for the file ssbh_data_py-0.8.4-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 800.9 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e73de6d20452a080c8e36cd944617f57e571e1bded74a01c9784e26d462e958 |
|
MD5 | dd534938002f34c21cc87b311c399cab |
|
BLAKE2b-256 | 03e8eba970b6af90500cff6613f0e8e2720a2516ef6d832635d27343e1ddca4e |
File details
Details for the file ssbh_data_py-0.8.4-cp39-cp39-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp39-cp39-macosx_10_12_x86_64.whl
- Upload date:
- Size: 860.6 kB
- Tags: CPython 3.9, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6537cfd4812a40655e4d04ae9b415cd42122d18fbf3babe4da1c42bf99ba276f |
|
MD5 | 631fe21a42c98c061ca6a6af14559ba1 |
|
BLAKE2b-256 | 5f8ac69c924eca587867070574b21c05a48656a5f87a025289a055cfc952d13a |
File details
Details for the file ssbh_data_py-0.8.4-cp38-none-win_amd64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp38-none-win_amd64.whl
- Upload date:
- Size: 814.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 552a48e550fc0ff96077a158e94387bfb271c7d23ac9b42c04379527cf1d17c3 |
|
MD5 | a5ee05ff1126f22b68feb5236535333a |
|
BLAKE2b-256 | b606c660ce27f36dd5e14fb91c0568fce76e1dda27c0dae51afd9ae59a91331a |
File details
Details for the file ssbh_data_py-0.8.4-cp38-cp38-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp38-cp38-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f38c3dd38f7cfc7c65b8826acc1d4087c3c3f167e796e1c012aa8b245e66c89 |
|
MD5 | ff32f79eef609e386c5ec0fa6a2c6a3d |
|
BLAKE2b-256 | 83d54b9f671fba1185a9a7249d01a8f571b2a8bfc2f6a31f6ee00305977a597c |
File details
Details for the file ssbh_data_py-0.8.4-cp37-none-win_amd64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp37-none-win_amd64.whl
- Upload date:
- Size: 814.9 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb3033eb721f40b744e41f101a7702484db37d1f2b1ee0493882edcdd3e2c3ab |
|
MD5 | e09557b800ddfd7cb983dd86f5fa0025 |
|
BLAKE2b-256 | eedfb347f447de0dd289c11e352d065a7de977d73097a3a62822d94c27c68973 |
File details
Details for the file ssbh_data_py-0.8.4-cp37-cp37m-manylinux_2_34_x86_64.whl
.
File metadata
- Download URL: ssbh_data_py-0.8.4-cp37-cp37m-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7m, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79ec7f6131a2bf2ba6c9ac7d750ade273134f970af89f6dc18ed260f13889c37 |
|
MD5 | 6cc88cc9fb9eadb372c4673cf5f4ae72 |
|
BLAKE2b-256 | 7e6ee0299cb07069d2690e44eae2db06071cbb36949085f3b111216c0ecd6113 |