本文整理汇总了Python中surface.Surface.setHeightfield方法的典型用法代码示例。如果您正苦于以下问题:Python Surface.setHeightfield方法的具体用法?Python Surface.setHeightfield怎么用?Python Surface.setHeightfield使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类surface.Surface
的用法示例。
在下文中一共展示了Surface.setHeightfield方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Ocean
# 需要导入模块: from surface import Surface [as 别名]
# 或者: from surface.Surface import setHeightfield [as 别名]
#.........这里部分代码省略.........
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()
finally:
f.close()
return src
fsrc = read_source('shaders/ocean.fragment')
fshader = FragmentShader([fsrc])
vsrc = read_source('shaders/ocean.vertex')
vshader = VertexShader([vsrc])
self.surfaceShader = ShaderProgram(fshader, vshader)
self.surfaceShader.use()
fsrc = read_source('shaders/oceanfloor.fragment')
fshader = FragmentShader([fsrc])
vsrc = read_source('shaders/oceanfloor.vertex')
vshader = VertexShader([vsrc])
self.groundShader = ShaderProgram(fshader, vshader)
self.groundShader.use()
self.surface.setShader(self.surfaceShader)
self.ground.setShader(self.groundShader)
def setCausticPhotonIntensity(self, intensity):
self.photonIntensity = intensity
self.caustics.photonIntensity = self.photonIntensity
def setCausticPhotonScale(self, scale):
self.photonScale = scale
self.caustics.photonScale = self.photonScale
def setDepth(self, depth):
self.oceanDepth = depth
self.caustics.setDepth(self.oceanDepth)
self.surface.setDepth(self.oceanDepth)
def resetHeightfield(self):
'''
Recreate the heightfield engine with new initial parameters, this is
required for heightfield engines such as Tessendorf as lookup tables
are generated upon creation based on input paramters
'''
del self.heightfield
self.heightfield = Tessendorf( self.tileSize,
self.waveHeight,
self.wind,
self.length,
self.period)
self.surface.setHeightfield( self.heightfield)
def setWind(self, wind):
self.wind = wind
self.resetHeightfield()
def setWaveHeight(self, waveHeight):
self.waveHeight = waveHeight
self.resetHeightfield()
def draw(self,dt):
if self.drawSeaSurface:
self.surface.draw(dt)
if self.drawSeaFloor:
if self.enableCaustics:
self.caustics.update(dt)
self.ground.draw(dt)