This commit is contained in:
Jeffreytsai1004 2025-01-08 21:31:36 +08:00
parent 171ef9e851
commit 4a717c6cd4
3 changed files with 1 additions and 348 deletions

View File

@ -1,59 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
## [1.3.1] - 2024-12-20
### Added
- example script to assemble face rig in Maya with textures `dna_viewer_build_rig_with_textures.py`
- added support for Maya 2024 in dna_calibration.mod file
## [1.3.0] - 2024-08-15
### Added
- support for Maya 2024
- support for Python 3.10
- added source code comments to python wrappers
### Fixed
- `CalculateMeshLowerLODsCommand` was rewritten to address edge cases discovered with eye lashes and to handle some common cases of invalid UV data.
- `RotateCommand` to rotate blend shape target deltas as well.
- `SetBlendShapeTargetDeltasCommand` to allow setting vertex indices as well.
- Swig generated classes are now wrapped instead of being monkey-patched to invoke constructors and destructors (which allows building with newer Swig versions - 4.0.x and 4.1.x).
### Changed
- CMake files to add test cases that execute the example scripts and allow generating bundled archives with CPack.
- Binaries for embeddedRL4 plugin to be .so files.
## [1.2.0] - 2023-06-30
### Added
- assets (gui.ma, Ada.dna, additional_assemble_script.py) which support MHC 2.x.x releases (UE 5.2 and 5.3)
## [1.1.0] - 2023-04-20
### Added
- support for Maya 2023
- support for Python 3.9
- `RenameAnimatedMapCommand` class to DNACalib API. Command to remove animated maps.
- `RemoveBlendShapeCommand` class to DNACalib API. Command to remove blend shapes.
- `DNA` class to DNAViewer API. This class is used for accessing data in DNA file.
- `rig_build` method to DNAViewer API. Method used for creating maya scene with functional rig. Replacement of method `assemble_rig`.
- `Config` class to DNAViewer API. Configuration class used for `build_meshes`.
- `RigConfig` class to DNAViewer API. Configuration class used for `rig_build`.
- documentation for DNA library.
### Fixed
- `ClearBlendShapesCommand` blend shape channel LODs were not correctly set.
- `RotateCommand` to rotate blend shape target deltas as well.
- `SetBlendShapeTargetDeltasCommand` to allow setting vertex indices as well.
### Changed
- changed signature of `build_meshes`. Method used for creating maya scene with meshes.
- Simplification of additional assemble script.
- option to pass list of indices to remove in remove commands.
### Removed
- removed method `assemble_rig` from DNAViewer API.

116
LICENSE
View File

