本文整理汇总了Python中bravo.chunk.Chunk.get_skylight方法的典型用法代码示例。如果您正苦于以下问题:Python Chunk.get_skylight方法的具体用法?Python Chunk.get_skylight怎么用?Python Chunk.get_skylight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bravo.chunk.Chunk
的用法示例。
在下文中一共展示了Chunk.get_skylight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestLightmaps
# 需要导入模块: from bravo.chunk import Chunk [as 别名]
# 或者: from bravo.chunk.Chunk import get_skylight [as 别名]
class TestLightmaps(unittest.TestCase):
def setUp(self):
self.c = Chunk(0, 0)
def test_trivial(self):
pass
def test_boring_skylight_values(self):
# Fill it as if we were the boring generator.
for x, z in product(xrange(16), repeat=2):
self.c.set_block((x, 0, z), 1)
self.c.regenerate()
# Make sure that all of the blocks at the bottom of the ambient
# lightmap are set to 15 (fully illuminated).
# Note that skylight of a solid block is 0, the important value
# is the skylight of the transluscent (usually air) block above it.
for x, z in product(xrange(16), repeat=2):
self.assertEqual(self.c.get_skylight((x, 0, z)), 0xf)
def test_skylight_spread(self):
# Fill it as if we were the boring generator.
for x, z in product(xrange(16), repeat=2):
self.c.set_block((x, 0, z), 1)
# Put a false floor up to block the light.
for x, z in product(xrange(1, 15), repeat=2):
self.c.set_block((x, 2, z), 1)
self.c.regenerate()
# Test that a gradient emerges.
for x, z in product(xrange(16), repeat=2):
flipx = x if x > 7 else 15 - x
flipz = z if z > 7 else 15 - z
target = max(flipx, flipz)
self.assertEqual(self.c.get_skylight((x, 1, z)), target,
"%d, %d" % (x, z))
def test_skylight_arch(self):
"""
Indirect illumination should work.
"""
# Floor.
for x, z in product(xrange(16), repeat=2):
self.c.set_block((x, 0, z), 1)
# Arch of bedrock, with an empty spot in the middle, which will be our
# indirect spot.
for x, y, z in product(xrange(2), xrange(1, 3), xrange(3)):
self.c.set_block((x, y, z), 1)
self.c.set_block((1, 1, 1), 0)
# Illuminate and make sure that our indirect spot has just a little
# bit of illumination.
self.c.regenerate()
self.assertEqual(self.c.get_skylight((1, 1, 1)), 14)
def test_skylight_arch_leaves(self):
"""
Indirect illumination with dimming should work.
"""
# Floor.
for x, z in product(xrange(16), repeat=2):
self.c.set_block((x, 0, z), 1)
# Arch of bedrock, with an empty spot in the middle, which will be our
# indirect spot.
for x, y, z in product(xrange(2), xrange(1, 3), xrange(3)):
self.c.set_block((x, y, z), 1)
self.c.set_block((1, 1, 1), 0)
# Leaves in front of the spot should cause a dimming of 1.
self.c.set_block((2, 1, 1), 18)
# Illuminate and make sure that our indirect spot has just a little
# bit of illumination.
self.c.regenerate()
self.assertEqual(self.c.get_skylight((1, 1, 1)), 13)
def test_skylight_arch_leaves_occluded(self):
"""
Indirect illumination with dimming through occluded blocks only should
work.
"""
# Floor.
for x, z in product(xrange(16), repeat=2):
self.c.set_block((x, 0, z), 1)
# Arch of bedrock, with an empty spot in the middle, which will be our
# indirect spot.
for x, y, z in product(xrange(3), xrange(1, 3), xrange(3)):
self.c.set_block((x, y, z), 1)
self.c.set_block((1, 1, 1), 0)
# Leaves in front of the spot should cause a dimming of 1, but since
#.........这里部分代码省略.........