DNAViewer.builder package

Submodules

dna_viewer.builder.builder module

class dna_viewer.builder.builder.BuildResult(meshes_per_lod: typing.Dict[int, typing.List[str]] = <factory>)[source]

Bases: object

A class used for returning data after finishing the build process

@type meshes_per_lod
Type

Dict[int, List[str]]

@param meshes_per_lod
Type

The list of mesh names created group by LOD number

get_all_meshes() List[str][source]

Flatten meshes to single list.

@rtype: List[str] @returns: The list of all mesh names.

meshes_per_lod: Dict[int, List[str]]
class dna_viewer.builder.builder.Builder(dna: dna_viewer.dnalib.dnalib.DNA, config: Optional[dna_viewer.builder.config.Config] = None)[source]

Bases: object

A builder class used for building the character

@type config
Type

Config

@param config
Type

The configuration options used for building the character

@type dna
Type

DNA

@param dna
Type

The DNA object read from the DNA file

@type meshes
Type

Dict[int, List[str]]

@param meshes
Type

A list of meshes created grouped by lod

add_animated_map_attributes_on_root_joint() None[source]

Adds and sets the animated map attributes on root joint.

add_attribute(control_name: str, long_name: str) None[source]

Adds attributes wrapper for internal usage.

add_ctrl_attributes_on_root_joint() None[source]

Adds and sets the raw gui control attributes on root joint.

add_joints() None[source]

Starts adding the joints the character, if the character configuration options have add_joints set to False, this step will be skipped.

add_key_frames() None[source]

Adds a starting key frame to the facial root joint if joints are added and the add_key_frames option is set to True.

add_mesh_to_display_layer(mesh_name: str, lod: int) None[source]

Add the mesh with the given name to an already created display layer.

@type mesh_name: str @param mesh_name: The name of the mesh that should be added to a display layer.

@type lod: int @param lod: The lod value, this is needed for determining the name of the display layer that the mesh should be added to.

attach_mesh_to_lod(mesh_name: str, lod: int) None[source]

Attaches the mesh called mesh_name to a given lod.

@type mesh_name: str @param mesh_name: The mesh that needs to be attached to a lod holder object.

@type lod: str @param lod: The name of the mesh that should be added to a display layer.

build() dna_viewer.builder.builder.BuildResult[source]

Builds the character

build_meshes() None[source]

Builds the meshes. If specified in the config they get parented to a created character node transform, otherwise the meshes get put to the root level of the scene.

build_meshes_by_lod(lod: int, meshes_per_lod: List[int]) List[str][source]

Builds the meshes from the provided mesh ids and then attaches them to a given lod if specified in the character configuration.

@type lod: int @param lod: The lod number representing the display layer the meshes to the display layer.

@type meshes_per_lod: List[int] @param meshes_per_lod: List of mesh indices that are being built.

@rtype: List[MObject] @returns: The list of maya objects that represent the meshes added to the scene.

create_groups() None[source]

Creates a Maya transform which will hold the character, if the character configuration options have create_character_node set to False, this step will be skipped.

default_lambert_shader(mesh_name: str) None[source]
get_angle_unit() dna_viewer.builder.config.AngleUnit[source]
get_angle_unit_from_int(value: int) dna_viewer.builder.config.AngleUnit[source]

Returns an enum from an int value. 0 -> degree 1 -> radian

@type value: int @param value: The value that the enum is mapped to.

@rtype: AngleUnit @returns: AngleUnit.degree or AngleUnit.radian

get_display_layers() List[int][source]

Gets a lod id list that need to be created for the meshes from @config

get_filtered_meshes() List[int][source]
get_linear_unit() dna_viewer.builder.config.LinearUnit[source]
get_linear_unit_from_int(value: int) dna_viewer.builder.config.LinearUnit[source]

Returns an enum from an int value. 0 -> cm 1 -> m

@type value: int @param value: The value that the enum is mapped to.

@rtype: LinearUnit @returns: LinearUnit.cm or LinearUnit.m

get_mesh_indices_filter() List[int][source]
get_mesh_node_fullpath_on_root(mesh_name: str) str[source]

Gets the full path in the scene of a mesh.

@type mesh_name: str @param mesh_name: The mesh thats path is needed.

@rtype: str @returns: The full path of the mesh object in the scene

new_scene() None[source]
set_filtered_meshes() None[source]
set_units() None[source]

Sets the translation and rotation units of the scene from @config

dna_viewer.builder.config module

