-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial io between 3ds max and maya.
Refactored environment to be managed with batch file. Initial test with vcpkg was problematic, will revisit this in the future.
- Loading branch information
Showing
47 changed files
with
1,205 additions
and
1,079 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"folders": | ||
[ | ||
{ | ||
"path": "../../../SkinPlusPlus", | ||
} | ||
], | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import numpy as np | ||
import numpy.typing as np_typing | ||
|
||
from .core import FileType as _FileType | ||
from .core import export_skin_data as _export_skin_data | ||
from .core import import_skin_data as _import_skin_data | ||
from .io import save as _save | ||
from .io import load as _load | ||
from .io import max_to_maya as _max_to_maya | ||
from .io import maya_to_max as _maya_to_max | ||
|
||
|
||
FileType = _FileType | ||
export_skin_data = _export_skin_data | ||
import_skin_data = _import_skin_data | ||
save = _save | ||
load = _load | ||
max_to_maya = _max_to_maya | ||
maya_to_max = _maya_to_max | ||
|
||
|
||
current_dcc: str = ... | ||
""" | ||
The name of the current DCC. | ||
""" | ||
|
||
|
||
class SkinData: | ||
""" | ||
Class containing data for a given skin object. | ||
--- | ||
This class is a wrapped c++ struct exposed to Python with Pybind11. | ||
# Note: It cannot be extended! | ||
--- | ||
Attributes: | ||
----------- | ||
- `bone_names`: The names of the bones in the skin object. | ||
- `bone_ids`: The ids of each influence assigned to each vertext. | ||
These are used to map to the bone names. | ||
- `weights`: The weights of each influence assigned to each vertext. | ||
- `positions`: The positions of each vertex. | ||
""" | ||
bone_names: list[str] | ||
bone_ids: np_typing.NDArray[np.int64] | ||
weights: np_typing.NDArray[np.float32] | ||
positions: np_typing.NDArray[np.float32] | ||
|
||
|
||
def get_skin_data(mesh_name: str) -> SkinData: ... | ||
def set_skin_weights(mesh_name: str, skin_data: SkinData) -> bool: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,123 @@ | ||
from __future__ import annotations | ||
|
||
from . import get_skin_data | ||
|
||
# from . import get_vertex_positions | ||
from . import set_skin_weights | ||
|
||
import enum | ||
import json | ||
import numpy | ||
import pathlib | ||
import pickle | ||
import skin_plus_plus | ||
|
||
# import scipy.sparse | ||
import pathlib | ||
|
||
_typing = False | ||
if _typing: | ||
pass | ||
del _typing | ||
|
||
|
||
class ImportType(enum.IntEnum): | ||
class ImportType(enum.Enum): | ||
order = 0 | ||
nearest = 1 | ||
nearest_n = 2 | ||
barycentric = 3 | ||
|
||
|
||
def export_skin_data(mesh_name: str, path: pathlib.Path): | ||
class FileType(enum.Enum): | ||
""" | ||
Enum to specify the type of file to save skin data as. | ||
Arguments: | ||
---------- | ||
- `json` | ||
- `pickle` | ||
""" | ||
json = 0 | ||
pickle = 1 | ||
|
||
|
||
def export_skin_data(mesh_name: str, path: pathlib.Path, file_type: FileType = FileType.pickle): | ||
""" | ||
Get skin data from the given mesh and save it to disk. | ||
""" | ||
|
||
skin_data = get_skin_data(mesh_name) | ||
with open(path, "wb") as path_data: | ||
pickle.dump(skin_data, path_data) | ||
if not path.parent.exists(): | ||
path.parent.mkdir(parents=True) | ||
|
||
if file_type == FileType.pickle: | ||
if path.suffix != ".skpp": | ||
path = path.with_suffix(".skpp") | ||
|
||
with open(path, "wb") as file: | ||
pickle.dump(skin_data, file) | ||
|
||
def import_skin_data(mesh_name: str, path: pathlib.Path, import_type: ImportType = ImportType.order): | ||
elif file_type == FileType.json: | ||
if path.suffix != ".skpp-json": | ||
path = path.with_suffix(".skpp-json") | ||
|
||
with open(path, "w") as file: | ||
weights = skin_data.weights.copy() | ||
weights[numpy.isnan(weights)] = 0 | ||
_skin_data = { | ||
"bone_names": skin_data.bone_names, | ||
"bone_ids": skin_data.bone_ids.tolist(), | ||
"weights": weights.tolist(), | ||
"positions": skin_data.positions.tolist(), | ||
} | ||
json.dump(_skin_data, file, indent=4) | ||
|
||
print(f"Exported '{mesh_name}' skin data to: {path}") | ||
|
||
|
||
def import_skin_data( | ||
mesh_name: str, | ||
path: pathlib.Path, | ||
file_type: FileType = FileType.pickle, | ||
import_type: ImportType = ImportType.order, | ||
): | ||
""" | ||
Load skin data from disk and apply it to the given mesh. | ||
""" | ||
|
||
with open(path, "rb") as path_data: | ||
skin_data = pickle.load(path_data) | ||
if file_type == FileType.pickle: | ||
if path.suffix != ".skpp": | ||
path = path.with_suffix(".skpp") | ||
|
||
if not path.exists(): | ||
raise IOError( | ||
f"File path does not exist: {path} - check mesh is named correctly: {mesh_name}" | ||
) | ||
|
||
with open(path, "rb") as file: | ||
skin_data = pickle.load(file) | ||
|
||
elif file_type == FileType.json: | ||
if path.suffix != ".skpp-json": | ||
path = path.with_suffix(".skpp-json") | ||
|
||
if not path.exists(): | ||
raise IOError( | ||
f"File path does not exist: {path} - check mesh is named correctly: {mesh_name}" | ||
) | ||
|
||
with open(path, "r") as file: | ||
data = json.load(file) | ||
skin_data = skin_plus_plus.skin_plus_plus_py.SkinData( | ||
tuple(data["bone_names"]), | ||
tuple(data["bone_ids"]), | ||
tuple(data["weights"]), | ||
tuple(data["positions"]) | ||
) | ||
|
||
return set_skin_weights(mesh_name, skin_data) | ||
|
||
# if import_type == ImportType.nearest: | ||
# vertex_positions = get_vertex_positions(mesh_name) | ||
# kd_tree = scipy.sparse.ckdtree(skin_data.positions) | ||
# matching_indices = kd_tree.query(vertex_positions) | ||
|
Binary file added
BIN
+28.9 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_2022/skin_plus_plus_pymxs.exp
Binary file not shown.
Binary file added
BIN
+183 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_2022/skin_plus_plus_pymxs.pyd
Binary file not shown.
Binary file added
BIN
+28.9 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_2023/skin_plus_plus_pymxs.exp
Binary file not shown.
Binary file added
BIN
+166 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_2023/skin_plus_plus_pymxs.pyd
Binary file not shown.
Empty file.
Binary file removed
BIN
-150 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_23000/skin_plus_plus_pymxs.pyd
Binary file not shown.
Empty file.
Binary file removed
BIN
-27.7 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_24000/skin_plus_plus_pymxs.exp
Binary file not shown.
Binary file removed
BIN
-206 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_24000/skin_plus_plus_pymxs.pyd
Binary file not shown.
Empty file.
Binary file removed
BIN
-166 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_25000/skin_plus_plus_pymxs.pyd
Binary file not shown.
Binary file added
BIN
+28.9 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_debug_2023/skin_plus_plus_pymxs.exp
Binary file not shown.
Binary file added
BIN
+862 KB
PYProjects/skin_plus_plus/dccs/max/skin_plus_plus_pymxs_debug_2023/skin_plus_plus_pymxs.pyd
Binary file not shown.
Binary file removed
BIN
-239 KB
PYProjects/skin_plus_plus/dccs/maya/skin_plus_plus_pymaya_2022/skin_plus_plus_pymaya.pyd
Binary file not shown.
Binary file modified
BIN
+106 Bytes
(100%)
PYProjects/skin_plus_plus/dccs/maya/skin_plus_plus_pymaya_2023/skin_plus_plus_pymaya.exp
Binary file not shown.
Binary file modified
BIN
+6 KB
(100%)
PYProjects/skin_plus_plus/dccs/maya/skin_plus_plus_pymaya_2023/skin_plus_plus_pymaya.pyd
Binary file not shown.
Oops, something went wrong.