peng3d/model.py
def create(self,obj,cache=False):
        """
        Initializes per-actor data on the given object for this model.
        
        If ``cache`` is set to True, the entity will not be redrawn after initialization.
        
        Note that this method may set several attributes on the given object, most of them starting with underscores.
        
        During initialization of vertex regions, several vertex lists will be created.
        If the given object has an attribute called ``batch3d`` it will be used, else it will be created.
        
        If the batch already existed, the :py:meth:`draw()` method will do nothing, else it will draw the batch.
        
        Memory leaks may occur if this is called more than once on the same object without calling :py:meth:`cleanup()` first.
        """
        obj._modeldata = {}
        
        data = obj._modeldata
        
        data["_model"]=self
        data["_modelcache"] = {}
        moddata = data["_modelcache"]
        
        # Model group, for pos of entity
        moddata["group"] = JSONModelGroup(self,data,obj)
        modgroup = moddata["group"]
        
        if not hasattr(obj,"batch3d"):
            obj.batch3d = pyglet.graphics.Batch()
            data["_manual_render"]=True
        
        # Vlists/Regions
        moddata["vlists"] = {}
        for name,region in self.modeldata["regions"].items():
            v = region.getVertices(data)
            vlistlen = int(len(v)/region.dims)
            
            if region.enable_tex:
                vlist = obj.batch3d.add(vlistlen,region.getGeometryType(data),JSONRegionGroup(self,data,region,modgroup),
                        "v3f/static",
                        "t3f/static",
                        )
            else:
                vlist = obj.batch3d.add(vlistlen,region.getGeometryType(data),modgroup,
                        "v3f/static",
                        )
            
            moddata["vlists"][name]=vlist
        
        self.setAnimation(obj,self.modeldata["default_animation"].name,transition="jump")
        
        self.data = data
        
        if not cache:
            self.redraw(obj)
def create(self,obj,cache=False):
        """
        Initializes per-actor data on the given object for this model.
        
        If ``cache`` is set to True, the entity will not be redrawn after initialization.
        
        Note that this method may set several attributes on the given object, most of them starting with underscores.
        
        During initialization of vertex regions, several vertex lists will be created.
        If the given object has an attribute called ``batch3d`` it will be used, else it will be created.
        
        If the batch already existed, the :py:meth:`draw()` method will do nothing, else it will draw the batch.
        
        Memory leaks may occur if this is called more than once on the same object without calling :py:meth:`cleanup()` first.
        """
        obj._modeldata = {}
        
        data = obj._modeldata
        
        data["_model"]=self
        data["_modelcache"] = {}
        moddata = data["_modelcache"]
        
        # Model group, for pos of entity
        moddata["group"] = JSONModelGroup(self,data,obj)
        modgroup = moddata["group"]
        
        if not hasattr(obj,"batch3d"):
            obj.batch3d = pyglet.graphics.Batch()
            data["_manual_render"]=True
        
        # Vlists/Regions
        moddata["vlists"] = {}
        for name,region in self.modeldata["regions"].items():
            v = region.getVertices(data)
            vlistlen = int(len(v)/region.dims)
            
            if region.enable_tex:
                vlist = obj.batch3d.add(vlistlen,region.getGeometryType(data),JSONRegionGroup(self,data,region,modgroup),
                        "v3f/static",
                        "t3f/static",
                        )
            else:
                vlist = obj.batch3d.add(vlistlen,region.getGeometryType(data),modgroup,
                        "v3f/static",
                        )
            
            moddata["vlists"][name]=vlist
        
        self.setAnimation(obj,self.modeldata["default_animation"].name,transition="jump")
        
        self.data = data
        
        if not cache:
            self.redraw(obj)
Initializes per-actor data on the given object for this model.
        
        If ``cache`` is set to True, the entity will not be redrawn after initialization.
        
        Note that this method may set several attributes on the given object, most of them starting with underscores.
        
        During initialization of vertex regions, several vertex lists will be created.
        If the given object has an attribute called ``batch3d`` it will be used, else it will be created.
        
        If the batch already existed, the :py:meth:`draw()` method will do nothing, else it will draw the batch.
        
        Memory leaks may occur if this is called more than once on the same object without calling :py:meth:`cleanup()` first.