class dna_viewer.builder.config.AngleUnit(value)[source]

Bases: enum.Enum

An enum used to represent the unit used for angle representation.

@degree
Type

using degree as unit

@radian
Type

using radian as unit

degree = 0
radian = 1
class dna_viewer.builder.config.Config(meshes: typing.List[int] = <factory>, mesh_filter: typing.List[str] = <factory>, lod_filter: typing.List[int] = <factory>, group_by_lod: bool = True, top_level_group: str = 'head', geometry_group: str = 'geometry', facial_root_joint_name: str = 'FACIAL_C_FacialRoot', blend_shape_group_prefix: str = 'BlendshapeGroup_', blend_shape_name_postfix: str = '_blendShapes', skin_cluster_suffix: str = 'skinCluster', create_display_layers: bool = True, add_joints: bool = True, add_blend_shapes: bool = True, add_skin_cluster: bool = True, add_ctrl_attributes_on_root_joint: bool = True, add_animated_map_attributes_on_root_joint: bool = True, add_key_frames: bool = True, add_mesh_name_to_blend_shape_channel_name: bool = True)[source]

Bases: object

A class used to represent the config for @Builder

@type mesh_filter
Type

List[str]

@param mesh_filter
Type

List of mesh names that should be filtered. Mash names can be just substrings. [“head”] will find all meshes that contins string “head” in its mash name.

@type lod_filter: List[int] @param lod_filter: List of lods that should be filtered.

@type group_by_lod: bool @param group_by_lod: A flag representing whether the character should be parented to a character transform node in the scene hierarchy

@type group_by_lod: bool @param group_by_lod: A flag representing whether the character should be parented to a character transform node in rig hierarchy

@type top_level_group: str @param top_level_group: Value that is going to be used when creating root group

@type geometry_group: str @param geometry_group: Value that is going to be used when creating group that contains geometry

@type facial_root_joint_name: str @param facial_root_joint_name: The name of the facial root joint

@type blend_shape_group_prefix: str @param blend_shape_group_prefix: prefix string for blend shape group

@type blend_shape_name_postfix: str @param blend_shape_name_postfix: postfix string for blend shape name

@type skin_cluster_suffix: str @param skin_cluster_suffix: postfix string for skin cluster name

@type animated_map_attribute_multipliers_name: str @param animated_map_attribute_multipliers_name: string for frame animated map attribute name

@type create_display_layers: bool @param create_display_layers: A flag representing whether the created meshes should be assigned to a display layer

@type add_joints: bool @param add_joints: A flag representing whether joints should be added

@type add_blend_shapes: bool @param add_blend_shapes: A flag representing whether blend shapes should be added

@type add_skin_cluster: bool @param add_skin_cluster: A flag representing whether skin should be added

@type add_ctrl_attributes_on_root_joint: bool @param add_ctrl_attributes_on_root_joint: A flag representing whether control attributes should be added to the root joint

@type add_animated_map_attributes_on_root_joint: bool @param add_animated_map_attributes_on_root_joint: A flag representing whether animated map attributes should be added to the root joint

@type add_key_frames: bool @param add_key_frames: A flag representing whether key frames should be added

@type add_mesh_name_to_blend_shape_channel_name: bool @param add_mesh_name_to_blend_shape_channel_name: A flag representing whether mesh name of blend shape channel is added to name when creating it

add_animated_map_attributes_on_root_joint: bool = True
add_blend_shapes: bool = True
add_ctrl_attributes_on_root_joint: bool = True
add_joints: bool = True
add_key_frames: bool = True
add_mesh_name_to_blend_shape_channel_name: bool = True
add_skin_cluster: bool = True
animated_map_attribute_multipliers_name = 'FRM_WMmultipliers'
blend_shape_group_prefix: str = 'BlendshapeGroup_'
blend_shape_name_postfix: str = '_blendShapes'
create_display_layers: bool = True
facial_root_joint_name: str = 'FACIAL_C_FacialRoot'
geometry_group: str = 'geometry'
get_geometry_group() str[source]
get_rig_group() str[source]
get_top_level_group() str[source]
group_by_lod: bool = True
lod_filter: List[int]
mesh_filter: List[str]
meshes: List[int]
skin_cluster_suffix: str = 'skinCluster'
top_level_group: str = 'head'
class dna_viewer.builder.config.LinearUnit(value)[source]

Bases: enum.Enum

An enum used to represent the unit used for linear representation.

@cm
Type

using cm as unit

