示例#1
0
def get_inverse_matrix(node, world_space=False, matrix_type='Transformation'):
    """
    Returns inverse matrix
    :param node: FBModel
    :param world_space: bool, Whether to return the matrix in world or local space
    :param matrix_type: str, matrix type to return ('Transformation', 'Translation', 'Rotation', 'Scaling', ...)
    :return: FBMatrix or None
    :return: FBMatrix or None
    """

    node = node_utils.get_model_node_by_name(node)
    if not node:
        return None

    matrix = pyfbsdk.FBMatrix()
    try:
        node.GetMatrix(matrix, INVERSE_MATRIX_TYPE_DICT[matrix_type],
                       world_space)
    except IndexError:
        logger.warning(
            'Invalid inverse matrix type "{}". Valid types are: "{}"'.format(
                matrix_type, ', '.join(list(INVERSE_MATRIX_TYPE_DICT.keys()))))
        return None

    return matrix
示例#2
0
def set_slot_model(character_node, slot, model):
    """
    Adds a model to a slot in the characterization map
    :param character_node: FBCharacter
    :param slot: str, full name of character slot
    :param model: str or FBModel, model to add to the slot (can be name or model object)
    :return:
    """

    if python.is_string(model):
        obj = node.get_model_node_by_name(model)
        if not obj:
            logger.warning(
                'Object "{}" does not exist. Unable to add it to the character map "{}" under slot "{}"'
                .format(model, character_node.Name, slot))
            return False
    else:
        obj = model

    character_slot = property.list_properties(pattern=slot)
    if not character_slot:
        logger.warning('Invalid character slot "{}"'.format(slot))
        return False

    # remove all current models from the slot
    character_slot[0].removeAll()

    if obj:
        character_slot[0].append(obj)

    return True
示例#3
0
def get_parent(node):
    """
    Returns parent of the given node
    :param node: FBModel
    :return: FBModel or None
    """

    node = node_utils.get_model_node_by_name(node)
    if not node:
        return None

    return node.Parent
示例#4
0
def get_children(node):
    """
    Returns children of the given node
    :param node: FBModel
    :return: list(FBModel)
    """

    node = node_utils.get_model_node_by_name(node)
    if not node:
        return list()

    return node.Children
示例#5
0
def set_scale(node, vector, world_space=False):
    """
    Sets node scale vector
    :param node: FBModel
    :param vector: FBVector3d
    :param world_space: bool, Whether to set the vector in world or local space.
    """

    node = node_utils.get_model_node_by_name(node)
    if not node:
        return

    node.SetVector(vector, MATRIX_TYPE_DICT['Scaling'], world_space)
示例#6
0
def get_scale(node, world_space=False):
    """
    Returns node scale vector
    :param node: FBModel
    :param world_space: bool, Whether to return the vector in world or local space.
    :return: FBVector3d or None
    """

    node = node_utils.get_model_node_by_name(node)
    if not node:
        return None

    vector = pyfbsdk.FBVector3d()
    node.GetVector(vector, MATRIX_TYPE_DICT['Scaling', world_space])

    return vector
示例#7
0
def set_matrix(node, matrix, world_space=False, matrix_type='Transformation'):
    """
    Sets node matrix
    :param node: FBModel
    :param matrix: FBMatrix
    :param world_space: bool, Whether to set the matrix in world or local space
    :param matrix_type: str, matrix type to set ('Transformation', 'Translation', 'Rotation', 'Scaling', ...)
    """

    node = node_utils.get_model_node_by_name(node)
    if not node:
        return

    try:
        node.SetMatrix(matrix, MATRIX_TYPE_DICT[matrix_type], world_space)
    except IndexError:
        logger.warning(
            'Invalid matrix type "{}". Valid types are: "{}"'.format(
                matrix_type, ', '.join(list(MATRIX_TYPE_DICT.keys()))))