@ -1,116 +0,0 @@
MetaHuman DNA Calibration License Agreement
This MetaHuman DNA Calibration License Agreement (“License Agreement”) is a legal document
detailing your rights and obligations related to your use of Epics proprietary
computer software known as MetaHuman DNA Calibration, including any updates, upgrades, or source
code made available to you by Epic (“Software”). By downloading or using the
Software, you are agreeing to be bound by the terms of this License Agreement,
and this License Agreement will be effective upon the first of those events to
occur. If you do not or cannot agree to the terms of this License Agreement, do
not use the Software.
1. Internal Production License. Subject to the terms and conditions herein,
Epic hereby grants you a worldwide, nonexclusive, royalty-free, non-sublicensable
license to reproduce and prepare derivative works of the Software for the sole
purpose of developing and using tools that enable third-party software programs
to export and edit digital characters in Epics proprietary MetaHuman format
(such exports, “MetaHuman Characters”). You may not distribute the Software or
make any use of the Software other than as expressly permitted in this Section 1.
2. MetaHuman Characters. You may only use MetaHuman Characters to the extent
such uses would be permitted if the MetaHuman Characters were licensed to you as
MetaHuman Content under the Epic Content License Agreement available at
https://www.unrealengine.com/en-US/eula/content. This means, for example, that
MetaHuman Characters may only be used in conjunction with Unreal Engine and Unreal
Engine-based products as designated by Epic, such as Twinmotion.
3. Ownership. The Software, and all intellectual property rights therein or
thereto, are owned by Epic or Epics licensors and are protected under both United
States and foreign laws. Epic reserve all right, title and interest in and to the
Software, including all related intellectual property rights therein or thereto.
No licenses or rights are granted to you other than as expressly stated in this
License Agreement.
4. Trademarks. This License Agreement does not grant you any right, title or
interest in the trademarks, service marks, trade names, and logos associated with
Epic, Epics games and other intellectual property, including Unreal Engine (the
“Epic Trademarks”). All use of the Epic Trademarks will inure to the sole benefit
of Epic.
5. Disclaimer of Warranties. THE SOFTWARE, INCLUDING ALL INFORMATION, CONTENT,
MATERIALS AND CODE, ARE PROVIDED BY EPIC ON AN “AS IS” AND “AS AVAILABLE” BASIS.
EPIC AND ITS AFFILIATES, LICENSORS AND SERVICE PROVIDERS (THE “EPIC PARTIES”) MAKE
NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, REGARDING THE SOFTWARE.
YOUR USE OF THE SOFTWARE IS AT YOUR SOLE RISK. TO THE FULL EXTENT PERMISSIBLE BY
APPLICABLE LAW, THE EPIC PARTIES DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
IMPLIED OR STATUTORY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
TITLE AND NONINFRINGEMENT. THE EPIC PARTIES DO NOT WARRANT THAT THE SOFTWARE IS
FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS. THE PARTIES ACKNOWLEDGE AND AGREE THAT
THE FOREGOING WARRANTY DISCLAIMERS WERE AN ESSENTIAL ELEMENT IN SETTING CONSIDERATION
UNDER THIS LICENSE AGREEMENT.
6. Limitation of Liability. TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW,
THE EPIC PARTIES WILL HAVE NO, AND YOU IRREVOCABLY RELEASE THE EPIC PARTIES FROM
AND FOREVER WAIVES ANY RIGHT YOU HAVE TO MAKE CLAIMS AGAINST THE EPIC PARTIES FOR,
ANY LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT, NEGLIGENCE, STRICT LIABILITY
OR OTHERWISE) ARISING OUT OF OR RELATING TO THE USE OR INABILITY TO USE THE SOFTWARE
OR OTHERWISE UNDER OR IN CONNECTION WITH THIS LICENSE AGREEMENT, INCLUDING WITHOUT
LIMITATION ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, EXEMPLARY, SPECIAL OR
PUNITIVE DAMAGES OR LIABILITIES WHATSOEVER, EVEN IF A EPIC PARTY HAS BEEN ADVISED
OF THE POSSIBILITY OF SUCH DAMAGES. YOUR EXCLUSIVE REMEDY WILL BE TO IMMEDIATELY
STOP USING THE SOFTWARE. THE LIMITATIONS OF LIABILITY SET FORTH IN THIS SECTION WILL
SURVIVE ANY TERMINATION OR EXPIRATION OF THIS LICENSE AGREEMENT AND WILL APPLY EVEN
IF ANY LIMITED REMEDY SPECIFIED HEREIN IS FOUND TO HAVE FAILED ITS ESSENTIAL PURPOSE.
IN NO EVENT WILL THE AGGREGATE LIABILITY OF THE EPIC PARTIES HEREUNDER EXCEED TEN
DOLLARS ($10.00). The foregoing disclaimer of warranties, disclaimer of certain
damages and limitation of liability will apply to the maximum extent permitted by
applicable law. The laws of some states or jurisdictions do not allow the exclusion
of implied warranties or the exclusion or limitation of certain damages. To the extent
that those laws apply to this License Agreement, the exclusions and limitations set
forth above may not apply to you.
7. U.S. Government License Rights. You may not use, access, download, or
otherwise export, reexport, or transfer the Software in violation of applicable
export control, economic sanctions, and import laws and regulations, such as the
U.S. Export Administration Regulations and U.S. Department of the Treasurys
Office of Foreign Assets Control regulations.
8. Termination. Without prejudice to any other rights, Epic may, upon written
notice, terminate this License Agreement at any time for convenience. Unless
otherwise agreed to by Epic in writing, upon termination of this License Agreement,
You must immediately delete all copies of the Software and any derivative works
based on the Software.
9. Governing Law; Jurisdiction. Any dispute or claim by you arising out of
or related to this License Agreement will be governed by North Carolina law,
exclusive of its choice of law rules. You and Epic submit to the exclusive jurisdiction
of the Superior Court of Wake County, North Carolina, or, if federal court jurisdiction
exists, the United States District Court for the Eastern District of North Carolina.
You and Epic waive any jurisdictional, venue, or inconvenient forum objections to such
courts (without affecting either partys rights to remove a case to federal court if
permissible), as well as any right to a jury trial. The Convention on Contracts for
the International Sale of Goods will not apply. Any law or regulation which provides
that the language of a contract will be construed against the drafter will not apply
to this License Agreement. This Section 9 will be interpreted as broadly as applicable
law permits.
10. Attorneys Fees. In any action or proceeding to enforce rights under this
License Agreement, the prevailing party will be entitled to recover costs and
reasonable attorneys fees.
11. Severability; Waiver. If any provision or part of a provision of this License
Agreement is unlawful, void or unenforceable, that provision or part of the provision
is deemed severable from this License Agreement and does not affect the validity and
enforceability of any remaining provisions.
The failure or delay of Epic to exercise or enforce any right, remedy or provision of
this License Agreement will not constitute a waiver of such right, remedy or provision.
All waivers of any terms or conditions in this License Agreement must be in writing
signed by Epic.
12. Entire Agreement. This License Agreement sets forth the entire agreement
between Epic and You with respect to the Software and the subject matter hereof
and supersedes all prior and contemporaneous understandings and agreements whether
written or oral. No amendment, modification or waiver of any of the provisions of
this License Agreement will be valid unless set forth in a written instrument signed
by the party to be bound thereby.

