Exemplo n.º 1
0
    def _write_visual_scene_node(self, objects, parent_node, group):
        for object_ in objects:
            if (object_.type == "MESH" or object_.type == 'EMPTY') \
                    and not utils.is_fakebone(object_) \
                    and not utils.is_lod_geometry(object_) \
                    and not utils.is_there_a_parent_releation(object_, group):
                prop_name = object_.name
                node_type = utils.get_node_type(group)
                if node_type in ('chr', 'skin'):
                    prop_name = join(
                        object_.name,
                        self._create_properties_name(object_, group))
                node = self._doc.createElement("node")
                node.setAttribute("id", prop_name)
                node.setAttribute("name", prop_name)
                node.setIdAttribute("id")

                self._write_transforms(object_, node)

                if not utils.is_dummy(object_):
                    ALLOWED_NODE_TYPES = ('cgf', 'cga', 'chr', 'skin')
                    if node_type in ALLOWED_NODE_TYPES:
                        instance = self._create_instance(group, object_)
                        if instance is not None:
                            node.appendChild(instance)

                udp_extra = self._create_user_defined_property(object_)
                if udp_extra is not None:
                    node.appendChild(udp_extra)

                parent_node.appendChild(node)

                if utils.is_has_lod(object_):
                    sub_node = node
                    for lod in utils.get_lod_geometries(object_):
                        sub_node = self._write_lods(lod, sub_node, group)

                if node_type in ('chr', 'skin') and object_.parent \
                        and object_.parent.type == "ARMATURE":
                    armature = object_.parent
                    self._write_bone_list([utils.get_root_bone(armature)],
                                          object_, parent_node, group)

                    armature_physic = utils.get_armature_physic(armature)
                    if armature_physic:
                        self._write_bone_list(
                            [utils.get_root_bone(armature_physic)],
                            armature_physic, parent_node, group)
                else:
                    self._write_child_objects(object_, node, group)

        return parent_node
Exemplo n.º 2
0
    def _write_visual_scene_node(self, objects, parent_node, group):
        node_type = utils.get_node_type(group)
        for object_ in objects:
            if node_type == 'i_caf' and object_.type == 'ARMATURE':
                self._write_bone_list([utils.get_root_bone(
                    object_)], object_, parent_node, group)

            elif node_type == 'anm' and object_.type == 'MESH':
                prop_name = "{}{}".format(
                    object_.name, self._create_properties_name(
                        object_, group))
                node = self._doc.createElement("node")
                node.setAttribute("id", prop_name)
                node.setAttribute("name", prop_name)
                node.setIdAttribute("id")

                self._write_transforms(object_, node)

                udp_extra = self._create_user_defined_property(object_)
                if udp_extra is not None:
                    node.appendChild(udp_extra)

                parent_node.appendChild(node)

        return parent_node