コード例 #1
0
    def load(self, mesh_file):
        # load mesh
        md = MeshData.from_file(mesh_file)
        self.mesh = Mesh(md)

        # instantiate animations
        self.animations = [
            AnimationInstance(anim) for anim in md.animations
        ]
        self.current_anim_idx = -1
        self.current_anim = self.next_anim()

        # compile shaders
        vert_file = open('data/default.vert', 'rb')
        frag_file = open('data/default.frag', 'rb')
        sources = [
            ShaderSource.from_buffer(vert_file.read(), ShaderSource.VERTEX_SHADER),
            ShaderSource.from_buffer(frag_file.read(), ShaderSource.FRAGMENT_SHADER),
        ]
        vert_file.close()
        frag_file.close()

        # create and make active the shader program
        self.shader = Shader(*sources)
        self.shader.use()