174
README.md
View File

@ -1,173 +1 @@
# MetaHuman DNA 校准 # MetaHuman Custome Tool For Maya
MetaHuman DNA 校准是一组用于处理 MetaHuman DNA 文件的工具,捆绑在一个单独的包中。
[`DNA`](/docs/dna.md#metahuman-dna) 是 [MetaHuman](https://www.unrealengine.com/en-US/metahuman) 身份的一个组成部分。
DNA 文件是使用 [MetaHuman Creator](https://metahuman.unrealengine.com/) 创建,并通过
[Quixel Bridge](https://docs.metahuman.unrealengine.com/en-US/downloading-metahumans-with-quixel-bridge/) 和 UE5 中的 Bifrost 下载的。
MetaHuman DNA 校准是一组用于处理 MetaHuman DNA 文件的工具,捆绑在一个单独的包中。我们希望分享此代码,以帮助用户自定义 DNA 文件,从而能够更好地将他们创建的角色集成到他们的游戏和体验中。
MetaHuman DNA 校准工具在 GitHub 存储库中提供,地址在此。
# 概述
关于存储库的组织方式的解释,[点击此处](docs/repository_organization.md)。
MetaHuman DNA 校准存储库包含两个不同的工具:
- [DNACalib](docs/dnacalib.md)(及其依赖项)
- [DNAViewer](docs/dna_viewer.md)
## 所需知识
要使用这些工具,您应该熟悉:
- 在 Maya 中的绑定
- Python
## 可选知识
- C++(用于 [DNACalib](docs/dnacalib.md) 及其 [API](docs/dnacalib_api.md)
## DNACalib
[DNACalib](docs/dnacalib.md) 及其 [API](docs/dnacalib_api.md) 用于检查和修改 DNA 文件。使用 [DNACalib](docs/dnacalib.md),您可以在 DNA 文件中进行以下更改:
- 重命名关节、网格、混合形状和/或动画映射。
- 删除关节、网格和/或关节动画。
- 旋转、缩放和平移装备。
- 删除 LOD。
- 更改中立关节位置、中立网格位置和混合形状增量值。
- 修剪混合形状。
- 删除所有混合形状数据。
MetaHuman DNA 文件格式的概述可以在 [`这里`](/docs/dna.md) 找到。
**注意**DNACalib 库允许删除和重命名任何关节。然而以下关节用于连接头部和身体不应被删除或重命名neck_01、neck_02、FACIAL_C_FacialRoot。
## 外部软件依赖项
DNACalib 的 Python 包装器是针对 Python 3.7 和 3.9 编译的。Windows 和 Linux均为 64 位)的预编译二进制文件是存储库的一部分。
如果您使用的是不同版本的 Python则必须重新编译。任何 Python 3 版本都应该可以。
如果用户具有不同的平台或架构,则必须编译库及其依赖项。
**重要**
DNA 文件作为 [LFS大文件存储](https://git-lfs.github.com/) 文件存储。如果安装并配置了 git-lfs 以供使用,它们将与其余代码一起下载。如果您未使用 git-lfs则必须手动下载 DNA 文件。
更多信息可以在 [这里](docs/faq.md#fix--runtimeerror--error-loading-dna--dna-signature-mismatched-expected-dna-got-ver-) 找到。
**警告**
不支持 Python 2。
DNACalib 可以在 C++ 项目中作为 C++ 库使用。
DNACalib Python 包装器可以在 Python 3.7 和 3.9 中使用,`mayapy`(与 Maya 一起提供的 Python 解释器)与 Maya 一起使用。
支持的 Maya 版本为 2022 和 2023。
注意Maya 2022 与 Python 3.7 捆绑Maya 2023 与 Python 3.9 捆绑。
## 环境设置
为了在您的脚本中使用 MetaHuman DNA 校准,您需要:
- 安装 Python3参见 [注意事项](README.md#external-software-dependencies)
- 将 MetaHuman DNA 校准的位置添加到 `MAYA_MODULE_PATH` 系统变量中(如果您想在 Maya 中使用 MetaHuman DNA 校准)
如果您计划从命令行运行脚本:
- 对于 Maya 的解释器mayapy您将必须使用以下代码初始化 maya
```python
import maya.standalone
maya.standalone.initialize()
```
- 对于 python 解释器,您将必须在脚本顶部添加以下内容:
```python
from os import path as ospath
from sys import path as syspath
from sys import platform
ROOT_DIR = f"{ospath.dirname(ospath.abspath(__file__))}/..".replace("\\", "/")
MAYA_VERSION = "2022" # 或 2023
ROOT_LIB_DIR = f"{ROOT_DIR}/lib/Maya{MAYA_VERSION}"
if platform == "win32":
LIB_DIR = f"{ROOT_LIB_DIR}/windows"
elif platform == "linux":
LIB_DIR = f"{ROOT_LIB_DIR}/linux"
else:
raise OSError(
"操作系统不支持,请编译依赖项并为 LIB_DIR 添加值"
)
# 将目录添加到路径
syspath.insert(0, ROOT_DIR)
syspath.insert(0, LIB_DIR)
```
注意:
如果在 Linux 上运行,请确保在运行示例之前将 `LD_LIBRARY_PATH` 附加到 `lib/Maya2022/linux``lib/Maya2023/linux` 目录的绝对路径:
- `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<路径到 lib-linux 目录>`
## DNAViewer
使用 DNAViewer您可以
- 为 Maya 创建功能性装备。
- 导出 FBX 文件。
- 读取 DNA 文件的内部部分。
DNAViewer 可以在 `mayapy`(与 Maya 一起提供的 Python 解释器)或 Maya 2022 中使用,除了 [从 Maya 场景传播更改到 dna](/examples/dna_viewer_grab_changes_from_scene_and_propagate_to_dna.py),它只能在 Maya 中使用。
# 示例
提供了几个 Python 示例作为参考,可以在 **examples'** 文件夹中找到:
- [展示一些命令](/examples/dnacalib_demo.py)
- [重命名关节](/examples/dnacalib_rename_joint_demo.py)
- [从头创建一个小的 DNA](/examples/dna_demo.py)
- [读取二进制 DNA 并以人类可读格式写入](/examples/dna_binary_to_json_demo.py)
- [通过提取特定 LOD 从现有 DNA 创建新的 DNA](/examples/dnacalib_lod_demo.py)
- [删除关节](/examples/dnacalib_remove_joint.py)
- [清除混合形状数据](/examples/dnacalib_clear_blend_shapes.py)
- [从中立网格中减去值](/examples/dnacalib_neutral_mesh_subtract.py)
- [Maya 中的简单 UI](examples/dna_viewer_run_in_maya.py) 及其一些 [文档](docs/dna_viewer.md#usage-in-maya)
- [生成装备](/examples/dna_viewer_build_rig.py)
- [按 LOD 导出 FBX](/examples/dna_viewer_export_fbx.py)
- [从 Maya 场景传播更改到 dna](/examples/dna_viewer_grab_changes_from_scene_and_propagate_to_dna.py)
- [生成带有纹理的面部装备](/examples/dna_viewer_build_rig_with_textures.py)
注意示例分为三组DNA、DNACalib 和 DNAViewer。这些名称作为前缀嵌入dna_、dnacalib_ 和 dna_viewer_。
## 示例 DNA 文件
[两个演示 DNA 文件](data/dna_files) 提供以便更轻松地测试此工具。任何使用 [MetaHumanCreator](https://www.unrealengine.com/en-US/metahuman) 生成的 DNA 都应该可以工作。
MHC 2023 春季发布对装备定义进行了更改(关节数量增加以及表达式数量增加)。
为了适应这些更改,我们在 `/data/mh4` 文件夹中向存储库添加了几个文件:新的 [gui 场景](/data/mh4/gui.ma)、更新的 [组装脚本](/data/mh4/additional_assemble_script.py) 和 Ada 的示例 [DNA 文件](data/mh4/dna_files/Ada.dna)。
如果用户想要切换并使用这个新的装备版本,则有必要在他们的脚本中更新路径:
```python
GUI = f"{DATA_DIR}/mh4/gui.ma"
ADDITIONAL_ASSEMBLE_SCRIPT = f"{DATA_DIR}/mh4/additional_assemble_script.py"
```
如果角色 DNA 是从 [Quixel Bridge](https://quixel.com/bridge) 下载的,并且我们不确定使用的是哪个装备定义,可以使用以下代码进行检查:
```python
from dna import (
BinaryStreamReader,
DataLayer_All,
FileStream,
Status,
)
def load_dna_reader(dna_file):
stream = FileStream(
dna_file, FileStream.AccessMode_Read, FileStream.OpenMode_Binary
)
reader = BinaryStreamReader(stream, DataLayer_All)
reader.read()
if not Status.isOk():
status = Status.get()
raise RuntimeError(f"错误加载 DNA: {status.message}")
return reader
角色_dna = "路径到/角色.dna"
reader = load_dna_reader(角色_dna)
if reader.getDBName() == "MH.4":
print("使用 mh4 文件夹")
elif reader.getDBName() == "DHI":
print("使用 data 文件夹")
else:
print("不支持的装备定义!")
```
# 注意
如果用户在 Maya 中运行示例,`ROOT_DIR` 的值应该更改并且必须使用绝对路径,
例如在 Windows 中为 `c:/MetaHuman-DNA-Calibration` 或在 Linux 中为 `/home/user/MetaHuman-DNA-Calibration`。重要:使用 `/`正斜杠Maya 在路径中使用正斜杠。
更多规格请参阅 [常见问题解答指南](docs/faq.md)。
# 许可证
MetaHuman DNA 校准随 [许可证](LICENSE) 发布。