本文整理汇总了Python中panda3d.core.PNMImage.getGray方法的典型用法代码示例。如果您正苦于以下问题:Python PNMImage.getGray方法的具体用法?Python PNMImage.getGray怎么用?Python PNMImage.getGray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.PNMImage
的用法示例。
在下文中一共展示了PNMImage.getGray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __map_Topography
# 需要导入模块: from panda3d.core import PNMImage [as 别名]
# 或者: from panda3d.core.PNMImage import getGray [as 别名]
def __map_Topography(self, planet, model, pts=[]):
height_map = PNMImage()
height_map_path = "{}/maps/{}".format(planet.path, planet.height_map)
height_map.read(Filename(height_map_path))
_hu_size = height_map.getXSize()-1
_hv_size = height_map.getYSize()-1
radius = planet.radius
bottom = radius + planet.height_min
elev_range = planet.height_max - planet.height_min
_has_sea = "sea_level" in planet.__dict__
if _has_sea:
sea_level = planet.sea_level + planet.radius
if not pts: pts = model.read("vertex")
for pt in pts:
u, v = self.__get_Pt_Uv(pt, _hu_size, _hv_size)
height_val = height_map.getGray(u, v) ## watch when extending w colours.
height = bottom + elev_range*height_val
ratio = height / radius
pt *= ratio
# If planet has sea then raise vert to sea level.
if _has_sea:
len_pt = pt.length()
if len_pt <= sea_level:
ratio = sea_level/len_pt
pt *= ratio
model.modify("vertex", pts)