MetaHuman DNA校准 - 5 DNA Viewer API - Mesh 实用程序

网格体实用程序 Mesh Utilities

以下方法的目的是提供:

  • 一种从给定 DNA 文件路径构建网格的简单机制
  • 返回和打印有关 DNA 文件中包含的网格的信息

导入

from dna_viewer import DNA, Config, build_meshes
DNA_PATH_ADA = f"{ROOT_DIR}/data/dna_files/Ada.dna"
DNA_PATH_TARO = f"{ROOT_DIR}/data/dna_files/Taro.dna"

创建配置实例(Config)

创建一个将在网格构建过程中使用的配置对象。

config = Config(
    add_joints=True,
    add_blend_shapes=True,
    add_skin_cluster=True,
    add_ctrl_attributes_on_root_joint=True,
    add_animated_map_attributes_on_root_joint=True,
    lod_filter=[0, 1],
    mesh_filter=["head"],
)

这些只是类的一些属性:Config

  • add_joints: bool - 表示是否应添加关节的标志,默认为 。True
  • add_blend_shapes: bool - 表示是否应添加混合形状的标志,默认为 。True
  • add_skin_cluster: bool - 表示是否应添加皮肤集群的标志,默认为 。True
  • add_ctrl_attributes_on_root_joint: bool - 表示是否应将控制属性添加到根关节的标志 作为属性,默认为 。它们用作引擎中Rig Logic输入的动画曲线。False
  • add_animated_map_attributes_on_root_joint: bool - 表示是否应将动画地图属性添加到 根关节作为属性,默认为 。它们用作引擎中动画贴图的动画曲线。True

重要提示:标志值的某些组合可能会导致装备无法使用或禁用某些功能!

构建网格体(build_meshes)

用于在没有 Rig Logic 的情况下构建 Rig 元素(关节、网格体、混合形状和蒙皮簇)。 它返回已添加到场景中的网格体的长名称。

config = Config(
    add_joints=True,
    add_blend_shapes=True,
    add_skin_cluster=True,
    add_ctrl_attributes_on_root_joint=True,
    add_animated_map_attributes_on_root_joint=True,
    lod_filter=[0, 1],
    mesh_filter=["head"],
)
mesh_names = build_meshes(
    dna=dna_ada,
    config=config
)

这使用以下参数:

  • dna: DNA - DNA 实例 .DNA
  • config: Config - 配置实例。
mesh_names = build_meshes(dna=dna_ada)

默认添加DNA文件中的所有网格。

例子

重要提示:在运行此示例之前,需要执行上面提供的环境设置。

from dna_viewer import DNA, Config, build_meshes

# if you use Maya, use absolute path
ROOT_DIR = f"{ospath.dirname(ospath.abspath(__file__))}/..".replace("\\", "/")
# Sets DNA file path
DNA_PATH_ADA = f"{ROOT_DIR}/data/dna_files/Ada.dna"
dna_ada = DNA(DNA_PATH_ADA)

# Starts the mesh build process with all the default values
build_meshes(dna=dna_ada)

# Creates the options to be passed in `build_meshes`
config = Config(
    add_joints=True,
    add_blend_shapes=True,
    add_skin_cluster=True,
    add_ctrl_attributes_on_root_joint=True,
    add_animated_map_attributes_on_root_joint=True,
    lod_filter=[0, 1],
    mesh_filter=["head"],
)

# Starts the mesh building process with the provided parameters
# In this case it will create every mesh contained in LODs 0 and 1 with 'head` in it's name,
build_meshes(
    dna=dna_ada,
    config=config,
)