### Full Example: Building Meshes in Maya Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer_api_build_meshes_md.html A comprehensive example demonstrating environment setup, DNA loading, and mesh building with both default and custom configurations in a Maya context. ```python 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, ) ``` -------------------------------- ### Build Character Rig Example Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer_api_build_rig_md.html This example demonstrates how to build a character rig in Maya using the DNAViewer API. Ensure the environment setup is completed before running. It involves loading a DNA file, configuring RigConfig with GUI and script paths, and then calling the build_rig function. ```python from dna_viewer import DNA, RigConfig, build_rig import os # if you use Maya, use absolute path ROOT_DIR = f"{os.path.dirname(os.path.abspath(__file__))}/..".replace("\", "/") # Sets the values that will used DNA_PATH_ADA = f"{ROOT_DIR}/data/dna_files/Ada.dna" dna_ada = DNA(DNA_PATH_ADA) config = RigConfig( gui_path=f"{ROOT_DIR}/data/gui.ma", analog_gui_path=f"{ROOT_DIR}/data/analog_gui.ma", aas_path=f"{ROOT_DIR}/data/additional_assemble_script.py", ) # Creates the rig build_rig(dna=dna_ada, config=config) ``` -------------------------------- ### Environment Setup Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer_api_md.html Sets up the environment variables and system path to allow importing from dna_viewer. This code should be added at the beginning of your script. ```APIDOC ## Environment Setup In order be able to import from dna_viewer, the environment needs to be set up. This is done by adding this code to the beginning of any example mentioned below: ```python from sys import path as syspath from os import environ, path as ospath ROOT_DIR = fr"{ospath.dirname(ospath.abspath(__file__))}/..".replace("\", "/") # if you use Maya, use an absolute path instead ROOT_LIB_DIR = fr"{ROOT_DIR}/lib" if platform == "win32": LIB_DIR = f"{ROOT_LIB_DIR}/windows" elif platform == "linux": LIB_DIR = f"{ROOT_LIB_DIR}/linux" else: raise OSError("OS not supported, please compile dependencies and add value to LIB_DIR") if "MAYA_PLUG_IN_PATH" in environ: separator = ":" if platform == "linux" else ";" environ["MAYA_PLUG_IN_PATH"] = separator.join([environ["MAYA_PLUG_IN_PATH"], LIB_DIR]) else: environ["MAYA_PLUG_IN_PATH"] = LIB_DIR syspath.append(ROOT_DIR) syspath.append(LIB_DIR) ``` When running this from Maya, the `ROOT_DIR` should be set to an absolute path to the root of the repository instead. ``` -------------------------------- ### read Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.dnalib.html Starts reading the behavior part of the DNA file. ```APIDOC ## read ### Description Starts reading in the behavior part of the DNA. ``` -------------------------------- ### Initiate Scene Build Process Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Starts the scene creation process based on UI configurations, handling unsaved changes and enabling/disabling UI elements. ```python def process(self) -> None: """Start the build process of creation of scene from provided configuration from the UI""" process = True if cmds.file(q=True, modified=True): process = self.show_message_dialog() if process: self.set_progress(text="Processing in progress...", value=0) config = RigConfig( meshes=self.mesh_tree_list.get_selected_meshes(), gui_path=self.select_gui_path.get_file_path(), analog_gui_path=self.select_analog_gui_path.get_file_path(), aas_path=self.select_aas_path.get_file_path(), add_rig_logic=self.add_rig_logic(), add_joints=self.add_joints(), add_blend_shapes=self.add_blend_shapes(), add_skin_cluster=self.add_skin_cluster(), add_ctrl_attributes_on_root_joint=self.add_ctrl_attributes_on_root_joint(), add_animated_map_attributes_on_root_joint=self.add_animated_map_attributes_on_root_joint(), add_mesh_name_to_blend_shape_channel_name=self.add_mesh_name_to_blend_shape_channel_name(), add_key_frames=self.add_key_frames(), ) self.main_widget.setEnabled(False) ``` -------------------------------- ### Get Maya Main Window Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Retrieves the MayaWindow instance. Raises a RuntimeError if the instance cannot be found. ```python @staticmethod def maya_main_window() -> QWidget: """ Gets the MayaWindow instance @throws RuntimeError @rtype: QtWidgets.QWidget @returns: main window instance """ for obj in QApplication.topLevelWidgets(): if obj.objectName() == "MayaWindow": return obj raise RuntimeError("Could not find MayaWindow instance") ``` -------------------------------- ### get_mesh_node_fullpath_on_root Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.builder.html Gets the full path of a mesh within the scene hierarchy, starting from the root. ```APIDOC ## get_mesh_node_fullpath_on_root ### Description Gets the full path of a mesh within the scene hierarchy, starting from the root. ### Method GET (assumed, as it's a retrieval function) ### Endpoint /dna_viewer/builder/get_mesh_node_fullpath_on_root ### Parameters #### Query Parameters - **_mesh_name** (str) - Required - The name of the mesh whose path is needed. ### Response #### Success Response (200) - **str** - The full path of the mesh object in the scene. ``` -------------------------------- ### Handle Help Button Click Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Opens the HELP_URL in a web browser if available, otherwise displays an 'About' message box indicating that documentation is not yet available. ```python def on_help(self) -> None: """The method that gets called when the help button is clicked""" if HELP_URL: webbrowser.open(HELP_URL) else: QMessageBox.about( self, "About", "Sorry, this application does not have documentation yet.", ) ``` -------------------------------- ### Start Geometry Reading Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/geometry.html Resets the geometry read flag to False before starting the reading process. Ensures that geometry data is read fresh on each call. ```python def start_read(self) -> None: super().start_read() self.geometry_read = False ``` -------------------------------- ### Start Definition Reading Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Resets the definition reading flag when starting the reading process. Ensures that the definition data is read only once per reading cycle. ```python def start_read(self) -> None: super().start_read() self.definition_read = False ``` -------------------------------- ### Create Build Options Widget Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Creates a QWidget that will contain the build options checkboxes, setting its layout and margins. ```python def create_build_options(self) -> QWidget: """Creates and adds the widget containing the build options checkboxes""" widget = QWidget() layout = QVBoxLayout(widget) layout.setContentsMargins( MARGIN_BODY_LEFT, MARGIN_BODY_TOP, MARGIN_BODY_RIGHT, MARGIN_BOTTOM, ) ``` -------------------------------- ### Get GUI to Raw From Values Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/behavior.html Retrieves the 'from' values for the GUI to Raw mapping from the DNA reader. ```python [docs] def get_gui_to_raw_from_values(self) -> List[float]: return cast(List[float], self.reader.getGUIToRawFromValues()) ``` -------------------------------- ### Get Age Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the age of the character. ```APIDOC ## GET /age ### Description Retrieves the age of the character. ### Method GET ### Endpoint /age ### Response #### Success Response (200) - **age** (uint16) - The age of the character. #### Response Example { "example": 30 } ``` -------------------------------- ### Create Command Instance (CommandImplBase) Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dnacalib.html Static factory method to create an instance of a command implementation. ```cpp static inline TCommand *create(MemoryResource *memRes) ``` -------------------------------- ### Setup Window Flags and Attributes Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Configures window properties such as title bar buttons, deletion on close, object name, window title, and focus policy. ```python def setup_window(self) -> None: """A method for setting up the window""" self.setWindowFlags( self.windowFlags() | Qt.WindowTitleHint | Qt.WindowMaximizeButtonHint | Qt.WindowMinimizeButtonHint | Qt.WindowCloseButtonHint ) self.setAttribute(Qt.WA_DeleteOnClose) self.setObjectName(WINDOW_OBJECT) self.setWindowTitle(WINDOW_TITLE) self.setWindowFlags(Qt.Window) self.setFocusPolicy(Qt.StrongFocus) ``` -------------------------------- ### Get Gender Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the gender of the character. ```APIDOC ## GET /gender ### Description Retrieves the gender of the character. ### Method GET ### Endpoint /gender ### Response #### Success Response (200) - **gender** (Gender) - The gender of the character. #### Response Example { "example": "female" } ``` -------------------------------- ### Create Main UI Elements Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Populates the application window with UI elements, including the main widget, setting its size, and applying stylesheets. ```python def create_ui(self) -> None: """Fills the window with UI elements""" self.main_widget = self.create_main_widget() self.setCentralWidget(self.main_widget) self.set_size() self.setStyleSheet(self.load_css()) ``` -------------------------------- ### Get Archetype Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the archetype of the character. ```APIDOC ## GET /archetype ### Description Retrieves the archetype of the character. ### Method GET ### Endpoint /archetype ### Response #### Success Response (200) - **archetype** (Archetype) - The archetype of the character. #### Response Example { "example": "human" } ``` -------------------------------- ### Get Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the name of the character. ```APIDOC ## GET /name ### Description Retrieves the name of the character. ### Method GET ### Endpoint /name ### Response #### Success Response (200) - **name** (string) - The name of the character. #### Response Example { "example": "MetahumanCharacter" } ``` -------------------------------- ### Create RigConfig Instance(`RigConfig`) Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer_api_build_rig_md.html Create a configuration object that will be used in the mesh building process. ```APIDOC ## Create RigConfig Instance(`RigConfig`) Create a configuration object that will be used in the mesh building process. ### Description Initializes a RigConfig object with various settings for the mesh building process. ### Attributes - `gui_path` (str): The GUI file path. - `analog_gui_path` (str): The analog GUI file path. - `aas_path` (str): The additional assemble script path. - `aas_method` (str): The method name that should be called from the additional assemble script. - `add_ctrl_attributes_on_root_joint` (bool): A flag representing if attributes should be added on the root joint, defaults to `True`. - `add_key_frames` (bool): A flag representing if keyframes should be added, defaults to `True`. ### Example ```python from dna_viewer import RigConfig config = RigConfig( gui_path="path/to/gui.ma", analog_gui_path="path/to/analog_gui.ma", aas_path="path/to/additional_assemble_script.py", aas_method="my_custom_method", add_ctrl_attributes_on_root_joint=False, add_key_frames=False ) ``` ``` -------------------------------- ### get_mesh_count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Gets the total number of meshes. ```APIDOC ## get_mesh_count ### Description Gets the total number of meshes. ### Method `get_mesh_count() -> int` ### Returns * int - The total number of meshes. ``` -------------------------------- ### get_rotation_unit Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Gets the unit of rotation used in the system. ```APIDOC ## get_rotation_unit ### Description Gets the unit of rotation used in the system. ### Method `get_rotation_unit() -> int` ### Returns * int - The rotation unit. ``` -------------------------------- ### Create GUI File Selector Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Creates a specific file chooser widget for selecting GUI files (.ma), intended for RigLogic. ```python def create_gui_selector(self) -> FileChooser: """ Creates the gui selector widget @rtype: FileChooser @returns: Gui selector widget """ return self.create_file_chooser( "Gui path:", "GUI file to load. Required by RigLogic", "Select the gui file", "gui files (*.ma)", ) ``` -------------------------------- ### Get GUI to Raw To Values Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/behavior.html Retrieves the 'to' values for the GUI to Raw mapping from the DNA reader. ```python [docs] def get_gui_to_raw_to_values(self) -> List[float]: return cast(List[float], self.reader.getGUIToRawToValues()) ``` -------------------------------- ### Create QProgressBar Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Initializes and configures a QProgressBar with a range of 0-100, sets its initial value to 0, makes the text visible, and clears the format. The progress bar is then added to the application's body. ```python progress = QProgressBar(self) progress.setRange(0, 100) progress.setValue(0) progress.setTextVisible(True) progress.setFormat("") self.body.addWidget(progress) return progress ``` -------------------------------- ### get_translation_unit Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Gets the unit of translation used in the system. ```APIDOC ## get_translation_unit ### Description Gets the unit of translation used in the system. ### Method `get_translation_unit() -> int` ### Returns * int - The translation unit. ``` -------------------------------- ### get_animated_map_count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Gets the total number of animated maps. ```APIDOC ## get_animated_map_count ### Description Gets the total number of animated maps. ### Method `get_animated_map_count() -> int` ### Returns * int - The total number of animated maps. ``` -------------------------------- ### Create Analog GUI File Selector Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Creates a file chooser widget for selecting Analog GUI files (.ma), required by RigLogic. ```python def create_analog_gui_selector(self) -> FileChooser: """ Creates and adds the analog gui selector widget @rtype: FileChooser @returns: Analog gui selector widget """ return self.create_file_chooser( "Analog gui path:", "Analog GUI file to load. Required by RigLogic", "Select the analog gui file", "analog gui files (*.ma)", ) ``` -------------------------------- ### Create Help Button Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Creates a QPushButton widget with a question mark icon and a tooltip. Connects the button's clicked signal to the on_help method. ```python def create_help_btn(self) -> QWidget: """ Creates the help button widget @rtype: QHBoxLayout @returns: The created horizontal box layout with the widgets added """ btn = QPushButton(self) btn.setText(" ? ") btn.setToolTip("Help") btn.clicked.connect(self.on_help) return btn ``` -------------------------------- ### get_joint_count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Gets the total number of joints in the skeleton. ```APIDOC ## get_joint_count ### Description Gets the total number of joints in the skeleton. ### Method `get_joint_count() -> int` ### Returns * int - The total number of joints. ``` -------------------------------- ### Show DnaViewerWindow Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Manages the singleton instance of the DnaViewerWindow, creating it if it doesn't exist and activating it. ```python @staticmethod def show_window() -> None: if DnaViewerWindow._instance is None: DnaViewerWindow._instance = DnaViewerWindow( parent=DnaViewerWindow.maya_main_window() ) DnaViewerWindow.activate_window() ``` -------------------------------- ### Set up Python Environment for DNA Viewer Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer_api_md.html Add this code to the beginning of your script to set up the environment for importing from dna_viewer. It configures Maya plugin paths and adds necessary directories to the system path. Ensure ROOT_DIR is an absolute path when running from Maya. ```python from sys import path as syspath from os import environ, path as ospath ROOT_DIR = fr"{ospath.dirname(ospath.abspath(__file__))}/..".replace("\\", "/") # if you use Maya, use an absolute path instead ROOT_LIB_DIR = fr"{ROOT_DIR}/lib" if platform == "win32": LIB_DIR = f"{ROOT_LIB_DIR}/windows" elif platform == "linux": LIB_DIR = f"{ROOT_LIB_DIR}/linux" else: raise OSError("OS not supported, please compile dependencies and add value to LIB_DIR") if "MAYA_PLUG_IN_PATH" in environ: separator = ":" if platform == "linux" else ";" environ["MAYA_PLUG_IN_PATH"] = separator.join([environ["MAYA_PLUG_IN_PATH"], LIB_DIR]) else: environ["MAYA_PLUG_IN_PATH"] = LIB_DIR syspath.append(ROOT_DIR) syspath.append(LIB_DIR) ``` -------------------------------- ### get_blend_shape_channel_count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Gets the total number of blend shape channels. ```APIDOC ## get_blend_shape_channel_count ### Description Gets the total number of blend shape channels. ### Method `get_blend_shape_channel_count() -> int` ### Returns * int - The total number of blend shape channels. ``` -------------------------------- ### build() Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.builder.html Initiates the mesh building process, including creating the neutral mesh and adding normals, blend shapes, and skin if configured. ```APIDOC ## build() -> None ### Description Starts the build process, creates the neutral mesh, then adds normals, blends shapes and skin if needed. ### Method build ``` -------------------------------- ### WriterImpl::setMeshIndices Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Sets mesh indices starting from a specific index. ```APIDOC ## setMeshIndices ### Description Sets mesh indices starting from a specific index. ### Parameters #### Path Parameters - **index** (std::uint16_t) - Required - The starting index for the mesh indices. - **meshIndices** (const std::uint16_t *) - Required - A pointer to the array of mesh indices. - **count** (std::uint16_t) - Required - The number of mesh indices. ``` -------------------------------- ### WriterImpl::setJointIndices Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Sets joint indices starting from a specific index. ```APIDOC ## setJointIndices ### Description Sets joint indices starting from a specific index. ### Parameters #### Path Parameters - **index** (std::uint16_t) - Required - The starting index for the joint indices. - **jointIndices** (const std::uint16_t *) - Required - A pointer to the array of joint indices. - **count** (std::uint16_t) - Required - The number of joint indices. ``` -------------------------------- ### Initialize DNACalib Command Implementation Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dnacalib.html Constructor for the Impl class, taking a MemoryResource. ```cpp inline explicit Impl(MemoryResource *memRes_) ``` -------------------------------- ### Get Mesh Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the name of a mesh at a specific index. ```APIDOC ## GET /meshes/name/{index} ### Description Retrieves the name of a mesh at the specified index. ### Method GET ### Endpoint /meshes/name/{index} ### Parameters #### Path Parameters - **index** (uint16) - Required - The index of the mesh name to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the mesh. #### Response Example { "example": "Head_Mesh" } ``` -------------------------------- ### Writer Initialization Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dnacalib.html Constructor for the WriterImpl class. ```APIDOC ## WriterImpl Constructor ### Description Initializes a new instance of the WriterImpl class. ### Signature `explicit WriterImpl(MemoryResource *memRes_)` ``` -------------------------------- ### Create Build Options Widget Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.ui.html Creates and returns a widget that contains all the checkboxes for configuring build options in the DNA Viewer. ```python def create_build_options() -> PySide2.QtWidgets.QWidget:[ source] Creates and adds the widget containing the build options checkboxes ``` -------------------------------- ### Get Joint Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the name of a joint at a specific index. ```APIDOC ## GET /joints/name/{index} ### Description Retrieves the name of a joint at the specified index. ### Method GET ### Endpoint /joints/name/{index} ### Parameters #### Path Parameters - **index** (uint16) - Required - The index of the joint name to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the joint. #### Response Example { "example": "Spine_01" } ``` -------------------------------- ### Get Metadata Key Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the metadata key at a specific index. ```APIDOC ## GET /metadata/key/{index} ### Description Retrieves the metadata key at the specified index. ### Method GET ### Endpoint /metadata/key/{index} ### Parameters #### Path Parameters - **index** (uint32) - Required - The index of the metadata key to retrieve. ### Response #### Success Response (200) - **key** (string) - The metadata key. #### Response Example { "example": "character_name" } ``` -------------------------------- ### Create Config Instance for Mesh Building Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer_api_build_meshes_md.html Instantiate a Config object to specify parameters for building meshes. This allows customization of which elements are included. ```python 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"], ) ``` -------------------------------- ### Get DB Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the name of the database from which the character originates. ```APIDOC ## GET /db/name ### Description Retrieves the name of the database the character originates from. ### Method GET ### Endpoint /db/name ### Response #### Success Response (200) - **name** (string) - The name of the database. #### Response Example { "example": "character_db_v1" } ``` -------------------------------- ### Set up Python Environment for Command Line Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/index.html Configure the Python path to include MetaHuman DNA Calibration directories when running scripts from the command line using a standard Python interpreter. This setup is necessary for Maya 2022 and 2023. ```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" # or 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( "OS not supported, please compile dependencies and add value to LIB_DIR" ) # Adds directories to path syspath.insert(0, ROOT_DIR) syspath.insert(0, LIB_DIR) ``` -------------------------------- ### Build DNACalib Project Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dnacalib_md.html Command to initiate the build process for DNACalib after generating build scripts with CMake. ```bash cmake --build ``` -------------------------------- ### Get Linear Unit Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.builder.html Retrieves the current linear unit setting. ```python get_linear_unit() → dna_viewer.builder.config.LinearUnit[source] ``` -------------------------------- ### Get Filtered Meshes Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.builder.html Retrieves a list of filtered mesh indices. ```python get_filtered_meshes() → List[int][source] ``` -------------------------------- ### DnaViewerWindow Class Initialization Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.ui.html Initializes the main UI window for the DNA Viewer. It sets up various widgets for file selection, loading DNA, mesh selection, and build options. ```python class DnaViewerWindow(_parent : Optional[PySide2.QtWidgets.QWidget] = None)_[ source] Bases: PySide2.QtWidgets.QMainWindow UI Window @type select_dna_path Type FileChooser @param select_dna_path Type The FileChooser widget for getting the DNA path @type load_dna_btn Type QPushButton @param load_dna_btn Type The button that starts loading in the DNA @type mesh_tree_list Type QWidget @param mesh_tree_list Type The widget that contains the meshes to be selected in a tree list @type joints_cb Type QCheckBox @param joints_cb Type The checkbox that represents if joints should be added @type blend_shapes_cb Type QCheckBox @param blend_shapes_cb Type The checkbox that represents if blend shapes should be added @type skin_cb Type QCheckBox @param skin_cb Type The checkbox that represents if skin should be added @type rig_logic_cb Type QCheckBox @param rig_logic_cb Type The checkbox that represents if rig logic should be added @type ctrl_attributes_on_root_joint_cb Type QCheckBox @param ctrl_attributes_on_root_joint_cb Type The checkbox that represents if control attributes on joint should be added @type animated_map_attributes_on_root_joint_cb Type QCheckBox @param animated_map_attributes_on_root_joint_cb Type The checkbox that represents if animated maps attributes on root joint should be added @type mesh_name_to_blend_shape_channel_name_cb Type QCheckBox @param mesh_name_to_blend_shape_channel_name_cb Type The checkbox that represents if mesh names to blend shapes channel name should be added @type key_frames_cb Type QCheckBox @param key_frames_cb Type The checkbox that represents if key frames should be added @type select_gui_path Type FileChooser @param select_gui_path Type The FileChooser widget for getting the gui path @type select_analog_gui_path Type FileChooser @param select_analog_gui_path Type The FileChooser widget for getting the analog gui path @type select_aas_path Type FileChooser @param select_aas_path Type The FileChooser widget for getting the additional assemble script path @type process_btn Type QPushButton @param process_btn Type The button that starts creating the scene and character @type progress_bar Type QProgressBar @param progress_bar Type The progress bar that shows the building progress ``` -------------------------------- ### Initialize RigBuilder Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/builder/rig_builder.html Initializes the RigBuilder with DNA data and an optional configuration. It sets up internal attributes for eye positions. ```python class RigBuilder(Builder): """ A builder class used for building meshes """ def __init__(self, dna: DNA, config: Optional[RigConfig] = None) -> None: super().__init__(dna=dna, config=config) self.config: Optional[RigConfig] self.eye_l_pos: MVector self.eye_r_pos: MVector ``` -------------------------------- ### Get Angle Unit Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.builder.html Retrieves the current angle unit setting. ```python get_angle_unit() → dna_viewer.builder.config.AngleUnit[source] ``` -------------------------------- ### Add GUI to Raw Mapping Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/behavior.html Initializes and populates the `gui_to_raw` mapping using data retrieved from the reader. This involves setting up a ConditionalTable with various input and output indices, and value mappings. ```python def add_gui_to_raw(self) -> None: """Reads in the gui to raw mapping""" self.reader.gui_to_raw = ConditionalTable( inputs=self.get_gui_to_raw_input_indices(), outputs=self.get_gui_to_raw_output_indices(), from_values=self.get_gui_to_raw_from_values(), to_values=self.get_gui_to_raw_to_values(), slope_values=self.gget_gui_to_raw_slope_values(), cut_values=self.get_gui_to_raw_cut_values(), ) ``` -------------------------------- ### WriterImpl::setAnimatedMapIndices Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Sets animated map indices starting from a specific index. ```APIDOC ## setAnimatedMapIndices ### Description Sets animated map indices starting from a specific index. ### Parameters #### Path Parameters - **index** (std::uint16_t) - Required - The starting index for the animated map indices. - **animatedMapIndices** (const std::uint16_t *) - Required - A pointer to the array of animated map indices. - **count** (std::uint16_t) - Required - The number of animated map indices. ``` -------------------------------- ### Get Mesh Count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the total number of meshes associated with the character. ```APIDOC ## GET /meshes/count ### Description Retrieves the total number of meshes. ### Method GET ### Endpoint /meshes/count ### Response #### Success Response (200) - **count** (uint16) - The number of meshes. #### Response Example { "example": 10 } ``` -------------------------------- ### Mesh.build Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/builder/mesh.html Starts the build process for the mesh. This method orchestrates the creation of the neutral mesh, addition of blend shapes, and application of skin clusters based on the configuration. ```APIDOC ## build() ### Description Starts the build process for the mesh. This method orchestrates the creation of the neutral mesh, addition of blend shapes, and application of skin clusters based on the configuration. ### Method `build()` ``` -------------------------------- ### new_scene Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.builder.html Creates a new, empty scene. This function initializes a fresh environment for building DNA assets. ```APIDOC ## new_scene ### Description Creates a new, empty scene. This function initializes a fresh environment for building DNA assets. ### Method POST (assumed, as it creates a new resource) ### Endpoint /dna_viewer/builder/new_scene ### Response #### Success Response (200) - **None** - Indicates successful scene creation. ``` -------------------------------- ### get_mesh_blend_shape_channel_mapping_count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/dnalib/definition.html Gets the total number of mesh blend shape channel mappings. ```APIDOC ## get_mesh_blend_shape_channel_mapping_count ### Description Gets the total number of mesh blend shape channel mappings. ### Method `get_mesh_blend_shape_channel_mapping_count() -> int` ### Returns * int - The count of blend shape channel mappings. ``` -------------------------------- ### DNACalib::run Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dnacalib.html Executes the DNA calibration process with the configured settings. ```APIDOC ## DNACalib::run ### Description Public method to run the DNA calibration process. ### Parameters * **output** (DNACalibDNAReader *) - A pointer to the DNACalibDNAReader object to store the output. ``` -------------------------------- ### Get Rig Group Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/builder/config.html Returns the formatted name for the rig group. ```python def get_rig_group(self) -> str: return f"{self.top_level_group}Rig_grp" ``` -------------------------------- ### Initialize DNA Viewer UI Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Initializes the main window for the DNA Viewer application, setting up window flags, object name, title, and focus policy. ```python def __init__(self, parent: QWidget = None) -> None: super().__init__(parent) self.body: QVBoxLayout = None self.header: QHBoxLayout = None self.build_options: QWidget = None self.extra_build_options: QWidget = None self.setup_window() self.create_ui() ``` -------------------------------- ### Get Geometry Group Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/builder/config.html Returns the formatted name for the geometry group. ```python def get_geometry_group(self) -> str: return f"{self.geometry_group}_grp" ``` -------------------------------- ### Create Generic File Chooser Widget Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html A factory method to create a reusable FileChooser widget with configurable labels, hints, captions, and filters. ```python def create_file_chooser( self, label: str, hint: str, caption: str, filter: str, on_changed: Callable[[int], None] = None, ) -> FileChooser: """ Creates a file chooser widget that is used for selecting file paths @type label: str @param label: The label in the FileDialog that pops up @type hint: str @param hint: The label in the FileDialog that pops up @type caption: str @param caption: The caption in the FileDialog that pops up @type filter: str @param filter: The file filter that is used in the FileDialog @rtype: FileChooser @returns: The created file chooser object """ widget = FileChooser( label, hint, self, dialog_caption=caption, dialog_filter=filter, on_changed=on_changed or self.on_generic_changed, ) self.body.addWidget(widget) return widget ``` -------------------------------- ### WriterImpl::setBlendShapeChannelIndices Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Sets blend shape channel indices starting from a specific index. ```APIDOC ## setBlendShapeChannelIndices ### Description Sets blend shape channel indices starting from a specific index. ### Parameters #### Path Parameters - **index** (std::uint16_t) - Required - The starting index for the blend shape channel indices. - **blendShapeChannelIndices** (const std::uint16_t *) - Required - A pointer to the array of blend shape channel indices. - **count** (std::uint16_t) - Required - The number of blend shape channel indices. ``` -------------------------------- ### Get Animated Map Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the name of an animated map at a specific index. ```APIDOC ## GET /animated_maps/name/{index} ### Description Retrieves the name of an animated map at the specified index. ### Method GET ### Endpoint /animated_maps/name/{index} ### Parameters #### Path Parameters - **index** (uint16) - Required - The index of the animated map name to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the animated map. #### Response Example { "example": "Eye_Blink_L" } ``` -------------------------------- ### Set GUI to Raw From Values Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Sets the 'from' values for the GUI to raw transformation. ```cpp inline void setGUIToRawFromValues(const float *fromValues, std::uint16_t count) override ``` -------------------------------- ### Get Joint Count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the total number of joints in the character's skeleton. ```APIDOC ## GET /joints/count ### Description Retrieves the total number of joints in the skeleton. ### Method GET ### Endpoint /joints/count ### Response #### Success Response (200) - **count** (uint16) - The number of joints. #### Response Example { "example": 150 } ``` -------------------------------- ### Create QPushButton Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Creates a 'Process' button, disables it initially, and connects its click signal to the 'process' method. This button is then added to the application's body. ```python btn = QPushButton("Process") btn.setEnabled(False) btn.clicked.connect(self.process) self.body.addWidget(btn) return btn ``` -------------------------------- ### Get Raw Control Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the name of a raw control at a specific index. ```APIDOC ## GET /raw_controls/name/{index} ### Description Retrieves the name of a raw control at the specified index. ### Method GET ### Endpoint /raw_controls/name/{index} ### Parameters #### Path Parameters - **index** (uint16) - Required - The index of the raw control name to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the raw control. #### Response Example { "example": "Jaw_Open_Raw" } ``` -------------------------------- ### Builder Build Method Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/builder/builder.html The main entry point to build the character rig. It orchestrates the internal build process, handles logging, and manages exceptions, returning a BuildResult object. ```python def build(self) -> BuildResult: """Builds the character""" self.meshes = {} try: filename = Path(self.dna.path).stem logging.info("******************************") logging.info(f"{filename} started building") logging.info("******************************") self._build() logging.info(f"{filename} built successfully!") except DNAViewerError as e: traceback.print_exc() raise e except Exception as e: traceback.print_exc() logging.error(f"Unhandled exception, {e}") raise DNAViewerError(f"Scene creation failed! Reason: {e}") from e return BuildResult(meshes_per_lod=self.meshes) ``` -------------------------------- ### Initialize WriterImpl Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Constructor for the `dna::WriterImpl` class. Requires a `MemoryResource`. ```cpp explicit WriterImpl(MemoryResource *memRes_) ``` -------------------------------- ### Get Raw Control Count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the number of raw controls available for the character. ```APIDOC ## GET /raw_controls/count ### Description Retrieves the number of raw controls. ### Method GET ### Endpoint /raw_controls/count ### Response #### Success Response (200) - **count** (uint16) - The number of raw controls. #### Response Example { "example": 20 } ``` -------------------------------- ### Behavior Class Initialization and Methods Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.dnalib.html Handles the reading and management of behavior data from a DNA binary stream. Includes methods to add and retrieve data for PSD, blend shapes, animated maps, joints, and GUI to raw mappings. ```python class Behavior(_reader : dna.BinaryStreamReader_, _layers : Optional[List[dna_viewer.dnalib.layer.Layer]]_): """@type reader: BinaryStreamReader @param reader: The binary stream reader being used @type gui_to_raw: ConditionalTable @param gui_to_raw: Mapping data about gui to raw values @type psd: PSDMatrix @param psd: The data representing Pose Space Deformation @type blend_shapes: BlendShapesData @param blend_shapes: The data representing blend shapes @type animated_maps: AnimatedMapsConditionalTable @param animated_maps: The data representing animated maps @type joints: JointGroups @param joints: The data representing joints""" def add_animated_maps_conditional_table() -> None: """Reads in the animated maps part of the behavior""" ... def add_blend_shapes() -> None: """Reads in the blend shapes part of the behavior""" ... def add_gui_to_raw() -> None: """Reads in the gui to raw mapping""" ... def add_joint_groups() -> None: """Reads in the joints part of the behavior""" ... def add_psd() -> None: """Reads in the PSD part of the behavior""" ... def get_animated_map_cut_values() -> List[float]: ... def get_animated_map_from_values() -> List[float]: ... def get_animated_map_input_indices() -> List[int]: ... def get_animated_map_lods() -> List[int]: ... def get_animated_map_output_indices() -> List[int]: ... def get_animated_map_slope_values() -> List[float]: ... def get_animated_map_to_values() -> List[float]: ... def get_blend_shape_channel_input_indices() -> List[int]: ... def get_blend_shape_channel_lods() -> List[int]: ... def get_blend_shape_channel_output_indices() -> List[int]: ... def get_gui_to_raw_cut_values() -> List[float]: ... def get_gui_to_raw_from_values() -> List[float]: ... def get_gui_to_raw_input_indices() -> List[int]: ... def get_gui_to_raw_output_indices() -> List[int]: ... def get_gui_to_raw_to_values() -> List[float]: ... def get_joint_column_count() -> int: ... def get_joint_group_count() -> int: ... def get_joint_group_input_indices(_joint_group_index : int_) -> List[int]: ... def get_joint_group_joint_indices(_joint_group_index : int_) -> List[int]: ... def get_joint_group_logs(_joint_group_index : int_) -> List[int]: ... def get_joint_group_output_indices(_joint_group_index : int_) -> List[int]: ... def get_joint_group_values(_joint_group_index : int_) -> List[float]: ... def get_joint_row_count() -> int: ... def get_joint_variable_attribute_indices() -> int: ... def get_psd_column_indices() -> List[int]: ... def get_psd_count() -> int: ... def get_psd_row_indices() -> List[int]: ... def get_psd_values() -> List[float]: ... def gget_gui_to_raw_slope_values() -> List[float]: ... def is_read() -> bool: ... def read() -> None: """Starts reading in the behavior part of the DNA""" ... def start_read() -> None: ... ``` -------------------------------- ### Get GUI Control Name Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the name of a GUI control at a specific index. ```APIDOC ## GET /gui_controls/name/{index} ### Description Retrieves the name of a GUI control at the specified index. ### Method GET ### Endpoint /gui_controls/name/{index} ### Parameters #### Path Parameters - **index** (uint16) - Required - The index of the GUI control name to retrieve. ### Response #### Success Response (200) - **name** (string) - The name of the GUI control. #### Response Example { "example": "Head_Yaw" } ``` -------------------------------- ### Set Window Size Constraints Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/ui/app.html Defines the maximum, minimum, and initial resize dimensions for the application window. ```python def set_size(self) -> None: """Sets the window size""" self.setMaximumSize(WINDOW_SIZE_WIDTH_MAX, WINDOW_SIZE_HEIGHT_MAX) self.setMinimumSize(WINDOW_SIZE_WIDTH_MIN, WINDOW_SIZE_HEIGHT_MIN) self.resize(WINDOW_SIZE_WIDTH_MIN, WINDOW_SIZE_HEIGHT_MIN) ``` -------------------------------- ### Get GUI Control Count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the number of GUI controls available for the character. ```APIDOC ## GET /gui_controls/count ### Description Retrieves the number of GUI controls. ### Method GET ### Endpoint /gui_controls/count ### Response #### Success Response (200) - **count** (uint16) - The number of GUI controls. #### Response Example { "example": 10 } ``` -------------------------------- ### Get Metadata Count Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the total number of metadata entries associated with the character. ```APIDOC ## GET /metadata/count ### Description Retrieves the total number of metadata entries. ### Method GET ### Endpoint /metadata/count ### Response #### Success Response (200) - **count** (uint32) - The number of metadata entries. #### Response Example { "example": 5 } ``` -------------------------------- ### Builder Class Initialization Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna_viewer.builder.html Initializes the Builder class with DNA and optional configuration for character building. ```python 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 ``` -------------------------------- ### Instantiate MayaSkinWeights from Scene Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/_modules/dna_viewer/builder/maya/skin_weights.html Creates and returns an instance of the MayaSkinWeights class, populated with skin data directly from the Maya scene for the specified mesh. ```python def get_skin_weights_from_scene(mesh_name: str) -> MayaSkinWeights: """ Gets the instance of this class filled with data from the scene for a given mesh name. @type mesh_name: str @param mesh_name: The mesh name @rtype: MayaSkinWeights @returns: An instance of this class with the data from the scene """ _, skin_cluster = get_skin_weights_data(mesh_name) return MayaSkinWeights(skin_cluster, mesh_name) ``` -------------------------------- ### Get Rotation Unit Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the rotation unit used for the character's rotations. ```APIDOC ## GET /units/rotation ### Description Retrieves the rotation unit. ### Method GET ### Endpoint /units/rotation ### Response #### Success Response (200) - **unit** (RotationUnit) - The rotation unit. #### Response Example { "example": "degrees" } ``` -------------------------------- ### Get Translation Unit Source: https://epicgames.github.io/MetaHuman-DNA-Calibration/dna.html Retrieves the translation unit used for the character's transformations. ```APIDOC ## GET /units/translation ### Description Retrieves the translation unit. ### Method GET ### Endpoint /units/translation ### Response #### Success Response (200) - **unit** (TranslationUnit) - The translation unit. #### Response Example { "example": "centimeters" } ```