Ejemplo n.º 1
0
 def create(self, app):
     """
     creates gl resources of model.
     @param lights: list of gl_helper.light.Light instances
     """
     
     GLObject.create(self, app, self.lights)
     
     self.createDrawFunction()
     
     for l in self.lights:
         l.createGuard(app, self.lights)
     for s in self.segments:
         s.createGuard(app, self.lights)
     # TODO: VBO: create some bigger vbos for vbo segments
     
     self.postCreate()
Ejemplo n.º 2
0
 def create(self, app, lights):
     """
     create the shadow maps.
     """
     
     if self.getAttr("useShadowMap", False):
         type = self.getLightType()
         #kernel = ShadowMap.noKernel()
         #kernel = ShadowMap.kernel44()
         if type==Light.POINT_LIGHT:
             # TODO: SM: point light shadows
             raise NotImplementedError
         
         elif type==Light.DIRECTIONAL_LIGHT:
             # directional light needs scene frustum
             app.needFrustumPoints = True
             
             mapSize = 2048.0
             numSplits = 4
             
             self.shadowMapArray = ShadowMapArray(app, app.sceneCamera, mapSize)
             frustas = splitFrustum(app.sceneFrustum, numSplits, 0.75)
             
             for frustum in frustas:
                 camera = DirectionalShadowCamera( app, self, frustum, mapSize )
                 self.shadowMapArray.addShadowMap( DirectionalShadowMap( camera ))
             
         else: # spot light
             mapSize = 2048
             
             self.shadowMapArray = ShadowMapArray(app, app.sceneCamera, mapSize)
             
             camera = SpotShadowCamera(app, self)
             self.shadowMapArray.addShadowMap( SpotShadowMap( camera  ) )
     
     if self.shadowMapArray!=None:
         self.shadowMapArray.create(app)
     
     GLObject.create(self, app, lights)
Ejemplo n.º 3
0
 def create(self, app, lights):
     """
     call after configuration.
     currently only once callable because some vertex data
     calculations cannot get undone (face groups).
     """
     self.app = app
     self.enabledLights = range(len(lights))
     self.lights = lights
     
     self.hidden = False
     
     GLObject.create(self, app, lights)
     
     # material needs to get gl resources for textures
     if self.material != None:
         self.material.createGuard(app, lights)
     
     # splits up creation
     self.createResources()
     self.createResourcesPost()
     self.createShader()
     self.createDrawFunction()
     self.postCreate()
Ejemplo n.º 4
0
 def create(self, app, lights):
     for tex in self.textures:
         tex.create()
     GLObject.create(self, app, lights)