Source

pygamekit / blendfile.pxi

Full commit


cdef extern from "gkUtils.h":
    gkString gkUtils_getFile "gkUtils::getFile"(gkString&)
    
cdef extern from "Loaders/Blender2/gkBlendFile.h":
    cdef cppclass gkBlendFile:
        gkScene* getMainScene()
    
cdef extern from "Loaders/Blender2/gkBlendLoader.h":
    cdef cppclass gkBlendLoader "gkBlendLoader::getSingleton":
        gkBlendLoader()
        gkBlendFile* loadFile(gkString&, int, gkString&, gkString&)
        

ONLY_ACTIVE_SCENE        = 1 << 0   # Load only the active scene found.
ALL_SCENES               = 1 << 1   # Load all scenes.
IGNORE_CACHE_FILE        = 1 << 2   # Load the blend file even if loaded.
CREATE_UNIQUE_GROUP      = 1 << 3   # Create unique resource group.
CREATE_PRIVATE_GROUP     = 1 << 4   # Create private resource group, so invisible in the global pool.

cdef class BlendFile:


    cdef gkBlendFile* bfile
    
    def __init__(self, filename = None, options = ONLY_ACTIVE_SCENE, scene = "", group = ""):
        
        if filename:
            self.load(filename, options, scene, group)

    def load(self, filename, options = ONLY_ACTIVE_SCENE, scene = "", group = "", seek = 0):
        
        self.bfile = gkBlendLoader().loadFile(gkUtils_getFile(gkString(filename)), options, gkString(scene), gkString(group))