@m
Type

using m as unit

cm = 0
m = 1
class dna_viewer.builder.config.RigConfig(meshes: typing.List[int] = <factory>, mesh_filter: typing.List[str] = <factory>, lod_filter: typing.List[int] = <factory>, group_by_lod: bool = True, top_level_group: str = 'head', geometry_group: str = 'geometry', facial_root_joint_name: str = 'FACIAL_C_FacialRoot', blend_shape_group_prefix: str = 'BlendshapeGroup_', blend_shape_name_postfix: str = '_blendShapes', skin_cluster_suffix: str = 'skinCluster', create_display_layers: bool = True, add_joints: bool = True, add_blend_shapes: bool = True, add_skin_cluster: bool = True, add_ctrl_attributes_on_root_joint: bool = True, add_animated_map_attributes_on_root_joint: bool = True, add_key_frames: bool = True, add_mesh_name_to_blend_shape_channel_name: bool = True, add_rig_logic: bool = True, rig_logic_command: str = 'createEmbeddedNodeRL4', rig_logic_name: str = '', control_naming: str = '<objName>.<attrName>', joint_naming: str = '<objName>.<attrName>', blend_shape_naming: str = '', animated_map_naming: str = '', gui_path: typing.Optional[str] = None, eye_gui_name: str = 'CTRL_C_eye', gui_translate_x: float = 10, analog_gui_path: typing.Optional[str] = None, left_eye_joint_name: str = 'FACIAL_L_Eye', right_eye_joint_name: str = 'FACIAL_R_Eye', central_driver_name: str = 'LOC_C_eyeDriver', left_eye_driver_name: str = 'LOC_L_eyeDriver', right_eye_driver_name: str = 'LOC_R_eyeDriver', left_eye_aim_up_name: str = 'LOC_L_eyeAimUp', right_eye_aim_up_name: str = 'LOC_R_eyeAimUp', central_aim: str = 'GRP_C_eyesAim', le_aim: str = 'GRP_L_eyeAim', re_aim: str = 'GRP_R_eyeAim', aas_path: typing.Optional[str] = None, aas_method: str = 'run_after_assemble', aas_parameter: typing.Dict[typing.Any, typing.Any] = <factory>)[source]

Bases: dna_viewer.builder.config.Config

A class used to represent the config for @RigBuilder

@type add_rig_logic: bool @param add_rig_logic: A flag representing whether normals should be added

@type rig_logic_command: str @param rig_logic_command: The command used to start creating the rig logic using the plugin

@type rig_logic_name: str @param rig_logic_name: The name of the rig logic node

@type control_naming: str @param control_naming: The naming pattern of controls

@type joint_naming: str @param joint_naming: The naming pattern of joints

@type blend_shape_naming: str @param blend_shape_naming: The naming pattern of blend shapes

@type animated_map_naming: str @param animated_map_naming: The naming pattern of animated maps

@type gui_path: str @param gui_path: The location of the gui file

@type left_eye_joint_name: str @param left_eye_joint_name: The name of the left eye joint

@type eye_gui_name: str @param eye_gui_name: The name of the control in the gui

@type gui_translate_x: float @param gui_translate_x: Represents the value that the gui should be additionally translated on the X axis

@type analog_gui_path: str @param analog_gui_path: The location of the analog gui file

@type left_eye_joint_name: str @param left_eye_joint_name: The name of the left eye joint

@type right_eye_joint_name: str @param right_eye_joint_name: The name of the right eye joint

@type central_driver_name: str @param central_driver_name: The name of the central driver

@type left_eye_driver_name: str @param left_eye_driver_name: The name of the left eye driver

@type right_eye_driver_name: str @param right_eye_driver_name: The name of the right eye driver

@type central_aim: str @param central_aim: The name of the central aim

@type le_aim: str @param le_aim: The name of the left eye aim

@type re_aim: str @param re_aim: The name of the right eye aim

@type aas_path: Optional[str] @param aas_path: The location of the script file

@type aas_method: str @param aas_method: The method that should be called

@type aas_parameter: Dict[Any, Any] @param aas_parameter: The parameters that will be passed as the method arguments

