Example #1
0
    def append_mesh(self,
                    root_path,
                    name,
                    mesh_path,
                    scale=None,
                    frame=None,
                    no_cache=None):
        """Append a mesh node to the group.

        Arguments:
            root_path {str} -- path to the group's root node
            name {str} -- node name within a group
            mesh_path {str} -- path to the mesh file on disk

        Keyword Arguments:
            scale {Vec3} -- mesh scale (default: {None})
            frame {tuple} -- local frame position and quaternion (default: {None})
            no_cache {bool} -- use cache to load a model (default: {None})
        """
        mesh = self.loader.loadModel(mesh_path, noCache=no_cache)
        if mesh_path.lower().endswith('.dae'):
            # converting from Y-up to Z-up axes when import from dae
            mesh.set_mat(Mat4.yToZUpMat())
        if scale is not None:
            mesh.set_scale(Vec3(*scale))
            if sum([s < 0 for s in scale]) % 2 != 0:
                # reverse the cull order in case of negative scale values
                mesh.set_attrib(CullFaceAttrib.make_reverse())
        self.append_node(root_path, name, mesh, frame)