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


Python PNMImage.getXel方法代码示例

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


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

示例1: make_data

# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import getXel [as 别名]
  def make_data(self, hmapfile):
    # open heightmap for reading pixel data
    heightmap = PNMImage()
    heightmap.read(Filename(hmapfile))
    xs = heightmap.getXSize()
    ys = heightmap.getYSize()

    # generate data bi-dimensional array
    data = []
    for x in range(xs):
      data.append([])
      for y in range(ys):
        # set data dictionary properties
        # name
        name = "cell_" + str(x) + "_" + str(y)
        # height
        height = (heightmap.getXel(x, ys - y - 1)[0] * 10)

        if self.retro == True:
          if height < 1 :
            height = height / 5
            height = int(height)
        # c and rgb
        c = [random.random(), random.random(), random.random()]
        rgb = (int(c[0] * 255), int(c[1] * 255), int(c[2] * 255))
        # default texture
        texture = self.tiles[0]['tex']
        texturenum = 0
        score = self.tiles[0]['score']

        # from rgb we assign tex and score
        for n in range(len(self.tiles)):
          if rgb == self.tiles[n]['rgb']:
            texture = self.tiles[n]['tex']
            texturenum = n
            score = self.tiles[n]['score']
            break

        # set terrain data dictionary
        data[x].append({'name':name, 'h':height, 'c':c, 'rgb':rgb, 'tex':texture,
                        'texnum':texturenum, 'score':score})
    return data
开发者ID:asceth,项目名称:devsyn,代码行数:44,代码来源:terrain.py

示例2: GXOStar

# 需要导入模块: from pandac.PandaModules import PNMImage [as 别名]
# 或者: from pandac.PandaModules.PNMImage import getXel [as 别名]

#.........这里部分代码省略.........
			return p2d
		
		return None

	def _getObscured(self, color):
		# This originally looked for the radius of the light but that caused
		# assertion errors. Now I use the radius of the hdr model.
		bounds = self.starcard.getBounds()
		#print ("bounds=%s rad=%s"%(bounds,bounds.getRadius()))
		if not bounds.isEmpty():
			r = bounds.getRadius()
			# Setting the film size sets the field-of-view and the aspect ratio
			# Maybe this should be done with setAspectRation() and setFov()
			self.ortlens.setFilmSize(r * self.radius, r * self.radius)
			
			# Point the flarecamera at the sun so we can determine if anything
			# is obscurring the sun
			self.flarecamera.lookAt(self.baseNode)
			
			# Renders the next frame in all the registered windows, and flips
			# all of the frame buffers. This will populate flaretexture since
			# it's attached to the flarebuffer.
			# Save the rendered frame in flaredata
			base.graphicsEngine.renderFrame()
			self.flaretexture.store(self.flaredata)
			
			#print ("flaredata=%s | color=%s"%(self.flaredata.getXel(5,5), color))
			
			# Initialize the obscured factor
			obscured = 100.0
			color = VBase3D(color[0],color[1],color[2])
			for x in xrange(0,9):
				for y in xrange(0,9):
					if color.almostEqual(self.flaredata.getXel(x,y), self.threshold):
						obscured -=  1.0
		else:
			obscured = 0
		return obscured
	
	
	def _flareTask(self, task):
		#going through the list of lightNodePaths
		#for index in xrange(0, len(self.lightNodes)):
			
		pos2d = self._get2D(self.sunlight)
		#if the light source is visible from the cam's point of view,
		# display the lens-flare
		if pos2d:
			#print ("Flare visible")
			
			# The the obscured factor
			obscured = self._getObscured(self.suncardcolor)
			# Scale it to [0,1]
			self.obscured = obscured/100
			##print obscured
			
			# Length is the length of the vector that goes from the screen
			# middle to the pos of the light. The length gets smaller the
			# closer the light is to the screen middle, however, since
			# length is used to calculate the brightness of the effect we
			# actually need an inverse behaviour, since the brightness
			# will be greates when center of screen= pos of light
			length = math.sqrt(pos2d.getX()*pos2d.getX()+pos2d.getY()*pos2d.getY())
			invLength= 1.0-length*2
			# Subtract the obscured factor from the inverted distence and
			# we have a value that simulates the power of the flare
开发者ID:crempp,项目名称:psg,代码行数:70,代码来源:GXO.py


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