FCE decoder/encoder
Project description
fcecodec - Python extension module
This file describes installation and usage of fcecodec
as Python extension
module.
Installation
Requires Python 3.10+
python -m pip install fcecodec
Though numpy
is not required, it is recommended
python -m pip install --upgrade numpy
Examples
For a script template and handy function wrappers, see https://github.com/bfut/fcecodec/blob/main/scripts/fcecodecScriptTemplate.py and https://github.com/bfut/fcecodec/blob/main/python/bfut_mywrappers.py
import fcecodec as fc
filepath_fce_input = "path/to/car_src.fce"
filepath_fce_input2 = "path/to/car_src2.fce"
filepath_fce_output = "path/to/car.fce"
with open(filepath_fce_input, "rb") as f:
fce_buf = f.read()
# Print FCE stats
fc.PrintFceInfo(fce_buf)
# Create Mesh object
mesh = fc.Mesh()
# Load FCE data to Mesh object
mesh.IoDecode(fce_buf)
# Print Mesh object stats
mesh.PrintInfo()
print(mesh.MNumParts)
print(mesh.MNumTriags)
print(mesh.MNumVerts)
# Validate Mesh object
assert mesh.MValid() == 1
# Merge parts 0, 3 to new part
new_pid = mesh.OpMergeParts(0, 3)
assert new_pid != -1
# Copy part 1
new_pid = mesh.OpCopyPart(1)
assert new_pid != -1
# Insert/copy part 1 from mesh2 to mesh
with open(filepath_fce_input2, "rb") as f:
fce_buf2 = f.read()
mesh2 = fc.Mesh()
mesh2.IoDecode(fce_buf2)
new_pid = mesh.OpInsertPart(mesh2, 1)
assert new_pid != -1
# Encode to FCE4
out_buf = mesh.IoEncode_Fce4()
with open(filepath_fce_output, "wb") as f:
f.write(out_buf)
Documentation
Help on module fcecodec:
NAME
fcecodec - FCE decoder/encoder
CLASSES
pybind11_builtins.pybind11_object(builtins.object)
Mesh
class Mesh(pybind11_builtins.pybind11_object)
| Method resolution order:
| Mesh
| pybind11_builtins.pybind11_object
| builtins.object
|
| Methods defined here:
|
| IoDecode(...)
| IoDecode(self: fcecodec.Mesh, arg0: str) -> None
|
| IoEncode_Fce3(...)
| IoEncode_Fce3(self: fcecodec.Mesh, center_parts: bool = True) -> bytes
|
| IoEncode_Fce4(...)
| IoEncode_Fce4(self: fcecodec.Mesh, center_parts: bool = True) -> bytes
|
| IoEncode_Fce4M(...)
| IoEncode_Fce4M(self: fcecodec.Mesh, center_parts: bool = True) -> bytes
|
| IoExportObj(...)
| IoExportObj(self: fcecodec.Mesh, objpath: str, mtlpath: str, texname: str, print_damage: int = 0, print_dummies: int = 0, use_part_positions: int = 1, print_part_positions: int = 0) -> None
|
| IoGeomDataToNewPart(...)
| IoGeomDataToNewPart(self: fcecodec.Mesh, vert_idxs: numpy.ndarray[numpy.int32], vert_texcoords: numpy.ndarray[numpy.float32], vert_pos: numpy.ndarray[numpy.float32], normals: numpy.ndarray[numpy.float32]) -> int
|
| vert_idxs: 012..., vert_texcoords: uuuvvv... , vert_pos: xyzxyzxyz..., normals: xyzxyzxyz...
|
| MGetColors(...)
| MGetColors(self: fcecodec.Mesh) -> Buffer
|
| MGetDummyNames(...)
| MGetDummyNames(self: fcecodec.Mesh) -> list[str]
|
| MGetDummyPos(...)
| MGetDummyPos(self: fcecodec.Mesh) -> Buffer
|
| MSetColors(...)
| MSetColors(self: fcecodec.Mesh, colors: numpy.ndarray[numpy.uint8]) -> None
|
| Expects shape=(N, 4, 4)
|
| MSetDummyNames(...)
| MSetDummyNames(self: fcecodec.Mesh, names: list[str]) -> None
|
| MSetDummyPos(...)
| MSetDummyPos(self: fcecodec.Mesh, positions: numpy.ndarray[numpy.float32]) -> None
|
| Expects shape (N*3, ) for N dummies
|
| MValid(...)
| MValid(self: fcecodec.Mesh) -> bool
|
| OpAddHelperPart(...)
| OpAddHelperPart(self: fcecodec.Mesh, name: str, new_center: numpy.ndarray[numpy.float32] = [0.0, 0.0, 0.0]) -> int
|
| Add diamond-shaped part at coordinate origin or at optionally given position.
|
| OpCenterPart(...)
| OpCenterPart(self: fcecodec.Mesh, pid: int) -> bool
|
| Center specified part to local centroid. Does not move part w.r.t. to global coordinates.
|
| OpCopyPart(...)
| OpCopyPart(self: fcecodec.Mesh, pid_src: int) -> int
|
| Copy specified part. Returns new part index.
|
| OpDelUnrefdVerts(...)
| OpDelUnrefdVerts(self: fcecodec.Mesh) -> bool
|
| Delete all vertices that are not referenced by any triangle. This is a very expensive operation. Unreferenced vertices occur after triangles are deleted or they are otherwise present in data.
|
| OpDeletePart(...)
| OpDeletePart(self: fcecodec.Mesh, pid: int) -> bool
|
| OpDeletePartTriags(...)
| OpDeletePartTriags(self: fcecodec.Mesh, pid: int, idxs: list[int]) -> bool
|
| OpInsertPart(...)
| OpInsertPart(self: fcecodec.Mesh, mesh_src: fcecodec.Mesh, pid_src: int) -> int
|
| Insert (copy) specified part from mesh_src. Returns new part index.
|
| OpMergeParts(...)
| OpMergeParts(self: fcecodec.Mesh, pid1: int, pid2: int) -> int
|
| Returns new part index.
|
| OpMovePart(...)
| OpMovePart(self: fcecodec.Mesh, pid: int) -> int
|
| Move up specified part towards order 0. Returns new part index.
|
| OpSetPartCenter(...)
| OpSetPartCenter(self: fcecodec.Mesh, pid: int, new_center: numpy.ndarray[numpy.float32]) -> bool
|
| Center specified part to given position. Does not move part w.r.t. to global coordinates.
|
| PGetName(...)
| PGetName(self: fcecodec.Mesh, pid: int) -> str
|
| PGetPos(...)
| PGetPos(self: fcecodec.Mesh, pid: int) -> Buffer
|
| PGetTriagsFlags(...)
| PGetTriagsFlags(self: fcecodec.Mesh, pid: int) -> Buffer
|
| PGetTriagsTexcoords(...)
| PGetTriagsTexcoords(self: fcecodec.Mesh, pid: int) -> Buffer
|
| uuuvvv..., Returns (N*6, ) numpy array for N triangles.
|
| PGetTriagsTexpages(...)
| PGetTriagsTexpages(self: fcecodec.Mesh, pid: int) -> Buffer
|
| PGetTriagsVidx(...)
| PGetTriagsVidx(self: fcecodec.Mesh, pid: int) -> Buffer
|
| Returns (N*3, ) numpy array of global vert indexes for N triangles.
|
| PNumTriags(...)
| PNumTriags(self: fcecodec.Mesh, pid: int) -> int
|
| PNumVerts(...)
| PNumVerts(self: fcecodec.Mesh, pid: int) -> int
|
| PSetName(...)
| PSetName(self: fcecodec.Mesh, pid: int, name: str) -> None
|
| PSetPos(...)
| PSetPos(self: fcecodec.Mesh, pid: int, pos: numpy.ndarray[numpy.float32]) -> None
|
| PSetTriagsFlags(...)
| PSetTriagsFlags(self: fcecodec.Mesh, pid: int, arr: numpy.ndarray[numpy.int32]) -> None
|
| Expects (N, ) numpy array for N triangles
|
| PSetTriagsTexcoords(...)
| PSetTriagsTexcoords(self: fcecodec.Mesh, pid: int, arr: numpy.ndarray[numpy.float32]) -> None
|
| arr: uuuvvv..., Expects (N*6, ) numpy array for N triangles.
|
| PSetTriagsTexpages(...)
| PSetTriagsTexpages(self: fcecodec.Mesh, pid: int, arr: numpy.ndarray[numpy.int32]) -> None
|
| Expects (N, ) numpy array for N triangles
|
| PrintInfo(...)
| PrintInfo(self: fcecodec.Mesh) -> None
|
| PrintParts(...)
| PrintParts(self: fcecodec.Mesh) -> None
|
| PrintTriags(...)
| PrintTriags(self: fcecodec.Mesh) -> None
|
| PrintVerts(...)
| PrintVerts(self: fcecodec.Mesh) -> None
|
| __buffer__(self, flags, /)
| Return a buffer object that exposes the underlying memory of the object.
|
| __init__(...)
| __init__(self: fcecodec.Mesh) -> None
|
| __release_buffer__(self, buffer, /)
| Release the buffer object that exposes the underlying memory of the object.
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| MNumParts
|
| MNumTriags
|
| MNumVerts
|
| MVertsGetMap_idx2order
| Maps from global vert indexes (contained in triangles) to global vertex order.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| MNumArts
| Usually equal to 1. Larger values enable multi-texture access for cop#.fce (police officer models), road objects, etc. Also used in the FCE4M format.
|
| MUnknown3
| FCE4M only. Unknown purpose.
|
| MVertsAnimation
| Returns (N, ) numpy array for N vertices.
|
| MVertsDamgdNorms
| Returns (N*3, ) numpy array for N vertices.
|
| MVertsDamgdPos
| Local vertice positions. Returns (N*3, ) numpy array for N vertices.
|
| MVertsNorms
| Returns (N*3, ) numpy array for N vertices.
|
| MVertsPos
| Local vertice positions. Returns (N*3, ) numpy array for N vertices.
|
| ----------------------------------------------------------------------
| Static methods inherited from pybind11_builtins.pybind11_object:
|
| __new__(*args, **kwargs) from pybind11_builtins.pybind11_type
| Create and return a new object. See help(type) for accurate signature.
FUNCTIONS
GetFceVersion(...) method of builtins.PyCapsule instance
GetFceVersion(buf: str) -> int
Returns 3 (FCE3), 4 (FCE4), 5 (FCE4M), negative (invalid)
PrintFceInfo(...) method of builtins.PyCapsule instance
PrintFceInfo(buf: str) -> None
ValidateFce(...) method of builtins.PyCapsule instance
ValidateFce(buf: str) -> int
Returns 1 for valid FCE data, 0 otherwise.
VERSION
1.5
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 Distribution
fcecodec-1.5.tar.gz
(44.9 kB
view hashes)
Built Distributions
fcecodec-1.5-cp312-cp312-win32.whl
(113.6 kB
view hashes)
fcecodec-1.5-cp311-cp311-win32.whl
(113.6 kB
view hashes)
fcecodec-1.5-cp310-cp310-win32.whl
(112.5 kB
view hashes)
Close
Hashes for fcecodec-1.5-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cd1f09f53dc305c1bc9357b58a4d4364040b0561455cd9665b5f82ae0a95acb |
|
MD5 | c0ab982c00af614086a36f91ea04ab4a |
|
BLAKE2b-256 | f73a4c8838235ba3f13d511151fbcfad9a6b12572d82ff43cd4b03011e312d21 |
Close
Hashes for fcecodec-1.5-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a95668b47d15242bb1c427475776b0c0eaf4c9bb3803456494e8c5998ffaa10 |
|
MD5 | 99933ab98af8321587fdc4359404af50 |
|
BLAKE2b-256 | 4bb1f3fb960cd4dd4d7aa4f80ac72b1828fc70c036387d9ad48584cea7982e61 |
Close
Hashes for fcecodec-1.5-cp312-cp312-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c14382c351be1d2cf826f28dce88c17db411f9385b71304977b010989c96d0f |
|
MD5 | 7bb9edb8c0c4d7cebcc158681e248d10 |
|
BLAKE2b-256 | 182ea3926e70408b9ad9231827948234c93e88576730fa1ec26ae2ae9e5ab9d7 |
Close
Hashes for fcecodec-1.5-cp312-cp312-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abe684f29a6b0a3369e3ef694675f948542ac7d4ac31ae5fe203243e474a8d74 |
|
MD5 | 5784763e75f19f8c4237a67da22a054f |
|
BLAKE2b-256 | 75ab968c5f34c404d1408d2b142631c0cd010afda0c698010f7fb520ce6a73ad |
Close
Hashes for fcecodec-1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d0d0380dd630c5a0b64b2f964199e12c0094892819c33bee183ebae977e06b0 |
|
MD5 | 19f049b1967805ca4456b492f91c8647 |
|
BLAKE2b-256 | 522d8647198c07f8b713f678bcafae04bd5dc7b09d2e1c0292193ff80ad9b676 |
Close
Hashes for fcecodec-1.5-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab2f45fe45f35295e5857ba82f59ed73787afeb345f2589f26eddfb69cebbadf |
|
MD5 | ec048b40d0166a62f5e00175aaa6678d |
|
BLAKE2b-256 | 510238a593bc9dc9aa05679db5b22132ecfb09ebf300553dcbcd74eccd35e3df |
Close
Hashes for fcecodec-1.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 230c496f887bcad8b482f960edc43c54e7db6bdfe60114970e366302e505b484 |
|
MD5 | 79dfa0c658f88afb2ddf51e01cd7e679 |
|
BLAKE2b-256 | e4e9210d6f31e5c66b210fa4d93d70db359c15f1d86f3aa514c1d42ba3dd03a5 |
Close
Hashes for fcecodec-1.5-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e953cc7339a92cbc85bce850652bfb4c669e0e8d31bf08540818c990594843e2 |
|
MD5 | f2c3823574d1b3a9848fbd67055a2ef6 |
|
BLAKE2b-256 | 5ce3fbe46c667e29a53dfb2c57d396e87ca7e4090bd9960375e944f146d384de |
Close
Hashes for fcecodec-1.5-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c621b6b76cfa58901e2bb8173cabd0cd83921bc68bfeafdfcd554b45a6dc3726 |
|
MD5 | 104b041699b1453a17ff9d58571ff7c2 |
|
BLAKE2b-256 | 04f4a3bd1ea1385776faffe63898c8f8e48f240f61ca41e8f9254a278eda2a70 |
Close
Hashes for fcecodec-1.5-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f751144359c76ea0f6e91eefd4373f604b0d83925599f7299753ec8d6892c526 |
|
MD5 | 346e147e638f88ad59ba30ac6686b615 |
|
BLAKE2b-256 | cc87e636f76a68659e35de0ed66097e83a662e12c837cf1b5aa0282e1fd12e08 |
Close
Hashes for fcecodec-1.5-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f2d534083c3a214f525145df5ffc4b3e89824d073fd63761faa7d8623badf4d |
|
MD5 | faa7d2f0fc28696dc8d52fdf15d1d595 |
|
BLAKE2b-256 | 6e78e85e57b2cd1770348cdfb243548f10e821657e9d3c03cbd8a0eb5001845f |
Close
Hashes for fcecodec-1.5-cp311-cp311-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8249ef4657cd0bf51459fe0941eee1f3f098aaa70fb5fcfffb05d0b89e36d67f |
|
MD5 | 03a81982d7b661da3cdcddc0cb4d47eb |
|
BLAKE2b-256 | 74e38b8d36fd0c39d50b557fdb8e95c6daac43f7bf40dbb696481fb3293ef524 |
Close
Hashes for fcecodec-1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77e08588f996259127e6fe470c60c22aab90f00f5da5715aa9324591f1491ede |
|
MD5 | a057da315563da44bb5c68c4c0328f29 |
|
BLAKE2b-256 | 3dc9e4455a8fa1e3b551d23415d25ab93a77d6cb232aec4976b8800f5a9fa35a |
Close
Hashes for fcecodec-1.5-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24a5652936fbed3ebb35b96934e865c89174f233d34c4ffd4a73fba7e9cada36 |
|
MD5 | 7a57354d30c812412cc1c6598525364d |
|
BLAKE2b-256 | 20aa7f40ce7e6a1ef7c84f4e9ac172586923c7e91e709d24587bb757c7ba0dc3 |
Close
Hashes for fcecodec-1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d50e5f9398fefb900023a879355ea638b52e84f587bcbd500843ecd09b11e26 |
|
MD5 | 7b23fc27dd4af24c93a10539a1889d29 |
|
BLAKE2b-256 | 5499b5574a50032de5dd8cc5ec9343e7fe8eab5d15b30bf344abc48f13989752 |
Close
Hashes for fcecodec-1.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24a9ac88a6cccfe3f24a2c038d82a4c2ff118267f694017aff70ded7f68bdfb6 |
|
MD5 | 325b76c4660952cbb2b899735dfad718 |
|
BLAKE2b-256 | 542dbc865dad2c7675da5ca8fda39580999c3c729ee2f92720a1b34dd0b6f7bc |
Close
Hashes for fcecodec-1.5-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a92cad9ee2d90be2b16976dc4737839e5b2beb4e6b2a9385303d12654a60438 |
|
MD5 | 20b25f4d2a2dccba541e00e7cecb7028 |
|
BLAKE2b-256 | f1717a3e6cce6babcb26800356ba59df770c7a87c7e7ff4d65c233dd949dda6f |
Close
Hashes for fcecodec-1.5-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 384f05eb219db492e49ac108335805e78d2bbb5968b3bc6d596268f294e44980 |
|
MD5 | 0aec2a3bdd34c0bae78ecb205153bb0d |
|
BLAKE2b-256 | dc9d7c2b6856045d60e94df28eb92f509d75c8053c46d737d7525670066fcc97 |
Close
Hashes for fcecodec-1.5-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a99476f1ceb605518600ab757d1bf30a3888b48a77a942b538efbe943f2436c |
|
MD5 | 6a24a03f75295c6ca1282ed8630ae44e |
|
BLAKE2b-256 | efbda6ee9eb61cca79127b22b676d165edfc2c1033702fff97eed1a7c6f8a547 |
Close
Hashes for fcecodec-1.5-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03b342b3772cb064f66ae8757f3046a95688cdbbfe9f297a7fa6b64d7a917933 |
|
MD5 | ac8ff88380940775a55a7e171209ccc8 |
|
BLAKE2b-256 | d520bf31100e9bf849953a44d15cdbbb58ad5491fb996ca5e609ce2e1daf33ed |
Close
Hashes for fcecodec-1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82908dbc3cfcb14720d4faa3060f445741fd9ab648a8ee1cc72d1fa8d22bb929 |
|
MD5 | 5ecb71db17bc72489379adeffe9827e4 |
|
BLAKE2b-256 | 92234a5e8cddbea16fdea943381ba000a21b4569eaaae1795d0cf25b561ae71e |
Close
Hashes for fcecodec-1.5-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0975d6ae7ad0e348721d05eb319eca6e7fbba4296273754b7ebf4412e74b15f9 |
|
MD5 | c9c442ab1e6561c89bed16ceb2161f9e |
|
BLAKE2b-256 | 20150b50c509207f9e84ca4045a27a2914184ce7eee23581f2613fa69b8e961d |
Close
Hashes for fcecodec-1.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44013e4d1e5075915e413a04b99b8c485042cf80d257f88297d99966d651346d |
|
MD5 | fafea5ffa670e65fe1d7d4cabde4fd76 |
|
BLAKE2b-256 | b2d8156b0c252c9c88c3211370facb0650c006dfc3b3a48eed2b2deb8c090343 |
Close
Hashes for fcecodec-1.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c42086a15e7f58974702907147340c68a137969cb6fa8b14f0ed5982a2232fcf |
|
MD5 | be0f5b1d86e69552a25d7e94c3087ba3 |
|
BLAKE2b-256 | 4c99164c754ca75f344e26aa6c4faaf34bac25263de2c2639bd8757828901c50 |