aas_method: str = 'run_after_assemble'
aas_parameter: Dict[Any, Any]
aas_path: Optional[str] = None
add_rig_logic: bool = True
analog_gui_path: str = None
animated_map_naming: str = ''
blend_shape_naming: str = ''
central_aim: str = 'GRP_C_eyesAim'
central_driver_name: str = 'LOC_C_eyeDriver'
control_naming: str = '<objName>.<attrName>'
eye_gui_name: str = 'CTRL_C_eye'
gui_path: str = None
gui_translate_x: float = 10
joint_naming: str = '<objName>.<attrName>'
le_aim: str = 'GRP_L_eyeAim'
left_eye_aim_up_name: str = 'LOC_L_eyeAimUp'
left_eye_driver_name: str = 'LOC_L_eyeDriver'
left_eye_joint_name: str = 'FACIAL_L_Eye'
re_aim: str = 'GRP_R_eyeAim'
rig_logic_command: str = 'createEmbeddedNodeRL4'
rig_logic_name: str = ''
right_eye_aim_up_name: str = 'LOC_R_eyeAimUp'
right_eye_driver_name: str = 'LOC_R_eyeDriver'
right_eye_joint_name: str = 'FACIAL_R_Eye'

dna_viewer.builder.joint module

class dna_viewer.builder.joint.Joint(joints: List[dna_viewer.model.Joint])[source]

Bases: object

A builder class used for adding joints to the scene

@type joints
Type

List[JointModel]

@param joints
Type

data representing the joints

@type joint_flags
Type

Dict[str, bool]

@param joint_flags
Type

A mapping used for setting flags that are used to avoid adding the same joint multiple times

add_joint_to_scene(joint: dna_viewer.model.Joint) None[source]

Adds the given joint to the scene

@type joint: JointModel @param joint: The joint to be added to the scene

process() None[source]

Starts adding all the provided joints to the scene

dna_viewer.builder.mesh module

class dna_viewer.builder.mesh.Mesh(config: dna_viewer.builder.config.Config, dna: dna_viewer.dnalib.dnalib.DNA, mesh_index: int)[source]

Bases: object

A builder class used for adding joints to the scene

@type dna
Type

DNA

@param dna
Type

The location of the DNA file

@type mesh_index
Type

int

@param mesh_index
Type

The mesh index we are working with

@type joint_ids
Type

List[int]

@param joint_ids
Type

The joint indices used for adding skin

@type joint_names
Type

List[str]

@param joint_names
Type

The joint names used for adding skin

@type config
Type

Config

@param config
Type

The build options that will be applied when creating the mesh

@type mesh: MayaMesh @param mesh: The builder class object for creating the meshes

@type dna: DNA @param dna: The DNA object that was loaded in

add_blend_shapes() None[source]

Reads in the blend shapes, then adds them to the mesh if it is set in the build options

add_skin_cluster() None[source]

Adds skin cluster to the mesh if it is set in the build options

build() None[source]

Starts the build process, creates the neutral mesh, then adds normals, blends shapes and skin if needed

create_neutral_mesh() None[source]

Creates the neutral mesh

prepare_joint_ids() None[source]
prepare_joints() None[source]

Gets the joint indices and names needed for the given mesh.

dna_viewer.builder.rig_builder module

class dna_viewer.builder.rig_builder.RigBuilder(dna: dna_viewer.dnalib.dnalib.DNA, config: Optional[dna_viewer.builder.config.RigConfig] = None)[source]

Bases: dna_viewer.builder.builder.Builder

A builder class used for building meshes

add_analog_gui() None[source]

Adds an analog gui according to the specified analog gui options. If none is specified no analog gui will be added.

add_animated_map_attributes() None[source]

Adds and sets the animated map attributes.

add_ctrl_attributes() None[source]

Adds and sets the raw gui control attributes.

add_eye_locators() None[source]

Add eye locators to the analog gui

add_eyes() None[source]

Add eyes to the analog gui

add_gui() None[source]

Adds a gui according to the specified gui options. If none is specified no gui will be added.

add_rig_logic() None[source]

Creates and adds a rig logic node specified in the character configuration.

import_gui(gui_path: str, group_name: str) None[source]

Imports a gui using the provided parameters.

@type gui_path: str @param gui_path: The path of the gui file that needs to be imported.

@type group_name: str @param group_name: The name of the transform that holds the imported asset.

position_gui(group_name: str) None[source]

Sets the gui position to align with the character eyes

run_additional_assemble_script() None[source]

Runs an additional assemble script if specified in the character configuration.

source_py_file(name: str, path: str) Optional[module][source]

Used for loading a python file, used for additional assemble script.

@type name: str @param name: The name of the module.

@type path: str @param path: The path of the python file.

@rtype: Optional[ModuleType] @returns: The loaded module.