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.fce"
filepath_fce_input2 = "path/to/another/car.fce"
filepath_fce_output = "path/to/output/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, filter_triagflags_0xfff: int = 1) -> 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.6
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.6.tar.gz
(44.9 kB
view hashes)
Built Distributions
fcecodec-1.6-cp312-cp312-win32.whl
(114.4 kB
view hashes)
fcecodec-1.6-cp311-cp311-win32.whl
(114.3 kB
view hashes)
fcecodec-1.6-cp310-cp310-win32.whl
(113.1 kB
view hashes)
Close
Hashes for fcecodec-1.6-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0512b2ff6f59ace00eb4c3eed28a273464b523b3dbfa6cf3518ce8d6b41196f |
|
MD5 | 0af643c58158545fefc4582a42687b5b |
|
BLAKE2b-256 | d663c878c9c5f53e10c00367930dea78a791a24729172b79bf8806dfcbf84942 |
Close
Hashes for fcecodec-1.6-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48473ee90dd38ad8f78a3788743d1fe88fa222d1c9f2629cd09682a4846789ab |
|
MD5 | 783a45e289959d1a2cafad1a8f94d0ff |
|
BLAKE2b-256 | dc8eafc25bb2339a3659488dd82ed668b3ba65a9618fff22f4b7ea2095f3d13c |
Close
Hashes for fcecodec-1.6-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41115f9188e511c73fcd943bd1934b6fb4aef7242bcfe2c6ab7a0c3e50681784 |
|
MD5 | 0d8789753d6c3362eae806062b19d843 |
|
BLAKE2b-256 | a537c21d5e1eeaf538aa4873344a24caf33c316990de1266fe1479d1d413117a |
Close
Hashes for fcecodec-1.6-cp312-cp312-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3ac9ddf3195a64293794a966f07f43ac5289204e3c488bc526bbcf93e17e6b8 |
|
MD5 | b30e5f061f495cbd346e545099ba8075 |
|
BLAKE2b-256 | f6310195cffbc853376d7c1a3e77c9199e9344c3edd4c32139819cc898322618 |
Close
Hashes for fcecodec-1.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 588f1ebf8b309d4fa051ebdf79318927261bfc48c928b750e85a53e856f88749 |
|
MD5 | 30ebdcc2ed67db23075057e660b23a24 |
|
BLAKE2b-256 | 3d0d25e1e7c281be899c19faef810df5223f1a8fdee088be9b64b5fa4afd42b8 |
Close
Hashes for fcecodec-1.6-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2b2a0b332ebfadf738fb45ee184adc6c957760e192cea0cc90e497d2f185437 |
|
MD5 | 84184819025dc8f9accea8db7dabc609 |
|
BLAKE2b-256 | 64b5c81c960c053b94876377d9bf76ecdbb06bd42552473530ef07e20cbffc98 |
Close
Hashes for fcecodec-1.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 580985aec0eaced3c7953d6f04d59e099a79edc7cf023e8ab7844dcd3da8d053 |
|
MD5 | 37d327d03e23d8e0939cdc19a360ecd1 |
|
BLAKE2b-256 | ce329c7a19a849c828bf9d0345b380a5b2362adadcfab1578e3c52dc21783101 |
Close
Hashes for fcecodec-1.6-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a8932b890d6c0fea14c6c2456903f2b712a903e126cd8887618132325015d11 |
|
MD5 | 151e083b5cb55c84b8bae46dc26dd1a2 |
|
BLAKE2b-256 | ade000f548866d838ae6dd5d21f5d9712b61268954baaae6182a82fccd67bb56 |
Close
Hashes for fcecodec-1.6-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7771f8ded4ddee434a74ac83df4d0a5d7d9466f5c2610c1967fe0dc1034e0ebf |
|
MD5 | 91f599b7a2d2ec0b6f03d87d39be8f58 |
|
BLAKE2b-256 | b3adec311f9373c21e7d46ed071479aa856924a5050697313e4137e2f0ebbbd2 |
Close
Hashes for fcecodec-1.6-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 883c249a3c1c35c36316437f706981c5f7aef888ff927cd1e970b7a798482082 |
|
MD5 | 9c066b541a186f8ba95a47d6992622b8 |
|
BLAKE2b-256 | 7f7f5d3606ecb208f8cfd96847d3ceebd51b139cea0ac0aa3db1621e21c7bff1 |
Close
Hashes for fcecodec-1.6-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3913031e7e159e485c14302ffe3d827e65c81a5036afe98c7f29a9d8029f7344 |
|
MD5 | 84364e7b31dc510efa699ab71a88e8a7 |
|
BLAKE2b-256 | 944d1026abe435e232f9db4183361de9e439fe0f7a3e49d9f0d45582e40fc0bf |
Close
Hashes for fcecodec-1.6-cp311-cp311-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54789fdb011adbb4ee46bc08ec45850d9a0a665bce3299311134ab3bfbc4b6bd |
|
MD5 | 7ecb64d02b6d02ec336de4163c113b11 |
|
BLAKE2b-256 | 5d6d965d5e04c9b13cf4007b3b0a2798959c756bf90bd07056c0125917be1c84 |
Close
Hashes for fcecodec-1.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65fd4693d9ce870a9cabe9cc38f0d699d2cd1ecd3772e095cdc09cf4c57b652e |
|
MD5 | b2a3693fe4a5b0a33af008492c206d96 |
|
BLAKE2b-256 | 31bd7d163ef79a027a5a24dd65575626bf3b860d3c5c66da59a88c12ee9e92b3 |
Close
Hashes for fcecodec-1.6-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82436cb46069d52533145ac21194a7abbf5d5e62021baced1d49f732a329f8d5 |
|
MD5 | eb66b2632b00ab75d66dc2d59602355c |
|
BLAKE2b-256 | 09895c10bee49355fd4c18f111b49fdd57c592648e06555866a3ec1007ad3f02 |
Close
Hashes for fcecodec-1.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 826d0f4d3535278e3fb5d8e35e7438385c609008b2745112b3b8b521ef5bfc71 |
|
MD5 | 616c7fd131103c0f9a53feb43385135e |
|
BLAKE2b-256 | 92718d2d8d325f6eefb70ba0ae0dc949e586b7e83e58cbdaef98f46ecfae4bbc |
Close
Hashes for fcecodec-1.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b5180d9b232b3d777e7879df6f16e71cc201c45f6ff3cd386ffa28c7ae150ed |
|
MD5 | 0238c53fc4877bc4a554165abe023634 |
|
BLAKE2b-256 | 7d1e1b737bec074122a944a0cf458c196eafbc89cefd4b00b170bce20373493b |
Close
Hashes for fcecodec-1.6-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f898a11ca02020eaf77649b81df99f0d23c6819f0846be06b6a1179fe924ba62 |
|
MD5 | 0bc42742e3f781f1c07b18d04bb408c2 |
|
BLAKE2b-256 | 326be257acc7ea18776d562748ec0f7e8177b20c71cedab89bc040af548e546b |
Close
Hashes for fcecodec-1.6-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81a7450b1f22d2d04b035320fb4868ea71512ef9134070b9de45bd22f6558a7c |
|
MD5 | 787f7f1249f7e0e1dd525fc6957fecba |
|
BLAKE2b-256 | b6044515d665394d654c67f9f23e8f14adb63e2c3357a029ccabf5f2bc555720 |
Close
Hashes for fcecodec-1.6-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d19593c552e424425c1cea3bf7c41fc795563007cb7178a99ce703ca059836a5 |
|
MD5 | 8347f82069753a06e234dc702c9fa3b4 |
|
BLAKE2b-256 | d66a49ef1a4e06c48a8fed77985c5de1ae9992ce6a0e6abaf8d8bf5b10500f37 |
Close
Hashes for fcecodec-1.6-cp310-cp310-musllinux_1_2_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5eb911daf6865cd59a0af11d6b13e934d8f44cb349a41199167a62532bb84ec1 |
|
MD5 | 325b2b3871f0deb96c5d9cd53b457d48 |
|
BLAKE2b-256 | 13c178d88a9febc769251a1c5cfdb4326060382e63eca899453e31e639c6d187 |
Close
Hashes for fcecodec-1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c90da294c25a6479b7f08fd6fff64a2a5997a5ef776bca441bb7b029dbd46dd |
|
MD5 | 7bcca1a641602897476aa20fab6b97d2 |
|
BLAKE2b-256 | a7b0aa1e56e80082901eaa0fc1c5582d24f4458d52062b182e5d6a1b7d91fb5c |
Close
Hashes for fcecodec-1.6-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c631c8a9e289074942be52d70d5b50f1e190d2e6ef138d61ea6336079d826fa |
|
MD5 | efe7cc4ec233d26865e7db07587c931a |
|
BLAKE2b-256 | a8ff2e32d10a6d6f882afa6ae7a231ab261511a7052a373ea3e894f3afef6a35 |
Close
Hashes for fcecodec-1.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3cf09deb736e7afa9821525995180124ba10cf06fa3f52f776393ea0d292bd7 |
|
MD5 | 8dcb028daa452b6dad096e8f58c10ca8 |
|
BLAKE2b-256 | 93f53e71e4a1d92bc2e984db1b93e0a3a87c41aaf9bd033a0239c36ef8097f91 |
Close
Hashes for fcecodec-1.6-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fa53e01b7bee72967d8c155703731935a86e28f756864592ebe3ccf8b97e98e |
|
MD5 | 728b0988995a9d73a42f80dd64546bd2 |
|
BLAKE2b-256 | e08e84f6d98b3986680e0a2e799db6a235fa593705f4b64f5cc011ae63987f39 |