当前位置: 首页>>代码示例>>Python>>正文


Python Surface.draw方法代码示例

本文整理汇总了Python中surface.Surface.draw方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.draw方法的具体用法?Python Surface.draw怎么用?Python Surface.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在surface.Surface的用法示例。


在下文中一共展示了Surface.draw方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Pool

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import draw [as 别名]
class Pool():
    '''
    A shallow pool with concentric ripples on its surface
    '''
    def __init__(   self,
                    camera,
                    scale=1.0,
                    tileSize=128,
                    tilesX=1,
                    tilesZ=1,
                    depth=30.0):
    
        self.depth = depth

        self.tileSize = tileSize
        self.tilesX = tilesX
        self.tilesZ = tilesZ

        self.camera = camera
        self.scale = scale
        
        self.surfaceShader = ShaderProgram.open('shaders/colour_by_height.shader')

        
        # Use the shallow pool ripple surface generator
        self.heightfield = Ripples(self.camera, self.tileSize)
                                           
        # The water surface
        self.surface = Surface( self.surfaceShader,
                                self.camera,
                                texture=None,
                                heightfield=self.heightfield,
                                tileSize=self.tileSize, 
                                tilesX=self.tilesX,
                                tilesZ=self.tilesZ,
                                scale=self.scale, 
                                offset=Vector3(0.0,self.depth,0.0))

    def setDepth(self, depth):
        self.surface.setDepth(self.depth)
    def tap(self, tapPosition):
        self.heightfield.tap(tapPosition)

    def draw(self,dt):
        self.surface.draw(dt)        
开发者ID:naxIO,项目名称:WaterCaustics,代码行数:47,代码来源:water.py

示例2: Ocean

# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import draw [as 别名]
class Ocean():
    def __init__(   self,
                    camera,
                    cubemap=None,
                    scale=1.0,
                    tileSize=128,
                    tilesX=1,
                    tilesZ=1,
                    depth=30.0,
                    waveHeight=3.125e-5,
                    wind=Vector2(64.0,128.0),
                    period=10.0,
                    photonScale=4.0,
                    photonIntensity=2.0):
                    
                    
        if cubemap:
            self.cubemapTexture = cubemap.texture
        else:
            self.cubemapTexture = None
            
        self.wind = wind                    # Ocean wind in X,Z axis
        self.waveHeight = waveHeight        # The phillips spectrum parameter
        self.oceanDepth = depth
        self.period = period                # Period of ocean surface anim
        self.drawSeaSurface = True
        self.drawSeaFloor = True
        self.enableCaustics = True
        self.photonIntensity = photonIntensity
        self.photonScale = photonScale
        
        self.tileSize = tileSize
        self.tilesX = tilesX
        self.tilesZ = tilesZ
        self.length = tileSize              # Ocean length parameter
        self.camera = camera
        self.scale = scale

        self.surfaceShader = shader.openfiles(  'shaders/ocean.vertex',
                                                'shaders/ocean.fragment')
        self.groundShader = shader.openfiles(   'shaders/oceanfloor.vertex',
                                                'shaders/oceanfloor.fragment')

        self.oceanFloorTexture = image.load('images/tiles.png').get_texture() 
        
        
        # Caustic texture
        self.causticTexture = image.DepthTexture.create_for_size(GL_TEXTURE_2D, 
                                                            self.tileSize, 
                                                            self.tileSize,
                                                            GL_RGBA)
        
        # Use Tessendorf FFT synthesis to create a convincing ocean surface.
        self.heightfield = Tessendorf(  self.tileSize,
                                        self.waveHeight, 
                                        self.wind,
                                        self.length,
                                        self.period)
                                           
        # The water surface
        self.surface = Surface( self.surfaceShader,
                                self.camera,
                                texture=self.oceanFloorTexture,
                                causticTexture=self.causticTexture,
                                cubemapTexture=self.cubemapTexture,
                                heightfield=self.heightfield,
                                tileSize=self.tileSize, 
                                tilesX=self.tilesX,
                                tilesZ=self.tilesZ,
                                scale=self.scale, 
                                offset=Vector3(0.0,self.oceanDepth,0.0))
                                
        # The caustics engine, uses the water surface to generate a caustic tex                      
        self.caustics = Caustics (  self.camera,
                                    self.surface,
                                    self.oceanDepth,
                                    self.causticTexture,
                                    self.photonScale,
                                    self.photonIntensity,
                                 )
        
        # The sea bed, an undisturbed mesh
        self.ground = Surface( self.groundShader,
                                self.camera,
                                texture=self.oceanFloorTexture,
                                causticTexture=self.causticTexture,
                                heightfield=None,
                                tileSize=1, 
                                tilesX=self.tilesX,
                                tilesZ=self.tilesZ,
                                scale=self.scale * self.tileSize, 
                                offset=Vector3(0.0,0.0,0.0))
                                
    def reloadShaders(self):
        from shader import FragmentShader, ShaderError, ShaderProgram, VertexShader
        
        def read_source(fname):
            f = open(fname)
            try:
                src = f.read()
#.........这里部分代码省略.........
开发者ID:naxIO,项目名称:WaterCaustics,代码行数:103,代码来源:water.py


注:本文中的surface.Surface.draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。